akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

const int MAX_P = 7368791; //max
bool prime[MAX_P+1];

void Eratosthenes(int m){
  for(int i=m;i<=MAX_P;i++)
    prime[i]=true;
  
  for(int i=m;i<=MAX_P;i++)
    if(prime[i])  
      for(int j=2;i*j<=MAX_P;j++)
        prime[i*j]=false;
}


bool solve(){
  int m, n;

  cin >> m >> n;
  if(m == 0) return 0;
  
  Eratosthenes(m);

  int counter = n;
  
  for(int i=m;;i++){
    counter -= prime[i];
    //if(prime[i]) debug(i);
    if(counter < 0){
      printf("%d\n", i);
      return 1;
    }
  }

  return 1;
}

int main(){
  while(solve());
  
  return 0;
}



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

int main(){
	int l,r,d;
	cin>>l>>r>>d;
	
	int cnt=0;
	for(int i=l;i<=r;i++){
		if(i%d==0){
			cnt++;
		}
	}
	
	cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=1e6+50;
int n,d,A,ans=0,r=1,v[N];
struct node{ int x,z; }a[N];
bool mycmp(node a,node b){ return a.x<b.x; }
int solv(int x){
	if(x%A==0) return x/A;
	else return x/A+1;
}
signed main(){
	scanf("%lld%lld%lld",&n,&d,&A);
	rep(i,1,n) scanf("%lld%lld",&a[i].x,&a[i].z);
	sort(a+1,a+n+1,mycmp);
	rep(i,1,n){
		v[i]+=v[i-1]; a[i].z-=v[i];
		if(a[i].z<=0) continue;
		while(a[r].x-a[i].x<=2*d&&r<=n) r++;
		int t=solv(a[i].z);
		v[i]+=t*A; v[r]-=t*A;
		ans+=t;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8448
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

count = 0
1.step(N) do |n|
  count += 1 if n.to_s.length % 2 == 1
end

puts count


Measured memory_bytes: 14488
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}



int main(){
   
  ios_base :: sync_with_stdio(0);
   cin.tie(0);
   ll n,k;
   cin>>n>>k;
   ll gone = n/k;
   gone *= k;
   n -= gone;
   cout<<min(n , abs(n-k));


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	int N,K,X,Y;
	cin >> N >> K >> X >> Y;
	cout << (N<K?N*X:K*X+((N-K)*Y)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<iostream>

int main(){
  int N;
  std::set<char> s;
  
  std::cin >> N;
  for (int i=0;i<N;i++) {
    char input;
    std::cin >> input;
    s.insert(input);
  }
    
  if (s.size()==3) {
    std::cout << "Three";
  } else {
    std::cout << "Four";
  }
  
}

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

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


Measured memory_bytes: 3188
#include<iostream>
#include<queue>
using namespace std;
#define MAX 1000

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


int t,n;
bool visited[MAX][MAX];

void init(){
  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++){
      visited[i][j]=false;
    }
  }
}

int main(){
  while(1){
    cin>>t>>n;
    if(t==0&&n==0)break;
    init();
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      visited[a+500][b+500]=true;
    }
    int ans=1,a,b;
    cin>>a>>b;
    queue<int> qy,qx,cnt;
    qy.push(a+500);qx.push(b+500);cnt.push(0);
    visited[a+500][b+500]=true;
    while(!qy.empty()){
      int y=qy.front();qy.pop();
      int x=qx.front();qx.pop();
      int z=cnt.front();cnt.pop();
      if(z==t)continue;
      for(int i=0;i<6;i++){
	int ny=y+dy[i];
	int nx=x+dx[i];
	if(visited[ny][nx])continue;
	visited[ny][nx]=1;
	qy.push(ny);
	qx.push(nx);
	cnt.push(z+1);
	ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2196
x = int(input())

BITMASK = (1 << 32) - 1

print("{:032b}".format(x))
print("{:032b}".format(~x & BITMASK))
print("{:032b}".format((x << 1) & BITMASK))
print("{:032b}".format((x >> 1) & BITMASK))



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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

ll mod_inv(ll n)
{
    ll left=MOD-2;  // define MOD!
    ll num=n;
    ll ans=1;
    while(left!=0)
    {
        if(left%2==1)ans=(ans*num)%MOD;
        left/=2;
        num=(num*num)%MOD;
    }
    return ans;
}

int main()
{
  ll n,m,k;cin>>n>>m>>k;
  ll total=0;
  ll i,j;
  for(i=1;i<m;i++)
  {
    total+=n*n*(m-i)*i;
    total%=MOD;
  }
  for(i=1;i<n;i++)
  {
    total+=m*m*(n-i)*i;
    total%=MOD;
  }
  ll pat=1;
  for(i=1;i<=k-2;i++)
  {
    pat=pat*((n*m-1-i)*mod_inv(i)%MOD)%MOD;
  }
  cout<<total*pat%MOD<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int N, X;
    std::cin >> N >> X;

    int ans = 1, sumL = 0;
    for (int i = 0; i < N; i++) {
        int L;
        std::cin >> L;

        sumL += L;
        if (sumL <= X)
            ans++;
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    a[0] -= 0x20;
    b[0] -= 0x20;
    c[0] -= 0x20;
    cout << a[0];
    cout << b[0];
    cout << c[0];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fore(b,c) for(int val0=b;val0<c;val0++)
#define forr(k,c,s) for(int k=c;k<s;k++)
#define pb push_back
#define mmp make_pair
#define oset(T) tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<vii> al;
typedef vector<ll> vl;
const int INF = 1e9;
const ll INFL = 1LL<<61;
const int MN = 200100;
ll tr[MN][2];
ll lso(ll n) {
	return n&(-n);
}
int sz;
ll dfs(int u, ll l) {
	int no = 0;
	ll res = 0;
	for(int i=0;i<2;i++) {
		if(tr[u][i] != -1) {
			res ^= dfs(tr[u][i],l-1);
		} else {
			no++;
		}
	}
	if(no == 1) {
		res ^= lso(l);
	}
	return res;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	memset(tr,-1,sizeof(tr));
	sz = 1;
	ll n,l;
	cin >> n >> l;
	for(int i=0;i<n;i++) {
		string s;
		cin >> s;
		int st = 0;
		for(int j=0;j<s.size();j++) {
			int val = s[j]-'0';
			ll& nx = tr[st][val];
			if(nx == -1) {
				nx = sz;sz++;
			}
			st = tr[st][val];
		}
	}
	ll gr = dfs(0,l);
	if(gr == 0) {
		cout << "Bob\n";
	} else {
		cout << "Alice\n";
	}
}


Measured memory_bytes: 8172
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	if (k <= a)
	{
		cout << a - k << " " << b << endl;
	}
	else
	{
		if (k - a <= b)
		{
			cout << 0 << " " << b - (k - a) << endl;
		}
		else
		{
			cout << 0 << " " << 0 << endl;
		}
	}
}

Measured memory_bytes: 256
def main():
    A, B, C = list(map(int, input().split(' ')))
    cnt = 0
    if A % 2 == B % 2 != C % 2:
        cnt = 1
        A += 1
        B += 1
    elif B % 2 == C % 2 != A % 2:
        cnt = 1
        B += 1
        C += 1
    elif C % 2 == A % 2 != B % 2:
        cnt = 1
        C += 1
        A += 1
    cnt += (3 * max([A, B, C]) - (A + B + C)) // 2
    print(cnt)


if __name__ == '__main__':
    main()

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

string x;
int a=0, b=0;

int main()
{
	cin >> x;
	for(int i=0; i<3; i++)
	{
		if(x[i] == 'A') a++;
		else b++;
	}
	
	if(a!=0 and b!=0) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int tokuten(int kaisuu);

main()
{
	int a,b,x;
	
	a=tokuten(4);
	b=tokuten(4);
	
	x=a>=b ? a : b;
	
	printf("%d\n",x);
	
	return 0;
}

int tokuten(int kaisuu){
	int sum=0,x,cou;
	for(cou=0;cou<kaisuu;cou++){
		scanf("%d",&x);
		sum+=x;
	}
	return sum;
}

Measured memory_bytes: 592
# -*- coding: utf-8 -*-
# A

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
print(n + n**2 + n ** 3)


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

int main() {
  int n;
  cin >> n;
  vector<pair<string, int>> t(n);
  rep(i,n) cin >> t[i].first >> t[i].second;
  string s;
  cin >> s;
  int res = 0;
  vector<int> cum(n+1,0);
  int idx = -1;
  for (int i = 0; i < n; i++) {
    cum[i+1] = cum[i] + t[i].second;
    if (t[i].first == s) idx = i;
  }
  cout << cum[n] - cum[idx+1] << endl;
  return 0;
} 

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int 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 digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int x;
    cin >> x;

    Int ans = 0;
    if (x <= 6) {
        ans = 1;
    } else {
        ans = Floor(x, 11) * 2;
        x -= Floor(x, 11) * 11;
        if (1 <= x && x <= 6) {
            ans++;
        } else if (7 <= x) {
            ans += 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();

    sc.close();

    int f = Integer.valueOf(S.substring(0, 2));
    int r = Integer.valueOf(S.substring(S.length() - 2));

    if (f <= 12 && r <= 12 && f != 0 && r != 0) {
      System.out.println("AMBIGUOUS");
    } else if (f <= 12 && f != 0) {
      System.out.println("MMYY");
    } else if (r <= 12 && r != 0) {
      System.out.println("YYMM");
    } else {
      System.out.println("NA");
    }
  }

}

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,p[200020],q[200020];

int main() {
	read(n);
	for(int i=1;i<=n;i++){
		read(p[i]);
		q[p[i]] = i;
	}
	int l = 0,lp = 1000009;
	int ans = n;
	for(int i=1;i<=n;i++){
		if(q[i]<lp){
			l = i;
		}
		lp = q[i];
		ans = min(ans,n-(i+1-l));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  vi A(9);
  cin >> A;
  int N;
  cin >> N;
  vi b(N);
  cin >> b;

  vector<bool> B(9, false);
  rep(i, N) {
    rep(j, 9) {
      if (A[j] == b[i]) {
        B[j] = true;
      }
    }
  }

  bool ans = false;
  rep(i, 3) if (B[i * 3] && B[i * 3 + 1] && B[i * 3 + 2]) ans = true;
  rep(i, 3) if (B[i] && B[i + 3] && B[i + 6]) ans = true;
  if (B[0] && B[4] && B[8]) ans = true;
  if (B[2] && B[4] && B[6]) ans = true;

  out(ans ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int u, v;
    long long int x = 0, y = 0;
    for(int i = 0; i<n-1; i++){
        cin >> u >> v;
        x = x + (long long int)min(u,v) * (n - max(u, v) + 1);
        y = y + (long long int)(i + 1) * (n - i);
    }
    cout << y + n - x;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define COUNT_RESET 0
#define LOOP_RESET 0
unsigned short serch_word(unsigned char * word, unsigned char * sent);
unsigned short s_scan_word(unsigned char * str, unsigned short length_max);
int main(){
	unsigned char word[10];
	unsigned char sent[1000];
	unsigned short word_length, sent_length;
	unsigned short count = 0;
	unsigned char sentence_end[] = {"END_OF_TEXT\n"};
	unsigned short i;
	for(i = 0;i < 10;i++){
		word[i] = 0;
	}
	for(i = 0;i < 1000;i++){
		sent[i] = 0;
	}
	word_length = s_scan_word(word, 1000);
	while(1){
		sent_length = s_scan_word(sent, 1000);
		if(serch_word(sentence_end, sent) == 1){
			break;
		}
		for(i = 0;i < word_length;i++){
			word[i] |= 0x60;
		}
		for(i = 0;i < sent_length;i++){
			sent[i] |= 0x60;
		}
		if(word_length == sent_length){
			count += serch_word(word, sent);
		}
		for(i = 0;i <= sent_length;i++){
			sent[i] = 0;
		}
	}
	printf("%d\n", count);
	return 0;
}
/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET; /* 文字列長カウンタ */
	unsigned short usW_C_i; /* ループ変数 */
	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i); /* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}
	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short serch_word(unsigned char * word, unsigned char * sent)
{
	unsigned int frg = 0;
	unsigned int i = 0;
	while(1){
		if(*(word + i) == '\n'){
			frg =1;
		}
		if(*(word + i) != *(sent + i)){
			break;
		}
		i++;
	}
	return frg;
} 


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

int main() {
  
  int n;
  cin >> n;
  vector<int> t(n);
  vector<pair<int,int>> xy(n);
  for(int i = 0; i < n; i++) {
    cin >> t.at(i);
    cin >> xy.at(i).first;
    cin >> xy.at(i).second;
  }

  for(int i = 0; i < n; i++) {
    int div = xy.at(i).first + xy.at(i).second;
    if((t.at(i) % 2 == 0 && div % 2 == 0) || (t.at(i) % 2 != 0 && div % 2 != 0)) {
      if(div/2 > t.at(i)/2) {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<tuple>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll N,A[100010];
	string S;
	ll ans,sum;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>N;
	REP(i,N)cin>>A[i];
	int pos=0;
	REP(i,N+1){
		sum+=abs(A[i]-pos);
		pos=A[i];
	}
	REP(i,N){
		if(i==0){
			cout<<sum+abs(A[i+1])-(abs(A[i])+abs(A[i+1]-A[i]));
		}else{
			cout<<sum+abs(A[i+1]-A[i-1])-(abs(A[i]-A[i-1])+abs(A[i+1]-A[i]));
		}
		cout<<endl;
	}

	return 0;
}

/*
3
2 -4 1
2 8 13 14
2 3 4
1-(6+5)
*/



Measured memory_bytes: 2048
K, N = map(int, input().split())
A =list(map(int, input().split()))

KK = int(K)


def smaler(x, y):
  if x < y:
    return x
  else:
    return y

def lager(x, y):
  if x > y:
    return x
  else:
    return y

 

def span(A, i):
  if i == 1:
    return K - A[len(A) - 1] + A[0]
  elif i != 1:
    return A[i] - A[i - 1]
    
m = 0
for i in range(0, len(A)):
  m = lager(m, span(A, i))

  
print(K - m)

Measured memory_bytes: 26444
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>


int main() {
	int n;
	bool a;
	std::vector<int> prime;
	prime.emplace_back(2);
	for (int i = 3; i < 1000000; i += 2) {
		a = false;
		for (int j = 3; j <= std::sqrt(i); j += 2) {
			if (i%j == 0) {
				a = true;
			}
		}
		if (a == false) {
			prime.emplace_back(i);
		}
	}
	while (std::cin >> n) {
		int ans = 0;
		int low = 0, high = 0;
		for (int i = 0; i < prime.size(); i++) {
			if (prime[i] < n) {
				low = prime[i];
			}
			if (prime[i] > n) {
				high = prime[i];
				break;
			}
		}
		std::cout << low << " " << high << std::endl;
	}
}

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

const int N = 1e5 + 10;

int dp[N];
vector <int> adj[N];

void dfs (int v, int p = -1) {
	int cnt = 0;
	for (auto u : adj[v]) {
		if(u == p) 	continue;
		dfs(u, v);
		dp[v] += dp[u];
		cnt += dp[u] % 2;
	}
	dp[v]++;
	if(cnt >= 2)	{
		cout << "First\n";
		exit(0);
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		adj[v].push_back(u), adj[u].push_back(v);
	}
	if(n % 2 == 1) {
		cout << "First\n";
		return 0;
	}
	dfs(0);
	cout << "Second\n";
}

Measured memory_bytes: 6144
<?php
// D
fscanf(STDIN, '%d', $n);
$primes = primesArr(55555);
$ans = [];
foreach ($primes as $p) {
    if ($p % 5 === 1) $ans[] = $p;
    if (count($ans) === $n) break;
}
echo implode(' ', $ans);

/**
 * 素数列挙（エラトステネスのふるい）
 * $maxまでの整数のうち素数のみを格納した配列を返す
 */
function primesArr($max)
{
    $arr = array_fill(2, $max - 1, true);
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        if (!isset($arr[$i])) continue;
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            unset($arr[$j]);
        }
    }
    return array_keys($arr);
}

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

int main() {
  long long h, w;
  cin >> h >> w;
  
  long long ans = h * w;
  for(long long i = 1; i < h; i++){
    vector<long long> c = {i * w, (h-i) * (w / 2), (h-i) * ((w+1) / 2)};
    sort(c.begin(), c.end());
    ans = min(ans, c.at(2) - c.at(0));
    c = {i * w, (h-i) / 2 * w, (h-i+1) / 2 * w};
    sort(c.begin(), c.end());
    ans = min(ans, c.at(2) - c.at(0));
  }
  swap(h, w);
  for(long long i = 1; i < h; i++){
    vector<long long> c = {i * w, (h-i) * (w / 2), (h-i) * ((w+1) / 2)};
    sort(c.begin(), c.end());
    ans = min(ans, c.at(2) - c.at(0));
    c = {i * w, (h-i) / 2 * w, (h-i+1) / 2 * w};
    sort(c.begin(), c.end());
    ans = min(ans, c.at(2) - c.at(0));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n = 3;
    vector<vector<int>> c(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> c.at(i).at(j);
        }
    }

    for (int i = 0; i < n -1; i++)
    {
        for (int j = 0; j < n - 1; j++)
        {
            if (c.at(i+1).at(j) - c.at(i).at(j) != c.at(i+1).at(j+1) - c.at(i).at(j+1))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << max({(a + b), (a - b), (a * b)}) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  VV<> d; assign(d, a + 1, b + 1, 0);
  for (int x = 1; x <= a; ++x) for (int y = 1; y <= b; ++y) cin >> d[x][y];
  VV<> c; assign(c, 101, 101, 0);
  for (int i = 0; i <= 100; ++i) for (int j = 0; j <= 100; ++j) {
    for (int x = 1; x <= a; ++x) for (int y = 1; y <= b; ++y) {
      c[i][j] = max(c[i][j], d[x][y] - i * x - j * y);
    }
  }
  for (int x = 1; x <= a; ++x) for (int y = 1; y <= b; ++y) {
    int mn = 1e9;
    for (int i = 0; i <= 100; ++i) for (int j = 0; j <= 100; ++j) {
      mn = min(mn, i * x + j * y + c[i][j]);
    }
    if (d[x][y] != mn) return cout << "Impossible" << '\n', 0;
  }
  cout << "Possible" << '\n';
  int n = 202, m = 100 + 100 + 101 * 101;
  cout << n << ' ' << m << '\n';
  for (int i = 1; i <= 100; ++i) cout << i << ' ' << i + 1 << " X\n";
  for (int i = 102; i < 202; ++i) cout << i << ' ' << i + 1 << " Y\n";
  for (int i = 0; i <= 100; ++i) for (int j = 0; j <= 100; ++j) {
    cout << i + 1 << ' ' << 202 - j << ' ' << c[i][j] << '\n';
  }
  cout << 1 << ' ' << 202 << '\n';
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, N: int, a: "List[int]"):
    
    al = [[i]*a[i-1] for i in range(1,N+1)]

    import itertools
    al = list(itertools.chain.from_iterable(al))

    c = []
    for i in range(H):
        t = al[i*W:(i+1)*W]
        if(i%2 == 0):
            c.append(t)
        else:
            c.append(t[::-1])

    for i in c:
        print(' '.join(map(str,i)))
    # print(c)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, W, N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4592
#include<bits/stdc++.h>
#define ll long long int
#define dd double
using namespace std;
const ll MOD = 1000000007;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin>>n;
  ll a[n];
  ll i,j;
  ll s=0;
  for(i=0;i<n;i++){
  	cin>>a[i];
  	s=s+a[i];
  }
  
  ll ans=0;
  for(i=0;i<n;i++){
  	s=s-a[i];
  	ans=ans+(s%MOD*a[i]%MOD)%MOD;
  	
  }
  cout<<ans%MOD<<endl;
  
  
  return 0;
}


Measured memory_bytes: 5192
#include <iostream>
using namespace std;
string s;

int main(){
	cin >> s;
	int ans = s[0] - '0';
	bool flag = s[0] != '1';
	for (int i = 1; i < s.length(); ++ i){
		if (s[i] != '0')
			flag = true;
		ans += s[i] - '0';
	}
	if (! flag)
		cout << 10 << endl;
	else
		cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[n];
	int count = 0;

	for(int i=1; i<=n; i++)
		cin >> a[i];
	for(int i=1; i<=n; i+=2){
		if(a[i] % 2 != 0)
			count++;
	}
	cout << count << endl;
		

	
}




Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;
  cin>>k>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin>>a.at(i);
  }
  int d=-1;
  for(int i=1; i<n; i++){
    d=max(d,a.at(i)-a.at(i-1));
  }
  if(a.at(0)+k-a.at(n-1)>d) d=a.at(0)+k-a.at(n-1);
  cout<<k-d<<endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll INF = 100000000000;

int main(){ 
    ll N; cin >> N;
    vector<long double> A(N);
    vb(N, false);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vll B(0);
    for(int i=0; i<33; i++){
        B.emplace_back(pow(2,i));
    }
    ll count = 0;
    for(int i=N-1; i>=0; i--){
        long double k;
        for(auto x: B){
            if(x>A[i]){
                k = x;
                break;
            }
        }
        long double p = k - A[i];
        if(upper_bound(A.begin(), A.end()-(N-i), p)-lower_bound(A.begin(), A.end()-(N-i), p)>0){
            *(upper_bound(A.begin(), A.end()-(N-i), p)-1) += 0.1;
            A[i] += 0.1;
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace  std;

typedef long long ll;

ll mod = 1e9 + 7;


ll fpow(ll a,ll b,ll p){
    ll res = 1;
    while(b > 0) {
        if (b & 1) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        b >>= 1;
    }
    return res % p;
}

//求逆元  1/(n-m)! = inv((n-m)!)
ll pw(ll a,ll p){
    return fpow(a,p-2,p);
}

ll nCk(ll n, ll k,ll p){
    ll f[1000010];
    f[0] = 1;
    for(int i = 1;i<=n;i++){
        f[i] = f[i-1] * i % p;
    }
    return f[n] * fpow(f[n-k],p-2,p) % p * fpow(f[k],p-2,p) % p;
}
ll x,y;
int main(){
    cin >> x >> y;

    if((x + y) % 3 || (x + x - y) < 0 || (y + y - x)< 0){
        cout << 0 << endl;
    }else{
        ll a = (x + x - y)/3;
        ll b = (y + y - x)/3;
        cout << nCk(a + b,b,mod) << endl;
    }
    return 0;
}

Measured memory_bytes: 8840
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;
int dp[3005][3005];
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}

int main() {
    input;
    int n, s;
    cin >> n >> s;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0][0] = power(2, n);
    int inv2 = power(2, mod - 2);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= s; j++) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
            if(a[i] + j <= s) {
                dp[i + 1][j + a[i]] += (1LL * dp[i][j] * inv2) % mod;
                dp[i + 1][j + a[i]] %= mod;
            }
        }
    }
    cout << dp[n][s];
}


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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007


int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    rep(h,1,3500) rep(w,1,3500){
        ll mul=h*w*4;
        mul-=(h+w)*n;
        if(mul<=0) continue;
        if((h*w*n)%mul == 0){
            cout<<(h*w*n)/mul<<" "<<h<<" "<<w<<'\n';
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    cout << (1900 * m + 100 * (n - m))*pow(2, m) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<k/2;i++){
			m+=(n/2);
			n/=2;
			n+=(m/2);
			m/=2;
	} 
	if(k-k/2*2){
		m+=(n/2);
		n/=2;
	} 
	cout<<n<<" "<<m<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextInt();
		}
		int UP = Integer.MIN_VALUE;
		int DOWN = Integer.MIN_VALUE;
		Arrays.sort(arr);
		/*for (int TOP = 0; TOP < N; TOP++) {
			for (int BOT = TOP+1; BOT<N; BOT++) {
				int Num = Math.max(arr[TOP], arr[BOT]);
				int Den = Math.min(arr[TOP], arr[BOT]);
				if (Num>=UP&&Den>=DOWN&&Num-Den>=UP-DOWN) {
					UP=Num;
					DOWN=Den;
				}
			}
		}*/
		int LDiff = 0;
		int RDiff = Integer.MAX_VALUE;
		for (int i = 0; i < N-1; i++) {
			int L = arr[i];
			int R = arr[N-1]-arr[i];
			if (Math.abs(L-R)<=Math.abs(RDiff-LDiff)) {
				RDiff = arr[N-1]-arr[i];
				LDiff = arr[i];
				DOWN=arr[i];
			}
		} 
		System.out.println(arr[N-1]+" "+DOWN);
		//for int i = 0
	}
}


Measured memory_bytes: 52048
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import 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')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    n, = LI()
    a = LI()
    q = []
    for ai in a:
        heappush(q, ai)
    for _ in range(m):
        heappush(q, heappop(q) / 2)
    ans = 0
    while q:
        ans += int(heappop(q))
    print(ans)
    return

# E


def E():
    return

# F


def F():
    return


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


Measured memory_bytes: 56032
#include <malloc.h>
#include <stdio.h>

#define MX 1000001
typedef struct Node {
    int u;
    struct Node *next;
} node;
node *edge[MX + 2], *cur;
node *New(int a) {
    node *temp = (node *)malloc(sizeof(node));
    temp->next = NULL;
    temp->u = a;
    return temp;
}
node *add(node *root, int a) {
    node *temp = New(a);
    if (root == NULL) return temp;
    temp->next = root;
    return temp;
}
void freeList(node *root) {
    if (root == NULL) return;
    freeList(root->next);
    free(root);
}
int min(int a, int b) {
    return (a < b) ? a : b;
}
int max(int a, int b) {
    return (a < b) ? b : a;
}
int notHash(int a, int b) {
    int id = min(a, b) * 1000 + max(a, b);
    return id;
}
int n, a, b, in[MX];
void init() {
    for (int i = 0; i <= MX; i++) {
        in[i] = 0;
        edge[i] = NULL;
    }
    cur = NULL;
}
void MRoy() {
    init();
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a);
        for (int j = 0; j < n - 2; j++) {
            scanf("%d", &b);
            int u = notHash(i, a);
            int v = notHash(i, b);
            edge[u] = add(edge[u], v);
            a = b;
            in[v]++;
        }
    }
    int times = 0;
    for (int i = 1; i <= MX; i++) {
        if (in[i] == 0) {
            cur = add(cur, i);
            times++;
        }
    }
    int days = 0, total = 0;
    while (times) {
        days++;
        total += times;
        int t = 0;
        node *after = NULL;
        while (cur != NULL) {
            int u = cur->u;
            node *tm = edge[u];
            while (tm != NULL) {
                int v = tm->u;
                in[v]--;
                if (in[v] == 0) {
                    after = add(after, v);
                    t++;
                }
                tm = tm->next;
            }
            cur = cur->next;
        }
        freeList(cur);
        cur = after;
        times = t;
    }
    if (total == MX) {
        printf("%d\n", days);
    } else
        printf("-1\n");
}
int main() {
    MRoy();
    return 0;
}

Measured memory_bytes: 74368
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
ll dp[1025][100005] ;
 int main(){
 ll n ; cin>> n ;
 vector<ll> v(n) ,w(n) ;
 rep(i,n) cin>>v[i]>>w[i] ;
 ll q ; cin>> q ;
rep(i,100005){
  dp[0][i]=0;
}
rep2(i,1,min(1023ll,n)){
 rep(j,100005){
   if(j>=w[i-1]) dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i-1]]+v[i-1]) ;
   else dp[i][j]= dp[i/2][j] ;
 }
}

 while(q--){
  ll a, b ; cin>>a>>b ;
  if(a<=1023) cout<<dp[a][b]<<endl ;
  
  else{
    vector<ll> koho ;
    while(a>1023){
      koho.pb(a) ;
      a/=2 ;
    }
    ll ans= dp[a][b] ;
    ll len = koho.size() ;
   rep(i,1<<len){
     bitset<9> s(i) ;
     ll we=0 ;
     ll va=0 ;
     rep(j,9){
       if(s[j]) {
         we+= w[koho[j]-1] ;
         va+= v[koho[j]-1] ;
       }
       }
     if(we<=b) chmax(ans,dp[a][b-we]+va) ;

   } 
      cout<<ans<<endl ;
  }
}


   return 0 ;
 }



Measured memory_bytes: 807392
n = gets.to_i
$stores = []
n.times { $stores << gets.split.map(&:to_i) }
$profits = []
n.times { $profits << gets.split.map(&:to_i) }
$answers = []

def dfs(decided, openings)
  if decided == 10
    profit_sum = 0
    $stores.each_with_index do |store, s_index|
      count = 0
      openings.each_char.with_index do |opening, o_index|
        next if opening == "0"
        count += 1 if store[o_index] == 1
      end
      profit_sum += $profits[s_index][count]
    end
    $answers << profit_sum
    return
  end
  
  dfs(decided + 1, openings + "0")
  dfs(decided + 1, openings + "1")
end

dfs(0, "")

$answers.shift
puts $answers.max


Measured memory_bytes: 1916
def main():
    k = int(input())
    nums = [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]

    print(nums[k-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------
ll N;
ll A[201010];
using PP = pair<ll, Pll>;
priority_queue<PP> que;

int main() {
  //
  cin >> N;
  rep(i, 0, N) { cin >> A[i]; }
  sort(A, A + N, greater<ll>());

  que.push(PP(A[0], Pll(A[0], A[0])));
  ll ans = 0;

  rep(i, 1, N) {
    PP elem = que.top();
    que.pop();
    ans += elem.first;

    ll ai = A[i];

    que.push(PP(min(ai, elem.second.first), Pll(ai, elem.second.first)));
    que.push(PP(min(ai, elem.second.second), Pll(ai, elem.second.second)));
  }

  cout << ans;
}


Measured memory_bytes: 11100
#include<stdio.h>
int ta[200010],nt[400010],to[400010],cc[400010];
long long u[200010],ANS[200020],ans[200020];
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
long long pp[200010],ip[200010],M=1e9+7;
int f(int s){//printf("!%d\n",s);
  long long i;
  u[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]])continue;
    ans[s]=ans[s]*f(to[i])%M;
    ans[s]=ans[s]*ip[cc[to[i]]]%M;
    cc[s]+=cc[to[i]];
  }
  ans[s]=ans[s]*pp[cc[s]-1]%M;
  return ans[s];
}
void h(int s,int t){
  ans[s]=ans[s]*ip[cc[s]-1]%M*pp[cc[t]]%M*inv(ans[t],M)%M;
  ans[t]=ans[t]*ip[cc[t]-1]%M;
  cc[s]-=cc[t];
  cc[t]+=cc[s];
  ans[s]=ans[s]*pp[cc[s]-1]%M;
  ans[t]=ans[t]*pp[cc[t]-1]%M*ip[cc[s]]%M*ans[s]%M;
}
void g(int s){//printf("!!%d %d\n",s,cc[s]);
  int i;
  u[s]=2;
  ANS[s]=ans[s];
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]]==2)continue;
    //printf("%d %d %d %d %lld %lld\n",s,to[i],cc[s],cc[to[i]],ans[s],ans[to[i]]);
    h(s,to[i]);
    //printf("%d %d %d %d %lld %lld\n",s,to[i],cc[s],cc[to[i]],ans[s],ans[to[i]]);
    g(to[i]);
    h(to[i],s);
  }
}
int main(){
  int n,a,b,i;
  scanf("%d",&n);
  for(i=0;i<=n;i++)ta[i]=-1;
  pp[0]=1;
  for(i=1;i<=n;i++)pp[i]=(pp[i-1]*i)%M;
  for(i=0;i<=n;i++)ip[i]=inv(pp[i],M);
  for(i=1;i<=n;i++)cc[i]=ans[i]=1;
  for(i=0;i<n-1;i++){
    scanf("%d %d",&a,&b);
    nt[i    ]=ta[to[i+n-1]=a];
    nt[i+n-1]=ta[to[i    ]=b];
    ta[b]=i+n-1;
    ta[a]=i;
  }
  f(1);
  //for(i=0;i<=10;i++)printf("%lld\n",pp[i]);printf("\n");
  //for(i=0;i<=n;i++)printf("%d\n",cc[i]);
  //printf("%d\n",f(1));
  //for(i=0;i<=n;i++)printf("%d\n",cc[i]);
  //for(i=1;i<=n;i++)printf("%3d ",i);printf("\n");
  //for(i=1;i<=n;i++)printf("%3lld ",ans[i]);printf("\n");
  //for(i=1;i<=n;i++)printf("%3d ",cc[i]);printf("\n");
  g(1);
  for(i=1;i<=n;i++)printf("%lld\n",ANS[i]);
  return 0;
}


Measured memory_bytes: 15488
x = input()
l = []
for i in range(4):
  l.append(int(x[i]))
  
ans_l = []  
for i in range(8):
  x = l[0]+l[1]*(-1)**(i//4)+l[2]*(-1)**((i//2)%2)+l[3]*(-1)**(i%2)
  if x==7:
    ans_l.append(i)
    
if min(ans_l)//4==0:
  op1 = '+'
else:
  op1 = '-'
if (min(ans_l)//2)%2==0:
  op2 = '+'
else:
  op2 = '-'
if min(ans_l)%2==0:
  op3 = '+'
else:
  op3 = '-'
  
print(str(l[0])+op1+str(l[1])+op2+str(l[2])+op3+str(l[3])+'=7')

Measured memory_bytes: 38256
import numpy as np
(n,m),*d = [list(map(int, s.split())) for s in open(0)]

inf = 100000000
dp = np.full([2]*n, inf, dtype=np.int)
dp[tuple([0]*n)] = 0

for i in range(m):
    a = d[2*i][0]
    b = d[2*i][1]
    c = d[2*i+1]
    
    l0 = [slice(None)]*n
    l1 = [slice(1,None)]*n
    for x in c:
        l0[x-1] = slice(None,1)
        l1[x-1] = slice(None)
    dp = np.minimum(np.minimum(dp[tuple(l1)], dp[tuple(l0)]+a), dp)
    
ans = dp[tuple([1]*n)]
if ans == inf:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 12772
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000 + 10;
struct Pos
{
    int val , x , y;
};
Pos meilleur[MAXN][MAXN];
int main()
{
    for (int i = 0 ; i < MAXN ; i++)
    {
        for (int j = 0 ; j < MAXN ; j++)
        {
            meilleur[i][j] = {0 , -1 , -1};
        }
    }
    string s;
    string t;
    cin>> s >> t;
    int N = s.size();
    int M = t.size();
    meilleur[0][0] = {0 , -1, - 1};
    for (int i = 0 ; i < N ; i++)
    {
        for (int j = 0 ; j < M ; j++)
        {
            if (meilleur[i + 1][j].val > meilleur[i + 1][j + 1].val)
            {
                meilleur[i + 1][j + 1] = meilleur[i + 1][j];
            }
            if (meilleur[i][j + 1].val > meilleur[i + 1][j + 1].val)
            {
                meilleur[i + 1][j + 1] = meilleur[i][j + 1];
            }
            if (s[i] == t[j])
            {
                if (meilleur[i][j].val + 1 > meilleur[i + 1][j + 1].val)
                {
                    meilleur[i  +1][j + 1] = {meilleur[i][j].val + 1 , i , j};
                }
            }
            else
            {
                if (meilleur[i][j].val > meilleur[i + 1][j + 1].val)
                {
                    meilleur[i  +1][j + 1] = meilleur[i][j];
                }
            }
        }
    }
    Pos actu = meilleur[N][M];
    vector <char> sol;
    while (actu.x != -1)
    {
        sol.push_back(s[actu.x]);
        actu = meilleur[actu.x][actu.y];
    }
    for (int i = sol.size() - 1 ; i >= 0 ; i--)
    {
        cout<<sol[i];
    }
    cout<<endl;
}

Measured memory_bytes: 106496