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

int main() {
    int a[4][3][10] = {0};
    int n,b,f,r,v;
    cin >> n;

    for (int tmp = 0; tmp < n; ++tmp) {
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }

    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 10; ++k) {
                cout << " " << a[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) {
            cout << "####################" << endl;
        }
    }
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll a;cin>>a;
    ll res=a+a*a+a*a*a;
    cout<<res<<endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int n;
int c[1 << 18];
ll dp[1 << 18];
int ri = -1;
vector<int> v[1 << 18];
int main(){
	cin >> n;
	rep(i, n) {
		cin >> c[i];
		v[c[i]].push_back(i);
	}
	dp[0] = 1;
	rep(i, n) {
		int loc = lower_bound(v[c[i]].begin(), v[c[i]].end(), i) - v[c[i]].begin();
		if (loc + 1 < v[c[i]].size()) {
			int nex = v[c[i]][loc + 1];
			if (i + 1 != nex) {
				(dp[nex] += dp[i]) %= mod;
			}
		}
		(dp[i + 1] += dp[i]) %= mod;
	}
	cout << dp[n] << endl;
	//stop
	return 0;
}


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


typedef unsigned long long int ulint;

ulint myPow(ulint x, ulint p) {
  if (p == 0) return 1;
  if (p == 1) return x;

  ulint tmp = myPow(x, p/2);
  if (p%2 == 0) return tmp * tmp;
  else return x * tmp * tmp;
}

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

  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  // N % 2 == 0

  ulint fives = 0;
  
  int k = 1; // power of 5

  while (myPow(5, k) * 2 <= N) {
    ulint div = myPow(5, k) * 2;

    ulint fives_by_div = N / div; // round down
    fives += fives_by_div;
    
    ++k;
  }

  cout << fives << endl;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S_ = S()
    T = S()
    a = len(S_)
    b = len(T)
    cnt_list = []

    for i in range(a - b + 1):
        cnt = 0
        S_1 = S_[i:i + b]
        for j in range(b):
            if S_1[j] == T[j]:
                cnt += 1
        cnt_list.append(cnt)

    ans = b - max(cnt_list)
    print(ans)



if __name__ == "__main__":
    main()




Measured memory_bytes: 69188
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
 
int dp[10000][10000]={0};
 
signed main(){
    FASTER;
    int n,m;cin>>n>>m;
    vector<vector<char> > v(n,vector<char>(m));cin>>v;
    for(int i=0;i<m;i++){
        if(v[0][i]=='#')break;
        dp[0][i]=1;
    }
    for(int i=0;i<n;i++){
        if(v[i][0]=='#')break;
        dp[i][0]=1;
    }
  	dp[0][0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(v[i][j]!='#')dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;
        }
    }
    cout<<dp[n-1][m-1];
 
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
template<typename TypeInt>
TypeInt G_C_D(TypeInt a, TypeInt b)
{
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    while (b != 0) {
        a %= b;
        if (a == 0) return b;
        b %= a;
    }
    return a;
}

template<typename TypeInt>
TypeInt G_C_D(const std::vector<TypeInt> &list)
{
    if (list.size() < 2)
        throw "内容が1以下\n";
 
    TypeInt a = list[0];
    for (size_t i = 1; i < list.size(); ++i) {
        a = G_C_D(a, list[i]);
    }
    return a;
}
template<typename TypeInt>
TypeInt L_C_M(TypeInt a, TypeInt b) {
    if( a == 0 && b == 0)return 0;
    return a / G_C_D(a, b) * b;
}
template<typename TypeInt>
TypeInt L_C_M(const std::vector<TypeInt> &list)
{
    if (list.size() < 2)
        throw "内容が1以下\n";
 
    TypeInt a = list[0];
    for (size_t i = 1; i < list.size(); ++i) {
        a = L_C_M(a, list[i]);
    }
    return a;
}

int main(){
	int n;
	cin>>n;
	vector<ll> vec(n);
	FDS(i,n){
		cin>>vec[i];
	}
	int ans=-n;
	FDS(i,n){
		ans+=vec[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import Control.Monad
 
main = do
  n <- readLn
  ss <- map read <$> replicateM n getLine
  putStr . show . f $ ss
 
f xs
  | mod (sum xs) 10 /= 0 = sum xs
  | all (\x -> mod x 10 == 0) xs = 0
  | otherwise = (sum xs) - minimum [x | x <- xs, mod (x - sum xs) 10 /= 0] 

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

signed main(){
	int ans = 0;
	string s,t = "CODEFESTIVAL2016";
	cin >> s;
	for(int i = 0;i < 16;i++){
		if(s[i] != t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == 'o')
        {
            count++;
        }
    }
    cout << 700 + 100 * count;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '1') {
            s[i] = '9';
        }
        else {
            if (s[i] == '9') {
                s[i] = '1';
            }
        }
    }
    cout << s << endl;

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
        solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int X,Y;
    cin>>X>>Y;
 
    for (int i=0;i<=X;i++)
    {
        int j=X-i;
        if (i*2+j*4==Y) 
        {
            cout<<"Yes\n";
            return 0;
        }
    }
 
    cout<<"No\n";
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
using namespace std;

int main() {
	int N, X; cin >> N >> X;
	int now=0, ans=0;
	for(int i=0; i<N; ++i){
	    if(now<=X) ++ans;
	    int L; cin >> L;
	    now += L;
	}
	if(now<=X) ++ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
class Dice:
  def make_dice(self, value):
    self.face = value
  def move(self, direc):
    if direc == "N":
      self.face = [self.face[1], self.face[5], self.face[2], self.face[3], self.face[0], self.face[4]]
      return self.face
    elif direc == "E":
      self.face = [self.face[3], self.face[1], self.face[0], self.face[5], self.face[4], self.face[2]]
      return self.face
    elif direc == "S":
      self.face = [self.face[4], self.face[0], self.face[2], self.face[3], self.face[5], self.face[1]]
      return self.face
    elif direc == "W":
      self.face = [self.face[2], self.face[1], self.face[5], self.face[0], self.face[4], self.face[3]]
      return self.face
  def get_face(self, top):
    if top == self.face[0]:
      return self.face
    elif top == self.face[1]:
      return dice.move("N")
    elif top == self.face[2]:
      return dice.move("W")
    elif top == self.face[3]:
      return dice.move("E")
    elif top == self.face[4]:
      return dice.move("S")
    elif top == self.face[5]:
      dice.move("N")
      return dice.move("N")
  def right_face(self, face1, face2):
    if face2 == self.face[1]:
      return self.face[2]
    elif face2 == self.face[2]:
      return self.face[4]
    elif face2 == self.face[4]:
      return self.face[3]
    elif face2 == self.face[3]:
      return self.face[1]

num = list(map(int, input().split()))
q = int(input())
dice = Dice()
for i in range(q):
  dice.make_dice(num)
  f1, f2 = map(int,input().split())
  dice.get_face(f1)
  print(dice.right_face(f1,f2))


Measured memory_bytes: 5608
#include<stdio.h>
int main()
{
    long long int a,b,c;
    char op;
    scanf("%lld %c %lld",&a,&op,&b);
    if(op=='+')
    {
        c=a+b;
        printf("%lld",c);
    }
    else
    {
        c=a-b;
        printf("%lld",c);
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
    int i,l,count=0,j;
    char s[101],s2[101];
    scanf("%s", s);
    l=strlen(s);
    for(i=l-1,j=0;i>=0;i--,j++)s2[j]=s[i];
    s2[j]='\0';
    for(i=0;i<l;i++)
    {
        if(s[i]!=s2[i])count++;
    }
    printf("%d\n", count/2);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        ll dist=x*x+y*y;
        if(dist<=(d*d)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

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

  for (int i = 0; i < w.length(); i++) {
    if(count(w.begin(), w.end(), w[i]) % 2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

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

int main(){
  string str;
  cin >> str;
  int i = 0;
  for(i=1;i<str.size();i++){
    if((str.size()-i)%2 == 1) continue;
    string tmp_str = str.substr(0,str.size()-i);
    int harflength = tmp_str.size()/2;
    bool flag = true;
    for(int j=0;j<harflength;j++){
      if (tmp_str[j] != tmp_str[harflength+j])
        flag = false;
    }
    if(flag){
      cout << str.size() - i << endl;
      break;
    }
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const int INF=100000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
vector<ll> v[100001];
ll C[100001];
struct edge{ll time,posi,abe,he;};
ll h,w;
char a[1001][1001];
int c[1001][1001];
int dp[1001][1001][16];
int main() {
	int n;
	cin>>n;
	int i=1;
	bool b=false;
	while(1){
		if((i*(i+1))/2==n){
			cout<<"Yes"<<endl;
			cout<<i+1<<endl;
			int h=1,ky=0,kx=0;
			while(1){
				if(kx>=n||ky>=n)break;
				int s=h;
				rep(j,0,i-kx){
					c[ky][kx+j]=h;
					h++;
				}
				h=s;
				ky++;
				rep(j,0,i-ky+1){
					c[ky+j][kx]=h;
					h++;
				}
				kx++;
			}
			rep(j,0,i+1){
				cout<<i;
				rep(k,0,i)cout<<" "<<c[j][k];
				cout<<endl;
			}
			break;
		}
		if((i*(i+1))/2>n){
			b=true;
			break;
		}
		i++;
	}
	if(b)cout<<"No"<<endl;
}


Measured memory_bytes: 8576
from collections import defaultdict


def main():
    n = int(input())
    card_list = list(map(int, input().split()))

    ans = len(set(card_list))

    d = defaultdict(int)
    for card in card_list:
        d[card] += 1

    one, two = 0, 0
    for card, num in d.items():
        if num % 2 == 1:
            one += 1
        else:
            two += 1

    print(ans - two % 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20188
//ALDS1_8B
#include <iostream>
#include <string>
using namespace std;

struct Node{
 int key;
 Node *right,*left,*parent;
};

Node *root,*NIL;

Node* find(Node *u,int k){
 while(u!=NIL && k!=u->key){
  if(k<u->key) u=u->left;
  else u=u->right;
 }
 return u;
}

void insert(int k){
 Node *y=NIL;
 Node *x=root;
 Node *z;
 z=new Node;
 z->key=k;
 z->left=NIL;
 z->right=NIL;
 while(x!=NIL){
  y=x;
  if(z->key<x->key){
   x=x->left;
  }else{
   x=x->right;
  }
 }
 z->parent=y;
 if(y==NIL){
  root=z;
 }else{
  if(z->key<y->key){
   y->left=z;
  }else{
   y->right=z;
  }
 }
}

void inorder(Node *u){
 if(u==NIL) return;
 inorder(u->left);
 cout<<" "<<u->key;
 inorder(u->right);
}

void preorder(Node *u){
 if(u==NIL) return;
 cout<<" "<<u->key;
 preorder(u->left);
 preorder(u->right);
}

int main(){
 int n,x;
 string com;
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>com;
  if(com=="find"){
   cin>>x;
   Node *t=find(root,x);
   if(t!=NIL) cout<<"yes"<<endl;
   else cout<<"no"<<endl;
  }else if(com=="insert"){
   cin>>x;
   insert(x);
  }else if(com=="print"){
   inorder(root);
   cout<<endl;
   preorder(root);
   cout<<endl;
  }
 }
 return 0;
}

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

int main(){

  int h, a[300];

  //input
  cin >> h;
  for(int i = 1;i <= h;i++) cin >> a[i];

  //output
  for(int i = 1;i <= h;i++){
    cout << "node " << i << ": ";
    cout << "key = " << a[i] << ", ";
    if(i / 2 != 0) cout << "parent key = " << a[i / 2] << ", "; //index of parent is i / 2
    if(2 * i <= h) cout << "left key = " << a[2 * i] << ", "; //index of left child is 2 * i
    if(2 * i + 1 <= h) cout << "right key = " << a[2 * i + 1] << ", "; //index of right child is 2 * i + 1
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    HashMap<Integer, List<Integer>> routes = new HashMap<Integer, List<Integer>>();
    
    for (int i=0; i<h; i++) {
      String row = sc.next();
      for (int j=0; j<w; j++) {
        char c = row.charAt(j);
        if (c=='.') {
          List<Integer> tmp = new ArrayList<Integer>();
          routes.put(i*w+j, tmp);
          
          if (i!=0) {
            if (routes.containsKey((i-1)*w+j)) {
              tmp.add((i-1)*w+j);
              routes.get((i-1)*w+j).add(i*w+j);
            }
          }
          
          if (j!=0) {
            if (routes.containsKey(i*w+j-1)) {
              tmp.add(i*w+j-1);
              routes.get(i*w+j-1).add(i*w+j);
            }
          }
        }
      }
    }
    
    int max = 1;
    for (int i=0; i<h*w; i++) {
      if (!routes.containsKey(i)) {
        continue;
      }
      HashMap<Integer, Integer> already = new HashMap<Integer, Integer>();
      Deque<Integer> queue = new ArrayDeque();
      queue.offer(i);
      already.put(i, 0);
      int count = 0;
      while(!queue.isEmpty()) {
        int current = queue.poll();
        List<Integer>tmp = routes.get(current);
        for (Integer route : tmp) {
          if (already.containsKey(route)) {
            continue;
          }
          queue.offer(route);
          already.put(route, already.get(current)+1);
          count = already.get(current)+1;
        }
      }
      if (max<count) {
        max = count;
      }
    }

    System.out.println(max);
  }
}

Measured memory_bytes: 39188
#include <stdio.h>
int main(void)
{ int cx,cy,cwx,cwy,nx,ny,n,set,count;
scanf("%d",&set);
for(;set>0;set--){
count=0;
scanf("%d%d%d%d",&cx,&cy,&cwx,&cwy);
scanf("%d",&n);
for(;n>0;n--){
scanf("%d%d",&nx,&ny);
if(nx>=cx&&ny>=cy&&nx<=cx+cwx&&ny<=cy+cwy)
count++;
} printf("%d\n",count);}}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int MAXN = 310, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, mod;
ll dp[MAXN][MAXN];
ll C[MAXN][MAXN];

inline ll get(int i, int j){
	ll res=dp[i][j]-dp[i][j+1]+mod;
	return res%mod;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k>>mod;
	for (int i=0; i<MAXN; i++){
		C[i][0]=C[i][i]=1;
		for (int j=1; j<i; j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	for (int i=0; i<=k; i++) dp[1][i]=k+1-i;
	for (int i=2; i<=n+1; i++){
		for (int j=0; j<=k; j++){
			for (int s=1; s<i; s++){
				dp[i][j]=(dp[i][j] + C[i-2][s-1]*(get(i-s, j)*dp[s][j+1]%mod))%mod;
			}
		}
		for (int j=k; j; j--) dp[i][j-1]=(dp[i][j-1]+dp[i][j])%mod;
	}
	
	cout<<get(n+1, 0)<<'\n';
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <valarray>
#include <map>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int m, n, k;
    cin >> m >> n >> k;
    vector<string> fld(m);
    using ps_t = vector<valarray<int>>;
    for (auto& i : fld) cin >> i;
    map<char, ps_t> cnt;
    for (auto i : {'J', 'O','I'})
        cnt[i] = {valarray<int>(0, n + 1)};
    for (auto& line : fld) {
        for (auto c : {'J', 'O', 'I'}) {
            valarray<int> result(0, n + 1);
            transform(begin(line), end(line), begin(result) + 1,
                    [c](char point) -> int { return c == point; });
            partial_sum(begin(result), end(result), begin(result));
            cnt[c].push_back(move(result));
        }
    }
    for (auto c : {'J', 'O', 'I'})
        partial_sum(begin(cnt[c]), end(cnt[c]), begin(cnt[c]));
    auto getPS = [](int x1, int y1, int x2, int y2, ps_t const& ps) {
        x1--;
        y1--;
        return ps[x2][y2]
            - ps[x2][y1]
            - ps[x1][y2]
            + ps[x1][y1];
    };
    for (auto i = 0; i < k; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        bool first = true;
        for (auto ch : {'J', 'O', 'I'})
            cout << (first ? (first = false, "") : " ")
                << getPS(a, b, c, d, cnt[ch]);
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 15636
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

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

	int bwhite = 0, ablack = 0;
	rep(i, n){
		ablack += s[i] == '#';
	}

	int ans = n - ablack;
	rep(i, n){
		bwhite += s[i] == '.';
		ablack -= s[i] == '#';
		const int cur = n - ablack - bwhite;
		chmin(ans, cur);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d" ,&a,&b);
    if(a>b){
        printf("a > b\n");
    }
    if(a==b){
        printf("a == b\n");
    }
    if(a<b){
        printf("a < b\n");
    }
    return 0;
}


Measured memory_bytes: 1980
//98tarunkumar
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rlop(i,n) for(int i=n;i>0;i--)
#define lli long long int
#define sf ios::sync_with_stdio(false); cin.tie(NULL);
#define ainp(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define aout(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";
#define f(i, a, b) for(int i=a; i<b; i++)
#define lop(a,b) for(int i=a;i<b;i++)
#define ln cout<<"\n"
#define MOD 1e9+7

int main()
{ 
   	sf;
    

    int f=0;
    string s;
    cin>>s;
    //stringstream d(s);sa
    //cout<<int(s[0]-'0');
   	double long  x=0;
   	for(int i=0;i<s.size();i++)
   		x+=int(s[i]-'0');

    //d>>x;
    if((lli)x%9==0)
		cout<<"Yes";
	else
		cout<<"No";
}

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

int main() {
	int n, k; cin >> n >> k;
	vector<int>h(n); for (auto&& x : h)cin >> x;

	int ans = 0;
	for (auto&& x : h) {
		if (x >= k)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

//https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }


    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    //////////////

    bool is_root(int x) {
        if(par[x]==x) return true;
        else return false;
    }
};

int main()
{
    // 入力
    ll N,M;
    cin>>N>>M;
    vector<ll> X(M+1),Y(M+1),Z(M+1);
    UnionFind tree(N+1);
    FOR(i,1,M){
        cin>>X[i]>>Y[i]>>Z[i];
        tree.unite(X[i],Y[i]);

    }
    ll ans=0;
    REP(i,N){
        if(tree.is_root(i)) ans++;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2944
using System;

namespace ITP1_9
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine();
            int c = 0;
            while(true)
            {
                string a = Console.ReadLine();
                if(a == "END_OF_TEXT") break;
                foreach(string s in a.ToLower().Split(' '))
                  if(s == w) c++;
            }
            Console.WriteLine("{0}", c);
        }
    }
}

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

using ll = long long;
const int MAXN = 110;
const int MAXW = 1e5+10;
struct item {
    int w, v;
};
item a[MAXN];
int N, W;
ll dp[MAXW];
int main() {
    cin >> N >> W;
    for(int i=1; i<=N; i++) {
        cin >> a[i].w >> a[i].v;
    }
    memset(dp, 0, sizeof(dp));
    for(int i=1; i<=N; i++) {
        for(int j=W; j>=a[i].w; j--) {
            dp[j] = max(dp[j], dp[j-a[i].w] + a[i].v);
        }
    }
    ll ans = 0;
    for(int j=1; j<=W; j++) {
        ans = max(ans, dp[j]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
def process(src, dst):
    # 偶数：何もしない
    # 奇数：1枚ならべる(1枚減る)
    if src % 2 == 0:
        pass
    else:
        src -= 1

    # 半分を相手に渡す
    # 自分：半分減
    # 相手：半分の値増
    src = src / 2
    dst += src

    return src, dst


# 入力
indata = input().split()
A = int(indata[0])
B = int(indata[1])
K = int(indata[2])

# 初期所持枚数
takahashi = A
aoki = B

# 操作をK回繰り返す
for i in range(K):
    if i % 2 == 0:
        # 高橋君のターン
        takahashi, aoki = process(takahashi, aoki)
    else:
        # 青木君のターン
        aoki, takahashi = process(aoki, takahashi)

# 結果
print(int(takahashi), int(aoki))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ll b = 0,c=0;
    for(int i=0;i<n;i+=2)b+=a[i];
    for(int i=1;i<n;i+=2)c+=a[i];
    cout << b - c << endl;
}
    

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

#define EPS 1e-10

typedef complex<double> P;

vector<P> cross(P a,P b){
  vector<P> res;

  if(abs(abs(b-a) - 2.0) < EPS){
    P c = a + b;
    res.push_back( P(c.real()/2,c.imag()/2) );
  }
  else if(abs(b-a) < 2.0){
    P ab = b - a;
    P center = a + P(ab.real()/2,ab.imag()/2);
    P un1 = (ab * P(0, +1)) / abs(ab);
    P un2 = (ab * P(0, -1)) / abs(ab);
    double dist = sqrt(1 - (abs(ab)/2)*(abs(ab)/2));
    P c1 = center + un1 * dist;
    P c2 = center + un2 * dist;

    res.push_back(c1);
    res.push_back(c2);
  }

  return res;
}

int main(void){
  int n;

  while(cin>>n,n){
    P p[n];
    for(int i=0;i<n;i++){
      double x,y;
      char ch;
      cin>>x>>ch>>y;
      p[i] = P(x,y);
    }

    int ans = 1;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        vector<P> v = cross(p[i],p[j]);
        if(v.empty()) continue;
        int countA = 2;
        int countB = 2;
        for(int k=0;k<n;k++){
          if(i == k || j == k) continue;
          if(abs(v[0]-p[k]) - 1.0 < EPS) countA++;
          if(v.size() == 2 && abs(v[1]-p[k]) - 1.0 < EPS) countB++;
        }
        ans = max(ans,max(countA,countB));
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>

int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  if(x<y){
    int i=x;
    x=y;
    y=i;
  }
  while(y>0){
    int i=x%y;
    x=y;
    y=i;
  }
  printf("%d\n",x);
  
  return 0;
}



Measured memory_bytes: 2144
#include <stdio.h>

int main()
{
  int a,b,c;
  scanf("%d",&b);
  c = 0;
  while(b > 0)
  {
  	a = b % 10;
	if (a == 1)
      c += 9;
    else
      c += 1;
    if (c < 100)
    	c *= 10;
    b /= 10;
  }
  b = 0;
  while(c > 0)
  {
  	a = c % 10;
	if (a == 1)
      b += 1;
    else
      b += 9;
    if (b < 100)
    	b *= 10;
    c /= 10;
  }
  printf("%d",b);
    
}

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

using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    int cnt_lr = 0;
    int cnt_rl = 0;
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] == S[i + 1]) {
            ans++;
        } else if (S[i] == 'L' and S[i + 1] == 'R') {
            cnt_lr++;
        } else if (S[i] == 'R' and S[i + 1] == 'L') {
            cnt_rl++;
        }
    }
    int cnt = 0;
    if(max(cnt_lr,cnt_rl)<=K){
      cout << S.size()-1 << endl;
      return 0;
    }
    while (K > 0 and cnt_lr > 0 and cnt_rl > 0) {
        cnt += 2;
        K--;
        cnt_lr--;
        cnt_rl--;
    }
    ans += cnt;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();// cards
        int M = scan.nextInt();// gates
        int[] L = new int[M];
        int[] R = new int[M];
        for (int i = 0; i < M; i++) {
            L[i] = scan.nextInt();
            R[i] = scan.nextInt();
        }//O(M)
        Arrays.sort(L);
        Arrays.sort(R);
        if(L[M-1] <= R[0]){
            System.out.print(R[0] - L[M-1] + 1);
        }
        else{
            System.out.print(0);
        }

    }
}

Measured memory_bytes: 64216
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = 3.1415926535897932384626;
const int SIZE = 1 << 17;

int main() {
	string h;
	cin >> h;
	vector<char>ans;
	for (int i = 0; i < h.length(); ++i) {
		if (h[i] == '0') { ans.push_back('0'); }
		else if (h[i] == '1') { ans.push_back('1'); }
		else if (ans.size() != 0) { ans.pop_back(); }
	}
	for (int i = 0; i < ans.size(); ++i) { cout << ans[i]; }
	cout << endl;
}

Measured memory_bytes: 256
N = list(input())
ans = 0
if len(N) == 1:
  print(*N)
  exit()
for i in range(len(N)):
  if i == 0 and N[i] != "9" and N[i+1] == "9":
    ans += int(N[i])
  elif N[i] != "9":
    N[i] = int(N[i]) - 1
    ans += N[i]
    ans += (len(N) - (i + 1)) * 9
    print(ans)
    exit()
  else:
    if i < len(N)-1 and N[i+1] != "9":
      ans += int(N[i]) - 1
      ans += (len(N) - (i + 1)) * 9
      print(ans)
      exit()
    else:
      ans += 9
print(ans)
      

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int mjs=0;

		str=bfr.readLine();
		mjs=Integer.parseInt(str);

		if(mjs==0) {
			System.out.println("1");
		}
		else if(mjs==1) {
			System.out.println("2");
		}
		else if(mjs==2) {
			System.out.println("1");
		}
		else if(mjs>=3) {
			System.out.println("0");
		}
	}
}


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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define mod 998244353
#define INF 9999999

signed main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < k; i++)
    ans += v[i];
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int cnt = 0;
  bool prev_swapped = false;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    if (p == i + 1) {
      if (prev_swapped) {
        prev_swapped = false;
      } else {
        ++cnt;
        prev_swapped = true;
      }
    } else {
      prev_swapped = false;
    }
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, k;
  cin >> n >> k;
  vll x(n);
  for (ll i = 0; i < n; i++) cin >> x[i];
  priority_queue<ll, vll, greater<ll>> y;
  for (ll i = 0; i < n - k + 1; i++) {
    ll z = x[k - 1 + i] - x[i];
    z += min(
      max(x[k - 1 + i], - x[k - 1 + i]),
      max(x[i], - x[i])
    );
    y.push(z);
  }
  cout << y.top() << endl;
}

Measured memory_bytes: 1660
//Name: Brave Princess Revisited
//Level: 2
//Category: グラフ,Graph,最短経路,ダイクストラ法,Dijkstra
//Note:

/*
 * [今いるノード][所持金]を状態にして、刺客の人数について最短経路を求める。
 *
 * ダイクストラ法でオーダーは O(M log N)。
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

struct Road {
    int to, fee;
    int cost;

    Road() {}
    Road(int t, int f, int c) : to(t), fee(f), cost(c) {}
};

struct Tag {
    int node, money;
    int cost;

    Tag() {}
    Tag(int n, int m, int c) : node(n), money(m), cost(c) {}

    bool operator < (const Tag &other) const {
        return cost > other.cost; // Reverse order
    }
};

const int INF = 10000*100*10;

bool solve() {
    int N, M, L;
    cin >> N >> M >> L;
    if(!N && !M & !L) return false;

    vector<vector<Road> > roads(N);
    for(int _ = 0; _ < M; ++_) {
        int a, b, d, e;
        cin >> a >> b >> d >> e;
        --a; --b;
        roads[a].push_back(Road(b, d, e));
        roads[b].push_back(Road(a, d, e));
    }

    int ans = INF;
    priority_queue<Tag> q;
    vector<vector<int> > memo(N, vector<int>(L+1, INF));
    memo[0][L] = 0;
    q.push(Tag(0, L, 0));
    while(!q.empty()) {
        const Tag t = q.top();
        q.pop();
        if(memo[t.node][t.money] < t.cost) continue;
        if(t.node == N-1) {
            ans = t.cost;
            break;
        }

        const vector<Road> &v = roads[t.node];
        for(vector<Road>::const_iterator it = v.begin(); it != v.end(); ++it) {
            {
                // Use guard
                const int nm = t.money - it->fee;
                if(nm >= 0 && t.cost < memo[it->to][nm]) {
                    memo[it->to][nm] = t.cost;
                    q.push(Tag(it->to, nm, t.cost));
                }
            }
            {
                // Not use guard
                const int nc = t.cost + it->cost;
                if(nc < memo[it->to][t.money]) {
                    memo[it->to][t.money] = nc;
                    q.push(Tag(it->to, t.money, nc));
                }
            }
        }
    }
    cout << ans << endl;
    return true;
}

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

    for(int case_num = 1; solve(); ++case_num) ;
    return 0;
}

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

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

int main() {
    int a,b,c; cin >> a >> b >> c;
    int sum = a + b + c;
    int MAX = max(a,max(b,c));
    int ans;
    if((MAX*3) % 2 != sum % 2){
        int d = (MAX+1)*3 - sum - 2;
        ans = 1 + d / 2 + d % 2;
    }else{
        int d = MAX*3 - sum;
        ans = d / 2 + d % 2;
    }
    cout << ans << endl;
}

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

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

  vector<int> button(N);
  for (int i = 0; i < N; i++) {
    cin >> button.at(i);
  }
  int a = 1, count = 0;
  vector<int> lamp(N);
  lamp.at(0) = 1;
  while (a != 2) {
    a = button.at(a - 1);
    if (lamp.at(a - 1) == 1) {
      count = -1;
      break;
    }
    lamp.at(a - 1) = 1;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
const int N = 25;

int b[N];

int main () {
    int n, m, c;
    read(n), read(m), read(c);
    for (int i = 1; i <= m; ++i) {
        read(b[i]);
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int ans = c;
        for (int j = 1; j <= m; ++j) {
            int a;
            read(a);
            ans += a * b[j];
        }
        if (ans > 0) {
            ++cnt;
        }
    }
    write(cnt), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int  main()
{
	ll a, b, x; cin >> a >> b >> x;
	ll ans;
	if (a != 0)
	{
		a--;
		ans = (b/x) - (a / x);
		cout << ans << endl;
	}
	else
	{
		ans = (b/x) - (a / x);
		cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 

typedef long long ll; 
const int mod = 1000000007; 

int prime[MAX]; 
unordered_map<int, int> max_map; 

// Function to return a^n 
ll power(ll a, ll n) 
{ 
	if (n == 0) 
		return 1; 
	ll p = power(a, n / 2) % mod; 
	p = (p * p) % mod; 
	if (n & 1) 
		p = (p * a) % mod; 
	return p; 
} 

// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
	prime[0] = prime[1] = 1; 
	for (int i = 2; i < MAX; i++) { 
		if (prime[i] == 0) { 
			for (int j = i * 2; j < MAX; j += i) { 
				if (prime[j] == 0) { 
					prime[j] = i; 
				} 
			} 
			prime[i] = i; 
		} 
	} 
} 
ll lcmModuloM(const int* ar, int n) 
{ 
	for (int i = 0; i < n; i++) { 
		int num = ar[i]; 
		unordered_map<int, int> temp; 
		while (num > 1) { 
			int factor = prime[num]; 
			temp[factor]++; 
			num /= factor; 
		} 

		for (auto it : temp)
			max_map[it.first] = max(max_map[it.first], it.second); 
	} 

	ll ans = 1; 
	for (auto it : max_map) { 
		ans = (ans * power(it.F, it.S)) % mod; 
	} 
	return ans; 
} 

int main() 
{ 
	sieve(); 
	int n=0;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	ll lcm= lcmModuloM(arr, n); 
	ll ans=0;
	for(int i=0;i<n;i++)
	    ans=(ans+(lcm*power(arr[i],mod-2))%mod)%mod;
	cout<<ans<<endl;
	return 0; 
} 


Measured memory_bytes: 39808
import Data.Char
import Text.Printf

solve :: String -> String
solve []     = []
solve (x:xs)
    | x=='@'     = exp++(solve (drop 2 xs))
    | otherwise  = [x]++(solve xs)
    where n = (digitToInt (xs!!0))
          c = xs!!1
          exp = take n $ repeat c

main :: IO ()
main = do
    str <- getContents::IO String
    mapM_ (printf "%s\n") $ map solve $ lines $ str

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

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    mint inv() const
    {

        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; i++)
        {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
        {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
int main()
{
    int n, k;
    cin >> n >> k;
    combination c(n);
    mint ans = 0;
    rep(i,min(n,k+1)){
        ans += c(n, i) * c(n - 1, i);
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 3328
import queue
N,M=map(int,input().split())
a=[0 for i in range(M)]
b=[0 for i in range(M)]
for i in range(M):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1

def isbridge(j):
    G=[set() for i in range(N)]
    for i in range(M):
        if i==j:
            continue
        G[a[i]].add(b[i])
        G[b[i]].add(a[i])
    q=queue.Queue()
    reached=[0 for i in range(N)]
    q.put(0)
    reached[0]=1
    while(not(q.empty())):
        r=q.get()
        reached[r]=1
        for p in G[r]:
            if reached[p]==0:
                q.put(p)
    if sum(reached)==N:
        return False
    else:
        return True

ans=0
for i in range(M):
    if isbridge(i):
        ans+=1
print(ans)


Measured memory_bytes: 46440
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s,t;cin>>s>>t;
	int n=s.size();
	vi a(n),b(n);
	int r=0;
	rep(i,n){
		if(r<n&&s[i]==t[r]){
			r++;
			a[i]=1;
		}
	}
	r=t.size()-1;
	rep(i,n){
		int j=n-1-i;
		if(r>=0&&s[j]==t[r]){
			r--;
			b[j]=1;
		}
	}
	
	bool h=true;
	rep(i,s.size())if(a[i]!=b[i])h=false;
	if(h)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}







Measured memory_bytes: 7916