akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}
void inp(vector<int>& v, int n){
    for (int i=0; i<n; ++i) scanf("%d ", &v[i]);
}

// ll dp[5005][5005];
int vis[5005];
ll res;

void dfs2(vector<int>& v, vector<ll>& cost, int st, int i, ll& currmax, ll curr, int x, int k){
    if (x>k) return;
    curr+=cost[i];
    currmax=max(currmax, curr);
    dfs2(v, cost, st, v[i], currmax, curr, x+1, k);
    return;
}

void dfs(vector<int>& v, vector<ll>& cost, int st, int i, ll& currmax, ll curr, int x, int k){
    // cout<<st<<" "<<" "<<x<<" "<<curr<<endl;
    if (x>k) return;
    if (vis[i]!=0){
        if (curr<=0) return;
        int a=(k-x)/(x-vis[i]);
        int b=(k-x)%(x-vis[i]);
        // cout<<a<<" "<<b<<" "<<curr<<" ";
        curr+=curr*a;
        ll tmp2=0;
        dfs2(v, cost, st, v[i], tmp2, 0, 1, b+1);
        curr+=tmp2;
        // cout<<st<<" "<<a<<" "<<b<<" "<<x<<" "<<curr<<endl;
        currmax=max(currmax, curr);
        return;
    }
    vis[i]=x;
    curr+=cost[i];
    currmax=max(currmax, curr);
    // dp[st][x]=currmax;
    dfs(v, cost, st, v[i], currmax, curr, x+1, k);
    return;
}

void sol(){
    int n;
    ll k;
    cin>>n>>k;
    vector<int> v(n);
    vector<ll> cost(n);
    // inp(v, n);
    // int x;
    for (int i=0; i<n; ++i){
        scanf("%d ", &v[i]);
        v[i]--;
    }
    for (int i=0; i<n; ++i) cin>>cost[i];
    // for (int i=0; i<=n; ++i){
    //     for (int j=0; j<=n; ++j) dp[i][j]=LLONG_MIN;
    // }
    res=LLONG_MIN;
    ll currmax;
    for (int i=0; i<n; ++i){
        memset(vis, 0, 4*n);
        currmax=LLONG_MIN;
        dfs(v, cost, i, v[i], currmax, 0, 1, k);
        res=max(res, currmax);
    }
    cout<<res<<endl;
}


int main() {
    // int t;
    // cin>>t;
    // t++;
    // for (int i=1; i<t; ++i){ 
        sol();
    // }
    return 0;
}

Measured memory_bytes: 4388
n = int(input())
a = list(map(int, input().split()))
s = a
while(len(a) != 1):
    a = s
    s = []
    a.sort()
    for i in range(len(a)):
        if i == 0:
            pass
        else:
            a[i] = a[i] % a[0]
    # print(len(a))
    for j in range(len(a)):
        if a[j] > 0:
            s.append(a[j])
    if len(a) == 1:
        break
print(a[0])


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
using namespace std;
const int N=187;
int n,m,s[N][N],c[N][N];
int f[2][N][N][N],v;
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n){
		scanf("\n");
		fo(j,1,m)c[i][j]=s[i][j]=getchar()=='#'?1:0;
	}
	fo(i,1,n)fo(j,1,m)s[i][j]+=s[i][j-1];
	fo(i,1,n)fo(j,1,m)s[i][j]+=s[i-1][j];
	fd(k,1,m)fo(i,1,n)fo(j,i,n){
		int su=s[j][k]-s[i-1][k]-s[j][k-1]+s[i-1][k-1];
		if(su&&su<j-i+1)continue;
		f[0][k][i][j]=f[0][k+1][i][j]&&c[i][k]==c[i][k+1]?f[0][k+1][i][j]+1:1;
	}
	if(f[0][1][1][n]==m)return printf("0"),0;
	int o=0;
	fo(le,1,16){
		o^=1;
		memset(f[o],0,sizeof f[o]);
		fo(k,1,m)fo(i,1,n){
			int wz=i-1;
			fo(j,i,n){
				v=f[!o][k][i][j];
				f[o][k][i][j]=v+f[!o][k+v][i][j];
				if(i==j)continue;
				for(;wz+1<j&&f[!o][k][i][wz+1]>f[!o][k][wz+2][j];)++wz;
				if(wz+1>i)f[o][k][i][j]=max(f[o][k][i][j],f[!o][k][wz+1][j]);
				if(wz+1<j)f[o][k][i][j]=max(f[o][k][i][j],f[!o][k][i][wz+1]);
			}	
		}
		if(f[o][1][1][n]==m)return printf("%d",le),0;
	}
}

Measured memory_bytes: 51712
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x:x[1])
tmp = 0
flag = True
for part in AB:
  a, b = part
  tmp+=a
  if tmp>b:
    flag = False
    break
print('Yes' if flag else 'No')

Measured memory_bytes: 55264
#include <iostream>
#include <vector>
#include <utility>
#include <limits>

using namespace std;
using llong = long long;
constexpr llong INF = std::numeric_limits<llong>::max();
int main() {
  llong N,W;
  cin >> N >> W;
  vector<pair<llong,llong>> weightval(N);
  for (auto& p : weightval) {
    cin >> p.first >> p.second;
  }
  vector<vector<llong>> dptable(N+1,vector<llong>(100'001));
  for (llong i = 0; i < N; i++) {
    for (llong w = 0; w <= 100'000; w++){
      if( w >= weightval[i].first ) {
        dptable[i+1][w] = max(dptable[i][w-weightval[i].first] + weightval[i].second,dptable[i][w]);
      } else {
        dptable[i+1][w] = dptable[i][w];
      }
    }
  }
  cout << dptable[N][W] << endl;
}


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
template <class T>
struct fenwick_tree {
	vector<T> x;
	fenwick_tree(int n) : x(n, 0) { }
	T sum(int i, int j) {
		if (i == 0) {
			T S = 0;
			for (j; j >= 0; j = (j & (j + 1)) - 1) S += x[j];
			return S;
		}
		else return sum(0, j) - sum(0, i - 1);
	}
	void add(int k, T a) {
		for (; k < x.size(); k |= k + 1) x[k] += a;
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	char c;
	int a;
	for (int i = 0; i < 2 * N; i++) {
		cin >> c >> a;
		a--;
		if (c == 'W') {
			A[a] = i + 1;
		}
		else {
			B[a] = i + 1;
		}
	}
	fenwick_tree<int> ft(2 * N + 1);
	for (int i = 1; i < 2 * N + 1; i++) {
		ft.add(i, 1);
	}
	vector<vector<int > > dp(N + 1, vector<int>(N + 1, (int)1 << 60));
	dp[0][0] = 0;
	for (int i = 0; i <= N; i++) {
		if (i > 0) {
			ft.add(A[i - 1], -1);
		}
		for (int j = 0; j <= N; j++) {
			if(j > 0)ft.add(B[j - 1], -1);
			if (j + 1 <= N) {
				dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + ft.sum(0, B[j] - 1));
			}
			
			if (i + 1 <= N) {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + ft.sum(0, A[i] - 1));
			}

		}
		for (int j = 0; j < N; j++) {
			ft.add(B[j], 1);
		}
	}
	/*for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			cerr << dp[i][j] << " ";
		}
		cerr << endl;
	}*/
	cout << dp[N][N] << endl;
}

Measured memory_bytes: 33792
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;

  using M = Mint<int, 998244353>;
  M ans{0};
  vector<M> dp(n*2+1,0);
  vector<int> divs;

  for(int k=1;k<=n*2;k++){
    if((n*2)%k) continue;

    divs.emplace_back(k);
    if(~(n*2/k)&1) continue;

    assert(~k&1);

    M res{0};
    for(int i=0;i<k/2;i++)
      res=res*M(2)+M(s[i]=='1');

    dp[k]=res;

    auto comp=[](char c){return c=='1'?'0':'1';};

    string t;
    for(int i=0;i<k/2;i++)
      t+=s[i];
    for(int i=0;i<k/2;i++)
      t+=comp(s[i]);
    for(int i=0;t.size()<s.size();i++)
      t+=char(t[i%k]);

    t.resize(n);
    if(t<=s) dp[k]+=M(1);

    for(int d:divs)
      if(k%d==0&&k!=d) dp[k]-=dp[d];

    ans+=dp[k]*M(k);
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2772
#include<stdio.h>
int main(void)
{
    double h;

    while(scanf("%lf",&h) != EOF){

        if(h <= 48.0) printf("light fly\n");
        else if(h > 48.0 && h <= 51.0) printf("fly\n");
        else if(h > 51.0 && h <= 54.0) printf("bantam\n");
        else if(h > 54.0 && h <= 57.0) printf("feather\n");
        else if(h > 57.0 && h <= 60.0) printf("light\n");
        else if(h > 60.0 && h <= 64.0) printf("light welter\n");
        else if(h > 64.0 && h <= 69.0) printf("welter\n");
        else if(h > 69.0 && h <= 75.0) printf("light middle\n");
        else if(h > 75.0 && h <= 81.0) printf("middle\n");
        else if(h > 81.0 && h <= 91.0) printf("light heavy\n");
        else printf("heavy\n");
    }

    return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int64 a, b, x;
    cin >> a >> b >> x;
    int64 ans = b/x - (a-1)/x;
    if (a == 0 && x != 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<pair<int,int>,int>P;

int main(void){
    int n;  cin >> n;
    int mass[3][n+1];
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            cin >> mass[i][j];
        }
    }

    queue<P>que;
    que.push(P{{1,1},0});
    int ans=0;
    while(que.size()!=0){
        P p = que.front();que.pop();
        // cout << p.first.first <<' '<< p.first.second << ' ' << p.second << endl;;

        int x = p.first.first,y = p.first.second, cnt = p.second + mass[x][y];
        if(x==2 && y == n && ans < cnt){
            ans = cnt;
        }
        for(int i=0;i<=1;i++){
            for(int j=0;j<=1;j++){
                if(i==0&&j==0){
                    continue;
                }
                int next_x = x+i,next_y = y+j;
                if(1<=next_x && next_x<=2 && 1<= next_y && next_y <= n){
                    que.push(P{{next_x,next_y},cnt});
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;

int P;
string line;
string::iterator iter;

void init() {
  // global init
  line.clear();
}

ll mod_pow(ll x, ll n){
  if(n == 0) return 1;
  ll res = mod_pow(x * x % P, n / 2);
  if(n & 1) res = res * x % P;
  return res;
}

void consume(char expected) {
  if(*iter == expected) { iter ++; }
  else {
    cout << "Failed...\n";
    while(iter == line.end()) {
      cout << *iter;
    }
    cout << endl;

    assert(false);
  }
}

bool ifconsume(char expected) {
  if(*iter == expected) { consume(expected); return true; }
  return false;
}

ll expression();
ll term();
ll factor();

ll factor() {
  
  if(ifconsume('(')) {
    ll exp = expression();
    consume(')');
    return exp;
  }
  else {
    ll num = 0;
    while(isdigit(*iter)) {
      num *= 10;
      num += (*iter)-'0';
      consume(*iter);
    }
    return num;
  }
}

ll term() {
  ll factor1 = factor();
  while(1) {
    if(ifconsume('*')) {
      ll factor2 = factor();
      factor1 = (factor1 * factor2) % P;
    }
    else if(ifconsume('/')) {
      ll factor2 = factor();
      if(factor2 == 0) throw(0);
      factor1 = (factor1 * mod_pow(factor2, P-2)) % P;
    }
    else { break; }
  }
  return factor1;
}

ll expression() {
  ll term1 = term();
  
  while(1) {
    if(ifconsume('+')) {
      ll term2 = term();
      term1 = (term1 + term2) % P;
    }
    else if(ifconsume('-')) {
      ll term2 = term();
      term1 += P;
      term1 = (term1 - term2) % P;
    }
    else {
      break;
    }
  }

  return term1;
}

int main() {
  
  string str;
  while(getline(cin, str)) {
    init();
    
    stringstream ss(str);
    ss >> P;
    if(P == 0) break;
    
    int sz = str.size();
    rep(i, sz) {
      if(str[i] == ':') {
	str = str.substr(i+1);
	break;
      }
    }
    sz = str.size();
    
    rep(i, sz) {
      if(str[i] != ' '){ line.push_back(str[i]); }
    }
    
    iter = line.begin();
    try {
      int r = expression();
      cout << line << " = " << r << " (mod " << P << ")\n";
    } catch(...) {
      cout << "NG\n";
    }
  }
  
  return 0;
}

Measured memory_bytes: 1688
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
struct Point{
   ll x,y;
   Point (ll x=0, ll y=0):x(x),y(y){}
};
 
typedef Point Vector;
 
Vector operator +(Vector A,Vector B) { return Vector(A.x+B.x,A.y+B.y); }
Vector operator -(Vector A,Vector B) { return Vector(A.x-B.x,A.y-B.y); }
Vector operator *(Vector A,double p) { return Vector(A.x*p,A.y*p); }
 
ll Dot(Vector A,Vector B) { return A.x*B.x+A.y*B.y; }
ll Cross(Vector A,Vector B) { return A.x*B.y-A.y*B.x; }
ll Length(Vector A) { return Dot(A,A); }
 
const int maxn = 2e5+10;
Point p[maxn],sol[maxn];
ll n,m;
 
bool cmp(Point a, Point b){
   ll ans = Cross(a-p[0],b-p[0]);
   return ans>0 || ans==0 && Length(a-p[0])<Length(b-p[0]);
}
 
ll ConvexHull(Point *p,Point *ch){
    sort(p+1,p+n,cmp);
    ll m = 0;
    for (ll i=0; i<n; i++) {
        while (m>1 && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
        ch[m++] = p[i];
    }
 
    ll k = m;
    for (ll i=n-2; i>=0; i--){
        while (m>k && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
        ch[m++] = p[i];
    }
 
    if (n>1) m--;
    return m;
}
ll f(Point A,Point B){
	return abs(A.x-B.x)+abs(A.y-B.y);
}
ll Rotate_calipers(Point* ch, int n){
    ll q=1;
    ll ans = 0;
    ch[n] = ch[0];
    for (ll i=0; i<n; i++) {
        while ( Cross(ch[q+1]-ch[i],ch[q+1]-ch[i+1])>Cross(ch[q]-ch[i],ch[q]-ch[i+1]) ) q = (q+1)%n;
        ans = max( ans,max( f(ch[i],ch[q]),f(ch[i+1],ch[q+1]) ) );
        //ans = max( ans,max( Length(ch[i]-ch[q]),Length(ch[i+1]-ch[q+1]) ) );
    }
    return ans;
}
 
int main(){
    while (scanf("%lld",&n)==1){
        ll x,y;
        for (ll i=0; i<n; i++) {
            scanf("%lld%lld",&x,&y);
            p[i] = Point(x,y);
        }
 
        if (n==2) {
            printf("%lld\n",f(p[0],p[1]));
            continue;
        }
 
        for (ll i=1; i<n; i++) {
            if (p[i].x<p[0].x || p[i].x==p[0].x && p[i].y<p[0].y) swap(p[i],p[0]);
        }
 
        //sort(p+1,p+n,cmp);
        //for (int i=0; i<n; i++) printf("%d %d\n",p[i].x,p[i].y);
 
        m = ConvexHull(p,sol);
        //printf("%d\n",m);
        printf("%lld\n",Rotate_calipers(sol,m));
 
    }
    return 0;
}


Measured memory_bytes: 6352
import fractions

a,b,c,d=map(int, input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

x =(b//c)-(((a-1)//c))
y =(b//d)-(((a-1)//d))
n =lcm(c,d)
xy=(b//n)-(((a-1)//n))

ans = (b-a+1) - (x+y-xy)
print(ans)

Measured memory_bytes: 5048
import sys
sys.setrecursionlimit(10**7)
n = int(input())
per = []
p = list(map(str,input().split()))
q = list(map(str,input().split()))
def dfs(num):
    if len(num) == n:
        per.append(int(num))
        
    for i in range(1,n+1):
        if str(i) not in num:
            dfs(num+str(i))
            
        
dfs("")
p = "".join(p)
q = "".join(q)
p = int(p)
q = int(q)
a = per.index(p)
b = per.index(q)
print(abs(a-b))


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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  
  vector<vector<ll>> v(n);
  rep(i,m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  
  ll ans = 0;
  rep(i,n) {
    bool y = true;
    for (auto z : v[i]) {
      if (h[i] <= h[z]) y = false;
    }
    if (y) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 9860
#include <iostream>
#include <cstdio>

using namespace std;
#define M 110000
int main(){
  int N, a[M], i, route[M];
  bool can = false;
  cin >> N;
  for (i = 1; i <= N; i++){
    cin >> a[i];
  }
  route[0] = 1;
  i = 0;
  while (i < N){
    route[i+1] = a[route[i]];
    if (route[i+1] == 2){
      can =true;
      break;
    }
    else if (route[i+1] == 1 || route[i+1] == route[i]){
      can = false;
      break;
    }
    i++;
  }
  if (can){
    cout << i+1 << endl;
  }
  else{
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	int cnt[n+1];
	forci(0,n){
		int x;
		cin>>x;
		cnt[x]=i+1;
	}
	for(int i=1;i<=n;i++)	cout<<cnt[i]<<" ";
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 4376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e15;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n,T;
  cin >> n >> T;
  vector<ll> zeros; // b with a = 0
  vector<P> ps;
  rep(i,n) {
    ll a,b;
    cin >> a >> b;
    if (a == 0) {
      zeros.push_back(b);
    } else {
      ps.emplace_back(a,b);
    }
  }
  sort(all(ps), [&](const P& p1, const P& p2) {
    // p1.first/(p1.second+1) > p2.first/(p2.second+1)
    return p1.first * (p2.second+1) > p2.first * (p1.second+1);
  });
  sort(all(zeros));

  // For Debug
  // for (auto& p : ps) {
  //   cout << "a,b:" << p.first << "," << p.second << endl;
  //   cout << (double)p.first/(p.second+1) << endl;
  // }

  // Here, start DP in ps.
  // dp[i][j] .. using [0,i), count is j. min cost.
  ll m = ps.size();
  // vector<vector<ll>> dp(m+1, vector<ll>(31, INF));
  vector<ll> dp(31, INF);
  dp[0] = 0;
  rep(i,m) {
    for (ll j = 30; j > 0; --j) {
      ll t = dp[j-1]; // j > 0
      if (t == INF) { continue; } // j-1 is invalid.
      ll ai = ps[i].first;
      ll bi = ps[i].second;
      ll now = (ai+1)*t + (ai+bi+1); // cost for achieve j+1
      if (now > T) { continue; } // t must be equal or lower than T.
      chmin(dp[j], now);
    }
  }

  // printvec(dp);

  ll ans = 0;
  rep(i,31) {
    if (dp[i] <= T) {
      ll now = i; // current value.

      // Here, add b in greedy way.
      ll t = dp[i];
      for (ll b : zeros) {
        ll nt = t + b + 1; // next t
        if (nt <= T) {
          t = nt;
          ++now;
        }
      }
      chmax(ans,now);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	vector<int> A;
	int a,b,c;
	SCD3(a,b,c);
	
	A.PB(a);
	A.PB(b);
	A.PB(c);
	
	int K; SCD(K);
	
	sort(A.begin(),A.end());
	
	REP(k,K){
		A[2] = A[2] * 2;
	}
	
	PRINTD(A[0]+A[1]+A[2]);
	
    return 0;
}

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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e5 + 10;
const int OO = 1e9;
using namespace std;

int main() {
    IO;
    priority_queue<int, vector<int>, greater<>> q;
    int n, t;
    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        q.push(x);
    }
    vector<pair<int, int>> v;
    while (t--) {
        int kam, value;
        cin >> kam >> value;
        v.push_back({value, kam});
    }
    sort(v.rbegin(), v.rend());
    for (auto &i:v) {
        while (q.top() < i.first && i.second--) {
            q.pop();
            q.push(i.first);
        }
    }
    ll sum=0;
    while(!q.empty()){
        sum+=ll(q.top());
        q.pop();
    }
    cout<<sum;


}


Measured memory_bytes: 4648
// 2010/12/28 Tazoe

#include <iostream>
using namespace std;

void rotate(int pic[52][52], int m)
{
	int tmp[52][52];

	for(int y=1; y<=m; y++)
		for(int x=1; x<=m; x++)
			tmp[x][m-y+1] = pic[y][x];

	for(int y=1; y<=m; y++)
		for(int x=1; x<=m; x++)
			pic[y][x] = tmp[y][x];
}

bool match(int sce[102][102], int n, int pic[52][52], int m, int y, int x)
{
	int yyyy = n+1;
	int xxxx = n+1;

	int yyy = 0;
	int xxx = 0;

	bool flg = true;

	for(int yy=m; yy>=1; yy--){
		for(int xx=m; xx>=1; xx--){
			if(pic[yy][xx]==-1)
				continue;
			if(sce[y+yy-1][x+xx-1]!=pic[yy][xx]){
				flg = false;
				break;
			}
			else{
				yyy = y+yy-1;
				xxx = x+xx-1;
			}
		}
		if(!flg)
			break;
	}

	if(flg)
		if(yyyy>yyy||(yyyy==yyy&&xxxx>xxx)){
			yyyy = yyy;
			xxxx = xxx;
		}

	rotate(pic, m);

	yyy = 0;
	xxx = 0;

	flg = true;

	for(int yy=m; yy>=1; yy--){
		for(int xx=m; xx>=1; xx--){
			if(pic[yy][xx]==-1)
				continue;
			if(sce[y+yy-1][x+xx-1]!=pic[yy][xx]){
				flg = false;
				break;
			}
			else{
				yyy = y+yy-1;
				xxx = x+xx-1;
			}
		}
		if(!flg)
			break;
	}

	if(flg)
		if(yyyy>yyy||(yyyy==yyy&&xxxx>xxx)){
			yyyy = yyy;
			xxxx = xxx;
		}

	rotate(pic, m);

	yyy = 0;
	xxx = 0;

	flg = true;

	for(int yy=m; yy>=1; yy--){
		for(int xx=m; xx>=1; xx--){
			if(pic[yy][xx]==-1)
				continue;
			if(sce[y+yy-1][x+xx-1]!=pic[yy][xx]){
				flg = false;
				break;
			}
			else{
				yyy = y+yy-1;
				xxx = x+xx-1;
			}
		}
		if(!flg)
			break;
	}

	if(flg)
		if(yyyy>yyy||(yyyy==yyy&&xxxx>xxx)){
			yyyy = yyy;
			xxxx = xxx;
		}

	rotate(pic, m);

	yyy = 0;
	xxx = 0;

	flg = true;

	for(int yy=m; yy>=1; yy--){
		for(int xx=m; xx>=1; xx--){
			if(pic[yy][xx]==-1)
				continue;
			if(sce[y+yy-1][x+xx-1]!=pic[yy][xx]){
				flg = false;
				break;
			}
			else{
				yyy = y+yy-1;
				xxx = x+xx-1;
			}
		}
		if(!flg)
			break;
	}

	if(flg)
		if(yyyy>yyy||(yyyy==yyy&&xxxx>xxx)){
			yyyy = yyy;
			xxxx = xxx;
		}

	if(yyyy==n+1&&xxxx==n+1)
		return false;
	else{
		cout << xxxx << ' ' << yyyy << endl;
		return true;
	}
}

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		int sce[102][102];
		for(int y=1; y<=n; y++)
			for(int x=1; x<=n; x++)
				cin >> sce[y][x];

		int pic[52][52];
		for(int y=1; y<=m; y++)
			for(int x=1; x<=m; x++)
				cin >> pic[y][x];

		bool flg = false;
		for(int y=1; y<=n-m+1; y++){
			for(int x=1; x<=n-m+1; x++){
				flg = match(sce, n, pic, m, y, x);
				if(flg)
					break;
			}
			if(flg)
				break;
		}

		if(!flg)
			cout << "NA" << endl;
	}

	return 0;
}

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

int main() {
  int A,B,C,D,E,F,a=0,b=0;
  cin >> A >> B >> C >> D >> E >> F;
  double aa=1,ab=0;
  
  for(int i=F/(100*A); i>=0; i--){
    for(int j=(F-i*100*A)/(100*B); j>=0; j--){
      double a=(i*A+j*B)*100;
      for(int k=0; k<=a*E/(100*C); k++){
        for(int h=0; h<=(a*E/100-k*C)/D; h++){
          double b=k*C+h*D;
          if(a!=0&&a+b<=F&&b*100/(a+b)>=ab*100/(aa+ab)){
            aa=a;
            ab=b;
          }
        }
      }
    }
  }
  cout << aa+ab << ' ' << ab << endl;
}

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

int main()
{
    int K;
    cin >> K;
    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};

    cout << A[K - 1] << endl;
}


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

using namespace std;

// does s contain t?
/*
bool contain(const string& s, const string& t)
{
  if(s.size() < t.size()) return false;
  int idx = 0;
  bool flag = false;
  for(int i = 0; i < t.size(); i++) {
    flag = false;
    for(int j = idx; j < s.size(); j++) {
      if(t[i] == s[j]) idx = j+1, flag = true;
      if(flag) break;
    }
    if(!flag) break;
  }
  return flag;
}
*/

bool cmp(const string& left, const string& right)
{
  if(left.size() != right.size()) return left.size() < right.size();
  for(int i = 0; i < left.size(); i++) {
    if(left[i] != right[i]) return left[i] < right[i];
  }
  return false;
}

// additional string to let s contain t.
/*
string addstr(const string& s, const string& t)
{
  int idx = 0;
  for(int i = 0; i < t.size(); i++) {
    bool flag = false;
    for(int j = idx; j < s.size(); j++) {
      if(t[i] == s[j]) idx = j+1, flag = true;
      if(flag) break;
    }
    if(!flag) return t.substr(i);
  }
  return "";
}
*/
string addstr(string s, string t)
{
  for(int i = 0; i < s.size(); i++) {
    if(s.substr(i) == t.substr(0, s.size()-i)) return t.substr(s.size()-i);
  }
  return t;
}

string inf()
{
  string ret = "";
  for(int i = 0; i < 1000; i++) ret += "~";
  return ret;
}

int main()
{
  int N;
  while(cin >> N, N) {
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(), S.end(), cmp);
    S.erase(unique(S.begin(), S.end()), S.end());

    vector<string> T;
    for(int i = 0; i < S.size(); i++) {
      bool flag = false;
      for(int j = i+1; j < S.size(); j++) {
	if(S[j].find(S[i]) != string::npos) flag = true;
	if(flag) break;
      }
      if(!flag) T.push_back(S[i]);
    }
    
    int M = T.size();
    string add[11][11];
    for(int i = 0; i < M; i++) {
      for(int j = 0; j < M; j++) {
	add[i][j] = addstr(T[i], T[j]);
      }
    }
    
    string dp[1<<11][11];
    fill(dp[0], dp[1<<11], inf());
    for(int i = 0; i < M; i++) dp[1<<i][i] = T[i];
    
    string ans = inf();
    for(int i = 0; i < 1<<M; i++) {
      for(int j = 0; j < M; j++) {
	if(dp[i][j] == inf()) continue;
	if(i == (1<<M)-1) {
	  ans = min(ans, dp[i][j], cmp);
	}
	for(int k = 0; k < M; k++) {
	  if((i >> k) & 1) continue;
	  dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], dp[i][j] + add[j][k], cmp);
	}
      }
    }
    
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3508
#include <stdio.h>

#define MAX 100
#define INF 1000000000
#define w 0
#define x 1
#define z 2

int n, m[MAX][MAX];

void data(){
  int min,d[MAX],a[MAX],i,u;
  for(i = 0 ;i< n;i++){
    d[i] = INF;
    a[i] = INF;
  }
  d[0]=0;
  a[0]=x;
  while(1){
    min = INF;
    u = -1;
    for(i = 0;i<n;i++){
      if(min > d[i] && a[i] != z){
        u = i;
        min = d[i];
      }
    }
    if(u == -1) break;
    a[u] = z;
    for(i = 0;i<n;i++){
      if(a[i]!= z &&m[u][i] != INF){
        if(d[i] > d[u] + m[u][i]){
          d[i] = d[u] + m[u][i];
        }
      }
    }
  }
  int v;
  for(i = 0 ;i< n;i++){
    v = d[i];
    if(d[i] == INF) v = -1;
    printf("%d %d\n",i,v);
  }
}

int main(){
  scanf("%d",&n);
  int i,j,k,c,u,v;
  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
      m[i][j] = INF;
    }
  }
  for(i = 0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j = 0;j<k;j++){
      scanf("%d %d",&v,&c);
      m[u][v] = c;
    }
  }
  data();
  return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<pair<ll,ll>> vec(n);
  vector<ll> x(n),y(n);
    rep(i,n){
        in(vec[i].first,vec[i].second);
        x[i]=vec[i].first-vec[i].second;
        y[i]=vec[i].first+vec[i].second;
    }
    sort(all(x));
    sort(all(y));
    out(max(x[n-1]-x[0],y[n-1]-y[0]));
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for(int i=0;i<n;++i){
        if(strncmp(s.c_str()+i, "ABC", 3) == 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = [int(input()) for i in range(N)]

max_A = 0
max_index = 0
next_A = 0

for i in range(N):
    if A_list[i] > max_A:
        max_A = A_list[i]
        max_index = i
    elif max_A >= A_list[i] > next_A:
        next_A = A_list[i]

for i in range(N):
    if i == max_index:
        print(next_A)
    else:
        print(max_A)

Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
signed main() {
    int T1,T2,A1,A2,B1,B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    int X = (A1-B1)*T1;
    int Y = (A2-B2)*T2;
    if(X < 0) {
        X*=-1;Y*=-1;
    }
    if(X == -Y) {
        cout << "infinity" << endl;
    }
    // X-Y+X-Y+X-Y
    else if(X+Y > 0) {
        cout << 0 << endl;
    }
    else {
        // 2 3 2 3 2 3 2 3 2 3 2 3
        // 2 -1 1 -2 0 -3 -1
        if(X%(abs(X+Y)) == 0) {
            cout << X/(abs(X+Y))*2 << endl;
        }
        else {
            cout << X/(abs(X+Y))*2+1 << endl;
        }
    }
}


Measured memory_bytes: 3536
var
	N:String;
	dp:Array[0..9,0..2,0..9,0..9]of int64;
	i,j,lim,k,l,d,nxt,R:Longint;
	ans:int64;
begin
	readln(N);
	dp[0,0,0,0]:=1;
	for i:=1 to length(N)do begin
		for j:=0 to 2 do begin
			lim:=ord(N[i])-48;
			if(j=2)or((j=0)and(i>1))then lim:=9;
			for k:=0 to 9 do begin
				for l:=0 to 9 do begin
					for d:=0 to lim do begin
						if(j=0)and(d=0)then begin
							nxt:=0;
						end else if(((j=0)and(i=1))or(j=1))and(d=lim)then begin
							nxt:=1;
						end else begin
							nxt:=2;
						end;
						if nxt=0 then begin
							R:=0;
						end else if j=0 then begin
							R:=d;
						end else begin
							R:=k;
						end;
						inc(dp[i,nxt,R,d],dp[i-1,j,k,l]);
					end;
				end;
			end;
		end;
	end;
	lim:=length(N);
	for i:=0 to 9 do for j:=0 to 9 do inc(dp[lim,2,i,j],dp[lim,1,i,j]);
	for i:=0 to 9 do for j:=0 to 9 do inc(ans,dp[lim,2,i,j]*dp[lim,2,j,i]);
	writeln(ans);
end.


Measured memory_bytes: 128
#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>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
const ll dx[4] = { 1,0,0,-1 };
const ll dy[4] = { 0,1,-1,0 };
ll H, W;
queue<P> que;
char maze[55][55];
ll dist[55][55];
ll bfs() {//sx = 0,sy = 0,gx = H - 1,gy = W - 1 
    que.push(P(0, 0));
    dist[0][0] = 0;
    while (que.size()) {
        P p = que.front();
        que.pop();
        if (p.first == H - 1 && p.second == W - 1)break;
        for (int i = 0; i < 4; i++) {
            ll dh = p.first + dx[i];
            ll dw = p.second + dy[i];
            if (dh < 0 || dw < 0 || dh >= H || dw >= W)continue;
            if (maze[dh][dw] != '#' && dist[dh][dw] == INF) {
                dist[dh][dw] = dist[p.first][p.second] + 1;
                que.push(P(dh, dw));
            }
        }
    }
    return dist[H - 1][W - 1];
}
int main() {
    cin >> H >> W;
    ll cnt = 0;
    rep(i, H) {
        rep(j, W) {
            cin >> maze[i][j];
            dist[i][j] = INF;
            if (maze[i][j] == '#')cnt++;
        }
    }
    ll num = bfs();
    if (num == INF)cout << "-1" << endl;
    else {
        cout << H * W - cnt - num - 1 << endl;
    }
}

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

using namespace std;

long long int comb(int i) {
    return ((long long int)(i-1)*(long long int)i)/2;
}

int main() {
    int N;
    cin >> N;
    
    map<string, int> mp;
    for(int n=0; n<N; n++) {
        string str;
        cin >> str;
        sort(str.begin(), str.end());
        
        mp[str]++;
    }

    // for(const auto& [key, value] : mp) {
    //     cout << key << ", " << value << endl;
    // }

    long long int ans=0;
    for(auto i=mp.begin(); i!=mp.end(); i++) {
        ans += comb(i->second);
    }
    
    cout << ans << endl;

    return 0;
    
}

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

using namespace std;

int main() {
  int64_t x;
  cin >> x;
  int  N = 500000;
  vector<int64_t> cal(N, 100);
  int ans =0;

   for(int j=1; j < N; j++){
    cal.at(j) = floor(cal.at(j-1) * 1.01);
    if (cal.at(j) >= x){
        ans = j;
        //cout << "break" << endl;
        break;
    } 
  } 
  cout << ans << endl;

}


Measured memory_bytes: 7288
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back


int n,m;
vector<P> v;

int main(){
  cin>>n>>m;
  rep(i,m){
    int x,y;
    cin>>x>>y;
    v.PB(P(y,x));
  }
  sort(all(v));
  int ans=0,t=0;
  rep(i,m){
    if(t<=v[i].S){
      ans++;
      t=v[i].F;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1400
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    n,x,t=INTM()
    print(int((n+x-0.1)//x*t))
    
    
if __name__ == '__main__':
    do()

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A == B && A == C) cout << NO << endl;
    else if(A != B && A != C && B != C) cout << NO << endl;
    else cout << YES << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 3632
N = int(input())
A =list(map(int, input().split()))
flag = 1
c = 0
while flag:
    flag = 0
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            A[i], A[i-1] = A[i-1], A[i]
            c += 1
            flag = 1
print(*A)
print(c)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int n,a,sum;
bitset<5000000>f;
int main(){
	scanf("%d",&n);
	f[0]=1;
	for(register int i=0;i<n;i++){
		scanf("%d",&a);
		f|=f<<a;
		sum+=a;
	}
	int j;
	for(j=sum/2;!f[j];j--);
	printf("%d",sum-j);
}

Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int,input().split())
    res = 0
    for i in range(k, n + 1):
        # 最小が 0 + 1 + ... + i - 1
        # 最大が (n + 1) + n + ... + (n - i + 2)
        low = (0 + (i - 1)) * i // 2
        high = (n + (n - i + 1)) * i // 2
        res += high - low + 1
        res %= MOD
    res += 1
    res %= MOD
    print(res)
resolve()

Measured memory_bytes: 63592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int L; cin>>L;
  vector<int> ans1, ans2;
  int sum = 0;
  int base = 1;
  while(true) {
    if(sum + base >= L) break;
    ans1.push_back(base);
    sum += base;
    base *= 2;
  } 
  const int rem = L - (sum+1);
  int r = rem;
  for(int i = 20; i >= 0; i--) {
    int v = (1<<i);
    if(r >= v) {
      ans2.push_back(i);
      r -= v;
    }
    //    cout << v << " " << r << " " << i << endl;
  }
  reverse(ans2.begin(), ans2.end());
  //  REP(i,ans1.size()) cout << " " << ans1[i]; cout << endl;
  //  REP(i,ans2.size()) cout << " " << ans2[i]; cout << endl;
  vector<int> from, to, cost;
  REP(i,ans1.size()) {
    from.push_back(i+1);
    to.push_back(i+2);
    cost.push_back(0);
    from.push_back(i+1);
    to.push_back(i+2);
    cost.push_back(1<<i);
  }
  int N = to.back();
  int c = L;
  REP(i,ans2.size()) {
    from.push_back(ans2[i]+1);
    to.push_back(N);
    c -= (1<<ans2[i]);
    cost.push_back(c);
  }
  int M = from.size();
  cout << N << " " << M << endl;
  REP(i,M) {
    cout << from[i] << " " << to[i] << " " << cost[i] << endl;
  }
  return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> K(N);
  int A[N][100];
  for(int i = 0; i < N; i++){
    cin >> K[i];
    for(int j = 0; j < K[i]; j++){
    cin >> A[i][j];
    }
  }

  vector<int> food(M);

  for(int i = 0; i < N; i++){
    for(int j = 0; j < K[i]; j++){
      food[A[i][j] - 1] += 1; 
    }
  }
  int ans = 0;
  for(int i = 0; i < M; i++){
    if(food[i] == N) ans++;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.rstrip().split())
    if (xa1 <= xb2 and xb1 <= xa2) and (ya1 <= yb2 and yb1 <= ya2):
        print 'YES'
    else:
        print 'NO'

Measured memory_bytes: 4200
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
  size_t N;
  intmax_t W;
  scanf("%zu %jd", &N, &W);

  intmax_t w;
  std::vector<intmax_t> v[4];
  {
    intmax_t tmp;
    scanf("%jd %jd", &w, &tmp);
    v[0].emplace_back(tmp);
  }
  
  for (size_t i=1; i<N; ++i) {
    intmax_t ww, vv;
    scanf("%jd %jd", &ww, &vv);
    v[ww-w].emplace_back(vv);
  }

  for (size_t i=0; i<4; ++i) {
    std::sort(v[i].begin(), v[i].end(), std::greater<>());
  }

  std::vector<intmax_t> V[4];
  for (size_t i=0; i<4; ++i) {
    V[i].emplace_back(0);
    for (size_t j=0; j<v[i].size(); ++j) 
      V[i].emplace_back(V[i].back()+v[i][j]);
  }

  intmax_t res=0;
  for (size_t i=0; i<V[0].size(); ++i)
    for (size_t j=0; j<V[1].size(); ++j)
      for (size_t k=0; k<V[2].size(); ++k)
        for (size_t m=0; m<V[3].size(); ++m) {
          intmax_t ww=w*(i+j+k+m)+j+2*k+3*m;
          if (ww > W) continue;

          res = std::max(res, V[0][i]+V[1][j]+V[2][k]+V[3][m]);
        }

  printf("%jd\n", res);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b != c) cout << "Yes" << endl;
    else if(a != b && b == c) cout << "Yes" << endl;
    else if(a == c && b != c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String... args) {

		Scanner sc = new Scanner(System.in);

		// まずい解毒剤クッキー数
		int badMedichineCount = Integer.parseInt(sc.next());

		// おいしい解毒剤クッキー数
		int goodMedichineCount = Integer.parseInt(sc.next());

		// おいしい毒入りクッキー数
		int poisonCount = Integer.parseInt(sc.next());

		if (poisonCount <= (goodMedichineCount + badMedichineCount)) {
			System.out.println(poisonCount + goodMedichineCount);
		} else {
			System.out.println((goodMedichineCount * 2) + badMedichineCount + 1);
		}

	}

}


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

int main()
{

    int V, e;
    ll r;
    cin >> V >> e >> r;
    pair<int, int> bridges[e];
    ll cost[e];
    vector<ll> d(V, INF);
    d[r] = 0;
    rep(i, e)
    {
        int s, t;
        ll d;
        cin >> s >> t >> d;
        bridges[i].first = s;
        bridges[i].second = t;
        cost[i] = d;
    }
    rep(i, V)
    {
        bool update = false;
        rep(j, e)
        {
            int u = bridges[j].first, v = bridges[j].second;
            if (d[v] > d[u] + cost[j] && d[u] != INF)
            {
                d[v] = d[u] + cost[j];
                update = true;
            }
        }
        if (update && i == V - 1)
        {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
        if (!update)
            break;
    }
    rep(i, V)
    {
        if (d[i] == INF)
            cout << "INF" << endl;
        else
            cout << d[i] << endl;
    }
    return 0;
}

// accepted


Measured memory_bytes: 3116