akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	ll a, b, x;
	cin >> a >> b >> x;
	ll b_ = b / x + 1;
	ll a_ = a / x + 1;
	ll tmp = a % x == 0;
	cout << b_ - a_  + tmp<< endl;
	return 0;
}

Measured memory_bytes: 256
// 選択ソート
#include<iostream>
#include<algorithm>
using namespace std;

static const int MAX_N = 100;

void selectionSort(int A[], int n);

int main(void)
{
    int N;
    int ary_sequence[MAX_N];

    cin >> N;

    for(int i = 0; i < N; i++)
    {
        cin >> ary_sequence[i];
    }

    selectionSort(&ary_sequence[0], N);

    return 0;
}

// 選択ソートを実施する関数
void selectionSort(int A[], int n)
{

    int count = 0;
    // 最小値の存在する配列の要素No.
    int min_pos;

    for(int i = 0; i < n; i++)
    {
        min_pos = i;

        for(int j = i; j < n; j++)
        {
            if( A[j] < A[min_pos] )
            {
                // 最小値の存在する位置を保存する
                min_pos = j;
            }
        }

        if( i != min_pos )
        {
            // 最小値を移動させる
            swap(A[i], A[min_pos]);

            count++;
        }
    }

    // 結果表示用
   for(int i = 0; i < n; i++)
   {
       if( i )
       {
           cout << ' ';
       }

       cout << A[i];
   }

   cout << endl;
   cout << count << endl;

    return;
}



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

int main() {
  int A , B;
  cin >> A >> B;
  int answer = 0;
  for(int i = A; i <= B; i++){
    if(i % 10 == i / 10000 && (i % 100) / 10 == (i % 10000) / 1000){
      answer++;
    }
  }   
  cout << answer << endl;
}


Measured memory_bytes: 256
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

Measured memory_bytes: 7760
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            

            String[]str= br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            String op = (str[1]);
            int b = Integer.parseInt(str[2]);
            int result = 0;
            
            if("?".equals(op)){
                break;
            }else if("+".equals(op)){
                result=a+b;
            }else if("-".equals(op)){
                result=a-b;
            }else if("*".equals(op)){
                result=a*b;
            }else if("/".equals(op)){
                result=a/b;
            }
           
               System.out.println(result);
        }
    }
}

Measured memory_bytes: 17116
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
	var board = new string[3,3];
    var n = 0;
    
    for(var i = 0;i < 3;i++){
    	var x = ReadLine().Split(' ');
        for(var j = 0;j < 3;j++){
        	board[i,j] = x[j];
        }
    }
    
    n = int.Parse(ReadLine());
    
    for(var i = 0;i < n;i++){
    	var x = ReadLine();
      	for(var j = 0;j < 3;j++){
          	for(var k = 0;k < 3;k++){
				if(board[j,k].Equals(x)){
    	        	board[j,k] = "101";
            	}
            }
        }
    }
    
    for(var i = 0;i < 3;i++){
        var x = new string[3];
      	var y = new string[3];
        for(var j = 0;j < 3;j++){
        	x[j] = board[i,j];
          	y[j] = board[j,i];
        }
      	if(x.All(a => a.Equals("101"))){
          	Write("Yes");
          	return;
        }else if(y.All(b => b.Equals("101"))){
          	Write("Yes");
          	return;
        } 
    }

        var s = new string[3];
      	var t = new string[3];
    
    int o,p;
    
    for(o = 0,p = 2 ;o < 3;o++,p--){
		s[o] = board[o,p];
      	t[o] = board[p,p];
    }
    
      	if(s.All(a => a.Equals("101"))){
          	Write("Yes");
          	return;
        }else if(t.All(b => b.Equals("101"))){
          	Write("Yes");
          	return;
        }
    
    Write("No");
    

  }
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  vector<ll> H(N);
  for (ll i = 0; i < N; i++) cin >> H.at(i);
  sort(H.begin(), H.end(), greater<ll>());
  ll tot = 0;
  for (ll i = K; i < N; i++) tot += H.at(i);
  cout << tot << endl;

  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int a, b, c;
  cin>>a>>b>>c;
  if(b-a==c-b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

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

long long lcm(long long x, long long y){
  long long xx=((x>y)?x:y), yy=((x>y)?y:x);
  while(yy>0){
    long long rr=xx%yy;
    xx=yy;
    yy=rr;
  }
  return x/xx*y;
}

int main(){
  int N,M; cin >> N >> M;
  long long b[100010];
  for(int i=0; i<N; i++){
    long long a; cin >> a;
    b[i]=a/2;
  }
  long long l=1;
  for(int i=0; i<N; i++){
    l=lcm(l,b[i]);
    if(l>M){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int i=0; i<N; i++){
    if((l/b[i])%2==0){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << ((M+l)/l)/2 << endl;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n;
    cin >> n;
    vll p(n);
    REP(i, n) {
      cin >> p[i];
    }

    ll count = 0;
    REP(i, n - 2) {
      vll buff(3);
      REP(j, 3) {
        buff[j] = p[i + j];
      }
      SORT(buff);
      if(buff[1] == p[i + 1]) {
        count++;
      }
    }

    COUT(count);
}

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

/*

5
1 3 5 4 2
*/


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

int main(int argc, const char * argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a+b == c){
        cout << "Yes";
    }else if(a+c == b){
        cout << "Yes";
    }else if(b+c == a){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 764
N, M, X = map(int, input().split())
A = list(map(int, input().split()))


ans = []

tmp = 0
for i in range(0, X):
    if i in A:
        tmp += 1

ans.append(tmp)

tmp = 0
for i in range(X, N):
    if i in A:
        tmp += 1

ans.append(tmp)

print(min(ans))


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli h;
	cin>>h;
	lli n;
	cin>>n;

	REP(i,0,n){
		lli a;
		cin>>a;
		h-=a;
	}
	if(h<=0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int i;
    for(i = 0; i < n; i++){
        bool flag = true;
        for(int j = i; j < n; j++){
            if(s[j] != t[j-i]) flag = false;
        }
        if(flag) break;
    }
    cout << n + i << endl;
    return 0;
}


Measured memory_bytes: 3596
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N = int(input())
    A = list(map(int, readline().split()))
    ans = 1
    if 0 in set(A):
        print(0)
        return
    for a in A:
        ans *= a
        if ans > pow(10,18):
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21604
S = int(input())

MOD = 10**9 + 7
class Mint:
    def __init__(self, value=0):
        self.value = value % MOD
        if self.value < 0: self.value += MOD

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, MOD
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        if u < 0: u += MOD
        return u

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % MOD
        return self

    def __add__(self, other):
        new_obj = Mint(self.value)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other)) % MOD
        if self.value < 0: self.value += MOD
        return self

    def __sub__(self, other):
        new_obj = Mint(self.value)
        new_obj -= other
        return new_obj

    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % MOD
        return self

    def __mul__(self, other):
        new_obj = Mint(self.value)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other)
        self *= other.inverse()
        return self

    def __floordiv__(self, other):
        new_obj = Mint(self.value)
        new_obj //= other
        return new_obj

    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj //= self
        return new_obj

class FactorialUtils:
    def __init__(self, n):
        self.fac = [1] * (n + 1)
        self.ifac = [1] * (n + 1)
        for i in range(2, n + 1): self.fac[i] = self.fac[i - 1] * i % MOD
        self.ifac[n] = pow(self.fac[n], MOD - 2, MOD)
        for i in range(n, 1, -1): self.ifac[i - 1] = self.ifac[i] * i % MOD

    def choose(self, n, r):
        if r < 0 or r > n: return 0
        return (self.fac[n] * self.ifac[n - r] % MOD) * self.ifac[r] % MOD

    def multichoose(self, u, k):
        return (self.fac[u + k - 1] * self.ifac[u - 1] % MOD) * self.ifac[k] % MOD

    def permutation(self, n, r):
        if r < 0 or r > n: return 0
        return self.fac[n] * self.ifac[n - r] % MOD

fu = FactorialUtils(S)
ans = Mint()
for n in range(1, S + 1):
    if S < 3 * n: break
    r = S - 3 * n
    ans += fu.multichoose(n, r)
print(ans)


Measured memory_bytes: 65272
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 3000;

long long r, D, x[MAX_N];

int main(int argc, char **argv) {
    std::cin >> r >> D >> x[2000];

    for (int i = 2001; i <= 2010; i++) {
        x[i] = r*x[i-1] - D;
    }

    for (int i = 2001; i <= 2010; i++) {
        std::cout << x[i] << std::endl;
    }

    return 0;
}

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

bool is_prime(int n)
{
  for (int i = 2; i*i<=n; i++) {
    if (n%i == 0) {
      return false;
    }
  }
  return n != 1;
}

int main()
{
  int n; cin >> n;
  int ans = 0;
  rep(i, n) {
    int a; cin >> a;
    if (is_prime(a)) ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3104
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
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...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>p(n);
  rep(i,0,n){
    cin>>p[i];
    p[i]--;
  }
  vector<ll>c(n);
  rep(i,0,n)cin>>c[i];
  res=-INF;
  rep(i,0,n){
    ll cnt=0,score=0;
    ll now=i;
    vector<ll>v;
    while(1){
      v.PB(score);
      now=p[now];
      score+=c[p[now]];
      cnt++;
      if(now==i)break;
    }
    ll rem=k%cnt;
    ll t=k/cnt;
    rep(j,0,cnt){
      if(j<=rem){
        if(score>0)chmax(res,score*t+v[j]);
        else if(j!=0)chmax(res,v[j]);
        else if(k>=cnt)chmax(res,score);
      }
      else{
        if(t>0){
          if(score>0)chmax(res,score*(t-1)+v[j]);
          else chmax(res,v[j]);
        }
      }
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
int nature(int a) {
  return max(a, -a);
}
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
    }
    int answer = 1000000000;
    for (int i = 0; i <= N - K; i++) {
        answer = min(answer, X.at(i + K - 1) - X.at(i) + min(nature(X.at(i)), nature(X.at(i + K - 1))));
    }
    cout << answer << endl;
}

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

int main(){
    int ans=0,sum=0;
    int n;
    
    cin >>n;
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << n*n*n << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}



Measured memory_bytes: 3100
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

A, B = 1, N
for lr in LR:
    L, R = lr
    if R < A or B < L:
        print(0)
        exit()

    if A <= L <= R <= B:
        A, B = L, R
    elif L <= A <= R <= B:
        B = R
    elif A <= L <= B <= R:
        A = L
print(B - A + 1)


Measured memory_bytes: 27332
#include <iostream>

using namespace std;

int main(){

	int A[5];
	int B[5];

	while(cin >> A[0] >> A[1] >> A[2] >> A[3] >> B[0] >> B[1] >> B[2] >> B[3]){

		int hit = 0 , blow = 0;
		
		for(int i = 0; i < 4; i++){
			if(A[i] == B[i]){
					hit++;
				}
			for(int j = 0; j < 4; j++){

				if(A[i] ==  B[j] && A[i] != B[i]){
					blow++;
				}
			}
		}

		cout << hit << " " << blow << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>

namespace test {
  std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
  }
}

using namespace std;



int main(void) {
  long long int n,m,c; cin >> n >> m >>c;
  long long int *b = new long long int[m];
  long long int *a = new long long int[m];
  int result = 0;
  long long int total = 0;
  for(int i = 0; i< n+1; i++){
    for(int j =0; j < m; j++){
      if(i == 0){
        cin >> b[j];
      } else {
        cin >> a[j];
        total += a[j] * b[j];
      }
    }
    total += c;
    if(i != 0 && total > 0){
      result++;
    }
    
    total = 0;
  }

  cout << result << endl;

  return 0;
}

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

const int MAX_N = 100000;
const int INF = LLONG_MAX/10;

int N, K, A[MAX_N + 1];

signed main()
{
	int ans = -INF, score = 0, latte = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		if (A[i] > 0) score += A[i];
	}
	int l = 0, r = 0;
	while (r < N)
	{
		while (r < l + K)
		{
			latte += A[r];
			if (A[r] > 0) score -= A[r];
			r++;
		}
		ans = max(ans, score + max(latte, 0ll));
		latte -= A[l];
		if (A[l] > 0) score += A[l];
		l++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define MAX_V 5005
#define INF 1e9
using namespace std;

/*????°??????¨???(???????????£????????????????????¨) O(F|V||E|)*/

//????????¨????§???????(???????????????????????????????????????)
struct edge{int to, cap,cost,rev;};
int V;                         //????????°
vector<edge> G[MAX_V];         //??°???????????£??\???????????¨???
int dist[MAX_V];               //???????????¢
int prevv[MAX_V],preve[MAX_V]; //??´??????????????¨???

// from??????to??????????????????cap????????????cost???????????°????????????????????????
void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,G[to].size()});
  G[to].push_back((edge){from,0,-cost,G[from].size()-1});
}
int ans=INF;
//s??????t????????????f???????°??????¨???????±???????
//??????????????´???-1?????????
void min_cost_flow(int s,int t,int f){
  int res=0;
  while(f>0){
    //????????????????????????????????????,s-t????????????????±???????
    fill(dist,dist+V,INF);
    dist[s]=0;
    bool update = true;
    while(update){
      update = false;
      for(int v=0; v<V ;v++){
	if(dist[v]==INF) continue;
	for(int i=0; i<G[v].size(); i++){
	  edge &e = G[v][i];
	  if(e.cap > 0 && dist[e.to] > dist[v]+e.cost) {
	    dist[e.to] = dist[v] + e.cost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    update = true;
	  }
	}
      }
    }
    if(dist[t]==INF) return;
    //s???t?????????????????£??????????????????
    int d = f;
    for(int v=t; v!=s; v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d*dist[t];
    ans=min(ans,res);
    for(int v=t; v!=s; v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return;
}

map<int,int> m;
int n,a[MAX_V],b[MAX_V];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    m[a[i]]=0; m[b[i]]=0;
  }
  int s=n+m.size(),g=s+1;
  map<int,int>::iterator ite=m.begin();
  int idx=n;
  while(ite!=m.end()){
    (*ite).second=idx;
    add_edge(idx,g,1,0);
    ite++; idx++;
  }
  for(int i=0;i<n;i++)add_edge(s,i,1,0);
  for(int i=0;i<n;i++){
    add_edge(i,m[a[i]],1,-b[i]);
    add_edge(i,m[b[i]],1,-a[i]);
  }
  V=g+1;
  min_cost_flow(s,g,INF);
  cout<<-ans<<endl;
  return 0;
}

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

int main()
{
    int n;
    vector<int> a;
    vector<int> aaa(1000010, 0);

    cin >> n;
    a = vector<int>(n);
    rep(i, n) cin >> a[i];
    for (int x : a)
    {
        if (aaa[x] != 0)
        {
            aaa[x] = 2;
            continue;
        }
        for (int j = x; j < 1000010; j += x)
        {
            aaa[j]++;
        }
    }
    int ans = 0;
    rep(i, n)
    {
        //    cout << aaa[a[i]] << endl;
        if (aaa[a[i]] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8008
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

typedef struct line{
 int lpos;
 int rpos;
}Line;


bool asc(const Line& left, const Line& right){
 return left.rpos == right.rpos ? left.lpos<right.lpos :left.rpos <right.rpos;
}

int main(void){
 int n,m;
 int cutpos;
 int ans=0;
 Line a;
 vector<Line> M;

 cin>>n>>m;
 for(int i=0;i<m; ++i){
  cin>>a.lpos;
  cin>>a.rpos;
  M.push_back(a);
 }

 sort(M.begin(),M.end(),asc);
 
 cutpos=M[0].rpos;
 ++ans;

 for(int i=1; i<m; ++i){
  if(M[i].lpos<cutpos);
  else {
   cutpos=M[i].rpos;
   ++ans;
  }
 }
 std::cout<<ans<<std::endl;
 return 0;
}




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

#define DEBUG 1

#if (DEBUG == 1)

#endif

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

  set<string> words;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    string __str;
    cin >> __str;
    s.at(i) = __str;
    words.insert(__str);
  }

  int M;
  cin >> M;
  
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    string __str;
    cin >> __str;
    t.at(i) = __str;
    words.insert(__str);
  }

  int max_point = 0;
  for (auto it = words.begin(); it != words.end(); it++) {
    int point = 0;
    
    for (int i = 0; i < N; i++) {
      if (s.at(i) == *it) {
	point++;
      }
    }

    for (int i = 0; i < M; i++) {
      if (t.at(i) == *it) {
	point--;
      }
    }

    if (point > max_point) {
      max_point = point;
    }
  }

  cout << max_point << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

int main(int argc, char** argv)
{
	int N, K, d, di, ans;
	std::vector<bool> v;
	std::cin >> N >> K;
	v.resize(N, false);
	for (int i = 0; i < K; i++)
	{
		std::cin >> d;
		for (int j = 0; j < d; j++)
		{
			std::cin >> di;
			v[di-1] = true;
		}
	}
	ans = 0;
	for (bool x : v)
	{
		if (!x) ans++;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	vector<vector<int>> a(3,vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a.at(i).at(j);
		}
	}
	int N;
	cin >> N;
	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b.at(i);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (b.at(i) == a.at(j).at(k)) {
					a.at(j).at(k) = 0;
				}
			}
		}
	}
	int record = 0;
	for (int i = 0; i < 3; i++) {
		if (a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0) {
			record++;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0) {
			record++;
		}
	}
		if (a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0) {
			record++;
		}
		if (a.at(0).at(2) == 0 && a.at(1).at(1) == 0 && a.at(2).at(0) == 0) {
			record++;
		}
		if (record > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=[0]*9
for i in range(n):
  if a[i]<400:
    ans[0]=1
  elif a[i]<800:
    ans[1]=1
  elif a[i]<1200:
    ans[2]=1
  elif a[i]<1600:
    ans[3]=1
  elif a[i]<2000:
    ans[4]=1
  elif a[i]<2400:
    ans[5]=1
  elif a[i]<2800:
    ans[6]=1
  elif a[i]<3200:
    ans[7]=1
  else:
    ans[8]+=1
print(max(sum(ans[:8]),1),sum(ans))

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
 let n:i32=read();
 let x:i32=read();
 let mut ans=None;
 'outer: for i in 0..n+1 {
   for j in 0..n-i+1 {
     let k = n-i-j;
     if 10000*i+5000*j+1000*k==x {
       ans=Some((i,j,k));
       break 'outer;
     }
   }
 }
 let (x,y,z)=ans.unwrap_or((-1,-1,-1));
 println!("{} {} {}",x,y,z);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
typedef long long int unsigned lliu;
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
#define MAXN 200005
int costo[MAXN];

lli mem[MAXN];
int n;

lli dp(int i){
	if(i==n-2)
		return abs(costo[i] - costo[i+1]);
	if(i>=n-1)
		return 0;
	if(mem[i]!=-1)
		return mem[i];
	mem[i]=min(dp(i+1) + abs(costo[i]-costo[i+1]), dp(i+2) + abs(costo[i]-costo[i+2]));
	return mem[i];
}

int main(){
	fastIO
	cin>>n;
	forn(i, n){
		cin>>costo[i];
	}

	memset(mem, -1, sizeof(mem));
	cout<<dp(0)<<endl;

	return 0;
}

Measured memory_bytes: 3840
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int[] count = new int[26];

            for (char cc : in.next().toCharArray()) {
                count[cc - 'a']++;
            }

            for (int i = 0; i < 26; i++) {
                if (count[i] == 0) {
                    out.println((char) ('a' + i));
                    return;
                }
            }

            out.println("None");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 23508
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FOF(i,a,b) for(int i=a;i< b;i++)
using namespace std;
const int N=100100;
int n,K;
struct subs{
	int v[N];
	subs iv(){
		subs x;
		FOR(i,1,n) x.v[v[i]]=i;
		return x;
	}
	subs operator * (const subs&x)const{
		subs y;
		FOR(i,1,n) y.v[i]=v[x.v[i]];
		return y;
	}
	subs pw(int K){
		subs x;
		static int vi[N],s[N];
		FOR(i,1,n)if(!vi[i]){
			int m=0;
			for(int u=i;!vi[u];u=v[u]) vi[u]=1,s[m++]=u;
			FOF(j,0,m) x.v[s[j]]=s[(j+K)%m];
		}
		return x;
	}
}p,q,r,w,a[7];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&K);K--;
	FOR(i,1,n) scanf("%d",&p.v[i]);
	FOR(i,1,n) scanf("%d",&q.v[i]);
	r=q*p.iv()*q.iv()*p;
	a[0]=p;a[1]=q;
	FOR(i,2,5) a[i]=a[i-1]*a[i-2].iv();
	r=r.pw(K/6);
	w=r*a[K%6]*r.iv();
	FOR(i,1,n) cout<<w.v[i]<<' ';cout<<'\n';
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
#define Inf 1000000000
using namespace std;
int H,W;

int main() {
    int N;
    cin>>N;
    int cx=0;
    int cy=0;
    int ct=0;
    
    bool ok=true;
    for(int i=1;i<=N;i++) {
        int t,x,y;
        cin>>t>>x>>y;
        
        int d = abs(x-cx)+abs(y-cy);
        
        
        if (d > t-ct || (t-ct+d)%2==1) {
            ok=false;
        }
        
        ct=t;
        cx=x;
        cy=y;
    }
    
    if (ok)
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<string.h>
#include<algorithm>
#include<vector>
#define il inline
#define ll long long
#define INF 0x7fffffff
#define rint register int
using namespace std;
int const N=16001;
vector<int> xoy[2];
int fxy[2];
bool dp[N][N];
il char gc(){
	static char BB[1000000],*S=BB,*T=BB;
	return S==T&&(T=(S=BB)+fread(BB,1,1000000,stdin),S==T)?EOF:*S++;
}
il ll re(){
	ll x=0,w=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
	return x*w;
}
int main(){
	char s[8005];
	scanf("%s",s);
	int xy=0,lon=0;
	for(int i=0;i<strlen(s);i++){
		if(s[i]=='F') lon+=1;
		else{if(lon) xoy[xy].push_back(lon);lon=0,xy^=1;}
	}
	xoy[xy].push_back(lon);
	/*for(int i=0;i<xoy[0].size();i++){
		cout<<xoy[0][i]<<endl;
	}*/
	scanf("%d%d",&fxy[0],&fxy[1]);
	int fl[2]={0};
	for(int k=0;k<=1;k++){
		memset(dp,0,sizeof(dp));
		dp[0][8000]=1;
		int MAX=xoy[k].size();
		for(int i=1;i<=MAX;i++){
			if(s[0]!='T'&&k==0&&i==1&&xoy[k].size()>=1) {dp[1][xoy[k][0]+8000]=1;continue;}
			for(int j=0;j<N;j++){
				 
				if(j-xoy[k][i-1]>=0)dp[i][j]|=dp[i-1][j-xoy[k][i-1]];
				dp[i][j]|=dp[i-1][j+xoy[k][i-1]];
			}
		}
		if(dp[MAX][fxy[k]+8000]) fl[k]=1;
	}
	if(fl[0]&&fl[1]) printf("Yes\n");
	else printf("No\n");
	return 0;
	
	
} 

Measured memory_bytes: 250368
n,m = map(int,input().split())
x = [None]*n
for _ in range(m):
    s,c = map(int,input().split())
    s-=1
    if x[s] is None:
        x[s] = c
    else:
        if x[s] != c:
            print("-1")
            exit(0)

if all(t is None for t in x):
    if n==1:
        print("0")
        exit(0)
    else:
        print("1" + "0"*(n-1))
        exit(0)

if x[0] == 0:
    if n==1 :
        print("0")
        exit(0)
    else:
        print("-1")
        exit(0)
if x[0] is None:
    x[0] = 1
for i in range(1,n):
    if x[i] == None:
        x[i] = 0

print("".join(map(str,x)))

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

int main(){
	char A[1005],B[1005];
	scanf("%s %s",A,B);
	int lenA = strlen(A);
	int lenB = strlen(B);

	if(lenA > lenB) printf("GREATER\n");
	if(lenA < lenB) printf("LESS\n");
	if(lenA == lenB){
		if(strcmp(A,B) > 0) printf("GREATER\n");
		if(strcmp(A,B) < 0) printf("LESS\n");
		if(strcmp(A,B) == 0) printf("EQUAL\n");
	}

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cmath>
#include<cstdio>
#define ll long long
using namespace std;
const int N=100010;

struct node{
    int a;
    int b;
};
bool cmp(struct node m, struct node n)
{
    return m.a<n.a;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    int n,m;
    node node[N];
    int ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>m;
        node[i].a=m;
        node[i].b=i+1;
    }
    sort(node,node+n,cmp);
for(int i=0;i<n;i++){
  cout<<node[i].b<<" ";
 }
 cout<<endl;
 return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int n;
  while(cin>>n, n){
    int a=0, ai=-1;
    int b=0, bi=-1;
    vector<char> c(n);
    rep(i,n) cin>>c[i];
    vector<int> vec(26, 0);
    rep(i,n){
      int v = c[i]-'A';
      vec[v]++;
      if(ai==v) a++;
      else if(bi==v){
        b++;
        if(b>a)swap(a,b),swap(ai,bi);
      }
      else {
        int t,ti;
        if(a > vec[v]) t=vec[v], ti=v;
        else t=a, ti=ai, a=vec[v], ai=v;
        if(b < t) b=t, bi=ti;
      }
      if(a > b + (n-i-1)) {printf("%c %d\n", ai+'A', i+1); break;}
      if(i==n-1) cout << "TIE" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3140
#include<stdio.h>

int isrectangle(int s1,int s2,int d)
{
	if(d*d==s1*s1+s2*s2){return 1;}
	else{return 0;}
}

int isrhombus(int s1,int s2)
{
	if(s1==s2){return 1;}
	else{return 0;}
}

int main()
{
	int side1,side2,diagonal,rectnum=0,rhomnum=0;

	while(scanf("%d,%d,%d",&side1,&side2,&diagonal)!=EOF)
	{
		rectnum+=isrectangle(side1,side2,diagonal);
		rhomnum+=isrhombus(side1,side2);
	}
	printf("%d\n%d\n",rectnum,rhomnum);
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (std::int64_t i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)ret.push_back(n / i);
        }
    }
    sort(ALL(ret));
    return ret;
}

void Main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        if (divisor(i).size() == 8)++ans;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    string s;
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> p(n);
	rep(i,n)cin>>p[i];

	vector<int> is_sort(n,0);

	int left=0,right=0;
	while(right<n-1){
		if(p[right]>p[right+1]){
			right++;
			left=right;
		}else{
			right++;
			if(right-left+1==k)is_sort[left]=1,left++;
		}
	}
	int sorted_num = accumulate(all(is_sort),0);
	if(sorted_num>0)sorted_num--;

	// for(auto x:is_sort)cout<<x<<" ";
	// cout<<endl;

	set<int> s,rev_s;
	rep(i,k)s.emplace(p[i]),rev_s.emplace(-p[i]);
	int res=0;
	left=0,right=k-1;
	while(right<n-1){
		int max_ = *rev_s.begin()*-1;
		int min_ = *s.begin();

		if(p[left] == min_ && p[right+1]>max_ && is_sort[left]==0){
			// cout<<left+1<<" "<<p[right+1]<<endl;
			res++;
		}
		s.erase(p[left]);
		s.emplace(p[right+1]);
		rev_s.erase(-p[left]);
		rev_s.emplace(-p[right+1]);
		left++,right++;
	}

	cout<<n-k+1-sorted_num-res<<endl;

	return 0;
}

Measured memory_bytes: 20608
import java.util.*;

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

        char[] s = sc.next().toCharArray();

        int c = 'a';
        int[] cnt = new int[26];
        for (int i = 0; i < s.length; i++) {
            cnt[s[i] - c]++;
        }
        
        boolean ans = true;
        for (int i = 0; i < 26; i++) {
            if (cnt[i] != 0 && cnt[i] % 2 == 1)
                ans = false;
        }

        System.out.println(ans ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
#include <iostream> 
#include <vector> 
#include <algorithm> 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)  
	bool cmp(const pair<int,char> &a,const pair<int,char> &b){  
		return a.first > b.first; 
}

int main(void){ 
	int n;   
	while(cin >> n,n){       
		vector< pair<int,char> > data(n);      
		rep(i,n){          
			int sum = 0;     
			cin >> data[i].second;   
			rep(j,n-1){              
				int t;                
				cin >> t;              
				sum += (t==0?10:t==2?1:0);  
			} 
			data[i].first = sum; 
		}   
		stable_sort(data.begin(),data.end(),cmp);  
		rep(i,n){         
			cout << data[i].second << endl;       
		}
	}
	return 0;
} 

Measured memory_bytes: 0
package main

import "fmt"

func main(){
	var S string;
	fmt.Scan(&S);
	
	ans := 0;
	for i:=0 ; i < len(S)/2 ; i++ {
		if S[i] != S[len(S)-1-i]{
			ans++;
		}
	}
	fmt.Println(ans);
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAX 300000
int main(void) {
    int n, i, cnt=0, ans=MAX-1;
    char s[MAX];
    scanf("%d %s", &n, s);
    
    for(i=1; i<n; i++) {
        if(s[i]=='E')
            cnt++;
    }
    ans = cnt;
    for(i=1; i<n; i++) {
        if(s[i-1]=='E' && s[i]=='E')
            cnt--;
        else if(s[i-1]=='W' && s[i]=='W') {
            cnt++;
        }
        
        if(cnt<ans)
            ans = cnt;
    }
    
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define N 100000

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[N];

int D[N];
 
int Depth(int x){
  int sum = 0;
  while(T[x].p != -1){
    sum++;
    x = T[x].p;
  }
  return sum;
}

int main(void){
  int n,i,j,k,c,s,node;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r = -1;
  }

  for(i=0;i<n;i++){
    scanf("%d",&node);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0){
	T[node].l = c;
	T[c].p = node;
	s = c;
      }else{
	T[s].r = c;
	T[c].p = node;
	s = c;
      }
    }
  }

  for(i=0;i<n;i++){
    D[i] = Depth(i);
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d,",i,T[i].p,D[i]);

    if(T[i].p == -1) printf(" root, [");
    else if(T[i].l == -1) printf(" leaf, [");
    else printf(" internal node, [");

    if(T[i].l != -1){
      while(1){

	if(T[T[i].l].r == -1){
	  printf("%d",T[i].l);
	  break;
	}
	else{
	  printf("%d, ",T[i].l);
	  T[i].l = T[T[i].l].r;
	}
      }
    }
    printf("]\n");
  }
  return 0;
}

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

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

  bool isApproved = true;
  int i = 0;
  while (i < a.size()) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        isApproved = false;
        break;
      }
    }
    i++;
  }

  if (isApproved) {
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <math.h>

using namespace std;
#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

li gcd(li a,li b) {
    return a % b == 0 ? b : gcd(b, a % b);
}

int main(void) {
    string a, b;
    cin >> a >> b;
    string c = a + b;

    li num = stoi(c);
    double n = sqrt(num);
    if (ceil(n) == floor(n)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            
            while((line = stdReader.readLine()) != null) {
                String[] input = line.split(" ", 0);
                int h = Integer.parseInt(input[0]);
                int w = Integer.parseInt(input[1]);
                
                // h, w?????¨??????0?????¨?????????
                if(h == 0 && w == 0) {
                    break;
                }
                
                for(int i = 0; i < h; i++) {
                    for(int j = 0; j < w; j++) {
                        if((i + j) % 2 == 0) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 31076