akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
using namespace std;

class Bubble{
protected:
	int *number;
	char *card;
	int size;
public:
	Bubble(int);
	Bubble(const Bubble&);
	Bubble& operator=(const Bubble&);
	~Bubble();
	void input();
	void narabekae();
	int get_size()const{ return size; }
	int *get_number()const;
	char *get_card()const;
};

class Select : public Bubble{
private:
	int *snumber;
	char *scard;
public:
	Select(int x) : Bubble(x){
		snumber = new int[x];
		scard = new char[x];
	}
	~Select(){
		delete [] snumber;
		delete [] scard;
	}
	void narabekae();
	void copy(char*,int*);
	void judge(char*)const;
};

Bubble::Bubble(int size){
	this->size = size;
	card = new char[get_size()];
	number = new int[get_size()];
}

Bubble::Bubble(const Bubble& x){
	number = new int[x.get_size()];
	card = new char[x.get_size()];
}

Bubble& Bubble::operator=(const Bubble& x){
	if(this==&x) return *this;
	delete number;
	delete card;
	number = new int[x.get_size()];
	card = new char[x.get_size()];
	return *this;
}

Bubble::~Bubble(){
	delete [] card;
	delete [] number;
}

void Bubble::input(){
	for(int i=0;i<get_size();i++){
		cin>>card[i];
		cin>>number[i];
	}
}

void Bubble::narabekae(){
	for(int i=0;i<get_size();i++){
		for(int j=get_size()-1;j>i;j--){
			if(number[j-1]>number[j]){
				int temp = number[j];
				char ntemp = card[j];
				number[j] = number[j-1];
				card[j] = card[j-1];
				number[j-1] = temp;
				card[j-1] = ntemp;
			}
		}
	}

	for(int i=0;i<get_size();i++){
		if(i!=get_size()-1){
			cout<<card[i]<<number[i]<<" ";
		}else{
			cout<<card[i]<<number[i]<<endl;
		}
	}
	cout<<"Stable"<<endl;
}

int* Bubble::get_number()const{
	return number;
}

char* Bubble::get_card()const{
	return card;
}

void Select::copy(char* card,int *number){
	for(int i=0;i<get_size();i++){
		snumber[i] = number[i];
		scard[i] = card[i];
		//cout<<"scard[]="<<scard[i]<<"snumber="<<snumber[i]<<endl;
	}
}

void Select::narabekae(){
	for(int i=0;i<get_size();i++){
		int minj = i;
		for(int j=i;j<get_size();j++){
			if(snumber[minj]>snumber[j]) minj = j;
		}
		int ntemp = snumber[i];
		snumber[i] = snumber[minj];
		snumber[minj] = ntemp;
		char ctemp = scard[i];
		scard[i] = scard[minj];
		scard[minj] = ctemp;
	}

	for(int i=0;i<get_size();i++){
		if(i!=get_size()-1){
			cout<<scard[i]<<snumber[i]<<" ";
		}else{
			cout<<scard[i]<<snumber[i]<<endl;
		}
	}
}

void Select::judge(char* card)const{
	for(int i=0;i<get_size();i++){
		if(scard[i]!=card[i]){
			cout<<"Not stable"<<endl;
			return;
		}
	}
	cout<<"Stable"<<endl;
}

int main(){

	int in;
	cin>>in;

	Bubble test1(in);
	Select test2(in);
	test1.input();
	int *p;
	char *n;
	p = test1.get_number();
	n = test1.get_card();
	test2.copy(n,p);
	
	test1.narabekae();
	test2.narabekae();

	n = test1.get_card();
	test2.judge(n);

}

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

int main(){
  int N,lp = 0;
  int keta[4];
  cin >> N;

  keta[0] = N/1000 ; N -= (N/1000)*1000;
  keta[1] = N/100 ; N -= (N/100)*100;
  keta[2] = N/10 ; N -= (N/10)*10;
  keta[3] = N;

  if (keta[0] == keta[1] && keta[1] == keta[2]){
    cout << "Yes" << endl;
  }else{
    if (keta[1] == keta[2] && keta[2] == keta[3]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
}

Measured memory_bytes: 26576
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    S = rl().rstrip()
    T = rl().rstrip()
    
    ans = 1001
    for i in range(len(S) - len(T) + 1):
        cnt = len(T)
        for j in range(len(T)):
            cnt -= S[i + j] == T[j]
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 73284
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split().Select(i => int.Parse(i)).OrderByDescending(i => i).ToArray();

            var f = l.First() < l.Skip(1).Sum();
            Console.WriteLine(f ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int cnt[(int)1e6+9];
bool b[(int)1e6+9];
int exist[(int)1e6+9];
int main()
{
    FASTINOUT;
    ll x,g=0;
    cin>>x;
    ll a[x];
    for (int i=0; i<x; i++)
    {
        cin>>a[i];
        exist[a[i]]++;
        g=__gcd(g,a[i]);
    }
    bool valid=1;
    for (int i=2; i<=1e6; i++)
    {
        if (b[i])
            continue;
        int cn=0;
        cn+=exist[i];
        for (int j=i+i; j<=1e6; j+=i)
        {
                cn+=exist[j];
            b[j]=1;
        }
        if (cn>1)
        {
            valid=0;
        }
    }
    if (valid)
        cout<<"pairwise coprime";
    else if (g==1)
        cout<<"setwise coprime";
    else
        cout<<"not coprime";
    return 0;
}


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

int main() {
	int N, Q;
	string S;
	cin >> N >> Q >> S;
	vector<int> L(Q), R(Q);
	for (int i = 0; i < Q; i++) cin >> L[i] >> R[i];
	vector<int> Nums(N);
	char before = S[0];
	for (int i = 1; i < N; i++) {
		if (before == 'A' && S[i] == 'C') Nums[i] = 1;
		before = S[i];
		Nums[i] += Nums[i - 1];
	}
	for (int i = 0; i < Q; i++) cout << Nums[R[i] - 1] - Nums[L[i] - 1] << endl;
}

Measured memory_bytes: 2304
N,A,B=map(int,input().split())
S=input()
tsuuka=0
kaigai=0

for i in range(len(S)):
    if S[i]=="c":
        print("No")
    elif S[i]=="a":
        if tsuuka < A+B:
            print("Yes")
            tsuuka+=1
        else:
            print("No")
    else:
        if tsuuka < A+B and kaigai<B:
            print("Yes")
            tsuuka+=1
            kaigai+=1
        else:
            print("No")

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

int main()
{
	int flag=0;
	size_t len;
	string S;
	cin >> S;
	len = S.length();
	for (int i = 0; i < len-1; i++)
	{
		for (int j = i+1; j < len; j++)
		{
			if (S[i] == S[j])
			{
				flag = 1;
			}
		}
	}

	if (flag == 0)
	{
		cout << "yes" << endl;
	}
	else
	{
		cout << "no" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>



int f(int x){
  return x*x;
}

int main(){
  int i;
  int count, d;
  int s;

  while (scanf("%d", &d)==1){
    s = 0;
    count = 600/d;
    for(i=1; i<count; i++){
      s += f(i*d)*d;
    }
    printf("%d\n", s);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, A, B, C, D, X, Y;
	string S, T;

	cin >> S;
	bool F = false;
	if (S[0] != S[1] || S[1] != S[2])F = true;
	if (F)cout << "Yes" << endl;
	else cout << "No" << endl;




	return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 105

int N;
int B[SIZE];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N-1; i++){

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

	int ans = B[0]+B[N-2];

	for(int i = 1; i < N-1; i++){

		ans += min(B[i],B[i-1]);
	}

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

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int s,n,y,m,d,t,i;

  s=39*5*999+333*5+1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d",&y,&m,&d);
    if(m%2==0) t=(y-1)*39*5+(m/2)*20+((m-1)/2)*19+d+5*((y-1)/3);
    else t=(y-1)*39*5+((m-1)/2)*39+d+5*((y-1)/3);
    if(y%3==0&&m%2==1)t=t+m/2;
    else if(y%3==0&&m%2==0) t=t+m/2-1;  
    printf("%d\n",s-t);
  }
  return 0;
}

Measured memory_bytes: 596
# include <map>
# include <iostream>
# include <string>
# include <vector>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
	int n; cin >> n;
	vector<string> s(n); rep(i, n) cin >> s[i];
	int m; cin >> m;
	vector<string> t(m); rep(i, m) cin >> t[i];
	int ans_score = 0;
	map<string, int> count;

	for (auto s_: s) {
		if (count.find(s_) != count.end()) count[s_]++;
		else count[s_] = 1;
	}

	for (auto t_: t) {
        if (count.find(t_) != count.end()) count[t_]--;
		else count[t_] = -1;
	}

	int ans = 0;
	for (pair<string, int> p: count) {
		ans = max(ans, p.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M  998244353
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
ll lcm(ll a,ll b)
{
    ll g=__gcd(a,b);
    return ((a*b)/g);
}
int pal(string S)
{
    int n=S.length();
    int ok=1,i;
    for(i=0;i<n;i++)
    {
        if(S[i]!=S[n-i-1])
        {
            ok=0;
            break;
        }
    }
    return ok;
}
ll d(ll n)
{
    ll y=n*(n-1);
    y/=2;
    return y;
}
int main()
{
  int n,i;
  cin>>n;
  int cnt[n+1]={0};
  int A[n];
  for(i=0;i<n;i++)
  {
      cin>>A[i];
      cnt[A[i]]++;
  }
  ll ans=0;
  for(i=1;i<=n;i++)
  {
      ans+=d(cnt[i]);
  }
  ll res;
  for(i=0;i<n;i++)
  {
      res=ans-(cnt[A[i]]-1);
      cout<<res<<"\n";
  }
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

ll gcd(ll a, ll b){
  if(a == 0 || b == 0) return 0;
  while(a != b){
    if(a > b) a = a - b;
    else b = b - a;
  }
  return a;
}

ll lcm(ll a, ll b){
  if(a == 0 || b == 0) return 0;
  return (a/gcd(a, b)*b);
}

int main(){
  ll n, ans, a;
  cin >> n;
  
  for(int i = 0; i < n; i++){
    if(i == 0) {
      cin >> ans;
    } else {
      cin >> a;
      ans = lcm(ans, a);
    }
  }

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



Measured memory_bytes: 3116
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (a <= b && b <= a + w) cout << 0 << endl;
  else if (a <= b + w && b + w <= a + w) cout << 0 << endl;
  else cout << min(abs(b - a - w), abs(a - b - w)) << endl;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;


public class Main{

	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			long a = scan.nextLong();
			long b = scan.nextLong();
			long gcd = divide(a, b);

			long lcm = a * b / gcd;
			System.out.println(gcd + " " + lcm);

		}
	}

	public static long divide(long a, long b) {
		long r;
		if (a < b) {
			long temp = b;
			b = a;
			a = temp;
		}
		r = a % b;

		return r == 0 ? b : divide(b, r);
	}

}

Measured memory_bytes: 17360
# -*- coding: utf-8 -*-
from operator import itemgetter


N, M = list(map(int, input().split()))

a = [0] * N
for i in range(N):
    a[i] = list(map(int, input().split()))


def main():
    b = sorted(a, key=itemgetter(0))
    m = 0
    cost = 0
    for i in range(N):
        if (m + b[i][1]) <= M:
            m += b[i][1]
            cost += (b[i][0] * b[i][1])
        else:
            cost += (b[i][0] * (M-m))
            return cost
    return cost


print(main())

Measured memory_bytes: 29868
#include<stdio.h>
int main(void)
{
  int n, m,i, in, out, Max;
  scanf("%d %d",&n,&m); 
  Max = m;
  for(i=0; i < n;i++){
    scanf("%d",&in);
    m  = m + in;
    scanf("%d",&out);    
    m  = m - out;
    if(m < 0)
      break;
    if(Max < m){Max = m;}
     
    
  }
  if(m < 0){printf("0\n");}
  else if(m > 0 ){printf("%d\n",Max);} 
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define pi 3.1415926536
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define INF 2147483647
#define _INF -2147483647
#define MM multimap
#define PB push_back
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vi H(N);

    int high = 0;
    int ans = 0;
    rep(i, 0, N) {
        cin >> H[i];
        if (high <= H[i]) {
            high = H[i];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n,1):
    dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))
print(dp[n-1])

Measured memory_bytes: 13928
fun main(arg: Array<String>) {
    val (H, W, K) = listOfInt()
    val S = Array(H) { next().map { it - '0' }.toIntArray() }
    val INF = 1001001001
    var ans = INF
    for (div in 0 until (1 shl (H - 1))) {
        var G = 0
        val id = IntArray(H)
        for (h in 0 until H) {
            id[h] = G
            if (((div shr h) and 1) == 1) G += 1
        }
        G += 1
        val c = Array(G) { IntArray(W) }
        for (h in 0 until H) for (w in 0 until W) c[id[h]][w] += S[h][w]
        var num = G - 1
        var now = IntArray(G)
        fun add(w: Int): Boolean {
            for (g in 0 until G) now[g] += c[g][w]
            for (g in 0 until G) if (now[g] > K) return false
            return true
        }
        for (w in 0 until W) {
            if (!add(w)) {
                num += 1
                now = IntArray(G)
                if (!add(w)) {
                    num = INF
                    break
                }
            }
        }
        ans = Math.min(ans, num)
    }
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 49916
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
#define MAXN 100010
#define LL long long
struct node
{
	int x,a,b;
}e[MAXN];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int x,y,z,a,b,c,n;
multiset<int>G;
LL sum,f[MAXN],p[MAXN],ans;
int main()
{
	scanf("%d%d%d",&x,&y,&z);
	n=x+y+z;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		ans+=c;
		a-=c,b-=c;
		e[i].x=a-b;
		e[i].a=a,e[i].b=b;
	}
	sort(e+1,e+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		sum+=e[i].b;
		G.insert(e[i].b);
		if(G.size()>y)
		{
			sum-=*G.begin();
			G.erase(G.begin());
		}
		f[i]=sum;
	}
	G.clear(),sum=0;
	for(int i=n;i;i--)
	{
		sum+=e[i].a;
		G.insert(e[i].a);
		if(G.size()>x)
		{
			sum-=*G.begin();
			G.erase(G.begin());
		}
		p[i]=sum;
	}
	LL tmp=ans;
	ans=0;
	for(int i=y;i+x<=n;i++)
		ans=max(ans,tmp+f[i]+p[i+1]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 7296
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	while (true) {
		LL n = -1, m = -1;
		cin >> n >> m;
		if (n <= 0) break;
		vector<LL> a(m), b(m), c(m), d(n, 1LL << 60);
		d[0] = 0;
		for (LL i = 0; i < m; ++i) {
			cin >> a[i] >> b[i] >> c[i];
			--a[i], --b[i];
			c[i] = -c[i];
		}
		auto update = [&]() {
			for (LL j = 0; j < m; ++j) {
				if (d[b[j]] > d[a[j]] + c[j]) {
					d[b[j]] = d[a[j]] + c[j];
				}
			}
		};
		for (LL i = 0; i < n - 1; ++i) {
			update();
		}
		vector<LL> prev = d;
		for (LL i = 0; i < n; ++i) {
			update();
		}
		LL first = -prev[n - 1], second = -d[n - 1];
		cout << (second > first ? "inf" : to_string(second)) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string a, b, c;
    int s = 'a' - 'A';
    cin >> a >> b >> c;
    cout << ( char )( a[0] - s ) << (char)( b[0] - s ) << ( char )( c[0] - s ) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200001;
int a[N];
ll s[N];
ll calc(pair<ll, ll> a, pair<ll, ll> b){
  ll mx = max(max(a.first, a.second), max(b.first, b.second));
  ll mn = min(min(a.first, a.second), min(b.first, b.second));
  if(a.first == -1 || b.first == -1)return 1e18;
  return mx - mn;
}
pair<pair<ll, ll>, pair<ll, ll>> d(int l, int r){
//  cout << l << ' ' << r << endl;
  int lo = l, hi = r - 1;
  ll tot_sum = s[r] - (l ? s[l - 1] : 0);
  while(lo < hi){
    int mid = (lo + hi) / 2;
    ll s1 = s[mid] - (l ? s[l - 1] : 0);
    if(s1 >= tot_sum - s1){
      hi = mid;
    }else{
      lo = mid + 1;
    }
  }
  pair<ll, ll> p1;
  pair<ll, ll> p2;
  ll s1 = s[lo] - (l ? s[l - 1] : 0);
  p1.first = s1;
  p1.second = tot_sum - s1;
  lo--;
  if(lo < l)
    p2.first = -1;
  else{
    ll s1 = s[lo] - (l ? s[l - 1] : 0);
    p2.first = s1;
    p2.second = tot_sum - s1;
  }
  return {p1, p2};
}
void pr(pair<pair<ll, ll>, pair<ll, ll>> p){
  cout << p.first.first << ' ' << p.first.second << ' ' << p.second.first << ' ' << p.second.second << endl;
}
ll sum(int l, int r){
  return s[r] - (l ? s[l - 1] : 0);
}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  for(int i = 0;i < n;i++)
    cin >> a[i];
  s[0] = a[0];
  for(int i = 1;i < n;i++)
    s[i] = a[i] + s[i-1];
  ll res = 1e18;
  int p1 = 0;
  int p2 = 2;
  for(int i = 1;i < n - 2;i++){
    while(p1 < i - 1 && abs(sum(0, p1 + 1) - sum(p1 + 2, i) < abs(sum(0, p1) - sum(p1 + 1, i))))
      p1++;
    while(p2 <= i || (p2 < n - 2 &&  abs(sum(i + 1, p2 + 1) - sum(p2 + 2, n - 1) < abs(sum(i + 1, p2) - sum(p2 + 1, n - 1)))))
      p2++;
//    cout << p1 << ' ' << p2 << endl;
//    pair<pair<ll, ll>, pair<ll, ll>> d1 = d(0, i);
//    pair<pair<ll, ll>, pair<ll, ll>> d2 = d(i + 1,  n - 1);

    res = min(res, calc({sum(0, p1), sum(p1 + 1, i)}, {sum(i + 1, p2), sum(p2 + 1, n - 1)}));
//    res = min(res, calc(d1.first, d2.second));
//    res = min(res, calc(d1.second, d2.first));
//    res = min(res, calc(d1.second, d2.second));

  }
    cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
N = int(input())
S = list(str(input()) for _ in range(N))

AC = 0
WA = 0
TLE = 0
RE = 0
for s in S:
    if s =='AC':
        AC +=1
    elif s == 'WA':
        WA +=1
    elif s == 'TLE':
        TLE += 1
    elif s == 'RE':
        RE  +=1

print('AC x {}'.format(str(AC)))
print('WA x {}'.format(str(WA)))
print('TLE x {}'.format(str(TLE)))
print('RE x {}'.format(str(RE)))

Measured memory_bytes: 16108
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int a[100001],i;
  for(i=0;i<100001;i++)
    a[i]=0;
  for(i=0;i<n;i++){
    int b;
    scanf("%d",&b);
    a[b]++;
  }
  int maximum=0;
  for(i=1;i<100000;i++)
    if(maximum<a[i]+a[i-1]+a[i+1])
      maximum=a[i]+a[i-1]+a[i+1];
  printf("%d\n",maximum);
  return 0;
}


Measured memory_bytes: 2124
import java.util.Scanner;
class Main{
	Scanner sc = new Scanner(System.in);
	int n;
	int[] S;
	int q;
	int[] T;
	int C;
	int left;
	int right;
	int mid;
	void n(){
		n=sc.nextInt();
		S=new int[n];
		for(int i=0; i<n; i++){
			S[i]=sc.nextInt();
		}
		q=sc.nextInt();
		T=new int[q];
		for(int j=0; j<q; j++){
			T[j]=sc.nextInt();
		}
		
		for(int j=0; j<q; j++){
			left=0;
			right=n;
			while(left<right){
				mid=(left+right)/2;
				
				if(T[j]==S[mid]){
					C++;
					break;
				}else if(T[j]<S[mid]){
					right=mid;
				}else if(T[j]>S[mid]){
					left=mid+1;
				}
			}
		}
		System.out.println(C);
	}
	public static void main(String[]agrs){
		new Main().n();
	}
}

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

long long f[10000001];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int j = i;
    while (j <= n) {
      f[j]++;
      j += i;
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    ans += i * f[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 81700
N, K = map(int, input().split())
S = str(input())

ans = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    ans +=1

for i in range(K):
  if N - ans > 2:
    ans += 2
  elif N-ans == 2:
    ans += 1
    break
  else:
    break
    
print(ans)

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  double ans,sum = 0.0;
  for (int i = 0; i < N; i++) {
    sum += 1.0/A[i];
  }
  ans = 1.0/sum;
  cout << setprecision(16) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0;
    int j = n - 1;
    int cnt = 0;
    while (i < n && j >= 0 && i < j) {
    	while (i < n && s[i] == 'R') {
    		++i;
    	}
    	while (j >= 0 && s[j] == 'W') {
    		--j;
    	}
    	if (i < n && j >= 0 && i < j) {
    		swap(s[i], s[j]);
    		cnt++;
    	}
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3780
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int unko=sc.nextInt();
		boolean ike=false;
		int N=0;
		for(int i=0; i<=500; i++) {
			if(unko==i*(i+1)/2) {
				ike=true;
				N=i;
				break;
			}
			else if(unko<i*(i+1)/2) {
				break;
			}
		}
		if(ike) {
			System.out.println("Yes");
			System.out.println(N+1);
			int[][] ary=new int[N+1][N];
			int[] kaz=new int[N+2];
			for(int i=0; i<=N; i++) {
				for(int j=0; j<N; j++) {
					ary[i][j]=0;
				}
			}
			for(int i=0; i<=N+1; i++) {
				kaz[i]=0;
			}
			int counter=1;
			for(int i=1; i<=N+1; i++) {
				for(int j=1; j<i; j++) {
					ary[i-1][kaz[i-1]]=counter;
					kaz[i-1]++;
					ary[j-1][kaz[j-1]]=counter;
					kaz[j-1]++;
					counter++;
				}
			}
			String buri="";
			for(int i=0; i<N+1; i++) {
				buri=Arrays.toString(ary[i]);
				buri=buri.replaceAll(",","");
				buri=buri.replace("["," ");
				buri=buri.replace("]","");
				System.out.println(N+buri);
			}
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 46056
#include <stdio.h>

int accept[100005];

int main() {

	int N, K, Q;

	scanf("%d %d %d",&N,&K,&Q);

	int i;

	for (i = 0; i < Q; i++) {
		int Ai;
		scanf("%d",&Ai);
		accept[Ai]++;
	}
	for (i = 1; i <= N; i++) {
		if (K - Q + accept[i] <= 0) {
			printf("No\n");
		}
		else {
			printf("Yes\n");
		}
	}

	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050];
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }

    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }
  ll invvf[1000500],fact[1000500];
  void pre()
  {
      ll i,j,n=1000050;
      fact[0]=1; fact[1]=1;
      rep(i,2,n) {fact[i]=fact[i-1]*i; fact[i]%=hell;}
      invvf[1]=1; invvf[0]=1;
      rep(i,2,n)
      {
          invvf[i]=inv(fact[i]);
      }

  }
 ll ncr(ll n , ll r)
 {
     ll y=fact[n];
     y*=invvf[r];
     y%=hell;
     y*=invvf[n-r];
     y%=hell;
     return y;
 }


int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}

void solve()
{
    ll i,j,k,n,m,y=0,c=0,a,b,d;
cin>>n;
map < string , ll> M;
rep(i,0,n)
{   string s;
    cin>>s;
    M[s]++;
}
cout<<M.size();
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 19204
#include<bits/stdc++.h>
using namespace std;
long long dp[101][5][5][5];
long long m=1000000007;

long long solve(int i,int j,int k,int l,int n)
{
    long long ans=0;
    if(dp[i][j][k][l]!=0) return dp[i][j][k][l];
    if(j==2 && k==3 && l==1) return 0;
    if(j==2 && k==1 && l==3) return 0;
    if(j==3 && k==2 && l==1) return 0;
    if(i==n) return 1;
    for(int z=1; z<=4; z++)
    {
        if(z==2 && k==3 && l==1) continue;
        if(z==2 && j==3 && l==1) continue;
        ans=(ans+solve(i+1,z,j,k,n))%m;
    }
    dp[i][j][k][l]=ans;
    return ans;
}

int main()
{
    int n;
    cin>>n;
    memset(dp,0,sizeof(dp));
    cout<<solve(0,0,0,0,n)<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N + 1);
  rep(i,0,N + 1) {
    cin >> A[i];
  }
  const i64 INF = 1e16;
  vector<i64> emp(N + 1);
  if(A[0] > 1) {
    cout << -1 << endl;
    return 0;
  }
  emp[0] = 1 - A[0];
  rep(i,1,N + 1) {
    i64 e = emp[i - 1] * 2;
    if(e > INF) e = INF;
    if(e < A[i]) {
      cout << -1 << endl;
      return 0;
    }
    e -= A[i];
    emp[i] = e;
  }
  i64 now = A[N];
  i64 ans = A[N];
  for(int i = N; i --> 0;) {
    now = std::min(now, emp[i]);
    now += A[i];
    ans += now;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

struct UnionFind {

	vi data;

	UnionFind(int n = 0) {
		data.assign(n, -1);
	}

	int find(int k) {
		if (data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return false;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int k) { return -data[find(k)]; }

};

int main() {

	int n, m;
	cin >> n >> m;

	UnionFind uf(n);

	rep(i, m) {
		int x, y, z;
		cin >> x >> y >> z;
		uf.unite(x - 1, y - 1);
	}

	int ans = 0;

	rep(i, n)if (uf.find(i) == i)ans++;
	
	cout << ans << endl;

}

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

using namespace std;

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) { ret *= a; }
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 998244353;
using mint = modint<MOD>;

//0-indexed
template <class T>
class SegmentTree
{
	int size;
	T def;
	vector<T> data;
	function<T(T, T)> f;

public:
	SegmentTree<T>(int _size, T _def, function<T(T, T)> _f) : f(_f), def(_def), size(1)
	{
		while (size < _size)
			size <<= 1;
		data = vector<T>(size * 2, def);
	}
	//bottom-up implementation
	//query for[l, r)
	T query(int l, int r)
	{
		T L = def, R = def;
		for (l += size, r += size; l < r; l >>= 1, r >>= 1)
		{
			if (l & 1)
				L = f(L, data[l++]);
			if (r & 1)
				R = f(data[--r], R);
		}
		return f(L, R);
	}
	void update(int idx, T val)
	{
		idx += size;
		data[idx] = val;
		while (idx > 1)
		{
			idx >>= 1;
			data[idx] = f(data[2 * idx], data[2 * idx + 1]);
		}
	}
	T operator[](int idx)
	{
		return data[idx + size];
	}
};


class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<pair<int, int>> xd(n);
		for(int i=0; i < n; i++)cin >> xd[i].first >> xd[i].second;
		sort(xd.begin(), xd.end());
		SegmentTree<int> st(n, 0, [](int a, int b){return max(a,b);});
		for(int i=0; i < n; i++)st.update(i, i);
		for(int i=n-2; i >= 0; i--){
			int R = distance(xd.begin(), upper_bound(next(xd.begin(), i), xd.end(), make_pair(xd[i].first+xd[i].second, 0)));
			st.update(i, st.query(i, R));
		}
		vector<mint> dp(n+1);
		dp[n] = 1;
		for(int i=n-1; i >= 0; i--){
			dp[i] = dp[i+1] + dp[st[i]+1];
		}
		cout << dp[0] << "\n";
		
		
		
		
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15)<<

signed main(){
    int n,m; cin >> n >> m;
    using P=pair<int,bool>;
    vector<P> p(n);
    rep(i,n){
        p[i].first=1;
        if(i!=0) p[i].second=false;
        else p[i].second=true;
    }
    //rep(i,n) cout<<p[i].first<<' '<<p[i].second<<endl;
    rep(i,m){
        int x,y; cin >> x >> y;
        x--; y--;
        p[x].first--;
        p[y].first++;
        p[y].second|=p[x].second;
        if(p[x].first==0) p[x].second=false;

    }
    //rep(i,n) cout<<p[i].first<<' '<<p[i].second<<endl;
    int res=0;
    rep(i,n){
        if(p[i].second==true) res++;
    }
    cout<<res<<endl;


}

Measured memory_bytes: 1792
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
l=[]
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    sum=c
    for j in range(m):
        sum+=a[j]*b[j]
    if sum>0:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n,m,d; cin >> n >> m >> d;
  
  if( d!=0){
    double s = 2*(m-1)*(n-d); s /= ( n*n);
    cout << fixed << setprecision(10) << s << endl;}
  else{
    double s = ( m - 1) / n;
    cout << fixed << setprecision(10) << s << endl;}

  return 0;}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
int a[1000000];
int zeta[400000],zeta2[400000];
int sum[400000];
signed main() {
	int n; cin >> n;
	rep(i, 1ll << n)cin >> a[i];
	rep(i, 1 << n)zeta[i] = a[i];

	rep(i, n) {
		rep(j, 1 << n) {
			if ((j&(1 << i))) {
				int b[4];
				b[0] = zeta[j], b[1] = zeta[j ^ (1 << i)], b[2] = zeta2[j], b[3] = zeta2[j ^ (1 << i)];
				sort(b, b + 4);
				zeta[j] = b[3]; zeta2[j] = b[2];
			}
		}
	}
	rep(i, 1 << n) {
		sum[i] = zeta[i] + zeta2[i];
	}
	rep(i, 1 << n)sum[i + 1] = max(sum[i], sum[i + 1]);
	for (int i = 1; i < (1 << n); i++)cout << sum[i] << endl;
}

Measured memory_bytes: 15360
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MP(x,y) make_pair(x,y)
#define X first
#define Y second
#define all(x) x.begin(), x.end()

using namespace std;
using ll= long long ;

int main(void){
  string s;
  cin >> s;
  bool flg = false;
  for(int i = 0; i < s.size()-1; ++i){
    if(s[i] == 'A' && s[i+1] =='C'){
      flg = true;
    }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
     int a, b, c, i;
     
     while(0<1){
	  if(scanf("%d", &a)==-1) break; 
	  scanf("%d", &b);
	  
	  c = a + b;
	  
	  i = 1;
	  
	  while(0<1){
	       c = c / 10; 
	       if(c > 0) i++;
	       else break;
	  }
	  printf("%d\n", i);
     }
     
     return 0;
}

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

int main(){
    int x[5]; cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for(int i = 0; i < 5; i++) {  
        if(x[i]==0) cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int H, W;
vector<vector<int>> A(201, vector<int>(201, 0));
vector<vector<P>> root(10);  //pair<辺の距離, 行先の頂点>
vector<vector<int>> dist(10, vector<int>(10, INT_MAX)); //distance[i]は始点(start)から頂点iへの最短距離が入る
bitset<10> used;

void Dijkstra(int start){ //start = 始点
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(0, start));
    while(!que.empty()){
        ll d, t; //d:startからの距離, t:行先
        tie(d, t) = que.top(); que.pop();
        if(used[t]) continue;   //探索済み
        used[t] = true, dist[start][t] = d;
        for(auto e : root[t]){
            if(dist[start][e.second] <= d + e.first) continue;
            que.push(make_pair(d + e.first, e.second));
        }
    }
}

int main(void){
    
    scanf("%d %d", &H, &W);
    for(int i = 0; i <= 9; ++i){
        for(int j = 0; j <= 9; ++j){
            int a; scanf("%d", &a);
            if(i == j) continue;
            root[i].push_back(make_pair(a, j));
        }
    }
    for(int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) scanf("%d", &A[i][j]);
    
    for(int i = 0; i <= 9; ++i){
        if(i == 1) continue;
        used.reset();
        Dijkstra(i);
    }
    
    int ans = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(A[i][j] == -1 || A[i][j] == 1) continue;
            ans += dist[A[i][j]][1];
        }
    }
    printf("%d\n", ans);
    
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
int a[200005],n;
bool b[200005];
bool pd(int x){
	for(int i=1;i<=n*2-1;i++) b[i]=(a[i]>=x);
	b[0]=b[1];
	for(int i=n;i<=n+n-1;i++){if(b[i]==b[i+1])return b[i];if(b[n+n-i]==b[n+n-i-1])return b[n+n-i];}
	return b[1];
}
int main(){
cin>>n;
for(int i=1;i<=n*2-1;i++)cin>>a[i];
int l=1,r=n*2,A=0,md;
while(l<=r){
md=(l+r)/2;
if(pd(md)) l=md+1,A=md;else r=md-1;
}cout<<A;}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int r;
int main()
{
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}


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

const int MOD = 1e9 + 7;
int N , arr[603] , dp[2][303][303]; bool vis1[603] , vis2[603];

void inc(int &a , int b){a = a + b >= MOD ? a + b - MOD : a + b;}

int main(){
	cin >> N; for(int i = 1 ; i <= 2 * N ; ++i) cin >> arr[i];
	int cnt = N;
	for(int i = 1 ; i <= 2 * N ; i += 2)
		if(arr[i] != -1 && arr[i + 1] != -1) cnt -= (vis2[arr[i]] = vis2[arr[i + 1]] = 1);
		else if(arr[i] != -1 || arr[i + 1] != -1) cnt -= (vis1[arr[i] + arr[i + 1] + 1] = 1);
	int now = 0; dp[0][0][0] = 1;
	for(int i = 1 ; i <= 2 * N ; ++i){
		if(vis2[i]) continue;
		memset(dp[now ^ 1] , 0 , sizeof(dp[0]));
		if(vis1[i])
			for(int j = 0 ; j <= N ; ++j)
				for(int k = 0 ; k <= N ; ++k){
					if(dp[now][j][k]){
						if(k) inc(dp[now ^ 1][j][k - 1] , 1ll * dp[now][j][k] * k % MOD);
						inc(dp[now ^ 1][j + 1][k] , dp[now][j][k]);
					}
				}
		else
			for(int j = 0 ; j <= N ; ++j)
				for(int k = 0 ; k <= N ; ++k)
					if(dp[now][j][k]){
						inc(dp[now ^ 1][j + 1][k] , dp[now][j][k]);
						inc(dp[now ^ 1][j][k + 1] , dp[now][j][k]);
						if(j) inc(dp[now ^ 1][j - 1][k] , dp[now][j][k]);
					}
		now ^= 1;
	}
	for(int i = 1 ; i <= cnt ; ++i) dp[now][0][0] = 1ll * dp[now][0][0] * i % MOD;
	cout << dp[now][0][0]; return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/








string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;

	int ans = inf;
	int N = S.length();

	// 10101...
	{
		int cnt = 0;
		rep(i, 0, N) if ((S[i] - '0') == i % 2) cnt++;
		chmin(ans, cnt);
	}

	// 01010...
	{
		int cnt = 0;
		rep(i, 0, N) if ((S[i] - '0') != i % 2) cnt++;
		chmin(ans, cnt);
	}

	cout << ans << endl;
}


Measured memory_bytes: 512