akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
using namespace std;

double dis(int r1,int r2,int g1,int g2,int b1,int b2){
  return sqrt( (r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2) );
}

int main(){
  string color,ans;
  int r,g,b;
  double dmin,tmp;

  while(1){
    cin >> color;
    if(color=="0")break;

    r = 0;
    if(color[1]-'0' < 10)r += 16*(color[1]-'0');
    else r += 16 * (color[1]-'a'+10);
    if(color[2]-'0' < 10)r += color[2]-'0';
    else r += color[2]-'a'+10;
    g = 0;
    if(color[3]-'0' < 10)g += 16*(color[3]-'0');
    else g += 16 * (color[3]-'a'+10);
    if(color[4]-'0' < 10)g += color[4]-'0';
    else g += color[4]-'a'+10;
    b = 0;
    if(color[5]-'0' < 10)b += 16*(color[5]-'0');
    else b += 16 * (color[5]-'a'+10);
    if(color[6]-'0' < 10)b += color[6]-'0';
    else b += color[6]-'a'+10;

    dmin = 510;
    tmp = dis(r,0,g,0,b,0);
    if(tmp < dmin){
      dmin = tmp;
      ans = "black";
    }
    tmp = dis(r,0,g,0,b,255);
    if(tmp < dmin){
      dmin = tmp;
      ans = "blue";
    }
    tmp = dis(r,0,g,255,b,0);
    if(tmp < dmin){
      dmin = tmp;
      ans = "lime";
    }
    tmp = dis(r,0,g,255,b,255);
    if(tmp < dmin){
      dmin = tmp;
      ans = "aqua";
    }
    tmp = dis(r,255,g,0,b,0);
    if(tmp < dmin){
      dmin = tmp;
      ans = "red";
    }
    tmp = dis(r,255,g,0,b,255);
    if(tmp < dmin){
      dmin = tmp;
      ans = "fuchsia";
    }
    tmp = dis(r,255,g,255,b,0);
    if(tmp < dmin){
      dmin = tmp;
      ans = "yellow";
    }
    tmp = dis(r,255,g,255,b,255);
    if(tmp < dmin){
      dmin = tmp;
      ans = "white";
    }

    cout << ans << endl;
  }
}

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

#define ll long long
#define ar array

const int mxN=2e5, M=1e9+7;
int n, s[mxN];
vector<int> adj[mxN];
ll iv[mxN], f1[mxN], f2[mxN], dp[mxN], ans[mxN];

void dfs1(int u=0, int p=-1) {
	dp[u]=1;
	for(int v : adj[u]) {
		if(v==p)
			continue;
		dfs1(v, u);
		dp[u]=dp[u]*dp[v]%M*f1[s[u]+s[v]]%M*f2[s[u]]%M*f2[s[v]]%M;
		s[u]+=s[v];
	}
	++s[u];
}

ll mI(ll a, ll m) {
	return (a%=m)<2?a:(1-mI(m%a, a)*m)/a+m;
}

void dfs2(int u=0, int p=-1, ll pd=1) {
	ans[u]=dp[u]*pd%M*f1[n-1]%M*f2[s[u]-1]%M*f2[n-s[u]]%M;
	for(int v : adj[u]) {
		if(v==p)
			continue;
		dfs2(v, u, ans[u]*mI(dp[v], M)%M*f2[n-1]%M*f1[n-1-s[v]]%M*f1[s[v]]%M);
	}
}

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

	cin >> n;
	iv[1]=1;
	for(int i=2; i<n; ++i)
		iv[i]=M-M/i*iv[M%i]%M;
	f1[0]=f2[0]=1;
	for(int i=1; i<n; ++i) {
		f1[i]=f1[i-1]*i%M;
		f2[i]=f2[i-1]*iv[i]%M;
	}
	for(int i=1, u, v; i<n; ++i) {
		cin >> u >> v, --u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs1();
	dfs2();
	for(int i=0; i<n; ++i)
		cout << ans[i] << "\n";
}

Measured memory_bytes: 22516
W, H, N = gets.split.map(&:to_i)
x0, x1, y0, y1 = 0, W, 0, H
N.times do
  x, y, a = gets.split.map(&:to_i)
  case a
  when 1
    x0 = x if x0 < x
  when 2
    x1 = x if x1 > x
  when 3
    y0 = y if y0 < y
  when 4
    y1 = y if y1 > y
  end
end

w = [x1-x0, 0].max
h = [y1-y0, 0].max

puts w*h

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll G = A[0];
    rep(i,N)G = gcd(G, A[i]);
    vector<int> cnt(1010101, 0);
    bool ok = true;
    rep(i,N){
        auto v = factorize(A[i]);
        for(auto p: v){
            cnt[p.first]++;
            if(cnt[p.first] >= 2){
                // // cout << ((G == 1) ? "setwise coprime" : "not coprime") << endl;
                // return 0;
                ok = false;
            }
        }
    }

    if(ok)cout << "pairwise coprime" << endl;
    else if(G == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}


Measured memory_bytes: 15064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int gcd(int a, int b)
{
    int r, tmp;

    /* 自然数 a > b を確認・入替 */
    if (a < b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

signed main()
{
    int N;
    vi A;
    cin >> N;
    A.resize(N);
    REP(i, N)
    cin >> A[i];
    // sort(ALL(A));
    vi F, B;
    F.resize(N);
    B.resize(N);
    REP(i, N)
    {
        if (i == 0)
        {
            F[i] = A[i];
            B[N - 1 - i] = A[N - 1 - i];
        }
        else
        {
            F[i] = gcd(F[i - 1], A[i]);
            B[N - 1 - i] = gcd(B[N - 1 - i + 1], A[N - 1 - i]);
        }
    }

    int ans = 0;
    int tmp;
    REP(i, N)
    {
        if (i == 0)
            tmp = B[1];
        else if (i == N - 1)
            tmp = F[N - 2];
        else
            tmp = gcd(F[i - 1], B[i + 1]);
        chmax(ans, tmp);
    }

    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 2560
n = int(input())
k = int(input())
x = list(map(int, input().split()))


# Bが回収
# Bが回収した場合の距離
b = []
for i in range(n):
    b.append(abs(k - x[i])*2)


# Aが回収
# Aが回収した場合の距離
a = []
for i in range(n):
    a.append(x[i]*2)

# aとbの少ない値を足していく→最小距離
min_len = 0
for i in range(n):
    min_len += min(a[i], b[i])

print(min_len)


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

int main() {
    int N, a, b, c, d;
  cin >> N ;
  a=N/1000 ;
  b=(N-1000*a)/100 ;
  c=(N-1000*a-100*b)/10 ;
  d=N-1000*a-100*b-10*c ;
    if (a==b&&b==c) {
    cout << "Yes" << endl;
  }
   else if (b==c&&c==d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;

long long search_mc(long long n) {
	for (int i = sqrt(n)+1; i > 0; --i) {
		if (n%i == 0) {
			return (i+(n/i)-2);
		}
	}
	return (1 << 28);
}

int main(void) {
	long long N;
	cin >> N;
	cout << search_mc(N) << endl;
	return 0;
}


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

typedef long long ll;

const int INF = 0x3f3f3f3f;
const int ms = 51;

int a[ms], b[ms];
int can[ms][ms];
int dp[ms][ms];

int main() {
	memset(dp, 0x3f, sizeof dp);
	for(int i = 0; i < ms; i++) {
		dp[i][0] = 1;
		dp[i][i] = 0;
		for(int j = 0; j < i; j++) {
			for(int k = 1; k <= i; k++) {
				dp[i][j] = std::min(dp[i][j], std::max(k, dp[i % k][j]));
			}
		}
	}
	int n;
	std::cin >> n;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
		can[i][a[i]] = true;
	}
	int mx = 0;
	for(int i = 0; i < n; i++) {
		std::cin >> b[i];
		mx = std::max(mx, dp[a[i]][b[i]]);
	}
	if(mx >= INF) {
		std::cout << "-1\n";
		return 0;
	}
	while(mx > 0) {
		ans += 1LL << mx;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < ms; j++) {
				if(can[i][j]) {
					can[i][j % mx] = true;
				}
			}
		}
		mx = 0;
		for(int i = 0; i < n; i++) {
			int cur = INF;
			for(int j = 0; j < ms; j++) {
				if(can[i][j]) {
					cur = std::min(cur, dp[j][b[i]]);
				}
			}
			mx = std::max(mx, cur);
		}
	}
	std::cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;


int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    ll diff = 0;
    vector<ll> A(N, 0);
    vector<ll> B(N, 0);
    vector<ll> C(N, 0);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];

    ll sum_A = accumulate(A.begin(),A.end(),0);
    ll sum_B = accumulate(B.begin(),B.end(),0);



    for(int i = 0; i < N; i++){
        if(A[i] < B[i]){
            diff += B[i] - A[i];
            ans++;
        }
        else{
            C[i] = A[i] - B[i];
        }
    }
    
    sort(C.begin(),C.end(),greater<ll>());
    
    if(diff > 0){

        for(int i = 0; i < N; i++){
            diff -= C[i];
            ans++;
            if(diff <= 0) break;
        }

        if(diff > 0){
            cout << -1 << endl;
            return 0;
        }

    }

    cout << ans << endl;

}


Measured memory_bytes: 5616
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;

const int INF = 100000000;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void bfs(int W, int H, vector<string>& A, vector<vector<int>>& d) {
  queue<P> que;

  rep(y, H) rep(x, W) {
    if (A[y][x] == '#') {
      que.push(P(x, y));
      d[y][x] = 0;
    }
  }

  while (que.size()) {
    P p = que.front(); que.pop();
    rep(i, 4) {
      int nx = p.first + dx[i], ny = p.second + dy[i];

      if (0 <= nx && nx < W && 0 <= ny && ny < H &&
          A[ny][nx] != '#' && d[ny][nx] == INF) {
        que.push(P(nx, ny));
        d[ny][nx] = d[p.second][p.first] + 1;
      }
    }
  }
}


int main(void) {
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  rep(i, H) cin >> A[i];
  
  vector<vector<int>> d(H, vector<int>(W, INF));
  bfs(W, H, A, d);

  int ans = 0;
  rep(i, H) rep(j, W) ans = max(ans, d[i][j]);

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

Measured memory_bytes: 17116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, long long C, long long K, std::vector<long long> T)
{
    SORT(T);
    ll current = 0;
    ll ans = 0;
    ll limit = 0;
    for (int i = 0; i < N; i++)
    {
        if (current == 0)
        {
            limit = T[i] + K;
        }
        current++;

        if (limit < T[i])
        {
            ans++;
            current = 1;
            limit = T[i] + K;
            continue;
        }

        if (current == C)
        {
            ans++;
            current = 0;
        }
    }

    if (current != 0)
    {
        ans++;
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> T(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &T[i]);
    }
    solve(N, C, K, std::move(T));
    return 0;
}


Measured memory_bytes: 1024
N,C = map(int, input().split())
s =[0]*N
t =[0]*N
c =[0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int, input().split())

imos = [[0]*int(1e5+20) for _ in range(31)]
for i in range(N):
    imos[c[i]][s[i]]+=1
    imos[c[i]][t[i]+1]-=1

ans = 0
for i in range(1,int(1e5+10)):
    sm = 0
    for j in range(31):
        imos[j][i]=imos[j][i-1]+ imos[j][i]
        if imos[j][i] >= 1:
            sm+=1
    ans = max(ans,sm)
print(ans)

Measured memory_bytes: 38076
((stdin) => {
  const lines = stdin.trim().split('\n');
  let q = Number(lines.shift());
  const result = [];
  const arr = [];
  const args = lines.map((line) => line.split(' ').map(Number));
  for (const [ops, p] of args) {
    if (ops === 0) {
      arr.push(p);
    } else if (ops === 1) {
      result.push(arr[p]);
    } else {
      arr.pop();
    }
  }
  console.log(result.join('\n'));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main() {
    int n; cin >> n;
    vector<int> a(n);

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

    int sum = 0;
    for (int i = 0; i < n; i++) sum += a[i];

    int ans = 0;
    int num = abs(sum - n * a[0]);
    for (int i = 1; i < n; i++) {
        if (num > abs(sum - n * a[i])) {
            ans = i;
            num = abs(sum - n * a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
k = int(input())
 
qu = list(range(1,10))
 
if (k <= 9):
  print(k)
else:
  cnt = 9
  while( cnt < k ):
    out = qu.pop(0)
    r = out%10
    y = 10*out+r
    if( r != 0 ):
      qu.append(y-1)
      cnt += 1
      if( cnt == k ):
        out = y-1
        break
    qu.append(y)
    cnt += 1
    if( cnt == k ):
      out = y
      break

    
    if( r!=9):
      qu.append(y+1)
      cnt+=1
      if( cnt == k ):
        out = y+1
        break
      

  print(out)

Measured memory_bytes: 5904
Public Class Program
  Shared Sub Main()
    Dim n As Integer= Cin.Int()
    Dim ans As String = ":("
    Dim base As Double = n / 1.08
    If Math.Floor(Math.Ceiling(base) * 1.08) = n Then
      ans = Math.Ceiling(base).ToString()
    ElseIf Math.Floor(Math.Floor(base) * 1.08) = n Then
      ans = Math.Floor(base).ToString()
    End If
    Console.WriteLine(ans)
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 13140
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	string sent;
	
	//prevs: 個々の数  ans: answer
	int prevs = 0, ans = 0;
	while(cin >> sent)
	{

		for(int i = 0; i < sent.size(); i++)
		{	
			if(sent[i] >= '0' && sent[i] <= '9')
			{
				prevs *= 10;
				prevs += sent[i] - '0';
			}
			else
			{
				ans += prevs;
				prevs = 0;
			}
		}
		ans += prevs;
		prevs = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long GCD(long long a,long long b){
if(b==0)return a;
else return GCD(b,a%b);
}


signed main(){
  int N;
  cin >> N;
  int ans;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		if (i > 0) ans = GCD(ans, a);
		else ans = a;
	}
	cout << ans << endl;
}


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

int n, m;
vvi G;

vi dp;

int dfs(int i) {
    if(dp[i] != -1) {
        return dp[i];
    }
    if(G[i].empty()) {
        dp[i] = 0;
        return 0;
    }

    int ma = 0;
    for(int next:G[i]) {
        if(ma < dfs(next)) {
            ma = dp[next];
            
        }
    }
    return dp[i] = ma+1;
    
}


int main() {
    
    cin >> n >> m;
    G.resize(n);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        G[x-1].push_back(y-1);
    }

    dp.assign(n, -1);

    int ma = 0;
    rep(i, n) {
        if(ma < dfs(i)) {
            ma = dp[i];
        }
    }


    cout << ma << '\n';
}

Measured memory_bytes: 8192
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        
        boolean[] visited = new boolean[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            a[i]--;
        }

        int cnt = 0;
        int i = 0;
        while (!visited[i]) {
            // marking i as a visited place.
            visited[i] = true;

            // traversing dependency.
            i = a[i];
            cnt++;
            if (i == 1) {
                System.out.println(cnt);
                return;
            }
        }

        System.out.println(-1);
        return;
    }

}

Measured memory_bytes: 57968
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  vector<int> a(3);
  cin >> a[0];
  cin >>a[1];
  cin >> a[2];
  
  sort(a.begin(),a.end());
  
  if(a[0]==a[1]){
    cout << a[2] << endl;
  }else{
    cout << a[0] << endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
bool isPrime(int num){
    if(num<2) return false;
    else if(num==2)return true;
    else if(num%2==0)return false; // 偶数はあらかじめ除く

    double sqrtNum=sqrt(num);
    for(int i=3;i<=sqrtNum;i+=2){
        if(num%i==0)return false;
    }
    // 素数である
    return true;
}

int main(void){
    ll N=100010;
    bool f[N+1];f[0]=false;f[1]=false;FOR(i,2,N)f[i]=true;
    FOR(i,2,N+1){
        if(f[i])for(ll j=i+i;j<100000;j+=i)f[j]=false;
    }
    
    ll asum[N+1];asum[0]=0;
    REPS(i,N){
        asum[i]=asum[i-1];
        if(i%2==1&&f[i]&&f[(i+1)/2])asum[i]++;
    }
    //REPS(i,100)cout<<i<<":"<<asum[i]<<" ";



    ll Q;cin>>Q;
    vector<pair<ll,ll>> que;
    ll l,r;
    REP(i,Q){
        cin>>l>>r;
        que.push_back(make_pair(l,r));
    }
    REP(i,Q){
        ll L=que[i].first,R=que[i].second;
        cout<<asum[R]-asum[L-1]<<"\n";
    }
}

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//環境で固定された変数を宣言
#define IN 200000
#define INPUTSIZE IN+2

int main() {
	//変数宣言
	int i, j;
	char Sin[INPUTSIZE], Tin[INPUTSIZE];
	char c;
	
	//入力受付
	fgets(Sin, INPUTSIZE, stdin);
	fgets(Tin, INPUTSIZE, stdin);
	int size = strlen(Sin);

	//文字列交換
	for (i = 0; i < size; i++) {
		if (Sin[i] != Tin[i]) {
			c = Sin[i];
			for (j = 0; j < size; j++) {
				if (Sin[j] == c || Sin[j] == Tin[i]) {
					if (j < i) goto MyEndFlag;
					if (Sin[j] == c) Sin[j] = Tin[i];
					else if(Sin[j] == Tin[i]) Sin[j] = c;
					////代入後に判定
					//if (j <= i && Sin[j] != Tin[j])　goto MyEndFlag;
				}
			}
		}
	}
	//プログラムの終了
	MyEndFlag:
	printf(i == size ? "Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))

R = {}
for i in a:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

ans = ["Yes", "No"]
if 0 in R:
  if len(R) == 1:
    print(ans[0])
  elif len(R) == 2:
    for i in R.keys():
      if i != 0:
        x = R[i]
      else:
        z = R[i]
    if x == z * 2:
      print(ans[0])
    else:
      print(ans[1])
  else:
    print(ans[1])
else:
  if len(R) != 3:
    print(ans[1])
  else:
    t = -1
    for i in R.values():
      if t == -1:
        t = i
      else:
        if i != t:
          print(ans[1])
          break
    else:
      a = b = c = -1
      for i in R.keys():
        if a == -1:
          a = i
        elif b == -1:
          b = i
        else:
          c = i
      if a ^ b == c:
        print(ans[0])
      else:
        print(ans[1])

Measured memory_bytes: 60784
#include <cstdio>
int main()
{
	// freopen("CF17-QA-F.in", "r", stdin); 
	int n, cur = 0, ans = 0; 
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int x; 
		scanf("%d", &x); 
		int p = 0; 
		while (1 << p <= x)
			p++;
		p--;
		bool f = (1 << p) != x; 
		if (cur < p)
			ans += p - cur; 
		else if (cur != p)
			f = false; 
		cur = p; 
		if (f)
		{
			cur++; 
			ans++; 
		}
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define MAX 50
const int nil=-1;
struct node
{
	int parent;
	int left;
	int right;
};
struct node tree[MAX];
int depth[MAX];
int height[MAX];
int n;
void setdepth(int u,int p)
{
	if(u==nil)
		return;
	depth[u]=p;
	setdepth(tree[u].left,p+1);
	setdepth(tree[u].right,p+1);
	return;
}
int setheight(int u)
{
	int h1=0,h2=0;
	if(tree[u].left!=nil)
		h1=setheight(tree[u].left)+1;
	if(tree[u].right!=nil)
		h2=setheight(tree[u].right)+1;
	if(h1>h2)
		return height[u]=h1;
	return height[u]=h2;
}
int getsibling(int u)
{
	if(tree[u].parent==nil)
		return nil;
	if(tree[tree[u].parent].right!=u && tree[tree[u].parent].right!=nil)
		return tree[tree[u].parent].right;

	if(tree[tree[u].parent].left!=u && tree[tree[u].parent].left!=nil)
		return tree[tree[u].parent].left;
	return nil;
}
void input()
{
	int i,j,id,c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		tree[i].parent=nil;
		tree[i].left=nil;
		tree[i].right=nil;
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&id);
		for(j=1;j<=2;j++)
		{
			scanf("%d",&c);
			if(j==1)
				tree[id].left=c;
			else
				tree[id].right=c;
			tree[c].parent=id;
		}
	}
	return;
}
void output(int u)
{
	printf("node %d: ",u);
	printf("parent = %d, ",tree[u].parent);
	printf("sibling = %d, ",getsibling(u));
	int deg=0;
	if(tree[u].left!=nil)
		deg++;
	if(tree[u].right!=nil)
		deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",depth[u]);
	printf("height = %d, ",height[u]);
	if(tree[u].parent==nil)
		printf("root\n");
	else
		if(tree[u].left==nil && tree[u].right==nil)
			printf("leaf\n");
		else
			printf("internal node\n");
	
	return;
}
int main()
{
	input();
	int i,root;
	for(i=0;i<n;i++)
		if(tree[i].parent==nil)
			root=i;

	setdepth(root,0);
	setheight(root);
	for(i=0;i<n;i++)
		output(i);
	return 0;
}


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

#define mod 1000000007

int cnt=0;

vector< vector<int> > adj;
vector<int> dp;


int n,m;
int res=0;

int longestPath(int v){
    if(dp[v]!=-1)
        return dp[v];
    
    if(adj[v].size()==0)
        return dp[v]=0;
    
    else{
        int maxi=0;
        for(auto c: adj[v]){
            maxi = max(maxi, longestPath(c));;
        }
        dp[v]= 1+maxi;
        return dp[v];
    }
}
int32_t main() {
	// your code goes here
	cin>>n>>m;
	int a,b;
	adj = vector< vector<int> > (n+1);
	dp = vector<int> (n+1,-1);
	for(int i=0; i<m; i++){
	  cin>>a>>b;
	  adj[a].push_back(b);
	}
	
	for(int i=1; i<=n; i++){
	        res = max(res, longestPath(i));
	}
	cout<<res;
	
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[2200][2200];
const int mod = 1000000007;
int sum[2200][2200];
signed main(){
    int n,m;cin >> n >> m;
    vector<int> s(n),t(m);
    rep(i,n)cin >> s[i];
    rep(i,m)cin >> t[i];
    rep(i,n)rep(j,m){
        if(s[i] == t[j]){
            dp[i][j] = 1;
            if(i-1>= 0 && j-1>=0)dp[i][j] += (sum[i-1][j-1])%mod;
        }
        else {
            dp[i][j] = 0;
        }
        sum[i][j] = dp[i][j];
        if(i-1>=0)sum[i][j] += sum[i-1][j];
        if(j-1>=0)sum[i][j] += sum[i][j-1];
        if(i-1>=0 && j-1>= 0)sum[i][j] -= sum[i-1][j-1];
        sum[i][j] = (sum[i][j]%mod+mod)%mod;
        
    }
    cout << (sum[n-1][m-1]+1)%mod  << endl;
    
    
    return 0;
}

Measured memory_bytes: 72316
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N; cin>>N;
    vector<ll>v(N);
    map<ll,ll>odd;
    map<ll,ll>even;
    rep(i,N){
        cin>>v[i];
        if(i%2==0){
            odd[v[i]]++;
        }
        else even[v[i]]++;
    }
    vector<vector<ll>>od(N,vector<ll>(2));
    vector<vector<ll>>ev(N,vector<ll>(2));
    int i=0;
    for(auto o:odd){
        od[i][0]=o.second;
        od[i][1]=o.first;
        i++;
    }
    i=0;
    for(auto e:even){
        ev[i][0]=e.second;
        ev[i][1]=e.first;
        i++;
    }
    sort(od.begin(),od.end());
    reverse(od.begin(),od.end());
     sort(ev.begin(),ev.end());
    reverse(ev.begin(),ev.end());
    if(od[0][1]!=ev[0][1]){
        cout<<N/2-od[0][0]+N/2-ev[0][0]<<endl;
    }
    else {
        cout<<min(N/2-od[0][0]+N/2-ev[1][0],N/2-od[1][0]+N/2-ev[0][0])<<endl;
    }
}


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

#define ll long long
#define endl '\n'

using namespace std;

int main() {
    ll n, i;
    cin >> n;
    vector<ll> v(n);
    vector<ll> sub(n);

    ios::sync_with_stdio(false);

    for(i = 1; i < n; i++) {
        cin >> v[i];
        sub[v[i] - 1] += 1;
    }

    for(i = 0; i < n; i++) {
        cout << sub[i] << endl;
    }

    return 0;
}


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

int main(){
  int N, D;
  cin >> N >> D;
  
  if(N % (D*2+1) == 0){
    cout << N / (D*2 + 1) << endl;
  }
  else{
    cout << N / (D*2 + 1) + 1 << endl;
  }
}

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

int a[1000002];

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


	a[1] = 7 % K;
	for (int i = 2; i <= K; i++) {
		a[i] = (a[i-1]*10+7) % K;
	}
	for (int i = 1; i <= K; i++) {
		if (a[i] == 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


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

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

	bool isNG = false;
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 == 0)
			{

			}
			else if (a[i] % 5 == 0)
			{
				
			}
			else
			{
				isNG = true;
				break;
			}
		}
	}

	if (isNG) { cout << "DENIED" << endl; }
	else { cout << "APPROVED" << endl; }

	return 0;
}


Measured memory_bytes: 256
pr = [True] * 50001
for i in range(2,225):
    if pr[i]:
        for j in range(i * 2, 50001, i):
            pr[j] = False

def gold_count(n):
    res = 0
    if pr[n - 2]:
        res += 1
    for i in range(3, n // 2 + 1, 2):
        if pr[i] and pr[n - i]:
            res += 1
    return res

while True:
    n = int(input())
    if n == 0:
        break
    print(gold_count(n))

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


ll bmod(ll n,ll m,ll mod)
{

    ll res = 1;

    while(m>0)
    {

        if(m%2==1)
            res=(res*n)%mod;

        m/=2;
        n=(n*n)%mod;
    }


    return res;


}


#define mx 3000000
#define md 1000000007ll

ll fac[3000002];


ll bigr(ll n)
{

    return bmod(n,md-2,md);

}
ll re(ll n,ll m)
{


    return  ((fac[n+m]*bigr(fac[n]))%md*bigr(fac[m]))%md;

}
int main()
{




    //cout<<bmod(2,3,7)<<endl;
    ll n,m;
    cin>>n>>m;

    fac[1] =1;
    fac[0] =1;


    for(int i=2; i<=mx; i++)
    {

        fac[i]=(fac[i-1]*i)%md;
    }

    //n--;m--;

    ll res=0;
    for(int i=0; i<=n; i++)
    {
        ll x= i;
        ll y= i*2;

        ll x1= (n-x);
        ll y1= (m-y);

        if(x1==y1*2)
        {


            //  cout<<i<<endl;
            res+=re(i,y1);
            //  cout<<re(i,y1)<<endl;
            if(res>=md)
                res-=md;
        }
    }

    cout<<res<<endl;



    return 0;
}


Measured memory_bytes: 23808
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int[] A = new int[7];
		for(int i = 0; i < 6; i++)
			A[i] = input.nextInt();
		String S = input.next();
		for( int i = 0; i < S.length(); i++)
		{
			dice(S.charAt(i), A);
		}	
			
		System.out.println(A[0]);
	}

	private static void dice(char roll, int a[])
	{
		int t;
		if( roll == 'E')
		{
			t = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = t;
		}
		else if( roll == 'W')
		{
			t = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = t;
		}
		else if(roll == 'N')
		{
			t = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = a[4];
			a[4] = t;
		}
		else if(roll == 'S')
		{
			t = a[0];
			a[0] = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = t;
		}
	}
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int k, x;
    cin >> k >> x;
    for(int i = x-k+1; i < x+k; i++){
        cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>


using namespace std;


int main(){
    long long a,b,c,N,sum;
    cin >> N;
    a=(N-N%3)/3;
    b=(N-N%5)/5;
    c=(N-N%15)/15;
    sum=(N*(N+1)/2)-3*(a*(a+1)/2)-5*(b*(b+1)/2)+15*(c*(c+1)/2);
    cout << sum << endl;
    //float ;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
		  #define endl "\n"
		  #define ll long long int
		  #define mod 1000000007
		  #define inf 1000000000000000001;
		  using namespace std;
		  int main()
		  {
		    //  #ifndef ONLINE_JUDGE
		    //  // for getting input from input.txt
		    //  freopen("input.txt", "r", stdin);
		    //  // for writing output to output.txt
		    //  freopen("output.txt", "w", stdout);
		    // #endif
		    std::ios::sync_with_stdio(false);
		    cin.tie(NULL);
			ll a,b;
			cin>>a>>b;
			if(a>0 && b>0){ cout<<"Positive"; }
			else if(a <= 0 && b >= 0){ cout<<"Zero"; }
			else if(a >= 0 && b <= 0){ cout<<"Zero"; }
			else{
				if(abs(a-b)%2 != 0){
					cout<<"Positive";
				}
				else{
					cout<<"Negative";
				}
			}
		    return 0;
		  }
	

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    
    int n; cin >> n;
    vector<int> a(100000, 0), b(100000, 0);
    vector<int> mp;
    ll minas_sum = 0;
    int ans = 0;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++){
        int tmp = a[i] - b[i];
        mp.push_back(tmp);
        if(tmp < 0){
            ans++;
            minas_sum += tmp;
        }
    }
    sort(mp.begin(), mp.end());

    for(int i=n-1; i>=0; i--){
        if(minas_sum>=0){
                break;
        }
        if(mp[i] > 0){
            minas_sum += mp[i];
            ans++;
        }else if(mp[i]<=0){
            break;
        }
    }
    if(minas_sum < 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4684
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define lld long long int 
#define vll vector<long long int>
#define vs vector<string> 
#define vint vector<int> 
#define vp vector<pair<int,int>>
#define vpll vector<pair<long long int , long long int>>
//#define tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
#define forl(i,a,b) for(int i = a ; i <= b ; i++)
#define forln(i,a,b) for(int i = a; i < b ; i++)
lld mod = 1e9 + 7;
#define ps push_back
#define B begin
#define E end
#define mk make_pair
#define F first 
#define S second 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
#define sv()                  int t; scanf("%d",&t); while(t--)



lld power(lld x, lld y) 
{ lld temp; if( y == 0) return 1; temp = power((x%mod), (y%mod)/2); if (y%2 == 0) return ((temp%mod)*(temp%mod))%mod;else return (((x%mod)*(temp%mod))%mod*(temp%mod))%mod;} 

using namespace std;

void solution( void );

int main()
{
	solution();
	return 0;
}

void solution()
{
	lld s,w;
	cin>>s>>w;
	if(s > w)cout<<"safe"; else cout<<"unsafe";
}



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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	ll a;
	in a;
	out a + a * a + a * a * a en;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;



public class Main{


	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		//SHDC?????????????????????????????????
		int[] cardS=new int[13];
		int[] cardH=new int[13];
		int[] cardD=new int[13];
		int[] cardC=new int[13];
		Arrays.fill(cardS, 0);
		Arrays.fill(cardH, 0);
		Arrays.fill(cardD, 0);
		Arrays.fill(cardC, 0);

		try{
		int n=Integer.parseInt(reader.readLine());//n?????????

		for(int i=0;i<n;i++){
			String text=reader.readLine();
			String[] str=text.split(" ");
			int x=Integer.parseInt(str[1]);

			switch(str[0]){//???????????????????????????????????¨????????????1?????£??\???

			case"S":
				cardS[x-1]=1;
				break;
			case"H":
				cardH[x-1]=1;
				break;
			case"D":
				cardD[x-1]=1;
				break;
			case"C":
				cardC[x-1]=1;
				break;
			}
		}

		for(int i=0;i<13;i++){
			if(cardS[i]==0){
				System.out.println("S "+(i+1));
			}
		}
		for(int i=0;i<13;i++){
			if(cardH[i]==0){
				System.out.println("H "+(i+1));
			}
		}
		for(int i=0;i<13;i++){
			if(cardC[i]==0){
				System.out.println("C "+(i+1));
			}
		}
		for(int i=0;i<13;i++){
			if(cardD[i]==0){
				System.out.println("D "+(i+1));
			}
		}


		reader.close();

		}catch(IOException e){
			System.out.println("??¨??????"+e);
		}


	}

}

Measured memory_bytes: 24328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll FLAG = LLONG_MIN;

const int MAX = 3000;

ll a[MAX];
ll dp[MAX + 1][MAX + 1][2];

ll calc(int l, int r, bool f = true) {
	if (dp[l][r][f] != FLAG) return dp[l][r][f];
	if (r - l == 0) return dp[l][r][f] = 0;
	if (f) return dp[l][r][f] = max(calc(l, r - 1, false) + a[r - 1], calc(l + 1, r, false) + a[l]);
	return dp[l][r][f] = min(calc(l, r - 1, true) - a[r - 1], calc(l + 1, r, true) - a[l]);
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= N; i++) {
		for (int j = i; j <= N; j++) {
			dp[i][j][0] = FLAG;
			dp[i][j][1] = FLAG;
		}
	}
	cout << calc(0, N) << endl;
	return 0;
}


Measured memory_bytes: 139776
#include <cstdio>

int n, A[50];

int solve(int i, int m)
{
	if (m == 0)
		return 1;
	if (i >= n)
		return 0;

	return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main()
{
	int q, M;

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &M);
		if (solve(0, M))
			printf("yes\n");
		else
			printf("no\n");
	}
}

Measured memory_bytes: 2688
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int A1,A2,A3;
	cin>>A1>>A2>>A3;
	cout << (A1+A2+A3>=22 ? "bust":"win")<<endl;

	return 0;
}


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

int main(){
    int a,b,C;
    double rad,s,h,l;
    cin >> a >> b >> C;
    
    rad = (acos(-1.0)*C)/ 180.0;
    s = a*b*sin(rad)/2.0;
    l = a + b + sqrt(a*a+b*b-2*a*b*cos(rad));
    h = b * sin(rad);
    
    printf("%lf\n%lf\n%lf\n",s,l,h);
    return 0;
    
    
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(void){
    int n, m, k; cin >> n >> m >> k;
    int M = (1 << m) - 1;

    vi d2l(n);
    rep(i, n) d2l[i] = m;
    rep(i, m){
        int v; cin >> v;
        v--;

        d2l[v] = i;
    }

    vvi edge_r2r(m, vi(k));
    rep(i, n){
        rep(j, k){
            int v; cin >> v;
            v = d2l[v - 1];
            int u = d2l[i];

            if(u < m) edge_r2r[u][j] = v;
        }
    }

    vvi edge(1 << m);
    rep(i, 1 << m){
        rep(j, k){
            int next = 0;
            rep(l, m){
                if(!((i >> l) & 1)) continue;
                int v = edge_r2r[l][j];
                if(v < m) next |= (1 << v);
            }
            if(i != next){
                edge[i].push_back(next);
            }
        }
    }

    vi used(1 << m);
    
    // (cost, v)
    queue<pair<int, int>> q;
    q.push(make_pair(0, M));

#define F first
#define S second

    int res = -1;
    while(q.size()){
        int cur_c = q.front().F;
        int cur_v = q.front().S;
        q.pop();

        if(used[cur_v]) continue;
        used[cur_v] = true;

        if(cur_v == 0){
            res = cur_c;
            break;
        }

        for(auto && e : edge[cur_v]){
            int next_c = cur_c + 1;
            int next_v = e;

            if(used[next_v]) continue;

            q.push(make_pair(next_c, next_v));
        }
    }

    cout << res << endl;

	return 0;
}

Measured memory_bytes: 49488
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int ans = c - (a - b);
            if (ans < 0) ans = 0;

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long A,B;
   cin>>A>>B;
   if((A+B)%2==0)
   {
       cout<<(A+B)/2<<endl;

   }
   else
   {
       cout<<"IMPOSSIBLE"<<endl;
   }
   return 0;


}

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

int main(void){
  int r,d,x;
  scanf("%d%d%d",&r,&d,&x);
  for(int i = 2001;i < 2011;i++){
    x = r*x - d;
    printf("%d\n",x);
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char sound;
    scanf("%c", &sound);

    if (sound == 'a' || sound == 'i' || sound == 'u' || sound == 'e' || sound == 'o') printf("vowel\n");
    else printf("consonant\n");

    return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, r = 0, a = 0, b = 0, x = 0;cin >> n;
	for (int i = 0; i < n; i++) {
		string s;cin >> s;
		for (int i = 1; i < s.size(); i++)
			if (s[i - 1] == 'A'&&s[i] == 'B')r++;
		if (s[0] == 'B') b++;
		if (s.back() == 'A') a++;
		if (s[0] == 'B' && s.back() == 'A') x++;
	}
	if (a&&a == x && b == x) r--;
	cout << r + min(a, b) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,i;
  long long count=0;
  scanf("%d",&N);
  int A[N+1],B[N];
  for(i=0;i<N+1;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    scanf("%d",&B[i]);
  }
  for(i=0;i<N;i++){
  if((A[i]+A[i+1])<=B[i]){
      count += A[i]+A[i+1];
      A[i+1] = 0;
    }else{
      count += B[i];
      if(A[i]<B[i]){
        A[i+1] = A[i+1] - (B[i]-A[i]);
      }
  }
  
  /* for(i=0;i<N;i++){
    if(A[i] >= B[i]){
      count = count + B[i];
    }else{
      if(A[i+1] >= B[i] - A[i]){
        A[i+1] = A[i+1] - (B[i] - A[i]);
        count = count + B[i];
      }else{
        count = count + A[i] + A[i+1];
        A[i+1] = 0;
      }
    } */
  }
  printf("%lld",count);
}
        

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int gcd(int x,int y)
{
	if(y==0)
		return x;
	else
		return gcd(y,x%y);
}

int main()
{
	int a,b,c;
	int ans=0;
	
	cin>>a>>b>>c;
	int g = gcd(a,b);
	if(c%g==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine(ReadString().Replace(",", " "));
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13140
import std.math;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.container;
import std.algorithm;

void main()
{
    int n, k;
    readf("%d %d\n", &n, &k);
    auto a = readln.splitter.map!(to!int).array;
    int ans = int.max;
    foreach (i; 0..n-k+1) {
        ans = min(ans, 
            abs(a[i]) + a[i + k - 1] - a[i],
            abs(a[i + k - 1]) + a[i + k - 1] - a[i]);
    }
    writeln(ans);
}


Measured memory_bytes: 3764
import java.util.*;
import java.lang.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if ((x == 3) || (x == 5) || (x == 7)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 22612