akhauriyash/Code-Regression huggingface dataset:
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = sc.next()
  val q = sc.nextInt()
  val seg = new SegmentTree()
  seg.init(n)
  for (i <- 0 until n) {
    seg.update(i, 1 << (s(i) - 'a'))
  }
  for (i <- 0 until q) {
    val t = sc.nextInt()
    if (t == 1) {
      val i = sc.nextInt() - 1
      val c = sc.next()(0)
      seg.update(i, 1 << (c - 'a'))
    } else {
      val l, r = sc.nextInt() - 1
      println(bitCount(seg.query(l, r + 1, 0, 0, seg.n)))
    }
  }
  def bitCount(n: Int): Int = {
    var i = n
    i = i - ((i >>> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >>> 2) & 0x33333333)
    i = (i + (i >>> 4)) & 0x0f0f0f0f
    i = i + (i >>> 8)
    i = i + (i >>> 16)
    i & 0x3f
  }
  class SegmentTree {
    var n = 1
    val id = 0
    var node = Array[Int]()
    def init(sz: Int) {
      n = 1
      while (n < sz) n *= 2
      node = Array.fill(2 * n - 1)(id)
    }
    def update(i: Int, k: Int) = {
      var x = i + n - 1
      node(x) = k
      while (x > 0) {
        x = (x - 1) / 2
        node(x) = node(2 * x + 1) | node(2 * x + 2)
      }
    }
    def query(a: Int, b: Int, k: Int, l: Int, r: Int): Int = {
      if (r <= a || b <= l) {
        id
      } else if (a <= l && r <= b) {
        node(k)
      } else {
        val lv = query(a, b, 2 * k + 1, l, (l + r) / 2)
        val rv = query(a, b, 2 * k + 2, (l + r) / 2, r)
        (lv | rv)
      }
    }
  }
}


Measured memory_bytes: 58708
#include <stdio.h>

void call(int n)
{
    for (int i = 1; i < n + 1; ++i)
    {
        /* show number if it's a multiple of 3 or includes 3 in any digit */
        int show_number = !(i % 3);
        if (!show_number)
        {
            for (int x = i; !show_number && x; x /= 10)
            {
                show_number = (x % 10 == 3);
            }
        }
        if (show_number)
        {
            printf(" %d", i);
        }
    }
    printf("\n");
}

int main(int argc, char *argv[])
{
    int n;
    scanf("%d", &n);
    call(n);
    return 0;
}



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

int main(){
    int a[4];
    for (auto i = 0; i < 4; i++) {
        char tmp;
        cin >> tmp;
        a[i] = atoi(&tmp);
    }

    for (auto i = 0; i < (1 << 3); i++) {
        int sum = a[0];
        string s = to_string(a[0]);
        for (auto j = 1; j < 4; j++) {
            if(i & (1 << (j - 1))) {
                sum += a[j];
                s += "+" + to_string(a[j]);
            } else {
                sum -= a[j];
                s += "-" + to_string(a[j]);
            }
        }
        if(sum == 7) {
            cout << s << "=7" << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
n,t = map(int,input().split())
a = list(map(int,input().split()))
mdic = {}
mx = 0
import heapq
h = []
heapq.heappush(h,a[0])

for i in range(1,n):
    if mx == a[i]-h[0]:
        mdic[mx] += 1
    if mx < a[i]-h[0]:
        mx = a[i]-h[0]
        mdic[mx] = 1
    heapq.heappush(h,a[i])
#print(h[0])
mlist = sorted(list(mdic.items()))
#print(mlist)
print(mlist[-1][1])



Measured memory_bytes: 67436
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int n;
	cin >> n;
	vector<int> tor(n,-1);
	vector<int> toc(n,-1);
	bool can=true;
	for(int i=0;i<n;i++)
	{
		int r,c;
		cin >> r >> c;
		r--;c--;
		if(tor[r]!=-1)
		{
			can=false;
		}
		if(toc[c]!=-1)
		{
			can=false;
		}
		tor[r]=c;
		toc[c]=r;
	}
	if(!can)
	{
		cout << -1 << endl;
		return 0;
	}

	int cnt=0;
	vector<bool> done(n,false);
	for(int i=0;i<n;i++)
	{
		if(done[i]==true)continue;
		cnt++;
		int nx=tor[i];
		while(true)
		{
			done[nx]=true;
			nx=tor[nx];
			if(done[nx]==true)
				break;
		}
	}
	int ans=n-cnt;
/*
	cnt=0;
	done=vector<bool>(n,false);
	for(int i=0;i<n;i++)
	{
		if(done[i]==true)continue;
		cnt++;
		int nx=toc[i];
		while(true)
		{
			done[nx]=true;
			nx=toc[nx];
			if(done[nx]==true)
				break;
		}
	}
	ans=min(ans,n-cnt);
*/
	cout << ans << endl;

}


Measured memory_bytes: 3612
program main
  implicit none
  integer i, N
  integer(8) A(10**5), A_abs(10**5), ans
  integer n_minus, min_zettaichi
  
  read(*, *) N
  read(*, *) (A(i), i=1,N)
  n_minus = 0 !0,minusが0,2,4   1,minusが1,3,5
  min_zettaichi = abs(A(1))

  A_abs = abs(A)
  
  do i = 1,N
    if (abs(A(i)) < min_zettaichi) then
      min_zettaichi = abs(A(i))
    end if
    if (A(i) < 0) then
      n_minus = 1-n_minus
    end if
  end do

  ans = sum(A_abs) - 2*n_minus*min_zettaichi
  
  write(* ,'(i0)') ans
end program main


Measured memory_bytes: 2304
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  b = list(int(i) for i in input().split())
  c = list(int(i) for i in input().split())
  ans = 0
  preryouri = -3
  for i in range(n):
    ryouri = a[i]-1
    ans += b[ryouri]
    if ryouri-preryouri == 1:
      ans += c[preryouri]
    preryouri = ryouri
  print(ans)
solve()

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int count = 0;
    int length = S.length();

    for(int i = 0; i < length/2; i++){
      char a = S.charAt(i);
      char b = S.charAt(length - 1 -i);

      if(!(a == b)){
        count++;
      }
    }
    System.out.println(count);
  }
}

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

long long n, ans, a[8005], c[5][8005];
string s;
int main() {
	int i, j, x;
	cin >> n >> s;
	for(i=n-1; i>=0; i--) {
		if(s[i]=='R') a[i]=1, c[1][i]=1;
		else if(s[i]=='G') a[i]=2, c[2][i]=1;
		else a[i]=3, c[3][i]=1;
	}
	for(i=1; i<=3; i++) for(j=n-1; j>=0; j--) c[i][j] += c[i][j+1];
	for(i=0; i<n-2; i++) {
		for(j=i+1; j<n-1; j++) {
			if(s[i] == s[j]) continue;
			x = 6 - a[i] - a[j];
			ans += c[x][j+1];
			if(a[2*j-i]==x) ans--;
		}
	}
	cout << ans;
	return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

const VI prm ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	VI v(105), dp(78);
	for(auto p: prm){
		for(ll w = n; w>0; w/=p) v[p] += w/p;
	}
	dp[1] = 1;
	rep(i, 76){
		VI np(78);
		rep(j, 76) rep(k, v[i]+1) if(j *(k+1) <=75) np[j *(k+1)] += dp[j];
		swap(np, dp);
	}
	cout << dp[75] <<"\n";
	return 0;
}


Measured memory_bytes: 256
N, W = gets.split.map(&:to_i)
dp = Array.new(W+1, 0)
N.times do
  tmp = dp.dup
  w, v = gets.split.map(&:to_i)
  w.upto(W) do |ww|
    vv = dp[ww - w] + v
    tmp[ww] = vv if vv > dp[ww]
  end
  dp = tmp
end
puts dp.last


Measured memory_bytes: 69004
import sys
rl = sys.stdin.buffer.readline


def solve():
    N, M = map(int, rl().split())
    graph = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x: int(x) - 1, rl().split())
        graph[a].add(b)
        graph[b].add(a)
    
    for child in graph[0]:
        if N - 1 in graph[child]:
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')


if __name__ == '__main__':
    solve()


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var x = r[0].ToInt64();
            var y = r[1].ToInt64();
            var ans = Combination((x + y) / 3, (2 * y - x) / 3);
            if ((x + y) % 3 != 0 || x > 2 * y || y > 2 * x) ans = 0;
            WriteRead(ans);
        }

        private static long mod = 1000000007;

        public static long ModPow(long x, long n)
        {
            x = x % mod;
            if (n == 0)
            {
                return 1;
            }
            else if (n % 2 == 1)
            {
                return (x * ModPow(x, n - 1)) % mod;
            }
            else
            {
                return ModPow((x * x) % mod, n / 2) % mod;
            }
        }

        public static long Combination(long n, long k)
        {
            long x = 1;
            for (long i = n - k + 1; i <= n; i++)
            {
                x = x * i % mod;
            }
            long y = 1;
            for (int i = 1; i <= k; i++)
            {
                y = y * i % mod;
            }
            y = ModPow(y, mod - 2);
            return x * y % mod;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
        public static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToInt64(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



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

int main(){
	int A, B; cin >> A >> B;

	int ans = 0;
	for (int i=A; i<B+1; i++){
		int temp1 = i%10;
		int temp2 = (i/10)%10;
		int temp3 = (i/1000)%10;
		int temp4 = (i/10000)%10;

		if (temp1 == temp4 && temp2 == temp3)
			ans++;
	}

	cout << ans << endl;
}

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

#define LL long long

const LL INF = 4*1e9+10;

LL a[400010];

int main() {
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; ++i) {
		scanf("%lld", &a[i]);
		a[i] += a[i-1];
	}

	LL ans = INF;
	for (int i=1; i<n; ++i) {
		ans = min(ans, abs(a[n]-2*a[i]));
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

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

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 = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  ll l, r;
  cin >> l >> r;

  ll ans = 2018;
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      chmin(ans, (i * j) % 2019);
      if (ans == 0) break;
    }
    if (ans == 0) break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

void solveAndOutput(LL x,LL y){
	int step = 0;
	while (y != 0){
		step++;
		x = x%y;
		swap(x, y);
	}
	cout << x << " " << step << endl;
}

int main(){
	fastIO;
	LL x = 0, y = 0;
	while (cin >> x >> y, x || y){
		if (x < y)	swap(x, y);
		solveAndOutput(x, y);
	}
	return 0;
}

Measured memory_bytes: 1196
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		
		String A[] =new String[N];
		for(int i=0;i<N;i++){
            A[i]=sc.next();
            
        }
		String ans="";
		
		Arrays.sort(A);
		
		for(int i=0;i<N;i++){
            ans+=A[i];
            
        }
        
        
        System.out.println(ans);
		
		
		
	}
}


Measured memory_bytes: 40224
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string S;
    cin >> S;

    map<char, int> mp;
    rep(i, S.size()) {
        mp[S[i]]++;
    }

    char res = '#';
    rep(i, 26) {
        if(mp[char('a'+i)]==0) {res = 'a'+i; break;}
    }

    if(res == '#') cout << "None";
    else cout << res;
    
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n, m;
  cin >> n >> m;
  vec a(m), b(m);
  REP(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  vec c(n, 0);
  REP(i, m){
    c[a[i]]++;
    c[b[i]]++;
  }

  REP(i, n){
    cout << c[i] << endl;
  }

  return 0;
}

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

double dist_Minkowski(const vector<double> &x, const vector<double> &y, int p){
    if(p == 0){
        double temp = 0;
        for(int i = 0; i < (int)x.size(); i++){
            if(abs(x[i] - y[i]) > temp) temp = abs(x[i] - y[i]);
        }
        return temp;
    }
    double temp = 0;
    for(int i = 0; i < (int) x.size(); i++){
        temp += pow(abs(x[i] - y[i]), (double)p);
    }
    return pow(temp, 1 / (double)p);
}
int main(){
    int n; cin >> n;
    vector<double> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    printf("%.10f\n", dist_Minkowski(a, b, 1));
    printf("%.10f\n", dist_Minkowski(a, b, 2));
    printf("%.10f\n", dist_Minkowski(a, b, 3));
    printf("%.10f\n", dist_Minkowski(a, b, 0));
}


Measured memory_bytes: 3400
N, M, X, Y = map(int, input().split())
x = max([int(x) for x in input().split()])
y = min([int(y) for y in input().split()])

if (X >= Y):
    print('War')
    exit()

for z in range(X+1, Y+1, 1):
    if x < z and z <= y:
        print('No War')
        break
else:
    print('War') 


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 200000
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int n, A[MAXN+5], X[MAXN+5]; ll S[MAXN+5], Ans;
int main()
{
	n = read(); for(rint i = 1; i <= n; A[i++] = read()); for(rint i = 1; i <= n; S[i] = S[i-1]+A[i], X[i] = X[i-1]^A[i], i++);
	for(rint i = 1, lef, rig, mid, j; i <= n; i++)
	{
		for(j = lef = i, rig = n; lef <= rig; mid = (lef+rig)>>1, S[mid]-S[i-1]==(X[mid]^X[i-1])?j=mid,lef=mid+1:rig=mid-1);
		Ans += j-i+1;
	}	cout << Ans << endl;

	return 0;
}

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

int main(){
	int a;
	double b;
	cin>>a;
	if(a%2==1){
		b=1.0*(a/2+1)/a;
		cout<<b<<endl;
	}
	else{
		b=0.5;
		cout<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
using namespace std;
 
int main(){
    long long N, j;
    cin >> N;
    for(long long i = sqrt(N); i > 0; i--){
        if(N % i == 0){
            j = N/i;
            cout << i + j - 2 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from collections import Counter

n = int(input())
a = [0] + list(map(int, input().split()))
cumsum = np.cumsum(a)
c = Counter(cumsum)
cnt = 0
for i in c.values():
    if i > 1:
        cnt += int(i * (i-1) / 2)
print(cnt)

Measured memory_bytes: 60728
# -*- coding: utf-8 -*-
class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret


N, K = map(int, input().split())
L = list(map(int, input().split()))
L = sorted(L)
MOD = 10**9+7
F = FactMod(N+1, MOD)

sub = 0
add = 0
for i in reversed(range(K-1, N)):
    add += L[i]*F.comb(i, K-1)
    sub += L[N-i-1]*F.comb(i, K-1)

print((-sub+add+MOD) % MOD)


Measured memory_bytes: 14936
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int read() {
	char ch;int sig=1;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar()) if (ch=='-') sig=-1;
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*sig;
}

const int N=2e5+5,M=1e6+5;

int t[M],nxt[M],lst[N],l;

void add(int x,int y) {
	t[++l]=y;nxt[l]=lst[x];lst[x]=l;
	t[++l]=x;nxt[l]=lst[y];lst[y]=l;
}

int n,rt1,rt2,S;
bool odd[N];

void dfs(int x,int y) {
	odd[x]=1;
	for(int i=lst[x];i;i=nxt[i])
		if (t[i]!=y) {
			dfs(t[i],x);
			odd[x]^=1;
		}
}

int b[M],an[N],top;
bool vis[M];


void find(int x) {
	for(int i=lst[x];i;i=lst[x]) {
		lst[x]=nxt[i];
		if (!vis[i]) {
			vis[i]=vis[i^1]=1;
			find(t[i]);
		}
	}
	b[++top]=x;
}

int main() {
	n=read();l=1;
	fo(i,1,n) {
		int x=read();
		if (x==-1) rt1=i;
		else add(x,i);
	}
	fo(i,n+1,n*2) {
		int x=read();
		if (x==-1) rt2=i;
		else add(x+n,i);
	}
	dfs(rt1,0);dfs(rt2,0);
	bool ok=1;
	fo(i,1,n)
		if (odd[i]^odd[i+n]) {
			ok=0;
			break;
		}
	if (!ok) {
		puts("IMPOSSIBLE");
		return 0;
	}
	puts("POSSIBLE");
	S=n*2+1;
	add(S,rt1);add(S,rt2);
	fo(i,1,n) if (odd[i]) add(i,i+n);
	find(S);
	fo(i,1,n) if (odd[i]) an[i]=-1;
	fo(i,1,top-1) if (b[i]<=n&&b[i+1]==b[i]+n) an[b[i]]=1;
	fo(i,1,n) printf("%d ",an[i]); 
	return 0;
}

Measured memory_bytes: 23296
#include <iostream>
#include <string>
using namespace std;
int w, h;
string field[101];

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

void dfs(char c, int x, int y) {
	if (x < 0 || w <= x || y < 0 || h <= y) return;
	if (c != field[y][x]) return;
	field[y][x] = 'x';
	for (int i = 0; i < 4; i++) {
		dfs(c, x + dx[i], y + dy[i]);
	}
}

int main() {
	while (cin >> h >> w, w || h) {
		for (int i = 0; i < h; i++) {
			cin >> field[i];
		}
		int count = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (field[i][j] != 'x') {
					dfs(field[i][j], j, i);
					count++;
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 2000
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         rep1(i,n)       for (int i = 1;i<(int)(n);i++)
#define         pi             3.14159265359
#define         nl             printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int ll;

int main()
{

    FIO;
    int i,j,k,temp,n,f=0,ans=0;
    cin>>n;
    int arr[n];
    rep(i,n)
        cin>>arr[i];
    sort(arr,arr+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if((arr[i]+arr[j])>arr[k])
                    ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct num{
	long long aaa,bbb,ccc;
};
vector<num> vec;
vector<long long> vec2;
long long check[10000005] = {0};
long long prime[10000005] = {0};
int main(){
    int pos=0;
    int flag;
    for (int i = 2 ; i < 10000002 ; i++)
    {
        if (!check[i])
            prime[pos++] = i;

        for (int j = 0 ; j < pos && i*prime[j] <10000002 ; j++)
        {
            check[i*prime[j]] =prime[j];
            if (i % prime[j] == 0)
                break;
        }
    }
    long long n;
    cin>>n;
	long long ss=0;
	for(long long i=1;i<=n;i++){
		if(i==1){
			ss+=1;
			continue;
		}
		int q=i;
		int p=1;
		if(check[i]==0){
			num h;
			h.aaa=1;
			h.bbb=i;
			h.ccc=1;
			vec.push_back(h);
		}else{
			if(vec[q/check[i]-2].bbb==check[i]){
				num h;
				h.aaa=vec[q/check[i]-2].aaa;
				h.bbb=vec[q/check[i]-2].bbb;
				h.ccc=vec[q/check[i]-2].ccc+1;
				vec.push_back(h);
			}else{
				num h;
				h.aaa=vec[q/check[i]-2].aaa*(vec[q/check[i]-2].ccc+1);
				h.bbb=check[i];
				h.ccc=1;
				vec.push_back(h);
			}
		}
		ss+=vec[i-2].aaa*i*(vec[i-2].ccc+1);
	}
	cout<<ss<<endl;
}


Measured memory_bytes: 479976
#include<iostream>
using namespace std;
int main()
{
	int n,k,ans=1,i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		if(ans>k)
		ans+=k;
		else
		ans+=ans;
	}
	cout<<ans<<endl;
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,ans;
    cin>>n>>m;
    char ma[n+1][m+1];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        cin>>ma[i][j];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(ma[i][j]=='#')cout<<"#";
            else if(ma[i][j]=='.')
            {
                ans=0;
                if(ma[i-1][j-1]=='#')ans++;
                if(ma[i-1][j]=='#')ans++;
                if(ma[i-1][j+1]=='#')ans++;
                if(ma[i][j-1]=='#')ans++;
                if(ma[i][j+1]=='#')ans++;
                if(ma[i+1][j-1]=='#')ans++;
                if(ma[i+1][j+1]=='#')ans++;
                if(ma[i+1][j]=='#')ans++;
                cout<<ans;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{	
	char S[105],T[105],s[210]; int k,i;
	while(scanf("%s%s",&S,&T)!=EOF){
		int t=0,f=0;
		k=strlen(S);
		for(i=0;i<2*k;i++){
			if(i<k) s[i]=S[i];
			else s[i]=S[i-k];
		}
		for(i=0;i<2*k;i++){
			if(T[t]==s[i]) t++;
			else t=0;
			if(t==k) {f=1;break; }
		}
		if(f) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
def dfs(s):
    if int(s) > N:
        return 0
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    else:
        ret = 0
    for c in '753':
        ret += dfs(s+c)
    return ret

print(dfs('0'))

Measured memory_bytes: 2940
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let s: String = read();
    let c: Vec<i32> = s.into_bytes().iter().map(|c| (c - b'0') as i32).collect();

    for p in 0..8 {
        let ops = ops(p);
        let ans = compute(&c, &ops);
        if ans == 7 {
            println!("{}", make(&c, &ops));
            break;
        }
    }
}

fn make(c: &Vec<i32>, ops: &Vec<char>) -> String {
    format!("{}{}{}{}{}{}{}=7", c[0], ops[0], c[1], ops[1], c[2], ops[2], c[3])
}

fn compute(c: &Vec<i32>, ops: &Vec<char>) -> i32 {
    let mut total = c[0];
    for i in 1..4 {
        if ops[i-1] == '+' {
            total += c[i];
        } else {
            total -= c[i];
        }
    }
    // println!("{:?} {:?} {}", c, ops, total);
    total
}

fn ops(p: usize) -> Vec<char> {
    let mut v = vec![];
    for i in 0..3 {
        if p & (1<<i) == 0 {
            v.push('+');
        } else {
            v.push('-');
        }
    }
    v
}

Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int n, m, c[20];
  int dp[50001];

  scanf("%d%d", &n, &m);
  for (int i = 0;i < m;i++) {
    scanf("%d", &c[i]);
  }
  for (int i = 0;i <= n;i++) {
    dp[i] = 1000000;
  }

  dp[0] = 0;
  for (int i = 1;i <= n;i++) {
    for (int j = 0;j < m;j++) {
      if (c[j] <= i) {
        dp[i] = min(dp[i], dp[i - c[j]] + 1);
      }
    }
  }

  printf("%d\n", dp[n]);

  return 0;
}



Measured memory_bytes: 2916
#!/usr/bin/env python3
# coding: utf-8
import math
# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    A, B, H, M = map(int, input().split())

    vh = ((H * 60 + M) / (12 * 60))
    vm = (M / 60)

    theta = (vh - vm) * math.tau
    d = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))

    print(d)

if __name__ == "__main__":
    main()


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

int main()
{
  long long a, b, c;

  cin >> a >> b >> c;

  if (a + b >= c)
  {
    cout << "Yes" << endl;
  }
  else 
  {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
n, m = map(int, input().split())
bad = []
for i in range(m):
    bad.append(int(input()))
dp = [0 for x in range(n+1)]
dp[0] = 1
idx = 0
if m > 0 and bad[0] == 1:
    dp[1] = 0
    idx = 1
else:
    dp[1] = 1

for i in range(2, n+1):
    if idx < m and i == bad[idx]:
        dp[i] = 0
        idx+=1
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[n])





Measured memory_bytes: 13704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for(char& c : s) {
        if(c == '?') c = 'D';
    }
    cout << s << endl;
}

Measured memory_bytes: 3764
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;


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

  int n, h, w;
  cin >> n >> h >> w;

  int a, b, out = 0;
  for(int i=0; i<n; ++i){
    cin >> a >> b;
    if(a >= h && b >= w)
      ++out;
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
x,k,d=map(int,input().split())

dcnt=abs(x)//d
if abs(x)%d <= abs(abs(x)%d-d):
    dans=abs(x)%d
else:
    dans=abs(abs(x)%d-d)
    dcnt+=1


if dcnt<k:
    if (k-dcnt)%2==0:
        print(abs(dans))
    else:
        print(abs(dans-d))


else:
    print(abs(x)-d*k)


Measured memory_bytes: 9100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String buffer[] = new String[2];
        int N,X,ans;
 
        while(true){
 
            try {
                buffer = br.readLine().split("\\s+");
                N = Integer.parseInt(buffer[0]);
                X = Integer.parseInt(buffer[1]);
 
                if(N == 0 && X == 0)break;
 
                ans = 0;
 
                for(int a = 1; a <= N-2; a++){
                    for(int b = a+1; b <= N-1; b++){
                        for(int c = b+1; c <= N; c++){
                            if(a+b+c == X){
                                ans++;
                            }
                        }
                    }
                }
 
                System.out.printf("%d\n", ans);
 
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


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

int main(){
  int64_t a, b, c;
  cin >> a >> b >> c;
  string out = "No";

  int64_t P = c-a-b;
  if(P>0 && 4*a*b<P*P){
    out = "Yes";
  }

  cout << out << endl;

  return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

void solve(long long N, long long M, std::vector<long long> s,
           std::vector<long long> c) {
    for(int i = 0 ; i < 1000 ; i++){
        stringstream ss;
        ss << i;
        string S = ss.str();
        if( S.size() == N ){
            bool f = true;
            for(int j = 0 ; j < M ; j++){
                if(S[s[j]-1] == c[j] + '0') continue;
                f = false;
            }
            if(f){
                cout << i << endl;
                return;
            }
        }
    }
    cout << -1 << endl;
}

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


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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int s[M], c[M];
    int ans[N];
    for (int i = 0; i < N; i++)
    {
        ans[i] = -1;
    }

    for (int i = 0; i < M; i++)
    {
        cin >> s[i] >> c[i];
    }
    for (int i = 0; i < M; i++)
    {
        if (ans[s[i] - 1] == -1)
        {
            ans[s[i] - 1] = c[i];
        }
        else if (ans[s[i] - 1] != c[i])
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    if (ans[0] == 0 && N > 1)
    {
        cout << "-1" << endl;
        return 0;
    }
    if (ans[0] == -1 && N == 1)
    {
        ans[0] = 0;
        cout << ans[0] << endl;
        return 0;
    }
    if (ans[0] == -1)
    {
        ans[0] = 1;
    }
    for (int i = 1; i < N; i++)
    {
        if (ans[i] == -1)
        {
            ans[i] = 0;
        }
    }
    for (int i = 0; i < N; i++)
    {
        cout << ans[i];
    }
    cout << endl;
}

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

int main(){
	int n, k;
  	cin>>n>>k;
	
  	long long int cnt=0;
  	long long int sum=0;
  	for(long long int i=k;i<=n+1;i++){
    	long long int n1=i*(i-1)/2, n2=i*(2*n-(i-1))/2;
      	cnt+=(n2-n1)+1;
      	if(cnt>NUM){
        	sum+=cnt%NUM;
          	cnt=0;
        }
    }
  	sum+=cnt;
  	
  	cout<<sum%NUM<<endl;
  	return 0;
}


Measured memory_bytes: 3612
'use strict';

const lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

let aCards = lines[0].split("");
let bCards = lines[1].split("");
let cCards = lines[2].split("");

function moveAnotherMan(someoneCards) {
  if (someoneCards.length === 0) {
    anyoneWin(someoneCards);
    return;
  }
  switch (someoneCards[0]) {
    case "a":
      someoneCards.shift();
      moveAnotherMan(aCards);
    break;
    case "b":
      someoneCards.shift();
      moveAnotherMan(bCards);
    break;
    case "c":
      someoneCards.shift();
      moveAnotherMan(cCards);
    break;
  }
};

function anyoneWin(who) {
  if (who===aCards) {
    console.log("A");
  }
  if (who===bCards) {
    console.log("B");
  }
  if (who===cCards) {
    console.log("C");
  }
}

moveAnotherMan(aCards);

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int x, y, dx, dy, maxl, tx, ty;
    int n; cin >> n;
    rep(j, n)
    {
        x = y = tx = ty = maxl = 0;
        while(cin >> dx >> dy && (dx || dy))
        {
            x += dx;
            y += dy;
            if( x * x + y * y > maxl) { tx = x; ty = y; maxl = x * x + y * y;}
            if(x * x + y * y == maxl && x > tx) {tx = x; ty = y;}
        }
        cout << tx << " " << ty << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
n = int(input())
s = input()

count = {"R":0,"G":0,"B":0}
for c in s:
    count[c] += 1

r,g,b = count.values()
ans = r*g*b
for i in range(1,(n-1)//2+1):
    for rgb in zip(s,s[i:],s[i*2:]):
        if len(set(rgb)) == 3:
            ans -=1
print(ans)


Measured memory_bytes: 9196
n=int(input())
lst=list(map(int,input().split()))

count=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if lst[j]<lst[minj]:
            minj=j
    if i!=minj:
        lst[i],lst[minj]=lst[minj],lst[i]
        count+=1

print(" ".join(map(str,lst)))
print(count)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k;
    string s;
    cin>>k>>s;
    int size=s.size();
    if (size<=k) {
        cout<<s<<endl;
    } else {
        for (int i=0;i<k;i++) {
            cout<<s.at(i);
        }
        cout<<"..."<<endl;
    }
}

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

int main()
{
	string s;
	string p;
	cin >> s >> p;
	s += s;
	string::size_type index = s.find(p);
	if (index == string::npos) {
		cout << "No" << endl;
	}else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#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>;
const int INF = 1 << 30;
 
int main() {
	int n, m;
	cin >> n;
	map<string, int> blue, red;
	set<string> wordR;
	rep(i, n) {
		string a; cin >> a; 
		blue[a]++;
		wordR.insert(a);
	} 
	cin >> m;
	rep(i, m) {
		string a; cin >> a; red[a]++;
	}
	int ans = 0;
	for (auto s: wordR) {
		ans = max(ans, blue[s]-red[s]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define radhey krishna
#define endl "\n"

 
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
       ios_base::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("river.in", "r", stdin);
	//freopen("river.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin>>x;
	if(x>=400 && x<=599){
		cout<<8<<endl; 
	}
	else if(x>=600 && x<=799){
		cout<<7<<endl;
	}
	else if(x>=800 && x<=999){
		cout<<6<<endl;
	} 
	else if(x>=1000 && x<=1199){
		cout<<5<<endl;
	}
	else if(x>=1200 && x<=1399){
		cout<<4<<endl; 
	}  
	else if(x>=1400 && x<=1599){
		cout<<3<<endl;
	}
	else if(x>=1600 && x<=1799){
		cout<<2<<endl;
	}
	else{
		cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 2e5+9;
ll n,k,a[inf];

int main(){

    cin>>n>>k;
    for(ll i=1;i<=n;i++)
        cin>>a[i];

    ll l = 0 , r = 1e9;
    while(r-l > 1){
        ll mid = l + (r-l)/2ll,sum = 0;
        for(ll i=1;i<=n;i++)
            sum += a[i]/mid + ( (a[i]%mid) > 0) -1;
        if(sum <= k )
            r = mid;
        else
            l = mid;
    }
    cout<<r<<endl;
}



Measured memory_bytes: 5156
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

string s;

void init() {
}

void input() {
	cin >> s;
}

void solve() {
	int ptr = SZ(s)-1;
	while(ptr >= 0){
		if(ptr >= 4 && s.substr(ptr-4, 5) == "dream") ptr -= 5;
		else if(ptr >= 6 && s.substr(ptr-6, 7) == "dreamer") ptr -= 7;
		else if(ptr >= 4 && s.substr(ptr-4, 5) == "erase") ptr -= 5;
		else if(ptr >= 5 && s.substr(ptr-5, 6) == "eraser") ptr -= 6;
		else {
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

int main() {
	init();
    input();
    solve();
	return 0;
}








Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    int n; cin >> n;
    ll res = INF;
    rep(i,n){
        ll a; cin >> a;
        if(i==0)res = a;
        else res = __gcd(res,a);
    }
    cout << res << endl;
}

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

using namespace std;
int n,l[100005],r[1000005],a[100005];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>l[i]>>r[i];
	for(int i=1;i<=n;i++)
	{
		if(r[i]>l[i]) swap(r[i],l[i]);
		for(int j=r[i];j<=l[i];j++)
			a[j]++;
	}
	int ans=0;
	for(int i=1;i<=100000;i++)
		if(a[i]>0) ans++;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

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

int x[100010][26];

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

    int len = s.length();

    if(((s[0] == s[len-1]) + (len % 2 == 0)) % 2 == 0){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }


    return 0;
}

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

int main(){
  long long H, W;
  cin >> H >> W;
  if(H == 1 || W == 1) cout << 1 << endl;
  else if(H % 2 == 0 || W % 2 == 0){
    cout << H * W / 2 << endl;
  }
  else cout << H * W / 2 + 1 << endl;
  return 0;
}


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

int main(int argc, char** argv){
  int N;
  cin >> N;
  long long A[2*N];
  for(long long cnt0=0; cnt0 < N; cnt0++){
    cin >> A[cnt0];
    A[cnt0+N] = A[cnt0];
  }
  
  long long B[N];
  long long sole = 0;
  long long solo = 0;
  for(int cnt0=0; 2*cnt0<N; cnt0++){
    sole += A[2*cnt0];
  }
  for(int cnt0=0; 2*cnt0<N-1; cnt0++){
    sole -= A[2*cnt0 + 1];
  }
  for(int cnt0=1; 2*cnt0<N; cnt0++){
    solo -= A[2*cnt0];
  }
  for(int cnt0=0; 2*cnt0<N; cnt0++){
    solo += A[2*cnt0 + 1];
  }
  
  B[0] = sole;
  B[1] = solo;
  
//  printf("%lld\n", B[0]);
//  printf("%lld\n", B[1]);
  
  for(int cnt0=1; 2*cnt0<N+1; cnt0++){
    sole += 2*A[2*cnt0-1];
    sole -= 2*A[2*cnt0-2];
    B[2*cnt0] = sole;
    solo += 2*A[2*cnt0];
    solo -= 2*A[2*cnt0-1];
    B[2*cnt0+1] = solo;
  }
  
  printf("%lld", B[0]);
  for(int cnt0=1; cnt0 < N; cnt0++) printf(" %lld", B[cnt0]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	int mis = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] != i + 1) mis++;
	}
	printf("%s\n", (mis <= 2)? "YES" : "NO");
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

ll solve() {
    vector<ll> d = divisor(n);
    ll res = 0;
    for (ll v : d) {
        ll c = n / v - 1;
        if (c > v) res += c;
    }
    return res;
}

void input() {
    cin >> n;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 384