akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

struct UnionFind {
  int n,num;
  vector<int> r,p;
  UnionFind() {}
  UnionFind(int n) : n(n), num(n), r(n,1), p(n,0) {
    iota(p.begin(),p.end(),0);
  }
  int find(int x) {
    return (x == p[x] ? x : p[x] = find(p[x]));
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (r[x] < r[y]) swap(x,y);
    r[x] += r[y];
    p[y] = x;
    num--;
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return r[find(x)];
  }
  int count() {
    return num;
  }
};

int N;
int x[51],y[51];

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

  cin >> N;
  REP(i,N) cin >> x[i] >> y[i];
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }
  int ans = INF;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j == i) continue;
      int dx = x[j]-x[i];
      int dy = y[j]-y[i];
      UnionFind uf(N);
      for (int k = 0; k < N; k++) {
        for (int l = 0; l < N; l++) {
          if (l == k) continue;
          int xx = x[l]-x[k];
          int yy = y[l]-y[k];
          if (xx == dx && yy == dy) {
            uf.unite(k,l);
          }
        }
      }
      CHMIN(ans,uf.count());
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h,w,x;
    scanf("%d%d",&h,&w);
    char a[h][w+1];
    for(int i=0;i<h;i++){
        scanf("%s",a[i]);
    }
    for(int i=1;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i-1][j]=='#'||a[i-1][j]=='A'){
                if(a[i][j]=='#'||a[i][j]=='A'){
                    a[i-1][j]='A';
                    a[i][j]='A';
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=1;j<w;j++){
            if(a[i][j-1]=='#'||a[i][j-1]=='A'){
                if(a[i][j]=='#'||a[i][j]=='A'){
                    a[i][j-1]='A';
                    a[i][j]='A';
                }
            }
        }
    }
    x=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#')x++;
        }
    }
    if(x!=0)printf("No\n");
    if(x==0)printf("Yes\n");
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==1&&b==1){
        cout<<"Open"<<endl;
    }
    else if(c==1){
        cout<<"Open"<<endl;
    }
    else{
        cout<<"Close"<<endl;
    }
}



Measured memory_bytes: 3104
from sys import exit
print("? 999999999", flush=True)
if input() == "N":
	print("! 1000000000", flush=True)
	exit()

ans = ""
while len(ans) < 9:
	if len(ans) == 0:
		ok, ng = 9, 0
	else:
		ok, ng = 9, -1
	while abs(ok-ng) > 1:
		x = (ok+ng)//2
		print("? " + ans + str(x) + "9"*9, flush=True)
		if input() == "Y":
			ok = x
		else:
			ng = x
	ans += str(ok)

if ans == "100000000":
	while ans != "1":
		print("? " + "9"*(len(ans)-1), flush=True)
		if input() == "N":
			break
		else:
			ans = ans[:-1]
else:
	while ans[-1] == "0":
		print("? " + str(int(ans)-1), flush=True)
		if input() == "Y":
			break
		else:
			ans = ans[:-1]

print("! " + ans, flush=True)
exit()

Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    ll s[N], ans = 0;
    rep(i, N) cin >> s[i];
    //A-B=iと固定する
    rep2(i, 1, N-1){
        vector<ll> l((N-1)/i+2), r((N-1)/i+2);
        //l[j](r[j]):=0(N-1)からiごとにj個取ったものの総和
        l[0] = r[0] = 0;
        rep(j, (N-1)/i+1){
            l[j+1] = l[j]+s[i*j];
            r[j+1] = r[j]+s[N-1-i*j];
        }
        //N-1=j*(A-B)+A
        rep(j, N/i){
            int A = N-1-j*i, B = A-i;
            if(B < 0) continue;
            if((N-1)%i == 0 && 2*i*j >= N-1) continue;
            ans = max(ans, l[j+1]+r[j+1]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t,res;
	cin>>s>>t;
	s='/'+s;
	t='/'+t;
	int i,j,n=s.length(),m=t.length();
	int arr[n+1][m+1]={0};
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(i==0||j==0)
				arr[i][j]=0;
			else if(s[i]==t[j])
				arr[i][j]=arr[i-1][j-1]+1;
			else
				arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
		}
	}
	i=n-1;
	j=m-1;
	while(i>0&&j>0)
	{
		if(arr[i][j]>max(arr[i-1][j],arr[i][j-1]))
		{
			res=t[j]+res;
			i--;
			j--;
		}
		else if(arr[i][j]==arr[i-1][j])
		{
			i--;
		}
		else if(arr[i][j]==arr[i][j-1])
		{
			j--;
		}
	}
	cout<<res;
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <utility>
#include <string>
 
#define MOD 1000000007LL
 
using namespace std;
 
typedef long long ll;
 
int main() {
    string S;
    cin >> S;
 
    ll dp[S.size()][13];
 
    for (int i=0; i<S.size(); ++i) {
        for (int j=0; j<13; ++j) {
            dp[i][j] = 0;
        }
    }
 
    if (S[0]=='?') {
        for (int i=0; i<10; ++i) {
            dp[0][i] = 1;
        }
    } else {
        int c = S[0] - '0';
        dp[0][c] = 1;
    }
 
    for (int i=1; i<S.size(); ++i) {
        if (S[i]=='?') {
            for (int j=0; j<10; ++j) {
                for (int ki=0; ki<13; ++ki) {
                    dp[i][(ki*10+j)%13] += dp[i-1][ki];
                }
            }
        } else {
            int c = S[i] - '0';
            for (int ki=0; ki<13; ++ki) {
                dp[i][(ki*10+c)%13] += dp[i-1][ki];
            }
        }
        for (int ki=0; ki<13; ++ki) {
            dp[i][ki] %= MOD;
        }
    }
 
    cout << dp[S.size()-1][5] << endl;
 
 
 
    return 0;
 
}


Measured memory_bytes: 10624
/*input
10
*/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a;
    cin >> a;
    int ans = a+a*a+a*a*a;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//sOLVING THIS SHIT USING SIEVE //
#define MAX 100001
 
using namespace std;
 
bool prime[MAX]={false};
int prefix[MAX];
 
 
void precal()
{
    
    for(int i=2;i*i<=MAX;i++)
    {
        
        
        if(!prime[i])
        {
            for(int j=i+i;j<=MAX;j+=i) prime[j]=true;
        }
        
    }
    
    prefix[0]=prefix[1]=0;
    for(int i=3;i<=MAX;i++)
    {
        prefix[i]=prefix[i-1];
        
        if(!prime[i]&&!prime[(i+1)/2]) ++prefix[i];
    }
    
    
}
 
 
int main()
{
precal();
int n;
cin>>n;
while(n--)
{
    int l,r;
    
    cin>>l>>r;
    cout<<prefix[r]-prefix[l-1]<<endl;
}
    
    
    
    
}

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

int main(){
    int n, t;cin >> n >> t;
    int c[n], t_e[n];
    int cost = 0;

    for (int i=0;i<n;i++){
        cin >> c[i] >> t_e[i];
        if (c[i] > cost ){
            cost = c[i];
        }
    }

    int isPossible = false;

    for (int j=0;j<n;j++) {
       if (t >= t_e[j]) {
           isPossible = true;
           if (cost >= c[j]) {
               cost = c[j];
           }
       } 
    }

    if (isPossible == false){
        cout << "TLE" << endl;
        return 0;
    }

    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int sum(int l,int r,vector<int>& bit) {
  int ans = 0;
  while(r>0) {
    ans += bit[r];
    r -= r & -r;
  }
  while(l>0) {
    ans -= bit[l];
    l -= l & -l;
  }
  return ans;
}
void add(int i,int n,vector<int>& bit) {
  while(i < bit.size()) {
    bit[i] += n;
    i += i & -i;
  }
}
int main() {
  int N,Q;
  string S;
  cin >> N >> S >> Q;
  vector<int> BIT[26];
  int i,j;
  for(i=0;i<26;i++)vector<int>(N+1,0).swap(BIT[i]);
  for(i=0;i<N;i++)add(i+1,1,BIT[(S[i]-'a')]);
  int q,l,r,cnt;
  char c;
  for(i=0;i<Q;i++) {
    cin >> q;
    if(q == 1) {
      cin >> j >> c;
      add(j,-1,BIT[(S[j-1]-'a')]);
      add(j,1,BIT[(c-'a')]);
      S[j-1] = c;
    }
    else {
      cin >> l >> r;
      cnt = 0;
      for(j=0;j<26;j++) {
        if(sum(l-1,r,BIT[j])>0)cnt++;
      }
      cout << cnt << endl;
    }
  }
}

Measured memory_bytes: 51716
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int d[100][100];
typedef pair<int, int>pii;
typedef pair<pii, int>pi3;
int x[1000];
int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)if (s[i] == ',')s[i] = ' ';
	cout << s << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#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 rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll a[100001];
ll s[100001];
int  main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	repe(i, 1, n) {
		s[i] += a[i] + s[i - 1];
	}

	if (n & 1) {
		ll l = s[n / 2] - s[0];
		ll m = a[n / 2 + 1] + a[n / 2 + 2];
		ll r = s[n] - s[n / 2 + 2];
		ll sum1 = -2 * l + m + 2 * r;

		l = s[n / 2 - 1] - s[0];
		m = a[n / 2] + a[n / 2 + 1];
		r = s[n] - s[n / 2 + 1];
		ll sum2 = -2 * l - m + 2 * r;

		cout << max(sum1, sum2) << endl;
	}
	else {
		ll l = s[n / 2 - 1] - s[0];
		ll mm = a[n / 2];
		ll mp = a[n / 2 + 1];
		ll r = s[n] - s[n / 2 + 1];
		cout << -2 * l - mm + mp + 2 * r << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
def max(x):
    p = x[0]
    for i in range(0,len(x)):
        if p < x[i]:
            p = x[i]
        else:
            p = p
    return p
        
n = int(input())
s = list(map(int, input().split()))
q = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
                q = q
            else:
                if s[i] + s[j] + s[k] - max([s[i],s[j],s[k]]) > max([s[i],s[j],s[k]]):
                    q = q + 1
                else:
                    q = q
print(q)

Measured memory_bytes: 9188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var result = "No";
            if (n < 10) result = "Yes";

            for (var i = 2; i < 10; i++)
            {
                if (n % i == 0 && n / i < 10)
                {
                    result = "Yes";
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27528
from collections import defaultdict
N, W = map(int, raw_input().split())

w = []
v = []
for i in range(0, N):
    w_i, v_i = map(int, raw_input().split())
    w.append(w_i)
    v.append(v_i)

items = sorted([{'w': w[i], 'v': v[i]} for i in range(0, N)],
               lambda i1, i2: cmp(i2['w'], i1['w']))

def default():
    return defaultdict(lambda:-1)

results = defaultdict(default)

def add(i, w_max):
    if results[i][w_max] != -1:
        return results[i][w_max]

    if i == N:
        return 0;

    if w_max < items[i]['w']:
        res = add(i+1, w_max)
    else:
        res = max(
            add(i+1, w_max),
            add(i+1, w_max - items[i]['w']) + items[i]['v']
        )
    results[i][w_max] = res
    return res

print(add(0, W))


Measured memory_bytes: 13816
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, t, a;
    cin >> n >> a;
    int tot = 0;
    for(int i = 0; i < a; ++i) {
        cin >> t;
        tot += t;
    }
    if(tot >= n) puts("Yes");
    else puts("No");
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(){
    using namespace std;
    int n;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    int q;
    cin >> q;
    int count = 0;
    for (int i = 0; i < q; i++) {
        int y;
        cin >> y;
        int ok = -1;
        int ng = s.size();
        while(abs(ok - ng) > 1){
            int mid = (ok + ng) / 2;
            if (s[mid] <= y) ok = mid;
            else ng = mid;
        }
        if (s[ok] == y)  count++;
    }
    cout << count << endl; 
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int n = count(s.begin(), s.end(), s[0]);
  if (n == 2) {
    if ((s[0] == s[1] && s[2] == s[3]) || (s[0] == s[2] && s[1] == s[3]) || s[0] == s[3] && s[1] == s[2]) {
      cout << "Yes" << endl;
    } else {
	  cout << "No" << endl;
    }
  } else {
    cout << "No" << endl; 
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 int INF = 1e9;
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 200010;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, -INF);
        for(int i=0; i<sz; i++) node[i+n-1] = -INF;
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return -INF;
        if(a <= l && r <= b) return node[k];
 
        int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};

//const ll mod = 1000000007;
int N;
SegmentTree seg;
vector<ll> paths[201000];
ll ans[201000];
vector<int> a;
void dfs(int now, int p) {
    ll tmp = seg.getmax(0, a[now]);
    tmp++;
    ll before = seg.getmax(a[now], a[now]+1);
    chmax(tmp, before);
    seg.update(a[now], tmp);
    ans[now] = seg.getmax(0, N + 1);
    for(auto to : paths[now]) {
        if(to == p) continue;
        dfs(to, now);
    }
    seg.update(a[now], before);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<int> cmp;
    a.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        cmp.push_back(a[i]);
    }
    cmp.push_back(-1);
    sort(cmp.begin(), cmp.end());
    cmp.erase(unique(cmp.begin(), cmp.end()), cmp.end());
    for(int i = 0; i < N; i++) {
        auto itr = lower_bound(cmp.begin(), cmp.end(), a[i]);
        a[i] = itr - cmp.begin();
    }
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    seg.update(0, 0);
    dfs(0, -1);
    for(int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 45176
#include <iostream>
using namespace std;
 
#define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
#define m tmp=d[r][1];d[r][1]=d[r][3];d[r][3]=d[r][4];d[r][4]=d[r][2];d[r][2]=tmp;
#define y tmp=d[r][0];d[r][0]=d[r][3];d[r][3]=d[r][5];d[r][5]=d[r][2];d[r][2]=tmp;
 
bool same(int d[][6],int q,int r){
 int tmp,cnt,j,a=1,i,k;
 check
   if(cnt==6)a=0;
 
 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    m
   }
   check
   if(cnt==6)break;
   tmp=d[r][0];
   d[r][0]=d[r][1];
   d[r][1]=d[r][5];
   d[r][5]=d[r][4];
   d[r][4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   m
  }
  if(cnt==6)break;
  y
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   m
  }
  a=0;
 }
 
 if(cnt==6)return true;
 return false;
 
}
 
 
int main(){
 int n,judge=0;
 
 cin >> n;
 
 int d[n][6];
 
 for(int i=0;i<n;i++){
  for(int j=0;j<6;j++){
   cin >> d[i][j] ;
  }
 }
 
 for(int q=0;q<n-1;q++){
  for(int r=q+1;r<n;r++){
  if(same(d,q,r))judge++;
  }
 }
 if(judge>0)cout << "No" << endl ;
 else cout << "Yes" << endl ;
 
 return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, k;
    cin >> n >> k;
    set<int> s;
    for(int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++)
        {
            int x;
            cin >> x;
            s.insert(x);
        }
    }
    int ans = n - s.size();
    cout << ans << endl;
}




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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;

  string result = "Yes";
  for (int i = 1; i <= s.size(); ++i) {
    char c = s[i - 1];
    if (i % 2 == 1) {
      if (c == 'L') {
        result = "No";
        break;
      }
    } else {
      if (c == 'R') {
        result = "No";
        break;
      }
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> PII;
typedef map<int,int> MII;
typedef vector<int> VI;
typedef vector<vector<int>> VII;
typedef vector<long long> VLL; 
#define For(i,a,b) for(int i = (a); i < (b); ++i)
#define Rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const LL ML = 4e18;

void solve() {
    int n;
    cin >> n;
    VI a(n);
    For(i,0,n) cin >> a[i];
    if(n %2 == 0) {
        int x = 0;
       For(i,0,n) x ^= a[i];
       For(i,0,n) {
           if(i != 0) cout << " ";
           int p = a[i]^x;
           cout << p;
       }
    }
    else {
        VI r(n,0);
        int x = 0;
        For(i,2,n) x ^= a[i];
        r[1] = a[0] ^ a[1];
        For(i,2,n) r[i] = a[i]^x;
        For(i,0,n) {
           if(i != 0) cout << " ";
           //int p = a[i]^x;
           cout << r[i];
       } 
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main(void){
  int N,res=0,V[21],C[21];
  cin >> N;
  for(int i=0;i<N;i++) cin >> V[i];
  for(int i=0;i<N;i++) cin >> C[i];

  for(int i=0;i<N;i++) res+=max(0,V[i]-C[i]);
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r, c;
	cin >> r >> c;
	vector<vector<int> > sheet(r);
	REP(i, r) sheet.at(i).resize(c);
	REP(i, r) {
		REP(j, c) {
			cin >> sheet.at(i).at(j);
		}
	}
	REP(i, r) {
		REP(j, c) {
			cout << sheet.at(i).at(j) << " ";
		}
		cout << accumulate(sheet.at(i).begin(), sheet.at(i).end(), 0) << endl;
	}
	REP(i, c) {
		int sum = 0;
		REP(j, r) sum += sheet.at(j).at(i);
		cout << sum << " ";
	}
	int sum = 0;
	REP(i, r) sum += accumulate(sheet.at(i).begin(), sheet.at(i).end(), 0);
	cout << sum << endl;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int a,b,x; cin>>a>>b>>x;

    double theta;
    if(a*a*b/2.>=x){
        double d=2.*x/b/a;
        theta=atan(b/d);
    }else{
        double _b=2*b-2.*x/a/a;
        theta=atan(_b/a);
    }

    theta=theta*180/(2*acos(0));
    cout<<fixed<<setprecision(10)<<theta<<endl;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, h, w, u, v, x, y;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s, t, tmp;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n >> m >> k;
        vi arr(n + 1, 0), brr(m + 1, 0);

        for(i = 1; i <= n; i++){
            cin >> arr[i];
            arr[i] += arr[i - 1];
        }
        for(i = 1; i <= m; i++){
            cin >> brr[i];
            brr[i] += brr[i - 1];
        }

        ans = 0;
        ll ta = 0, tb = m;
        for(i = 0; i <= n; i++){
            if(arr[i] > k) break;

            ta = arr[i];
            while(tb >= 0 and brr[tb] > k - ta){
                tb--;
            }

            ans = max(ans, i + tb);
        }
        cout << ans << nl;
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 6404
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int cnt = 0;
    vector<int> black(N, 0);
    if (S.at(0) == '#')
        black.at(0) = 1;

    for (int i = 1; i < N; i++)
    {
        if (S.at(i) == '#')
        {
            black.at(i) += black.at(i - 1) + 1;
        }
        else
            black.at(i) = black.at(i - 1);
    }

    int ans = N - black.at(N - 1); //全部白に変える
    for (int i = 0; i < N; i++)
    {
        int cnt = 0;
        cnt += black.at(i);                                   // 左側．黒を白に変える
        cnt += (N - 1 - i) - (black.at(N - 1) - black.at(i)); // 右側，白を黒に変える．
        ans = min(cnt, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1412
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;
int n,K,len;
vector<int>ans[2000];
int main(){
	K=38; n=K*(K-1)+1; len=0;
	for (int i=1;i<=K;i++){
		len++;
		int l=(i-1)*(K-1)+1,r=i*(K-1);
		for (int j=l;j<=r;j++) ans[j].push_back(len);
		ans[n].push_back(len);
	}
	for (int i=1;i<=(K-1);i++)
		for (int j=1;j<=(K-1);j++){
			len++; ans[i].push_back(len);
			for (int k=2;k<=K;k++){
				int num=((k-2)*i+j-1)%(K-1)+1;
				int now=(k-1)*(K-1)+num;
				ans[now].push_back(len);
			}
		}
	printf("%d %d\n",n,K);
	for (int i=1;i<=n;i++){
		for (int j=0;j<ans[i].size();j++) cout<<ans[i][j]<<" "; cout<<endl;
	}
}

Measured memory_bytes: 896
#include <iostream>
#include <cassert>
#include <vector>

using llong = long long;
static const long long INF = 1LL << 60;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

int main()
{
  // Input
  int numArray;
  std::cin >> numArray;
  assert(1 <= numArray and numArray <= 3000);
  std::vector<llong> gain(1 + numArray);
  for (int i = 1; i <= numArray; ++i) {
    std::cin >> gain[i];
    assert(1 <= gain[i] and gain[i] <= 1.0e+9);
  }

  // Initialization
  auto dp = vectors<llong>(1 + numArray, 1 + numArray, -INF);

  // Initial condition
  for (int i = 1; i <= numArray; ++i)
    dp[i][i] = gain[i];

  // DP main
  for (int k = 0; k < numArray; ++k) {
    for (int i = 1; i <= numArray - k; ++i) {
      int j = i + k;
      assert(1 <= i and i <= j and j <= numArray);
      if (j + 1 <= numArray)
        chmax(dp[i][j + 1], gain[j + 1] - dp[i][j]);
      if (i - 1 >= 1)
        chmax(dp[i - 1][j], gain[i - 1] - dp[i][j]);
    }
  }

  // Output
  std::cout << dp[1][numArray] << std::endl;

  return 0;
}


Measured memory_bytes: 70784
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	ans := 0
	for a := 1; a < N; a++ {
		for b := 1; a*b < N; b++ {
			c := N - a*b
			if c > 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


Measured memory_bytes: 1864
program main
  implicit none
  integer :: n, ans, x, i
  character(100) :: s

  read(*,*) n
  read(*,*) s

  x = 0
  ans = 0

  do i= 1, n
     if(s(i:i) == 'I')then
        x = x + 1
     else
        x = x - 1
     end if

     ans = max(ans,x)
  end do
  write(*,*) ans
end program main

     


Measured memory_bytes: 2848
import java.util.Scanner;

public class Main {

    private static int taskOne(int n, int k) {
        return 0;
    }

    private static int taskTwo() {
        return 0;
    }

    private static int taskThree() {
        return 0;
    }

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

        if (n >= 10) {
            System.out.println(r);
        } else {
            System.out.println(r + 100 * (10 - n));
        }
    }
}

Measured memory_bytes: 23508
import itertools

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    N = int(input())
    primes = list(set(prime_factorize(N)))
    cnt = 0
    while len(primes) != 0:
        d = primes.pop(0)
        e = 1
        # print(d,e)
        # print('===================')
        while N%d**e == 0:
            # print(d,N,e,cnt)
            N = N/(d**e)
            e += 1
            cnt += 1
        #     print(d,N,e,cnt)
        # print('===================')
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9288
#include <iostream>

int main()
{
    char a[3];
    for (int i = 0; i < 3; ++i)
        std::cin >> a[i];

    for (int i = 0; i < 3; ++i)
        if (a[i] == '1')
            std::cout << '9';
        else
            std::cout << '1';

    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 2005;
void solve(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	int ans = 0;
	int r = 0;
	for(int i =0; i < n; i++ ){
		if(s[i]=='R')
			r++;
	}
	for(int i = 0;i<r ; i++) {
		if(s[i]!='R')
			ans++;
	}

	cout<<ans<<'\n';
}
int main() {	
	IOS
	ll T;
	// cin>>T;
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    std::cout <<fixed << setprecision(10)<< (double(w)*double(h)/2) << " ";
    if((x*2==w) && (y*2==h)){
        std::cout << 1 << std::endl;
    }else{
        std::cout << 0 << std::endl;
    }
}

Measured memory_bytes: 256
a = [[0 for i2 in range(10)] for i1 in range(10)]

def small_ink(x,y):
    a[x][y] += 1
    a[x-1][y] += 1
    try:
        a[x+1][y] += 1
    except:
        pass
    a[x][y-1] += 1
    try:
        a[x][y+1] += 1
    except:
        pass
    if x-1 < 0:
        a[x-1][y] -= 1
    if y-1 < 0:
        a[x][y-1] -= 1
    return 0

def mid_ink(x,y):
    for i in [-1,0,1]:
        for j in [-1,0,1]:
            if 9 >= x+i >= 0 and 9>= y+j >= 0:
                a[x+i][y+j] += 1
    return 0

def big_ink(x,y):
    mid_ink(x,y)
    a[x-2][y] += 1
    try:
        a[x+2][y] += 1
    except:
        pass
    a[x][y-2] += 1
    try:
        a[x][y+2] += 1
    except:
        pass
    if x-2 < 0:
        a[x-2][y] -= 1
    if y-2 < 0:
        a[x][y-2] -= 1
    return 0

def ink(x,y,s):
    if s == 1:
        small_ink(x,y)
    if s == 2:
        mid_ink(x,y)
    if s == 3:
        big_ink(x,y)
    return 0

while True:
    try:
        x,y,s = map(int,input().split(','))
        ink(x,y,s)
    except EOFError:
        break
nu = 0
for i in range(10):
    for j in range(10):
        if a[i][j] == 0:
            nu += 1
print(nu)
max_val = 0
for i in range(10):
    for j in range(10):
        if a[i][j] > max_val:
            max_val = a[i][j]
print(max_val)

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

int main(void){
  string word;
  string str;
  int wordcount;
  int count = 0;
  int wordnum;
  int flag;

  cin >> word;

  for(int i = 0 ; word[i] != '\0' ; i++){
      wordnum++;
      if ( (word[i] >= 'a') && (word[i] <= 'z') ){ word[i]-=32; }
  }

  while(1){

    getline(cin,str);

    if ( str == "END_OF_TEXT"){break;}
    flag = 1;
    wordcount = 0;
    for(int i = 0 ; str[i] != '\0' ; i++){

      if ( (str[i] >= 'a') && (str[i] <= 'z') ){ str[i]-=32; }

      if ( str[i] == ' '){
        flag = 1;
        wordcount = 0;
      }else{
        if ( (flag == 1 ) && (str[i] == word[wordcount]) ){

          if( (wordcount == wordnum - 1) && ((str[i+1] == ' ') ||  (str[i+1] == '\0')) ){
            count++;
            wordcount = 0;
          }else{
            wordcount++;
          }

        }else{
          flag = 0;
          wordcount = 0;
        }
      }
    }
  }

  cout << count << endl;
}

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

int main() {
  string t; cin >>t;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == '?') t.at(i) = 'D';
  }
  cout << t << endl;
  return 0;
}


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

int main(){
    int N, M, tmp;
    ll res = 0;
    cin >> N >> M;
    priority_queue<int> A;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        A.push(tmp);
    }
    for(int i = 0; i < M; i++){
        tmp = A.top() / 2;
        A.pop();
        A.push(tmp);
    }
    for(int i = 0; i < N; i++){
        res = res + A.top();
        A.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main(){
    int N,M,max=0,count=0;
    vector<string> C(201);
    cin>>N;
    map<string,int> BR;
    for(int i=0;i<N;i++){
        cin>>C[count];
        BR[C[count]]++;
        count++;
    }
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>C[count];
        BR[C[count]]--;
        count++;
    }
    for(int i=0;i<=count;i++){
        if(BR[C[i]]>max) max=BR[C[i]];
    }
    cout<<max;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int n,a[100],sum;
int MIN,MAX,minflag,maxflag;
int main()
{
    n=sum=0;
    memset(a,0,sizeof(a));
    MIN=2000000000;
    MAX=-2000000000;
    scanf("%d",&n);
    for (int i=0; i<n; ++i)
    {
        scanf("%d",&a[i]);
        if (a[i]>MAX) {MAX=a[i];maxflag=i;}
        if (a[i]<MIN) {MIN=a[i];minflag=i;}
    }
    printf("%d\n",2*n);
    if (MAX>=0 && MAX >= -MIN)
    {
        cout<<maxflag+1<<' '<<1<<endl;
        cout<<maxflag+1<<' '<<1<<endl;
        for (int i=0; i<n-1; ++i)
        {
           cout<<i+1<<' '<<i+2<<endl;
           cout<<i+1<<' '<<i+2<<endl;
        }
    }else
    {
        cout<<minflag+1<<' '<<n<<endl;
        cout<<minflag+1<<' '<<n<<endl;
        for (int i=n; i>1; --i)
        {
            cout<<i<<' '<<i-1<<endl;
            cout<<i<<' '<<i-1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	ld ans=(n/2+n%2)/(ld)n;
	cout<<fixed<<setprecision(10)<<ans;
}

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

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

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

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> a(H+2,vector<char>(W+2,'#'));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a.at(i+1).at(j+1);
    }
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout<<a.at(i).at(j);
    }
    cout<<endl;
  }
}

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

ll gcd(ll a, ll b) { return (b == 0)? a : gcd(b,a%b);}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() 
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    ll divc = b/c - a/c;
    ll divd = b/d - a/d;
    ll l = lcm(c,d);
    ll divcd = b/l - a/l;

    ll ans = (b-a) - divc - divd + divcd;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;
vector<int> g[4001];
int n;
inline int remain(const int& p,const int& r)
{
	static bool vis[4001];
	static int d[4001],top,ans,i,t;
	memset(vis,false,sizeof(bool)*(n<<1));
	queue<int> que;
	d[p]=0;
	que.push(p);
	vis[p]=true;
	ans=0;
	while(!que.empty())
	{
		top=que.front();
		if(d[top]>r)
		{
			return ans;
		}
		++ans;
		que.pop();
		for(i=0;i<g[top].size();++i)
		{
			t=g[top][i];
			if(!vis[t])
			{
				d[t]=d[top]+1;
				vis[t]=true;
				que.push(t);
			}
		}
	}
	return ans;
}
int main()
{
	int i,k,a,b,ans;
	scanf("%d%d",&n,&k);
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
		g[n+i].push_back(a);
		g[n+i].push_back(b);
	}
	ans=-1e9;
	if(k&1)
	{
		for(i=(n<<1)-1;i>n;--i)
		{
			ans=max(ans,remain(i,(k>>1)+1)-1);
		}
	}
	else
	{
		for(i=1;i<=n;++i)
		{
			ans=max(ans,remain(i,k>>1));
		}
	}
	printf("%d\n",n-ans);
	return 0;
}
/*
6 2
1 2
3 2
4 2
1 6
5 6
*/
/*
6 5
1 2
3 2
4 2
1 6
5 6
*/


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

namespace TYC
{
	const int N = 1e5 + 5, INF = 0x3f3f3f3f;

	int n, sumv, mxv, siz[N], col[N], F[N][2];
	char str[N];
	vector<int> E[N], T[N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	bool rebuild(const int u, const int f, int deg)
	{
		bool flag = col[u];
		for (int v : T[u])
			if (v != f && rebuild(v, u, 1))
			{
				E[u].push_back(v);
				deg++;
				flag = true;
			}
		if (!flag)
			n--;
		else
			sumv += (col[u] ^= (deg & 1));
		return flag;
	}

	inline int f(const int p) { return col[p] == 1 ? 1 : -1; }

	void dfs(const int u)
	{
		F[u][0] = F[u][1] = E[u].size() ? -INF : 0;
		for (int v : E[u])
		{
			dfs(v);
			mxv = max(mxv, F[u][0] + f(u) + F[v][1] + 1);
			mxv = max(mxv, F[v][0] + f(v) + F[u][1] + 1);
			F[u][0] = max(F[u][0], F[v][0] + f(v) + 1);
			F[u][1] = max(F[u][1], F[v][1] + f(u) + 1);
		}
		mxv = max(mxv, max(F[u][0], F[u][1]));
	}

	void work()
	{
		n = read();
		for (int i = 1; i < n; i++)
		{
			int u = read(), v = read();
			T[u].push_back(v);
			T[v].push_back(u);
		}
		scanf("%s", str + 1);
		int rot = 0, cnt = 0;
		for (int i = 1; i <= n; i++)
		{
			col[i] = str[i] == 'W';
			if (!rot && col[i])
				rot = i;
			cnt += col[i];
		}
		if (cnt <= 1)
			return void(printf("%d\n", cnt));
		rebuild(rot, 0, 0);
		dfs(rot);
		printf("%d\n", 2 * n - 2 + sumv - mxv);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 22016
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        String[] array = line1.split(" ");
        
        int n = Integer.parseInt(array[0]);
        int m = Integer.parseInt(array[1]);
        
        String[] answer = new String[n];
        for(int i = 0; i < n; i++)
        {
            answer[i] = "xx";
        }
        
        
        int right = 0;
        int wrong = 0;
        int waCount[] = new int[n];
        
        for(int i = 0; i < m; i++)
        {
            String buf = sc.nextLine();
            String[] array2 = buf.split(" ");
            
            int problemNo = Integer.parseInt(array2[0]) - 1;
            if(!(answer[problemNo].equals("AC")) && array2[1].equals("AC"))
            {
                right++;
                answer[problemNo] = "AC";
            }
            else if(!(answer[problemNo].equals("AC")) && array2[1].equals("WA"))
            {
                wrong++;
                answer[problemNo] = "WA";
                waCount[problemNo]++;
            }
        }
        
        for(int i = 0; i < n; i++)
        {
            if(answer[i] == "WA")
            {
                wrong -= waCount[i];
            }
        }
        
        System.out.println(right + " " + wrong);
    }
}


Measured memory_bytes: 110188
let s = read_line () in
let n = String.length s in
let d i = int_of_char s.[i] - int_of_char '0' in
let rec loop i prev mi =
    if i = n then mi else
        let cur = (prev * 10 + d i) mod 1000 in
        loop (i + 1) cur (min mi (abs (cur - 753)))
in
loop 2 (d 0 * 10 + d 1) 999 |> Printf.printf "%d\n"

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

using namespace std;
typedef unsigned long long ll;
const int MAXN = 1e3 + 5;
const int MAXD = 1e6 + 5;
const int MOD = 1e9 + 7;


int main() {

ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

unsigned long long a;
cin >> a;
long double b;
cin >> b;
long double fc = (b - (int)b);

unsigned long long Ans = (fc * a + (int)b * a);
cout << Ans ;

}

Measured memory_bytes: 3724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Q5
{
    class Program
    {
        static void Main(string[] args)
        {
            long divide = (long)Math.Pow(10, 9) + 7;
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int M = int.Parse(strs[1]);
            long[] S = new long[N];
            long[] T = new long[M];
            line = Console.ReadLine();
            strs = line.Split(' ');
            for (int i = 0; i < N; i++)
            {
                S[i] = long.Parse(strs[i]);
            }
            line = Console.ReadLine();
            strs = line.Split(' ');
            for (int i = 0; i < M; i++)
            {
                T[i] = long.Parse(strs[i]);
            }
            long count = 0;

            long[,] dp = new long[N, M];
            long[,] sum = new long[N, M];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    dp[i, j] = 0;
                }
            }
            for (int i = 0; i < N; i++)
            {
                for(int j = 0; j < M; j++)
                {
                    if (S[i] == T[j])
                    {
                        dp[i, j] = 1;
                        if (i > 0 && j > 0) dp[i, j] += sum[i - 1, j - 1];
                    }
                    sum[i, j] = dp[i, j];
                    if (i > 0 && j > 0) sum[i, j] -= sum[i - 1, j - 1];
                    if (i > 0) sum[i, j] += sum[i - 1, j];
                    if (j > 0) sum[i, j] += sum[i, j - 1];
                    if (sum[i, j] < 0) sum[i, j] += divide;
                    sum[i, j] %= divide;
                }
            }
            count = sum[N-1, M-1] + 1;
            Console.WriteLine(count % divide);
        }
    }
}


Measured memory_bytes: 73688
n = int(input())

data = list(map(int,input().split()))

s = 0

for i in range(n):
    s += data[i]
    data[i] = s

a = data[-1]
res = -1
for i in range(n-1):
    if res<0:
        res = abs(data[i]-(a-data[i]))
    else:
        res = min(res,abs(data[i]-(a-data[i])))
print(res)


Measured memory_bytes: 24812
n = int(input())
a = list(map(int, input().split()))
x = 1
if 0 in a:
    x = 0
    print(x)
else:
    for j in a:
        x = j*x
        if x > 10**18:
            x = -1
            break
        else:
            continue
    print(x)

Measured memory_bytes: 21580
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define ceili(x,y) (x+y-1)/y  
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  DV(P,lli,M,0,0);
  rep(i,0,N){
    cin >> X >> Y;
    if(X>M)continue;
    P[M-X].pb(Y);
  }
  priority_queue<lli> pque;
  rrep(i,M,0){
    for(auto j:P[i])pque.push(j);
    if(!pque.empty()){
      sum+=pque.top();pque.pop();
    }
  }
  Out(sum);
}


Measured memory_bytes: 5632
n = int(input())
a = [int(input()) for i in range(n)]
maxa = max(a)
seconda = a[:]
seconda.remove(maxa)
secondmaxa = max(seconda)
for i in range(0,n):
    if a[i] == maxa:
        print(secondmaxa)
    else:
        print(maxa)



Measured memory_bytes: 14076