akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	static class Node {
		int id;
		boolean hasReached;
		Set<Integer> conns;

		Node(int id) {
			this.id = id;
			this.hasReached = false;
			this.conns = new HashSet<>();
		}
	}

	static class Edge {
		int src, dst;

		Edge(int src, int dst) {
			this.src = src;
			this.dst = dst;
		}
	}

	int N, M;
	Node[] nodes;
	Edge[] edges;
	int count = 0;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		nodes = new Node[N];
		for (int i = 0; i < N; ++i) {
			nodes[i] = new Node(i);
		}
		edges = new Edge[M];
		for (int i = 0; i < M; ++i) {
			tokens = in.readLine().split(" ");
			int src = Integer.parseInt(tokens[0]) - 1;
			int dst = Integer.parseInt(tokens[1]) - 1;
			edges[i] = new Edge(src, dst);
			nodes[src].conns.add(dst);
			nodes[dst].conns.add(src);
		}
	}

	void search(int current, int parent) {
		if (nodes[current].hasReached) {
			return;
		}
		nodes[current].hasReached = true;
		for (Integer child : nodes[current].conns) {
			if (child != parent) {
				search(child, current);
			}
		}
	}

	boolean isBridge(Edge edge) {
		nodes[edge.src].conns.remove(edge.dst);
		nodes[edge.dst].conns.remove(edge.src);
		search(0, -1);
		boolean isOK = true;
		for (int i = 0; i < N; ++i) {
			if (!nodes[i].hasReached) {
				isOK = false;
				break;
			}
		}
		for (int i = 0; i < N; ++i) {
			nodes[i].hasReached = false;
		}
		nodes[edge.src].conns.add(edge.dst);
		nodes[edge.dst].conns.add(edge.src);
		return !isOK;
	}

	void calc() {
		for (Edge edge : edges) {
			if (isBridge(edge)) {
				++count;
			}
		}
	}

	void showResult() {
		System.out.println(count);
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005];
int main(void){
    int N; cin>>N;
    for(int i=0;i<N;i++){
        int k; cin>>k;
        a[k+1]++;
        a[k]++;
        a[k+2]++;
    }
    sort(a,a+100005);
    cout<<a[100004]<<endl;
    
    
}


Measured memory_bytes: 640
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())
    T = t_i-t
    D = abs(x_i-x) + abs(y_i-y)
    if T % 2 != D % 2 or D > T:
        print("No")
        exit()
    else:
        t = t_i
        x = x_i
        y = y_i
print("Yes")

Measured memory_bytes: 9212
import sys
from collections import defaultdict
N, M, Q = list(map(int, input().split()))


sys.setrecursionlimit(10**7)

seq = [0, 1]


ABCD = [list(map(int, input().split())) for _ in range(Q)]


def check():
    tmp = 0
    for a, b, c, d in ABCD:
        if seq[b] - seq[a] == c:
            tmp += d
    return tmp


ans = 0


def dfs():
    global ans
    global seq
    l = len(seq)
    if l == N+1:
        ans = max(ans, check())
        return
    else:
        lastVal = seq[-1]
        for k in range(lastVal, M+1):
            seq.append(k)
            dfs()
            seq = seq[:-1]


dfs()

print(ans)


Measured memory_bytes: 83904
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<functional>
typedef long long ll;

using namespace std;


int main(){
    int N;
    cin >> N;
    int sum=0;
    long xsum = 0;
    long MOD = 1e9+7;
    vector<long> A(N, 0);
    vector<long> bcnt(64,0);
    vector<long> mul(64,0);
    for(int i=0;i<64;i++){
        mul[i] = (1L << i);
        mul[i] %= MOD;
    }
    int maxKeta = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        long k=A[i];
        int ind=0;
        while(k > 0){
            if((k & 1L) > 0L){
                bcnt[ind] ++;
            }
            k = (k>>1);
            ind++;
            maxKeta = max(maxKeta, ind);
        }
    }
    for(int i=0;i<N;i++){
        int keta=0;
        for(int j=0;j<=maxKeta;j++){
            if((A[i] & 1L) > 0L){
                xsum += mul[keta] * (N-bcnt[keta]);
                xsum %= MOD;
            }else{
                xsum += mul[keta] * bcnt[keta];
                xsum %= MOD;
            }
            A[i] = (A[i] >> 1);
            keta++;
        }
    }
    if(xsum % 2 == 0){
        xsum /= 2;
    }else{
        xsum = (xsum+MOD)/2;
    }
    cout << xsum << endl;

    return 0;
}


Measured memory_bytes: 2560
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a, b, x;
  cin >> a >> b >> x;
  if (a <= x and x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <set>
#include <cmath>
using namespace std;

int I[256];
int N;
double func(int S,int A,int C){
	int R[256] = {};
	R[0] = S;
	for(int i = 1 ; i < 256 ; i++){
		R[i] = (A*R[i-1]+C) % 256;
	}
	int Alpha[256] = {};
	for(int i = 0 ; i < N ; i++){
		int O = (I[i]+R[i+1]) % 256;
		Alpha[O]++;
	}
	double answer = 0;
	for(int i = 0 ; i < 256 ; i++){
		if( Alpha[i] == 0 ) continue;
		answer += Alpha[i] * log(1.*Alpha[i]/N);
	}
	return - answer / N;
}
int main(){
	while( cin >> N && N){
		for(int i = 0 ; i < N ; i++) cin >> I[i];
		
		double ans = 1e15;
		int SS,AA,CC;
		
		for(int S = 0 ; S < 16 ; S++){
			for(int A = 0 ; A < 16 ; A++){
				for(int C = 0 ; C < 16 ; C++){
					double calc = func(S,A,C);
					if( calc < ans - 1e-10 ){
						ans = calc;
						SS = S;
						AA = A;
						CC = C;
					}
				}
			}
		}
		//cout << func(8,7,14) << endl;
		cout << SS << " " << AA << " " << CC << endl;
		//printf("%.10lf\n",ans);
	}
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define hh ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) 
using namespace std; 
typedef long long ll;
const int maxn=100;
int n,sum=0;
int value[maxn]={0},cost[maxn]={0},ans[maxn]={0};
int main(){
	hh;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>value[i];
	}
	for(int i=1;i<=n;i++){
		cin>>cost[i];
		ans[i]=(value[i]>cost[i])?(value[i]-cost[i]):(0);
	}
	for(int i=1;i<=n;i++){
		sum+=ans[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;


typedef long long ll;

const int MOD = 998244353;

int sum(int a, int b)
{
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}
int sub(int a, int b)
{
    a -= b;
    if (a < 0) a += MOD;
    return a;
}
int mult(int a, int b)
{
    if (a < 0)
        a += MOD;
    if (b < 0)
        b += MOD;
    return (a * 1LL * b) % MOD;
}
int bin_pow(int a, int n)
{
    int res = 1;
    for (; n; n >>= 1, a = mult(a, a))
        if (n & 1) res = mult(res, a);
    return res;
}
int inv(int a)
{
    return bin_pow(a, MOD - 2);
}
int sqr(int x)
{
    return mult(x, x);
}

const int C = 1e6 + 5;

int mu[C];
int cnt[C];
int Sum[C], SumSqr[C];
int f[C], g[C];



int main()
{
    //freopen("input.txt", "r", stdin);


    int n;
    scanf("%d", &n);
    while(n--)
    {
        static int x;
        scanf("%d", &x);
        ++cnt[x];
    }

    mu[1] = 1;
    for (int x = 1; x < C; ++x)
    {
        for (int y = x; y < C; y += x)
        {
            if (y > x)
                mu[y] -= mu[x];
            Sum[x] = sum(Sum[x], mult(y, cnt[y]));
            SumSqr[x] = sum(SumSqr[x], mult(sqr(y), cnt[y]));
        }
        f[x] = sub(sqr(Sum[x]), SumSqr[x]);
        f[x] = mult(f[x], inv(2));
    }

    for (int x = 1; x < C; ++x)
        for (int y = x; y < C; y += x)
            g[x] = sum(g[x], mult(mu[y / x], f[y]));

    ll ans = 0;
    for (int x = 1; x < C; ++x)
        ans = sum(ans, mult(g[x], inv(x)));
    ans %= MOD;
    printf("%d", ans);
}


Measured memory_bytes: 23680
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  vector<vector<int> > len,tree;
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;

  HeavyLight(vector<vector<int> >tree)
    :tree(tree),n(tree.size()),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  //ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 24500
let inf = 101010101010101010.0
let rec for_iter a b f = if a >= b then () else (f a; for_iter (a+1) b f)

let rec main () =
  let n, m, p, a, b =
    Scanf.scanf " %d %d %d %d %d" (fun v w x y z -> v, w, x, y-1, z-1) in
  if n = 0 && m = 0 && p = 0 then () else
  let ts = Array.init n (fun _ -> Scanf.scanf " %f" (fun x -> x)) in
  let graph = Array.init m (fun _ -> []) in
  for_iter 0 p (fun _ ->
    Scanf.scanf " %d %d %f" (fun x y z ->
      let x, y = x-1, y-1 in
      graph.(x) <- (y, z) :: graph.(x);
      graph.(y) <- (x, z) :: graph.(y)));

  let dp = Array.init (1 lsl n) (fun _ -> Array.make m inf) in
  dp.(0).(a) <- 0.0;
  for_iter 0 (1 lsl n) (fun b ->
    for_iter 0 m (fun v ->
      for_iter 0 n (fun t -> 
        if b land (1 lsl t) = 0 then () else
        let b' = b lxor (1 lsl t) in
        dp.(b).(v) <- min dp.(b).(v) dp.(b').(v);
        graph.(v) |> List.iter (fun (u, z) ->
          dp.(b).(v) <-
            (dp.(b').(u) +. z /. ts.(t)) |> min dp.(b).(v)))));

  if dp.((1 lsl n) - 1).(b) = inf then
    print_endline "Impossible"
  else
    Printf.printf "%.12f\n" dp.((1 lsl n) - 1).(b);

  main ()

let () = main ()



Measured memory_bytes: 5144
#include<iostream>
#include<algorithm>
#include <stdlib.h>
#include <locale>
using namespace std;
int main(){
  int i,a,b;
  cin >> a >> b;
  if(a-1>=b){
    cout << a+a-1 << endl;
  }
  else if(b-1>=a){
    cout << b+b-1 << endl;
  }
  else{
    cout << a*2 << endl;
  }
  return 0;
}


Measured memory_bytes: 3540
import java.util.Scanner;

public class Main {

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

		if (a == b) {
			System.out.println("Draw");
			return;
		}

		if (a == 1) {
			System.out.println("Alice");
			return;
		}

		if (b == 1) {
			System.out.println("Bob");
			return;
		}

		if (a > b) {
			System.out.println("Alice");
			return;
		}

		System.out.println("Bob");

	}

}


Measured memory_bytes: 35488
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for(auto&& i : a){
        cin >> i;
    }
    partial_sum(begin(a), end(a), begin(b));
    double d = (b.back() + 1) / 2;
    auto p = upper_bound(begin(b), end(b), d);
    long long ans;
    if(p != begin(b)){
        ans = min(abs(b.back() - *p * 2), abs(b.back() - *(p - 1) * 2));
    }else{
        ans = abs(b.back() - *p * 2);
    }
    cout << ans << "\n";
}

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

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

    int d, t;
    int A[101] = {0};
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> t;
            A[t]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (A[i] == 0) ans++;
    }

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

Measured memory_bytes: 3632
#include<stdio.h>

#define MAX 100000

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

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

void get(int u);
void depth(int u,int p);

int NIL = -1;


int main(void){
  int i,j;
  int l,r;
  int p,q,c;
  
  scanf("%d",&n);
  
  for(i = 0;i < n;i++){
    T[i].left = NIL;
    T[i].right = T[i].left;
    T[i].parent = T[i].right;
  }

  for(i = 0;i < n;i++){
    scanf("%d %d",&p,&q);
    for(j = 0;j < q;j++){
      scanf("%d",&c);
      if(j == 0){
	T[p].left = c;
      } else {
	T[l].right = c;
      }
      l = c;
      T[c].parent = p;
    }
  }
  
    for(i = 0;i < n;i++){
      if(T[i].parent == NIL){
	r = i;
      }
    }

    depth(r,0);

    for(i = 0;i < n;i++){
      get(i);
    }

      return 0;
    }



void get(int u){
  int i = 0;
  int d;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);

  if(T[u].parent == NIL){
    printf("root, ");
  } else if(T[u].left == NIL){
    printf("leaf, ");
  } else {
    printf("internal node, ");
  }

  putchar('[');

  for(d = T[u].left;d != NIL;d = T[d].right,i++){
    
    if(i != 0){
      printf(", ");
    }
    printf("%d",d);
  }
  puts("]");
}


void depth(int u,int p){
  D[u] = p;

  if(T[u].left != NIL){
    depth(T[u].left,p+1);
  }  
  if(T[u].right != NIL){
    depth(T[u].right,p);
  }
}



Measured memory_bytes: 3340
# abcde -> String
readline_() = readline() |> chomp
# a b c d e -> Array{SubString{String},1}
readline_array_string() = readline() |> chomp |> split
# 1 2 3 4 5 -> Array{Int64, 1}
readline_array_int() = [parse(Int, x) for x in readline() |> chomp |> split]

a, b, c = readline_array_int()

function yesno(a, b, c)
    if a < c < b || b < c < a
        "Yes"
    else
        "No"
    end
end

print(yesno(a, b, c))

Measured memory_bytes: 112012
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,tuple<int,int,int>> pti;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int N,K;
string s;
int main(){
  cin >> N >> K >> s;
  K--;
  if(s[K]=='A') s[K]='a';
  else if(s[K]=='B') s[K]='b';
  else if(s[K]=='C') s[K]='c';
  cout << s << endl;
}

Measured memory_bytes: 3600
s=input()
t=input()
l=len(s)
l2=len(t)
ans=1000000
for i in range(l-l2+1):
	curr=0
	for j in range(i,i+l2):
		if(s[j]!=t[j-i]):
			curr+=1
	if(curr<ans):
		ans=curr
print(ans)

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100;

int p[N],s[N];

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

    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>p[i],
        s[i]=s[i-1]+p[i];
    int ans=0;
    for(int i=1;i+k-1<=n;i++)
        ans=max(ans,s[i+k-1]-s[i-1]);
    cout<<fixed<<setprecision(10)<<(ans+k)/2.0;
}


Measured memory_bytes: 3328
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
//#include<map>
#include <iomanip>
//#include<cstring>
//#include<string>
#include<cmath>
#include<queue>
//#include<stack>
#include<algorithm>
#define ll long long
#define eps 1e-9
#define endl "\n"
#define PI acos(-1)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    fast;
    string s;
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        cout<<"x";
    }
    cout<<endl;


    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int mark[100001],A[100001];
int main()
{
	int n,i,x,c=0;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>A[i];
	x=1;
	c=0;
	mark[i]=1;
	while(x!=2)
	{
		c++;
		x=A[x];
		if(mark[x])break;
		mark[x]=1;
	}
	if(x==2)cout<<c<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>
#pragma comment(linker, "/STACK:67108864")

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define ERASE(a) memset(a, -1, sizeof(a))
#define INF 2000000000
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;


int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  LL h,mult=1;
  cin >>h;
  LL a=0;
  while (h>0){
    h /= 2;
    a += mult;
    mult *= 2;
  }
  cout <<a <<endl;
  return 0;
}


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

using namespace std;
typedef long long int lli;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
typedef pair<lli, lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
const lli MAX = 1e9 + 7;

int main()
{
    fast;
    int t = 1;
    while (t--)
    {
        string s;
        cin >> s;
        lli sum = 0;
        for (int i = 0; i < s.size(); i++)
            sum += (s[i] - '0');
        if (sum % 9 == 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
    ;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e5;
const int inf=1e9;
int main(){
	int A,B,C,D,K; cin>>A>>B>>C>>D>>K;
	cout<<(C-A) * 60 + (D-B) - K<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
// 	///*
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
//*/
	string s;
	cin >> s;
	bool flag = 1;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == 'L' && !(i & 1))flag = false;
		else if (s[i] == 'R' && (i & 1)) flag = false;
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

int main(void){
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=n-1;i>=0;i--){
		cout<<a[i];
		if(i!=0)cout<<" ";
		else cout<<endl;
	}
}


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


  
int main(){

  
  string s;
  cin>>s;
  
  if (s=="ABC"){
    cout<<"ARC"<<endl;
  }
  
  else {
    cout<<"ABC"<<endl;
  }
  
  
    
  
  
  
    
  
}

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

int divi(int a,int b){
  return (a+b-1)/b;
}

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);

  int x;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if( A[i] == 1 )x=i;
  }
  
  int ans=1e9;
  for(int i=x-K+1;i+K<=N;i++){
    if(0<=i){
      ans=min( ans, 1+divi(i,K-1)+divi(N-(i+K),K-1) );
    }
  }

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


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N;
int A[110000],B[110000];
signed main() {
    cin>>N;
    int ans=0;
    for(int i=0;i<N+1;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin>>B[i];
    for(int i=0;i<N;i++){
        if(A[i]<=B[i]){
            ans+=A[i];
            B[i]-=A[i];
        }else{
            ans+=B[i];
            B[i]=0;
        }
        if(A[i+1]<=B[i]){
            ans+=A[i+1];
            A[i+1]=0;
        }else{
            ans+=B[i];
            A[i+1]-=B[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S[4]={"Sunny","Cloudy","Rainy","Sunny"};
string T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	if(S[0]==T) cout<<S[1]<<endl;
	if(S[1]==T) cout<<S[2]<<endl;
	if(S[2]==T) cout<<S[3]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;
const int nmax = 2e3 + 10;

int n, k;
int dp[nmax];

int sum(int a, int b) {
    a += b; if (a >= mod) a -= mod; return a;
}

int mul(int a, int b) {
    return (1LL * a * b) % mod;
}

int lgpow(int a, int b) {
    if (b <= 0) return 1;
    int res = 1;
    for (int i = 0; (1 << i) <= b; ++i) {
        if (b & (1 << i))
            res = mul(res, a);
        a = mul(a, a);
    }
    return res;
}

int main()
{
    scanf("%d %d", &n, &k);
    dp[0] = 1;
    for (int i = n - 1; i; --i)
        for (int j = n - i + 1; j >= 0; --j)
            dp[j] = sum(dp[j-1], dp[j+1]);

    int ans = mul(dp[n-k], lgpow(2, n - k - 1));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
struct point{
	int a,b;
	point(){}
	point(int _a,int _b){
		a=_a;b=_b;
	}
	bool operator <(const point &y) const{
		return 1ll*a*(y.b+1)>1ll*y.a*(b+1);
	}
}A[N];
int sum[N],tot,cnt;
long long f[35];
signed main(){
//	freopen("hand.in","r",stdin);
	int n,a,b,T;
	cin>>n>>T;
	for(int i=1;i<=n;++i){
		cin>>a>>b;
		if(a==0) sum[++tot]=b;
		else A[++cnt]=point(a,b);
	}
	sort(A+1,A+cnt+1);
	sort(sum+1,sum+tot+1);
	for(int i=1;i<=tot;++i)
		sum[i]=sum[i]+sum[i-1]+1;
	for(int i=1;i<=32;++i) f[i]=1e10;
	f[0]=0;
	for(int i=1;i<=cnt;++i){
		for(int j=32;j>=1;--j){
			if(f[j-1]==1e10) continue;
			f[j]=min(f[j],1ll*(f[j-1]+1)*(A[i].a+1)+A[i].b);
		}
	}
	int ans=0;
	for(int i=0;i<=32;++i)
		if(f[i]<=T){
			int mid,l=1,r=tot,res=0;
			while(l<=r){
				mid=(l+r)>>1;
				if(T-f[i]>=sum[mid]) l=mid+1,res=mid;
				else r=mid-1;
			}
			//cout<<sum[res]<<endl;
			ans=max(ans,res+i);
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6708
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <tuple>
#include <bitset>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    ll N_{};
    vector<ll> v_{};
    explicit C1(vector<ll> v) : N_(v.size()), v_(move(v)){}
    ll resolve() {
        std::sort(v_.begin(), v_.end());
        ll count = 0;
        for(ll i=0; i < N_; ++i) {
            for(ll j=0; j < i; ++j) {
                auto a = v_[j];
                auto b = v_[i];
                auto u = upper_bound(v_.begin()+j+1, v_.begin()+i, a+b);
                auto l = lower_bound(v_.begin()+j+1, v_.begin()+i, b-a+1);
                if(l == v_.end() || l > u) {
                    continue;
                }
                count += distance(l, u);
            }
        }
        return count;
    }
};

int main() {
    ll N;
    cin >> N ;
    vector<ll> v{};
    for (int i=0; i < N; ++i) {
        ll x;
        cin >> x;
        v.emplace_back(x);
    }
    C1 c{move(v)};
    cout << c.resolve() << endl;
    debug(c.resolve());
    return 0;
}


Measured memory_bytes: 384
from sys import stdin

S = stdin.readline().rstrip()
T1 = [k % 2 for k in range(len(S))]
T2 = [1 - k % 2 for k in range(len(S))]
c1 = 0
c2 = 0
for l in range(len(S)):
    if int(S[l]) == T1[l]:
        c1 += 1
    else:
        c2 += 1

print(min(c1, c2))


Measured memory_bytes: 4724
//Code by a weak man who named tarjin, and he hopes the code can get more points.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int x;
int main(void)
{
	scanf("%d",&x);
	if(x==0)
		printf("1\n");
	else
		printf("0\n");
	return 0;  
}   

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

#define fi first
#define se second

const int N = 200200;
const long long mod = 1e9 + 7;

using namespace std;

int n, m1, m2;
int a[N];
int b[N];
int p[N];

int get(int x)
{
        return p[x] == x ? x : p[x] = get(p[x]);
}

void solve(int m, int *d)
{
        for(int i = 1; i <= n; i++){
                p[i] = i;
        }
        for(int i = 1; i <= m; i++){
                int x, y;
                cin >> x >> y;
                x = get(x);
                y = get(y);
                if(x != y){
                        p[x] = y;
                }
        }
        for(int i = 1; i <= n; i++){
                d[i] = get(i);
        }
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n >> m1 >> m2;
        solve(m1, a);
        solve(m2, b);
        map < pair < int, int >, int > d;
        for(int i = 1; i <= n; i++){
                d[{a[i], b[i]}] += 1;
        }
        for(int i = 1; i <= n; i++){
                cout << d[{a[i], b[i]}] << " ";
        }
}


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

int main(){
  vector<int> v(5);
  int last;
  for(int i=0; i<5; i++){
    cin >> v[i];
    if (i==0) last=i;
    else if(v[i]%10 != 0 && (v[last]%10 > v[i]%10)) last=i;
  }
  
  int time=0;
  for(int i=0; i<5; i++){
    if(i==last) continue;
    else{
      time = ceil((double)time/10)*10;
      time += v[i];
    }
  }
  cout << ceil((double)time/10)*10+v[last] <<endl;
}

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

int main(){
    long long n;
    cin >> n;

    for (long long i = 1; i <= n + 1; i++){
        if (i*i > n){
            cout << (i-1)*(i-1) << endl;
            return 0;
        }
    }
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A < C && C < B){
        cout << "Yes";
    } else if(A > C && C > B){
        cout << "Yes";
    } else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

void factor(map<ll,ll> f, ll n){
    ll p = sqrt(n)+1;
  for(int i = 2;i < p && n!=0;i++){
    //cout << i << endl;
    if(n%i == 0){
      f[i]++;
      n/=i;
    } 
  }
  for(int  i = 2;i < p;i++){
      cout << f[i] << endl;
  }
}

  map<ll, ll> fa,fb;
void solve(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >>t;
  for(int i = 0;i < n;i++){
    cout << s[i] << t[i];
  }
  cout << endl;
}

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


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    const c = arg.split("\n")[0];
    const vowels = ["a", "i", "u", "e", "o"];
    
    console.log(vowels.filter(n=>n==c).length ? "vowel" : "consonant");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

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

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		for (int i = 3; i <= n/2; i += 2)
			if (isPrime[i] && isPrime[n-i])
				++ans;
		printf("%d\n", ans);
	}

	return 0;
}

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

void No(){
    cout << "No" << endl;
}

void Yes(){
    cout << "Yes" << endl;
}

int main(){

    int n, A, B; cin >> n >> A >> B;
    int a = 0, b = 0;
    
    for(int i = 0; i < n; i++){
        char in; cin >> in;

        if(in == 'a'){
            if(a + b < A + B){
                Yes();
                a++;
            }else{
                No();
            }
        }else if(in == 'b'){
            if(a + b < A + B && b < B){
                Yes();
                b++;
            }else{
                No();
            }
        }else{
            No();
        }
    }
    return 0;
}

Measured memory_bytes: 640
input()
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = 0

A.sort(reverse=True)

for a in A:
    B.sort(reverse=True)
    for i in range(a):
        B[i] -= 1
    if min(B) < 0:
        ans = 0
        break

if max(B) == 0:
    ans = 1

print(ans)



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

void fnInput(vector<int> &a_rvoTarget, vector<int> &a_rvoSearch)
{
  int iTargetCnt;
  cin >> iTargetCnt;

  a_rvoTarget.resize(iTargetCnt);
  for (int i = 0; i < iTargetCnt; i++)
    cin >> a_rvoTarget[i];

  int iSearchCnt;
  cin >> iSearchCnt;

  a_rvoSearch.resize(iSearchCnt);
  for (int i = 0; i < iSearchCnt; i++)
    cin >> a_rvoSearch[i];
}

void fnBinarySearch(const vector<int> &a_cnrvoTarget, const vector<int> &a_cnrvoSearch, int &a_riFound)
{
  for (int i = 0; i < a_cnrvoSearch.size(); i++)
  {
    int jLow  = 0;
    int jHigh = a_cnrvoTarget.size();
    while (jLow != jHigh)
    {
      int jMid = (jLow + jHigh) / 2;
      if (a_cnrvoSearch[i] == a_cnrvoTarget[jMid])
      {
        a_riFound++;
        break;
      }
      else if (a_cnrvoSearch[i] < a_cnrvoTarget[jMid])
        jHigh = jMid;
      else
        jLow  = jMid + 1;
    }
  }
}

void fnResultOut(int a_iFound)
{
  cout << a_iFound << endl;
}

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

  vector<int> voTarget, voSearch;
  int iFound = 0;

  fnInput(voTarget, voSearch);
  
  sort(begin(voTarget), end(voTarget));

  fnBinarySearch(voTarget, voSearch, iFound);
  fnResultOut(iFound);

  return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int Maxn=2005,p=1e9+7;
int n,a[Maxn],ans,tmp;
long long k;
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(a[i]>a[j]) ans++;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(a[i]>a[j]) tmp++;
	printf("%lld",(ans*k%p+(k*(k-1)/2%p)*tmp%p)%p);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,ans=0;
	
	scanf("%d %d",&a,&b);
	
	if(a >= 13){
		ans = b;
	}
	else if(a <= 5){
		ans = 0;
	}else{
		ans = b/2;
	}
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long int mod=1000000007;
int main(){
  long long int n,a,b,p,q,r,x,y,z;
  cin>>n>>a>>b;
  vector<long long int>S(b);
  for(int i=1;i<=b;i++){
    p=i,q=mod-2,r=1;
    while(q>0){
      if(q&1)r=r*p%mod;
      p=p*p%mod;
      q>>=1;
    } 
    S.at(i-1)=r;
  }
  p=2,q=n,r=1;
  while(q>0){
    if(q&1)r=r*p%mod;
    p=p*p%mod;
    q>>=1;
  }
  y=1,z=1;
  for(int i=0;i<a;i++)y=y*S.at(i)%mod*(n-a+1+i)%mod;
  for(int i=0;i<b;i++)z=z*S.at(i)%mod*(n-b+1+i)%mod;
  x=(r-y-z-1)%mod;
  if(x<0)x+=mod;
  cout<<x<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int i, j, x, y;

	while (1)
	{
		scanf("%d %d", &i, &j);
		if (i == 0 && j == 0)break;
		for (x = 0; x < i; x++)
		{
			for (y = 0; y < j; y++)
			{
				if ((x+y)%2==0)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string a,b,c; cin >> a >> b >> c;
    cout << 'A' << b[0] << 'C' << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(ll i = x; i < n; i++)


int main(){
  ll n, p, ans = 1; cin >> n >> p;

  if(n == 1){
    cout << p << endl;
    return 0;
  }

  for(ll a = 2; a * a <= p; a++){
    ll i = pow(a, n);
    if(p % i == 0){
      ans = a;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int N,Q;
  while(~scanf("%d %d",&N,&Q)){
    if(N==0 && Q==0) break;

    map<string,int> StartWestYear;
    map<int,string> StartWestYearName;
    map<string,int> EraBasedYearUpperBounds;
    vector<int> WesternBasedYears;
    for(int i=0;i<N;i++){
      string EraName;
      int EraBasedYear,WesternYear;
      cin >> EraName >> EraBasedYear >> WesternYear;
      StartWestYear[EraName] = WesternYear - EraBasedYear + 1;
      StartWestYearName[WesternYear - EraBasedYear + 1] = EraName;

      EraBasedYearUpperBounds[EraName] = max(EraBasedYear,EraBasedYearUpperBounds[EraName]);
      WesternBasedYears.push_back(WesternYear - EraBasedYear + 1);
    }

    WesternBasedYears.push_back(0);
    WesternBasedYears.push_back(INF);
    sort(WesternBasedYears.begin(),WesternBasedYears.end());

    for(int i=0;i<Q;i++){
      int year;
      cin >> year;

      string res = "Unknown";
      for(int year_idx=0;year_idx+1 < WesternBasedYears.size();year_idx++){

	// year := 2000
	// [1990(year_idx's year) ~ 2050)
	if(WesternBasedYears[year_idx] <= year && year < WesternBasedYears[year_idx+1]){
	  if(year_idx == 0) break;

	  if(StartWestYearName.find(WesternBasedYears[year_idx]) != StartWestYearName.end()){
	    ostringstream oss;

	    if(EraBasedYearUpperBounds[StartWestYearName[WesternBasedYears[year_idx]]]
	       < year - WesternBasedYears[year_idx] + 1) break;

	    oss << (StartWestYearName[WesternBasedYears[year_idx]])
		<< " " 
		<< (year - WesternBasedYears[year_idx] + 1);
	    res = oss.str();
	    break;
	  }
	}
      }

      printf("%s\n",res.c_str());
    }
  }
}

Measured memory_bytes: 1556
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main implements Runnable {

	ArrayList<Integer>[] g;
	int[] deg;
	int n;
	int[] a, b;
	int A, B;

	public void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new int[n - 1];
		b = new int[n - 1];
		deg = new int[n];
		g = new ArrayList[n];
		for (int i = 0; i < n; ++i)
			g[i] = new ArrayList();
		for (int i = 0; i < n - 1; ++i) {
			a[i] = Integer.parseInt(sc.next());
			b[i] = Integer.parseInt(sc.next());
			--a[i];
			--b[i];
			++deg[a[i]];
			++deg[b[i]];
			g[a[i]].add(b[i]);
			g[b[i]].add(a[i]);
		}
		A = 0;
		for (int i = 0; i < n; ++i) {
			if (deg[i] % 2 == 1)
				++A;
		}
		A /= 2;
		int ok = n - 1;
		int ng = 0;
		while (ok - ng > 1) {
			int middle = (ok + ng) / 2;
			if (check(middle)) {
				ok = middle;
			} else {
				ng = middle;
			}
		}
		System.out.println(A + " " + ok);
		sc.close();
	}

	boolean check(int B_) {
		int p = dfs(0, -1, B_);
		if (p <= B_)
			return true;
		else
			return false;
	}

	int dfs(int cur, int par, int B_) {
		ArrayList<Integer> pnd = new ArrayList<>();
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			int insert = dfs(dst, cur, B_);
			if (insert > B_)
				return insert;
			pnd.add(insert);
		}
		if (deg[cur] % 2 == 1)
			pnd.add(0);
		if (cur == 0)
			pnd.add(B_ - 1);
		Collections.sort(pnd);
		int ng = -1;
		int ok = pnd.size();
		loop1: while (ok - ng > 1) {
			int middle = (ok + ng) / 2;
			int s = 0;
			int t = pnd.size() - 1;
			if (s == middle)
				++s;
			if (t == middle)
				--t;
			while (t - s > 0) {
				if (pnd.get(s) + pnd.get(t) > B_) {
					ng = middle;
					continue loop1;
				}
				++s;
				--t;
				if (s == middle)
					++s;
				if (t == middle)
					--t;
			}
			ok = middle;
		}
		if (ok == pnd.size()) {
			return B_ + 1;
		}
		return pnd.get(ok) + 1;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}
}


Measured memory_bytes: 148680
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    ll a, b, c;
    cin >> a >> b >> c;

    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout << 0 << endl;
    } else {
        cout << min({a * b, a * c, b * c}) << endl;
    }



}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 998244353;

ll ima[10][10];

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

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    ll n;
    cin >> n;
    ll res = 1;
    string s;
    cin >> s;
    for(ll i=0; i<3*n; i++){
        if(s[i] == 'R'){
            if(ima[2][3]+ima[3][2]){
                res = mul(res, ima[2][3]+ima[3][2]);
                if(ima[2][3]) ima[2][3]--;
                else ima[3][2]--;
            }
            else if(ima[2][0]){
                res = mul(res, ima[2][0]);
                ima[2][0]--;
                ima[2][1]++;
            }
            else if(ima[3][0]){
                res = mul(res, ima[3][0]);
                ima[3][0]--;
                ima[3][1]++;
            }
            else ima[1][0]++;
        }
        else if(s[i] == 'G'){
            if(ima[1][3]+ima[3][1]){
                res = mul(res, ima[1][3]+ima[3][1]);
                if(ima[1][3]) ima[1][3]--;
                else ima[3][1]--;
            }
            else if(ima[1][0]){
                res = mul(res, ima[1][0]);
                ima[1][0]--;
                ima[1][2]++;
            }
            else if(ima[3][0]){
                res = mul(res, ima[3][0]);
                ima[3][0]--;
                ima[3][2]++;
            }
            else ima[2][0]++;
        }
        else{
            if(ima[2][1]+ima[1][2]){
                res = mul(res, ima[2][1]+ima[1][2]);
                if(ima[2][1]) ima[2][1]--;
                else ima[1][2]--;
            }
            else if(ima[2][0]){
                res = mul(res, ima[2][0]);
                ima[2][0]--;
                ima[2][3]++;
            }
            else if(ima[1][0]){
                res = mul(res, ima[1][0]);
                ima[1][0]--;
                ima[1][3]++;
            }
            else ima[3][0]++;
        }
    }
    for(ll i=2; i<=n; i++) res = mul(res, i);
    cout << res;
    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
int main(void){
    char s[100], t[100], u[100];
    int a,b;
    int i;
    int flg;
    scanf("%s", s);
    scanf("%s", t);
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%s", u);
    flg = 0;
    for(i = 0;u[i] != '\0';i ++){
        if(u[i] != s[i]){
            flg = 1;
            break;
        }
    }
    if(flg == 0){
        printf("%d %d", a - 1, b);
    }else{
        printf("%d %d", a, b - 1);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3520