akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = list(map(int,input().split()))

c = [0]*n
c[1] = abs(h[1]-h[0])
for i in range(1,n-1):
    c[i+1] = min(c[i-1]+abs(h[i+1]-h[i-1]),c[i]+abs(h[i+1]-h[i]))
print(c[n-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(n);
    rep(i, n) cin >> a[i];
    int l = 0, r = 0;
    ll sum = 0;
    ll ans = 0;
    // [l, r) の xor を sum に格納 -> 尺取
    // A_l, A_l+1, ... A_rの総和とxorが一致するならその連続部分列も条件を満たす
    while(l < n && r < n){
        while(r < n && (sum + a[r]) == (sum ^ a[r])) sum += a[r], r++, ans += r - l;
        sum -= a[l];
        l++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3984
#include <stdio.h>
int main(){
  int N;
  int i=0; 
  int a[100000];
  int sum=0;
  int temp;
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&a[i]);
  }
for(i=0; i<N; i++){
  temp=a[i];

  if(i+1 == a[temp-1]) sum++;
  }

 printf("%d\n",sum/2);
 return 0;




}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
	int n,a[1000000];
  cin>>n;
  rap(i,n){
	cin>>a[i];
  }
  sort(a,a+n);
  int mid = n/2;
  cout<<a[mid]-a[mid-1]<<"\n";
return(0);
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stack>
#include<queue>
#include<limits>

using namespace std;

int main(){
    unordered_map<string,int> hm{
        {"SUN",7},
        {"MON",6},
        {"TUE",5},
        {"WED",4},
        {"THU",3},
        {"FRI",2},
        {"SAT",1},
    };
    string inp;
    cin >> inp;
    cout << hm[inp];
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    }
}

class Stack {
    int top;
    int[] stack;

    public Stack() {
        this.top = 0;
        this.stack = new int[1000];
    }

    public void push(int num) {
        this.top++;
        this.stack[top] = num;
    }

    public int pop() {
        int num = this.stack[this.top];
        this.stack[this.top] = 0;
        this.top--;
        return num;
    }
}


Measured memory_bytes: 26280
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int L,N,M;
	int sum;
	int answer;

	while( cin >> L && L != 0 ){
		sum = 0;
		answer = 0;
		for( int i = 0;i < 12;i++ ){
			cin >> M >> N;
			sum += M - N;
			if( sum >= L && answer == 0 ) answer = i + 1;
		}
		if( answer != 0 ) cout << answer << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
// バケット法による解
#include <iostream>
using namespace std;

int main() {
    int N,M;
    cin >> N >> M;
    int b[110];
    for(int i = 0; i< M*2;++i)  cin >> b[i];
    int app[110] = {0};
    for(int i = 0; i< M*2;++i){
      app[b[i]]++;
    }
    for(int i = 1;i<=N;++i){
      cout << app[i] << endl;
    }
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int solve(int x,const vi& ms,vector<int8_t>& memo)
{
	if(memo[x]!=-1) return memo[x];
	
	if(x==0) return memo[x]=0;
	int res=INF;
	for(int m:ms) if(__builtin_ctz(x)==__builtin_ctz(m))
		res=min(res,solve(x^m,ms,memo));
	return memo[x]=res+1;
}

int main()
{
	vi ms;
	rep(t,5) repi(b,t,5) rep(l,5) repi(r,l,5){
		int m=0;
		repi(i,t,b+1) repi(j,l,r+1) m|=1<<(i*5+j);
		ms.push_back(m);
	}
	vector<int8_t> memo(1<<25,-1);
	
	for(int n;cin>>n && n;){
		int x=0;
		rep(i,n) rep(j,n){
			int b; cin>>b;
			x|=b<<(i*5+j);
		}
		
		int res=solve(x,ms,memo);
		rep(i,res) cout<<string("myon"); cout<<endl;
	}
}

Measured memory_bytes: 33772
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int a[13] = {0,1,2,1,3,1,3,1,1,3,1,3,1};
    int x,y;
    cin >> x >> y;
    cout << (a[x] == a[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split
end

S, T = attrs.shift
A, B = attrs.shift.map{|v| v.to_i }
U = attrs.shift[0]

if S == U then
  result = "#{A - 1} #{B}"
elsif T == U then
  result = "#{A} #{B - 1}"
else
  result = "#{A} #{B}"
end
  
puts result

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#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 FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

struct P {
  int x, y;
  P() {}
  P(int x, int y): x(x), y(y) {}
  bool operator==(P& p) const { return x == p.x && y == p.y; }
};

inline bool chain(P p0, P p1) {
  int dx = p1.x-p0.x, dy = p1.y-p0.y;
  return dx == 0 || dy == 0 || dx == dy || dx == -dy;
}

P p[2];
P g;

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d%d%d%d", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &g.x, &g.y);

    if (p[0] == g || p[1] == g) {
      puts("0");
    } else if (chain(p[0], g) && chain(p[1], g)) {
      puts("1");
    } else if (chain(p[0], g) || chain(p[1], g)) {
      puts("2");
    } else if (chain(p[0], p[1])) {
      puts("3");
    } else {
      static const int dy[] = {1, 1, 1, 0};
      static const int dx[] = {0, 1, -1, 1};

      int x0 = p[0].x, y0 = p[0].y, x1 = p[1].x, y1 = p[1].y;
      int ans = 4;
      REP(i, 4) {
        int a0 = dx[i], b0 = dy[i];
        REP(j, 4) if (i != j) {
          int a1 = dx[j], b1 = dy[j];
          int xc = x0*a1*b0 - x1*a0*b1 + (y1-y0)*a0*a1;
          int yc = y1*a1*b0 - y0*a0*b1 - (x1-x0)*b0*b1;
          int d = a1*b0 - a0*b1;
          if (xc%d == 0 && yc%d == 0) {
            if (chain(P(xc/d, yc/d), g)) { ans = 3; }
          }
        }
      }
      printf("%d\n", ans);
    }
  }
}

Measured memory_bytes: 0
using System;
class c
{
    static void Main()
    {
        var s = Console.ReadLine();
        int a = int.Parse(s.Substring(0, 2));
        int b = int.Parse(s.Substring(2, 2));
        if (a <= 12 && a > 0 && b <= 12 && b > 0) Console.WriteLine("AMBIGUOUS");
        else if (b <= 12 && b > 0) Console.WriteLine("YYMM");
        else if (a <= 12 && a > 0) Console.WriteLine("MMYY");
        else Console.WriteLine("NA");
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

inline string mk(int n, vector<int> a) {
    string res;
    for (int i = 0; i < n; i++) {
        res += 'a' + a[i];
    }
    return res;
}

inline void add(vector<int>& a) {
    for (int i = a.size() - 1; i > 0; i--) {
        int mx = 0;
        for (int j = 0; j < i; j++) {
            mx = max(mx, a[j]);
        }
        if (mx >= a[i]) {
            a[i]++;
            break;
        } else {
            a[i] = 0;
        }
    }
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> ans;
    vector<int> a(n), ed(n);
    vector<int> mx(n);
    iota(ed.begin(), ed.end(), 0);
    while (a != ed) {
        string s = mk(n, a);
        debug(a);
        ans.emplace_back(s);
        add(a);
    }
    string s = mk(n, ed);
    ans.emplace_back(s);
    sort(ans.begin(), ans.end());
    for (string xx : ans) {
        cout << xx << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K; cin >> N >> K;
    // Kが偶数の場合，a,b,c = K/2 (modK) or a,b,c = 0 (modK)
    // Kが奇数の場合，a,b,c = 0 (modK)
    if (K % 2 == 1){
        cout << (ll)(pow(N / K, 3)) << endl;
    } else {
        cout << (ll)(pow(N / K, 3)) + (ll)(pow((N + K / 2) / K, 3)) << endl;
    }
}

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


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) {
    cout << b + c << endl;
  } else {
    cout << b + (a + b + 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,ans;
string str;
int main(){
  while(scanf("%d",&n)&&n){
    int t[1000001]={0};
    ans=-1;
    for(int i=0;i<n;i++){
      scanf("%d",&a);
      t[a]++;
      if(t[a]>n/2){
	ans=a;
	getline(cin,str);
	break;
      }
    }
    if(ans==-1)printf("NO COLOR\n");
    else printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 5252
n=int(input())
S=input()
L=''
ans=0
for s in S:
    if s=='A':
        L = s #工夫
    elif s=='B' and L=='A':
        L += s
    elif s=='C' and L=='AB':
        ans += 1
        L='' 
    else:
        L=''
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<ll, ll>;
const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(ALLr(a));
  priority_queue<P> q;
  q.push(P(a[1], a[0]));
  q.push(P(a[1], a[0]));
  ll ans = a[0];
  FOR(i, 2, n){
    P p = q.top();
    q.pop();
    ans += p.first;
    q.push(P(a[i], p.first));
    q.push(P(a[i], p.second));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    long double A;
    long double B;
    cin >> A >> B;
    long double C = A * B;
    ll D = C;
    cout << D << endl;
}






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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String   input   = reader.readLine();
    String[] numbers = input.split(" ");
    System.out.println(numbers[2] +" "+ numbers[0] +" "+ numbers[1]);
  }
}

Measured memory_bytes: 20564
using System;

public class AtCoder
{
    public static void Main()
    {
        var line = Console.ReadLine();
        var lineWords = line.Split(' ');
        int n = int.Parse(lineWords[0]);
        int m = int.Parse(lineWords[1]);

        Console.WriteLine(n == m ? "Yes" : "No");
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

class Main{
   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       while(true){
           int a = sc.nextInt();
           if(a == 0){
               break;}
           int[] data = new int[a];
           int count = 0;
           int sum = 0;
           int avg = 0;
       for(int i=0;i<data.length;i++){
           data[i] = sc.nextInt();
           sum += data[i];
       }
       avg = sum/data.length;
       for(int i=0;i<data.length;i++){
           if(data[i] <= avg){
               count++;
           }
       }
       System.out.println(count);
   }
}
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

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

    int N;
    cin >> N;
    Vl t(N), x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    bool ok = true;
    ll t_now = 0, x_now = 0, y_now = 0;
    for (int i = 0; i < N; i++) {
        ll steps = abs(x[i] - x_now) + abs(y[i] - y_now);
        if (t[i] - t_now < steps) {
            ok = false;
        }
        else if ((t[i] - t_now) % 2 != steps % 2) {
            ok = false;
        }
        if (!ok) break;
        t_now = t[i], x_now = x[i], y_now = y[i];
    }

    cout << (ok ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void)
{
  int n, i, j;
  int cards[4][13] = { {0} };
  char marks[4] = {'S', 'H', 'C', 'D'};
  char in_mark;
  int in_rank;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf(" %c %d", &in_mark, &in_rank);
    switch (in_mark) {
    case 'S':
      cards[0][in_rank - 1] = 1;
      break;
    case 'H':
      cards[1][in_rank - 1] = 1;
      break;
    case 'C':
      cards[2][in_rank - 1] = 1;
      break;
    case 'D':
      cards[3][in_rank - 1] = 1;
      break;
    }
  }
  for(i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (cards[i][j] == 0) printf("%c %d\n", marks[i], j + 1);
    }
  }
     return 0;
}

Measured memory_bytes: 596
n =int(input())
x = [0]*n
u = [0]*n
a = 0

for i in range(n):
    x[i], u[i] = map(str,input().split())
    if u[i] == 'JPY':
        a += int(x[i])
    else:
        a += float(x[i]) * 380000 
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s;
int dp[114514][2];

signed main() {
	cin >> s;
	int n = s.size();
	for (int i = 1; i <= n; i++) {
		if (s[i - 1] == '0') {
			dp[i][1] = dp[i - 1][1] * 3 % mod;
			dp[i][0] = dp[i - 1][0];
		}
		else {
			if (i == 1) {
				dp[i][1] = 1;
				dp[i][0] = 2;
			}
			else {
				dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod;
				dp[i][0] = dp[i - 1][0] * 2 % mod;
			}
		}
	}
	cout << (dp[n][0] + dp[n][1]) % mod << endl;
}

Measured memory_bytes: 2048
n = int(input())
d, x = map(int, input().split())

# 各参加者がチョコレートを食べる日付を取得してリストへ格納する
al = [0 for _ in range(n)]
for i in range(n):
    al[i] = int(input())

ans = 0
for i in al:
    ans += ((d-1)//i)
    ans += 1

print(ans+x)

Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int i;
	for (i = 0; i < 5; i = 0) {
		C = C - B;
		if (C < 1) {
			cout << "Yes" << endl;
			break;
		}
		A = A - D;
		if (A < 1) {
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        
        int sec = t / a;
        int result = b * sec;
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pair = pair <int, int>;

ll		rec(string s, int len, ll nb, ll ans, int i){
	nb += s[i] - '0';
	if (i == len - 1)
		return (ans + nb);
	return (rec(s, len, 0, ans + nb, i + 1) + rec(s, len, nb * 10, ans, i + 1));
}

int		main(void)
{
	string	s;
	cin >> s;
	
	cout << rec(s, s.length(), 0, 0, 0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    vector<ll> d(n);
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
// B ***

// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  inputs = input.split("\n");
  
  const N = Number(inputs[0]);
  const arr = [];
  for( let i = 1 ; i  <= N ; i++ ){
    if( i % 3 !== 0 && i % 5 !== 0){
      arr.push(i);
    }
  }

  const sum = arr.reduce( (prev,current) => {
    return BigInt(prev) + BigInt(current);
  });

  console.log(`${sum}`);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 60040
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc103/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N;
    cin >> N;
    int a[N];
    ll ans = 0;
    rep(i, N){
        cin >> a[i];
        ans += (a[i] - 1);
    }
    cout << ans << "\n";
    
    return 0;
}

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

int main(void)
{
  char str[32];
  char after[21];
  int i;
  /* reset */
  memset(str, '\0', sizeof(str));
  memset(after, '\0', sizeof(after));

  fgets(str, sizeof(str), stdin);
  str[strlen(str)-1] = '\0';

  for (i=0; i < strlen(str); i++)
    {
      after[strlen(str)-1-i] = str[i];
    }

  printf("%s\n", after);

  return 0;
}

Measured memory_bytes: 524
if __name__ == '__main__':
    while True:
        [n, k] = [int(i) for i in input().split()]
        if n == 0 and k == 0:
            break
        a = []
        for i in range(n):
            a.append(int(input()))

        old = sum(a[0:k])
        max = old

        for i in range(1, n-k+1):
            new = old - a[i-1] + a[i+k-1]
            if new > max:
                max = new
            old = new

        print(max)



Measured memory_bytes: 9872
#include<bits/stdc++.h>
#define ll long long int
#define modulo 1000000007
#define read(x) ll x; cin>>x;
using namespace std;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    static const auto _ = []() {
        ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
        return 0;
    }();
    read(n);

    vector<string> s;
    for(int i=0;i<n;i++)
    {
        string s1; cin>>s1;
        s.push_back(s1);
    }
  int AC=0,WA=0,TLE=0,RE=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=="AC") {
            AC++;
        }
         if(s[i]=="WA") {
            WA++;
        }
             if(s[i]=="TLE") {
            TLE++;
        }
           if(s[i]=="RE") {
               RE++;
           }
    }
    cout<<"AC x"<<" "<<AC<<endl;
    cout<<"WA x"<<" "<<WA<<endl;
    cout<<"TLE x"<<" "<<TLE<<endl;
    cout<<"RE x"<<" "<<RE<<endl;

}


Measured memory_bytes: 7428
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	string str;
	cin>>str;
	int cnt=0;
	if(str.size()<7){
		cout<<"NO"<<endl;
		return 0;
	}
	string k = "keyence";
	int fl=1;
	for(int i=0;i<7;i++){
		if(str[i]==k[i] && fl==1){
			cnt++;
		}
		else{
			fl = 0;
		}
	}
	fl = 1;
	for(int i=0;i<7;i++){
		if(str[str.size()-1-i]==k[6-i] && fl==1){
			cnt++;
		}
		else{
			fl = 0;
		}
	}
	if(cnt>=7){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
const int N = 1e5 + 5;
int p[N], a[N];
int pwr(int a,int b){
    int ans = 1;
    while(b){
        if(b & 1) 
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
void solve(){
    int n;
    cin >> n;
    fr(i, 1, n)
        cin >> a[i];
    fr(i, 1, n)
        p[i] = (p[i - 1] + pwr(i, mod - 2)) % mod;
    int ans = 0;
    fr(i, 1, n){
        ans += (p[i] * a[i]) % mod;
        ans += (p[n - i + 1] * a[i]) % mod;
        ans -= a[i];
        ans %= mod;
    }
    ans = (ans + mod) % mod;
    fr(i, 1, n) ans = (ans * i) % mod;
    cout << ans << endl;
}
signed main()
{
    IO;
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    fr(i, 1, t){
        solve();
    }
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
};

Measured memory_bytes: 1792
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
    IOS

    int x, n; cin>>x>>n;


    
    set<int> st;
    for(int i = 0; i < n; i++){
        int v; cin>>v;
        st.insert(v);
    }

    int i = x;
    
    for(int d = 0; d <= 100; d++){
        if(!st.count(x-d)){
            cout<<x - d<<"\n";
            return 0;
        }else if(!st.count(x + d)){
            cout<<x + d<<"\n";
            return 0;
        }
    }






}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3620
a, b, c, x, y= map(int, input().split())

ans = a*x + b*y

if x > y:
    ans = min(ans, c * x * 2, y * c * 2+ (x - y) * a)
else:
    ans = min(ans, c * y * 2, x * c * 2 + (y - x) * b)
    
print(ans)

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

int N,T;
vector<pair<string,int> > ans;
inline int conv(int hh,int mm) {
    return hh*60+mm;
}
int main() {
    cin>>N>>T;
    int hh1,mm1,hh2,mm2;

    string st_name,ar_name;
    scanf("%d:%d",&hh1,&mm1);
    cin>>st_name;
    rep(i,N-1) {
        scanf("%d:%d",&hh1,&mm1);
        cin>>st_name;

        scanf("%d:%d",&hh2,&mm2);
        cin>>ar_name;

        int t = conv(hh2,mm2)-conv(hh1,mm1);
        if(t>=T) {
            ans.push_back(make_pair(st_name,t));
        }
    }
    scanf("%d:%d",&mm1,&hh1);
    cin>>st_name;

    cout<<ans.size()<<endl;
    rep(i,ans.size()) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }


    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<1000000007>;

void solve() {
  int n;
  cin >> n;
  vi32 x(n);
  cin >> x;
  vector<mint> p(n - 1);
  p[0] = 1;
  rep(i, n - 2) {
    p[i + 1] = p[i] + (mint) 1 / (i + 2);
  }
  rep(i, n - 1) {
    p[i] *= x[i + 1] - x[i];
  }
  mint sum = 0;
  rep(i, n - 1) sum += p[i];
  reps(i, n - 1) sum *= i;
  cout << sum << endl;
}


Measured memory_bytes: 1024
import numpy as np

N = int(input())
x = []
for i in range(N):
    x.extend(input().split())

a = np.array(x, dtype='int').reshape((N, 2))
s = a[:,0:1] + a[:,1:2]
a = np.hstack((a, s))
a = a[np.argsort(a[:, 2])][::-1, :]
n = np.sum(a[0::2, 0]) - np.sum(a[1::2, 1])
print(n)

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

int main(){
  int N,M;
  cin >> N >> M;
  
  for(int i=0;i<M;i++){
    int A;
    cin >> A;
    N -= A;
    if(N < 0){
      N = -1;
      break;
    }
  }
  
  cout << N << endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> array(n);
  for(int i=0;i<n;i++) cin >> array.at(i);
  sort(array.begin(),array.end());
  int sum = 0;
  for(int i=0;i<k;i++){
    sum += array.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define int long long int
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int32_t main(){
	FIO
	int s,w;
	cin>>s>>w;
	if(w>=s)cout<<"unsafe";
	else cout<<"safe";
	return 0;
}

Measured memory_bytes: 3604
N, D = map(int, input().split())
zahyo = [list(map(int, input().split())) for i in range(N)]

def distance(a, b):
    return (a ** 2 + b ** 2) ** 0.5

kazu = 0
for i in range(N):
    genzai = zahyo[i]
    if distance(genzai[0], genzai[1]) <= D:
        kazu += 1

print(kazu)

Measured memory_bytes: 45668
#define _GLIBCXX_IOSTREAM
#include<bits/stdc++.h>
#define maxn 200100
using namespace std;
typedef pair<int,int> par;
int n,m,ans,mx[maxn<<2],atg[maxn<<2];
vector<int>v[maxn];
void mdy(int o,int l,int r,int ql,int qr,int tg){
	if(ql<=l&&r<=qr){
		atg[o]+=tg,mx[o]+=tg;
		return ;
	}
	int mid=l+r>>1;
	if(ql<=mid)mdy(o<<1,l,mid,ql,qr,tg);
	if(qr>mid)mdy(o<<1|1,mid+1,r,ql,qr,tg);
	mx[o]=max(mx[o<<1],mx[o<<1|1])+atg[o];
}
int qry(int o,int l,int r,int ql,int qr){
	if(ql<=l&&r<=qr)return mx[o];
	int ans=-1000000007,mid=l+r>>1;
	if(ql<=mid)ans=max(ans,qry(o<<1,l,mid,ql,qr));
	if(qr>mid)ans=max(ans,qry(o<<1|1,mid+1,r,ql,qr));
	return ans+atg[o];
}
int main(){
	scanf("%d%d",&n,&m);
	int ans=max(0,n-m);
	for(int i=1,l,r;i<=n;++i)
		scanf("%d%d",&l,&r),v[l].push_back(r);
	for(int i=0;i<=m+1;++i)mdy(1,0,m+1,i,i,i-m-1);
	for(int i=0;i<=m;++i){
		for(int j=0;j<v[i].size();++j)
			mdy(1,0,m+1,0,v[i][j],1);
		ans=max(ans,qry(1,0,m+1,i+1,m+1)-i);
	}
	printf("%d",ans);
}

/*
[1,l][r,m]
man's (l,r)
cnt-l-m+r-1
*/

Measured memory_bytes: 14080
#include <iostream>
using namespace std;
int main(){
    int r,D,X;
    cin>>r>>D>>X;
    int sum=0;
    for (int i=0;i<10;i++){
        if(i==0){
            cout<<r*X-D<<endl;
        sum=r*X-D;
        continue;
        }
        cout<<r*sum-D<<endl;
        sum=r*sum-D;
    }
}

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

int keta(int num){
	int c;
	if(num < 10) num = 1;
	if(num >= 10 && num < 100) num = 2;
	if(num >= 100 && num < 1000) num = 3;
	if(num >= 1000 && num < 10000) num = 4;
	if(num >= 10000 && num < 100000) num = 5;
	if(num >= 100000 && num < 1000000) num = 6;
	if(num >= 1000000) num = 7;
	
	c = num;
	
	return c;
}

int main(){
	int n, a, b, c;
	
	while(scanf("%d %d",&a, &b)!=EOF){
		c = a+b;
		printf("%d\n", keta(c));
	
  }
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
#ifdef KEV
#define debug(i) cerr << #i << ' ' << i << '\n'
#else
#define debug(i) 
#endif
using ll = long long;
const int maxn = 1<<19;
int n, k, a[maxn], pos[maxn];
struct sgt {
	int val[maxn<<1];
	void modify(int i, int v) {
		i += maxn;
		val[i] = v;
		for (;i>>=1;)
			val[i] = max(val[i<<1], val[i<<1|1]);
	}
	int query(int l, int r) {
		int res = 0;
		l = max(l, 1), r = min(r, n+1);
		l += maxn, r += maxn;
		for (;l < r;l>>=1, r>>=1) {
			if (l&1) res = max(res, val[l++]);
			if (r&1) res = max(res, val[--r]);
		}
		return res;
	}
}tree;
void bf(int l, int r) {
	bool c = true;
	while (c) {
		c = false;
		for (int j = l+1;j <= r;++j)
			if (abs(pos[j] - pos[j-1]) >= k && pos[j] < pos[j-1])
				c = true, swap(pos[j], pos[j-1]);//, swap(a[ pos[j] ], a[ pos[j-1] ]), c = true;
		for (int j = r;j >= l+1;--j)
			if (abs(pos[j] - pos[j-1]) >= k && pos[j] < pos[j-1])
				c = true, swap(pos[j], pos[j-1]);//, swap(a[ pos[j] ], a[ pos[j-1] ]), c = true;
	}
}
set<int> st;
void solve(int l, int r) {
	static int cp[maxn], pri[maxn];
	static vector<int> q[maxn];
	if (r <= l) return;
	if (false && r-l+1 <= 100) 
		bf(l, r);
	else {
		int m = l + r >> 1;
		solve(l, m);
		solve(m+1, r);
		for (int i = l;i <= m;++i)
			tree.modify(pos[i], i), st.insert(pos[i]);//,cerr << "modify " << pos[i] << " : " << i << '\n';
		int lst = l-1;
		for (int i = m+1;i <= r;++i) {
			int p = tree.query(1, pos[i]);
			auto invalid = [&]() {
				auto it = st.lower_bound(pos[i]);
				return it != end(st) && *it - pos[i] < k;
			};
			while (lst < p || (lst < m && invalid())) {
				st.erase(pos[++lst]);
//				if (lst != l-1) st.erase(pos[lst]);
//				++lst;
			}
			debug(p) ;

			q[lst].pb(pos[i]);
			//if (l == 1 && r == 4) cerr << lst << '\n' << "P " << p << '\n';
		}
		for (int i = l;i <= m;++i)
			tree.modify(pos[i], 0);
		st.clear();

		int h = l;
		for (int i = l-1;i <= m;++i) {
			if (i != l-1) cp[h++] = pos[i];
			for (int u : q[i]) cp[h++] = u;
			q[i].clear();
		}
		copy(cp+l, cp+r+1, pos+l);
//		cerr << "L R " << l << ' ' << r << '\n';
//		for (int i = l;i <= r;++i)
//			cerr << pos[i] << ' ';
//		cerr << "\n\n";
	}
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for (int i = 1;i <= n;++i)
		cin >> a[i], pos[a[i]] = i;
//	for (int i = 1;i <= n;++i)
//		cerr << pos[i] << ' ';
//	cerr << '\n';
	solve(1, n);

	for (int i = 1;i <= n;++i) a[pos[i]] = i;
//	bf(1, n);
//	for (int i = 1;i <= n;++i)
//		cerr << pos[i] << ' ';
//	cerr << '\n';
	for (int i = 1;i <= n;++i)
		cout << a[i] << '\n';
}


Measured memory_bytes: 65408
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
        int n,m;
        cin>>m;
        while(m--){
            cin>>n;
            int b,a;
            cin>>b;
            int Max=0,Min=100000000;
            while(--n){
                cin>>a;
                int dif=a-b;
                Max=max(Max,dif);
                Min=min(Min,dif);
                b=a;
            }
            if(Min<0)Min*=-1;
            else Min=0;
            cout<<Max<<" "<<Min<<endl;
        }
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		
		int a = 0;
		int b = 0;
		int cnt = 0;
		
		for (char c: s.toCharArray()) {
			if (c == 'a') {
				a++;
			} else if (c == 'b') {
				b++;
			} else {
				cnt++;
			}
		}
		
		
		if (a==1 && b == 1 && cnt ==1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22996
import scala.io.StdIn

object Main {
  
  def main(args: Array[String]): Unit = {
    val s: Vector[Either[Int, Int]] = StdIn.readLine().toVector.map{ c =>
      if (c == 'L') Left(1) else Right(1)
    }
	val rFolded = (2 until s.size).foldLeft(s){ (acc, i) =>
   	  (acc(i - 2), acc(i - 1), acc(i)) match {
        case (Right(x), Right(_), Right(_)) =>  
          acc.updated(i - 2, Right(0)).updated(i, Right(x + 1))
        case (Right(x), Right(_), Left(_)) =>
          acc.updated(i - 2, Right(0)).updated(i, Left(x + 1))
        case _ => acc
      }
    }
    val lrFolded = (0 until s.size - 2).reverse.foldLeft(rFolded){ (acc, i) =>
      (acc(i), acc(i + 1), acc(i + 2)) match {
        case (Left(y), Left(_), Left(x)) =>
          acc.updated(i + 2, Left(0)).updated(i, Left(x + y))
        case (Right(y), Left(_), Left(x)) =>
          acc.updated(i + 2, Left(0)).updated(i, Right(x + y))
        case _ => acc
      }
    }
	println(lrFolded.map{_.fold(identity, identity)}.mkString(" "))
  }
  
}


Measured memory_bytes: 65668
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

vector<lint> edge[MAX_N];
int ans[MAX_N];
bool reach[MAX_N];

int main(void){
    lint N,M;
    cin >> N >> M;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    queue<int> now;
    now.push(0);
    while(!now.empty()){
        int tmp=now.front();
        now.pop();
        rep(i,edge[tmp].size()){
            if(reach[edge[tmp][i]]) continue;
            reach[edge[tmp][i]]=true;
            ans[edge[tmp][i]]=tmp;
            now.push(edge[tmp][i]);
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<N;i++) cout << ans[i]+1 << endl;
}

Measured memory_bytes: 14960
void main()
{
    long h, w;
    rdVals(h, w);

    if (h == 1 || w == 1) 1.writeln;
    else writeln((h * w + 1) / 2);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	int x;
	cin>>x;
	int ans=(x/500)*1000;
	x-=(x/500)*500;
	ans+=(x/5)*5;
	cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

export function Main(input: string) {
    const lines = input.split('\n');    // ?
    const s = lines[0]; // ?
    const t = lines[1]; // ?

    let result: string;

    if (t.length === s.length + 1 && t.slice(0, -1) === s) {
        result = 'Yes';
    } else {
        result = 'No';
    }

    //output
    console.log(result);
    return result;
}

// Don't edit this line!
Main(fs.readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29524
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const int N = 3005;

int dp[N][N];
pair<int, int>a[N];
int n;
int  t;
int solve(int idx, int rem) {
	if (rem<= 0||idx>=n) {
		return 0;
	}
	int& ret = dp[idx][rem];
	if (ret != -1) {
		return ret;
	}
	int choice1 = solve(idx + 1, rem);
	int choice2 = solve(idx + 1, rem - a[idx].first) + a[idx].second;
	ret = max(choice1, choice2);
	return ret;

	
}

int main() {
	
	memset(dp, -1, sizeof(dp));
	
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	cout << solve(0, t);


}

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

class union_find {
	vector<int> par;
	int find(int a) {
		return par[a] < 0 ? a : par[a] = find(par[a]);
	}
public:
	union_find(int n) : par(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] < par[b]) swap(a, b);
		else if (par[a] == par[b]) par[b]--;
		par[a] = b;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	union_find uf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			uf.unite(x, y);
		}
		else {
			printf("%d\n", uf.same(x, y));
		}
	}
	return 0;
}



Measured memory_bytes: 3288