akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >>S ;
  if(S.size()%2!=0)S+='z';
  rep(i,1,S.size()){
    if(S[i-1]!='h'||S[i]!='i')flag=1;
    i++;
  }
  if(flag)Out("No");
  else Out("Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  ll n,k,ans=0;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  
  sort(a,a+n);
  
  for(int i=1; i<=n-1; i++){
    k = n-(i/2);
    ans += a[k-1];
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5156
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int h,w,cnt;
int d[55][55];
char maze[55][55];
queue<PII> Q;

//移動用のベクトル
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

//(1,1)から(h,w)までの最短距離を幅優先で求める
int bfs()
{
	//すべての点をINFで初期化
	REP(i,h+1)
	{
		REP(j,w+1)
		{
			d[i][j]=INF;
		}
	}
	//スタート点をキューにいれ、その距離を0にする
	Q.push(MP(1,1));d[1][1]=1;
	//キューが空になるまでループ
	while(Q.size())
	{
		//キューの先頭を取り出す
		PII p=Q.front();Q.pop();
		//取り出した状態がゴールなら探索をやめる
		if(p.first==h&&p.second==w)break;
		//移動４方向をループ
		for(int i=0;i<4;i++)
		{
			//移動後の点をnx,nyとする
			int nx=p.first+dx[i];
			int ny=p.second+dy[i];
			//移動可能判定と未訪問判定
			if(1<=nx&&nx<=h&&1<=ny&&ny<=w&&maze[nx][ny]=='.'&&d[nx][ny]==INF)
			{
				//移動できるならキューに入れ、その距離をpからの距離+1で確定
				Q.push(MP(nx,ny));
				d[nx][ny]=d[p.first][p.second]+1;
			}
		}
	}
	return d[h][w];
}

int main()
{
	cin>>h>>w;
	REP(i,h)
	{
		REP(j,w)
		{
			cin>>maze[i+1][j+1];
			if(maze[i+1][j+1]=='.')cnt++;
		}
	}
	int minroot=bfs();
	if(minroot==INF)cout<<"-1"<<endl;
	else cout<<cnt-minroot<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin>>n;
  cout<<a[n-1];
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll h,w,d ;
	cin >> h >> w >> d ;
	map<ll,pll> m ;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ll a ; cin >> a ;
			m[a] = {i,j} ;
		}
	}
	vvll sum(d,vll(1,0)) ;
	for(int i=0;i<d;i++){
		for(int j=i+d;j<=h*w;j+=d){
			sum.at(i).emplace_back(sum.at(i).at(sum.at(i).size()-1)+sa(m[j].first,m[j-d].first)+sa(m[j].second,m[j-d].second)) ;
		}
	}
	ll q ; cin >> q ;
	for(int i=0;i<q;i++){
		ll l,r ;
		cin >> l >> r ;
		cout << sum.at(r%d).at(r/d)-sum.at(l%d).at(l/d) << endl ;
	}
}


Measured memory_bytes: 11008
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod 1000000007 //1e9+7
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,n,k,r,g,b,cnt=0;
    string s;
    cin>>r>>g>>b>>n;
    for(i=0;i<=n;i+=r)
    for(j=0;i+j<=n;j+=g)
        if((n-i-j)%b==0) cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  std::vector<int> ruisekiwa(n,0);
  rep(i,n) {
    if(i == 0) continue;
    int w_or_e = 0;
    if(s.at(i-1) == 'W') w_or_e = 1;
    ruisekiwa.at(i) = ruisekiwa.at(i - 1) + w_or_e;
  }

  std::vector<int> ruisekiwa2(n,0);
  for(int i = n - 1; i >= 0; i--) {
    if(i == n-1) continue;
    int w_or_e2 = 0;
    if(s.at(i+1) == 'E') w_or_e2 = 1;
    ruisekiwa2.at(i) = ruisekiwa2.at(i + 1) + w_or_e2;
  }

  std::vector<int> ruiseki_sum(n,0);
  int minvalue = INF;
  rep(i,n) {
    ruiseki_sum.at(i) = ruisekiwa.at(i) + ruisekiwa2.at(i);
    if(minvalue > ruiseki_sum.at(i)) minvalue = ruiseki_sum.at(i);
  }


cout << minvalue << endl;
  
}



Measured memory_bytes: 4228
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        
        System.out.println(Character.toString(a.charAt(0)) + b.charAt(1) + c.charAt(2));
    }
}


Measured memory_bytes: 20692
#include <iostream>

using namespace std;

int main(){
    string keyword;
    string strori;
    int count=0;
    cin >> keyword;
    while(cin >> strori){
      string str="";
        for(int i=0;i<strori.size();i++){
            str += tolower(strori[i]);
        }
        //cout << str << endl;
        if(strori=="END_OF_TEXT"){
            break;
        }
        else if(str==keyword){
            count += 1;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3204
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    long long a,b;
    cin >> a  >> b;
    if((b+a)%2==0){
        cout << ((b+a)/2) << endl;
    }
    else{
        cout << "IMPOSSIBLE" <<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
   

fast;

ll n;
cin>>n;

ll a[n+1];
for(ll i=1;i<=n;i++)
    cin>>a[i];

ll ct=0;
for(ll i=1;i<=n;i+=2)
    if(a[i]&1)ct++;

cout<<ct;

}


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

int main() {
	string s;
	cin>>s;
	set<string>T;
	int k;
	cin>>k;
	for(int i=0;i<s.size();i++){
		for(int j=1;j<=k+1;j++){
			T.insert(s.substr(i,j));
		}
	}

    auto itr = T.begin();
    for(int i = 0; i < k-1; ++i){
        ++itr;	
    }
    cout <<*itr;
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int x[100010];
int diff[100010];

int gcd(int x, int y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main()
{
	int N, X;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	x[N] = X;
	sort(x, x + N + 1);
	for (int i = 0; i < N; i++) {
		diff[i] = x[i + 1] - x[i];
	}
	int ans = diff[0];
	for (int i = 0; i < N; i++) {
		ans = gcd(ans, diff[i]);
		//cout << ans << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4224
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

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


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int m, f, b;
	cin >> m >> f >> b;
	int ans = 0;
	if (m < b) {
		ans = b - m;
		if (ans > f) {
			cout << "NA\n";
			return 0;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3092
N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(1, N + 1):
    a.append(a[i - 1] * 2 + 3)
    p.append(p[i - 1] * 2 + 1)


def F(n, x):
    if n == 0:
        return 1
    if x == 1:
        return 0
    elif x <= 1 + a[n - 1]:
        return F(n - 1, x - 1)
    elif x == 2 + a[n - 1]:
        return p[n - 1] + 1
    elif x <= 2 + 2 * a[n - 1]:
        return p[n - 1] + 1 + F(n - 1, x - 2 - a[n - 1])
    else:
        return 2 * p[n - 1] + 1

print(F(N, X))



Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

	void submit() {
		int n = nextInt();
		int[] ts = new int[n + 1];
		int[] xs = new int[n + 1];
		int[] ys = new int[n + 1];
		
		for (int i = 1; i <= n; i++) {
			ts[i] = nextInt();
			xs[i] = nextInt();
			ys[i] = nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			int d1 = Math.abs(xs[i + 1] - xs[i]) + Math.abs(ys[i + 1] - ys[i]);
			int d2 = ts[i + 1] - ts[i];
			if (d1 <= d2 && d1 % 2 == d2 % 2) {
				
			} else{
				out.println("No");
				return;
			}
		}
		
		out.println("Yes");
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 41344
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	int N = ni();
    	int W = ni();
    	int[][] wv = new int[N][2];
    	for (int i = 0; i < N; i++) {
			wv[i] = ndi(2);
		}
    	long[][] dp = new long[2][100010];
    	Arrays.fill(dp[0], 1000000000000000000L);
    	Arrays.fill(dp[1], 1000000000000000000L);
    	dp[0][0] = 0;
    	int from = 0, to = 1;
    	for (int i = 0; i < N; i++) {
    		from = (i & 1);
    		to = (from + 1) & 1;
    		for (int j = 0; j <= 100000; j++) {
    			if(dp[from][j] + wv[i][0] <= W)
    				dp[to][j + wv[i][1]] = Math.min(dp[to][j + wv[i][1]], 
    												dp[from][j] + wv[i][0]); 
    			dp[to][j] = Math.min(dp[to][j], dp[from][j]); 
			}
		}
    	long ans = 0;
		for (int j = 0; j <= 100000; j++) {
			if(dp[to][j] <= W)	ans = j;
		}
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 28116
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cstring>
using namespace std;

string N;
int dp[11][2][2][8];
vector<int> num;

int main(void)
{
	cin >> N;
	memset(dp, sizeof(dp), 0);
	dp[0][0][0][0] = 1;

	num.push_back(3);
	num.push_back(5);
	num.push_back(7);

	// dp[pos][isStart][isSmall][numberFlag]
	for(int i=0; i<N.size(); i++){
		// 先頭から0埋め
		// 必ず小さくなる
		for(int j=0; j<2; j++)
			dp[i+1][0][1][0] += dp[i][0][j][0];
		
		int n = N[i] - '0';
		for(int j=0; j<2; j++){
			// 357埋め
			for(int k=0; k<num.size(); k++){
				int kBit = 1 << k;
				for(int bit=0; bit<(1<<num.size()); bit++){
					// まだ分からない
					if(num[k] == n)
						dp[i+1][1][0][kBit|bit] += dp[i][j][0][bit];

					// 小さいのが確定
					if(num[k] < n)
						dp[i+1][1][1][kBit|bit] += dp[i][j][0][bit];

					// 既に小さい
					dp[i+1][1][1][kBit|bit] += dp[i][j][1][bit];
				}
			}
		}
	}

	cout << dp[N.size()][1][1][7] + dp[N.size()][1][0][7] << endl;

	return 0;
}


Measured memory_bytes: 256
MOD = 998244353
class SegmentTree:
    def __init__(self, a):
        self.padding = 0
        self.n = len(a)
        self.N = 2 ** (self.n-1).bit_length()
        self.seg_data = [self.padding]*(self.N-1) + a + [self.padding]*(self.N-self.n)
        for i in range(2*self.N-2, 0, -2):
            self.seg_data[(i-1)//2] = self.seg_data[i] + self.seg_data[i-1]
    
    def __len__(self):
        return self.n
    
    def update(self, i, x):
        idx = self.N - 1 + i
        self.seg_data[idx] += x
        self.seg_data[idx] %= MOD
        while idx:
            idx = (idx-1) // 2
            self.seg_data[idx] = (self.seg_data[2*idx+1] + self.seg_data[2*idx+2]) % MOD
    
    def query(self, i, j):
        # [i, j)
        if i == j:
            return self.seg_data[self.N - 1 + i] % MOD
        else:
            idx1 = self.N - 1 + i
            idx2 = self.N - 2 + j # 閉区間にする
            result = self.padding
            while idx1 < idx2 + 1:
                if idx1&1 == 0: # idx1が偶数
                    result = (result + self.seg_data[idx1]) % MOD
                if idx2&1 == 1: # idx2が奇数
                    result = (result + self.seg_data[idx2]) % MOD
                    idx2 -= 1
                idx1 //= 2
                idx2 = (idx2 - 1)//2
            return result


N, K = map(int, input().split())
LR = [tuple(map(int, input().split())) for i in range(K)]
a = [0] * (N+1)
a[1] = 1
dp = SegmentTree(a)
for i in range(2, N+1):
    for l, r in LR:
        ll = max(0, i - l)
        rr = max(0, i - r)
        dp.update(i, dp.query(rr, ll+1))

print(dp.query(N, N+1))

Measured memory_bytes: 85112
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n,x,m=MI()
    seq=[x]
    y=x
    for i in range(2*10**5+10):
        y=((y%m)**2)%m
        seq.append(y)
        #print(y)
    #print(seq)
    z=seq[m-1]
    repeat=[]
    for i in range(1,m+1):
        repeat.append(seq[i+m-1])
        if seq[i+m-1]==z:
            rep=i
            #print(i)
            break
    #print(len(repeat)==m)
    if n<=m:
        print(sum(seq[:n]))
    else:
        ans=sum(seq[:m])
        #print(repeat[:1])
        counts=(n-m)//rep
        S=sum(repeat)
        ans+=S*counts
        rest=(n-m)%rep
        last=m-1+counts*rep
        '''for i in range(last+1,n):
            ans+=repeat[(i-(m-1))%rep]'''
        for i in range(rest):
            ans+=repeat[i]
        print(ans)
    
        
        
        
        
    
        
                    
            
        



        
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 85408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n; cin >> n;
  cout << pow(n, 3) << endl;
  return 0;
}

Measured memory_bytes: 256
N, C = map(int, input().split())
xy = []
for _ in range(N):
    xy.append(tuple(map(int, input().split())))
ans = 0
cal_sum_A = [0 for _ in range(N)]
cal_sum_A[0] = xy[0][1] - xy[0][0]
for i in range(1, N):
    cal_sum_A[i] += cal_sum_A[i - 1] + xy[i][1] - xy[i][0] + xy[i - 1][0]

cal_sum_B = [0 for _ in range(N)]
cal_sum_B[N - 1] = xy[N - 1][1] - (C - xy[N - 1][0])
for i in range(N - 2, -1, -1):
    cal_sum_B[i] += cal_sum_B[i + 1] + xy[i][1] - (C - xy[i][0]) + (C - xy[i + 1][0])

# O -> A
max_cal_A = [0 for _ in range(N)]
max_cal_A[0] = cal_sum_A[0]
for i in range(1, N):
    max_cal_A[i] = max(max_cal_A[i - 1], cal_sum_A[i])
ans = max(ans, max_cal_A[N-1])
# O -> B
max_cal_B = [0 for _ in range(N)]
max_cal_B[N-1] = max(max_cal_B[N-1], cal_sum_B[N-1])

for i in range(N-2, -1, -1):
    max_cal_B[i] = max(max_cal_B[i+1], cal_sum_B[i])
ans = max(ans, max_cal_B[0])
# O -> B -> O -> A
for i in range(1, N-1):
    cal = 0
    cal += cal_sum_B[-i]
    cal -= (C-xy[-i][0])
    cal += max_cal_A[N-i-1]
    ans = max(ans, cal)
# 0 -> A -> O -> B
for i in range(1, N):
    cal = 0
    cal += cal_sum_A[i-1]
    cal -= xy[i-1][0]
    cal += max_cal_B[-(N-i)]
    ans = max(ans, cal)
print(ans)










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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


namespace sub {
template <typename T>
constexpr typename std::enable_if<std::is_integral<T>::value, T>::type
inf_sub() {
  return std::numeric_limits<T>::max() / 2 - 1000;
}

template <typename T>
constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type
inf_sub() {
  return std::min(std::numeric_limits<T>::max() / 2 - 1000, T(1e50));
}
}  // namespace sub

template <typename T> constexpr T inf() {
  static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
  return sub::inf_sub<T>();
}

template <typename T> constexpr T zero() {
  static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
  return T(0);
}

const long double pi = acos(-1.0);

template <class edge_t> class graph_t {
  std::vector<std::vector<edge_t>> g;

public:
  using reference = std::vector<edge_t> &;
  using const_reference = const std::vector<edge_t> &;
  using iterator = typename std::vector<edge_t>::iterator;
  graph_t() : g(0) { ; }
  graph_t(int n) : g(n) { ; }
  int size() const { return g.size(); }
  void push_back(const std::vector<edge_t> &es) { g.push_back(es); }
  reference operator[](int x) { return g[x]; }
  const_reference operator[](int x) const { return g[x]; }
  iterator &begin() { return begin(g); }
  iterator &end() { return end(g); }
};

template <typename Cost> class WeightedEdge {
public:
  using cost_type = Cost;
  int to;
  cost_type cost;
  WeightedEdge(int, int t, cost_type c) : to(t), cost(c) { ; }
};

template <typename Cost> using WeightedGraph = graph_t<WeightedEdge<Cost>>;

template <typename Cost>
void add_edge(WeightedGraph<Cost> &g, int from, int to, Cost cost) {
  g[from].emplace_back(from, to, cost);
}

template <typename edge_t, typename cost_type = typename edge_t::cost_type>
std::vector<cost_type> dijkstra(const graph_t<edge_t> &g, int s) {
  std::vector<cost_type> d(g.size(), inf<cost_type>());
  d[s] = zero<cost_type>();
  using P = std::pair<cost_type, int>;
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;
  que.push(P(zero<cost_type>(), s));
  while (!que.empty()) {
    cost_type dist = que.top().first;
    int v = que.top().second;
    que.pop();
    if (d[v] < dist) continue;
    for (const auto &e : g[v]) {
      if (d[e.to] <= d[v] + e.cost) continue;
      d[e.to] = d[v] + e.cost;
      que.push(P(d[e.to], e.to));
    }
  }
  return d;
}

int main() {
    int n,m;
    cin>>n>>m;
    int V;
    V = n*3;

    WeightedGraph<int> g(V);
    for (int i = 0; i < m; i++)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        add_edge(g,u,v+n,1);
        add_edge(g,u+n,v+n*2,1);
        add_edge(g,u+n*2,v,1);
    }
    
    int ss,tt;
    cin>>ss>>tt;
    ss--;
    tt--;
    auto res = dijkstra(g, ss);
    if (res[tt] == inf<int>())
    {
        cout<<-1<<endl;
    }
    else cout<<res[tt]/3<<endl;
    return 0;
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    double a[n];
    double ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+=1/a[i];
    }
    cout<<fixed<<setprecision(15)<<1/ans<<endl;
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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 pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
    summon_tourist;

    int N; string S; cin >> N >> S;
    int R[4010]={}, G[4010]={}, B[4010]={};
    RREP(i, N){
        R[i] += R[i+1];
        G[i] += G[i+1];
        B[i] += B[i+1];
        if(S[i] == 'R') R[i]++;
        else if(S[i] == 'G') G[i]++;
        else B[i]++;
    }
    char chs[] = {'R', 'G', 'B'};
    lnt ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            if(S[i] == S[j]) continue;
            char k;
            REP(idx, 3){
                if(chs[idx]!=S[i] and chs[idx]!=S[j]) k = chs[idx];
            }
            if(k == 'R') ans += R[j+1];
            else if(k == 'G') ans += G[j+1];
            else ans += B[j+1];
            if(j+(j-i) < N and S[j+j-i]==k) ans--;
        }
    }
    cout << ans << ln;
}

Measured memory_bytes: 3708
import numpy as np

n, T = [int(i) for i in input().split()]
ct = [int(i) for _ in range(n) for i in input().split()]

cs = np.array(ct[0::2])
ts = np.array(ct[1::2])

cs_fil = cs[ts <= T]

if len(cs_fil) == 0:
    print('TLE')
else:
    print(min(cs_fil))

Measured memory_bytes: 21548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;

const int kMod = 1e9 + 7, kMaxN = 1e5 + 5;
int h, w, a, b;
ll fact[kMaxN << 1], rfact[kMaxN << 1];

ll QuickPow(ll x, ll y) {
  ll ret = 1;
  for (; y; y >>= 1, x = x * x % kMod)
    if (y & 1) ret = ret * x % kMod;
  return ret;
}

inline ll Combin(int n, int m) {
  return n < m ? 0 : (1LL * fact[n] * rfact[m] % kMod * rfact[n - m] % kMod);
}

int main() {
  scanf("%d%d%d%d", &h, &w, &a, &b);
  fact[0] = 1;
  for (int i = 1; i <= h + w; ++i)
    fact[i] = 1LL * fact[i - 1] * i % kMod;
  rfact[h + w] = QuickPow(fact[h + w], kMod - 2);
  for (int i = h + w - 1; i >= 0; --i)
    rfact[i] = 1LL * rfact[i + 1] * (i + 1) % kMod;
  ll ans = 0;
  for (int i = 1; i <= h - a; ++i) {
    ans = (ans + 1LL * Combin(b + i - 2, i - 1) * Combin(h - i + w - b - 1, h - i) % kMod) % kMod;
  }
  return printf("%lld\n", ans), 0;
}


Measured memory_bytes: 3328
N = gets.to_i

vs = N.times.collect{[]}

def calc_d_from(vs, n)
	queue = [n]
	distance = {n => 0}
	
	while cur = queue.pop
		d = distance[cur] + 1
		vs[cur].each{|n|
			if (prev_d = distance[n]) == nil || d < prev_d
				distance[n] = d
				queue << n
			end
		}
	end
	
	max_n = 0
	max_d = 0
	
	distance.each{|n, d|
		if d > max_d
			max_n = n
			max_d = d
		end
	}
	
	[max_n, max_d, distance]
end

def calc_d(vs)
	max_n1, max_d1, distance = calc_d_from(vs, 0)
	max_n2, max_d2, distance = calc_d_from(vs, max_n1)

	path = [max_n2]
	cur = max_n2
	d = max_d2 - 1
	while d >= 0
		cur = vs[cur].find{|n|
			distance[n] == d
		}
		path << cur
		d -= 1
	end
	
	[max_d2, path]
end

(N - 1).times{
	a, b = gets.strip.split(/ /).collect{|n| n.to_i - 1}
	
	vs[a] << b
	vs[b] << a
	
}

d, path = calc_d(vs)

def check2(vs, c1, c2)
	cur_list = [c1, c2]
	visited = {c1 => true, c2 => true}
	count = 2
	while cur_list.length > 0
		next_list = []
		
		max = 0
		
		cur_list.each{|n|
			if vs[n].length > max
				max = vs[n].length - 1
			end
			vs[n].each{|n2|
				if !visited[n2]
					visited[n2] = true
					next_list << n2
				end
			}
		}
		if max == 0
			break
		end
		count *= max
		cur_list = next_list
	end
	count
end

def check1(vs, c)
	cur_list = [c]
	visited = {c => true}
	count = 1
	additional = 1
	while cur_list.length > 0
		next_list = []
		
		max = 0
		
		cur_list.each{|n|
			if vs[n].length + additional > max
				max = vs[n].length - 1 + additional
			end
			vs[n].each{|n2|
				if !visited[n2]
					visited[n2] = true
					next_list << n2
				end
			}
		}
		if max == 0
			break
		end
		additional = 0
		count *= max
		cur_list = next_list
	end
	count
end


if d % 2 == 1
	cols = (d + 1) / 2
	count = check2(vs, path[(d - 1) / 2], path[(d + 1) / 2])
else
	cols = d / 2 + 1
	c = path[d / 2]
	counts = [check1(vs, c)]
	
	vs[c].each{|n|
		counts << check2(vs, c, n)
	}
	count = counts.min
end

puts "#{cols} #{count}"


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

//-----------------------------------------------------------------------------

int n;
int d[51],cnt[51][51];

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

	cin>>n;
	REP(i,n) cin>>d[i+1];

	sort(d,d+n+1);

	FOR(i,1,n+1) {
		if(!(i&1)) d[i]=24-d[i];
	}

	int mi=INF;
	FOR(i,1,n+1) {
		int x=abs(d[i]-d[i-1]);
		if(i==1) mi=d[i];
		else mi=min(min(mi,abs(d[i]-d[i-2])),min(x,24-x));
	}

	cout<<mi<<endl;

	return 0;
}


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


int calc(int x){
  int ret = 0;
  for(int i = 0; i < 6; i++){
    ret += (x%10);
    x /= 10;
  }
  return ret;
}

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

  int ans = 100000000;
  for(int A = 1; A < N; A++){
    int buf = calc(A) + calc(N-A);
    ans = min(buf, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
float polydiagonal(float n, float a) 
{ 
  
  
    if (a < 0 && n < 0) 
        return -1; 
  
   
    return 2 * a * sin((((n - 2) * 180) / (2 * n)) * 3.14159 / 180); 
}

void solve()
{
  int n  ;
  cin>>n ; 
  // int ans = dig(n);
  if(n%10==3){
  	cout<<"bon";
  }
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
  	cout<<"pon";
  }
  else{
  	cout<<"hon";
  }
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3864
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define MAX_STR 100000

int main(int argc, char const* argv[])
{
    int num0, num1;
    int i = 0;
    char tile[MAX_STR + 1];

    scanf("%s", tile);

    while( tile[i] != '\0' ){
        if(( tile[i] == '0' && i % 2 ) || ( tile[i] == '1' && !( i % 2 ) ) ) num1++;
        else num0++;
        i++;
    }

    if(num0 < num1) printf("%d\n", num0);
    else printf("%d\n", num1);



    return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = (0 until n).map {
        readLine()!!.toInt()
    }

    val gs = gaps(n)

    val (ys, cnt) = shellSort(xs, gs)

    println(gs.size)
    println(gs.joinToString(" "))
    println(cnt)
    ys.forEach {
        println(it)
    }
}

private fun gaps(n: Int): List<Int> {
    return generateSequence(1, { it * 3 + 1 })
            .takeWhile { it <= n }
            .toList()
            .reversed()
}

private fun shellSort(xs: List<Int>, gs: List<Int>): Pair<List<Int>, Int> {

    var cnt = 0

    fun insertionSort(xs: List<Int>, g: Int): List<Int> {
        val n = xs.size
        val ys = xs.toMutableList()

        for (i in g until n) {
            val v = ys[i]
            var j = i - g
            while (j >= 0 && ys[j] > v) {
                ys[j + g] = ys[j]
                j -= g
                cnt++
            }
            ys[j + g] = v
        }

        return ys
    }

    var ys = xs
    gs.forEach {
        ys = insertionSort(ys, it)
    }

    return Pair(ys, cnt)
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll N, ans= 1, l0=2, l1=1;
	
	cin >> N;
	while(N > 1){
		ans = l0 + l1;
		l0 = l1;
		l1 = ans;
		--N;
	}
	cout << ans;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<cmath>
#include<utility>
#include<vector>
using namespace std;
const int maxn = 1<<20;
int a[maxn],f[maxn],g[maxn];
void work(int k,int j)
{
//	if(k==3)cout<<"!"<<k<<" "<<j<<endl;
	if(g[j]>f[k])
	{
		g[k] = f[k];
		f[k] = g[j];
	}
	else if(g[j]>g[k])g[k] = g[j];
	if(f[j]>f[k])
	{
		g[k] = f[k];	
		f[k] = f[j];
	}
	else if(f[j]>g[k])g[k] = f[j];
	return;
}
int main()
{
	int n;cin>>n;
	int m = 1<<n;
	for(int i=0;i<m;i++)scanf("%d",&a[i]);
	memset(f,0,sizeof(f));
	memset(g,0,sizeof(g));
	for(int i=0;i<m;i++)
	{
		f[i] = a[i];
		g[i] = 0;
	}
	int ans = 0;
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	if((j&(1<<i))==0)
	{
		int nj = j|(1<<i);
		work(nj,j);
	}
	for(int k=1;k<m;k++)
	{
		ans = max(ans,f[k]+g[k]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 13312
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        ans += i & 1
    print(ans/n)
    return

#B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        ans += i >= k
    print(ans)
    return

#C
def C():
    n = II()
    a = LI()
    d = defaultdict(int)
    for i in range(n):
        d[a[i] + 1] = i + 1
    for _, v in sorted(d.items()):
        print(v, end=" ")
    print()
    return

def primes(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    """ 6以上の数であれば p (素数) <= n のlistを返す """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

#D
def D():
    a, b = LI()
    p = primes(int(math.sqrt(max(a, b))) + 1)
    ans = 1
    for i in p:
        if a % i == b % i == 0:
            ans += 1
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 67484
from collections import Counter
import math
import sys
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0]) 

arr01 = [int(x) for x in arr_data[1]]
arr02 = [int(x) + 1 for x in arr_data[1]]
arr03 = [int(x)-1 for x in arr_data[1]]

#print(arr01, arr02, arr03)

arr = Counter(arr01 + arr02 + arr03)

print(arr.most_common(1)[0][1])

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

const int maxl = 2e5 + 10, INF = 0x3f3f3f3f;
string s;
int n, dp[maxl], last[maxl][26];

int main() {
    cin >> s;
    n = s.length();
    for (int i = 0; i < 26; i++) {
        last[n][i] = n + 1;
    }
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            last[i][j] = last[i + 1][j];
            if (s[i] == 'a' + j) {
                last[i][j] = i + 1;
            }
        }
    }
    for (int i = n; i >= 0; i--) {
        dp[i] = INF;
        for (int j = 0; j < 26; j++) {
            dp[i] = min(dp[i], dp[last[i][j]] + 1);
        }
    }
    int cur = 0;
    while (cur < n) {
        for (int i = 0; i < 26; i++) {
            if (dp[cur] == dp[last[cur][i]] + 1) {
				cout << char('a' + i);
				cur = last[cur][i];
				break;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 21636
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    int n;
    std::cin >> n;

    std::vector<int> x(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }

    double ave = std::accumulate(x.begin(), x.end(), 0.0) / (double)n;

    std::vector<int> y = x, z = x;
    for (int i = 0; i < n; i++) {
        y[i] -= (int)ave;
        z[i] -= (int)ave + 1;

        y[i] *= y[i];
        z[i] *= z[i];
    }

    std::cout << std::min(std::accumulate(y.begin(), y.end(), 0), std::accumulate(z.begin(), z.end(), 0)) << std::endl;
}


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

int main(){
  int n, d;
  cin >> n >> d;
  vector< vector<double> > a(n, vector<double>(d));
  for (int i = 0; i < n; i++){
    for (int v = 0; v < d; v++){
      cin >> a.at(i).at(v);
    }
  }

  int count = 0;
  for (int i = 0; i < n; i++){
    for (int v = i+1; v < n; v++){
      double sum = 0;
      for (int c = 0; c < d; c++){
        sum += (a[i][c] - a[v][c])*(a[i][c] - a[v][c]);
      }
      if (floor(sqrt(sum)) == sqrt(sum)){
        count += 1;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}


Measured memory_bytes: 2572
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;
//0->決定
//1->xのみ決定
//2->yのみ決定
//3->x,yの範囲のみ決定
struct query {
	ll type;
	pll p1, p2;
};

ll H, W;
vector<ll> A, B;
vector<query> DP2;

int main() {
	cin >> H >> W;
	A.resize(H + 1);
	for (ll y = 1; y <= H; y++)cin >> A[y];
	sort(A.begin(), A.end(), [](ll a, ll b) {return a < b; });
	B.resize(W + 1);
	for (ll x = 1; x <= W; x++)cin >> B[x];
	sort(B.begin(), B.end(), [](ll a, ll b) {return a < b; });
	for (ll x = W; x > 1; x--) {
		if (B[x] == B[x - 1]) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (ll y = H; y > 1; y--) {
		if (A[y] == A[y - 1]) {
			cout << 0 << endl;
			return 0;
		}
	}
	DP2.resize(W * H + 1);
	ll xuse = W, yuse = H;
	for (ll p = W * H; p >= 1; p--) {
		if (A[yuse] == p && B[xuse] == p) {
			xuse--;
			yuse--;
			DP2[p] = { 0,pll(xuse,yuse),pll(-1,-1) };
		}
		else if (A[yuse] == p) {
			DP2[p] = { 2,pll(xuse + 1, yuse),pll(W, yuse) };
			yuse--;
		}
		else if (B[xuse] == p) {
			DP2[p] = { 1,pll(xuse, yuse + 1) ,pll(xuse, H) };
			xuse--;
		}
		else {
			DP2[p] = { 3,pll(xuse + 1, yuse + 1) ,pll(W, H) };
		}
	}
	ll ans = 1;
	for (ll p = W * H; p >= 1; p--) {
		if (DP2[p].type == 0)continue;
		else if (DP2[p].type == 1) {
			ll left = DP2[p].p2.second - DP2[p].p1.second + 1;
			ans = (ans * left) % MOD;
		}
		else if (DP2[p].type == 2) {
			ll left = DP2[p].p2.first - DP2[p].p1.first + 1;
			ans = (ans * left) % MOD;
		}
		else {
			ll left = (W - DP2[p].p1.first + 1) * (H - DP2[p].p1.second + 1) - (W * H - p);
			ans = (ans * left) % MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39296