akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

vector<int> h(1000000, 0);

using graph = vector<vector<int>>;
vector<bool> seen;
int mmax = 0;
void dfs(const graph &g, int v){
    seen[v] = true;
    if(h[v] > mmax) mmax = h[v];

    for(auto next_v : g[v]){
        if(seen[next_v]) continue;
        dfs(g, next_v);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    
    graph g(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }

    int cnt = 0;
    for(int i = 0; i < n; i++){
        int k = h[i];
        for(int j = 0; j < g[i].size(); j++){
            if(h[i] == h[g[i][j]]){
                k = -1;
                break;
            }
            k = max(k, h[g[i][j]]);
        }
        if(k == h[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

const int inf = 1e9 + 5;
int n;
int m;
PP p[100000];
PP q[100000];
PP a[100001];
PP b[100001];
PP f[100001];
PP g[100001];

int len(PP p) {
  return max(0, p.second - p.first);
}

PP cap(PP p, PP q) {
  return PP(max(p.first, q.first), min(p.second, q.second));
}

void reduce() {
  int prevr = -inf;
  vector<bool> chosen(n, true);
  for (int i = 0; i < n; ++i) {
    if (p[i].second <= prevr) chosen[i - 1] = false;
    prevr = p[i].second;
  }
  
  for (int i = 0; i < n; ++i) {
    if (!chosen[i]) continue;
    q[m] = p[i];
    ++m;
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    p[i] = PP(a, b + 1);
  }
  sort(p, p + n, [](PP a, PP b) {
    return a.first < b.first || a.first == b.first && a.second > b.second;
  });
  
  a[0] = PP(-inf, inf);
  for (int i = 0; i < m; ++i) {
    a[i + 1] = cap(a[i], p[i]);
  }
  b[m] = PP(-inf, inf);
  for (int i = m - 1; i >= 0; --i) {
    b[i] = cap(b[i + 1], p[i]);
  }
  
  reduce();
  
  if (m == 1) {
    cout << len(p[0]) + len(p[n - 1]) << endl;
    return 0;
  }
  
  f[0] = PP(-inf, inf);
  for (int i = 0; i < m; ++i) {
    f[i + 1] = cap(f[i], q[i]);
  }
  g[m] = PP(-inf, inf);
  for (int i = m - 1; i >= 0; --i) {
    g[i] = cap(g[i + 1], q[i]);
  }
  
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    PP c = cap(f[i], g[i + 1]);
    mx = max(mx, len(p[i]) + len(c));
  }
  
  for (int i = 1; i < m; ++i) {
    mx = max(mx, len(f[i]) + len(g[i]));
  }
  cout << mx << endl;
}

Measured memory_bytes: 4480
#include<iostream>

using namespace std;

int main(){
	
	int x,h,m,s;
	cin>>x;
	if(x>=0&&x<=86400){
	h=x/3600;
	m=(x%3600)/60;
	s=(x%3600)%60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	}
	return 0;

}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code



int main(int argc, char const* argv[])
{
	int n,m;
	cin >> n >> m;
	vector<VVL> G(3,VVL(n));
	VVL visited(3,VL(n,0));
	for (int i = 0; i < m; i++) {
		int u,v;
		cin >> u >> v;
		u--;v--;
		for (int i = 0; i < 3; i++) {
		G[i][u].push_back(v);
		}
	}
	int s,t;
	cin >> s >> t;
	s--;t--;
	visited[0][s] = 1;
	queue<int> q;
	q.push(s);
	int kkp = 0;
	for (int d = 1;!q.empty(); d++) {
		int next = (++kkp)%3;
		int ql = q.size();
		for (int i = 0; i < ql; i++) {
			int v = q.front();
			q.pop();
			for (auto&& var : G[next][v]) {
				if (var == t and next == 0) {
					cout << d/3 << endl;
					return 0;
				}
				if (visited[next][var] == 0) {
					visited[next][var] = 1;
					q.push(var);
				}
			}
		}
	}

	cout << -1 << endl;

	return 0;
}


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


int main()
{
	int N,K;
	cin>>N>>K;
	vector<ll> H(N);
	rep(i,N) cin>>H[i];
	sort(H.begin(),H.end(),greater<ll>());
	ll ans=0;
	Rep(i,K,N)
	{
		ans+=H[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll inf = 1e17;
const ll N = 1e5+10;
const ll bits = 30;
const ll mod = 1e9+7;

ll dp[N][2]; // 1 if first win 0 if second wins
ll arr[N];

int solve(int k,int pl,int n){
    if(k<0){
        return pl;
    }

    if(k==0){
        return !pl;
    }
    if(dp[k][pl]!=-1){
        return dp[k][pl];
    }

    dp[k][pl] = !pl;

    for(int i=0;i<n;i++){
        if(pl==solve(k-arr[i],!pl,n)){
            dp[k][pl] = pl;
            break;
        }
    }

    return dp[k][pl];

}


int main(){
    FASTIO;

    int n;
    cin>>n;
    int k;
    cin>>k;

    for(int i=0;i<=k;i++){
        dp[i][0] = dp[i][1] = -1;
    }


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

    if(solve(k,1,n)){
        cout<<"First\n";
    }else{
        cout<<"Second\n";
    }
    
}

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

typedef long long int ll;
using namespace std;

const ll MOD = 1e9 + 7;

int solve(int n,int a,int b){
	int ans=0;
	for(int i=0;i<=n;i++){
		int res = n - i*a;
		if(res < 0) break;
		if(res%b == 0) ans++;
	}
	return ans;
}

int main()
{
	int r,g,b,n; cin>>r>>g>>b>>n;
	int ans=0;
	for(int i=0;i<=n;i++){
		int res = n - i*r;
		if(res < 0) break;
		ans += solve(res,g,b);
	}

	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, a[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	bool ok = 1;
 	for(int i=1; i<=n; i++)
 	{
 		cin >> a[i];
 		if(a[i]%3==0 || a[i]%5==0) continue;
 		if(a[i]%2==0) ok = 0;
 	}
 	if(ok) cout << "APPROVED\n";
 	else cout << "DENIED\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
    const auto INF = numeric_limits< T >::max();
    vector< T > dist(g.size(), INF);

    using Pi = pair< T, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
        auto next_cost = cost + e.cost;
        if(dist[e.to] <= next_cost) continue;
        dist[e.to] = next_cost;
        que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main(void) {
    int H, W;
    cin >> H >> W;
    WeightedGraph<int> g(10);
    for(int i=0; i<10; i++) {
        for(int j=0; j<10; j++) {
            int cost;
            cin >> cost;
            g[i].emplace_back(j, cost);
        }
    }
    vector<int> cnt(10);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            int A;
            cin >> A;
            if(A != -1) {
                ++cnt[A];
            }
        }
    }

    int ans = 0;
    for(int i=0; i<10; i++) {
        ans += dijkstra(g, i)[1] * cnt[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define STRING_LENGTH 100
#define ARRAY_SIZE (STRING_LENGTH + 1)

void solve(char s[ARRAY_SIZE]);


int main()
{
  char s[ARRAY_SIZE];

  scanf("%s", &s);
  solve(s);

  return 0;
}

void solve(char s[ARRAY_SIZE])
{
  int i;
  int length;

  i = 0;
  while (s[i] != '\0')
    {
      i++;
    }
  length = i;

  printf("%c%d%c\n", s[0], length - 2, s[length - 1]);
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin>>t;
    using P = pair<int,int>;
    while(t--){
        int N; cin>>N;
        vector<P> Left,Right;
        ll ans=0;
        rep(i,N){
            int k,l,r; cin>>k>>l>>r;
            ((l>r)?Left:Right).pb({k,abs(l-r)});
            ans+=min(l,r);
        }
        sort(rall(Left));
        sort(all(Right));
        int L = Left.size();
        int R = Right.size();
        int idx=0;
        priority_queue<int> que;
        FOR(i,L,N-1){
            while(idx<R && Right[idx].fi<=i){
                que.push(Right[idx++].se);
            }
            if (!que.empty()){
                ans+=que.top();
                que.pop();
            }
        }
        idx = 0;
        que = priority_queue<int>();
        RFOR(i,L-1,0){
            while(idx<L && Left[idx].fi>i){
                que.push(Left[idx++].se);
            }
            if (!que.empty()){
                ans+=que.top();
                que.pop();
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


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

static const int INFTY = 1<<21;

/*
enum Color{
    WHITE,
    GRAY,
    BLACK
};
*/

int n;
deque<int> Q;
int d[100]; //距離で色も表せる
bool M[100][100];
//Color color[100];


void dfs(int i){
    for(int j=0; j<n; j++){
        //color[i] = WHITE;
        d[j] = INFTY;   //色の要素も兼ねている
    }

    //color[i] = GRAY;
    d[i] = 0;
    Q.push_back(i);

    while(!Q.empty()){
        int u = Q.front();
        Q.pop_front();
        for(int v=0; v<n; v++){
            if((M[u][v]==true)&&(d[v]==INFTY)){
                //color[u] = GRAY;
                d[v] = d[u] + 1;
                Q.push_back(v);
            }
        }
        //color[u] = BLACK;
    }

    for(int i=0; i<n; i++){
        cout << i+1 << " ";
        if(d[i]==INFTY) cout << -1;
        else cout << d[i];
        cout << endl;
    }
}

int main(){

    cin >> n; 

    for(int i=0; i<n; i++){
        int u, k;
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            int v;
            cin >> v;
            v--;
            M[u][v] = true;
        }
    }

    dfs(0);

    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7; //998244353
const double PI = acos(-1);

long long p[405][405];
long long dp[405][405];

void precalc() {
    for (int power = 0; power <= 400; power++) {
        for (int x = 1; x <= 400; x++) {
            if (power == 0) p[x][0] = 1;
            else p[x][power] = p[x][power - 1] * x % MOD;
        }
    }
    for (int power = 0; power <= 400; power++) {
        for (int x = 1; x <= 400; x++) {
            p[x][power] += p[x - 1][power];
            p[x][power] %= MOD;
        }
    }
}

long long get(int power, int l, int r) {
    return (p[r][power] - p[l - 1][power] + MOD) % MOD;
}

void solve() {
    int n, C; cin >> n >> C;
    vector<int> a(n + 1), b(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int c1 = 0; c1 <= C; c1++) {
            for (int c2 = 0; c2 + c1 <= C; c2++) {
                dp[i][c1 + c2] += (dp[i - 1][c1] * get(c2, a[i], b[i]) % MOD);
                dp[i][c1 + c2] %= MOD;
            }
        }
    }
    cout << dp[n][C] << endl;
} 

int main() {
    jonathan; 
    livingston;
    precalc();
    solve();
    return 0;
}

Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size()) {
        int ret = 0;
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'T' || s[i] == 'G') {
            ret++;
            rep2(j, i + 1, s.size()) {
                if (s[j] == 'A' || s[j] == 'C' || s[j] == 'T' || s[j] == 'G')
                    ret++;
                else
                    break;
            }
        }
        ans = max(ans, ret);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
nm = raw_input().split()
nm[1] = str(int(nm[1]) / 2)
scc1 = min(int(nm[0]),int(nm[1]))
nm[0] = str(int(nm[0]) - scc1)
nm[1] = str(int(nm[1]) - scc1)
scc2 = int(nm[1]) / 2
print scc1+scc2

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


def solve(K: int, S: str):
    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + '...')
    return


# Generated by 1.1.7.1 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()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A[100005];
int main()
{
  ios::sync_with_stdio(false);
  int N;
  ll T;
  cin >> N >> T;
  for( int i=0; i<N; i++ ) cin >> A[i];
  ll vmin = A[N-1];
  ll vmax = A[N-1];
  ll d = 0;
  int c = 0;
  for( int i=N-2; i>=-1; i-- ){
    if( i < 0 || A[i] > vmax ){
      ll vd = vmax - vmin;
      if( d < vd ){
        d = vmax - vmin;
        c = 1;
      } else if( d == vd ){
        c++;
      }
      if( i >= 0 ) vmin = vmax = A[i];
    }
    vmin = min( vmin, A[i] );
  }
  cout << c << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

def main():
    N = int(input())
    b = list(map(int,input().split()))

    answer = []
    while b:
        for i in range(len(b)-1,-1,-1):
            if b[i] == i+1:
                answer.append(b[i])
                b.pop(i)
                break
        else:
            print(-1)
            return
    for i in range(N-1,-1,-1):
        print(answer[i])
    return 

if __name__ == '__main__':
    main()


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

int shichigo(long long a,long long ju) {
  int a2=(a%(10*ju))/ju;
  if (a2==3 || a2==5) {a+=2*ju;}
  else if (a2==0) {a+=3*ju;}
  else {
    a-=4*ju;
    ju*=10;
	a=shichigo(a,ju);
  }
  return a;
}

int main() {
  long long A,B,C,D,E,F,G,H,I,J,K,L,M,N,T,W,X,Y,JU;
  string S;
  cin >>  N;
  
  vector<long long> vec(27010,100000000000);
  K=0;
  A=355;
  
  while (K<27000) {
    
	JU=1;
	A=shichigo(A,JU);
    
	T=0;
	for (long long i=1;i<=A;i*=10) {
	  if ((A%(10*i))/i==3 && (T==0 || T==5 || T==7 || T==12)) {T+=3;}
	  if ((A%(10*i))/i==5 && (T==0 || T==3 || T==7 || T==10)) {T+=5;}
	  if ((A%(10*i))/i==7 && (T==0 || T==3 || T==5 || T==8)) {T+=7;}
	}
	
	if (T==15) {vec.at(K)=A;K++;}
  }
  
  sort(vec.begin(),vec.end());
  int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 27000; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (vec.at(mid)>N) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    cout << right << endl;
  
  
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


int main(){
  ll N;
  cin>>N;
  vector<pll> A(N);
  for(int i=0;i<N;i++){cin>>A[i].F; A[i].S=i;}
  sort(A.begin(),A.end());
  vector<ll> ans(N);
  for(int i=0;i<N;i++){ans[i]=A[i].S+1;}
  cout<<ans<<endl;
  
  
  return 0;
}


Measured memory_bytes: 3200
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n,x,ans=0;
  string s;
  cin >> n;
  cin >> s;
  x=0;
  for(char c:s){
    if(c=='I') x++;
    else x--;
    ans = max(ans,x);
  }
  cout << ans << endl;
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e6+10;
const int mod = 1e9+7;

using namespace std;

set<string> nums;

char nxt[] = {'0','1','2','3','4','5','6','7','8','9'};

bool ok(string x){
	for(int i=1;i<x.size();++i){
		int previous = x[i-1]-'0';
		int current = x[i]-'0';
		if(abs(previous-current)>1)
			return false;
	}
	return true;
}

ll transform(string x){
	ll val = 0,ha=1LL;
	for(int i=x.size()-1;i>=0;--i){
		val = val + ((x[i]-'0')*ha);
		ha*=10LL;
	}
	return val;
}

bool comp(string x){
	if(x.size() > 10)
		return true;
	return transform(x) > 3234566667;
}

void generate(string num){
	if(comp(num) || nums.count(num)) return;
	//if(ok(num)) 
	nums.insert(num);
	//cout<<"num="<<num<<endl;
	for(char c='0';c<='9';++c){
		string aux = num;
		aux.pb(c);
		int previous = num.back()-'0';
		int current = c-'0';
		//cout<<previous<<" "<<current<<endl;
		if(abs(previous-current)>1){
			string go = num;
			int nx = (go.back()+1)-'0';
			int nnx = (go[go.size()-2]-'0');
			if(go.back()+1 <= '9' && abs(nx-nnx)<=1){
				go.back()++;
				generate(go);
			}
		}
		else
			generate(aux);
	}
	return;
}

void solve(){
	int n;
	cin>>n;
	generate("1");
	generate("2");
	generate("3");
	generate("4");
	generate("5");
	generate("6");
	generate("7");
	generate("8");
	generate("9");
	vector<ll>ans;
	for(string x:nums){
		ans.pb(transform(x));
	}
	sort(all(ans));
	cout<<ans[n-1]<<endl;
}

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

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

using namespace std;

int main()
{
	int A,B,K;
	cin>> A>> B>> K;
	for(int i=A;i<min(A+K,B+1);i++)cout<< i<< endl;
	for(int i=max(B-K+1,A+K);i<=B;i++)cout<< i<< endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define pai 3.1415926535

int main(void) {
	int A[3];
	int sum = 0;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &A[i]);
		sum += A[i];
	}
	if (sum >= 22) {
		printf("bust");
	}
	else {
		printf("win");
	}

	return 0;
}

Measured memory_bytes: 128
import math as m

def is_lunlun(n):
    d=int(m.log10(n))

    for i in range(d):
        q = n // (10**(d-i))
        r = n % 10**(d-i)
        if i == 0:
            q_pre = q
        
        if abs(q_pre-q) >1:
            return False
        if i == d-1:
            if abs(r-q) > 1:
                return False
        n=r
        q_pre=q
    return True

K=int(input())

tbl = [[0]*10 for _ in range(10)]
accum = [[0]*10 for _ in range(10)]
cnt = 0
i=0
j=0
for j in range(10):
    if cnt >= K:
        break

    for i in range(10):
        if j == 0:
            tbl[i][j] = 1
        else:
            if i == 0:
                tbl[i][j] = tbl[i][j-1] + tbl[i+1][j-1]
            elif i==9:
                tbl[i][j] = tbl[i-1][j-1] + tbl[i][j-1]
            else:
                tbl[i][j] = tbl[i-1][j-1] + tbl[i][j-1] + tbl[i+1][j-1]

        if i != 0:
            cnt += tbl[i][j]
        accum[i][j]=cnt
        if cnt >= K:
            i_s=i
            j_s=j
            break

i=i_s
j=j_s

digit=str(i)

base=accum[i-1][j] if i>0 else accum[j-1][9]

while j > 0:
    j=j-1
    for itmp in [i-1,i,i+1]:
        if itmp < 0 or itmp >9:
            continue
        base += tbl[itmp][j]
        if base >= K:
            base -= tbl[itmp][j]
            break
    digit+=str(itmp)
    i=itmp
print(digit)


Measured memory_bytes: 3188
#include <stdio.h>
int main()
{
    int a,b,c,sum,max;
    max=0;
    scanf("%d%d%d",&a,&b,&c);
    if (a>max) max=a;
    if (b>max) max=b;
    if (c>max) max=c;
    sum=0;
    sum=sum+max-a;
    sum=sum+max-b;
    sum=sum+max-c;
    if (sum%2==0) printf("%d",sum/2); else
        printf("%d",(sum+3)/2);
    return(0);
}


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

using namespace std;

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

    string x;
    cin >> x;

    int counter = 0;
    for(int i=0; i<x.size()/2; i++) if(x[i] != x[x.size() - i - 1]) counter++;

    cout << counter;

    return 0;
}

Measured memory_bytes: 256
def bisect_right(a, x, lo=0, hi=None):
    """Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(x) will
    insert just after the rightmost x already there.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """

    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo

n = int(input())
f = int(input())
ans = [-f]
for i in range(n-1):
    now = -int(input())
    j = bisect_right(ans,now)
    if j == len(ans):
        ans.append(now)
    else:
        ans[j] = now

print(len(ans))


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

int main() {
  int w, a, b; cin >> w >> a >> b;
  if (b > a + w) {
    cout << b - a - w << endl;
  } else if (b + w < a) {
    cout << a - b - w << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
int x;
bool prime(int a) {
	for(int i=2;i*i<=a;i++) if(a%i==0) return false;
	return true;
}
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
  	cin>>x;
  	while(!prime(x)) x++;
  	cout<<x;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void) {
  int a, b, c;
  int change[3];
  
  while(cin >> a >> b, a!=0 && b!=0) {
    for(int i = 0 ; i < 3 ; i++) {
      change[i] = 0;
    }
    c = b - a;
    while(c != 0) {
      if(c >= 1000) { c -= 1000; change[2]++; }
      else if(c >= 500) { c -= 500; change[1]++; }
      else if(c >= 100) { c -= 100; change[0]++; }
    }
    printf("%d %d %d\n", change[0], change[1], change[2]);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B;
  cin >> A >> B;
  if(B%A==0) cout << A+B << "\n";
  else       cout << B-A << "\n";

  return 0;
}

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

int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    long long ztime=n/(a+b);
    long long ans=ztime*a;
    long long res=n-ztime*(a+b);
    ans+=min(res,a);
    cout<<ans<<endl;
    return 0;
    
}

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

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

	int rect = 0;
	int loze = 0;

	int a, b, c;
	char c1, c2;

	while(cin >> a >> c1 >> b >> c2 >> c)
{		if(a * a + b * b == c * c){
			rect++;
		} 
		if(a == b){
			loze++;
		}
	}

	cout << rect << endl;
	cout << loze << endl;

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  ll a[n*3];
  rep(i,n*3) R a[i];
  sort(a,a+n*3,greater<int>());
  ll ans=0;
  rep(i,n) ans+=a[i*2+1];
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 2560
# B 
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def calc(a,b):
    sa=list(str(a))
    sb=list(str(b))
    res=0
    for aa in sa:
        res+=int(aa)
    for bb in sb:
        res+=int(bb)
    return res

n=ni()
ans=10**6
for i in range(1,n):
    a=i
    b=n-i
    t=calc(a,b)
    ans=min(ans,t)
print(ans)



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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  auto it = find(str.begin(), str.end(), c);
  return it != str.end();
}
*/

bool contain(string &str, char c) {
  auto it = find(str.begin(), str.end(), c);
  return it != str.end();
}

int main() {
  string s, t;
  cin >> s >> t;
  rep(i, 100) {
    string new_s;
    rep(j, s.size() - 1) {
      new_s += s[j + 1];
    }
    new_s += s[0];
    if (new_s == t) {
      cout << "Yes" << endl;
      exit(0);
    }
    s = new_s;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
p = [list(map(str,input().split())) for _ in range(m)]
###ACとWAのフラグを作成、ACしたらフラグを立てていく
ac =[0]*(n+1)
wa =[0]*(n+1)
for i in range(m):
    question =int(p[i][0])
    ###フラグが立っていればカウントしない
    if p[i][1] == "AC" and ac[question] == 0:
        ac[question] = 1
     ###同様に一度ACしてフラグがあるならWAもカウントしない
    elif p[i][1] == "WA" and ac[question] == 0:
        wa[question] += 1
for j in range(n+1):
  ###ACしていないならばWAはカウントしない
    if ac[j] == 0:
        wa[j] = 0
       # print(wa)
print(sum(ac),sum(wa))


Measured memory_bytes: 35084
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W = LI()
    a = []
    for _ in range(H):
        a.append(SS())
    a = ''.join(a)

    # not 中央行 and not 中央列 の文字は4n個
    # 中央行 xor 中央列 は2n or 4n個
    # 中央行中央列 は1個
    cnt = collections.Counter(a)
    l = list(cnt.values())
    c4 = len([i for i in l if i % 4 == 0])
    c2 = len([i for i in l if i % 4 == 2])
    c1 = len([i for i in l if i % 4 == 1])
    # print(cnt)
    # print(c4, c2, c1)

    if H % 2 == W % 2 == 0:
        if c4 == len(cnt):
            print('Yes')
        else:
            print('No')
    elif H % 2 == W % 2 == 1:
        if c1 == 1 and c2 <= (H + W - 2) // 2 and c4 + c2 + c1 == len(cnt):
            print('Yes')
        else:
            print('No')
    else:
        if H % 2 == 1:
            if c2 <= W // 2 and c4 + c2 == len(cnt):
                print('Yes')
            else:
                print('No')
        if W % 2 == 1:
            if c2 <= H // 2 and c4 + c2 == len(cnt):
                print('Yes')
            else:
                print('No')
            
if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10128
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
n = input()
ans = 0
for i in range(len(n)):
    ans += int(n[i])
    ans = ans%9
if ans == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10136
using System;
class aoj
{
    static void Main()
    {
        while (true)
        {
            string[] u = Console.ReadLine().Split(' ');
            int h = int.Parse(u[0]), w = int.Parse(u[1]);
            if (h == 0 && w == 0) break;
            char[,] a = new char[h,w];
            for (int i = 0; i < h; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < w; j++)
                    a[i,j] = s[j];
            }
            int b = 0, c = 0;
            bool[,] d = new bool[h,w];
            while (a[b,c] != '.')
            {
                d[b,c] = true;
                if (a[b,c] == '>')
                    c++;
                else if (a[b,c] == '<')
                    c--;
                else if (a[b,c] == 'v')
                    b++;
                else if (a[b,c] == '^')
                    b--;
                if (d[b,c])
                {
                    b = -1;
                    c = -1;
                    break;
                }
            }
            if (b == -1 && c == -1)
                Console.WriteLine("LOOP");
            else
                Console.WriteLine(c + " " + b);
        }
    }
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n, h;
    cin >> n >> h;

    vector<int> a(n);
    vector<int> b(n);

    int amax = 0;
    for(int in=0;in<n;in++) {
        cin >> a.at(in) >> b.at(in);
        if(amax<a.at(in)) {
            amax = a.at(in);
        }   
    }

    int ans = 0;
    sort(b.begin(), b.end(), greater<int>());
    for(int in=0;in<n;in++) {
        if(b.at(in)>=amax) {
            h -= b.at(in);
            ans++;
            if(h<=0) {
                cout << ans << endl;
                return 0;
            }
        }
    }
    
    ans += h / amax;
    if(h%amax!=0) ans++;

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


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

int main(){
    int64_t H;
    cin >> H;
    bitset<50> b(H);
    int64_t ans = 0, n = 1;
    while (b.any()){
        b >>= 1;
        ans += n;
        n *= 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N;
  cin >> N;

  int S = 0;
  for (int n=N; n != 0; n /= 10) S += n%10;

  if (N % S == 0) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 101

void enQ(int);
int deQ(void);
void bfs(int);

int G[N][N]={};
int n,head=0,tail=0,d[N],color[N],Q[N];

int main(){
  int i,j,u,k,v;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }

  bfs(0);

  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,d[i]);
  }
  return 0;
}
void enQ(int s){
  Q[tail]=s;
  tail++;
  if(tail==N){
    tail=0;
  }
}
int deQ(){
  int num;
  num=Q[head];
  head++;
  if(head==N){
    head=0;
  }
  return num;
}
void bfs(int s){
  int i,u,v;
  for(i=0;i<n;i++){
    color[i]=0;
    d[i]=-1;
  }
  color[s]=1;
  d[s]=0;

  enQ(s);
  while(head != tail){
    u=deQ();
    for(v=0;v<n;v++){
      if(color[v]==0 && G[u][v]==1){
        color[v]=1;
        d[v]=d[u]+1;
        enQ(v);
      }
    }
    color[u]=2;
  }
}

Measured memory_bytes: 632
#include<iostream>
#include<algorithm>
#include <tuple>
#include <set>
using namespace std;

std::tuple<int,int,int> exchange(int x,int y,int z) {
    return std::make_tuple((y+z)/2, (z+x)/2, (x+y)/2);
}
bool isAlleven(int x,int y,int z) {
    return (x%2==0)&&(y%2==0)&&(z%2==0);
}

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    std::set<std::tuple<int,int,int>> appeared;
    appeared.insert(std::make_tuple(A,B,C));
    int ans=0;
    while(isAlleven(A,B,C)) {
        std::tuple<int,int,int> tuple = exchange(A,B,C);
        A=std::get<0>(tuple);
        B=std::get<1>(tuple);
        C=std::get<2>(tuple);
        tuple = std::make_tuple(A,B,C);
        if (appeared.find(tuple) != appeared.end()) {
            ans=-1;
            break;
        }
        appeared.insert(tuple);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,l;
	while(~scanf("%d%d",&n,&l))
  {
	int a[210];
	int i;
	for(i=0;i<=n-1;i++)
       a[i]=l+i;
    sort(a,a+n);
    int sum=0;
    for(i=0;i<=n-1;i++)
        sum+=a[i];
    if(l<=0&&l>=(-n+1))
       printf("%d\n",sum);
	else
	if(l>0)
	   printf("%d\n",sum-a[0]);
	else 
	if(l<0)
	   printf("%d\n",sum-a[n-1]);
  }
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	int N = 123456 * 2;
	vector<bool> isp(N + 1, 1);
	isp[0] = isp[1] = 0;
	REP (i, 2, N) if (isp[i]) for (int j = i + i; j <= N; j += i) isp[j] = 0;
	for (int n; cin >> n, n != 0; ) {
		int ans = 0;
		REP(i, n + 1, 2 * n) if (isp[i]) ans++;
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

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

int gcd(int a,int b){
	if(a < b)swap(a,b);
	if(b == 0)return a;
	return gcd(b,a%b);
}

bool mp[33333];

int main()
{
	int n;cin >> n;
	int cou = 0;
	int sum = 0;
	vector<int> v;
	for(int i = 2;cou + 1 < n;i++){
		if(gcd(i,6) != 1){
			mp[i] = true;
			cou++;
			sum += i;
			v.PB(i);
		}
	}
		
	REP(i,30001){
		if(i > 0 && !mp[i] && (sum + i) % 6 == 0 && gcd(i,sum) != 1){
			v.PB(i);
			break;
		}
	}
	
	REP(i,n){
		cout << v[i];
		if(i != n-1)cout << ' ';
	}cout << endl;
	
	return 0;
}

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

int main(){
  int n,a,ans=1000000;
  cin >> n;
  for(int i=0;i<n;i++){
    int unti =0;
    cin >> a;
    if(a%2 != 0){
      ans =0;
    }
    while(a%2==0){
      a/=2;
      unti+=1;
    }
    ans =min(ans,unti);
  }
  cout<<ans<<endl;
}


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

using namespace std;

#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define mp make_pair
#define pb push_back
#define eps 1e-9
#define PI acos(-1.0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<int, pii> iii;
typedef vector<pii> vii;
typedef vector<iii> vip;
typedef long double ld;
int INF = 1e9 + 5;
// const ll INF = 1e18L + 5;

bool prime(ll x)
{
    if(x == 2)
        return true;
    for(int i = 2 ; i * i <= x ; i++)
        if(x % i == 0)
            return false;
    return true;
}


template <typename T> void self_max(T& a, T b)
{
    a = max(a, b);
}

int main()
{

    int n, m;
    string str, t;
    cin >> str >> t;
    n = str.length(), m = t.length();
    vector<vector<pair<int, pair<int, int>>>> dp(n + 1, vector<pair<int, pair<int, int>>>(m + 1, {-INF, {0, 0}}));
    dp[0][0] = {0, {0, 0}};
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if(str[i] == t[j])
                self_max(dp[i + 1][j + 1], make_pair(dp[i][j].first + 1, make_pair(i, j)));
            self_max(dp[i + 1][j], make_pair(dp[i][j].first, make_pair(i, j)));
            self_max(dp[i][j + 1], make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    iii ans = {0, {0, 0}};
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= m; ++j)
        {
            self_max(ans, make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    string s;
    pii cur = ans.second;
    while(!(cur.first == 0 || cur.second == 0))
    {
        int i = cur.first, j = cur.second;
        pii prev = dp[i][j].second;
        if(prev == make_pair(i - 1, j - 1))
            s += str[i - 1];
        cur = prev;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 105984