akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Dice d[] = new Dice[n];

		for (int i = 0; i < n; i++) {
			int num[] = new int[6];
			for (int j = 0; j < 6; j++) {
				num[j] = sc.nextInt();
			}
			d[i] = new Dice(num);
		}

		if (isEqualDices(d, n)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		

	}

	static boolean isEqualDices(Dice d[], int n) {

		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (isEqualDice(d[i], d[j])) {
					return true;
				}
			}
		}

		return false;
	}

	static boolean isEqualDice(Dice d1, Dice d2) {
		while (true) {
			if (d1.num[0] == d2.num[0]) {
				break;
			}
			if (d1.num[0] == d2.num[1]) {
				d2.rollNorth();
			} else if (d1.num[0] == d2.num[2]) {
				d2.rollWest();
			} else if (d1.num[0] == d2.num[3]) {
				d2.rollEast();
			} else if (d1.num[0] == d2.num[4]) {
				d2.rollSouth();
			} else if (d1.num[0] == d2.num[5]) {
				d2.rollSouth();
				d2.rollSouth();
			} else {
				return false;
			}
		}

		while (true) {
			if (d1.num[1] == d2.num[1]) {
				break;
			}
			if (d1.num[1] == d2.num[2]) {
				d2.rollLeft();
			} else if (d1.num[1] == d2.num[3]) {
				d2.rollRight();
			} else if (d1.num[1] == d2.num[4]) {
				d2.rollRight();
				d2.rollRight();
			} else {
				return false;
			}
		}

		if (d1.num[2] == d2.num[2] && d1.num[3] == d2.num[3] && d1.num[4] == d2.num[4] && d1.num[5] == d2.num[5]) {
			return true;
		} else {
			return false;
		}
	}
}

class Dice {
	int num[];
	int temp;

	public Dice(int num[]) {
		this.num = num;
	}

	void printDice() {

		for (int i = 0; i < 6; i++) {
			System.out.print(num[i] + " ");
		}
		System.out.println();
	}

	void printDiceSide(int upSide, int frontSide) {
		while (true) {
			if (upSide == num[0] && frontSide == num[1]) {
				break;
			}

			if (upSide == num[1]) {
				rollSouth();
			} else if (upSide == num[2]) {
				rollEast();
			} else if (upSide == num[3]) {
				rollWest();
			} else if (upSide == num[4]) {
				rollNorth();
			} else if (upSide == num[5]) {
				rollSouth();
				rollSouth();
			}
			if (frontSide == num[2]) {
				rollRight();
			} else if (frontSide == num[3]) {
				rollLeft();
			} else if (frontSide == num[4]) {
				rollRight();
				rollRight();
			}
		}
		System.out.println(num[2]);
	}

	void rollWest() {
		temp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = temp;
	}

	void rollNorth() {
		temp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = temp;
	}

	void rollEast() {
		temp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = temp;
	}

	void rollSouth() {
		temp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = temp;
	}

	void rollRight() {
		temp = num[1];
		num[1] = num[3];
		num[3] = num[4];
		num[4] = num[2];
		num[2] = temp;
	}

	void rollLeft() {
		temp = num[1];
		num[1] = num[2];
		num[2] = num[4];
		num[4] = num[3];
		num[3] = temp;
	}
}

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

int main()
{
    long long N, x;
    long long a[100000] = {0};

    cin >> N >> x;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    long long ans = 0LL;
    for (int i = 1; i < N; i++)
    {
        long long sum = a[i - 1] + a[i];
        if (sum > x)
        {
            if (a[i - 1] <= x)
            {
                a[i] -= sum - x;
                ans += sum - x;
            }
            else
            {
                ans += a[i];
                sum -= a[i];
                a[i] = 0;
                a[i - 1] -= sum - x;
                ans += sum - x;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

clock_t time_p = clock();

void rtime() {
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float) 1000 * (time_p) / CLOCKS_PER_SEC << "\n";
}

#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF=1e15;
const int MOD=1e9+7;
const int N=2e5+10;

void solve() {
    int n,m;
    cin>>n>>m;
    vector<int> h(n+1);
    for(int i=1;i<=n;i++) cin>>h[i];
    set<int> adj[n+1];
    for(int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        adj[u].insert(h[v]);
        adj[v].insert(h[u]);
    }
    int ans=0;
    for(int i=1;i<=n;i++) {
        if(adj[i].size()==0) {
            ans++;
            continue;
        }
        int g=*adj[i].rbegin();
        if(g<h[i]) {
            ans++;
//            cout<<i<<"\n";
        }
    }
    cout<<ans<<"\n";
}

signed main() {
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    IOS;
    int t = 1;
//    cin >> t;
    for(int i=1;i<=t;i++) {
//        cout<<"Case #"<<tc<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 18040
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

vector<vector<ll>> c;

void mk_c(){
    c.resize(3100);
    for(int i=0;i<2100;i++){
        c[i].resize(3100);
        c[i][0]=1;
        c[i][i]=1;
        for(int t=1;t<i;t++){
            c[i][t]=(c[i-1][t-1]+c[i-1][t])%MOD;
        }
    }
}

int main(){
    ll d,n;
    cin>>d>>n;
    ll ans=1;
    while(d--){
        ans*=100;
    }
    ll count=0;
    for(int i=1;i<10000;i++){
        if(i%100!=0){count++;}
        if(count==n){ans*=i; break;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush
N = int(input())
idx = {}
A = []
ans = 0
for i in range(N):
  a = int(input())
  idx[a] = i%2
  heappush(A,a)

for i in range(N):
  x = heappop(A)
  if idx[x] != i%2:
    ans += 1
print(ans//2)

Measured memory_bytes: 15844
#include <cstdio>
#include <cmath>
#include <iostream>
#include <complex>
#include <vector>
using namespace std;

typedef complex<double> point;
double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}

typedef vector<point> polygon;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
double convex_diameter(const polygon &pt) {
	const int n = pt.size();
	int is = 0, js = 0;
	for (int i = 1; i < n; ++i) {
		if (imag(pt[i]) > imag(pt[is])) is = i;
		if (imag(pt[i]) < imag(pt[js])) js = i;
	}
	double maxd = norm(pt[is]-pt[js]);

	int i, maxi, j, maxj;
	i = maxi = is;
	j = maxj = js;
	do {
		if (cross(diff(pt,i), diff(pt,j)) >= 0) j = (j+1) % n;
		else i = (i+1) % n;
		if (norm(pt[i]-pt[j]) > maxd) {
			maxd = norm(pt[i]-pt[j]);
			maxi = i; maxj = j;
		}
	} while (i != is || j != js);
	return maxd; /* farthest pair is (maxi, maxj). */
}

int main() {
	int n;
	while (cin >> n) {
		polygon pol(n);
		for (auto& p : pol) {
			double x, y;
			cin >> x >> y;
			p = point(x, y);
		}
		printf("%.10lf\n", sqrt(convex_diameter(pol)));
	}
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

ll N, L, T;
ll X[100005], W[100005];
vll xp, xn;
ll ans[100005] = {};
int main() {
    cin >> N >> L >> T;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> W[i];
        for (int j = 0; j < 5; j++) {
            (W[i] == 1 ? xp : xn).push_back(X[i] + j * L);
        }
    }
    sort(begin(xp), end(xp));
    sort(begin(xn), end(xn));

    for (int i = 0; i < N; i++) {
        ll t = T * 2 % L;
        if (W[i] == 1) {
            ll num = lower_bound(begin(xn), end(xn), X[i] + t) - lower_bound(begin(xn), end(xn), X[i]);
            num += (T * 2 / L) * (xn.size() / 5);
            ans[(i + num) % N] = (X[i] + T) % L;
        } else {
            ll num = --upper_bound(begin(xp), end(xp), X[i] + L) - --upper_bound(begin(xp), end(xp), X[i] + L - t);
            num += (T * 2 / L) * (xp.size() / 5);
            ans[(i + N - num % N) % N] = (X[i] + L - T % L) % L;
        } 
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] << el;
    }
    return (0);
}

Measured memory_bytes: 7628
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N; cin >> N;
	vector<long long> H(N);
	for (int i = 0; i < N; i++)cin >> H[i];
	bool ans = 1;
	H[0]--;
	for (int i = 1; i < N; i++) {
		if (H[i - 1] < H[i])H[i]--;
		if (H[i - 1] > H[i]) { ans = 0; break; }
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}





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

using ll = long long;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    map<int, ll> mp;
    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    ll cnt = 0;
    for(auto p : mp) {
        cnt += p.second;
        if(cnt >= K) {
            cout << p.first << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int H,W; cin>>H>>W;
    vector<string> a(H);
    REP(i,H) cin>>a[i];
    
    REP(i,W+2) cout<<'#'; cout<<endl;
    REP(i,H){ 
        cout<<'#'<<a[i]<<'#'<<endl;
    }
    REP(i,W+2) cout<<'#'; cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <vector>
using namespace std;


class Point{
public:
  int x, y;
};

int cnt;
Point data[100][100];
bool visited[100][100];
bool loop[100][100];


void rec(int x, int y, int sx, int sy) {
  if(loop[y][x]) return;
  if(visited[y][x]) {
    if(x == sx && y == sy) {
      cnt++;
      loop[y][x] = true;
    }
    return;
  }
  visited[y][x] = true;
  rec(data[y][x].x, data[y][x].y, sx, sy);
}

int main() {
  while(1) {
    int N;
    cin >> N;
    if(N == 0) break;
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
	cin >> data[i][j].x >> data[i][j].y;
      }
    }

    cnt = 0;

    fill(&loop[0][0], &loop[N-1][N-1]+1, false);
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
	fill(&visited[0][0], &visited[N-1][N-1]+1, false);
	rec(j, i, j, i);
      }
    }

    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 960
#include <algorithm>
#include <iostream>
using namespace std;
main() {
    int time=0, ma=-1;
    for(int i=1; i<=5; ++i) {
        int dish; cin>>dish;
        int wait= (dish+9) /10*10;
        time+= wait;
        ma = max(ma, wait-dish);
    }
    cout<< time-ma <<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  static int N = 0;
  static int[][] edge;
  static int ans = 0;
  static int[] permutation = new int[8];
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    edge = new int[N][N];
    int M = sc.nextInt();
    for(int i = 0; i < M; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      edge[a][b] = 1;
      edge[b][a] = 1;
    }
    dfs(1, 1);
    System.out.println(ans);
  }

  public static void dfs(int pos, int mask) {
    if(pos == N) {
      int count = 0;
      for(int i = 0; i < N - 1; i++) {
        if(edge[permutation[i]][permutation[i + 1]] == 0) count++;
      }
      if(count == 0) ans++;
    } else {
      for(int i = 0; i < N; i++) {
        if((mask & (1 << i)) == 0) {
          permutation[pos] = i;
          dfs(pos + 1, mask ^ (1 << i));
        } 
      }
    }
  }
}

Measured memory_bytes: 22100
#!/usr/bin/env python3
import numpy as np
n = int(input())
f = [list(map(int, input().split())) for _ in [0]*n]
p = [list(map(int, input().split())) for _ in [0]*n]

m = -float("INF")
from itertools import*
for j in product([0, 1], repeat=10):
    if sum(j) == 0:
        continue
    t = 0
    for i, k in enumerate(f):
        t += p[i][sum(np.array(j) & np.array(k))]
    m = max(t, m)
print(m)

Measured memory_bytes: 21624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            String[] values = line.split(" ");
            int a = Integer.parseInt(values[0]);
            int b = Integer.parseInt(values[1]);
            int n = Integer.parseInt(values[2]);
            int q = Math.abs(b);
            int p = Math.abs(a) % q;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                p *= 10;
                int f = p / q;
                if (f == 0) {
                    continue;
                }
                sum += f;
                p %= q;
            }
            out.println(sum);
        }
    }
}

Measured memory_bytes: 9716
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(){

  int N;
  cin >> N;

  while (true){
    if (N <= 0){
      cout << abs(N) << endl;
      return 0;
   }
   N -= 1000;
  }


  return 0;
}

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

ll a;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin>> a;
    cout << a + a*a + a*a*a << '\n';

    return 0;
}

Measured memory_bytes: 3596
#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
string S;

int main() {
    cin >> N >> S;
    int R = 0, B = 0;

    rep(i, N) {
        if (S[i] == 'R') {
            R++;
        }
        else {
            B++;
        }
    }

    write(R > B ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;
#define s second
#define f first

int main()
{	
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output1.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {	int a,b;
    	cin>>a>>b;
    	cout<<a*b<<endl;
 
    }
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}
bool check(string s,char c){
  bool flag = true;
  for (int i(0);i<int(s.size());i++){
    if (s[i] != c){
      flag = false;
    }
  }
  return flag;
}

int main(){
  string s;
  cin>>s;
  int N = int(s.size());
  int cnt[30] = {0};
  rep(i,N){
    cnt[s[i]-'a']++;
  }
  int ans(1e9);
  for(int i(0);i<30;i++){
    if (cnt[i] != 0){
      char c = (char)('a' + i);
      string t = s;
      int cnti(0);
      // cout << c << endl;
      while(!check(t,c)){
        string ti(int(t.size()-1),'.');
        for (int j(0);j<int(t.size())-1;j++){
          if (t[j] == c || t[j+1] == c){
            ti[j] = c;
          }else{
            ti[j] = t[j];
          }
        }
        cnti++;
        t = ti;
      }
      ans = min(ans,cnti);
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
n_a_b = list(map(int, input().split()))

n = n_a_b[0]
a = n_a_b[1]
b = n_a_b[2]

division = n // (a+b)
remainder = n % (a+b)

answer = division * a

if remainder <= a:
  answer += remainder
else:
  answer += a

print(answer)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;

typedef vector<int> vi;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;                   
const int MAXN = 300500; 

void solve() {     
    ll n;
    cin >> n;
    cout << ((n * n + n) / 2) - n;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include<cstdio>
#include <cstring>
#include <algorithm>
#define ll long long int
using namespace std;

ll arr[100030];
ll dp[100030];
ll n,k;

ll call(int i)
{
    int ans1[109];
    if(i == n-1)
        return 0;
    if(dp[i] != -1)
            return dp[i];
    else if(i < n-k)
    {
        for(int p = 0;p<k;p++)
        {
            ans1[p] = abs(arr[i]-arr[i+p+1]) + call(i+p+1);
        }
        sort(ans1,ans1+k);
        dp[i] = ans1[0];
        return dp[i];
    }
    else if(i >= n-k)
    {
        for(int p = 0;p<n-i-1;p++)
        {
            ans1[p] = abs(arr[i]-arr[i+p+1]) + call(i+p+1);
        }
        sort(ans1,ans1+(n-i-1));
        dp[i] = ans1[0];
        return dp[i];
    }

}

int main()
{

    cin>>n;
    cin>>k;
    if(k>=n)
        k=n-1;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<call(0);
}


Measured memory_bytes: 50176
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a1 = sc.nextInt(); int a2 = sc.nextInt(); int a3 = sc.nextInt();
    int c12 = Math.abs(a1-a2);
    int c23 = Math.abs(a2-a3);
    int c31 = Math.abs(a3-a1);
    System.out.println(c12+c23+c31-Math.max(Math.max(c12, c23), c31));
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SONI ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn=5e5+15;
const int maxm=5000+15;
const int mod=1e9+9;
const int inf=0x3f3f3f3f;
const int MOD=1000000007;

int main()
{
    SONI;
    int n,W;cin>>n>>W;
    int value[n],weight[n];
    for(int i=0;i<n;i++)
    cin>>weight[i]>>value[i];
    
    ll k[n+1][W+1];
    
    for(int i=0;i<=n;i++)
    {
        for(int w=0;w<=W;w++)
        {
            if(i==0||w==0)
            k[i][w]=0;
            else if(weight[i-1]<=w)
            k[i][w] = max(value[i-1]+k[i-1][w-weight[i-1]],k[i-1][w]);
            else
            k[i][w]=k[i-1][w];
        }
    }
    
    cout<<k[n][W];
    return 0;
}

Measured memory_bytes: 79232
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
using namespace std;
int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (c == -1 || d == -1) {
		if (a < b) cout << "Alice" << endl;
		else if (a > b) cout << "Bob" << endl;
		else cout << "Draw" << endl;
	}
	else {
		if (c > d) cout << "Alice" << endl;
		else if (c < d) cout << "Bob" << endl;
		else cout << "Draw" << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
N, K = map(int,input().split())
A = [int(i) for i in input().split()]
a = 0
b = 0
mod = 10**9+7
for i in range(N) :
    for j in range(N) :
        if A[i]>A[j] :
            if i < j :
                a += 1
            else :
                b += 1
ans = ( a * ((K+1)*K) // 2 %mod + b * (K*(K-1)) // 2 %mod ) %mod
print(ans)

Measured memory_bytes: 9284
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {		
		InputStreamReader reader = new InputStreamReader(System.in);
		int key,i,a[];
		a=new int[100];
		key='.';
		key=reader.read();
		while(true){
			i=0;
			a[i]=0;
			if(key=='.')
				break;
			while(true){
				if(key=='['||key=='('){
					i++;
					a[i]=key;
				}
				else if(key==']'){
					if(a[i]!='['){
						while(key!='.'){
							key=reader.read();
						}
						System.out.println("no");
						break;
					}
					i--;
				}
				else if(key==')'){
					if(a[i]!='('){
						while(key!='.'){
							key=reader.read();
						}
						System.out.println("no");
						break;
					}
					i--;
				}
				key=reader.read();
				if(key=='.'){
					if(i==0){
						System.out.println("yes");
						break;
					}
					else{
						System.out.println("no");
						break;
					}
				}
			}
			while(key!='\n'){
				key=reader.read();
			}
			key=reader.read();
		} 
	} 
}

Measured memory_bytes: 11000
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
using namespace std;

typedef struct vec vec;

struct vec {
    double x, y;
};


static double cross(vec a, vec b){  //外積
    return a.x * b.y - a.y * b.x;
}

int main(void){
    double x[21], y[21];
    int i, n = 0;
    double sum = 0;
    while(scanf("%lf,%lf", &x[n], &y[n]) != EOF)   n++;
    x[n] = x[0];
    y[n] = y[0];
    for(i = 0; i < n; i++){
        vec a = {x[i], y[i]};
        vec b = {x[i + 1], y[i + 1]};
        sum += cross(a,b);    
    }

    cout << fixed << setprecision(6) <<fabs(sum) / 2.0 << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define var auto
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    int a, b; char c;
    cin>>a>>c>>b;
    if(c=='-')cout<<a-b;
    else cout<<a+b;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define N 200010
struct aa{int l,r;
}a[N];
int n,m,i,ans,now;
inline int read()
{
	char ch=getchar();
	int x=0,f=1;
	while (ch<'0'||ch>'9')
		{
			if (ch=='-') f=-1;
			ch=getchar();
		}
	while (ch<='9'&&ch>='0')
		{
			x=x*10+ch-'0';
			ch=getchar();
		}
	return x*f;
}
inline void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>=10) write(x/10);
	putchar(x%10+'0');
}
inline bool cmp(aa a,aa b)
{
	if (a.l==b.l) return a.r>b.r;
	return a.l<b.l;
}
struct heap{
	struct bb{
		int val;
	}a[N];
	int cnt;
	inline bool check(int x,int y)
	{
		return a[x].val<a[y].val;
	}
	inline void up(int x)
	{
		int k=x/2;
		while (k)
		{
			if (check(x,k)) swap(a[x],a[k]);
			else return;
			x=k;
			k=x/2;
		}
	}
	inline void down(int x)
	{
		int k=x*2;
		while (k<=cnt)
		{
			if (k+1<=cnt&&check(k+1,k)) k++;
			if (check(k,x)) swap(a[x],a[k]);
			else return;
			x=k;
			k=x*2; 
		}
	}
	inline void pop()
	{
		swap(a[1],a[cnt]);
		cnt--;
		down(1);
	}
	inline void insert(int y)
	{
		cnt++;
		a[cnt].val=y;
		up(cnt);
	}
}Heap;
int main()
{
	n=read();
	m=read();
	for (i=1;i<=n;i++)
		{
			a[i].l=read();
			a[i].r=read();
		}
	sort(a+1,a+n+1,cmp);
	for (now=1;now<=n;now++) if (a[now].l) break;
	now--;
	for (i=1;i<=now;i++) Heap.insert(a[1].r);
	for (i=1;i<=m;i++)
		{
			while (now<n&&a[now+1].l<i) now++,Heap.insert(a[now].r);
			if (now<n)
				{
					now++;
					ans++;
					if (ans==n) break;
					continue;
				}
			if (Heap.cnt&&Heap.a[1].val<=i)
				{
					Heap.pop();
					ans++;
					if (ans==n) break;
					continue;
				}
		}
	write(n-ans);
}

Measured memory_bytes: 2560
# Acceptance of input

import sys

file_input = sys.stdin

V, E = map(int, file_input.readline().split())

adj_mat = [[0] * V for i in range(V)]

for line in file_input:
    u, v, c = map(int, line.split())
    adj_mat[u][v] = c

# Ford???Fulkerson algorithm

import collections

# BFS for residual capacity network
def bfs(start, goal, parent):
    flow = [0] * V
    queue = collections.deque()
    queue.append(start)
    flow[start] = 10000
    while queue:
        u = queue.popleft()
        for v, r_capacity in enumerate(adj_mat[u]):
            if not flow[v] and (r_capacity > 0):
                queue.append(v)
                flow[v] = min(flow[u], r_capacity)
                parent[v] = u
                if v == goal:
                    return flow[goal]

def ford_fulkerson(source, sink):
    max_flow = 0
    while True:
        parent = [None] * V
        aug_path_flow = bfs(source, sink, parent)
        if aug_path_flow:
            max_flow += aug_path_flow
            v = sink
            while (v != source):
                u = parent[v]
                adj_mat[u][v] -= aug_path_flow
                adj_mat[v][u] += aug_path_flow
                v = u
        else:
            break
    return max_flow

# output
print(ford_fulkerson(0, V - 1))

Measured memory_bytes: 8172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2,v=0; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder();
      for (int[] i : graph) {
        for (int v : i) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25408
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char
import Control.Monad

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine :: IO (VU.Vector Int)
    ys <- VUM.replicate n 0 :: IO (VUM.IOVector Int) 
    forM_ [0..n-1] $ \i -> do
        let n = xs VU.! i
        VUM.write ys (n-1) (i+1) 
    forM_ [0..n-1] $ \i -> do
        VUM.read ys i >>= \r -> putStr $ show r
        putStr " "
    putStrLn ""

Measured memory_bytes: 4348
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int n, q;
vector<char> t(200010);
vector<char> d(200010);
string s;


int main() {
	cin >> n >> q >> s;
	for (int i = 0; i < q; i++)
	{
		cin >> t[i] >> d[i];
	}
	int beg = -1;
	int end = n;
	//呪文配列を後ろから操作
	for (int i = q-1; i >=0; i--)
	{
		if (beg>=-1&&t[i] == s[beg+1] && d[i] == 'L') {
			beg++;
		}
		if (beg>=0&&t[i] == s[beg] && d[i] == 'R') {
			beg--;
		}
		if (beg == n - 1) {
			break;
		}
	}
	for (int i = q - 1; i >= 0; i--)
	{
		if (end<=n&&t[i] == s[end-1] && d[i] == 'R') {
			end--;
		}
		if (end<=n-1&&t[i] == s[end] && d[i] == 'L') {
			end++;
		}
		if (end == 0) {
			break;
		}
	}
	int ans = 0;
	if (beg>=end)
	{
		ans = 0;
	}else {
		ans = end - beg - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
class Dice(object):
    def __init__(self, numbers: list):
        self.numbers = dict(zip(("T", "S", "E", "W", "N", "B"), numbers))

    def _roll(self, old_part: tuple):
        new_part = old_part[1:] + (old_part[0],)
        new_numbers = [self.numbers[face] for face in new_part]

        for old, new in zip(old_part, new_numbers):
            self.numbers[old] = new

    def vroll(self, reverse=False):
        """北方向に回転"""
        old_part = ("N", "T", "S", "B")
        self._roll(old_part if not reverse else old_part[::-1])

    def hroll(self, reverse=False):
        """時計回りに回転"""
        old_part = ("N", "W", "S", "E")
        self._roll(old_part if not reverse else old_part[::-1])

    def roll_to(self, direction: str):

        if direction == "N":
            self.vroll()
        elif direction == "S":
            self.vroll(reverse=True)
        elif direction == "E":
            self.hroll(reverse=True)
            self.vroll()
            self.hroll()
        elif direction == "W":
            self.hroll()
            self.vroll()
            self.hroll(reverse=True)
        else:
            raise AssertionError


dice = Dice(list(map(int, input().split())))
for direction in input():
    dice.roll_to(direction)
print(dice.numbers["T"])



Measured memory_bytes: 5616
/**
 *   author: sahushivam
 *   created: 22 December 2019 (Sunday)  17:33:32
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
	int n; cin>>n;
	string s,t;
	cin>>s>>t;
	string ans="";
	for(int i=0;i<n;i++)
	{
		ans+=s[i];
		ans+=t[i];
	}
	cout<<ans;
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);

    int a=0,b=0;
    string s;
    cin>>s;
    int n = s.size();
    for(int i=0;i<n;i++) {
        if(i&1){
            if(s[i]-'0') a++;
            else b++;
        }
        else {
            if(s[i]-'0') b++;
            else a++;
        }
    }

    int ans = min(a,b);
    cout<<ans<<endl;;

    return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
S = list(input())
count = 0
for i in range(N):
    if S[i] == "L":
        if i == 0:
            count += 1
        else:
            if S[i-1] == "R":
                count += 1
    else:
        if i == N-1:
            count += 1
        else:
            if S[i+1] == "L":
                count += 1

if (count-1) / 2 <= K:
    print(N-1)

else:
    print(N - (count - 2*K))


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int N;
int A[MAXN];
int cnt[MAXN];
void Solve() {
	read(N);
	for(int i = 1 ; i <= N ; ++i) read(A[i]);
	for(int i = 1 ; i <= N ; ++i) {
		if(A[i]) cnt[A[i] - 1]++;
		cnt[A[i]]++;
		cnt[A[i] + 1]++;
	}
	int res = 0;
	for(int i = 0 ; i <= 100001 ; ++i) res = max(cnt[i],res);
	out(res);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;++i)
template<class T, class U>inline bool chmax(T &a, U const &b) { if(a<b){ a=b;return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, U const &b) { if(b<a){ a=b;return 1; } return 0; }
const int inf = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a[i]; }

  long long ans = 0;
  int neg = 0, min = inf;
  rep(i, n) {
    if (a[i] < 0) {
      ++neg;
      a[i] *= -1;
    }
    ans += a[i];
    chmin(min, a[i]);
  }

  if (neg % 2) {
    cout << ans - min * 2 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

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

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

int H, W;
string a[110];

int main() {
  cin >> H >> W;
  rep(i, 0, H) { cin >> a[i]; }

  rep(i, 0, W + 2) { cout << "#"; }
  cout << endl;
  rep(i, 0, H) {
    cout << "#";
    rep(j, 0, W) { cout << a[i][j]; }
    cout << "#\n";
  }
  rep(i, 0, W + 2) { cout << "#"; }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		int j=i,s=0;
		while (j) s++,j/=10;
		if (s&1) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
#define MAX_N 55
ll C[MAX_N][MAX_N];
void make() {
  rep(i, MAX_N) {
    C[i][1] = i;
    C[i][i] = 1;
    C[0][i] = 1;
    C[i][0] = 1;
  }
  REP(i, 1, MAX_N) rep(j, i) {
    if(i-1 < 0 || j-1 < 0) continue;
    C[i][j] = C[i-1][j] + C[i-1][j-1];
  }
}
ll comb(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return C[n][r];
}
int main() {
  make();
  int N, P;
  cin >> N >> P;
  vector<int> A(N);
  vector<int> cnt(2);
  rep(i, N) {
    cin >> A[i];
    cnt[A[i]%2]++;
  }
  ll odd = 0, even = 0;
  for(int i=P; i<=cnt[1]; i+=2) odd += comb(cnt[1], i);
  rep(i, cnt[0]+1) even += comb(cnt[0], i);
  cout << odd * even << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = [0]
tmp = 0
for a in A:
    tmp += a
    B.append(tmp)

l = 1
r = 3
cut = []
for i in range(2,N-1):
    Lm = float("inf")
    Rm = float("inf")
    c = [0,i,0]
    for j in range(l,i):
        tmp = abs(B[i]-2*B[j])
        if tmp > Lm:
            c[0] = j-1
            l = j-1
            break
        Lm = tmp
    else:
        c[0] = i-1
        l = i-1
    for k in range(r,N):
        tmp = abs((B[N]-B[k])-(B[k]-B[i]))
        if tmp > Rm:
            c[2] = k-1
            r = k-1
            break
        Rm = tmp
    else:
        c[2] = N-1
        r = N
    cut.append(c)
#print(cut)
ans = float("inf")
for p,q,r in cut:
    P = B[p]
    Q = B[q]-B[p]
    R = B[r]-B[q]
    S = B[N]-B[r]
    ans = min(ans,max(P,Q,R,S)-min(P,Q,R,S))
print(ans)


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

int main() {
	int s;
	cin >> s;
	int h = s / 3600;
	s = s - h * 3600;
	int m = s / 60;
	s = s - m * 60;
	cout << h << ":" << m << ":"<< s << endl;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin>>k;
  int a=7%k;
  for(int i=1;i<=k;i++){
    if(a==0){
      cout<<i<<endl;
      return 0;
    }
    a=(a*10+7)%k;
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        g[i].emplace_back(a - 1);
    }
    queue<int> que;
    vector<int> d(n, INF);
    d[0] = 0;
    que.push(0);
    while(que.size()) {
        int now = que.front();
        que.pop();
        for(auto nxt : g[now]) {
            if(d[nxt] > d[now] + 1) {
                d[nxt] = d[now] + 1;
                que.push(nxt);
            }
        }
    }
    cout << (d[1] >= INF ? -1 : d[1]) << "\n";
}

Measured memory_bytes: 9008
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int five = 0;
		int seven = 0;
		if (A == 5) {
		    five++;    
		} else if (A == 7) {
		    seven++;
		}
		if (B == 5) {
		    five++;    
		} else if (B == 7) {
		    seven++;
		}
		if (C == 5) {
		    five++;    
		} else if (C == 7) {
		    seven++;
		}
        if (five == 2 && seven == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int i = 1;
		while(k*i <= b) {
			if(k*i >= a && k*i <=b) {
				System.out.println("OK");
				System.exit(0);
			}
			i++;
		}
		System.out.println("NG");
		sc.close();
	}
}


Measured memory_bytes: 27212
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

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


int main() {
  int K, X;
  cin >> K >> X;
  FOR(i,X-K+1,X+K) cout << i << ' ';
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = list(map(int,input().split()))
c = 0
x = []
k = [0]*a
for i in range(a-1,-1,-1):
    souwa = 0
    for j in range(i,a,i+1):
        souwa += k[j]
    if not souwa%2 == b[i]:
        k[i] = 1
        c += 1
        x.append(i+1)
print(c)
if len(x) > 0:
    for o in range(len(x)):
        print(x[o],' ',end="")

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

typedef struct Node
{
    int value;
    Node *parent, *left, *right;
} Node;

Node *root, *NIL;

Node * Find(Node *u, int k)
{
    while (u != NIL && k != u->value) {
        if (k < u->value) u = u->left;
        else u = u->right;
    }
    return u;
}
void Insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->value = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->value < x->value) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->value < y->value) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}
void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    cout << " " << u->value;
    inorder(u->right);
}
void preorder(Node *u)
{
    if (u == NIL) return;
    cout << " " << u->value;
    preorder(u->left);
    preorder(u->right);
}

int main(void)
{
    int n, i, x;
    string com;

    cin >> n;

    for (i = 0; i < n; ++i) {
        cin >> com;
        if (com[0] == 'f') {
            cin >> x;
            Node *t = Find(root, x);
            if (t != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        } else if (com == "insert") {
            cin >> x;
            Insert(x);
        } else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 21832
#include <iostream>

using namespace std;

int main()
{
    int d = 0;
    int c[26];
    int s[365][26];
    int t[365];
    int last[26] = {0};
    int score = 0;

    cin >> d;

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

    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < d; i++)
    {
        cout << (i % 26 + 1) << endl;
    }

}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
class dice{
public:
  int d[6];
  void rotate(char a){
    if(a=='N'){
      int top=d[0];
      d[0]=d[1];
      d[1]=d[5];
      d[5]=d[4];
      d[4]=top;
    }
    else if(a=='S'){
      int top=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=top;
    }
    else if(a=='E'){
      int top=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=top;
    }
    else if(a=='W'){
      int top=d[0];
      d[0]=d[2];
      d[2]=d[5];
      d[5]=d[3];
      d[3]=top;
    }
    else if(a=='R'){
      rotate('N');
      rotate('E');
      rotate('S');
    }
    else if(a=='L'){
      rotate('N');
      rotate('W');
      rotate('S');
    }
    return;
  }
  void rotate2(int t,int f){
    int i;
    for(i=0;i<6;i++) if(d[i]==t) break;
      if(i==1) rotate('N');
      else if(i==2) rotate('W');
      else if(i==3) rotate('E');
      else if(i==4) rotate('S');
      else if(i==5) rotate('S'),rotate('S');

      for(i=1;i<5;i++) if(d[i]==f) break;
      if(i==2) rotate('L');
      else if(i==3) rotate('R');
      else if(i==4) rotate('R'),rotate('R');

      return;
  }
};
int main(){
  dice d[2];
  bool b=false;
  for(int i=0;i<6;i++){
    cin>>d[0].d[i];
  }
  for(int i=0;i<6;i++){
    cin>>d[1].d[i];
  }
  for(int j=0;j<4;j++){
    for(int k=0;k<4;k++){
      d[0].rotate('L');
      if(d[0].d[0]==d[1].d[0] && d[0].d[1]==d[1].d[1] && d[0].d[2]==d[1].d[2] && d[0].d[3]==d[1].d[3] && d[0].d[4]==d[1].d[4] && d[0].d[5]==d[1].d[5]) b=true;
    }
    d[0].rotate('N');
  }
  for(int j=0;j<4;j++){
    for(int k=0;k<4;k++){
      d[0].rotate('L');
      if(d[0].d[0]==d[1].d[0] && d[0].d[1]==d[1].d[1] && d[0].d[2]==d[1].d[2] && d[0].d[3]==d[1].d[3] && d[0].d[4]==d[1].d[4] && d[0].d[5]==d[1].d[5]) b=true;
    }
    d[0].rotate('E');
  }
  if(b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    int n = 0;
    for (int i = 0; i < s.size(); ++i) {
        n += (s[i] - '0');
    }
    cout << (n % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3732