akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int ans,n,d;
int main()
{
    cin>>n>>d;
    while(n--){
        int x,y;
        cin>>x>>y;
        double t = sqrt(pow(x,2)+pow(y,2));
        if(t <= d){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;

void Main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        sort(ALL(s));
        ++mp[s];
    }

    ll ans = 0;
    for(auto& p : mp) {
        int s = p.second;
        ans += (ll)s * (s - 1) / 2;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 11264
import bisect
def index(alist, x):
    i = bisect.bisect_left(alist, x)
    if i != len(alist) and alist[i] == x:
        return i
    raise ValueError

n, m = map(int, input().split())
p, y = [0] * m, [0] * m
year_list = [[] for _ in range(n)]
for i in range(m):
    p[i], y[i] = map(int, input().split())
    year_list[p[i] - 1].append(y[i])
for j in range(n):
    year_list[j].sort()
for i in range(m):
    x = index(year_list[p[i] - 1], y[i]) + 1
    print(str(p[i]).zfill(6) + str(x).zfill(6))

Measured memory_bytes: 24064
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
N=int(input())
P = list(map(int, input().split()))

count = 1
min = P[0]

for i in range(1,N):
    if min > P[i]:
        count+=1
        min = P[i]

print(count)

Measured memory_bytes: 100940
#include <stdio.h>

int main(void)
{
    int n;
    char s[3];
    int l, r, next;
    int m;
    int i;

    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }

        l = r = 0;
        next = 1;
        m = 0;
        for (i = 0; i < n; i++){
            scanf("%s", s);
            if (s[0] == 'l'){
                if (s[1] == 'u'){
                    l = 1;
                }
                else {
                    l = 0;
                }
            }
            else {
                if (s[1] == 'u'){
                    r = 1;
                }
                else {
                    r = 0;
                }
            }
            if (l == next && r == next){
//                printf("<%d %d>step\n", l,r);
                m++;
                if (next == 0){
                    next = 1;
                }
                else {
                    next = 0;
                }
            }
            else {
//                printf("<%d %d>\n", l,r);
            }
        }
        printf("%d\n", m);
    }
    
    return (0);
}



Measured memory_bytes: 2064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
namespace AtCoder_Beginner_Contest_127
{
    class Program
    {
        static public List<int> SIn() { return ReadLine().Split().Select(int.Parse).ToList(); }
        public struct BCpair
        {
            public long B;
            public long C;
            public BCpair(long b, long c) { B = b; C = c; }
        }
        static void Main(string[] args)
        {
            var NM = SIn();
            var N = NM[0];//N個
            var M = NM[1];//M回
            var Ai = SIn();
            var BCplst = new List<BCpair>(M+N);
            foreach(var a in Ai)
            {
                BCplst.Add(new BCpair(1, a));
            }
            for (var i = 0; i < M;++i)
            {
                var BC = SIn();
                BCplst.Add(new BCpair(BC[0], BC[1]));
            }
            //降順にする
            BCplst.Sort((l, r) => (int)(r.C - l.C));
            long sum = 0;
            long num = 0;
            foreach (var bc in BCplst)
            {
                var hosei = bc.B;
                if (N < hosei + num)
                {
                    hosei = N - num;
                    if (hosei <= 0)
                        break;
                }
                sum += bc.C * hosei;
                num += hosei;
            }
            WriteLine(sum);
        }
    }
}


Measured memory_bytes: 30556
#include<bits/stdc++.h>
using namespace std;
#define N 500000
#define S 1000000001
 
void merge(int *, int, int ,int);
void mergeSort(int *, int, int);
int cnt;

int main(){
  int n,s[N];
  cin>>n;
  for(int i=0;i<n;i++) cin>>s[i];
  mergeSort(s,0,n);
   
  for(int i=0;i<n-1;i++)cout<<s[i]<<' ';
  cout<<s[n-1]<<endl<<cnt<<endl;
  return 0;
}
 
void merge(int *a,int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int l[N], r[N];
   
  for(int i=0;i<n1;i++) l[i]=a[left + i];  
  for(int i=0;i<n2;i++) r[i]=a[mid + i];
  l[n1]=S;
  r[n2]=S;
  int x=0,y=0;

  for(int k=left;k<right;k++)
    if(l[x]<=r[y]){
      a[k]=l[x];
      x++;
      cnt++;
    }
    else{
      a[k]=r[y];
      y++;
      cnt++;
    }
}
 
void mergeSort(int *a, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
}



Measured memory_bytes: 7000
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string ss;
    cin >> ss;
    cin >> n;

    deque<char> aa;

    bool rev = false;

    rep (i, 0, ss.size()) aa.emplace_back(ss[i]); 

    for (i = 0; i < n; ++i) {
        cin >> c;
        if (c == 2) {
            cin >> f;
            char cc;
            cin >> cc;
            if (f == 1) {
                if (rev) aa.emplace_back(cc);
                else aa.push_front(cc);
            } else {
                if (rev) aa.push_front(cc);
                else aa.emplace_back(cc);
            }
        } else {
            if (rev == false) rev = true;
            else rev = false;
            //reverse(aa.begin(), aa.end());
        }
    }

    if (rev) reverse(aa.begin(), aa.end());

    rep (j, 0, aa.size()) cout << aa[j];
    cout << endl;

    return 0;
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

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

    vector<vector<int>> ans(H, vector<int>(W));

    int cnt = 0;
    int a_i = 0;
    rep(i, H) {
        rep(j, W) {
            int nj = j;
            if (i % 2) nj = W - 1 - j;
            ans[i][nj] = a_i + 1;
            cnt++;

            if (cnt == a[a_i]) {
                a_i++;
                cnt = 0;
            }
        }
    }

    rep(i, H) {
        rep(j, W) {
            cout << ans[i][j];
            if (j != W - 1) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include<stdio.h>
#define N 100001

int partition(int *,int,int );

int A[N];
int main(){
  
  int n,i,k;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  k=partition(A,0, n);
  for(i=0;i<k-1;i++)
    printf("%d ",A[i]);
  printf("[%d] ",A[k-1]);
  for(i=k;i<n-1;i++)
    printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  return 0;
}



int partition(int *A,int p, int r)
{
  int x,i,j,tmp;
  x=A[r-1];
  
  for(j=p;j<r;j++){

    if(A[j]<=x){
      tmp=A[i];
  A[i]=A[j];
  A[j]=tmp;

  i++;
  
    }}
  return i;
}




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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll n;
	cin >> n;
	string ans = "";
	while(n != 0){
		int now = n % 26; 
		if(n % 26 == 0){
			n /= 26;
			n--;
			now = 26;
		} else {
			n /= 26;
		}
		char c = 'a' + (now - 1);
		ans.push_back(c);
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}


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

int main()
{
    int a, b, c;
    int count;
    cin >> a >> b >> c;
    
    while (a <= b)
    {
        if (c % a == 0)
            count++;
        a++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3116
H, W = gets.split(' ').map(&:to_i)

ary = Array.new(H, Array.new(W, nil) )

[*0..H-1].each{|i|
  ary[i] = gets.chomp.split('').dup
}

# debug
#[*0..H-1].each{|i|
#  puts ary[i].join('')
#}

# 最初から黒いマスの数
init_black = 0
[*0..(H-1)].each{|i|
  [*0..(W-1)].each{|j|
#    p ary[i][j]
    init_black += 1 if ary[i][j] == '#'
  }
}
#p init_black

# スタートから順に数字で塗りつぶしていく
ary[0][0] = 1


# 多めに回すためのカウンタ
countdown_to_break = 100

maxstep = 100000
[*0..(maxstep-1)].each{|istep|
  update = false

#p istep
#p update

  # 右側
  [*0..(H-1)].each{|i|
    [*0..(W-2)].each{|j|
      if ary[i][j].class == Fixnum then
        tmp = ary[i][j+1]
        if tmp == '.' or (tmp.class == Fixnum and tmp > (ary[i][j] + 1)) then
          ary[i][j+1] = ary[i][j] + 1
          update = true
        end
      end
    }
  }

  # 下側
  [*0..(H-2)].each{|i|
    [*0..(W-1)].each{|j|
      if ary[i][j].class == Fixnum then
        tmp = ary[i+1][j]
        if tmp == '.' or (tmp.class == Fixnum and tmp > (ary[i][j] + 1)) then
          ary[i+1][j] = ary[i][j] + 1
          update = true
        end
      end
    }
  }

  # 左側
  [*0..(H-1)].each{|i|
    [*1..(W-1)].each{|j|
      if ary[i][j].class == Fixnum then
        tmp = ary[i][j-1]
        if tmp == '.' or (tmp.class == Fixnum and tmp > (ary[i][j] + 1)) then
          ary[i][j-1] = ary[i][j] + 1
          update = true
        end
      end
    }
  }

  # 上側
  [*1..(H-1)].each{|i|
    [*0..(W-1)].each{|j|
      if ary[i][j].class == Fixnum then
        tmp = ary[i-1][j]
        if tmp == '.' or (tmp.class == Fixnum and tmp > (ary[i][j] + 1)) then
          ary[i-1][j] = ary[i][j] + 1
          update = true
        end
      end
    }
  }

#  p ary[-1][-1]
  if ary[-1][-1].class == Fixnum then
    countdown_to_break -= 1
    break if countdown_to_break == 0
  end

#  p update
  if (not update) and countdown_to_break == 100 then
    puts '-1'
    exit
  end
}

# 全マス - 最短ステップ数 - 最初から黒いマスの数, がスコア

puts H*W - ary[-1][-1] - init_black

Measured memory_bytes: 4348
int printf();
int scanf();
void *malloc ();

int main ()
{
    int h;
    int w;
    char *s;
    scanf("%d %d", &h, &w);
    s = malloc(w + 9);
    h = h + 1;
    while ((h = h - 1)) {
        scanf("%s", s);
        printf("%s\n%s\n", s, s);
    }

    return 0;
}


Measured memory_bytes: 128
M = 10**9
S = int(input())
q, r = divmod(S, M)
x1, y1 = 0, 0
if r == 0:
    x2, y2, x3, y3 = M, 0, 0, q
else:
    x2, y2, x3, y3 = M, M - r, 1, q + 1
print(x1, y1, x2, y2, x3, y3)

Measured memory_bytes: 3060
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)
#define frei freopen("input.txt","r",stdin)

const ll mod=1e9+7;
const ll maxn=1e3+10,maxp=10110;

ll x,k,d,ans;

int main(){
	FAST_IO;
	cin>>x>>k>>d;
	x=abs(x);
	if(k<=(x/d)){
		ans=x-(k*d);
	}else{
		k-=(x/d);
		if(k%2){
			ans=abs(x-((x/d)*d)-d);
		}else{
			ans=x-((x/d)*d);
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  const int max = 1000000;
  int isPrime[max] = {1, 1, 0};
  int i = 2;
  int n, count;

  while(i < max) {
    while(isPrime[i] != 0) {
      i++;
    }
    for(n = 2; n*i < max; n++) {
      isPrime[n*i] = 1;
    }
    i++;
  }

  while(cin >> n) {
    count = 0;
    for(n; n > 0; n--) {
      if(isPrime[n] == 0) count++;
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 5072
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
LL H,W;
LL N;
LL x[100000],y[100000];
LL x_[100000],y_[100000];
void solve(){
    sort(x,x+N);
    sort(y,y+N);
    vector<PLL>V;
    if(N&1){
        V.PB(PLL(x[N/2],y[N/2]));
    }
    else{
        V.PB(PLL(x[N/2],y[N/2]));
        V.PB(PLL(x[N/2-1],y[N/2]));
        V.PB(PLL(x[N/2],y[N/2-1]));
        V.PB(PLL(x[N/2-1],y[N/2-1]));
    }
    LL mic=100000000000000000;
    LL mix,miy;

    REP(i,V.size()){
        LL xym=0;
        LL sum=0;
        REP(j,N){
            LL xd=max(V[i].F,x_[j])-min(V[i].F,x_[j]);
            LL yd=max(V[i].S,y_[j])-min(V[i].S,y_[j]);

            sum+=(xd+yd)*2;
            xym=max(xym,xd+yd);
        }
        if(mic>=sum-xym){
            if(mic==sum-xym&&mix!=V[i].F&&mix<V[i].F)continue;
            if(mic==sum-xym&&miy!=V[i].S&&miy<V[i].S)continue;
            mic=sum-xym;
            mix=V[i].F;
            miy=V[i].S;
        }
    }

    cout<<mic<<endl;
    cout<<mix<<" "<<miy<<endl;
}


int main(){
    cin>>W>>H;
    cin>>N;
    REP(i,N){
        cin>>x[i]>>y[i];
        x_[i]=x[i];
        y_[i]=y[i];
    }
    solve();
    return 0;
}

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N = il();
  ll first = false;
  rep(i, N){
    ll a = il();
    if (a % 2 == 1) first = true;
  }

  cout << ( first ? "first" : "second" ) << endl;

  
}

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

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<ll> a(n), ans;
	for(ll &x : a)
		cin >> x;
	sort(a.rbegin(), a.rend()); 
	for(int i=0; i<n; ++i) {
		if(!i)
			ans.push_back(a[i]);
		else {
			ans.push_back(a[i]);
			ans.push_back(a[i]);
		}
	}
	ll s=0;
	for(int i=0; i<n-1; ++i)
		s+=ans[i];
	cout << s << "\n";
}


Measured memory_bytes: 8944
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int,int> pii;

inline int dist(const pii &p, const pii &q){
	return abs(p.first - q.first) + abs(p.second - q.second);
}

int main(){
	const int INF = 1000000000;
	int w, h, x;
	char ch;
	while(scanf("%d%d", &w, &h), w){
		map<int,vector<pii> > mp;
		map<int,vector<pii> >::iterator it1, it2;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(scanf("%d", &x) == 1){
					mp[x].push_back(pii(i, j));
				}
				else{
					ch = getchar();
					if(ch == 'S'){
						mp[0].push_back(pii(i, j));
					}
					else if(ch == 'G'){
						mp[INF].push_back(pii(i, j));
					}
				}
			}
		}

		vector<int> dp1(1, 0), dp2;
		it1 = it2 = mp.begin();
		while(++it2 != mp.end()){
			dp2.assign(it2->second.size(), INF);
			for(int i = 0; i < it1->second.size(); ++i){
				pii p1 = it1->second[i];
				for(int j = 0; j < it2->second.size(); ++j){
					pii p2 = it2->second[j];
					dp2[j] = min(dp2[j], dp1[i] + dist(p1, p2));
				}
			}
			dp1.swap(dp2);
			++it1;
		}
		printf("%d\n", dp1[0]);
	}
}

Measured memory_bytes: 1288
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
while(1){
int i,j,r,c,cnt,ans=0,sum,l;
static int t[10][10000];
scanf("%d%d",&r,&c);
if(r==0&&c==0)return 0;
for(i=0;i<r;i++){
for(j=0;j<c;j++){
scanf("%d",&t[i][j]);
}
}
for(l=0;l<(1<<r);l++){
sum=0;
for(j=0;j<c;j++){
cnt=0;
for(i=0;i<r;i++){
cnt+=(t[i][j]==((l>>i)&0x01));
}
sum+=max(r-cnt,cnt);
}
ans=max(ans,sum);
}
printf("%d\n",ans);
}
return 0;
}



Measured memory_bytes: 3508
N,a,b=map(int,input().split())

if (b - a)%2 == 0:
  ans = int((b - a)//2)
else:
  ans4 = int(int(a) + int((b-a-1)//2))
  ans5 = int(int(N-b+1) + int((b-a-1)//2))
  ans = int(min(ans4,ans5))
  
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

const int MAX_V = 2501;
const int MAX_E = 5001;

struct edge {
  int from, to, cost;
};

// 辺
edge es[MAX_E];
// 最短距離
int d[MAX_V];
int V, E;
int P;

vector<int> to[2501];
vector<int> rto[2501];
bool ok[2501];
bool rok[2501];

void dfs(int s) {
  if (ok[s]) {
    return;
  }
  ok[s] = true;
  for (int i = 0; i < to[s].size(); i++) {
    dfs(to[s][i]);
  }
}

void rdfs(int s) {
  if (rok[s]) {
    return;
  }
  rok[s] = true;
  for (int i = 0; i < rto[s].size(); i++) {
    rdfs(rto[s][i]);
  }
}

bool bellman_ford(int s) {
  fill(d, d + V, INF);
  d[s] = 0;

  for (int i = 0; i < V - 1; i++) {
    for (int j = 0; j < E; j++) {
      edge e = es[j];
      if (d[e.from] == INF) {
        continue;
      }
      if (ok[e.from] && rok[e.from]) {
        d[e.to] = min(d[e.to], d[e.from] + e.cost);
      }
    }
  }

  for (int j = 0; j < E; j++) {
    edge e = es[j];
    if (d[e.from] == INF) {
      continue;
    }
    if (d[e.from] + e.cost < d[e.to]) {
      if (ok[e.from] && rok[e.from]) {
        return false;
      }
    }
  }

  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> V >> E >> P;
  for (int i = 0; i < E; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    es[i] = edge{a, b, P - c};
    to[a].push_back(b);
    rto[b].push_back(a);
  }

  // 0からの経路があるか
  dfs(0);
  // V-1への経路があるか
  rdfs(V - 1);

  bool flag = bellman_ford(0);
  if (!flag) {
    cout << -1 << endl;
    return 0;
  }

  int ans = max(-d[V - 1], 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int m = scan.nextInt();
			if(n == 0 && m == 0){
				break;
			}
			int[] p = new int[n];
			int sum = 0;
			for(int i = 0;i < n;i++){
				p[i] = scan.nextInt();
				sum += p[i];
			}
			Arrays.sort(p);
			for(int i = m-1;i < n;i+=m){
				sum -= p[n-1-i];
			}
			System.out.println(sum);			
		}
	}
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M, A, B; cin >> N >> M >> A >> B;
  VI tmp;
  REP(i,N){
	int x; cin >> x;
	if(x < A) break;
	tmp.PB(x);
  }

  int ans = SZ(tmp);
  if(N - SZ(tmp) < M){
	for(int i=SZ(tmp)-1;i>=0;--i){
	  if(tmp[i] > B) break;
	  --ans;
	}
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
    ll n,i,s=0;
    vector<long>v;
    cin>>n;
    while(n--)
    {
        cin>>i;
        v.pb(i);
        sort(v.begin(),v.end());
    }
    for(i=0;i<v.size()-1;i++)
    {
        s=s+v[i];
    }
    if(v[v.size()-1]<s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

x = gets.to_i

puts x == 0 ? "1" : "0"


Measured memory_bytes: 14420
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(LDBL_DIG);
    cout << fixed;
    ld n, k;
    ld prob = 0;
    cin >> n >> k;
    for(int i = 1; i < min(n + 1, k); i++)
    {
        int x = ceil(log2(k) - log2(i));
        prob += pow(0.5, x)/n;
    }
    if(n >= k)
    {
        prob += (n - k + 1)/n;
    }
    cout << prob;

    return 0;
}


Measured memory_bytes: 512
from collections import deque

r, c = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
maze = [list(input()) for i in range(r)]

sy -= 1
sx -= 1
gy -= 1
gx -= 1

# キューを使って解く
# キューはdeque([])で定義し，popleft()で取り出す。

def find_shortest():
    # たどり着くまでにかかった回数をいれる多重リスト。
    d = [[float("inf")] * c for i in range(r)]
    # 1ノード降りるときにforで回せるようリスト化しておく
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    ddx = [-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2]
    ddy = [2,1,0,-1,-2,2,1,-1,-2,2,-2,2,1,-1,-2,2,1,0,-1,-2]

    # 接したポイントを取り込む用のqueを定義
    que = deque([])
    queq = deque([])
    # スタート地点をqueに加える。探索の際はqueから取り出すループを回すので最初だけ先に入れておく
    que.append((sy,sx))
    queq.append((sy,sx))
    # スタートからスタートにかかる距離は0なのでinfを0にかえる。
    d[sy][sx] = 0


    while que or queq:

        # queがあるかぎり続ける
        while que:
            # queから座標を取り出す。
            p = que.popleft()
            queq.append(p)
            # 取り出した点がゴールなら終了
            if p[0] == gy and p[1] == gx:
                key = 1
                break
            #　それ以外の時は，接している点を4方向順に取得。一つずつ処理する。
            for i in range(4):
                nx = p[0] + dx[i]
                ny = p[1] + dy[i]

                # 新しく取得した座標に対しての処理
                # 迷路内に存在する座標であり，壁ではなく，まだ通ったことがなくdがinfの点なら処理する = 新しく取得した道候補の1つ
                if 0 <= nx < r and 0 <= ny < c and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                    # 道候補をqueに加える。
                    que.append((nx, ny))
                    # その道候補への経路までにかかった経路は加えなくて良い。
                    d[nx][ny] = d[p[0]][p[1]]
        while queq:
            p = queq.popleft()
            #　ワープを使う。
            for i in range(20):
                nx = p[0] + ddx[i]
                ny = p[1] + ddy[i]

                # 新しく取得した座標に対しての処理
                # 迷路内に存在する座標であり，壁ではなく，まだ通ったことがなくdがinfの点なら処理する = 新しく取得した道候補の1つ
                if 0 <= nx < r and 0 <= ny < c and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                    # 道候補をqueに加える。
                    que.append((nx, ny))
                    # その道候補への経路までにかかった経路は加える。
                    d[nx][ny] = d[p[0]][p[1]]+1
    if d[gy][gx] != float('inf'):
        return d[gy][gx]
    else:
        return -1

ans = find_shortest()
print(ans)



Measured memory_bytes: 142728
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        String[] s = {"1", "1", "1", "2", "1", "2", "1", "5", "2", "2", "1", "5", "1", "2", "1", "14", "1", "5", "1", "5", "2", "2", "1", "15", "2", "2", "5", "4", "1", "4", "1", "51"};
        System.out.println(s[k-1]);


    }
}

Measured memory_bytes: 22100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,q;cin>>n>>q;
    int x,y;
    vector<vector<int>> g(n,vector<int>(0,0));
    rep(i,n-1){
        cin>>x>>y;
        x--,y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    vector<int> cnt(n,0);
    rep(i,q){
        cin>>x>>y;
        cnt[x-1] +=y;
    }
    vector<int> ans(n,-1);
    int num=1;
    queue<int> que;
    que.emplace(0);
    ans[0]=cnt[0];

    while(num<n){
        x=que.front();
        que.pop();
        for(auto z:g[x]){
            if(ans[z]>-1) continue;
            ans[z]=ans[x]+cnt[z];
            num ++;
            que.emplace(z);
        }    
    }
    rep(i,n-1) cout<<ans[i]<<" ";
    cout<<ans[n-1]<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 17328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int B = count(all(S), '#'), W = 0, ans = INT_MAX;
    ans = N - W - B;
    rep(i, N)
    {
        if (S[i] == '.')
        {
            W++;
        }
        else
        {
            B--;
        }
        ans = min((i + 1 - W) + (N - (i + 1)) - B, ans);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
    
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] A = in.nextInt(new int[n]);
        int maxMask = (int)Math.pow(2,n);
        HashSet<Integer> okNumber = new HashSet<>();
        int mask=1;
        int fullsum = 0;
        for(int i=0; i<n; i++) {
        	fullsum += A[i];
        }
        okNumber.add(fullsum);
        
        LOOP1:
        for(int m : in.nextInt(new int[in.nextInt()])) {
        	if(okNumber.contains(m)){
        		out.println("yes");
        		continue;
        	}
        	for(; mask<maxMask/2; mask++) {
        		int sum=0;
        		for(int i=0; i<n; i++) {
        			if(((1<<i)&mask) != 0){
        				sum += A[i];
        			}
        		}
        		okNumber.add(sum);
        		okNumber.add(fullsum - sum);
        		if(m == sum || m == fullsum - sum){
            		out.println("yes");
            		continue LOOP1;
        		}
        		
        	}
        	out.println("no");
        }
        out.flush();
    }
    
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s;
  for (int i = 0; i < h; i++)
  {
    string buf;
    cin >> buf;
    s.push_back(buf);
  }

  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      char cnt = '0';
      if (s.at(i).at(j) == '.')
      {

        if (i - 1 >= 0 && j - 1 >= 0)
        {
          if (s.at(i - 1).at(j - 1) == '#')
          {
            cnt++;
          }
        }
        if (i - 1 >= 0)
        {
          if (s.at(i - 1).at(j) == '#')
          {
            cnt++;
          }
        }
        if (i - 1 >= 0 && w > j + 1)
        {
          if (s.at(i - 1).at(j + 1) == '#')
          {
            cnt++;
          }
        }
        if (j - 1 >= 0)
        {
          if (s.at(i).at(j - 1) == '#')
          {
            cnt++;
          }
        }
        if (w > j + 1)
        {
          if (s.at(i).at(j + 1) == '#')
          {
            cnt++;
          }
        }
        if (h > i + 1 && j - 1 >= 0)
        {
          if (s.at(i + 1).at(j - 1) == '#')
          {
            cnt++;
          }
        }
        if (h > i + 1)
        {
          if (s.at(i + 1).at(j) == '#')
          {
            cnt++;
          }
        }
        if (h > i + 1 && w > j + 1)
        {
          if (s.at(i + 1).at(j + 1) == '#')
          {
            cnt++;
          }
        }
        s.at(i).at(j) = (char)cnt;
      }
    }
  }
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cout << s.at(i).at(j);
    }
    cout << endl;
  }
}


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

int main() {
  long long n, m, d;
  cin>>n>>m>>d;
  double p;
  if (d > 0) {
    p = (double)((n-d) * 2) / (n*n);
  } else {
    p = 1.0 / n;
  }
  printf("%.9lf", p*(m-1));
}

Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
const int INF=mod;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<int, int>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,k,n) for(int i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)


//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////

int main(){
  string s; cin >> s;
  int N = s.size();
  vector<int> point;
  rep(i, N - 1){
    if(s[i] == 'R' && s[i + 1] == 'L') point.pb(i); 
  }

  int cnt = 1;
  int next_point = point[0];
  int pre_point = 0;
  vector<int> res(N);

  rep(i, N){
    if(s[i] == 'R'){
      res[next_point + (next_point - i) % 2]++;
    }
    else{
      res[pre_point - (i - pre_point) % 2]++;
    }

    if(i == next_point){
      pre_point = next_point + 1;
      if(cnt < point.size()) next_point = point[cnt];
      cnt++;
    }
  }

  rep(i, N) cout << res[i] << " ";
  cout << endl;
}

Measured memory_bytes: 1280
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (v[i] > v[j]) {
				ans += K * (K + 1) / 2;
				ans %= MOD;
			}
			else if (v[i] < v[j]) {
				ans += (K)*(K - 1) / 2;
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int s[6],ans=0,m=10000;
    for(int i=0;i<5;i++){
        cin>>s[i];
        if(s[i]%10==0){
            ans=ans+s[i];
        }
        else {
            m=min(m,s[i]%10);
            ans=ans+10+(s[i]-s[i]%10);
            }
    }
    if(m==10000)m=10;
    ans=ans-10+m;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int d;
  cin>>d;

  vector<ll> p(26);
  rep(i,26) {
    cin>>p[i];
  }


  vector<vector<ll>> q(d,vector<ll>(26));
  rep(i,d) {
    rep(j,26) {
      cin>>q[i][j];
    }
  }

  ll pre=0;
  vector<int> r(26,0);
  rep(i,d-5){
    ll ans=-INF;
    ll memo;
    rep(j,26){
      ll sum=pre;
      auto last=r;
      sum+=q[i][j];
      last[j]=i+1;
      rep(k,26){
        sum-=6*p[k]*(i+1-last[k]);
      }
      if(sum>ans) {
        memo=j;
        chmax(ans,sum);
      }
    }
    cout << memo+1 << endl;
    pre=ans;
    r[memo]=i+1;
  }

  ll answer=-INF;
  ll A,B,C,D,E;
  vector<int> zen(5);
  rep(i,26){
    rep(j,26){
      rep(k,26){
        rep(l,26){
          rep(m,26){
            zen[0]=i;
            zen[1]=j;
            zen[2]=k;
            zen[3]=l;
            zen[4]=m;

            ll sum=0;
            auto last=r;
            rep(n,5){
              sum+=q[d-5+n][zen[n]];
              last[zen[n]]=d-5+n+1;
              rep(o,26){
                sum-=p[o]*(d-5+n+1-last[o]);
              }
            }

            if(sum>answer) {
              A=zen[0];
              B=zen[1];
              C=zen[2];
              D=zen[3];
              E=zen[4];
            }
            chmax(answer,sum);

          }
        }
      }
    }
  }

  cout << A+1 << endl;
  cout << B+1 << endl;
  cout << C+1 << endl;
  cout << D+1 << endl;
  cout << E+1 << endl;
  
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>


using namespace std;

int main(int, char**){
    int tmp;
    stack<int> st;
    while(cin >> tmp){
	if(tmp == 0) {
	    cout << st.top() << endl;
	    st.pop();
	}
	else{
	    st.push(tmp);
	}
    }
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cmath>
#define R 6378.1
#define PI 4*atan(1.0)
#define deg PI/180
using namespace std;
int main(){
	double a,b,c,d;
	while(cin>>a>>b>>c>>d){
		if(a==-1&&b==-1&&c==-1&&d==-1)break;
		double theta = acos(cos(a*deg)*cos(c*deg)*cos((d-b)*deg) + sin(a*deg)*sin(c*deg));
		cout<<round(R*theta)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  for (ll i = 10; i >= 0; i--) {
    if (pow(2, i) <= N) {
      cout << ll(pow(2, i)) << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
	string S;
	cin >> S;
	int total = 0;
	int n = 0;
	string T = "ATCG";

	int ans = 0;
	int now = 0;
	for (int i = 0; i < S.size(); i++) {
		bool isATCG = false;
		for (int j = 0; j < T.size(); j++) {
			if (S[i] == T[j]) 	isATCG = true;
		}
		if (!isATCG) now = 0;
		else {
			now++;
			ans = max(now, ans);
		}

	}

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




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

/// input macro
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
///
/// # Example
///
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! eprintln (
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}

fn main() {
    input! {
        n: usize,
        d: [i32; n],
    }

//    let min: i32 = *d.iter().min().unwrap();
//    let max: i32 = *d.iter().max().unwrap();

    let mut d = d;
    d.sort();
    let k0 = d[d.len() / 2 - 1] + 1;
    let k1 = d[d.len() / 2];
    debug!(d);
    debug!(k0, k1);

    let mut ans = k1 - k0 + 1;
//    for k in min - 1..max + 1 {
//        let arc: usize = d.iter().filter(|&x| *x >= k).count();
//        if arc == d.len() / 2 { ans += 1 }
//    }

    println!("{}", ans);
}



Measured memory_bytes: 4476