akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long


int main() {
  ll n,s;
  ll* a;
  ll* x;
  
  cin >> n;
  a = new ll[n];
  x = new ll[n];
  rep(i,n) {
    cin >> a[i];
    x[i] = 0;
  }

  s = +1;
  rep(j,n) {
    x[0] += s*a[j];
    s *= -1;
  }
  cout << x[0] << " ";

  for(int i=1;i<n;i++) {
    x[i] = -1*x[i-1] + 2*a[i-1];
    cout << x[i] << " ";
  }
  cout << endl;
  
  
  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt=0,l=s.size();
  for(int i=0; i<l; i++) {
    if(i%2==s[i]-'0') {
      cnt++;
    }
  }
  cout << min(cnt,l-cnt) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int MAXN = 2e5+7;
const int Inf = 0x3f3f3f3f;
 
int pre1[MAXN],pre2[MAXN];
 
int finds(int x,int *pre)
{
    return pre[x] == x? pre[x]:pre[x] = finds(pre[x],pre);
}
 
void join(int x,int y,int *pre)
{
    int px = finds(x,pre);
    int py = finds(y,pre);
    if( px!=py)
    {
        pre[px] = py;
    }
}
int main()
{
    int n,k,l;
    cin>>n>>k>>l;
    for(int i = 1;i<=n;i++)
        pre1[i] = i,pre2[i] = i;
    for(int i = 1;i<=k;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre1);
    }
    for(int i = 1;i<=l;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre2);
    }
    for(int i = 1;i<=n;i++)
    {
        finds(i,pre1);
        finds(i,pre2);
    }
    map<pair<int,int>,int> mp;
    for(int i = 1;i<=n;i++)
    {
        //cout<<pre1[i]<<" | "<<pre2[i]<<endl;
        mp[make_pair(pre1[i],pre2[i])] ++;
    }
    for(int i = 1;i<=n;i++)
    {
        cout<<mp[make_pair(pre1[i],pre2[i])]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 13568
s = gets.strip.split('').map(&:to_i)
inv = []
(0..s.length-1).each do |i|
  if s[0] == 0
    if i.even?
      inv[i]= 0
    else
      inv[i]= 1
    end
  else
    if i.even?
      inv[i]= 1
    else
      inv[i]= 0
    end
  end
end
ans = 0

(0..s.length-1).each do |i|
  ans += (s[i]-inv[i]).abs

end

puts ans

Measured memory_bytes: 8644
// only miss the sun when it starts to snow

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=18, Max=(1<<maxn) + 10;

ll dp[maxn][maxn][2*Max], a[maxn];
pll p[Max];

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

    p[1]={1,1};

    for(int i=2;i<Max;i++){
	p[i]= p[i/2];
	if(i&1) p[i].F+=p[i].S;
	else p[i].S+=p[i].F;
    }
    
    int n; cin>>n;

    for(int i=0;i<n;i++){
	cin>>a[i];
    }
    for(int r=2; r<n; r++){
	for(int l=r-2; l>=0; l--){
	    for(int w=1; w<Max; w++){
		
		dp[l][r][w]= 1e18;
		
		for(int md=l+1; md<r; md++){
		    dp[l][r][w]= min( dp[l][r][w], dp[l][md][2*w] + dp[md][r][2*w+1] + a[md] * (p[w].F + p[w].S) );
		}
	    }
	}
    }
    return cout<<a[0] + a[n-1] + dp[0][n-1][1]<<endl,0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
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<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    cout<<fixed<<setprecision(10);


    ll n; cin>>n;
    vint a(n); rep(i,n) cin>>a[i];
    sort(ALL(a));

    map<ll,ll> m;
    for(auto e:a) m[e]++;

    if(m.size() > 2){
        puts("No");
        return 0;
    }else if(m.size() == 1){
        ll t1 = a.front();
        auto div1 = divisor(m[t1]);
        for(auto e:div1){
            if(e == m[t1]){
                if(e - 1 == t1){
                    puts("Yes");
                    return 0;
                }
            }else{
                if(e == t1){
                    puts("Yes");
                    return 0;
                }
            }
        }
        puts("No");
        return 0;
    }else{
        ll t1,t2;
        t1 = a.front();
        t2 = a.back();
        auto div1 = divisor(m[t1]);
        auto div2 = divisor(m[t2]);
        for(auto e1:div1){
            for(auto e2:div2){
                ll T = e1 + e2;
                // for t1
                bool b1 = T - (int)(e1==m[t1]) == t1;
                // for t2
                bool b2 = T - (int)(e2==m[t2]) == t2;
                if(b1&&b2){
                    puts("Yes");
                    return 0;
                }
            }
        }
        puts("No");
        return 0;
    }



    return 0;

}



Measured memory_bytes: 7296
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()

	a := getDivide(A)
	b := getDivide(B)

	//fmt.Printf("%+v\n", a)
	//fmt.Printf("%+v\n", b)

	out := map[int]int{}
	for k, _ := range a {
		if _, ok := b[k]; ok {
			out[k] = 1
		}
	}

	for k, _ := range b {
		if _, ok := a[k]; ok {
			out[k] = 1
		}
	}

	fmt.Println(len(out) + 1)

}

func getDivide(A int) map[int]int {
	mp := map[int]int{}
	Q := A
	for v := 2; v*v <= Q; v += 1 {
		for A%v == 0 {
			mp[v]++
			A /= v
		}
	}
	if A != 1 {
		mp[A] = 1
	}
	return mp
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;
int main(){
    int A,B;
    string S;
    cin >> A >> B >> S;
    bool frag = 1;
    int a =0;
    char list[10]{'0','1','2','3','4','5','6','7','8','9'} ;
    for(int i = 0;i < A+B+1;i++){
        if(i != A){
            bool frag2 = false;
            for(int j = 0;j < 10;j++){
                if(S[i] == list[j]) frag2 = true;
            }
            if(frag2)a++;
            else frag = 0;
        }
        else{
            if(S[i] != '-') frag = 0;
        }
    }
    if(frag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define MOD 1000000007
//#define MOD 998244353
struct mint {
	int i;
	mint() : i(0) {}
	mint(int x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	template<class T> mint(T x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	mint operator+(const mint x) const {return i + x.i;}
	mint operator-(const mint x) const {return i - x.i;}
	mint operator*(const mint x) const {return (long long)i * x.i;}
	mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;}
	mint inv() {return pow(MOD - 2);}
	template<class T> mint pow(T p) const {
		long long r = 1;
		long long t = i;
		for(; p > 0; p >>= 1) {
			if (p & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	template<class T1, class T2> static mint pow(T1 a, T2 b) {
		long long r = 1;
		long long t = (long long)(a % MOD);
		for(; b > 0; b >>= 1) {
			if (b & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	mint& operator+=(const mint x) {
		i = (i + x.i) % MOD;
		return *this;
	}
	mint& operator-=(const mint x) {
		i = i - x.i;
		if (i < 0) i += MOD;
		return *this;
	}
	mint& operator*=(const mint x) {
		i = (int)((long long)i * x.i % MOD);
		return *this;
	}
	mint& operator/=(const mint x) {
		i = (long long)i * x.pow(MOD - 2).i % MOD;
		return *this;
	}
};

std::ostream& operator<<(std::ostream& os, const mint& m) {
	return os << m.i;
}
vector<vector<int>> to;
pair<mint, mint> dfs(int u, int parent=-1) {
    mint b = 1, w = 1;
    for(int v: to[u]) {
        if (v == parent) continue;
        mint bv, wv;
        tie(bv, wv) = dfs(v, u);
        b *= wv;
        w *= (bv + wv);
    }
    return {b, w};
}

int main() {
    int n;
    cin >> n;
    to.resize(n);
    rep(_, n-1) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    auto p = dfs(0);
    cout << p.first + p.second << endl;
}


Measured memory_bytes: 15464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B;
  cin >> A >> B;

  cout << (((A * B) % 2 == 1) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-22:17:27:25
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int INF = 2e9;

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

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

  vector<int> dp(n + 5, INF);
  dp[0] = 0;

  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= 2; ++j) {
      if (i - j >= 0) {
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }
  //debug(dp);

  cout << dp[n - 1] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=4e18;
const ll MOD=998244353;
const double EPS=1e-7;

ll N;
ll a[100];
int main(){
    cin>>N;
    ll maAbs=0;
    ll maAbsIndex=0;
    for(ll i=0;i<N;i++){
        cin>>a[i];
        if(maAbs <= abs(a[i])){
            maAbs=abs(a[i]);
            maAbsIndex=i;
        }
    }
    vector<P> ans;
    for(ll i=0;i<N;i++){
        a[i]+=a[maAbsIndex];
        ans.push_back(P(maAbsIndex+1 , i+1) );
    }
    if(a[0] > 0){//全部正
        for(ll i=1;i<N;i++){
            if(a[i-1]>a[i]){
                a[i]+=a[i-1];
                ans.push_back(P(i-1 +1 , i +1) );
            }
        }
    }else{
        for(ll i=N-1;i>=1;i--){
            if(a[i-1]>a[i]){
                a[i-1]+=a[i];
                ans.push_back(P(i +1,i-1 +1));
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto p:ans){
        cout<<p.first<<" "<<p.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
using namespace std;
#define MOD 1000000007
map<long long,long long>m;
int main() {
    long long n,a[100005],i,t,x;
    char s[100];
    cin>>s;
    for(i=0;s[i];i++)
    {
        if(i==4)
           cout<<" ";
        cout<<s[i];
    }
    cout<<endl;
    
  return 0;
}

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

int main() {
  int l, r, d, ans = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++) {
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    ll ans=0;
    rep(i,n){
        cin>>h[i];
        if(h[i]>=k)ans++;
    }
    cout<<ans<<endl;

    
    
    return 0;
}


Measured memory_bytes: 1024
import string

def shift_enc(message, n, cap=True):
    output_index = 0
    output = ""
    for chara in message:
        output_index = (string.ascii_uppercase.index(chara.upper()) + int(n)) % 26
        output += string.ascii_uppercase[output_index]
    if cap == False:
        output = output.lower()
    return output

N = int(input())
S = str(input())

print(shift_enc(S, N, True))

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define long long long
using namespace std;
const long N=1e6;
long dd[N+2],mm[N+2],cc[N+2],dm[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  long n;cin>>n;
  string s;cin>>s;
  for(long i=1;i<=n;i++)
  {
    dd[i]=dd[i-1];mm[i]=mm[i-1];cc[i]=cc[i-1];
    dm[i]=dm[i-1];
    if(s[i-1]=='D')dd[i]++;
    if(s[i-1]=='M')
    {
      mm[i]++;dm[i]+=dd[i];
    }
    if(s[i-1]=='C')cc[i]++;
  }
  long q;cin>>q;
  while(q--)
  {
    long k;cin>>k;long ans=0;
    for(long i=1;i<=n;i++)
    {
      if(s[i-1]!='C')continue;

      long pr=max(i-k,0LL);

      long tt=dm[i]-dm[pr];
      tt-=(dd[pr]*(mm[i]-mm[pr]));
      ans+=tt;
    }
    cout<<ans<<"\n";
  }
  return 0;
}

Measured memory_bytes: 32668
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[200010] = {-1},ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i + 1];
	for(int i = 0;i < n;i++){
		if(a[i] + 2 <= a[i + 1]){
			cout << -1 << endl;
			return 0;
		}
		if(a[i] + 1 == a[i + 1] && a[i + 1]) ans++;
		else ans += a[i + 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
const int MAXn=100;
const int INFTY=1<<21;

int n,M[MAXn][MAXn],col[MAXn],d[MAXn],p[MAXn];

void dijkstra(int s)
{
	for(int i=0;i<n;i++)
	{
		col[i]=0;
		d[i]=INFTY;
	}
	d[s]=0;
	p[s]=-1;
	
	while(1)
	{
		int mincost=INFTY;
		int u;
		for(int i=0;i<n;i++)
		{
			if(col[i]!=2&&d[i]<mincost)
			{
				mincost=d[i];
				u=i;
			}
		}
		if(mincost==INFTY)break;
		col[u]=2;
		for(int v=0;v<n;v++)
		{
			if(col[v]!=2&&M[u][v]!=INFTY)
			{
				if(d[u]+M[u][v]<d[v])
				{
					d[v]=d[u]+M[u][v];
					p[v]=u;
					col[v]=1;
				}
			}
		}
	}
	
	for(int i=0;i<n;i++)cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
	
	return;
}

int main() {
	cin>>n;
	int id,k,v,c;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)M[i][j]=INFTY;
	for(int i=0;i<n;i++)
	{
		cin>>id>>k;
		for(int j=0;j<k;j++)
		{
			cin>>v>>c;
			M[id][v]=c;
		}
	}
	dijkstra(0);
	return 0;
}

Measured memory_bytes: 3112
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

s = list(input())
n = len(s)

for i in range((n-1)//2+1):
    if s[i] != s[n-2-i]:
        print(-1)
        exit()

if s[0] == '0':
    print(-1)
    exit()

if s[n-1] == '1':
    print(-1)
    exit()

from_ = 1
to_ = 2
ans = []
for i in range(n-1):
    ans.append((from_,to_))
    if s[i] == '1':
        from_ = to_
        to_ += 1
    else:
        to_ += 1

for a in ans:
    print(*a)

Measured memory_bytes: 54792
n = int(input())
h = list(map(int, input().split()))

mx = h[0]

flag = True
for i in range(1, n):
  if h[i] < mx - 1:
    print("No")
    flag = False
    break
  else:
    mx = max(mx, h[i])

if flag:
  print("Yes")

Measured memory_bytes: 63984
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
typedef long long ll;

using namespace std;

ll func(ll a,ll b){
    ll cnta=0,cntb=0;
    while (a > 0){
	cnta++;
	a/=10;
    }
    while (b > 0){
	cntb++;
	b/=10;
    }
    return max(cnta,cntb);
}

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

    ll res=11;
    for (ll i=1;i<=sqrt(N);i++){
	if (N%i == 0){
	   res=min(res,func(i,N/i));
	}
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next(), b = scanner.next();
		String s = a + b;
		int num = Integer.valueOf(s);
		double sqrt = Math.sqrt(num);
		if((int)sqrt == sqrt){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

int num[1000];

int main()
{
	int n;
	std::cin>>n;
	char op[2];
	for(int i=1;i<=n;i++)
	{
		scanf("%s",op);
		num[op[0]]=1;
	}
	int res=num['Y']+num['W']+num['G']+num['P'];
	if(res==3)
		puts("Three");
	else
		puts("Four");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int n = s.size();
  cout << s[0] << n - 2 << s[n - 1] << endl;


  
  return 0;
}

Measured memory_bytes: 256
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,x,y;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d %d",&n,&x,&y);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			int at=j-i;
			at=min(at,abs(i-x)+abs(j-y)+1);
			at=min(at,abs(i-y)+abs(j-x)+1);
			b[at]++;
		}
	}
	for(int i=1;i<n;i++)printf("%d\n",b[i]);
	return 0;
}



Measured memory_bytes: 256
using System;

namespace AtCoder.ABC093
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            string s1 = input[0];

            int a = 0;
            int b = 0;
            int c = 0;
            for (int i = 0; i < s1.Length; i++)
            {
                if (s1[i].ToString() == "a")
                {
                    a++;
                }
                if (s1[i].ToString() == "b")
                {
                    b++;
                }
                if (s1[i].ToString() == "c")
                {
                    c++;
                }
            }
        
            Console.WriteLine(a == 1 && b ==1 && c == 1 ? "Yes": "No");
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC093.A.Solve();
        }
    }
}


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

int main(){
  int q,n,c;
  cin >> q;
  while(q--){
    cin >> n; c=0;
    for(;;){
      int m = -1,k = 10;
      if(n<10){
	cout << c << endl;
	break;
      }
      for(int i=0;i<5;i++){
	m=max(m,(n/k)*(n%k));
	k*=10;
      }
      n = m; c++;
    }
  }
}

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

typedef long long ll;

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

int main(){
  int n;
  ll d[10],v[10],t[10];

  for(;;){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> d[i] >> v[i];
    t[0] = 1;
    for(int i=1;i<n;i++){
      t[i] = t[i-1]*d[i-1]*v[i];
      for(int j=0;j<i;j++)t[j] *= d[i]*v[i-1];
      ll T = t[0];
      for(int j=1;j<=i;j++)T = gcd(T,t[j]);
      for(int j=0;j<=i;j++)t[j]/=T;
    }

    for(int i=0;i<n;i++)cout << t[i] << endl;
  }
}

Measured memory_bytes: 0
n, m = map(int, input().split())
info = [tuple(map(int, input().split())) for _ in range(m)]
# print(info)
num = [-1] * n
answer = ''
ok = True
for si, ci in info:
    # print(si, ci)
    if num[si-1] == -1:
        num[si-1] = ci
    if num[si-1] != ci or (num[0] == 0 and n != 1):
        ok = False
    # if num[0] == 0 and n != 1:
    #     ok = False


if ok:
    for i in range(n):
        if num[i] == -1:
            if i == 0:
                if n == 1:
                    answer += '0'
                else:
                    answer += '1'
            else:
                answer += '0'
        else:
            answer += str(num[i])
    print(answer)
else:
    print(-1)


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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;

ll A(ll x,ll y)
{
    //if(y==1)
    if(x<y)
        return x;
    return A(x/y,y)+x%y;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll n,s;
    cin>>n>>s;
    if(n==s) {
        cout<<n+1<<endl;
        return 0;
    }
    if(n<s){
        cout<<-1<<endl;
        return 0;
    }
    for(ll i=2;i*i<=n+1;i++){
       if(A(n,i)==s) {
        cout<<i;
        return 0;
       }
    }
    ll m=n-s;
    ll ans=1e12;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){
             if(A(n,m/i+1)==s)
             ans=min(ans,m/i+1);
        }
    }
    if(ans==1e12)
    cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int n;
               cin>>n;
               if(n==1)
                    cout<<1;
               else if(n%2==0)
               {
                    double ans = 0.5;
                    cout<<fixed<<setprecision(10)<<ans;
               }
               else
               {
                    float ans = 1.0*((n/2 + 1.0)/n);
                    cout<<fixed<<setprecision(10)<<ans;
               }
       }
}


Measured memory_bytes: 3780
import math
def main():
    A, B, H, M = map(int, input().split())
    pi2 = 2.0 * math.pi
    ht = (H * 60.0 + M) * pi2 / (60.0 * 12)
    mt = pi2 * M / 60.0
    C = abs(ht - mt)
    c2 = A**2 + B**2 - 2 * A * B * math.cos(C)
    c = math.sqrt(c2)
    print(c)


if __name__ == '__main__':
    main()

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

int main() {
  string S;
  cin >> S;
  
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 3560
#include<stdio.h>
int main(void){
  int a,b,n,m;
  while(scanf("%d %d",&a,&b)!=EOF){
    n = 0;
    if(a==0&&b==0)return(0);
    m = a + b;
    while(m>=10){
      m /= 10;
      n++;
    }
    printf("%d\n",n+1);
  }
  return(0);
}

Measured memory_bytes: 1736
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;
    char s[60][60];
    imfor(i, h) {
        imfor(j, w) {
            cin >> s[i][j];
        }
    }
    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0, 0, 1, -1};
    bool ans = true;
    imfor(i, h) {
        imfor(j, w) {
            if (s[i][j] == '#') {
                bool f = false;
                imfor(k, 4) {
                    int posx = j + dx[k];
                    int posy = i + dy[k];
                    if (0 <= posx && posx <= w - 1 && 0 <= posy && posy <= h - 1) {
                        if (s[posy][posx] == '#') {
                            f = true;
                        }
                    }
                }
                if (!f) {
                    ans = false;
                }
            }
        }
    }
    if (ans) {
            cout << "Yes" << endl;
    }
    else {
            cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

bool prime(int n){
    for (int i = 2; i*i <= n; ++i) {
        if(n%i == 0) return false;
    }
    return n != 1;
}

int main() {
    int n;
    ll ans = 1;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        if(!prime(i)) continue;
        int tmp = n;
        ll cnt = 0;
        while(tmp > 0){
            tmp /= i;
            cnt += tmp%mod;
        }
        ans = (ans*(cnt+1))%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = list(input())
T = input()
ans = "UNRESTORABLE"
for i in range(len(S)-len(T)+1):
    key = S[:]
    for n,t in enumerate(T):
        if key[i+n] not in ("?",t):break
        else:
            key[i+n] = t
        if n == len(T)-1:
            ans = "".join(key).replace("?","a")
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int num1[10]={};
        int num2[10]={};
        int num3[10]={};
        int num[10];
        char mo[10];
        //cout<<"a"<<endl;
        for(int j=0;j<9;j++){
            cin>>num[j];
        }
        //cout<<"b"<<endl;
        for(int j=0;j<9;j++){
            //cout<<j<<" a"<<endl;
            cin>>mo[j];
            if(mo[j]=='R'){
                num1[num[j]]++;
            }
            else if(mo[j]=='G'){
                num2[num[j]]++;
            }
            else num3[num[j]]++;
        }
        int flag=1;
        for(int j=1;j<10;j++){
            if(num1[j]%3!=0){
                if(num1[j+1]==0 || num1[j+2]==0){
                    flag=0;
                    break;
                }
                else{
                    num1[j]--;
                    num1[j+1]--;
                    num1[j+2]--;
                    j--;
                }
            }
        }
        for(int j=1;j<10;j++){
            if(num2[j]%3!=0){
                if(num2[j+1]==0 || num2[j+2]==0){
                    flag=0;
                    break;
                }
                else{
                    num2[j]--;
                    num2[j+1]--;
                    num2[j+2]--;
                    j--;
                }
            }
        }
        for(int j=1;j<10;j++){
            if(num3[j]%3!=0){
                if(num3[j+1]==0 || num3[j+2]==0){
                    flag=0;
                    break;
                }
                else{
                    num3[j]--;
                    num3[j+1]--;
                    num3[j+2]--;
                    j--;
                }
            }
        }
        if(flag) cout<<1<<endl;
        else cout<<0<<endl;
    }
}



Measured memory_bytes: 3092
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int x = scanner.nextInt();
    List<Integer> intArray = new ArrayList<Integer>();

    for (int i = 0; i < n; i++) {
      int y = scanner.nextInt();
      intArray.add(y);
    }

    int count = 1;
    int sum = 0;


    for (Integer i : intArray) {
      sum  = sum + i;
      if(sum > x) {
        break;
      }
      count++;
    }

    System.out.println(count);
  }

}

Measured memory_bytes: 22100
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int arr[] = new int[n];
	    for(int i=0;i<n;i++){
	        arr[i] = sc.nextInt();
	    }
	    int seen[] = new int[n+1];
	    int max = -1;
	    for(int i=0;i<n;i++){
	        if(seen[arr[i]-1]!=0){
	            seen[arr[i]] = seen[arr[i] - 1]+1;
	        } else {
	            seen[arr[i]] = 1;
	        }
	        max = Math.max(seen[arr[i]], max);
	    }
	    System.out.println(n-max);
	}
}

Measured memory_bytes: 86944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    int n;
    ll c,k;
    cin >> n >> c >> k;
    ll t[n];
    for(int i=0; i<n; i++) {
        cin >> t[i];
    }
    sort(t,t+n);
    ll people = 0;
    ll res = 0;
    ll start = 0;
    for(int i=0; i<n; i++) {
        if(people>0 && t[i]-start>k) {
            people=0;
            res++;
        }
        if(people == 0) {
            start = t[i];
        }
        ++people;
        if(people == c) {
            res++;
            people = 0;
        }
    }
    if(people > 0) {
        res++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1024
def main():
    from heapq import heappush, heappop

    n = int(input())
    a = [[int(x) for x in input().split()] for _ in range(n)]

    for i in range(n):
        for j in range(n):
            if a[i][j] != min(a[i][k] + a[k][j] for k in range(n)):
                print(-1)
                return

    h = []
    for r, row in enumerate(a):
        for c, cell in enumerate(row):
            if r == c: break
            heappush(h, (cell, r, c))  # dist,r,c

    pathes = []
    while h:
        dist, r, c = heappop(h)

        is_path = True
        for k in range(n):
            if k == r or k == c: continue
            if dist >= a[r][k] + a[k][c]:
                is_path = False
                break

        if is_path:
            pathes.append(dist)

    print(sum(pathes))


if __name__ == '__main__':
    main()


Measured memory_bytes: 55516
PROGRAM goToSchool
      IMPLICIT NONE
      INTEGER :: N
      INTEGER,ALLOCATABLE :: A(:),ans(:)
      
      INTEGER :: i, buffer, in ,out
      LOGICAL :: flag
      
      
      READ*,N
      ALLOCATE( A(N),ans(N) )
      READ*,A(:)
      


!      o:DO out = 1,N !order
!        DO in = 1,N !num of student
!          IF(A(in)==out)THEN
!            ans(out) = in
!            CYCLE o
!          END IF
!        END DO 
!      END DO o
      DO i = 1,N
        ans(A(i)) = i
      END DO
      
      
      
      print*,ans(:)
      
      END PROGRAM

Measured memory_bytes: 3328
#include<stdio.h>
 
int main(){
 
  int i,j,n,mini,si,a1[37],a2[37],count=1,f=0;
  char sc,c1[37],c2[37];
 
  //load N
  scanf("%d",&n);
 
  //load number
  for(i=1;i<=n;i++){
    scanf(" %c%d",&c1[i],&a1[i]);
    a2[i]=a1[i];
    c2[i]=c1[i];
  }
 
 
 
  //BubbleSort
  for(i=1;i<=n;i++){
    for(j=n;j>=i+1;j--){
      //swap
      if(a1[j]<a1[j-1]){
        si=a1[j];
        a1[j]=a1[j-1];
        a1[j-1]=si;
    sc=c1[j];
    c1[j]=c1[j-1];
    c1[j-1]=sc;
 
    }
    }
  }
  //print
  for(i=1;i<=n;i++){
    printf("%c%d",c1[i],a1[i]);
    if(i!=n){
      printf(" ");
    }
  }
    printf("\n");
 
    //stability
    printf("Stable\n");
 
  //SelectionSort
  for(i=1;i<=n;i++){
    mini=i;
    for(j=i;j<=n;j++){
      if(a2[j]<a2[mini]){
        mini=j;
      }
    }
      //swap
      si=a2[i];
      a2[i]=a2[mini];
      a2[mini]=si;
      sc=c2[i];
      c2[i]=c2[mini];
      c2[mini]=sc;
  }
 
 
  //print
  for(i=1;i<=n;i++){
    printf("%c%d",c2[i],a2[i]);
    if(i!=n){
      printf(" ");
    }
  }
  printf("\n");
 
  //stability
  f=0;
  for(i=1;i<=n;i++){
    if(c2[i]!=c1[i]){
      printf("Not stable\n");
      f=1;
      break;
    }
  }  
  if(f==0)printf("Stable\n");
   
   
   
 
  return 0;
 
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll A,B,M; cin >> A >> B >> M;
    vector<ll> a(A),b(B);
    for(int i = 0; i < A; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < B; ++i){
        cin >> b[i];
    }
    ll ans = LOWINF;
    for(int i = 0; i < M; ++i){
        ll x,y,c; cin >> x >> y >> c;
        x--,y--;
        chmin(ans,a[x]+b[y]-c);
    }
    chmin(ans,*min_element(ALL(a)) + *min_element(ALL(b)));
    cout << ans << endl;

    return 0;
}


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

#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 fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

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 pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
	int n; scanf("%d", &n);
	vpi ans(n + 1);
	for1(i, n) {
		ans[i].second = i;
		scanf("%d", &ans[i].first);
	}
	sort(all(ans));
	for1(i, n)
		printf("%d ", ans[i].second);
	return 0;
}










Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

//四近傍
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int bfs(const vector<string> &f, int x, int y) {
    int h = f.size(), w = f[0].size();
    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<pint> q;

    int res = 0;
    q.push({x, y});
    dist[x][y] = 0;

    while (!q.empty()) {
        int x = q.front().first, y = q.front().second;
        res = max(res, dist[x][y]);
        q.pop();
        for(int i = 0; i < 4; i++) {
            int nx = x+dx[i];
            int ny = y+dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (f[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                q.push({nx, ny});
            }
        }
    }
    return res;
}

int main() {

    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    REP(i, h) cin >> field[i];

    int res = 0;
    for(int x = 0; x < h; x++) {
        for(int y = 0; y < w; y++) {
            if (field[x][y] == '#') continue;
            res = max(res, bfs(field, x, y));
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {

		static int INF = 1 << 29;

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int[] yen = in.nextIntArray(3);
			int min = INF;
			for (int i = 0; i < 3; i++) {
				for (int j = i + 1; j < 3; j++) {
					min = Math.min(yen[i]+yen[j], min);
				}
			}
			System.out.println(min);


		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
using P = pair<ll,ll>;

int main(){
  ll n;cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n){
    ll x,y;cin >> x >> y;
    a.at(i) = x+y;
    b.at(i) = x-y;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  ll ans = max(a.back()-a.front(),b.back()-b.front());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6428
-- ABC088 D Grid Repainting
import Control.Monad
import qualified Data.Set as Set
import Data.Maybe
import Data.Array
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  (h:w:_) <- fmap (map read . words) getLine :: IO [Int]
  ms <- replicateM h $ B.getLine :: IO [B.ByteString]
  -- print $ toMaze (h, w) ms
  print . solve (1, 1) (h, w) . toMaze (h, w) $ ms

type Position = (Int, Int)
type Maze = Array Position Bool
toMaze :: (Int, Int) -> [B.ByteString] -> Maze
toMaze (n, m) = listArray ((1,1), (n,m)) . join . map (map (=='.') . B.unpack)

solve :: Position -> Position -> Maze -> Int
solve start goal maze = numOfWhite - 1 - (bfs (Set.singleton start) (Set.singleton start) 0)
  where
    numOfWhite = length . filter id $ elems maze
    bfs :: Set.Set Position -> Set.Set Position -> Int -> Int
    bfs visiting visited n
      | visiting == Set.empty = numOfWhite
      | goal `Set.member` visiting = n
      | otherwise = bfs visit (Set.union visited visit) (n + 1)
        where
          adjacents = Set.fromList . join . map step $ Set.toList visiting
          visit = adjacents Set.\\ visited

    step :: Position -> [Position]
    step (x,y) = validate [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]

    validate :: [Position] -> [Position]
    validate = filter (\p -> isInRange p (bounds maze) && maze!p)

    isInRange :: Position -> (Position, Position) -> Bool
    isInRange p (l, u) = lx <= px
                        && px <= ux
                        && ly <= py
                        && py <= uy
      where
        (px,py) = p
        (lx,ly) = l
        (ux,uy) = u


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

int main() {
	long n,m,r,g,b,i,j,k,cur,ans=0,res;
	cin >> r >> g >>  b >> n;
	
	
	for(i=0; i<=n/r; i++){
		for(j=0; j<=(n-i*r)/g; j++){
			if((n-i*r-j*g)%b ==0){
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"bufio"
	"fmt"
	"strings"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}
 
func main() {
	sc.Split(bufio.ScanWords)
	nextInt()
	S := nextString()
	fmt.Println(strings.Count(S, "ABC"))
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  int higher[2] = { 0,0 };
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> A[i];
    
    if (higher[0] < A[i])
    {
      higher[1] = higher[0];
      higher[0] = A[i];
    }
    else if (higher[1] < A[i]) higher[1] = A[i];
  }

  for (int i = 0; i < N; ++i)
  {
    if (higher[0] != A[i]) cout << higher[0] << endl;
    else cout << higher[1] << endl;
  }
}

Measured memory_bytes: 2432