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

typedef long long ll;
 
int main(){
  ll x, y;
  cin >> x >> y;
  if(x+y<=1ll){
    cout << "Brown" << endl;
    return 0;
  }
  if(abs(x-y)<=1){
    cout << "Brown" << endl;
  }else{
    cout << "Alice" << endl;
  }
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int N;
cin >> N;
vi p(N);
rep(i,N) {
    cin >> p[i];
    p[i]--;
}

int cur = 0;
int ans = 0;
rep(i,N) {
    if(p[i] != i) {
        ans += (cur+1)/2;
        cur = 0;
    }
    else cur++;
}
ans += (cur+1)/2;
cout << ans << endl;
return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> vec(2, vector<int>(N));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
        cin >> vec.at(i).at(j);
    }
  }

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < (i+1); j++) {
      A.at(i)+=vec.at(0).at(j);
    }
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      B.at(i)+=vec.at(1).at(j);
    }
  }
  
  int count=0;
  for (int i = 0; i < N; i++) {
    count=max(count,A.at(i)+B.at(i));
  }

  cout << count << endl;
}

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

int main()
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int time = ((H2*60)+M2) - ((H1*60)+M1);
    cout << time-K << endl;
    return 0;
}

Measured memory_bytes: 3620
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 1e5 + 10;
vector < int > g[maxN];
int clr[maxN];
void dfs(int v, int p) {
    for (int to : g[v]) {
        if (to == p) continue;
        clr[to] = clr[v] ^ 1;
        dfs(to, v);
    }
}
int k;
int val[maxN];
int tp[2];
void bad() {
    cout << "No";
    exit(0);
}
bool used[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i < n   ; i++) {
        int a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs(1, -1);
    cin >> k;
    memset(val, -1, sizeof val);
    int shft = -1;
    priority_queue < pair < int, int > > pq;
    for (int i = 1; i <= k; i++) {
        int x, y;
        cin >> x >> y;
        if (shft != -1 && shft != (clr[x] ^ (y % 2))) bad();
        shft = clr[x] ^ (y % 2);
        val[x] = y;
        pq.push({-val[x], x});
    }
    while (!pq.empty()) {
        auto it = pq.top();
        pq.pop();
        int v = it.second;
        for (int p : g[v]) {
            if (val[p] == -1) {
                val[p] = val[v] + 1;
                pq.push({-val[p], p});
            }
            else {
                if (abs(val[p] - val[v]) != 1) bad();
            }
        }
    }
    cout << "Yes\n";
    for (int i = 1; i <= n; i++) cout << val[i] << '\n';
    return 0;
}

Measured memory_bytes: 12156
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMOD = 998244353;

if __name__ == "__main__":
    # sys.stdin = open("input.txt","r")  # <<<  ^o^  Comment this line  ^_^  >>>
    h1, m1, h2, m2, k = get_ints()
    if h2 < h1:
        h2 = 24 + h2
    min1 = h1 * 60 + m1
    min2 = h2 * 60 + m2
    print(min2 - min1 - k)


# #############################################################################
'''
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
>>> DO NOT PLAGIARISE.
TESTCASES:
'''

Measured memory_bytes: 62024
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define LLINF (long long)1e18
#define NMAX 8
#define MMAX 200
#define MOD (long long)(1e9+7)
using namespace std;

// コメントアウトするとdb_printf()を実行しない
// #define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> p;
typedef long long ll;

ll N,M,K,A,B,C,D,E;
int dp[NMAX][MMAX] = {};
std::vector<int> x, v;

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

ll ans = 1LL;

bool canMakeSpace(std::vector<int> V, int i){
    // check first i toads can make space for xx[i]
    // for (int j = 0; j < V.size(); ++j)
    // {
    //     cout << V[j] << " ";
    // }
    // cout << endl;
    for (int ii = 0; ii < i; ++ii)
    {
        if (V[ii] < 2 * ii)
        {
            // cout << "failure.\n";
            return false;
        }
    }
    return true;
}

void solve(){
    // 解答アルゴリズム
    std::vector<int> interval;
    for (int i = 0; i < x.size()-1; ++i)
    {
        interval.push_back(x[i+1] - x[i]);
    }
    do
    {
        db_printf("seq: ");
        for(auto vv: v){
            db_printf("%d ", vv);
        }
        db_printf("\n");

        std::vector<int> xx = x;
        bool failed = false;

        for(auto vv: v){
            int index = distance(xx.begin(), find(xx.begin(), xx.end(), x[vv]));
            if (canMakeSpace(xx, index))
            {
                // toad vv can reach goal
                xx.erase(xx.begin() + index);
            }else
            {
                // db_printf("failed\n");
                failed = true;
                break;
            }
        }
        if (!failed)
        {
            ans++;
        }
    } while (next_permutation(v.begin(), v.end()));

}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    cout << ans << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    // ios::sync_with_stdio(false);

    Fill(dp, -1);

    scanf("%lld", &N);
    std::vector<int> v;
    int k=0;
    for (int i = 1; i <= N; ++i)
    {
        int x;
        scanf("%d", &x);
        v.push_back(x);
        k++;
        if (x < 2*k - 1)
        {
            // printf("delete k=%d\n", k);
            ans = ans * k % MOD;
            k--;
            v.erase(v.begin() + k);
        }
    }
    for (int i = 1; i <= v.size(); ++i)
    {
        ans = ans * i % MOD;
    }
    answer();

    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

	char a[55], b[55];

int main(){
	int i = 0, j = 0;
	
	scanf("%s %s", a, b);

	int tamA= strlen(a);
	int tamB= strlen(b);

	while(i < tamA && j < tamB){
		printf("%c", a[i]);
		++i;
		printf("%c",b[j]);
		++j;
	}

	while (i < tamA){
		printf("%c", a[i]); 
		++i;
	}	

	while (j < tamB){
		printf("%c",b[j]);
		++j;
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 128
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

int arr[maxn];
int main(){
	migmig;
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		arr[x]++;
	}
	for(int i=1;i<=n;i++){
		arr[i]+=k;
		arr[i]-=q;
	}
	
	for(int i=1;i<=n;i++){
		if(arr[i]>0){
			cout<<"Yes"<<endl;
		}else cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 1024
N,M,X,Y = map(int, input().split())
Xx = [int(x) for x in input().split()]
Yy = [int(x) for x in input().split()]

def f():
    mxx = max(Xx)
    mny = min(Yy)
    for z in range(Y, X, -1):
        if mxx < z and z <= mny:
            return "No War"
    return "War"
print(f())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string O, N;
  cin>>O>>N;
  int a=0;
  int b=0;
  while(a<O.size()-1){
      cout<<O[a]<<N[a];
      a++;
  }
  if(O.size()!=N.size()){
    cout<<O[a];
  }else{
    cout<<O[a]<<N[a];
  }
  cout<<endl;
  return 0;
}

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

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

// 全てを c 以下にするのに必要な回数
bool is_larger(long long c, long long K, vector<long long>& A)
{
    int N = A.size();
    long long cnt = 0;
    REP(i, N){
        cnt += (A[i]-1)/c;
        if(cnt > K) return true;
    }
    return false;
}

int main()
{
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];

    long long l = 1, r = 1e+9;
    while(l+1 < r){
        long long c = (l+r)/2;
        if(is_larger(c, K, A)) l = c;
        else r = c;
    }
    if(is_larger(l, K, A)) cout << r << endl;
    else cout << l << endl;

    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define MAX_N 100005
using namespace std;
typedef pair<int,int> P;
P par[MAX_N];

void init(int n){
  for(int i=0;i<n;i++)
    par[i]=P(i,0);
}

P find(int x){
  if(par[x].first==x)return P(x,0);
  P r=find(par[x].first);
  return par[x]=P(r.first,par[x].second+r.second);
}

void unite(int x,int y,int cost){
  P r1=find(x);
  P r2=find(y);
  if(r1.first==r2.first)return;
  par[r1.first]=P(r2.first,r2.second-r1.second+cost);
}

bool same(int x,int y){return find(x).first==find(y).first;}

int n,m,a,b,cost;
char c;

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    init(n);
    rep(i,m){
      cin>>c>>a>>b;
      if(c=='!'){
	cin>>cost;
	unite(b-1,a-1,cost);
      }else{
	if(!same(a-1,b-1))cout<<"UNKNOWN"<<endl;
	else cout<<find(b-1).second-find(a-1).second<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4900
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int A, B; cin >> A >> B;
    rep(i, 0, 1010) {
        int tax_8 = i * 0.08;
        int tax_10 = i * 0.1;
        if (tax_8 == A && tax_10 == B) {
            cout << i << endl;
            exit(0);
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
a = [int(_) for _ in input().split()]
cnt_a =0
cnt_b=0
for i in range(len(a)):
  if a[i] <x:
    cnt_a +=1
  else:
    cnt_b+=1
print(min(cnt_a,cnt_b))

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

int main(void) {
    int n[4];

    for(int i=0; i<4; i++) {
        scanf("%d", &n[i]);
    }

    sort(n, n+4); 
    int m[4] = {1, 4, 7, 9};
    int flag=1;
    for(int i=0; i<4; i++) {
        if(n[i] != m[i]) flag=0;
    }

    if (flag) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  long double deg_m = m * 6;
  long double deg_h = h * 30 + m * 0.5;
  long double deg = abs(deg_m - deg_h);
  long double ans = sqrt(a * a + b * b - 2 * a * b * cos(deg * M_PI / 180));
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 4180
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n,q;
string s;
vector<pair<char,int>> query;

bool checkL(int pos){
  char now_c = s[pos];
  rep(i,q){
   if(query[i].first == now_c){
     pos += query[i].second;
     now_c = s[pos];
     if(pos == 0) return true; //一番左まで行ったらtrue
   }
  }
  return false; //一番左まで行けなかったらfalse
}
bool checkR(int pos){
  char now_c = s[pos];
  rep(i,q){
   if(query[i].first == now_c){
     pos += query[i].second;
     now_c = s[pos];
     if(pos == n+1) return true; //一番右まで行ったらtrue
   }
  }
  return false; //一番右まで行けなかったらfalse
}

int main(){
  cin >> n >> q >> s;
  s = 'a' + s + 'a';
  rep(i,q){
    char t,d; cin >> t >> d;
    int move;
    if(d=='L') move = -1;
    else move = 1;
    query.push_back({t,move});    
  }
  
  int l = 0, r = n+1;
  while(r-l>1){
    int c = (l+r)/2;
    if(!checkL(c)) r = c;
    else l = c;
  }
  int left_lim = l;
  l = 0, r = n+1;
  while(r-l>1){
    int c = (l+r)/2;
    if(checkR(c)) r = c;
    else l = c;
  }
  int right_lim = r;
  //printf("left=%d right=%d\n",left_lim,right_lim);
  
  cout << n- (left_lim + 1) - (n - right_lim) << endl;
  return 0;
}

Measured memory_bytes: 3768
from itertools import accumulate
def a():
    return map(int,input().split())
n,m,q=a()
s=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    x,y=a()
    s[n-x][y-1]+=1
def f(s):
    for i in range(len(s)):
        s[i]=list(accumulate(s[i]))
f(s)
s=list(zip(*s))
f(s)
for i in range(q):
    x,y=a()
    print(s[y-1][n-x])

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


int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N;
	cin >> N;
	vector<int> h(N + 1);
	for (int i = 0; i < N; ++i) cin >> h[i + 1];

	vector<int> dp(N + 5, (int)1e9 + (int)1e5);
	dp[0] = dp[1] = 0;
	for (int i = 2; i <= N; ++i) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		if (i - 2) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N] << endl;

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
  cin>>A[i];
  }
  int count=0;
    for(int i=1;i<n-1;i++){
    if(A[i-1]<A[i]&&A[i+1]>A[i]||A[i-1]>A[i]&&A[i]>A[i+1]){
    count++;
    }
    }
  cout<<count<<endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var N = NM[0];
            var M = NM[1];
            var hn = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var anss = new bool[N];
            for(var i=0;i<M;i++)
            {
                var tmp = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
                if (hn[tmp[0] - 1] == hn[tmp[1] - 1])
                {
                    anss[tmp[0] - 1] = true;
                    anss[tmp[1] - 1] = true;
                }
                else if(hn[tmp[0]-1]< hn[tmp[1]-1])
                {
                    anss[tmp[0] - 1] = true;
                }
                else
                {
                    anss[tmp[1] - 1] = true;
                }
            }
            Console.WriteLine(anss.Count(b=>!b));
        }
    }
}

Measured memory_bytes: 33284
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int gcd(int a ,int b){
  if(b>a){
    swap(a,b);
  }
  return b?gcd(b,a%b):a;
}
int main(){
  int n;
  cin >> n ;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  vector<int> l(n),r(n);
  rep(i,n-1) l[i+1] = gcd (l[i],a[i]);
  for(int i=n-1;i>=1;--i) r[i-1] = gcd(r[i],a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans,gcd(l[i],r[i]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
n,a,b = gets.chomp.split(" ").map(&:to_i);

loop do  
    if a + 1 == b
      if a - 1 < 1
        puts "Borys"
        exit
      else
        a -= 1
      end
    else
      a += 1
    end
    if b - 1 == a
      if b + 1 > n
        puts "Alice"
        exit
      else 
        b += 1
      end
    else
      b -= 1
    end
end

Measured memory_bytes: 1788
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int a[501][501];
int main(void){
	int n=nextint();
	int m=nextint();
	int q=nextint();
	for(int i=0; i<m; i++){
		int L=nextint();
		int R=nextint();
		a[L][R]++;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			a[i][j]+=a[i][j-1];
		}
	}
	for(int i=0; i<q; i++){
		int L=nextint();
		int R=nextint();
		int ans=0;
		for(int j=L; j<=R; j++){
			ans+=a[j][R]-a[j][L-1];
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	int b[102];
	scanf("%d",&n);
	rep1(i,n){
		scanf("%d",&b[i]);
	}
	
	vector<int> ans;
	rep1(i,n){
		for(int j = n+1-i ; j >= 1 ; j --){
			if(b[j] == j){
				ans.pb(j);
				for(int k = j ; k <= n+1-i ; k ++){
					b[k] = b[k+1];
				}
				break;
			}
			if(j == 1){
				puts("-1");
				return 0;
			}
		}
	}
	rev(ans);
	rep(i,ans.size()){
		printf("%d\n",ans[i]);
	}
}



Measured memory_bytes: 764
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <bitset>

using namespace std;

struct UnionFind {
	std::vector<int> _parent;
	std::vector<int> _size;
	UnionFind(int size) : _parent(size, -1), _size(size, 1) { }
	void unite(int a, int b) {
		int ra = root(a), rb = root(b); if (ra == rb) { return; }
		if (_size[ra] >= _size[rb]) { _parent[rb] = ra, _size[ra] += _size[rb]; } else { _parent[ra] = rb, _size[rb] += _size[ra]; }
	}
	int root(int a) {
		int p = _parent[a];
		if (p < 0) { return a; }
		while (_parent[p] >= 0) { p = _parent[p]; }
		return _parent[a] = p;
	}
	int size(int a) { return _size[root(a)]; }
};

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, m = -1, k = -1, a, b, c, d;
		cin >> n >> m >> k;
		if (n < 0) return 0;
		UnionFind uf(n);
		set<int> g[100000], df[100000], blk[100000];
		for (int i = 0; i < m; ++i) {
			cin >> a >> b;
			--a, --b;
			uf.unite(a, b);
			df[a].insert(b);
			df[b].insert(a);
		}
		for (int i = 0; i < k; ++i) {
			cin >> c >> d;
			--c, --d;
			blk[c].insert(d);
			blk[d].insert(c);
		}
		for (int i = 0; i < n; ++i) {
			int r = uf.root(i);
			g[r].insert(i);
		}
		for (int i = 0; i < n; ++i) {
			const set<int>& s = g[uf.root(i)];
			int cnt = s.size() - 1;
			for (int x : df[i]) {
				if (s.find(x) != s.end()) {
					--cnt;
				}
			}
			for (int x : blk[i]) {
				if (s.find(x) != s.end()) {
					--cnt;
				}
			}
			if (i) cout << " ";
			cout << cnt;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 39168
#include<stdio.h>

int main(void){
    int H,W;
    for(int i=0;i<1000000;i++){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)    break;
        for(int n=0;n<H;n++){
            for(i=0;i<W;i++){
                printf("#");
            }
         printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1972
import java.util.*;
public class Main{
	
	public static String[] kommaReader(String sc) {
		String line = sc;
		String[] array = line.split(",");
		return array;
	}

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double theta=0;
		double x=0;
		double y=0;
		do{
			String[] a= kommaReader(sc.nextLine());
			double dest = Double.parseDouble(a[0]);
			double degr = Double.parseDouble(a[1]);
			if(dest==0 && degr==0) break;
			x += dest*Math.sin(theta*Math.PI/180);
			y += dest*Math.cos(theta*Math.PI/180);
			theta += degr;
		} while(sc.hasNext());
		
		System.out.println((int)x+"\n"+(int)y);

	}

}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
 */
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[500005];
char s[400004];

int main(){
    cin >> a >> b >> c >> d;
    p((a != c));
    
    return 0;
    
}


















Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  ll sum=0;
  REP(i,1,n+1){
    if(i%3==0 || i%5==0){
    }
    else{
      sum+=i;
    }
  }
  cout<<sum<<'\n';
  return(0);
}


Measured memory_bytes: 3668
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            checked
            {
                var X = cin.ReadLong;
                var Y = cin.ReadLong;
                var i = 0;
                while ((X << i) <= Y) i++;
                WriteLine(i);
            }
        }
    }

    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


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

using namespace std;

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

    int ans = 1000;

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

        ans = min(ans , count);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
const long long INF = 1LL << 60;

ll A,B,K;
ll a[10010], b[10010];
int main(){
  cin >> A >> B >> K;
  for(int i = 0; i < K; ++i) if(A+i <= B) a[i] = A+i;
  for(int i = 0; i < K; ++i) if(B-i >= A) b[i] = B-i;
  for(int i = 0; i < K; ++i){
    for(int j = 0; j < K; ++j){
      if(a[i] == b[j]) b[j] = 0;
    }
  }
  for(int i = 0; i < K; ++i) if(a[i] != 0) cout << a[i] << endl;
  for(int i = K; i >= 0; --i) if(b[i] != 0) cout << b[i] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int matrix[100][100],i,j,input,n,m,matrix1[100],sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&matrix[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&matrix1[i]);
    }
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum+=matrix[i][j]*matrix1[j];
        }
        printf("%d\n",sum);
    }
    return 0;
}


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

int main(){
    string input;
    cin >> input;
    vector<int> num(4);
    for(int i = 0; i < 4; i++) num[i] = input[i]-'0';

    string ans = "";
    for(int i = 0; i <= 1; i++){
        for(int j = 0; j <= 1; j++){
            for(int k = 0; k <= 1; k++){
                int ansnum = num[0];
                if(i == 1) ansnum += num[1];
                else ansnum -= num[1];

                if(j == 1) ansnum += num[2];
                else ansnum -= num[2];

                if(k == 1) ansnum += num[3];
                else ansnum -= num[3];

                if(ansnum == 7 && ans == ""){
                    ans += to_string(num[0]);
                    if(i == 1) ans += "+";
                    else ans += "-";
                    ans += to_string(num[1]);
                    if(j == 1) ans += "+";
                    else ans += "-";
                    ans += to_string(num[2]);
                    if(k == 1) ans += "+";
                    else ans += "-";
                    ans += to_string(num[3]);
                    ans += "=7";
                    break;
                }
            }
        }
    }

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

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

int main()
{
    int n;
    int i;
    double x[100];
    double y[100];
    double d;

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%lf", &x[i]);
    }
    for(i = 0; i < n; i++) {
        scanf("%lf", &y[i]);
    }

    d = 0;
    for(i = 0; i < n; i++) {
        d += fabs(x[i] - y[i]);
    }
    printf("%f\n", d);

    d = 0;
    for(i = 0; i < n; i++) {
        d += pow(fabs(x[i] - y[i]), 2);
    }
    printf("%f\n", sqrt(d));

    d = 0;
    for(i = 0; i < n; i++) {
        d += pow(fabs(x[i] - y[i]), 3);
    }
    printf("%f\n", cbrt(d));

    d = 0;
    for(i = 0; i < n; i++) {
        if(d < fabs(x[i]-y[i])) {
            d = fabs(x[i]-y[i]);
        }
    }
    printf("%f\n", d);

    return 0;
}


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

int main(void){
	int n;
	cin >> n;
	vector<ll> a, b, c;
	a.resize(n); b.resize(n); c.resize(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	for(int i = 0; i < n; ++i){
		cin >> b[i];
	}
	ll ans = 0;
	ll dif = 0;
	for(int i = 0; i < n; ++i){
		if(a[i] < b[i]){
			ans++;
			dif += b[i] - a[i];
		}else{
			c[i] = a[i] - b[i];
		}
	}
	//cout << ans << endl;
	sort(c.rbegin(), c.rend());
	for(int i = 0; i < n; ++i){
		if(dif <= 0LL) break;
		dif -= c[i];
		ans++;
	}
	if(dif <= 0LL){
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a),i##_end_ = (b);i<=i##_end_;i++)
#define ROF(i,a,b) for(int i = (a),i##_end_ = (b);i>=i##_end_;i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 1500005
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
#define DEBUG_
#ifdef DEBUG_
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#else
#define DEBUG(...)
#endif // DEBUG
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        int x = 0;
        while((ll)x*(ll)(x+1)<2*n)x++;
        cout<<x<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

template <typename T>
struct BIT {
    int n;
    std::vector<T> bit;
    // 1-indexed
    BIT() : n(-1) {}
    BIT(int n_, T d) : n(n_), bit(n_ + 1, d) {}

    T sum(int i) {
        T s = bit[0];
        for(int x = i; x > 0; x -= (x & -x)) s += bit[x];
        return s;
    }
    void add(int i, T a) {
        if(i == 0) return;
        for(int x = i; x <= n; x += (x & -x)) bit[x] += a;
    }

    int lower_bound(int w) {
        if(w <= 0) return 0;
        int x = 0, r = 1;
        while(r < n) r <<= 1;
        for(int k = r; k > 0; k >>= 1) {
            if(x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }

    T sum0(int i) { return sum(i + 1); }
    void add0(int i, T a) { add(i + 1, a); }

    T query(int l, int r) { return sum(r - 1) - sum(l - 1); }

    T query0(int l, int r) { return sum(r) - sum(l); }
};
// END CUT HERE

void solve() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(auto &e : a) std::cin >> e;
    std::map<int, int> mp;
    i64 ans = 0;
    rep(i, n) {
        int t = i - a[i];
        ans += mp[t];
        mp[a[i] + i]++;
    }
    std::cout << ans << std::endl;
}

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

Measured memory_bytes: 20964
#include<cstdio>
using namespace std;
int mp[505][505], n, N;

int main() {
	scanf("%d", &n);
	if(n == 1) {
		printf("1\n1");
		return 0;
	}
	N = ((n + 3) / 4) * 2;
	printf("%d\n", N);
	for(register int i = 0; i < N; ++i) {
		for(register int j = 0; j < N; ++j) {
			mp[i][j] = ((i) & 1) * N + ((i + j) % N);
			if(mp[i][j] >= n) mp[i][j] = mp[i][j] % N;
			printf("%d ", mp[i][j] + 1);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		String result="";
		char[] c = s.toCharArray();
		for(int i=0;i<c.length;i++) {
			switch(c[i]) {
			case '0':
				result += "0";
				break;
			case '1':
				result += "1";
				break;
			case 'B':
				if(!result.equals("")) {
					result = result.substring(0,result.length()-1);
				}
				break;
			}
		}
		System.out.println(result);
		scanner.close();
	}

}


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

int main() {
	long long a, b;
	scanf("%lld%lld", &a, &b);
	if (a<=0 && b>=0) printf("Zero\n");
	else if (a>0) printf("Positive\n");
	else {
		if ((b-a+1)%2==0) printf("Positive\n");
		else printf("Negative\n");
	}

	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int[] arr = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        Console.WriteLine(arr[0]*arr[1]);
    }

   

}




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

int main(void){
	int a[3],t,i,q,m=0,n=0,l=0;

	while(1){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		for(t=0;t<3;t++){
			for(i=1;i<3;i++){
				if(a[i]<a[i-1]){
					q=a[i];
					a[i]=a[i-1];
					a[i-1]=q;
				}
			}
		}
		if(a[0]+a[1]<=a[2]){
			break;
		}
		if(hypot(a[0],a[1])==a[2]){
			n++;
		}
		if(hypot(a[0],a[1])<a[2]){
			l++;
		}
		if(hypot(a[0],a[1])>a[2]){
			m++;
		}
	}

printf("%d %d %d %d\n",m+n+l,n,m,l);

return 0;
}

Measured memory_bytes: 608
// 0505 Questionnaire (??¢?????±??????)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0505
// by Equim on 17-02-08

using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        while (true)
        {
            var Size = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (Size[0] == 0) break;

            var Count = new Dictionary<int, int>();

            for (int i = 0; i < Size[0]; i++)
            {
                var Line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (int j = 0; j < Size[1]; j++)
                {
                    Count[j + 1] = (Count.ContainsKey(j + 1) ? Count[j + 1] : 0) + Line[j];
                }
            }
            
            Console.WriteLine(string.Join(" ", Count.OrderByDescending(p => p.Value).Select(p => p.Key.ToString()).ToArray()));
        }
    }
}

Measured memory_bytes: 10384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    REP (i,2*n) cin >> d[i];
    sort(d,d+2*n);
    int ans = 0;
    for (int i=0;i<2*n;i+=2) ans += d[i];
    cout << ans << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
int n;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	int n1=(ld)n/(1.08);
	if ((int)((ld)n1*1.08)==n)
		cout<<n1;
	else if ((int)((ld)(n1+1)*1.08)==n)
		cout<<n1+1;
	else 
		cout<<":(";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N,K; cin >> N >> K; int ans=0; int cnt=0;
    string S; cin >> S;
    rep(i,N-1){
       if(S[i]==S[i+1]) ans++;
       else cnt++;
    }
    if(cnt%2==0) ans+=min(cnt/2,K)*2;
    else if(cnt/2+1<=K) ans+=(cnt/2)*2+1;
    else ans+=K*2;
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll =long long;

#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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	//入力
	ll h , n ;
	cin >> h >> n ;//定期の体力はh
	vector<ll> dp(h+1,INF);
	dp[0] = 0 ;

	for(int i = 0 ; i < n ; i ++ ) {
		ll atk , mp;
		cin >> atk >> mp;
		for(int i = 1 ; i <= h ; i ++ ){
			if( i < atk ){
				chmin(dp[i], mp );
			} else {
				chmin(dp[i], dp[i-atk] + mp);
			}
		}
	}
	//rep(j,h+1){
	//	cout << dp[j] <<" ";  
	//}
	//cout << endl; 
	//cout <<"above is check" << endl;
	cout << dp[h] << endl;

}


Measured memory_bytes: 384
# 配るDP
H, W = map(int, input().split())
a = [input() for _ in range(H)]

m = 1000000007

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for h in range(H - 1):
    for w in range(W - 1):
        if a[h][w] == '#':
            continue
        if a[h][w + 1] != '#':
            dp[h][w + 1] = (dp[h][w + 1] + dp[h][w]) % m
        if a[h + 1][w] != '#':
            dp[h + 1][w] = (dp[h + 1][w] + dp[h][w]) % m
    if a[h][W - 1] == '#':
        continue
    if a[h + 1][W - 1] != '#':
        dp[h + 1][W - 1] = (dp[h + 1][W - 1] + dp[h][W - 1]) % m
for w in range(W - 1):
    if a[H - 1][w] == '#':
        continue
    if a[H - 1][w + 1] != '#':
        dp[H - 1][w + 1] = (dp[H - 1][w + 1] + dp[H - 1][w]) % m

print(dp[H - 1][W - 1])


Measured memory_bytes: 49564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> l(N);
  for(int i = 0; i < N; i++){
    cin >> l[i];
  }
  int count = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      if(l[i] == l[j]){
        continue;
      }
      for(int k = j+1; k < N; k++){
        if((l[k] == l[i]) || (l[k] == l[j])){
          continue;
        }
        if((l[i] < l[j] + l[k]) && (l[j] < l[k]+l[i]) && (l[k] < l[i]+l[j])){
          count++;
        }
      }
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 3628