akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	int as,kl,o,n,m,hun,p;
	
	Scanner sc = new Scanner(System.in);
	public void solve() {	
n=sc.nextInt();
while(true) {
	n=n-1000;
	if(n<=0) {
		if(n==0) {
		System.out.println(n);
		break;
	}else {
		System.out.println(n*-1);
		break;
	}
	}
}
	}
	public static void main(String[] args) {
		new Main().solve();
	
	}
}

Measured memory_bytes: 35600
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n,r;
    n=sc.nextInt();
    r=sc.nextInt();
    if(n<10){
      System.out.print((r+100*(10-n)));
    }else{
      System.out.print(r);
    }
  }
}

Measured memory_bytes: 19924
#include<stdio.h>

int main(){
    char s[3] = {'\0','\0','\0'};
    scanf("%s",s);
    if(s[2] != '\0'){
        char a = s[0];
        s[0] = s[2];
        s[2] = a; 
    }
    printf("%s\n",s);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline int read()
{
    int x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-') t=-1,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return x*t;
}
int n;
int main ()
{
	n=read();
	cout<<3*n*n<<endl;
	return 0;
}


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

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

 typedef long long ll;
 const long long INF = 1LL << 60;

ll dp[100100][110];

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

    vector<int> h(n), v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> h[i] >> v[i];
    }

    for(int i = 0; i <= w; i++)
    {
      for(int j = 0; j <= n; j++)
      {
          dp[i][j] = 0;
      }
    }

    for(int i = 1; i <= w; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(i - h.at(j-1) >= 0) chmax(dp[i][j], (ll)(dp[i-h.at(j-1)][j-1] + v.at(j-1)));
            chmax(dp[i][j], dp[i][j-1]);
        }
    }

    cout << dp[w][n] << endl;


    return 0;
}

Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
//#define int 					ll
#define ios	    				ios_base::sync_with_stdio(false); cin.tie(0)
#define hell 					1000000007
#define inf 					9e18

// Data Structures //
#define ull 					unsigned long long
#define ll 						long long
#define p_q 					priority_queue
#define pii         			pair<ll,ll>
#define vi          			vector<ll>
#define vii         			vector<pii>
#define mi          			map<ll,ll>
#define mii         			map<pii,ll>
// Functions //
#define pb 						push_back
#define ppb						pop_back
#define all(a)      			(a).begin(),(a).end()
#define gcd(a,b)    			__gcd((a),(b))
#define lcm(a,b)    			((a)*(b)) / gcd((a),(b))
#define mp 						make_pair
#define bs						binary_search
#define lb 						lower_bound
#define ub						upper_bound
#define F						first
#define S						second
#define take(a,n)				for(ll i=0;i<n;i++) cin>>a[i];
#define dbg(x) 					cout << #x << " = " << x << '\n'
#define endl					"\n"
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

#define N  1000005

void solve()
{
	string s,t,u;
	ll n,m,k=0,cnt=0,mx=-hell,mn=hell;
	cin>>s>>t;
	m = s.size();
	n = t.size();
	ll dp[m+1][n+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j] = 1 + dp[i-1][j-1];
			}
			else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
		}
	}
	ll i=m,j=n;
	for(int k=0;k<=m+n;k++)
	{
		if(i==0||j==0) break;
		if(s[i-1]==t[j-1])
		{
			u.pb(s[i-1]);
			i--; j--;
		}
		else if(dp[i][j-1]>=dp[i-1][j])
		{
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
		{
			i--;
		}
	}
	reverse(u.begin(),u.end());
	cout<<u<<endl;
}


signed main()
{
	ios;
	ll n,tests=1,prev=0,i=0;

	while(tests--)
	{
		solve();
	}
	time
	return 0;
}


Measured memory_bytes: 74036
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int remain = a - b;
        int result = Math.max(0, c - remain);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val map = mutableMapOf<Char, Long>()
    val march = mutableListOf('M', 'A', 'R', 'C', 'H')
    for (i in march) {
        map[i] = 0L
    }
    for (i in 1..n) {
        val s = readLine()!!
        val first = s.first()
        if (first in march) map[first] = map[first]!! + 1
    }

    var count = 0L
    for (i in 0..2) {
        for (j in i + 1..3) {
            for (k in j + 1..4) {
                count += map[march[i]]!! * map[march[j]]!! * map[march[k]]!!
            }
        }
    }

    println(count)
}


Measured memory_bytes: 39712
#include <iostream>
#include<vector>
#define def 1000000007
using namespace std;

long long pow(long long a,long long p){
	long long ans=1;
	long long add=a;
	while(p){
		if((p&1)==1){
			ans*=add;
			if(ans>=def)ans%=def;
		}
		add*=add;
		if(add>def)add%=def;
		p>>=1;
	}
	return ans;
}

int main() {
	long long h,w,a,b;cin>>h>>w>>a>>b;
	long long ans=0;
	long long x,y;
	x=b+1;
	y=h-a;
//	cout<<'a'<<endl;
	while((x<=w)*(y>=1)){
		x++;
		y--;
	}
	x--;
	y++;
//	cout<<y<<' '<<x<<endl;
//	long long def=1;
//	for(int i=0;i<9;i++){
//		def*=10;
//	}
//	def+=7;
	vector<long long> xh(h+w),xhm(h+w);
	xh[0]=1;
	xhm[0]=1;
	long long fact=1;

	for(long long i=1;i<h+w;i++){
		fact*=i;
		if(fact>=def)fact%=def;
		xh[i]=fact;
		xhm[i]=pow(fact,def-2);
//		cout<<xh[i]<<' '<<xhm[i]<<endl;
	}
//	cout<<xh[3]*xhm[2]*xhm[1]<<endl;
//	long long t=1;
//	for(int i=0;i<def-2;i++){
//		t*=2;
//		if(def<=t)t%=def;
//	}
//	cout<<t<<endl;

	while((x>b)*(y<h-a+1)){
		long long add=xh[x+y-2]*xhm[y-1];
		add%=def;
		add*=xhm[x-1];
		add%=def;
		add*=xh[h-y+w-x];
		add%=def;
		add*=xhm[h-y];
		add%=def;
		add*=xhm[w-x];
		if(def<=add)add%=def;
		ans+=add;
		if(def<=ans)ans%=def;
		x--;
		y++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
typedef long long ll;
using namespace std;

const int MAX_N = 100001;
int dp[MAX_N];

int main() {
  int N; cin>>N;
  
  REP(i,MAX_N) dp[i] = N;
  dp[0] = 0;

  REP1(n,N) {
    for(int pow6=1; pow6<=n; pow6*=6) dp[n] = min(dp[n], dp[n-pow6]+1);
    for(int pow9=1; pow9<=n; pow9*=9) dp[n] = min(dp[n], dp[n-pow9]+1);
  }

  cout<<dp[N]<<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

// http://www.prefield.com/algorithm/dp/lcs.html
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s, t; cin >> s >> t;
  int s_sz = s.size(), t_sz = t.size();
  vector<vector<int> > dp(s_sz + 1, vector<int>(t_sz + 1, 0));
  vector<vector<int> > dp2(s_sz + 1, vector<int>(t_sz + 1, 0));
  REP(i, s_sz) REP(j, t_sz) {
    if (s[i] == t[j]) {
      dp[i+1][j+1] = dp[i][j] + 1;
      dp2[i+1][j+1] = 0;
    } else if (dp[i+1][j] < dp[i][j+1]) {
      dp[i+1][j+1] = dp[i][j+1];
      ++dp2[i+1][j+1];
    } else {
      dp[i+1][j+1] = dp[i+1][j];
      --dp2[i+1][j+1];
    }
  }
  string ans = "";
  for (int i = s_sz, j = t_sz; i > 0 && j > 0;) {
    if (dp2[i][j] > 0) --i;
    else if (dp2[i][j] < 0) --j;
    else {
      ans += s[i-1];
      --i;
      --j;
    }
  }
  reverse(ALL(ans));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 70912
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
def main():
    S = input()
    N = len(S)-1

    if S[0] == '?':
        dp = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    else:
        dp = [0,0,0,0,0,0,0,0,0,0,0,0,0]
        dp[int(S[0])] = 1

    for i in range(1,N):
        dppre = dp
        dp = [0] * 13

        if S[i] == '?':
            R = range(10)
        else:
            R = [int(S[i])]
        
        for j in range(13):
            for k in R:
                dp[(j * 10 + k) % 13 ] += dppre[j]
        for j in range(13):
            dp[j] %= MOD

    print(dp[5])
if __name__ == '__main__':
    main()

Measured memory_bytes: 44148
S = input()
result = 0
for i in range(len(S)//2):
  if S[i] != S[-1-i]:
    result += 1
A = S[:(len(S)-1)//2]
#print(A,result)
for i in range(len(A)//2):
  #print(S[i],S[-1])
  if A[i] != A[-1-i]:
    result += 1
B = S[(len(S)+2)//2:]
#print(B,result)
for i in range(len(B)//2):
  if B[i] != B[-1-i]:
    result += 1
print("Yes" if result == 0 else "No")

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int x = 100 * r + 10 * g + b;

  if (x % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (sc.nextInt() >= k) {
                count++;
            }
        }
        sc.close();
        System.out.println(count);
    }
}


Measured memory_bytes: 47904
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int a = sc.NextInt() - 1;
        int b = sc.NextInt() - 1;
        int c = sc.NextInt() - 1;
        int d = sc.NextInt() - 1;
        string s = sc.Next();

        bool ok = true;

        for (int i = a; i < c - 1; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
            {
                ok = false;
            }
        }

        for (int i = b; i < d - 1; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
            {
                ok = false;
            }
        }

        if (c > d)
        {
            bool tmpOk = false;

            for (int i = b; i <= d; i++)
            {
                if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
                {
                    tmpOk = true;
                }
            }

            if (!tmpOk)
            {
                ok = false;
            }
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

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

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

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        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()
        {
            _line = Console.ReadLine().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: 12384
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int Z = sc.nextInt();
    System.out.println(Z + " " + X + " " + Y);
  }
}

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

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

int main(){
  int a;
  cin >> a;
  cout << a+a*a+a*a*a<< endl;
  }

Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
//使い方　インスタンス化(頂点数)　uniteつなぐ(双方向注意) same判定
int main()
{
    int n;
    cin >> n;
    vector<ll> p;
    vector<ll> o;
    vector<ll> vec(n);
    vector<ll> vec1(n);
    for (int i = 0; i < n;i++){
        cin >> vec[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> vec1[i];
    }
    ll p_sum = 0;
    ll num = 0;
    for (int i = 0; i < n;i++){
        if(vec[i]>vec1[i]){
            o.push_back(vec[i] - vec1[i]);
        }
        if (vec[i] < vec1[i]){
            p_sum += (vec1[i] - vec[i]);
            num++;
        }
    }
    sort(o.begin(), o.end(), greater<ll>());
    if(p_sum==0){
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0;i<o.size();i++){
        num++;
        p_sum -= o[i];
        if(p_sum<=0){
            break;
        }
    }
    if(p_sum>0){
        cout << -1 << endl;
        return 0;
    }
    cout << num << endl;
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb push_back
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
 
void solve()
{
	int n, x, ans=0;
	vector<int> a;
	cin>>n;
	// F0R(i, n) {
	// 	cin>>x;
	// 	a.pb(x);
	// }
	if(n>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

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

#define int long long
int n;

int a[100010];
int b[100010];

signed main()
{
    cin >> n;

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

    // a > b ... a - b times
    // b < a ... b - a / 2 + (b - a % 2 == 0 ? 0 : 1)

    int res1 = 0,res2 = 0;
    int sum = 0;

    for (int i = 0; i < n;i++)
    {
        sum += b[i] - a[i];
        if(a[i] > b[i])
        {
            res1 += a[i] - b[i];
        }
        if(a[i] < b[i])
        {
            res2 += (b[i] - a[i]) / 2 + ((b[i] - a[i]) % 2 == 0 ? 0 : 1);
        }
    }
    if(res1 <= sum && res2 <= sum)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;


}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;

	int num[4];
	for (auto i = 0; i < 4; ++i)
	{
		num[3 - i] = N % 10;
		N /= 10;
	}


	string op = "+++";
	for (auto i = 0; i <= 7; ++i)
	{
		auto result = num[0];
		for (auto j = 0; j < 3; ++j)
		{
			if ((i & (1 << j)) != 0)
			{
				op[j] = '+';
				result += num[j + 1];
			}
			else
			{
				op[j] = '-';
				result -= num[j + 1];
			}
		}

		if (result == 7)
		{
			break;
		}
	}

	for (auto i = 0; i < 7; ++i)
	{
		if (i % 2 == 0)
		{
			cout << num[i / 2];
		}
		else
		{
			cout << op[i / 2];
		}
	}

	cout << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n+1),b(n);
	rep(i,n+1) cin >> a.at(i);
	rep(i,n) cin >> b.at(i);
	ll ans=0;
	rep(i,n){
		int k=min(b.at(i),a.at(i));
		ans+=k;
		b.at(i)-=k;
		if(b.at(i)>0){
			k=min(b.at(i),a.at(i+1));
			ans+=k;
			a.at(i+1)-=k;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
Mod = 10 ** 9 + 7

# 素因数分解(prime factorize)
def prime_factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

n = int(readline())

p_list = [0] * (n + 1)

for i in range(2, n + 1):
    arr = prime_factorize(i)
    for p, e in arr:
        p_list[p] += e

ans = 1
for j in p_list:
    if j >= 1:
        ans *= (j + 1)
        ans %= Mod
print(ans)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
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<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, M, X; cin >> N >> M >> X;
	vll C(N);
	vvll A(N, vll(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}

	ll B = 1<<N;
	ll minv = LLINF;
	for (int b = 0; b < B; b++) {
		ll cost = 0;
		vll par(M, 0);
		for (int i = 0; i < N; i++) {
			if ((b >> i) & 1) {
				cost += C[i];
				for (int j = 0; j < M; j++) {
					par[j] += A[i][j];
				}
			}
		}
		bool flag = true;
		for (int i = 0; i < M; i++) {
			if (par[i] < X) {
				flag = false;
			}
		}
		if (flag) {
			chmin(minv, cost);
		}
	}
	if (minv == LLINF) {
		cout << -1 << endl;
	} else {
		cout << minv << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3668
// Aizu Vol-5 0539: Pizza
// 2017.9.1 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<=(b)?(a):(b))

int p[100003]; int size;
int k[10003];

int cmp(int *a, int *b) { return *a - *b; }

int bsrch(int x)
{
	int m, l = 0, r = size;
    while (l < r) {
        m = (l + r) >> 1;
		if (p[m] == x) return 0;
		if (p[m] < x) l = m + 1; else r = m;
    }
	return MIN(x-p[l-1], p[l]-x); 
}

int main()
{
	int d, n, m, i, x;
	int final, ans;

	while (scanf("%d", &d) && d) {
		scanf("%d%d", &n, &m);
		p[0] = 0, size = n;
		for (i = 1; i < n; i++) scanf("%d", p+i);
		for (i = 0; i < m; i++) scanf("%d", k+i);
		qsort(p, n, sizeof(int), cmp);
		qsort(k, m, sizeof(int), cmp);
		final = p[n-1];
		for (ans = 0, i = 0; i < m; i++) {
			x = k[i];
			if (x >= final) ans += MIN(d-x, x-final);
			else ans += bsrch(x);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
#include <random>
#include <time.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint pow_kai(mint a, ll n){//aのn乗を計算します。
  mint x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

int main(){
  ll n;
  cin>>n;
  mint ans=pow_kai(10,n);
  ans-=pow_kai(9,n);
  ans-=pow_kai(9,n);
  ans+=pow_kai(8,n);
  cout<<ans<<endl;




}


Measured memory_bytes: 3632
def main():
    n = int(input())
    s = []
    for i in range(n):
        ss = input()
        s.append(ss)

    import collections
    cnt = collections.Counter(s)
    print('AC x ' + str(cnt['AC']))
    print('WA x ' + str(cnt['WA']))
    print('TLE x ' + str(cnt['TLE']))
    print('RE x ' + str(cnt['RE']))

if __name__=='__main__':
    main()


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

ll gcd(ll a, ll b) {
  return (!a || !b) ? 0 : ((a % b == 0) ? b : gcd(b, a % b));
}

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

// ====================================================================

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  ll l = v[0];
  for (int i = 1; i < n; i++) {
    l = lcm(l, v[i]);
    if (l > 3000000000) {  // 1つめがそもそもない、オーバーフロー対策
      cout << 0 << endl;
      return 0;
    }
  }

  if (l % 2) {  // 答えが整数にならない
    cout << 0 << endl;
    return 0;
  }

  bool can = true;
  for (int i = 0; i < n; i++) {
    if (l / 2 % v[i] == 0) {  // どれかの0.5倍で作れる数字が、どれかの整数倍で作れてしまう
      can = false;
    }
  }
  if (!can) {
    cout << 0 << endl;
    return 0;
  }

  cout << (m + l / 2) / l << endl;
}


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

int main() {
  int n, x;
  cin >> n >> x;

  vector<int> m(n);
  int ans = 0, min_m = 1000;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    min_m = min(min_m, m[i]);
    x -= m[i];
    ans++;
  }

  while (x >= min_m) {
    x -= min_m;
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	string s; CI s;
	int cnt = 0;
	REP(i, 3) {
		if (s[i] == 'o')cnt++;
	}

	CO 700 + cnt * 100 EN;

	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int n;
  char A[100];
  int S[100];
  int a,v;
  int p=0;

  while( scanf("%s", A) != EOF){ 
    // printf("%s\n",A);
    a = atoi(A);
    if(a!=0){
      S[p] = a;
      // printf("S[%d] = %d\n",p,S[p]);
      p++;
    }else{
      if(A[0]=='+')
	S[p-2] = S[p-2] + S[p-1];
      if(A[0]=='-')
	S[p-2] = S[p-2] - S[p-1];
      if(A[0]=='*')
	S[p-2] = S[p-2] * S[p-1];
      // printf("S[%d] = %d\n",p-2,S[p-2]);
      p--;
    }
  }
  printf("%d\n",S[0]);
  return 0;
}

Measured memory_bytes: 1828
_ = input()
l = map(int, input().split())

def chk_valid(i):
    if i % 2 == 1:
        return False
    if i % 3 == 0 or i % 5 == 0:
        return False
    return True

f = filter(chk_valid, l)
print('APPROVED' if len(list(f)) == 0 else 'DENIED')

Measured memory_bytes: 38256
#include <iostream>

#include<vector>

using namespace std;


int main()
{

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {

        int a;
        cin >> a;

        if (a % 2 == 0) {
            if ((a % 3 != 0) && (a % 5 != 0)) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 10000000000000000


int main() {
	
	long long ans  = -Inf;
	
	int N;
	cin>>N;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	

	long long t = 0;
	for(int i=1;i<N;i+=2){
		t += A[i];
	}
	ans = max(ans,t);
	
	vector<vector<long long>> dp(N+1,vector<long long>(2+(N%2),-Inf));
	int K = 2+(N%2);
	dp[0][0] = A[0];
	dp[1][1] = A[1];
	if(N%2==1)dp[2][2] = A[2];
	for(int i=0;i<N;i++){
		for(int j=0;j<K;j++){
			if(dp[i][j]<=-Inf)continue;
			if(i==N-1){
				dp[N][j] = max(dp[N][j],dp[i][j]);
			}
			if(i+2==N&&j+1<K){
				dp[N][j+1] = max(dp[N][j+1],dp[i][j]);
			}
			if(i+2<N){
				dp[i+2][j] = max(dp[i+2][j],dp[i][j]+A[i+2]);
			}
			for(int k=0;k<2;k++){
				if(i+3+k==N&&j+2+k<K){
					dp[N][j+2+k] = max(dp[N][j+2+k],dp[i][j]);
				}
				if(i+3+k<N&&j+1+k<K){
					dp[i+k+3][j+1+k] = max(dp[i+3+k][j+1+k],dp[i][j]+A[i+3+k]);
				}
			}
		}
	}

	
	ans = max(ans,dp.back().back());
		
		
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 15668
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<numeric>

using namespace std;

int main() {
    unsigned long long ans=0;
	long double buf=0;
	unsigned long long N;
	unsigned long long u, d;
	cin >> N;
	cin >> buf;
	u = (unsigned long long)buf;
	d = (unsigned long long)(buf * 1000) - u * 1000;
	u = N * u;
	d = (N * d) / 1000;
	ans = u + d;
	//cout << u << endl;
	//cout << d << endl;
	cout << ans;
}

Measured memory_bytes: 3736
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) { //WOOOOOOO AtCoder is HELPING!!!!!!!!!!
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		ArrayList<Integer> times = new ArrayList<Integer>();
		long cap = input.nextLong();
		long extra = input.nextLong();
		long ans = 0;
		for (int i = 0; i < N; i++) {
			times.add(input.nextInt());
		}
		Collections.sort(times);
		while (times.size()>0) {
			int curSTART = times.get(0);
			int curPpl = 1;
			int curTime = curSTART;
			times.remove(new Integer(times.get(0)));
			while (curTime <= curSTART+extra&&curPpl<=cap) {
				if (times.size()==0) break;
				int x = times.get(0);
				curTime = x;
				curPpl++;
				if (curTime <= curSTART+extra&&curPpl<=cap) times.remove(new Integer(times.get(0)));
				else break;
			}
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 60432
import java.util.*;

public class Main
    {
        public static void main (String[] args)
            {
                Scanner scanner = new Scanner(System.in);
                List<Integer> list = new ArrayList<Integer>();

                try
                    {
                        for (int i = 0; i < 3; i++)
                            {
                                list.add(scanner.nextInt());
                            }

                        Collections.sort(list);

                        for (int i = 0; i < 3; i++)
                            {
                                System.out.print(list.get(i));

                                if (i == 2)
                                    {
                                        System.out.println();
                                    }
                                else
                                    {
                                        System.out.print(" ");
                                    }
                            }
                    }
                catch (InputMismatchException e)
                    {
                        System.out.println("整数を入力してください");
                        e.printStackTrace();
                    }
            }
    }

Measured memory_bytes: 17172
import java.util.Scanner;

public class Main {

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

		if(n ==m) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35868
n = gets.chomp.to_i
a = Array.new(n)
cnt = 0
a_hi = 0
b_hi = 0
ab_hi = 0
n.times {|i|
  a[i] = gets.chomp
  a[i].each_char.with_index do |a_char,k|
    if a_char == 'A' and a[i][k+1] == 'B'
      cnt += 1
    end
  end
  if a[i][0] == 'B' and a[i][-1] == 'A'
    ab_hi += 1
  elsif a[i][0] == 'B'
    b_hi += 1
  elsif a[i][-1] == 'A'
    a_hi += 1
  end
}
if ab_hi == 0 
  puts cnt + [a_hi,b_hi].min
else
  if a_hi + b_hi == 0
    puts ab_hi - 1 + cnt
  else
    puts cnt + ab_hi + [a_hi,b_hi].min
  end
end


Measured memory_bytes: 2812
def main():
    S = input()
    S = S[::-1]
    _T = 'dreamer', 'dream', 'eraser', 'erase'
    T = []
    for t in _T:
        T.append(t[::-1])
    i = 0
    while 1:
        temp = []
        bool = True
        for t in T:
            if S[:len(t)] == t:
                S = S[len(t):]
                bool = False
        if bool:
            break
    if len(S) > 0:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <bitset>
#include <limits>
typedef unsigned long long int ll;
const ll INF = 876543210987654321;
const int MOD = 1000000007;
#define REP(i,n) for(int i=0;i<n;++i)
#define pd(x) cout<<x<<endl

using namespace std;

//vector<vector<int>>(h, vector<int>(w, f));
vector<int> u;
int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	ll n, ans=0,x,nm=0;
	cin >> n;
	vector<ll>a(100010,0);

	REP(i, n) {
		cin >>x;
		a[x+1]++;
	}
	for(int i=1;i<100010;++i) {
		ans = max(a[i] + a[i + 1] + a[i-1], ans);
	}
	cout << ans;
	
	

	return 0;


}

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

bool str_checker(string root_str, string target_str) {
    for (int i = 0; i < root_str.size(); ++i) {
        if (target_str == root_str.substr(i, target_str.size())) {
            return true;
        }
    }

    return false;
}

int main() {
    string s, p;
    cin >> s >> p;

    s += s;

    if (!str_checker(s, p)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node{
	int key;
	Node*left,*right,*parent;
};

Node *root, *NIL;

void insert(int k){
	Node *y=NIL;
	Node *x=root;
	Node *z;
	
	z=(Node*)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(z->key<x->key)
			x=x->left;
		else 
			x=x->right;
	}
	z->parent=y;
	if(y==NIL)
		root=z; //very important
	else{
		if(z->key<y->key)
			y->left=z;
		else
			y->right=z;
	}
}


void inorder(Node *u){
	if(u==NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node*u){
	if(u==NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

Node* find(Node*u, int k){
	while(u!=NIL && k!=u->key){
		if(k<u->key) u=u->left;
		else u=u->right;
	}
	return u;
}

int main(){
	//freopen("data.in","r",stdin);
	int n,x;
	string com;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>com;
		if(com[0]=='f'){
			scanf("%d",&x);
			Node*t=find(root,x);
			if(t!=NIL) printf("yes\n");
			else printf("no\n");
		}else if(com=="insert"){
			scanf("%d",&x);
			insert(x);
		}
		else if(com=="print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
		return 0;
}

Measured memory_bytes: 21996
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int K, S, count = 0;
    cin >> K >> S;
    for (int x = 0; x <= K; ++x) {
        for (int y = 0; y <= K; ++y) {
            int z = S - x - y;
            if (0 <= z && z <= K) ++count;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    

    int n;
    cin>>n;
    string s;
    map<string, int> m;
    rep(i,n){
        cin>>s;
        m[s]++;
    }
    vector<pair<int,string>> ans;
    irep(i,m){
        ans.pb(mp((-1)*i->second,i->first));
    }
    Sort(ans);
    rep(i,ans.size()){
        if(ans[i].first!=ans[0].first)break;
        cout<<ans[i].second<<endl;
    }
    
}


Measured memory_bytes: 29296
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int k,i;
    cin>>k;
    cin>>s;
    if(s.length()<=k)
    cout<<s<<endl;
    else
    {for(i=0;i<k;i++)
    {
        cout<<s[i];
    }
    cout<<"..."<<endl;
    }
}

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

int main() {

	int S, h, m, s, a ;


	cin >> S;

	h = S / 3600;
	m = S % 3600 / 60;
	s = (S - h * 3600) % 60;



	cout << h << ":" << m << ":" << s << endl;

	

	return 0;

	


}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);



int main() {
    ll n, x;
    cin >> n >> x;

    vector<ll> donuts(n);
    ll m_donut = INF;
    rep(i, n) {
        ll m;
        cin >> m;
        donuts[i] = m;
        cmin(m_donut, m);
    }

    ll lim = accumulate(donuts.begin(), donuts.end(), 0ll);
    ll nokori = x - lim;
    ll nokori_do = nokori / m_donut;
    cout << n + nokori_do << endl;

}

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

int main(void) {
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

  int m = a[0], mi = 0;
  for (int i = 0; i < 5; i++)
  {
    if (a[i] % 10 != 0) {
      m = a[i];
      mi = i;
    }
  }

  for (int i = 0; i < 5; i++) {
    if (a[i] % 10 != 0 && m % 10 > a[i] % 10){
      m = a[i]; mi = i;
    }
  }

  int sum = 0;
  for (int i = 0; i < 5; i++) {
    if (mi != i){
      if (a[i] % 10 == 0)
        sum += a[i];
      else {
        sum += (a[i] - a[i] % 10) + 10;
      }
      //cout <<"a" <<sum << endl;
    }
  }
  cout << sum + m << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  vector<int> A(N-1);
  rep(i,N-1){
    cin >> A.at(i);
    ans.at(A.at(i)-1) ++; 
  }
  rep(i,N){
    cout << ans.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 4792
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

int main(){
  int n,q;
  cin>>n>>q;
  
  dsu d(n);
  rep(i,q){
    int c,u,v;
    cin>>c>>u>>v;
    if(c==0) d.merge(u,v);
    if(c==1) cout<<d.same(u,v)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	
	string S;
	cin >> S;

	string kotae;
	rep(i, (S.size() + 1) / 2) {
		kotae += S[i * 2];
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n, x, count = 0;

		while (true) {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		}
	}
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    string s;
    cin >> n;
    cin >> s; 
    int m=s.size();
    rep(i,m) {
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    cout << s << endl;
     
    return 0;   
}

Measured memory_bytes: 3576
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
const int INF = 1 << 30;
using namespace std;
#define pp pair<int,int>
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
int main() {
	string s[3], ss;
	TFOR(i, 3) {
		cin >> s[i];
		ss.push_back(s[i][0]);
	}
	cout << ss << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m, t;
	cin >> n >> m >> t;
	ll ans = t - 2 * m * n;
	vi v(n); cin >> v;
	FOR(i, 1, n)
	{
		if (v[i] - v[i - 1] <= m * 2) ans += 2 * m - (v[i] - v[i - 1]);
	}
	if (t - v[n - 1] < m) ans += m - (t - v[n - 1]);
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(M),B(M);
    vector<ll> C(N);

    rep(i,M){
        cin >> A[i] >> B[i];
        C[A[i]-1]++;
        if(B[i]<N)C[B[i]]+=INF;
    }
    ll cnt=0;
    ll ans=0;
    rep(i,N){
        if(C[i]>=1)cnt+=C[i];
        if(cnt>=M && cnt<INF)ans++;
    }
    //ans++;

    cout<< ans << endl;
}

Measured memory_bytes: 2560
def f(x):
    now = 0
    for i in range(n):
        now += (a[i]-1)//x

    return now <= k

n, k = map(int, input().split())
a = list(map(int, input().split()))
ng = 0
ok= int(1e9)
while ok - ng > 1:
    x = (ok + ng) // 2
    if f(x):
        ok = x
    else:
        ng = x

print(ok)

Measured memory_bytes: 30848
from collections import deque

A = deque(list(input()))
B = deque(list(input()))
C = deque(list(input()))

def extract(s):
    if s == "a":
        S = A
    if s == "b":
        S = B
    elif s == "c":
        S = C
    if len(S) == 0:
        print(s.upper())
        exit()
    t = S.popleft()
    extract(t)

extract("a")

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

int main(){
  	long N, A, B, ans;
  	cin >> N >> A >> B;
  	if(N%(A+B)<A){
    	cout << N/(A+B)*A+N%(A+B) << endl;
    }else{
    	cout << (N/(A+B)+1)*A << endl;
    }
	return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int h, w;
    cin >> h >> w;
    char ary[h][w] = {};
    rep(i, h) {
        rep(j, w) { cin >> ary[i][j]; }
    }

    // 処理
    // 出力
    for (int i = 0; i < h; i++) {
        int cnt = 0;
        for (int k = 0; k < 2; k++) {
            for (int j = 0; j < w; j++) {
                cout << ary[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256