akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
using namespace std;

vector<int> H(int m){
	vector<int> h;
	for(int i = 0; i < m; i++){
		int g;
		cin >> g;
		h.push_back(g);
	}
	return h;
}

string Shuffle(string Previous, vector<int> h, int m, int n){
	char after[200];
	string After;
	for(int i = 0; i < m; i++){
		for(int j = h[i]; j < n; j++) after[j-h[i]] = Previous[j];
		for(int j = 0; j < h[i]; j++) after[n-h[i]+j] = Previous[j];
		for(int j = 0; j < n; j++) Previous[j] = after[j];
	}
	for(int i = 0; i < n; i++){
		After.push_back(after[i]);
	}
	return After;
}

int main(){
	while(1){
		//????????????????????¨?????????????????\?????????
		string Previous;
		cin >> Previous;
		if(Previous == "-") break;
		//?????£???????????????????????\?????????
		int m;
		cin >> m;
		vector<int> h = H(m);
		//?????£?????????????????????????????????????????????
		string After;
		int n = Previous.size();
		After = Shuffle(Previous, h, m, n);
		cout << After << endl;
	}
	return 0;
}	

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

constexpr int MOD = 1'000'000'007;

int main() {
    using P = pair<long long, long long>;
    ModInt<MOD> two = 2, ans = 0;
    int n;
    cin >> n;
    map<P, P> mp;
    for (int i = 0; i < n; i++) {
        long long a, b;
        cin >> a >> b;
        if (a == 0 and b == 0) {
            ans += 1; continue;
        }
        if (b < 0) { a = -a; b = -b; }
        long long c = abs(gcd(a, b));
        a /= c; b /= c;
        if (a <= 0) mp[P(b, -a)].second++;
        else mp[P(a, b)].first++;
    }

    ModInt<MOD> val = 1;
    for (auto [_, e] : mp) {
        val *= (two.pow(e.first) + two.pow(e.second) - 1);
    }

    cout << (ans + val - 1) << '\n';

    return 0;
}


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

int main() {

    int n, s[1001];
    double a, m;

    for ( ;; ) {
        cin >> n;

        if ( n == 0 ) break;

        m = 0;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            m += s[i];
        }
        m = m / n;    // ?????????

        a = 0;
        for (int i = 0; i < n; i++) {
            a += (s[i] - m) * (s[i] - m);
        }
        a = a / n;    // ?????£
        a = sqrt(a);    // ?¨??????????
        printf("%lf\n", a);
    }

    return 0;
}

Measured memory_bytes: 3136
process.stdin.resume();
process.stdin.setEncoding('utf8');

const reader = require("readline").createInterface({
    input : process.stdin,
    output : process.stdout
})

let input_line
reader.on("line", (line) => input_line = line)

reader.on("close", () => {
    const input_second = parseInt(input_line)
    const h = Math.floor(input_second/(60*60))
    const m = Math.floor((input_second-(h*60*60))/60)
    const s = (input_second-(h*60))%60
    console.log(h + ":" + m + ":" + s)
})


Measured memory_bytes: 16244
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    rep(i,n)if(s[i] == 'x')cnt++;
    if(cnt >= 8)cout << "NO" << endl;
    else cout << "YES" << endl;

}


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

int64_t func(int64_t num, int64_t x) {
  if (num == -1) return 0;
  return num / x + 1;
}

int main() {
  int64_t a, b, x, ans = 0;
  cin >> a >> b >> x;
  ans = func(b, x) - func(a-1, x);
  cout << ans << endl;
}

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

int res = 0;
void go(int a, int b) {
	if (a < b) a^=b,b^=a,a^=b;
	if (a%b == 0) res += 2*a - b;
	else { res += 2 * (a/b) * b; go(a % b, b); }
}

signed main() {
	// your code goes here
	int n, x;
	cin >> n >> x;
	go(x, n-x);
	cout << n + res << "\n";
	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
d = inpl()
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += d[i] * d[j]
print(ans)

Measured memory_bytes: 39860
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, p;

signed main(){
    cin >> n;
    ll cnt = 0, min_p = INF;
    REP(i, n){
        cin >> p;
        if(min_p >= p){
            cnt++;
            min_p = p;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 8
#define L -1
#define O 1


int A[N], B[N], C[2*N-1], D[2*N-1];

int E[N][N];

void initialize();

void b();
void Qeen(int );

int main(){
  int i, j, a, b, c;
  
  initialize();

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      E[i][j] = -1;
    }
  }

  scanf("%d", &a);
  for(i = 0; i < a; i++){
    scanf("%d%d", &b, &c);
    E[b][c] = 1;
  }
  Qeen(0);

  return 0;
}

void initialize(){
  int i;
  for(i = 0; i < N; i++){
    A[i] = O;
    B[i] = O;
  }
  for(i = 0; i < 2*N-1; i++){
    C[i] = O;
    D[i] = O;
  }
}

void b(){
  int i, j;
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(E[i][j]==1){
        if(A[i] != j) return;
      }
    }
  }

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(A[i] == j)
      printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void Qeen(int i){
  int j;
  if(i == N){
    b();
    return;
  }

  for(j = 0; j < N; j++){
    if(B[j] == L || C[i+j] == L || D[i-j+(N-1)] == L) continue;
    A[i] = j;
    B[j] = L;
    C[i+j] = L;
    D[i-j+(N-1)] = L;

    Qeen(i+1);
    A[i] = O;
    B[j] = O;
    C[i+j] = O;
    D[i-j+(N-1)] = O;
  }
}




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

int main() {
	int A, B, C, D, L, R;
	cin >> A >> B >> C >> D;

	L = A + B;
	R = C + D;

	if (L > R)
		cout << "Left" << endl;

	if (L < R)
		cout << "Right" << endl;

	if (L == R)
		cout << "Balanced" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final String SUUNY = "Sunny";
	public static final String CLOUDY = "Cloudy";
	public static final String RAINY = "Rainy";

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		String str = scan.next();

		//出力値
		String result = null;

		if (str.equals(SUUNY)) {
			result = CLOUDY;
		} else if (str.equals(CLOUDY)) {
			result = RAINY;
		}  else if (str.equals(RAINY)) {
			result = SUUNY;
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 21076
// B - Distance
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;

int main(){
    ll n, d;
    cin >> n >> d;
    ll x, y, ans = 0;
    for(ll i=0; i<n; i++){
        cin >> x >> y;
        double xy = sqrt((x*x)+(y*y));
        if(xy <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
const int N = 105;
 
int i, n, j, t[N], v[N];
double rs;
map<int, double> dp[N * N * 4];
set<pair<int, int>> S;
queue<pair<int, int>> q;
vector<int> h;
 
int main() {
  ios_base::sync_with_stdio(0);
 
  cin >> n;
  for(i = 1; i <= n; ++i) cin >> t[i];
  for(i = 1; i <= n; ++i) cin >> v[i];
 
  for(i = 1; i <= n; ++i)
    for(j = 0; j < t[i]; ++j)
      h.push_back(v[i]);
 
  dp[0][0] = 0; S.insert(make_pair(0, 0));
  for(q.push(make_pair(0, 0)); !q.empty(); q.pop()) {
    int x = q.front().first;
    int vit = q.front().second;
    S.erase(make_pair(x, vit));
    if(x == h.size()) continue;
    if(h[x] < vit) continue;
 
    if(h[x] >= vit) {
      dp[x + 1][vit] = max(dp[x + 1][vit], dp[x][vit] + vit);
      if(!S.count(make_pair(x + 1, vit))) q.push(make_pair(x + 1, vit)), S.insert(make_pair(x + 1, vit));
    }
 
    if(h[x] >= vit + 0.5) {
      dp[x + 1][vit] = max(dp[x + 1][vit], dp[x][vit] + vit + 0.25);
      if(!S.count(make_pair(x + 1, vit))) q.push(make_pair(x + 1, vit)), S.insert(make_pair(x + 1, vit));
    }
 
    if(h[x] >= vit + 1) {
      dp[x + 1][vit + 1] = max(dp[x + 1][vit + 1], dp[x][vit] + vit + 0.5);
      if(!S.count(make_pair(x + 1, vit + 1))) q.push(make_pair(x + 1, vit + 1)), S.insert(make_pair(x + 1, vit + 1));
    }
 
    if(h[x] >= vit - 1 && vit - 1 >= 0) {
      dp[x + 1][vit - 1] = max(dp[x + 1][vit - 1], dp[x][vit] + vit - 0.5);
      if(!S.count(make_pair(x + 1, vit - 1))) q.push(make_pair(x + 1, vit - 1)), S.insert(make_pair(x + 1, vit - 1));
    }
  }
 
  cout << setprecision(3) << fixed << dp[h.size()][0] << '\n';
 
  return 0;
}

Measured memory_bytes: 68608
from collections import Counter

current = last_month = Counter()
this_month = Counter()

while True:
    try:
        s = input()
    except EOFError:
        break
    if s:
        customer, day = map(int, s.split(','))
        current[customer] += 1
    else:
        current = this_month

for i in last_month.keys():
    if i in this_month:
        print(i, last_month[i] + this_month[i])

Measured memory_bytes: 6716
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, m;

int main() {
	while (cin >> n >> m) {
		if (n == 0 && m == 0)return 0;
		vector<pair<LL, LL>>v(n);
		REP(i, n) {
			cin >> v[i].second >> v[i].first;
		}
		sort(ALL(v));
		reverse(ALL(v));
		LL ans = 0;
		REP(i, n) {
			LL d = min(m, v[i].second);
			m -= d;
			ans += v[i].first*(v[i].second - d);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3208
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int cnt = 0;
	REP(i, 3)if (s[i] == '1')cnt++;
	cout << cnt << endl;
}


Measured memory_bytes: 256
import math
from collections import defaultdict
import itertools
N=int(input())
d=defaultdict(float)
l=[]
for i in range(N):
  x,y=map(int,input().split())
  l.append([x,y])
for i in range(N-1):
  for j in range(i+1,N):
    x1,y1=l[i][0],l[i][1]
    x2,y2=l[j][0],l[j][1]
    d[(i,j)]=(math.sqrt((x1-x2)**2+(y1-y2)**2))
    d[(j,i)]=(math.sqrt((x1-x2)**2+(y1-y2)**2))

tot=0
for pat in itertools.permutations([i for i in range(N)]):
  for i in range(N-1):
    tot+=(d[(pat[i],pat[i+1])])
print(tot/math.factorial(N))

Measured memory_bytes: 3444
n, m = map(int, input().split())
edge = []
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge.append((a, b))

ans = 0
for rep in range(m):
    d = [[10 ** 18] * n for i in range(n)]
    for i in range(n):
        d[i][i] = 0

    for i in range(m):
        if i == rep:
            continue
        a, b = edge[i]
        d[a][b] = 1
        d[b][a] = 1

    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    ok = 0
    for i in range(n):
        for j in range(n):
            if d[i][j] == 10 ** 18:
                ok = 1
    ans += ok

print(ans)


Measured memory_bytes: 45148
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#include <boost/sort/spreadsort/spreadsort.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;

constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
template <class Func>

class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;

template <typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

constexpr int dxw[] = {-2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2};
constexpr int dyw[] = {-2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};

struct negrightshift {
    inline int operator() (const int &x, const unsigned offset) {
        return -(x >> offset);
    }
};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int d, t, s;
    cin >> d >> t >> s;

    if(d <= t * s){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

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

const int MAXN = 1e5;
const int INF = 1e9;

vector<int> h(MAXN, 0);
int dp[MAXN];
int k;

int solve(int id)
{
	if(id == 0) return 0;
	if(dp[id] != -1) return dp[id];
	
	
	int ans = INF;
	for(int i = k; i >= 1; i--)
	{
		if(id - i >= 0)
			ans = min(ans, abs(h[id-i] - h[id]) + solve(id-i));
	}
	
	return dp[id] = ans;
}


int main()
{
	int n, target;
	cin >> n >> k;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < n; i++)
		cin >> h[i];
	
	cout << solve(n-1) << '\n';
}

Measured memory_bytes: 8832
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

char pp[1000000] = {};

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);
  int k = 0;
  for (int i = 1; i <= n; i++) if (i % 2 == 1) k++;
  printf("%f\n", (float)k/(float)n);
  return 0;
}


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

using namespace std;


int keta(long long n){
    int cnt = 0;
    while(n>0){
        cnt++;
        n /= 10;
    }
    return cnt;
}

int main(){
    long long n;
    cin >> n;
    int k = keta(n);


    int x = 9 * (k-1);

    long long  ten = 1;
    for(int i=0;i<k-1;i++)
        ten *= 10;
    
    int ans = x + n/ten-1;
    if((n+1)/ten > n/ten)
        ans += 1;

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a,b;
int main()
{
	cin>>a>>b;
	if(a=='D' && b=='H') cout<<"D"<<endl;
	else if(a=='D' && b=='D') cout<<"H"<<endl;
	else if(a=='H' && b=='D') cout<<"D"<<endl;
	else if(a=='H' && b=='H') cout<<"H"<<endl;
	return 0;
}


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

template<typename T>
void read(T &x)
{
	x = 0; int f = 1; char c = getchar();
	while (!isdigit(c)) { if (c == '-'); f = -1; c = getchar(); }
	while (isdigit(c)) { x = x * 10 + c - 48; c = getchar(); }
	x *= f;
} 

const int Mod = 1e9 + 7;

inline int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
inline void updateA(int &a, int b) { a = add(a, b); }

const int MAXN = 2e3 + 9;

int n, m, k, ans = 0;
int f[MAXN << 1]; // 和为 j 的方案数
int s[MAXN << 1];

inline bool equiv(int a, int b, int p) { return a % p == b % p; }

inline bool chk(int i, int j) 
{ 
	int res = 1 + i * (k - 1) - j;
	return 
		equiv(j, m, k - 1) && 
		res <= n && equiv(res, n, k - 1);
}

int main() 
{
	read(n), read(m), read(k);

	for (int i = 0; i <= m; ++i) s[i] = 1;
	for (int i = 1, tt = (n + m - 1) / (k - 1); i <= tt; ++i) // 总位数
	{
		for (int j = 1; j <= m; ++j) // 前几位的和
		{
			f[j] = sub(s[j - 1], j >= k ? s[j - k] : 0); // 是否进位
			if (chk(i, j)) updateA(ans, f[j]);
		}
		for (int j = 1; j <= m; ++j) updateA(f[j], f[j - 1]), updateA(s[j], f[j]); // 前缀和优化
	}

	printf("%d\n", ans);

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<math.h>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(c >= a && c <= b)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

int main() {
	int n,w,i,k,ans,cur;
	cin >> n >> w;
	vector<pair<long,long>> p(n);
	vector<long> a(4,0),j(4);
	for(i=0; i<n; i++){
		cin >> p[i].first >> p[i].second;
		a[p[i].first-p[0].first]++;
		p[i].second*=-1;
	}
	sort(p.begin(),p.end());
	
	ans=0;
	for(j[0]=0; j[0]<=a[0]; j[0]++){
		for(j[1]=0; j[1]<=a[1]; j[1]++){
			for(j[2]=0; j[2]<=a[2]; j[2]++){
				for(j[3]=0; j[3]<=a[3]; j[3]++){
					if((j[0]+j[1]+j[2]+j[3])*(p[0].first)+(j[1]+j[2]*2+j[3]*3)<=w){
						cur=0;
						for(k=0; k<j[0]; k++){
							cur+=p[k].second;
						}
						for(k=a[0]; k<a[0]+j[1]; k++){
							cur+=p[k].second;
						}
						for(k=a[0]+a[1]; k<a[0]+a[1]+j[2]; k++){
							cur+=p[k].second;
						}
						for(k=a[0]+a[1]+a[2]; k<a[0]+a[1]+a[2]+j[3]; k++){
							cur+=p[k].second;
						}
						
						if(ans>cur){
							ans=cur;
						}
					}
				}
			}
		}
	}
	cout << -ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int matrix[3][3];
	char o;
	for(int i = 0; i<3 ; i++){
		for(int j = 0; j<3 ; j++){
			scanf("%d", &matrix[i][j]);
		}
	}
	int N;
	scanf("%d", &N);
	int input[N];
	for(int x = 0; x < N ; x++){
		scanf("%d", &input[x]);
		for(int i = 0 ; i<3 ; i++){
			for(int j = 0 ; j<3 ; j++){
				if(input[x] == matrix[i][j]){
					matrix[i][j] = o;
				}
			}
		}
	}
	int ctr[8] = {0};
	int last = 2;
	for(int i = 0; i<3; i++){
		if(matrix[i][0] == o){
			++ctr[0];
		}
		if(matrix[i][1] == o){
			++ctr[1];
		}
		if(matrix[i][2] == o){
			++ctr[2];
		}
		if(matrix[0][i] == o){
			++ctr[3];
		}
		if(matrix[1][i] == o){
			++ctr[4];
		}
		if(matrix[2][i] == o){
			++ctr[5];
		}
		if(matrix[i][i] == o){
			++ctr[6];
		}
		if(matrix[i][last--] == o){
			++ctr[7];
		}
	}
	int flag = 0;
	for(int i = 0; i < 8; i++){
		if(ctr[i] == 3){
			flag = 1;
		}
	}
	if(flag == 1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
#include <cstring>

#include <algorithm>

using std::max;
using std::min;
using std::sort;

const int SIZE = 1e5+5;

int n, a[SIZE], dp[SIZE], ans;

int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    if (a[i] > a[i - 1])
      dp[i] = 0;
    else
      dp[i] = dp[i - 1] + 1;
  for (int i = 1; i <= n; ++i)
    ans = max(ans, dp[i]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(){
	int a, b;
	char op;
	while (1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if (op=='?')
		{
			break;
		}
		else if (op == '+')
		{
			printf("%d\n", a + b);
		}
		else if (op == '-')
		{
			printf("%d\n", a - b);
		}
		else if (op == '*')
		{
			printf("%d\n", a * b);
		}
		else if (op == '/')
		{
			printf("%d\n", a / b);
		}
	}
	return 0;

}

Measured memory_bytes: 600
using Atcoder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
           var firstLine = Console.ReadLine().Split(' ');
            var N = int.Parse(firstLine[0]);
            var K = int.Parse(firstLine[1]);
            var S = Console.ReadLine();
            for (int i = 0; i < S.Length; i++)
            {
                if (K-1 == i)
                {                    
                    Console.Write(char.ToLower(S[i]));
                    continue;
                }
                Console.Write(S[i]);
            }
        }

    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;

ll n, k;
vector<ll> a[100001];
ll fact[100001];

ll power(ll aa, ll b) {
    ll ans = 1;
    ll till = aa;
    while (b) {
        if (b % 2) {
            ans *= till;
            ans %= mod;
        }

        till = (till * till) % mod;
        b >>= 1;
    }

    return ans;
}

ll f(ll root, ll par) {
    ll childs = a[root].size() - (par != -1);
    ll aval = k - 1 - (par != -1);
    ll ans = 1;

    if (aval < childs) {
        cout << 0;
        exit(0);
    }

    if (childs == 0) {
        return 1;
    }

    for (ll e : a[root]) {
        if (e != par) {
            ans = (ans * f(e, root)) % mod;
        }
    }

    ans = (ans * fact[aval]) % mod;
    ans = (ans * power(fact[aval - childs], mod - 2)) % mod;
    return ans;

}


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    cin >> n >> k;
    fact[0] = 1;
    for (ll i = 1; i <= 100000; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    for (ll i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        a[u].pb(v);
        a[v].pb(u);
    }


    cout << (k * f(1, -1)) % mod;


}



Measured memory_bytes: 12416
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>

const double kEpsilon = 1e-10;
inline bool equals(double a, double b)
{
    return fabs(a - b) < kEpsilon;
}

class Point
{
  public:
    double x, y;

    Point() = default;
    Point(double x, double y) : x(x), y(y)
    {
    }

    Point operator+(const Point &p)
    {
        return Point(x + p.x, y + p.y);
    }
    Point operator-(const Point &p)
    {
        return Point(x - p.x, y - p.y);
    }
    Point operator*(const double k)
    {
        return Point(x * k, y * k);
    }
    Point operator/(const double k)
    {
        return Point(x / k, y / k);
    }

    double SquaredNorm()
    {
        return x * x + y * y;
    }
    double abs()
    {
        return sqrt(this->SquaredNorm());
    }

    bool operator<(const Point &p) const
    {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator==(const Point &p) const
    {
        return fabs(x - p.x) < kEpsilon && fabs(y - p.y) < kEpsilon;
    }

    double dot(const Point &p) const
    {
        return x * p.x + y * p.y;
    }
    double cross(const Point &p) const
    {
        return x * p.y - y * p.x;
    }
};

double dot(const Point &p1, const Point &p2)
{
    return p1.x * p2.x + p1.y * p2.y;
}
double cross(const Point &p1, const Point &p2)
{
    return p1.x * p2.y - p1.y * p2.x;
}

using Vector = Point;

struct Segment
{
    Point p1, p2;

    Segment() = default;
    Segment(Point p1, Point p2) : p1(p1), p2(p2)
    {
    }
};
using Line = Segment;

class Circle
{
  public:
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0.0) : c(c), r(r)
    {
    }
};

Point projection(Point &p1, Point &p2, Point &p)
{
    auto q = p2 - p1;
    auto a = q.dot(p - p1) / q.SquaredNorm();
    return p1 + q * a;
}

Point projection(Line &l, Point &p)
{
    auto p1 = l.p1;
    auto p2 = l.p2;
    return projection(p1, p2, p);
}

std::array<Point, 2> crossPointsCircleLine(Circle &c, Line &l)
{

    Vector q = l.p2 - l.p1;
    if (l.p2 < l.p1)
        q = q * (-1.);

    Vector e = q / q.abs();
    Point pr = projection(l, c.c);
    double h = (c.c - pr).abs();
    double length = sqrt(c.r * c.r - h * h);

    std::array<Point, 2> cross = {pr - e * length, pr + e * length};

    return cross;
}

int main()
{
    int q;
    Circle c;
    Line l;

    std::cin >> c.c.x >> c.c.y >> c.r;
    std::cin >> q;

    for (size_t i = 0; i < q; ++i)
    {
        std::cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
        auto cross = crossPointsCircleLine(c, l);
        printf("%.9f %.9f %.9f %.9f\n", cross[0].x, cross[0].y, cross[1].x, cross[1].y);
    }
}



Measured memory_bytes: 3216
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <cmath>
#include <climits>
using namespace std;
// int 2,147,483,647
/*
1、数组开得太小了，导致访问到了不该访问的内存区域

2、发生除零错误

3、大数组定义在函数内,导致程序栈区耗尽

4、指针用错了，导致访问到不该访问的内存区域

5、还有可能是程序抛出了未接收的异常
*/
int main(int argc, char *argv[]) {
	int N;
	int X;
	scanf("%d %d", &N, &X);
	int x[N];
	int min = INT32_MAX;
	for (int i = 0; i < N; i++) {
		scanf("%d", x+i);
		x[i] = abs(x[i] - X);
		if (x[i] < min && x[i] != 0) min = x[i];
	}
	
	for (int i = min; i > 0; i--) {
		if (min % i != 0) continue;
		bool ok_ = true;
		for (int j = 0; j < N; j++) {
			if (x[j] % i != 0) {
				ok_ = false; 
				break;
			}	
		}
		if (ok_) {
			printf("%d", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N = 0;
  int M = 0;
  vector<int> A;
  vector<int> B;
  int a = 0;
  double sum = 0.0;
  double condition = 0.0;
  
  cin >> N;
  cin >> M;
  for(int i = 0; i < N; i++){
    cin >> a;
    A.push_back(a); 
    sum += a;
  }
  
  double c = 0.0;
  c = 4 * M;
  condition = sum / c;
  
  for(int i = 0; i < N; i++){
    if(A[i] >= condition){
      B.push_back(A[i]);
    }
  }
  
  if(B.size() >= M){
    cout << "Yes";
  }else{
    cout << "No";
  }
 
  return 0;
 
 }

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys

n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if n>k:
    for i in range(k):
        H[n-1-i]=0
else:
    print(0)
    sys.exit()
    
sum_H=sum(H)
print(sum_H)

Measured memory_bytes: 31676
m, f, r = [int(i) for i in input().split()]
while not all(i == -1 for i in (m, f, r)):
    if -1 in (m, f):
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        print("C" if r >= 50 else "D")
    else:
        print("F")
    m, f, r = [int(i) for i in input().split()]



Measured memory_bytes: 5600
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int a=Integer.parseInt(bf.readLine());
        int[][][] num=new int[4][3][10];
        
        for(int i=0;i<a;i++){
            String[] str=bf.readLine().split(" ");
            int b=Integer.parseInt(str[0]);
            int f=Integer.parseInt(str[1]);
            int r=Integer.parseInt(str[2]);
            int v=Integer.parseInt(str[3]);
            
            num[b-1][f-1][r-1]+=v;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++){
                    System.out.print(" "+num[i][j][k]);
            }
                System.out.println();
        }
            if(i !=3)
                System.out.println("####################");
        }
    }
}

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

class Program
{
	static void Main(string[] args)
	{
		var Param = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList<int>();

		Console.WriteLine(string.Format("{0} {1}", Param[0] * Param[1], (Param[0] + Param[1]) * 2));
	}
}

Measured memory_bytes: 9440
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int p = sc.nextInt();
    int q = sc.nextInt();
    int r = sc.nextInt();
    int max = p;
    if(q > max){
      max = q;
    }
    if(r > max){
      max = r;
    }
    System.out.println(p+q+r-max);
  }
}


Measured memory_bytes: 23764
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (a,b) = get!(usize, usize);
    if (b-1)%(a-1) == 0 {
        println!("{}", (b-1)/(a-1));
    } else {
        println!("{}", (b-1)/(a-1)+1);
    }
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a, b, c, d;
  string ans;
    cin >> a >> b >> c >> d;
    a += b;
    c += d;
      (a==c) ? ans="Balanced": (a<c)? ans="Right": ans="Left";
    cout << ans << endl;
}

Measured memory_bytes: 256
#touristさんのやつ

n = gets.to_i
left,right = [0],[0]
n.times.map{
  l,r = gets.split.map(&:to_i)
  left << l
  right << r
}
left.sort!.reverse!
right.sort!

ans = 0
n.times{|i|
  if left[i] > right[i]
    ans += 2 * (left[i] - right[i])
  end
}

p ans


Measured memory_bytes: 5352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);
    
    set<int> s;
    for(auto a:A){
        if(s.count(a)) s.erase(a);
        else s.insert(a);
    }

    cout<<s.size()<<endl;
}

Measured memory_bytes: 5248
l = list(map(int, input()))

ans = [''] * 3
for p in range(1<<3):
    t = l[0]
    for i in range(1,4):
        if p & 1:
            t += l[i]
            ans[i-1] = '+'
        else:
            t -= l[i]
            ans[i-1] = '-'
        p >>= 1
    if t == 7:
        break

print(str(l[0])+ans[0]+str(l[1])+ans[1]+str(l[2])+ans[2]+str(l[3])+'=7')

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int n=sc.nextInt();
    	int a=sc.nextInt();


    	if(a>=n%500) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}



    }

}







Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)

using namespace std;
typedef long long ll;

int N,A,B;

int main(){
    int N;
    cin>>N;
    int B[105];
    for(int i = 0;i < N;i++){
        cin>>B[i];
    }
    vector<int> ans;
    for(int sz = N;sz > 0;sz--){
        int index = 1;
        int imax = -1;
        for(int i = 0;i < N;i++){
            if(B[i]>0){
                if(B[i]==index){
                    imax = i;
                }
                index++;
            }
        }
        if(imax<0||B[imax]>sz){
            cout<<-1<<endl;
            return 0;
        }
        ans.push_back(B[imax]);
        B[imax]=0;
    }
    reverse(ans.begin(),ans.end());
    for(int i = 0;i < N;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

getIntListN n = map readInt <$> replicateM (fromIntegral n) BS.getLine

pick :: [Int] -> Int -> Int -> Int -> Int
pick [] t' k i = 0
pick (t : ts) t' k i
  | i == 0 = 0
  | t > t' + k = 0
  | t <= t' + k = 1 + pick ts t' k (i - 1)

calc :: [Int] -> Int -> Int -> Int
calc [] c k = 0
calc ts c k = 1 + calc ts' c k
  where
    t = head ts
    n = pick ts t k c
    ts' = drop n ts

main = do
  [n, c, k] <- getIntList
  ts <- getIntListN n
  let ts' = sort ts
  print $ calc ts' c k


Measured memory_bytes: 29472
#include <bits/stdc++.h>
#include <stdio.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
    if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
    else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
    else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
    else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
    else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
    else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
    else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
    else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y ;
  cin >> x >> y ;
  cout << gcd(x,y) <<endl ;
  
  
  
  return 0 ;
}


Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<stdio.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
	set<char>left;
	left.insert('a');
	left.insert('b');
	left.insert('c');
	left.insert('d');
	left.insert('e');
	left.insert('f');
	left.insert('g');
	left.insert('q');
	left.insert('r');
	left.insert('s');
	left.insert('t');
	left.insert('v');
	left.insert('w');
	left.insert('x');
	left.insert('z');
	string s;
	while(true){
		cin>>s;
		int hand=0,ans=0;
		if(s=="#")break;
		for(int i=0;i<s.length();i++){
			if(i==0){
				if(left.count(s[i])==1){
					hand=0;
				}
				else hand=1;
			}
			else{
				if(hand==0){
					if(left.count(s[i])==1)hand=0;
					else{
						ans++;
						hand=1;
					}
				}
				else{
					if(left.count(s[i])==1){
						ans++;
						hand=0;
					}
					else hand=1;
				}
			}
		}
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 3156
def main():
    while True:
        votesum = int(input())
        #print("----------")
        halfsum = votesum // 2
        if votesum == 0: break

        votedata = []
        votedata = list(map(str, input().split()))
        #print("votedata::")
        #print(votedata)

        nowdata = dict()
        nowdata['o'] = 0
        #[[候補者,得票数],[候補者,得票数]...]

        for i in range(len(votedata)):
            cand = votedata[i]

            voteremn = votesum - (i + 1)

            if newcand(votedata, cand, i): nowdata[cand] = 1
            else: nowdata[cand] += 1

            nowdata = sorted(nowdata.items(), key = lambda x:x[1], reverse = True)
            #print(nowdata)
            #print("残り" + str(voteremn))
            if nowdata[0][1] > halfsum:
                print(str(nowdata[0][0] + " " +  str(i + 1)))
                break
            elif nowdata[0][1] > nowdata[1][1] + voteremn:
                print(str(nowdata[0][0] + " " + str(i + 1)))
                break

            nowdata = dict(nowdata)

            if i == len(votedata) - 1:
                print("TIE")
                break
            
        


def newcand(data, cand, now):
    for i in range(now):
        item = data[i]
        if item == cand: return False
    return True
main()



Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0;i<n;++i)
const int MAX = 510000;
const int MOD = 1000000007;

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll comb(ll n, ll k) {
    ll x = 1;
    for(int i=n-k+1; i<=n; i++) {
        x = x*i%MOD;
    }

    ll y = 1;
    for(int i=1; i<=k; i++) {
        y = y*i%MOD;
    }
    y = modpow(y, MOD-2);

    return x*y%MOD;
}

int main(){
    int n,k; cin >> n >> k;
    for(int i=1;i<=k;++i){
        cout << (comb(k-1,i-1) * comb(n-k+1,i))%MOD << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    
    int n , M , m ;
    long S ;
    
    cin >> n ;
    
    int a[n] ;

    cin >> a[1] ;
    M = a[1] ;
    m = a[1] ;
    S = a[1] ;

    for(int i = 2 ; i <= n ; i++){
        cin >> a[i] ;
        M = max(M , a[i]) ;
        m = min(m , a[i]) ;
        S = S + a[i] ;
    }
    
    
    cout << m << " " << M << " " << S << endl;
    
    
    
    
}


Measured memory_bytes: 3132