akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+100;
vector<int>ve[N];
int ans[N];
int vis[N];
queue<int>q;
void bfs()
{

    q.push(1);
    vis[1]=1;
    while(q.size()){
        int k=q.front();q.pop();
        for(auto v:ve[k]){
            if(!vis[v]){
                ans[v]+=ans[k];
                vis[v]=1;
                q.push(v);
            }
        }
    }
}
int main()
{
     ios::sync_with_stdio(0);cin.tie(0);
     int n,q;
     cin>>n>>q;
     for(int i=1;i<=n-1;i++){
         int a,b;
         cin>>a>>b;
         ve[a].push_back(b);
         ve[b].push_back(a);
     }
     for(int i=1;i<=q;i++){
        int a,b;
        cin>>a>>b;
        ans[a]+=b;
     }
     bfs();
     for(int i=1;i<=n;i++){
        cout<<ans[i]<<" ";
     }
     return 0;
}


Measured memory_bytes: 17360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 1e9 + 7;
const ll maxn = 200005;
const ll N = 500005;
char s[10]; 
void solve(){
	
}
int main(){  
	cin.tie(0); 
    ios::sync_with_stdio(false);
	/*int T,n,m,k,sum=0;
	scanf("%d",&T); 
	while(T--){
		//solve();	
		
	}*/
	int a=0,b=0;
	scanf("%s",s);
	for(int i=0;i<3;i++){
		if(s[i]=='A') a++;
		if(s[i]=='B') b++;
	}
	if(a==0||b==0) printf("No");
	else printf("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e6;
int f[N];
int main(){
    int n,ans=1e9; cin>>n;
    for (int i=1; i<=n; ++i)
	f[i]=f[i/10]+i%10;
    for (int i=1; i<n; ++i)
	ans=min(ans,f[i]+f[n-i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    long n,k;
    cin >> n >> k;
    vector<long> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    long ans = 0;
    for(int i = 0;i < n - k;i++){
        ans += a[i];
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
N,K = map(int,input().split())
H = list(map(int,input().split()))
 
ans = [10**10 for i in range(N+1)]
ans[0],ans[1] = 0,0
for i in range(1,N+1):
    for k in range(1,K+1):
        if i-k > 0:
            ans[i] = min(ans[i-k]+abs(H[i-1]-H[i-k-1]),ans[i])
print(ans[-1])

Measured memory_bytes: 56160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println( (A <= C && C <= B) ? "Yes":"No");
    }
}


Measured memory_bytes: 23764
//       BAAP IZ HERE           //
#include<bits/stdc++.h>
using namespace std;
#define gcd __gcd
#define lli long long int
#define jmd ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main()
{
    jmd; lli a[5]; lli pos=0;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
            pos = i+1;
    }
    cout<<pos;
}


Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
bool is_polyndrom(int n){
    vi a;
    while(n > 0){
        a.pb(n % 10);
        n /= 10;
    }
    for(int i = 0; i < a.size(); i++){
        if(a[i] != a[a.size()-i-1]) return false;
    }
    return true;
}
int main(){
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(is_polyndrom(i))cnt++;
    }
    cout << cnt;
}

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

int main(void){
	int i=1;
	int x;
	int n;

	cin >> n;
	if(n<=10000){
		while(i<=n){
			x=i;
			if(x%3==0){
				cout << " " << i;
				i++;
				continue;
			}
			while(x){
				if(x%10==3){
					cout << " " << i;
					break;
				}
				x/=10;
			}
			if(x%10==3){
				i++;
				continue;
			}
			i++;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    /*
    string a, b;
    cin >> a >> b;
    bool ans = false;
    for (int i=0; i<b.size(); ++i){
        if (a == b){
            ans = true;
            break;
        }
        b = b.back() + b.substr(0, b.size()-1);
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    */
   string s,t; cin >> s >> t;
   for(int i=0; i<s.size(); ++i){
       s = s.back() + s.substr(0,s.size()-1);
       if(s == t){
           break;
       }
   }
   if(s == t){
       cout << "Yes" << endl;
   }else{
       cout << "No" <<  endl;
   }
}

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

int gcd(int a, int b) {
  if (a > b) {
    ll tmp = b;
    b = a;
    a = tmp;
  }
  int r = b % a;
  while (r != 0) {
    b = a;
    a = r;
    r = b % a;
  }
  return a;
}

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v;
  v.push_back(x);
  rep(i, n) {
    int num;
    cin >> num;
    v.push_back(num);
  }
  sort(v.begin(), v.end());
  if (n == 1) {
    cout << v[1] - v[0] << endl;
  } else {
    int l = gcd(v[1] - v[0], v[2] - v[1]);
    rep(i, n - 1) l = gcd(l, v[i + 1] - v[i]);
    cout << l << endl;
  }
  return 0;
}


Measured memory_bytes: 892
import sys

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

count = 0
min = P[0]
for i in range(N):
    if P[i] <= min:
        min = P[i]
        count += 1
    """
    else:
        for j in range(i+1):
            if P[i] > P[j]:
                break
        else:
            count += 1
    """
print(count)

Measured memory_bytes: 24432
#include<stdio.h>
int main(){
	int r,g,b;
    scanf("%d" "%d" "%d",&r,&g,&b);
	
		
		if((r*100+g*10+b) % 4 == 0){
			printf("YES");
			printf("\n");
		}else{
			printf("NO");
			printf("\n");
		}						

	return 0;
}   

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

#define int long long
#define endl '\n'

const int N = 1e5 + 5;

vector<int> a(N);

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    int sum = 0;
    for (int i = 0, x; i < n; i++)
        cin >> x, a[x]++, sum += x;
    int q; cin >> q;
    while (q--) {
        int b, c; cin >> b >> c;
        sum -= b * a[b];
        sum += c * a[b];
        a[c] += a[b];
        a[b] = 0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
#define llong long long
int n,m;
int c[100100],b[100100];
struct data{
    int to,nxt;
}mp[200200];
int head[100100],cnt;
void link(int x,int y)
{
    mp[++cnt].to=y;
    mp[cnt].nxt=head[x];
    head[x]=cnt;
}
int ed[100100][2],ted;

struct UFS{
    int fa[100100];
    void reset(){for(int i=1;i<=n;++i)fa[i]=i;}
    int f(int x){return fa[x]==x?x:fa[x]=f(fa[x]);}
}ufs;

int pos[100100];
bool cmp(int a,int b){return c[a]<c[b];}
bool did[100100];

llong dp[100100];
llong sb[100100];
void dfs(int x,int fa)
{
    sb[x]=b[x];
    int v;
    for(int i=head[x];i;i=mp[i].nxt)
        if(mp[i].to!=fa)
        {
            v=mp[i].to;
            dfs(v,x);
            sb[x]+=sb[v];
        }
    dp[x]=sb[x]+c[x];
    for(int i=head[x];i;i=mp[i].nxt)
        if(mp[i].to!=fa)
        {
            v=mp[i].to;
            dp[x]=min(dp[x],sb[x]-sb[v]+max(1ll*c[x],dp[v]));
        }
}
int main()
{
    scanf("%d%d",&n,&m);
    ufs.reset();
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&c[i],&b[i]);
        c[i]=max(c[i]-b[i],0);
        pos[i]=i;
    }
    int xx,yy;
    for(int i=1;i<=m;++i)
        scanf("%d%d",&xx,&yy),link(xx,yy),link(yy,xx);
    sort(pos+1,pos+n+1,cmp);
    for(int t=1;t<=n;++t)
    {
        xx=pos[t];
        did[xx]=1;
        for(int i=head[xx];i;i=mp[i].nxt)
            if(did[mp[i].to])
            {
                yy=ufs.f(mp[i].to);
                if(yy==xx)continue;
                ufs.fa[yy]=xx;
                ed[++ted][0]=yy;
                ed[ted][1]=xx;
            }
    }
    memset(head,0,sizeof(head));
    cnt=0;
    for(int i=1;i<=ted;++i)
        link(ed[i][0],ed[i][1]),link(ed[i][1],ed[i][0]);
    dfs(pos[n],0);
    printf("%lld\n",dp[pos[n]]);
    return 0;
}


Measured memory_bytes: 9472
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int r,g,b;
	cin >> r >> g >>b;
	if((r*100+g*10+b)%4==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var N, K, ans int;
	fmt.Scan(&N, &K);

	h := make([]int, N);

	for i := 0 ; i < N ; i++ {
		fmt.Scan(&h[i]);
	}

	for i := 0 ; i < N; i++ {
		if h[i] >= K {
			ans++;
		}
	}
	fmt.Println(ans);

}

Measured memory_bytes: 5504
object Main {
  import scala.io.StdIn.readLine
  def input[A](change: String => A) = readLine.split(" ").map(change(_))
  def main(args: Array[String]): Unit = {
    val i = input(a=>a).head.toCharArray.map(_.toInt)
    println(new QB(i).ans)
  }
}

class QB(input: Array[Int]) {
  val isBegeer = input.tail.exists(_>input.head)
  def initStr(a:Int, b:Int) ={
    (1 to b).toList.foldLeft(List(): List[Char])((acc, c) => {
      acc :+ a.toChar
    }).mkString
  }
  val ans: String = {
    isBegeer match {
      case false => initStr(input.head, input.length)
      case true => initStr(input.head+1, input.length)
    }
  }
}

Measured memory_bytes: 25416
#include<stdio.h>
#include<string.h>

typedef struct {
 char name[100];
 int t;
} process;

process array[100001];
int head=0,tail=0;

int main(void){
 int n,q,i,sum=0,endprocess=0;
 scanf("%d %d",&n,&q);
 for(i=0;i<n;i++){
  scanf("%s %d",array[i].name,&array[i].t);
 }
 while(endprocess!=n){
  if(q<array[head].t){
   array[head].t=array[head].t-q;
   sum+=q;
   array[tail]=array[head];
   if(tail==n-1) tail=0;
   else tail++;
  }
  else if(array[head].t!=0){
   sum+=array[head].t;
   array[head].t=0;
   printf("%s %d\n",array[head].name,sum);
   endprocess++;
  }
  if(head==n-1) head=0;
  else head++;
 }
 return 0;
}

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  
  if((b-a)%2 == 0){
    cout << "Alice" << endl;
    return 0;
  }else{
    cout << "Borys" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());
    let x:usize = r.readl();
    let mut ans = 0;
    for i in 2..((f64::sqrt(x as f64) + 1e-9) as usize + 1) {
        let mut pows = 2;
        loop {
            if(i.pow(pows) <= x){
                if(ans <= i.pow(pows)){
                    ans = i.pow(pows);
                }
                pows += 1;
            }else{
                pows = 2;
                break;
            }
        }
    }

    if ans == 0{
        ans = 1;
    }

    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, n, a, b,i,j;
    scanf("%d %d",&h,&n);
    vector<long long> dp(h + 1,INT_MAX);
    dp[0]=0;
    for(i=0;i<n;i++) {
        scanf("%d %d",&a,&b);
        for (j=0;j<h;j++)
            dp[min(h,j+a)]=min(dp[min(h,j+a)],dp[j]+b);
    }
    printf("%d", dp[h]);
}


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

static const int INF = 0x3f3f3f3f;

template<typename Type>
struct SegmentTree {
        vector<Type> data;
        int n;
        SegmentTree(int x) {
                n = pow(2, ceil(log2(x)));
                data.resize(2 * n - 1, INF);
        }
        Type merge(Type x, Type y) { //更新関数
                return min(x, y);
        }
        void update(int k, Type p) { //k番目をpに更新する
                k += n - 1;
                data[k] = p;
                while (k > 0) {
                        k = (k - 1) / 2;
                        data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
                }
        }
        // [l, r)
        Type query(int a, int b) { return query(a, b, 0, 0, n); }
        Type query(int a, int b, int k, int l, int r) {
                if (r <= a || b <= l) return INF; //初期値
                if (a <= l && r <= b) return data[k];
                int m = (l + r) / 2;
                return merge(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
        }
};

int n, k, p[505050];
bool used[505050];
int ans[505050], ord;

void decide(int idx, SegmentTree<int> &st) {
        while (true) {
                int least = st.query(0, p[idx]);
                if (least >= idx + k) break;
                decide(least, st);
        }
        ans[idx] = ord ++;
        used[idx] = true;
        st.update(p[idx], INF);
}

int main() {
        scanf("%d%d", &n, &k);
        SegmentTree<int> st(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", p + i);
                p[i] --;
                st.update(p[i], i);
        }
        ord = 0;
        for (int i = 0; i < n; i ++) if (!used[i]) decide(i, st);
        for (int i = 0; i < n; i ++) cout << ans[i] + 1 << endl;
        return 0;
}


Measured memory_bytes: 58880
r, c = map(int, input().split())
mat =[]

for x in range(r):
 mat.append(list(map(int, input().split())))

tsum = 0

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
  tsum == mat[x][y]
 mat[x].append(rsum)

mat.append([])

for x in range(c):
 csum = 0
 for y in range(r):
  csum += mat[y][x]
  tsum += mat[y][x]
 mat[r].append(csum)



for x in range(r):
 for y in range(c):
  print("{0} ".format(mat[x][y]), end = '')
 print(mat[x][c])

for x in range(c):
 print("{0} ".format(mat[r][x]), end='')
print(tsum)
 

Measured memory_bytes: 8208
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var Num = int.Parse(Console.ReadLine());
            var Text = Console.ReadLine().ToArray();
            var Patern = new int[Num, 3];
            var Result = 0L;
            for (int i = Num -1; -1 < i; i--)
            {

                if (Text[i] == 'R') Patern[i, 0]++;
                else if (Text[i] == 'G') Patern[i, 1]++;
                else Patern[i, 2]++;

                if (i != Num - 1)
                {

                    Patern[i, 0] += Patern[i + 1, 0];
                    Patern[i, 1] += Patern[i + 1, 1];
                    Patern[i, 2] += Patern[i + 1, 2];

                }

            }

            for (int i = 0; i + 2 < Num; i++)
            {

                for (int j = i + 1; j + 1 < Num; j++)
                {

                    if (Text[i] != Text[j])
                    {

                        if (j + j - i < Num)
                        {

                            if (Text[j + j - i] != Text[i] && Text[j + j - i] != Text[j])
                                Result--;

                        }

                        if (Text[i] != 'R' && Text[j] != 'R')
                            Result += Patern[j + 1, 0];
                        else if (Text[i] != 'G' && Text[j] != 'G')
                            Result += Patern[j + 1, 1];
                        else
                            Result += Patern[j + 1, 2];

                    }

                }

            }

            Console.WriteLine(Result);

        }


    }
}


Measured memory_bytes: 27916
#include <cstdio>

#define maxn 200010
int cnt[maxn];
int main()
{
	int n, k; scanf("%d%d", &n, &k);
	long long ans = 0;
	for (int i = 1; i <= n; ++i)
		if (2 * i % k == 0) ++cnt[i % k];
	for (int i = 0; i < k; ++i) ans += 1ll * cnt[i] * cnt[i] * cnt[i];
	printf("%lld\n", ans);
	return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int	A, B, C, X;
	std::cin >> A >> B >> C >> X;

	ll	ans(0);

	for (int i(0); i <= A; ++i)
		for (int j(0); j <= B; ++j)
			for (int k(0); k <= C; ++k)
				if (i * 500 + j * 100 + k * 50 == X)
					++ans;

	pnl(ans);
}



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

using int64 = long long;
using uint64 = unsigned long long;

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

    int N;
    cin >> N;

    vector<int> P(N), pos(N), length(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i]; P[i]--;
        pos[P[i]] = i;
    }

    int maxLength = 1;
    length[N - 1] = 1;

    for (int i = N - 2; i >= 0; i--)
    {
        if (pos[i] < pos[i + 1]) length[i] = 1 + length[i + 1];
        else length[i] = 1;

        maxLength = max(maxLength, length[i]);
    }

    cout << N - maxLength << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>

int main() {
  std::string str;
  std::cin >> str;
  for (int i=0; i<str.size(); i++) {
    if (i%2 == 0) {
      std::cout << str.at(i);
    }
  }
  std::cout << std::endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; i++)
#define rep(i,n) REP(i,0,n)
long long h[102];
int n;
void update(int &a, int &b, int &c, int idx){
  c = (c+1 != idx)?c+1:c+2;
  b = (b+1 != idx)?b+1:b+2;
  a = (a+1 != idx)?a+1:a+2;
}
void init(int &a, int &b, int &c, int idx){
  if(idx == 0){a = 1; b = 2; c = 3;}
  else if(idx == 1){a = 0; b = 2; c = 3;}
  else if(idx == 2){a = 0; b = 1; c = 3;}
  else {a = 0; b = 1; c = 2;}
}
bool isAns(int idx){
  int a, b, c;
  init(a,b,c,idx);
  while(c < n+1){
    if( h[b] - h[a] != h[c] - h[b])return false;
    update(a,b,c,idx);
  }
  return true;
}
void solve(){
  rep(i,n+1){
    if(isAns(i)){
      cout << h[i] << endl;
      break;
    }
  }
  
}

int main(){

  while(cin >> n, n){
    rep(i,n+1){
      cin >> h[i];
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>
#include <cmath>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

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

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int N;
    cin >> N;
    vector<double> x(N + 2), y(N + 2), r(N + 2);
    REP(i, 0, N) {
        cin >> x[i] >> y[i] >> r[i];
    }
    x[N] = xs;
    y[N] = ys;
    r[N] = 0.0;
    x[N + 1] = xt;
    y[N + 1] = yt;
    r[N + 1] = 0.0;

    const double inf = 1e+20;
    vector<double> Cost(N + 2, inf);

    auto dijkstra = [&](int s, vector<double> &cost) {
        priority_queue<P, vector<P>, greater<P>> pq;
        pq.emplace(0.0, s);
        while (pq.size()) {
            double dist = pq.top().first;
            int vertex = pq.top().second;
            pq.pop();
            if (cost[vertex] < dist) continue;
            cost[vertex] = dist;
            REP(i, 0, N + 2) {
                if (i == vertex) continue;
                double ndist = max(hypot(x[vertex] - x[i], y[vertex] - y[i]) - r[vertex] - r[i], 0.0);
                if (cost[i] > dist + ndist) {
                    cost[i] = dist + ndist;
                    pq.emplace(cost[i], i);
                }
            }
        }
    };

    dijkstra(N, Cost);
    cout << fixed << setprecision(15) << Cost[N + 1] << endl;

    return 0;
}


Measured memory_bytes: 6388
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[3][3];
bool occur[3][3];
 
int32_t main()
{
    fast;
    int c = 0, fl = 0;;
    For(i, 0, 3) {
        For(j, 0, 3) cin >> a[i][j];
    }
    int n; cin >> n;
    while(n--) {
        int x; cin >> x;
        For(i, 0, 3) {
            For(j, 0, 3) {
                if(x == a[i][j]) occur[i][j] = true, c++;
            }
        }
    }

    For(i, 0, 3) {
        if(occur[i][0] and occur[i][1] and occur[i][2]) fl = 1;
    }

    For(i, 0, 3) {
        if(occur[0][i] and occur[1][i] and occur[2][i]) fl = 1;
    }

    if(occur[0][0] and occur[1][1] and occur[2][2]) fl = 1;

    if(occur[0][2] and occur[1][1] and occur[2][0]) fl = 1;

    cout << (fl ? "Yes" : "No");


    
    
    
    
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int main(){
   int n,m;cin>>n>>m;
   vector<bool> v(n+1,1);
   vector<ll> ans(n+1,0);
   for(int i=0;i<m;i++){
       int yay;cin>>yay;
       v[yay]=0;
   }
   ans[1]=1;
   if(v[1]==1)ans[2]=2;
   else ans[2]=1;
   for(int i=3;i<=n;i++){
       if(v[i-2]==1)ans[i]=(ans[i]+1ll*ans[i-2]) %mod;
       if(v[i-1]==1)ans[i]=(ans[i]+1ll*ans[i-1] )%mod;
   }
   cout<<ans[n];
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	vector<int> vis[105]; 
	long long a[105],ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
    for(int i=1;i<=n;i++)
    {
    	for(int j=i+1;j<=n;j++)
    	{
    		for(int k=j+1;k<=n;k++)
    		{
    			if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])
    			{
    				ans++;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
 } 

Measured memory_bytes: 3792
#include <stdio.h>
#define MAX 250

int Parent(int i){

  return(i/2);
}


int Left(int i){

  return 2*i;
}

int Right(int i){

  return 2*i+1;
}

main(){
  int heap_size;
  int A[MAX];
  int i;


  scanf("%d",&heap_size);

  for(i=1;i <= heap_size;i++){

    scanf("%d",&A[i]);

  }

  for(i=1;i <= heap_size;i++){

    
    printf("node %d: key = %d, ",i,A[i]);

    if(Parent(i) >= 1){
      printf("parent key = %d, ",A[Parent(i)]);
    }

	if(Left(i) <= heap_size){

	  printf("left key = %d, ",A[Left(i)]);
	}

      if(Right(i) <= heap_size){

	printf("right key = %d, ",A[Right(i)]);
      }
      printf("\n");
  }
  return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;
    return 0;
}


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

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

int main() {
	ll n;
	cin >> n;
	int ans = 0;
	for (ll x : enumDivisor(n)) {
		if (x == 1) continue;
		ll tmp = n;
		while (tmp % x == 0) tmp /= x;
		tmp %= x;
		if (tmp == 1) ans++;
	}
	ans += enumDivisor(n - 1).size() - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		sc.close();

		String s = Integer.toString(N, K);
		out.println(s.length());

	}

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


Measured memory_bytes: 23508
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
inline void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
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;}
template<class T> inline void operator>>(istream& is,vector<T>& v) { for(int& i : v){ is>>i; } }
template<class T> inline void operator<<(ostream& os,const vector<T>& v) { for(int i : v){ os<<i<<" "; } os<<endl; }
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi r(n+1,0),g(n+1,0),b(n+1,0);
    rrep(i,n) r[i] = r[i+1]+(s[i] == 'R');
    rrep(i,n) g[i] = g[i+1]+(s[i] == 'G');
    rrep(i,n) b[i] = b[i+1]+(s[i] == 'B');
    ll ans = 0;
    rep(i,n) rep(j,n) {
        if(i >= j) continue;
        if(j == n-1) continue;
        if(s[i] == 'R') {
            if(s[j] == 'R') continue;
            if(s[j] == 'G') {
                ans += b[j+1];
                if(j*2-i < n && s[j*2-i] == 'B') ans--;
            } else {
                ans += g[j+1];
                if(j*2-i < n && s[j*2-i] == 'G') ans--;
            }
        } else if(s[i] == 'G') {
            if(s[j] == 'G') continue;
            if(s[j] == 'R') {
                ans += b[j+1];
                if(j*2-i < n && s[j*2-i] == 'B') ans--;
            } else {
                ans += r[j+1];
                if(j*2-i < n && s[j*2-i] == 'R') ans--;
            }
        } else {
            if(s[j] == 'B') continue;
            if(s[j] == 'R') {
                ans += g[j+1];
                if(j*2-i < n && s[j*2-i] == 'G') ans--;
            } else {
                ans += r[j+1];
                if(j*2-i < n && s[j*2-i] == 'R') ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
n=int(input())
a=list(map(int,input().split()))
ans=[]
if n%2==0:
    for i in range(n-1,0,-2):
        ans.append(a[i])
    for i in range(0,n-1,2):
        ans.append(a[i])
else:
    for i in range(n-1,-1,-2):
        ans.append(a[i])
    for i in range(1,n-1,2):
        ans.append(a[i])
print(' '.join(map(str,ans)))

Measured memory_bytes: 29764
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    LL n, x;
    cin >> n >> x;
    vector<LL> b(n), u(n), l(n);
    rep(i, n) cin >> b[i] >> l[i] >> u[i];

    vector<pair<LL, int>> d(n);
    rep(i, n) d[i] = make_pair((x-b[i])*u[i] + b[i]*l[i], i);
    sort(all(d));
    reverse(all(d));

    vector<LL> sum_d(n+1, 0);
    rep(i,n) sum_d[i+1] = sum_d[i] + d[i].first;

    LL sum_bl = 0;
    rep(i, n) sum_bl += b[i]*l[i];

    LL ok = x*n, ng = -1;
    while(abs(ok - ng) > 1){
        LL mid = (ok+ng)/2;
        LL sub_x = mid / x;
        LL rem = mid % x;

        LL tmp = 0;
        bool f = 0;
        // if(sub_x >= n){
        //     ng = mid;
        //     continue;
        // }
        rep1(i, n+1){
            if(i <= sub_x){
                tmp = sum_d[sub_x+1] - (sum_d[i] - sum_d[i-1]);
            }else{
                tmp = sum_d[sub_x];
            }
            int j = d[i-1].second;
            if(b[j] < rem){
                tmp += (rem-b[j])*u[j] + b[j]*l[j];
            }else{
                tmp += rem*l[j];
            }
            if(tmp >= sum_bl){
                f = 1;
                break;
            }
        }
        // cout << mid << " : " << tmp << " " << sum_bl << endl;
        if(f) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;

}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<ll>B(N,0);
  for(int i=0;i<N;i++){
    if(i%2)B[0]-=A[i];
    else B[0]+=A[i];
  }
  for(int i=1;i<N;i++){
    B[i]=(A[i-1]-B[i-1]/2)*2;
  }
  for(auto it:B)cout<<it<<" ";
  cout<<endl;
  return 0;
}


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

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; }

using ll = long long;

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

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

bool pri(ll x){ //素数判定
  bool ok = true;
  for(ll i = 2LL; i*i<=x;i++){
    if(x%i==0LL) {
      ok = false;
      break;
    }
  }
  if(x==1LL)ok = false;
  return ok;
}

int main() {
  ll Q;
  cin>>Q;
  vector<ll> similar(100050,0);
  for(ll i = 3LL; i < 100050LL;i+=2LL){
    if(pri(i)&&pri((i+1LL)/2LL)) similar[i]=1;
  }
  for(ll i = 1LL; i < 100050LL;i++){
    similar[i]+=similar[i-1];
  }
  for(ll i = 0LL; i < Q; i++) {
    int l, r;
    cin>>l>>r;
    cout<<similar[r]-similar[l-1]<<endl;
  }
}
  

Measured memory_bytes: 1408
/** Seek God..Trust God..Praise God..**/

#include<bits/stdc++.h>
using namespace std;


#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define endl            "\n";

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////



/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/


int main()
{
    FASTIO;

    ll n;

    cin >> n;


    ll a[n+1] , b[n+1];



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


    for(int i=0; i<n; i++)
    {
        if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2] && i+1<=n-1 && i+2<=n-1)
        {
            cout << "Yes" << endl;
            return 0;
        }

    }

    cout << "No" << endl;





    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<climits>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int> >vec(n,make_pair(0,1));
    vec[0].first = 1;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(vec[a-1].second>0)vec[b-1].second+=1;
        if(vec[a-1].first>0)vec[b-1].first+=1;
        if(vec[a-1].second==1){
            vec[a-1].first=0;
        }
        vec[a-1].second --;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(vec[i].first>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

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

	int N=in(),M=in();
	auto D = enum_div(M);
	ll max_num = 0;
	for(auto& x:D){
		if((M/x)>=N) max_num = max(max_num,x);
	}

	cout << max_num << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace ABC118B
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().calc();
        }

        void calc()
        {
            var temp = Console.ReadLine().Split(' ');
            var n = int.Parse(temp[0]);
            var m = int.Parse(temp[1]);
            var likeMatrix = new bool[n + 1, m + 1];

            for (int i = 1; i <= n; i++)
            {
                var line = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                line.RemoveAt(0);
                
                foreach (int j in line)
                {
                    likeMatrix[i, j] = true;
                }
            }

            var likeArray = new bool[m + 1];
            for (int i = 0; i < likeArray.Length; i++)
            {
                likeArray[i] = true;
            }
            likeArray[0] = false;

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= m; j++)
                {
                    if (likeMatrix[i, j] != true)
                    {
                        likeArray[j] = false;
                    }
                }
            }

            Console.WriteLine(likeArray.Where(v => v == true).Count());
        }
    }
}


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

int main(void){
  string s;
  cin >> s;
  int n=s.length();
  long long int sum=0,sm=0;
  
  for(int i=0;i<(1<<(n-1));i++){
    long long int a=s[0]-'0';
    for(int j=0;j<(n-1);j++){
      if(i&(1<<j)){
        sum+=a;
        a=s[j+1]-'0';
      }
      else{
        a=a*10+s[j+1]-'0';
      }
    }
    sum+=a;
    sm+=sum;
    sum=0;
  }
  
  cout << sm << endl;
}

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

//-----------------------------------------------

//------------------------------------------------

int main(){
  ll n,ans;
  ans=0;
  ll b[110];
  ll a[110];
  cin>>n;
  rep(i,0,n-1) cin>>b[i];

  rep(i,0,n){
    if(i==0) a[i]=b[i];
    if(i==n-1) a[i]=b[i-1];
    if(i!=0 && i!=n-1)  a[i]=min(b[i],b[i-1]);

    ans+=a[i];
  }
  cout<<ans<<endl;
}


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

namespace TOPSIC
{
    partial class Program
    {
        static void Main(string[] args)
        {
          string[] NAB = Console.ReadLine().Split(' ');
            long N = long.Parse(NAB[0]);
            long A = long.Parse(NAB[1]);
            long B = long.Parse(NAB[2]);

            long ans = 0;

            ans += (long)(N / (A + B)) * A;

            ans += Math.Min(A, N % (A + B));

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> num(m);
  vector<vector<int>> dat(n,vector<int>(m,0));
  for(int i=0;i<m;i++)
    cin >> num.at(i);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)
      cin >> dat.at(i).at(j);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int x=0;
    for(int j=0;j<m;j++)
      x+=dat.at(i).at(j)*num.at(j);
    x+=c;
    if(x>0)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e+9

int main(){
int n,m,a[50],b[50],ab[51][51],tmp[51][51];
for(int i=0;i<51;i++)
  for(int j=0;j<51;j++) ab[i][j]=inf;
cin>>n>>m;
for(int i=0;i<m;i++){
  cin>>a[i]>>b[i];
  ab[a[i]][b[i]]=1;ab[b[i]][a[i]]=1;
}
int ans=0;
for(int l=0;l<m;l++){
  for(int ti=0;ti<=n;ti++)
    for(int tj=0;tj<=n;tj++)
      tmp[ti][tj]=ab[ti][tj];
  tmp[a[l]][b[l]]=inf;tmp[b[l]][a[l]]=inf;
  for(int k=1;k<=n;k++)
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
        tmp[i][j]=min(tmp[i][j],tmp[i][k]+tmp[k][j]);
  if(tmp[a[l]][b[l]]==inf||tmp[b[l]][a[l]]==inf)ans++;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl vec(n);
        rep(i, n)   cin>>vec[i];
        vl pup(n/2);
        ll axor = 0;
        rep(i, n/2){
            pup[i] = vec[2*i]^vec[2*i + 1]; 
            axor ^= pup[i];
        }
        rep(i, n){
            ll lft = axor ^ pup[i/2];
            if(i & 1)   cout<<(lft^vec[i-1])<<" ";
            else cout<<(lft^vec[i+1])<<" ";
        }
    }
}

Measured memory_bytes: 5544
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn index(v: &Vec<usize>, n: usize) -> Option<usize> {
    for i in 0..v.len() {
        if n == v[i] {
            return Some(i);
        }
    }
    None
}

fn fun(
    u: usize,
    edges: &Vec<Vec<(usize, u32)>>,
    cost: &mut Vec<u32>,
    set: &mut BTreeSet<usize>,
    c: u32,
) {
    cost[u] = c;
    for i in 0..edges[u].len() {
        let v = edges[u][i].0;
        let ct = edges[u][i].1;
        if c + ct < cost[v] {
            cost[v] = c + ct;
        }
    }
    let mut id: usize = 300;
    let mut tmp: u32 = 1000000000;
    if !set.is_empty() {
        for v in set.clone() {
            if cost[v] < tmp {
                tmp = cost[v];
                id = v;
            }
        }
        set.remove(&id);
        fun(id, edges, cost, set, tmp);
    }
}

fn fun2(u: usize, mat: &Vec<Vec<u32>>, set: &mut BTreeSet<usize>) -> u32 {
    if set.is_empty() {
        return 0;
    }
    let mut ans: u32 = 1000000000;
    for v in set.clone() {
        set.remove(&v);
        let tmp = mat[u][v] + fun2(v, mat, set);
        set.insert(v);
        if tmp < ans {
            ans = tmp;
        }
    }
    ans
}

use std::collections::BTreeSet;

fn main() {
    let nmr: Vec<usize> = read_vec();
    let n = nmr[0];
    let m = nmr[1];
    let r = nmr[2];
    let rtmp: Vec<usize> = read_vec();
    let rvec: Vec<usize> = rtmp.into_iter().map(|a| a - 1).collect();

    let mut edges: Vec<Vec<(usize, u32)>> = vec![vec![]; n];
    let mut mat: Vec<Vec<u32>> = vec![vec![0; r]; r];

    for _ in 0..m {
        let abc: Vec<usize> = read_vec();
        let a = abc[0] - 1;
        let b = abc[1] - 1;
        let c = abc[2] as u32;
        edges[a].push((b, c));
        edges[b].push((a, c));
    }

    for i in 0..r {
        let mut cost: Vec<u32> = vec![1000000000; n];
        let mut set: BTreeSet<usize> = BTreeSet::new();
        for j in 0..n {
            if j != rvec[i] {
                set.insert(j);
            }
        }
        fun(rvec[i], &edges, &mut cost, &mut set, 0);
        for j in 0..r {
            mat[i][j] = cost[rvec[j]];
        }
    }

    let mut ans: u32 = 1000000000;
    for u in 0..r {
        let mut set: BTreeSet<usize> = BTreeSet::new();
        for v in 0..r {
            if v != u {
                set.insert(v);
            }
        }
        let tmp = fun2(u, &mat, &mut set);
        if tmp < ans {
            ans = tmp;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin>>N;
  int c0,c1,c2,c3;
  c0 = c1 = c2 = c3 = 0;
  
  for(int n=0;n<N;n++){
    string S;
    cin>>S;
    if(S=="AC"){
      c0++;
    }else if(S=="WA"){
      c1++;
    }else if(S=="TLE"){
      c2++;
    }else{
      c3++;
    }
  }
  cout<<"AC x "<<c0<<"\n"<<"WA x "<<c1<<endl;
  cout<<"TLE x "<<c2<<"\n"<<"RE x "<<c3<<endl;
  return 0;
  
}

Measured memory_bytes: 3628