akhauriyash/Code-Regression huggingface dataset:
/**
 *      purpose : KEYENCE Programming Contest 2019 A
 *      author  : kyomukyomupurin
 *      created : 2019-01-13 21:00:12
**/

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a[4];
    rep(i, 4) cin >> a[i];
    sort(a, a + 4);
    if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) print("YES");
    else print("NO");
    
    
    return 0;
}


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

using namespace std;

const int MAXN = 1e5;

int v[MAXN + 2];

int main() {
    //ifstream cin(".in");
    //ofstream cout(".out");
    int n, ans = 0, num;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> num;
      if (num == i)
        v[i] = 1;
    }
    for (int i = 1; i <= n; ++i)
      if (v[i]) {
        if (v[i + 1])
          v[i + 1] = 0;
        ++ans;
        v[i] = 0;
      }
    cout << ans;
    return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	
	char c;
	cin>>c;
	
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
		cout<<"vowel"<<endl;
	else
		cout<<"consonant"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int a,b;
    cin >> a >> b;
    int ans;
    if(12<a)ans=b;
    else if(5<a&&a<=12)ans=b/2;
    else ans=0;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll r = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'R') r++;
    }
    ll ans = 0;
    for(int i = 0; i < r; i++) {
        if(S[i] != 'R') ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3772
import bisect

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = [0] * N
B[-1] = A[-1]
for i in range(N - 2, -1, -1):
    B[i] = B[i+1]+A[i]


def C(mid):
    tmp = 0
    for a in A:
        pos = bisect.bisect_right(A, mid - a)
        tmp += N-pos
    return tmp > M


lb = 0
rb = 10**6
while rb - lb > 1:
    happy = (lb + rb) // 2
    if C(happy):
        lb = happy
    else:
        rb = happy

ans = 0
cnt = 0
for a in A:
    pos = bisect.bisect_right(A, rb - a)
    if pos == N:
        continue
    ans += B[pos]+(N-pos)*a
    cnt += N - pos
ans += (M-cnt)*rb
print(ans)


Measured memory_bytes: 14268
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
int a[MAXN],b[MAXN];
int main()
{
	int n,m,cnt=0;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2) cnt++;
	}
	if(cnt>2)
	{
		printf("Impossible\n");
		return 0;
	}
	bool f=1;
	for(int i=0;i<m;i++)
		if(a[i]%2)
		{
			if(f) swap(a[i],a[0]),f=0;
			else swap(a[i],a[m-1]);
		}
	if(m==1)
	{
		if(a[0]==1) printf("1\n1\n1\n");
		else printf("%d\n2\n%d 1\n",a[0],a[0]-1);
		return 0;
	}
	b[0]=a[0]+1;
	for(int i=1;i<m-1;i++)
		b[i]=a[i];
	f=1;
	for(int i=0;i<m;i++)
	{
		if(f) printf("%d",a[i]),f=0;
		else printf(" %d",a[i]);
	}
	if(a[m-1]==1) m--;
	else b[m-1]=a[m-1]-1;
	printf("\n%d\n%d",m,b[0]);
	for(int i=1;i<m;i++)
		printf(" %d",b[i]);
	printf("\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(){
    int ans,N,res;
    cin>>N;

    res=N;
    for(int i=0;i<=N;i++){
        int t=i;
        int cc=0;

        //6で割る部分の計算
        while(t>0){
            cc+=t%6;
            t/=6;
        }
        //9で割る部分の計算
        t=N-i;
        while(t>0){
            cc+=t%9;
            t/=9;
        }
        if(res>cc){
            res=cc;
        }
    }

    //int k=37;
    //ans= k/=6;
    //cout<< ans <<endl;
    cout<<res<<endl;
}

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

int main() {
    int A,B,M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    for (int i = 0; i < A; ++i) {
        cin >> a.at(i);
    }
    for (int i = 0; i < B; ++i) {
        cin >> b.at(i);
    }
    vector<vector<int>> m(M, vector<int>(3));
    for (int i = 0; i < M; ++i) {
        cin >> m.at(i).at(0) >>m.at(i).at(1) >> m.at(i).at(2);
    }
    /////
    int mina=10000000, minb=10000000;
    for (int i = 0; i < A; ++i) {
        if(mina > a.at(i)){
            mina = a.at(i);
        }
    }
    for (int i = 0; i < B; ++i) {
        if(minb > b.at(i)){
            minb = b.at(i);
        }
    }
    int minsum = mina + minb;

    for (int i = 0; i < M; ++i) {
        if(a.at(m.at(i).at(0) -1) + b.at(m.at(i).at(1) -1) -m.at(i).at(2) < minsum){
            minsum = a.at(m.at(i).at(0) -1) + b.at(m.at(i).at(1) -1) -m.at(i).at(2);
        }
    }

    cout << minsum << endl;

}

Measured memory_bytes: 6528
x, n = map(int, input().split())
p = list(map(int, input().split()))
s, t = x, x

def check(l, m):
    flag = True
    for i in l:
        if i == m:
            flag = False
            break
    return flag

if check(p, s):
    print(s)
    exit()
if check(p, t):
    print(t)
    exit()

while True:
    s = s - 1
    t = t + 1
    # print(s, t)
    if check(p, s):
        print(s)
        exit()
    if check(p, t):
        print(t)
        exit()
    


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

enum State {
  Opened,
  Closed
};

int main(int argc, char const* argv[])
{
  int N;
  std::cin >> N;
  std::vector<std::string> members(N);
  for (int i = 0; i < N; ++i)
    std::cin >> members[i];
  int M;
  std::cin >> M;
  State st = Closed;
  for (int i = 0; i < M; ++i) {
    std::string s;
    std::cin >> s;
    if (std::find(members.begin(), members.end(), s) == members.end()) {
      std::cout << "Unknown " << s << std::endl;
    } else {
      if (st == Closed) {
        std::cout << "Opened by " << s << std::endl;
        st = Opened;
      } else {
        std::cout << "Closed by " << s << std::endl;
        st = Closed;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
main()
{
    long long int a,b,sum=0,i,j;
    while(scanf("%lld%lld",&a,&b)==2)
    {
        sum=a+b;
        j=0;
        while(sum!=0)
        {
            sum/=10;
            j++;
        }
        printf("%lld\n",j);
    }
    return 0;
}

Measured memory_bytes: 600
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
void solve()
{
    ll n;
    ll a,b;
    cin>>n;
    cin>>a>>b;
    ll tot=n/(a+b);
    ll rem=n%(a+b);
    ll ans=tot*a;
    ans+=min(rem,a);
    pr(ans);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int Z=0;
  string S,T;
  cin>>S>>T;
  vector<int> p(26,-1);
  vector<int> q(26,-1);
  int N=S.size();
  for(int i=0;i<N;i++){
    int a=S[i]-'a';
    int b=T[i]-'a';
    if(p[a]==-1&&q[b]==-1){
      p[a]=b;
      q[b]=a;
    }
    else if(p[a]!=b){
      Z=1;
    }
  }

  if(Z==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3916
#include<stdio.h>
int main(){
  int a, b, c, i;
  int tmp = 0;
  scanf("%d %d %d", &a, &b, &c);
  for(i = 0 ; i < 100; i++){
    tmp = tmp + a;
    if(tmp % b == c){
      break;
    }
  } 
  if(tmp % b == c){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {

  ll N, X; cin >> N >> X;
  vector<ll> L(N);
  FOR(i, N) cin >> L[i];

  ll d = 0;
  ll ans = 1;
  while (d <= X) {
    d = d + L[ans-1];
    if (d <= X)
      ans += 1;
    else break;
  }

  cout << min(ans, N+1) << endl;

  return 0;
}


Measured memory_bytes: 256
X, K, d = map(int, input().split())
X=abs(X)
if d>=X and K%2==0:
    ans=X
elif d>=X and K%2==1:
    ans=d-X
elif d<X and K*d<X:
    ans=X-K*d
else:
    ans=X%d
    if (X-ans)%2!=K%2:
        ans=d-ans
print(ans)

Measured memory_bytes: 9124
// while (clock()<=69*CLOCKS_PER_SEC)
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

int main()
{
	_upgrade
  LL n, a, b;
  cin>>n>>a>>b;
  LL res = n * 2 + 10;
  if((a % 2 ) == b % 2)
    res = min(res, abs(a - b) / 2);
  else
    res = min((n - a + n - b + 1) / 2, (a - 1 + b - 1 + 1) / 2);
  cout<<res;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>=k;i--)
bool qq(long long a){
    if(a<2) return false;
    for(long long i=2;i*i<=a;i++){
        if(a%i==0){
            return false;
        }
    }
    return true;
}
int main(){
    long long n;
    cin>>n;
    while(!qq(n)){
        n++;
    }
    cout<<n<<endl;
    return 0;
}


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

int N; vector<int> A;

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

int main() {
	cin >> N;
	A.resize(N); for (int i = 0; i < N; i++)cin >> A[i];
	int ans = gcd(A[0],A[1]);
	for (int i = 2; i < N; i++) {
		ans = gcd(ans, A[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_V 1000
#define MAX_E 2000
using namespace std;

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

struct edge { int from, to, cost; };

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    edge es[MAX_E];
    
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        es[i] = edge{s, t, d};
    }
    
    int d[MAX_V];
    fill(d, d + MAX_V, INF);
    d[r] = 0;
    
    bool negative = false;
    
    for (int i = 0;; ++i) {
        if (i >= V) {
            negative = true;
            break;
        }
        bool updated = false;
        for (int i = 0; i < E; ++i) {
            edge e = es[i];
            if (d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
                updated = true;
            }
        }
        if (!updated) break;
    }
    
    if (negative)
        cout << "NEGATIVE CYCLE" << endl;
    else {
        for (int i = 0; i < V; ++i) {
            if (d[i] == INF)
                cout << "INF" << endl;
            else
                cout << d[i] << endl;
        }
    }
    
    return 0;
}



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

using namespace std;

int main() {
	int Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;

	H = min(2*Q, H);
	S = min(2*H, S);

	if (2*S <= D) {
		cout << ((long long)N)*S;
	} else {
		cout << ((long long)(N/2))*D + ((N%2) ? S : 0);
	}
}

Measured memory_bytes: 256
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float('inf')

for i in range(2**10):
    bag = []
    for j in range(10):
        if (i>>j)&1:
            bag += [j]

    tmp = 0
    is_cnt = False
    for n in range(N):
        f = F[n]
        cnt = 0
        for b in bag:
            if f[b] == 1:
                cnt += 1
        tmp += P[n][cnt]
        if cnt:
            is_cnt = True
    
    if is_cnt:
        ans = max(ans, tmp)

print(ans)

    

        





Measured memory_bytes: 74284
/*
 * Problem Description: Rooted Trees
 * Category: Trees
 * Author: Khan
 * Date: 21th October, 2017
 */

#include <iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node
{
    int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u)
{
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = "<< D[u] << ", ";

    if(T[u].p == NIL)
        cout << "root, ";
    else if(T[u].l == NIL)
        cout << "leaf, ";
    else
        cout << "internal node, ";

    cout << "[";
    for (int i = 0, c = T[u].l; c != NIL; ++i, c = T[c].r)
    {
        if(i)
            cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p)
{
    D[u] = p;
    if(T[u].r != NIL)
        rec(T[u].r, p);
    if(T[u].l != NIL)
        rec(T[u].l, p + 1);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int i, j, d, v, c, l, r;
    cin >> n;
    for (int i = 0; i < n; ++i)
        T[i].p = T[i].l = T[i].r = NIL;
    for (int i = 0; i < n; ++i)
    {
        cin >> v >> d;
        for (int j = 0; j < d; ++j)
        {
            cin >> c;
            if(j == 0)
                T[v].l = c;
            else
                T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (int i = 0; i < n; ++i)
        if(T[i].p == NIL)
            r = i;
    rec(r, 0);
    for (int i = 0; i < n; ++i)
        print(i);
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  map<char, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s[0]]++;
  }
  string a = "MARCH";
  int ans = 0;
  rep(i, 5) {
    reps(j, i+1, 5) {
      reps(k, j+1, 5) {
	ans += mp[a[i]]*mp[a[j]]*mp[a[k]];
      }
    }
  }
  cout << ans << endl;


  return 0;
}


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


int main(){
    int D;

    cin>>D;
    if(D==25){
        cout<<"Christmas"<<endl;
    }else if(D==24){
        cout<<"Christmas Eve"<<endl;
    }else if(D==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(D==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
        cin>>a[i];
	}
	int dp[n+1]={0};
	dp[2] = abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
        dp[i+1] = min(abs(a[i]-a[i-1])+dp[i], abs(a[i]-a[i-2])+dp[i-1]);
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String S = sc.next();
		int[] countWest = new int[n];
		
		int ans = Integer.MAX_VALUE;
		
		for (int i=0;i<n;i++) {
			countWest[i] = (i==0 ? 0 : countWest[i-1])
					+ (S.charAt(i)=='W' ? 1: 0);
		}
		
		for (int i=0;i<n;i++) {
			ans = Math.min(ans, (i==0 ? 0 : countWest[i-1])
					+ (i==n-1 ? 0 : (n-1-i-(countWest[n-1]-countWest[i]))));
		}
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 30016
#include <stdio.h>
#include<stdlib.h>

int int_sort( const void * a , const void * b ) {
  /* 引数はvoid*型と規定されているのでint型にcastする */
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}
int main(void){
    int N;
    int q[100];
    int ans=0;
     size_t data_cnt;
     data_cnt = sizeof( q )/sizeof( q[0] );
    scanf("%d",&N);
    for(int i=0;i<100;i++)q[i]=-1;
    for(int i=0;i<N;i++){scanf("%d",&q[i]);ans+=q[i];}
     qsort(( void * )q , data_cnt , sizeof( q[0] ), int_sort );
     if(ans%10!=0)printf("%d",ans);
     else{
         for(int i=0;i<100;i++)
         if(q[i]!=-1&&q[i]%10!=0){
             ans-=q[i];
             printf("%d",ans);
             break;
         }
         else if(i==99)printf("0");
     }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N=40404;
struct line{
	int a,b,c,i;
	line(){}
}a[N];
ld curx,cury;
bool compxminusinf(const line&p1,const line&p2){
	return (ld)p1.a/p1.b>(ld)p2.a/p2.b;
}
bool compyminusinf(const line&p1,const line&p2){
	return (ld)p1.b/p1.a>(ld)p2.b/p2.a;
}
bool compy(const line&p1,const line&p2){
	return (-p1.c-p1.a*curx)/p1.b<(-p2.c-p2.a*curx)/p2.b;
}
bool compx(const line&p1,const line&p2){
	return (-p1.c-p1.b*cury)/p1.a<(-p2.c-p2.b*cury)/p2.a;
}
int t[N];
int get(int i){
    int res=0;
    for(;i>=0;i=(i&(i+1))-1)res+=t[i];
    return res;
}
void add(int i,int x){for(;i<N;i|=i+1)t[i]+=x;}
int get(int l,int r){return get(r)-get(l-1);}
int32_t main(){
	int n;
	cin>>n;
	forn(i,n){
		cin>>a[i].a>>a[i].b>>a[i].c;
		a[i].c*=-1;
	}
	sort(a,a+n,compxminusinf);
	forn(i,n)a[i].i=i;
	ld ansx,ansy;
	int all=n*(n-1)/2;
	{
		ld l=-1e9,r=1e9;
		forn(it,70){
			ld m=(l+r)/2;
			curx=m;
			sort(a,a+n,compy);
			memset(t,0,sizeof t);
			int inv=0;
			forn(i,n){
				inv+=get(a[i].i);
				add(a[i].i,1);
			}
			dbg(m,inv,all);
			if(inv>=(all+1)/2)r=m;
			else l=m;
		}
		ansx=l;
	}
	sort(a,a+n,compyminusinf);
	forn(i,n)a[i].i=i;
	{
		ld l=-1e9,r=1e9;
		forn(it,70){
			ld m=(l+r)/2;
			cury=m;
			sort(a,a+n,compx);
			memset(t,0,sizeof t);
			int inv=0;
			forn(i,n){
				inv+=get(a[i].i);
				add(a[i].i,1);
			}
			if(inv>=(all+1)/2)r=m;
			else l=m;
		}
		ansy=l;
	}
	cout<<ansx<<' '<<ansy<<'\n';
    return 0;
}

Measured memory_bytes: 5368
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int main()
{
    string a,b,c ;
    cin>>a ;
    cin>>b;
    cin>>c;
    cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<"\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[][] path = new int[n+1][n+1];
    if(n%2==1){
      int cnt = 0;
      for(int i=1;i<=n;i++)Arrays.fill(path[i],1);
      for(int i=1;i<=n-1;i++)path[i][n-i]=0;
      for(int i=1;i<=n;i++)path[i][i]=0;
      for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
          if(path[i][j]==1)cnt++;
      System.out.println(cnt);
      for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
          if(path[i][j]==1)System.out.println(i+" "+j);
    }
    else{
      int cnt = 0;
      for(int i=1;i<=n;i++)Arrays.fill(path[i],1);
      for(int i=1;i<=n;i++)path[i][n+1-i]=0;
      for(int i=1;i<=n;i++)path[i][i]=0;
      for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
          if(path[i][j]==1)cnt++;
      System.out.println(cnt);
      for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
          if(path[i][j]==1)System.out.println(i+" "+j);
    }
  }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll a,b,x; cin>>a>>b>>x;
  cout<<(b-a+1-(a%x!=0?x-a%x:0)-b%x+x-1)/x<<endl;


  return 0;
}

Measured memory_bytes: 256
# 75=3*5*5
# N=a^2*b^4*c^4 | a^14+b^4 | a^24*b^2 | a^74
n=int(input())

cntDiviser=[0 for _ in range(n+1)]
for i in range(2,n+1):
    tmp=i
    for j in range(2,i+1):
        while tmp%j==0:
            cntDiviser[j]+=1
            tmp//=j # //整数の商

def num(m):
    return len(list(filter(lambda x:x>=m,cntDiviser)))

print(
    num(74)
    +num(24)*(num(2)-1)
    +num(14)*(num(4)-1)
    +num(4)*(num(4)-1)*(num(2)-2)//2 # 4,4,2の組み合わせの数
    )


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#define f cin
#define NMAX 200010
using namespace std;

//ifstream f("date.in");

int n, m;
string s;
char move_char[NMAX], move_type[NMAX];

int right_most, left_most;

bool left_match(int x) {
    int current_pos = x;
    char current_character = s[x];
    for (int i = 0; i < m; ++i) {
        if (current_character  == move_char[i]) {
            if (move_type[i] == 'L') {
                current_pos --;
            } else {
                current_pos ++;
            }
            if (current_pos < 0) return true;
            if (current_pos >= n) return false;
            current_character = s[current_pos];
        }
    }
    return false;
}

bool right_match(int x) {
    int current_pos = x;
    char current_character = s[x];
    for (int i = 0; i < m; ++i) {
        if (current_character  == move_char[i]) {
            if (move_type[i] == 'L') {
                current_pos --;
            } else {
                current_pos ++;
            }
            if (current_pos < 0) return false;
            if (current_pos >= n) return true;
            current_character = s[current_pos];
        }
    }
    return false;
}


void find_right_most(int st, int dr) {
    if (st > dr) return;
    if (st == dr) {
        if (left_match(st)) {
            right_most = max(right_most, st);
        }
        return;
    }
    int mij = (st + dr) / 2;
    if (left_match(mij)) {
        right_most = max(right_most, mij);
        find_right_most(mij + 1, dr);
    } else {
        find_right_most(st, mij - 1);
    }
}

void find_left_most(int st, int dr) {
    if (st > dr) return;
    if (st == dr) {
        if (right_match(st)) {
            left_most = min(left_most, st);
        }
        return;
    }
    int mij = (st + dr) / 2;
    if (right_match(mij)) {
        left_most = min(left_most, mij);
        find_left_most(st, mij - 1);
    } else {
        find_left_most(mij + 1, dr);
    }
}


void solve() {

    right_most = -1;
    left_most = n;
    find_right_most(0, n);
    find_left_most(0, n);

    int total_sum = right_most + 1 + n - left_most;
    if (left_most < right_most) {
        total_sum -= (right_most - left_most + 1);
    }
    cout << n - total_sum;
}

int main() {

    f >> n >> m;
    f >> s;
    for (int i = 0; i < m; ++i) {
        f >> move_char[i] >> move_type[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 900
// ABC075_C
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>  // std::swap()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define pll pair<ll, ll>
#define F first
#define S second

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M, a, b;
    cin >> N >> M;
    vector<pll> vec(M);
    REP(i, M) {
        cin >> a >> b; --a, --b;
        vec[i].F = a;
        vec[i].S = b;
    }
    
    // calculation
    UnionFind uf(N);
    ll res = 0;
    REP(i, M) {
        uf.init(N);
        REP(j, M) {
            if (j == i) continue;
            uf.merge(vec[j].F, vec[j].S);
        }
        if (uf.size(0) < N) res++;
    }
    
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long i64;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e7+5, P = 998244353;
int n, ans, pw[N]; i64 iv[N]; void fix(int &x) { x<P?0:x-=P; }
int main()
{
    n = rd(); pw[0] = iv[1] = 1, pw[1] = 2, ans = 3; 
    for(int i = 2; i <= n; ++i) ans = ans*3ll%P, iv[i] = P-(P/i)*iv[P%i]%P, fix(pw[i]=pw[i-1]<<1);
    ans = P-ans; for(int i = 0, m = n>>1, v = 1, w = 0; i <= m; ++i) 
        fix(w += (i64)v*pw[m-i]%P), fix(ans += (i64)v*w%P*pw[i+1]%P), v = v*iv[i+1]%P*(m-i)%P;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 120852
#include<iostream>
#include<sstream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
int main()
{
    long a,b,c,e,f,g,h;
    cin>>a>>b;
    if(a%3==0||b%3==0){cout<<0;return 0;}
    c=((double)(a))/3.0+0.5;
    e=max(max(c*b,(a-c)*(b/2)),(a-c)*((b+1)/2))-min(min(c*b,(a-c)*(b/2)),(a-c)*((b+1)/2));
    g=max(max(c*b,((a-c)/2)*(b)),((a-c+1)/2)*(b))-min(min(c*b,((a-c)/2)*(b)),((a-c+1)/2)*(b));
    {long d;d=a;a=b;b=d;}
    c=((double)(a))/3.0+0.5;
    f=max(max(c*b,(a-c)*(b/2)),(a-c)*((b+1)/2))-min(min(c*b,(a-c)*(b/2)),(a-c)*((b+1)/2));
    h=max(max(c*b,((a-c)/2)*(b)),((a-c+1)/2)*(b))-min(min(c*b,((a-c)/2)*(b)),((a-c+1)/2)*(b));
    cout<<min(min(e,f),min(g,h));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char n;
int a,b;
int main()
{
    cin>>a>>b;
    for(int s=0;s<a;s++)
    {
    	cin>>n;
    	if(n<'0'||n>'9')
    	{
    		cout<<"No"<<endl;
    		return 0;
		}
	}
	cin>>n;
	if(n!='-')
	{
    	cout<<"No"<<endl;
    	return 0;
		
	}
	for(int s=0;s<b;s++)
	{
		cin>>n;
    	if(n<'0'||n>'9')
    	{
    		cout<<"No"<<endl;
    		return 0;
		}
	}
	cout<<"Yes"<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200000
int main(void) {
  int num, i;
  int men[N]={0};
  scanf("%d", &num);
  for ( i = 0; i < num-1; i++)
  {
    int temp;
    scanf("%d", &temp);
    men[temp-1]++;
  }
  for( i = 0; i < num; i++){
    printf("%d\n", men[i]);
  }
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  cin >> n >> k;
  cout << (n%k == 0 ? 0 : 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, 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 factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

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

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    int g[3][3];
    rep0(i, 3)rep0(j, 3)cin >> g[i][j];
    int n;
    cin >> n;
    rep0(i, n){
        int a;
        cin >> a;
        rep0(i, 3)rep0(j, 3)if(g[i][j] == a)g[i][j] = 0;
    }
    rep0(i, 3){
        bool f = true;
        rep0(j, 3)if(g[i][j] != 0)f = false;
        if(f){
            pf("Yes");
            return 0;
        }
    }
    rep0(i, 3){
        bool f = true;
        rep0(j, 3)if(g[j][i] != 0)f = false;
        if(f){
            pf("Yes");
            return 0;
        }
    }
    if((g[0][0] == 0 && g[1][1] == 0 && g[2][2] == 0) || (g[0][2] == 0 && g[1][1] == 0 && g[2][0] == 0)){
        pf("Yes");
        return 0;
    }
    pf("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    int cnt=0;
    rep(i,n){
        int tmp;cin>>tmp;
        if(tmp%2) cnt++;
    }
    cout<<(cnt%2?"NO":"YES")<<endl;
    return 0;
}


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

int main() {
	int a,b;
	scanf("%d %d", &a,&b);
	int result1;
	int result2;
	result1 = a * b;
	result2 = 2 * a + 2 * b;
	printf("%d %d\n",result1,result2);

	return 0;
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> &a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
template<class T>void prArr(T a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int n;
  cin>>n;

  vector<set<int> > G(n);
  for(int i=0;i<n;i++){
    int u, v;
    cin>>u>>v; u--, v--;
    G[u].insert(v);
    G[v].insert(u);
  }


  vector<int> noLoop(n);
  function<void(int,int)> dfs = [&](int pos, int pre){
    noLoop[pos] = 1;
    for(int to:G[pos]) G[to].erase(pos);
    for(int to:G[pos]) if(G[to].size() == 1) dfs(to, pos);
  };

  for(int i=0;i<n;i++) if(G[i].size() == 1) dfs(i, -1);

  int Q;
  cin>>Q;
  while(Q--){
    int a, b;
    cin>>a>>b; a--, b--;

    if(noLoop[a] || noLoop[b]) cout<<1<<endl;
    else cout<<2<<endl;
    
    
  }
  
  return 0;
}



Measured memory_bytes: 28188
#include<iostream>
using namespace std;	
int main()
{
	long a,b,c,d;
  	cin>>a>>b>>c>>d;
  	while(true)
    {
     	c = c-b;
      	if(c<=0)
        {
          	cout<<"Yes\n";
        	break;
        }
      	a = a-d;
      	if(a<=0)
        {
          	cout<<"No\n";
          	break;
        }
          
    }
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

inline int ctz(uint x)
{
	int i=0;
	if(!(x&0x0000ffff)) i+=16,x>>=16;
	if(!(x&0x000000ff)) i+=8,x>>=8;
	if(!(x&0x0000000f)) i+=4,x>>=4;
	if(!(x&0x00000003)) i+=2,x>>=2;
	if(!(x&0x00000001)) i+=1,x>>=1;
	return i+!x;
}

int solve(int x0)
{
	static array<int,225> ms;
	{
		int k=0;
		rep(t,5) repi(b,t,5) rep(l,5) repi(r,l,5){
			int m=0;
			repi(i,t,b+1) repi(j,l,r+1) m|=1<<(i*5+j);
			ms[k++]=m;
		}
	}
	
	queue<tuple<int,int>> q; q.emplace(x0,0);
	unordered_set<int> vis;
	while(q.size()){
		int x,c; tie(x,c)=q.front(); q.pop();
		if(x==0) return c;
		if(!vis.insert(x).second) continue;
		for(int m:ms) if(ctz(x)==ctz(m))
			q.emplace(x^m,c+1);
	}
	return -1;
}

int main()
{
	for(int n;cin>>n && n;){
		int x0=0;
		rep(i,n) rep(j,n){
			int b; cin>>b;
			x0|=b<<(i*5+j);
		}
		string res;
		per(_,solve(x0)) res+="myon";
		cout<<res<<endl;
	}
}

Measured memory_bytes: 18776
n = gets.to_i
a = gets.split.map(&:to_i)

ls = []
0.upto(n - 1) do |i|
  ls.unshift(a[i]) if i.even?
  ls.push(a[i]) if i.odd?
end

puts n.even? ? ls.reverse.join(' ') : ls.join(' ')

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


int main(){
    int N,n;
    int a[110];

    cin >> N;

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


    sort(a,a+N,greater<int>());

    int alice = 0;
    int bob = 0;

    for(int i = 0; i < N; i++){
        if(i % 2 == 0) alice += a[i];
        else bob += a[i];
    }
    
    cout << alice - bob << "\n";
}
   

Measured memory_bytes: 256
N = int(input())

lList = [int(i) for i in input().split()]

lList.sort()
counter = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        ab = lList[a] + lList[b]
        startIndex = b+1
        endIndex = N-1
        while endIndex - startIndex > 1:
            searchIndex = (startIndex+endIndex)//2
            if lList[searchIndex] >= ab:
                endIndex = searchIndex
            else:
                startIndex = searchIndex
        if lList[startIndex] >= ab:
            counter += 0
        elif lList[endIndex] < ab:
            counter += N-1-b
        else:
            counter += startIndex - b

print(counter)


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

int main(){
  int n;
  cin >> n ;
  vector<int> a(n);
  vector<int> ans(n);
  for (int i = 1; i <= n; i++) {
    cin >> a.at(i-1);
    ans[a[i-1]-1] = i;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1536
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var N = ScanInt();
        long count = 0;
        for (int i = 0; i < N; i++) {
            var a = ScanLong();
            while (a % 2 == 0) {
                a /= 2;
                count++;
            }
        }
        Console.WriteLine(count);
    }
}

public static class Scanner
{
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    static Stream stream => Console.OpenStandardInput();
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    private static char Char() {
        var let = ConsoleIn();
        while ((let < '!' || '~' < let) && !isEof) let = ConsoleIn();
        return (char) let;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var let = Char(); '!' <= let && let <= '~'; let = (char) ConsoleIn()) {
            sb.Append(let);
        }
        return sb.ToString();
    }
    public static int ScanInt() {
        var temp = 0;
        for (var let = Char(); '0' <= let && let <= '9'; let = (char) ConsoleIn()) {
            temp = temp * 10 + let - '0';
        }
        return temp;
    }
    public static long ScanLong() {
        long temp = 0;
        for (var let = Char(); '0' <= let && let <= '9'; let = (char) ConsoleIn()) {
            temp = temp * 10 + let - '0';
        }
        return temp;
    }
}

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

int main() {
	bool prime[1000000];
	fill(prime, prime + 1000000, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i * i < 1000000; i++) {
		for (int j = 2; j * i < 1000000; j++) {
			if (!prime[i * j]) continue;
			prime[i * j] = false;
		}
	}

	int n;
	while (cin >> n) {
		if (n == 0) break;

		int t = 0, sum = 0;
		while (n > 0) {
			if (!prime[++t]) continue;

			n--;
			sum += t;
		}
		cout << sum << endl;
	}
	return 0;
}

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

#define int long long

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;



signed main() {
    IOS();
    int N;
    while(cin>>N){
        if(N==0)break;
        int A=0,B=0;
        int a,b;
        rep(i,0,N){
            cin>>a>>b;
            if(a>b)A+=a+b;
            else if(a<b)B+=a+b;
            else{
                A+=a;
                B+=b;
            }
        }
        cout<<A<<" "<<B<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}


int main(void){
    ll d,g;
    ll ans=1e9;
    ll a;
    cin>>d>>g;
    vll p(d,0);
    vll c(d,0);
    rep(i,d)cin>>p[i]>>c[i];
    
    rep(i,1<<d){
        ll tmp=0,pt=0,lq=-1;
        rep(j,d){
            if((i>>j)&1==1){
                pt+=p[j]*100*(j+1)+c[j];
                tmp+=p[j];
            }else{
                lq=j;
            }
        }
        
        if(pt>=g){
            ans=min(ans,tmp);
        }else{
            if(lq<0){
                0;
            }else{
                int nlq=(g-pt+100*(lq+1)-1)/(100*(lq+1));
                if(nlq<=p[lq])ans=min(ans,tmp+nlq);
            }
        }
    
    }
    
    cout<<ans<<endl;
    //solve(t);
}


Measured memory_bytes: 256