akhauriyash/Code-Regression huggingface dataset:
N,Q = map(int,input().split())	

S = input()

t = [0] * N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        t[i] = t[i-1] + 1
    else:
        t[i] = t[i-1]
#    print(t)

for _ in range(Q):
    l,r = map(int,input().split())	
    print(t[r-1]-t[l-1])

Measured memory_bytes: 8060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BBitterAlchemy {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, x;
	    in >> n >> x;
	    vector<int> m(n);
	    int sum = 0;
	    for(int i=0; i<n; i++){
	        in >> m[i];
	        sum += m[i];
	    }
        sort(m.begin(), m.end());
	    int res = n;
	    int rest = x - sum;
	    res += rest / m[0];
	    out << res << endl;
	}
};


int main() {
	BBitterAlchemy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

class suffix_array {
    // compare (rank[i], rank[i + k]) and (rank[j], rank[j + k])
    static bool compare_sa(int n, const vector<int>& rank, int i, int j, int k) {
        if (rank[i] != rank[j]) return rank[i] < rank[j];
        int ri = i + k <= n ? rank[i + k] : -1;
        int rj = j + k <= n ? rank[j + k] : -1;
        return ri < rj;
    }
public:
    static vector<int> construct_sa(const string& s) {
        int n = s.length();
        vector<int> sa(n + 1), rank(n + 1);
        for (int i = 0; i <= n; ++i) {
            sa[i] = i;
            rank[i] = i < n ? s[i] : -1;
        }
        for (int k = 1; k <= n; k <<= 1) {
            sort(sa.begin(), sa.end(), [&n, &k, &rank](const int& a, const int& b){ return compare_sa(n, rank, a, b, k); });

            vector<int> tmp(n + 1);
            for (int i = 1; i <= n; ++i)
                tmp[sa[i]] = tmp[sa[i - 1]] + compare_sa(n, rank, sa[i - 1], sa[i], k);
            for (int i = 0; i <= n; ++i)
                rank[i] = tmp[i];
        }
        return sa;
    }
    static vector<int> construct_lcp(const string& s, const vector<int>& sa) {
        int n = s.length();
        vector<int> rank(n + 1), lcp(n + 1);
        for (int i = 0; i <= n; ++i) rank[sa[i]] = i;

        int h = 0;
        for (int i = 0; i < n; ++i) {
            if (h > 0) --h;
            for (int j = sa[rank[i] - 1]; j + h < n && i + h < n; ++h)
                if (s[j + h] != s[i + h]) break;

            lcp[rank[i] - 1] = h;
        }
        return lcp;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int q;
    cin >> s >> q;
    const char* sc = s.c_str();
    vector<int> sa = suffix_array::construct_sa(s);
    for (int i = 0; i < q; ++i) {
        string t;
        cin >> t;
        const char* tc = t.c_str();
        int l = -1, re = s.length();
        while (l + 1 < re) {
            int m = (l + re) / 2;
            if (strcmp(sc + sa[m], tc) < 0) {
                l = m;
            }
            else {
                re = m;
            }
        }
        bool ok = true;
        for (int j = 0; j < (int)t.length(); ++j) {
            if (s[sa[re] + j] != t[j]) {
                ok = false;
                break;
            }
        }
        cout << ok << '\n';
    }
    return 0;
}



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

int twocount(int n){
    int r = n;
    int count = 0;
    while(r%2 == 0){
        count++;
        r /= 2;
    }
    return count;
}

int main(){
    int n;
    cin >> n;
    int m = INT_MAX;

    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        m = min(m,twocount(a));
        if(m == 0) break;
    }

    cout << m << endl;

    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

signed main(){
    int H, W;
    cin >> H >> W;
    int ch, dh, cw, dw;
    cin >> ch >> cw >> dh >> dw;
    vector<vector<char>> S(H+2, vector<char>(W+2, '#'));
    rep(h,1,H+1) rep(w,1,W+1) cin >> S[h][w];
    vector<vector<int>> distance(H+2, vector<int>(W+2, -1));
    deque<pair<pair<int, int>, int>> que;
    que.push_back({{ch, cw}, 0});
    while (!que.empty()) {
        auto current = que.front().first;
        int cost = que.front().second;
        que.pop_front();
        static vector<pair<int, int>> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
        rep(i,0,4) {
            pair<int, int> next = {current.first + directions[i].first, current.second + directions[i].second};
            if (S[next.first][next.second] == '#') continue;
            if (distance[next.first][next.second] == -1 || distance[next.first][next.second] > cost) {
                distance[next.first][next.second] = cost;
                que.push_front({next, cost});
            }
        }
        rep(i,-2,3) rep(j, -2, 3) {
            pair<int, int> next = {current.first + i, current.second + j};
            if (next.first <= 0 || next.first > H || next.second <= 0 || next.second > W) continue;
            if (S[next.first][next.second] == '#') continue;
            if (distance[next.first][next.second] == -1 || distance[next.first][next.second] > cost+1) {
                distance[next.first][next.second] = cost+1;
                que.push_back({next, cost+1});
            }
        }
    }
    cout << distance[dh][dw] << endl;
    return 0;
}


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

string str, stk;

int main( void ) {
    
    cin >> str;

    int cnt = 0;
    for( char ch : str ) {
        if( stk.empty() == false && stk.back() == 'S' && ch == 'T' )
            stk.pop_back();
        else
            stk.push_back( ch );
    }
    
    cout << stk.length() << endl;
    return 0;
}

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

ll read()
{
	ll s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}

int main()
{
	ll x=read(),y=read();
	print(x*y/gcd(x,y));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5;
 
 
 
int main() {
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    run();
    unordered_map<string,int> mp;
    int n;
    cin>>n;
    for (int i = 0; i <n ; ++i) {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<'\n'
        <<"WA x "<<mp["WA"]<<'\n'
        <<"TLE x "<<mp["TLE"]<<'\n'
        <<"RE x "<<mp["RE"];
 
    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

struct Node{
	bool operator<(const struct Node &arg) const{
		return weight < arg.weight;
	};
	int from,to,weight;
};

int parent[10000],height[10000];

int getParent(int id){
	if(parent[id] == id)return id;
	else{
		return parent[id] = getParent(parent[id]);
	}
}

bool isSame(int a, int b){
	return getParent(a) == getParent(b);
}

void unite(int a,int b){
	int a_parent = getParent(a);
	int b_parent = getParent(b);

	if(a_parent == b_parent)return;

	if(height[a_parent] > height[b_parent]){
		parent[b_parent] = a_parent;
	}else{
		if(height[a_parent] == height[b_parent])height[b_parent]++;
		parent[a_parent] = b_parent;
	}
}


int main(){

	int V,E;

	scanf("%d %d",&V,&E);
	Node nodes[E];

	for(int i = 0; i < V; i++){
		parent[i] = i;
		height[i] = 0;
	}

	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&nodes[i].from,&nodes[i].to,&nodes[i].weight);
	}

	sort(nodes,nodes+E);

	int sum = 0;

	for(int i = 0; i < E; i++){
		if(!isSame(nodes[i].from,nodes[i].to)){
			sum += nodes[i].weight;
			unite(nodes[i].from,nodes[i].to);
		}
	}

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

	return 0;
}



Measured memory_bytes: 3976
#include<cstdio>
#include<algorithm>

#define INF 1000000000

using namespace std;

int cost[32][32];	//[i][j]ªi©çjÖÌRXg
int d[32];			//s©çÌÅ¬RXg
bool used[32];		//gíê½©Ç¤©
int N;				//¸_


void dijkstra(int s){
	//ú»
	fill(d, d + 32, INF);
	fill(used,used+32,false);
	d[s] = 0;
	
	
	while(true){
		int v = -1;
		//gíêÄ¢È¢àÌÅÅ¬ÌàÌðT·
		for(int i = 1; i <= N; i++){
			if(used[i]  == false && (v == -1 || d[i] < d[v]))v = i;
		}
		if(v == -1)break;
		
		used[v] = true;
		
		for(int i = 1; i <= N; i++){
			d[i] = min(d[v]+cost[v][i],d[i]);
		}
	}
}	
	
int main(void){
	while(scanf("%d", &N) != EOF){
//		scanf("%d", &N);
		int m;
		int a1,b1,c1,d1;
		int start,goal,money,price;
		int go,back;
		
		scanf("%d", &m);
		
		//ú»
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= N; j++){
				cost[i][j] = INF;
			}
		}
		for(int i = 0; i < m; i++){
			scanf("%d,%d,%d,%d", &a1, &b1, &c1, &d1);
			cost[a1][b1] = c1;
			cost[b1][a1] = d1;
		}
		
		scanf("%d,%d,%d,%d", &start, &goal, &money, &price);
		
		
		dijkstra(start);
		go = d[goal];
		
		dijkstra(goal);
		back = d[start];
		
		printf("%d\n",money-price-go-back);
	}
	return 0;
}

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

using namespace std;

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

int w[300];
int dp[301][301];

int delta(int x,int y){
  if(abs(w[x]-w[y])<=1&&x!=y)return 2;
  return 0;
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(!n)break;
    rep(i,n)cin >> w[i];
    rep(i,301)rep(j,301)dp[i][j]=0;
    rep(i,n)dp[i][i+1]=delta(i,i+1);
    for(int d=2;d<n;d++){
      for(int i=0;i<n-d;i++){
        int tmp = 0,tmp1,tmp2,tmp3;
        for(int k=i;k<i+d;k++){
          if(k>0&&dp[i+1][k-1]==k-i-1)tmp1 = max(dp[i][k],dp[i+1][k-1]+delta(i,k));
          else tmp1 = dp[i][k];
          if(k+2<n&&dp[k+2][i+d-1]==i+d-k-2)tmp2 = max(dp[k+1][i+d],dp[k+2][i+d-1]+delta(k+1,i+d));
          else tmp2 = dp[k+1][i+d];
          if(d%2!=0&&dp[i+1][i+d-1]==d-1)tmp3 = dp[i+1][i+d-1]+delta(i,i+d);
          else tmp3 = 0;
          // cout << i << " " << k << " " << i+d << " " << tmp1 << " " << tmp2 << " " << tmp3 << endl;
          tmp = max(tmp,tmp1+tmp2);
          tmp = max(tmp,tmp3);
        }
        dp[i][i+d] = tmp;
        // cout << tmp << endl;
      }
    }
    cout << dp[0][n-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3456
n=int(input())
a=list(map(int, input().split()))
cnt=0
abs_min=10**9
abs_sum=0
for ai in a:
    if ai<0:
        cnt+=1        
    abs_min=min(abs_min, abs(ai))
    abs_sum+=abs(ai)
if cnt%2==0:
    ans=abs_sum
else:
    ans=abs_sum-abs_min*2
print(ans)

Measured memory_bytes: 14412
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
n_list = [i for i in range(1,n+1)]
n_permutations = itertools.permutations(n_list)
n_permu_list = list(map(list,n_permutations))
print(abs(n_permu_list.index(p)-n_permu_list.index(q)))

Measured memory_bytes: 47068
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define de(x) cout << #x << " = " << x << endl
#define dd() cout << "Out Put!\n"
const int mod= 1e9+7,maxn=10;
const double eps = 1e-8,PI = acos(-1.0);
const int inf=0x7f7f7f7f;
using namespace std;
char a[maxn][maxn],b[maxn][maxn];
int shu[maxn] = {0};
int hang[maxn]={0};
string s;
int h,w,k;
int ans = 0;
int p;
void dfs(int x,int y)
{
//	cout << x << " " << y <<" "<<h <<" " << w << endl;
	if(x > h && y > w)
	{
		rep(i,1,h)
			rep(j,1,w)
				b[i][j] = a[i][j];
		rep(i,1,h)
			rep(j,1,w)
			{
			//	cout << hang[i] <<" "<< shu[j] <<endl;
				if(hang[i] == 1)
					b[i][j] = '.';
				if(shu[j] == 1)
					b[i][j] = '.';
			}
		int cnt = 0;
		rep(i,1,h)
			rep(j,1,w)
				if(b[i][j] == '#')
					cnt++;
		if(cnt == k)
			ans++;
		return ;
	}
	if(x <= h)
		hang[x] = 1,dfs(x+1,y+1),hang[x] = 0;
	if(y<=w)
		shu[y] = 1,dfs(x+1,y+1),shu[y] = 0;
	if(x<=h&&y<=w)
		hang[x] = shu[y] = 1,dfs(x+1,y+1),hang[x] = shu[y] = 0;
	dfs(x+1,y+1);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin >> t;
	while(t--)
	{
		cin >> h >> w >> k;
		rep(i,1,h)
			cin >> (a[i]+1);
		p = max(h,w);
		dfs(1,1);
		cout << ans <<endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include<cstdio>

int binarysearch(int *A,int key,int n){
  int left=0,right=n,mid;
  while(left<right){
    mid = (right+left)/2;
    
    if(key==A[mid]){
      return 1;
    }else if(key>A[mid]){
      left = mid+1;
    }else{
      right = mid;
    }
  }
  return 0;
}

int main() {
  int A[100000];
  
  int n;
  scanf("%d",&n);
  
  
  for(int i=0;i<n;i++){
    scanf("%d",A+i);
  }
  
  int q;
  scanf("%d",&q);
  
  int key,sum=0;
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    if(binarysearch(A,key,n)){
      sum++;
    }
  }
  
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	int mod = 1e9 + 7;
	int dp[2001];
	int dpsa[2001] = {};
	int kari;

	rep(i, M + 1) dp[i] = 1;
	rep1(i, N) {
		rep1(j, M) {
			if (S[i - 1] == T[j - 1]) {
				dpsa[j] = dp[j];
				dp[j] = dp[j - 1] + dp[j];
			}
			else {
				dp[j] = dp[j - 1] + dpsa[j];
			}
			kari = dp[j] - mod;
			if (kari >= 0) dp[j] = kari;
		}
	}
	co(dp[M]);

	Would you please return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int H, W;
        int[] tate = new int [100];
        int[] yoko = new int [100];
        int i=0;
        int j=0;
        int k=0;
        int l=0;
        //scan.close();
        try{
            
            while((H = scan.nextInt()) != 0 && (W = scan.nextInt()) != 0){
                /*int H = scan.nextInt();
                int W = scan.nextInt();
                if(H == 0 && W == 0){
                    break;
                }*/

                tate[i] = H;
                yoko[i] = W;
                i++;
            }
           // System.out.printf("\n");
            while(l<i){
                for(j=0; j<tate[l]; j++){
                    for(k=0; k<yoko[l]; k++){
                        if(j%2 == 1){
                            if(k%2 == 1){
                                System.out.printf("#");
                            }else{
                                System.out.printf(".");
                            }
                        }else{
                            if(k%2 == 1){
                                System.out.printf(".");
                            }else{
                                System.out.printf("#");
                            }
                        }
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
                l++;
            }
            scan.close();
        }
        
        catch(NumberFormatException e){
            System.out.println(e);
        }/*catch(IOException e){
            System.out.println(e);
        }*/
    }
}


Measured memory_bytes: 64712
def output(S):
  s = S.split()
  i, j, k = map(int, s[1:])
  if s[0] == '<':
    state[k] = 1 if state[i] < state[j] else 0
  else:
    state[k] = state[i] + state[j]
  #print(state)
  #print(S)

outputs = []
output = outputs.append
def print_outputs():
  print(len(outputs))
  for x in outputs:
    print(x)

def solve(x, y):
  LIM = 32
  state = [0] * 5 * 10 * LIM
  state[0] = x
  state[1] = y

  usable = 3  # reset to 0 after use
  usable1 = 4  # reset to 0 after use
  usable2 = 5  # reset to 0 after use
  usable3 = 6  # reset to 0 after use
  zero = 7
  one = 8
  base = one  # base, ... base + LIM-1, (2**X)

  output(f'< {zero} 0 {base}')
  output(f'< {zero} 1 {usable}')
  output(f'+ {base} {usable} {base}')  # 2 is 0, 3 is 1 or 2
  output(f'< {zero} {base} {base}')  # 2 is 0, 3 is 1
  output(f'+ {zero} {zero} {usable}')
  
  for i in range(LIM-1):
    output(f'+ {base+i} {base+i} {base+i+1}') 

  def print_or(i, j, k):
    output(f'+ {i} {j} {k}')
    output(f'< {zero} {k} {k}')

  def print_not(i, k):
    output(f'< {i} {one} {k}')

  def print_zero(i):
    output(f'+ {zero} {zero} {i}')

  def print_and(i, j, k):
    print_not(i, k)
    print_not(j, usable)
    print_or(k, usable, k)
    print_not(k, k)
  
  def print_mult_pow2(n, i, k):
    # set i*2**n to k
    output(f'+ {zero} {i} {k}')
    for _ in range(n):
      output(f'+ {k} {k} {k}')

  def print_binarize(i, k): # binarize i and output in k, k+1, .. k+LIM-1
    output(f'+ {one} {i} {usable1}')  # usable1 = I + 1   # usable2 added so far

    for p in range(LIM-1, -1, -1):
      # 2 ** i
      #print(i, p, k)
      output(f'+ {base+p} {usable2} {usable3}')
      output(f'< {usable3} {usable1} {k+p}')
      print_mult_pow2(p, k+p, usable3)
      output(f'+ {usable3} {usable2} {usable2}')
    print_zero(usable1)
    print_zero(usable2)
    print_zero(usable3)

  A = base + LIM
  B = base + 2 * LIM
  print_binarize(0, A)  
  print_binarize(1, B)  

  for i in range(LIM):
    for j in range(LIM):
      print_and(A+i, B+j, usable1)
      print_mult_pow2(i+j, usable1, usable2)
      output(f'+ 2 {usable2} 2')


  return state[2]

solve(8, 7)
print_outputs()
# for x in range(11):
#   for y in range(11):
#     ans = solve(x, y)
#     if ans != x* y:
#       print(x, y, ans)

Measured memory_bytes: 71488
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


int main(){
    int k;
    cin >> k;
    int a = k / 2;
    int b = k - a;
    cout << a * b << endl;
    
    
    return 0;
}


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    l: [usize; n],
  }
  let mut popl = vec![0i64; 1001];
  for &x in &l {
    popl[x] += 1;
  }
  let mut sum = vec![0; 1002];
  for i in 0 .. 1001 {
    sum[i+1] = sum[i] + popl[i];
  }
  let mut ans = 0i64;
  for i in 0 .. 1001 {
    for j in i .. 1001 {
      let third = sum[cmp::min(i + j, 1001)] - sum[j+1];
      if i == j {
        ans += third * ((popl[i] * (popl[i] - 1)) / 2);
        ans += popl[i] * (popl[i] - 1) * (popl[i] - 2) / 6;
      } else {
        ans += third * popl[i] * popl[j];
        ans += popl[i] * (popl[j] * (popl[j] - 1) / 2);
      }
    }
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
def dfs(p,n,s):#p以下の数からn個用いてsを作る場合の数
    if not p:
        if n == 1 and s == 0:
            return 1
        else:
            return 0
    elif n == 1:
        if 0 <= s <= p:
            return 1
        else:
            return 0
    elif s < 0:
        return 0
    else:
        return dfs(p-1,n-1,s-p)+dfs(p-1,n,s)

while True:
    try:
        n,s = map(int, input().split())
        if (not n and not s):
            break;
        print(dfs(9,n,s))
    except:
        break;


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int H,W;
	cin>>H>>W;
	string s[H];
	REP(i,H)cin>>s[i];
	int tmi = INF,tma = 0;
	int ymi = INF,yma = 0;
	REP(i,H)REP(j,W){
		if(s[i][j]=='B'){
			CHMIN(tmi,i+j);
			CHMAX(tma,i+j);
			CHMAX(yma,i+W-j-1);
			CHMIN(ymi,i+W-j-1);
		}
	}
	cout<<max(tma-tmi,yma-ymi)<<endl;
}


Measured memory_bytes: 4016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);

      int i = 1;
      int x = 0;
      while( i <= n){
        if( i % 3 == 0) System.out.print(" " + i);
        else if( i % 10 == 3) System.out.print(" " + i);
        else {
          x = i;
          x /= 10;
          for( int j = 10; x != 0;x /= j){
            if( x % 10 == 3) {
              System.out.print(" " + i);
              break;
            }
          }
        }
        i++;
      }
      System.out.println("");
    }
  }
}


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

using namespace std;

int main() {
    constexpr long MOD = 1e9 + 7;

    long n,q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<pair<string, string>> td(q);
    for(auto &x: td) cin >> x.first >> x.second;

    long lok = -1, lng = n;
    while(lng - lok > 1) {
        long m = (lok+lng)/2;

        long cur = m;
        for(auto &x: td) {
            if(cur < 0 || n <= cur) break;

            char t = x.first[0];
            char d = x.second[0];
            if(s[cur] == t)
                cur += d == 'L' ? -1 : 1;
        }
        if(cur < 0)
            lok = m;
        else
            lng = m;
    }

    long rok = n, rng = -1;
    while(rok - rng > 1) {
        long m = (rok+rng)/2;

        long cur = m;
        for(auto &x: td) {
            if(cur < 0 || n <= cur) break;

            char t = x.first[0];
            char d = x.second[0];
            if(s[cur] == t)
                cur += d == 'L' ? -1 : 1;
        }
        if(n <= cur)
            rok = m;
        else
            rng = m;
    }

    cout << rok - lok - 1 << endl;
}


Measured memory_bytes: 22276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numH = 0;
		int numW = 0;
		int h = 0;
		int w = 0;

		try {
			scanner = new Scanner(System.in);
			numH = scanner.nextInt();
			numW = scanner.nextInt();
			h = scanner.nextInt();
			w = scanner.nextInt();

			int total = numH * numW;
			int col = h * numW;
			int row = w * (numH - h);
			System.out.println(total - col - row);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numM = 0;
		int numC = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numM = scanner.nextInt();
			numC = scanner.nextInt();
			int[] bArray = new int[numM];
			int[][] aArray = new int[numN][numM];

			for (int i = 0; i < bArray.length; i++) {
				bArray[i] = scanner.nextInt();

			}
			for (int i = 0; i < aArray.length; i++) {
				for (int j = 0; j < aArray[i].length; j++) {
					aArray[i][j] = scanner.nextInt();
				}
			}
			int cnt = 0;

			for (int i = 0; i < aArray.length; i++) {
				int res = 0;
				for (int j = 0; j < aArray[i].length; j++) {
					res += (aArray[i][j] * bArray[j]);
				}
				if (res + numC > 0) {
					cnt++;
				}
			}

			System.out.println(cnt);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main(){
  long long int cnt,ans=0,N,K ;
  string S ;
  vector<int> A(200);
  
  cin>> N>>K;
  for(int i=0;i<K;i++ ){
    int d; cin>>d;
    for(int j=0;j<d;j++){
      int ac;
      cin>>ac;
      A.at(ac-1)=1;
    }
  }
  for(int i=0;i<N;i++){
   ans+=A.at(i);
  
  }
  cout<<N-ans<<endl;;
}


Measured memory_bytes: 3636
#include <stdio.h>

using namespace std;

int main(void){
	int a, b, x;
	int hantei = 0;
	scanf("%d%d%d", &a, &b, &x);

	if (x == a + b)hantei = 1;
	else if (a <= x){
		if (x - a < b) hantei = 1;
	}

	if (hantei) printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

int main() {
  long D;
  cin >> D;
  
  //減点量の入力
  long c[27];
  for(int i=1; i<26+1; i++){
    cin >> c[i];
  }
  
  //加点量の入力
  long s[D+1][26+1];
  for(int i=1; i<D+1; i++){
  for(int j=1; j<26+1; j++){
    cin >> s[i][j];
  }}
  
  //開催日程の入力
  long t[D+1];
  for(int i=1; i<D+1; i++){
    cin >> t[i];
  }
  
  //過去の最終開催日を保持する配列
  long past[26+1] = {0};
  
  //日々の処理
  
  for(int day=1; day<D+1; day++){
    
    //仮の満足度を保持する配列
    long tempPoint[26+1] = {0};
    for(int tt=1; tt<26+1; tt++){

      //満足度の加点計算
      tempPoint[tt] += s[day][tt];

      //満足度の減点計算
      for(int num=1; num<26+1; num++){
        tempPoint[tt] -= ( c[num] * (day - past[num]) );
      }
    }
    
    //それぞれの選択に対する満足度の変化量を表示
    //for(int i=1; i<26+1; i++){
    //  cout << i << " : " << tempPoint[i] << endl;
    //}
    
    //仮の満足度から一番高い満足度の選択を出力
    int choice=1;
    for(int i=1; i<26+1; i++){
      if(tempPoint[choice] < tempPoint[i]) choice = i;
    }
    //cout << "choice " << choice << endl;
    if(day!=D){
      cout << choice << endl;
    }else{
      cout << choice;
    }
  }

  return 0;
}


Measured memory_bytes: 3720
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [True] * (A[-1]+1)

for i,num in enumerate(A):
    if i < N-1 and A[i+1] == num:
        dp[num] = False
    else:
        for j in range(2*num, A[-1]+1, num):
            dp[j] = False

print(len([i for i in A if dp[i]]))

Measured memory_bytes: 32236
n = int(input())
h = tuple(map(int, input().split()))

counts = []
i = 0
count = 0
while i < n - 1:
  if h[i] < h[i+1]:
    counts.append(count)
    count = 0
  else:
    count += 1
  i += 1
counts.append(count)
print(max(counts))


Measured memory_bytes: 14352
k = int(input())

# 解説AC
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans, num = 1, 7
for i in range(k):
    if num % k == 0:
        print(ans)
        break
    ans += 1
    num = (num % k) * 10 + 7


Measured memory_bytes: 63212
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [list(map(int,input().split())) for _ in range(M)]

total = sum(T)

Ans = []
for p,x in PX:
    Ans.append(total - T[p-1] + x)

for ans in Ans:
    print(ans)

Measured memory_bytes: 3064
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;	
	cin >> s;
	if(s == "SUN") cout << 7;
	if(s == "MON") cout << 6;
	if(s == "TUE") cout << 5;
	if(s == "WED") cout << 4;
	if(s == "THU") cout << 3;
	if(s == "FRI") cout << 2;
	if(s == "SAT") cout << 1;
	return 0;
}


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

int main()
{
	string strS, strT;
	cin >> strS >> strT;

	if(strT.size() == (strS.size() +1)){

		if(strS == strT.substr(0, strS.size())){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <vector>
#include <math.h>


using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)


int main() {
	long long int N, M, K, t = 0;
	cin >> N >> M >> K;
	vector<ll> A(N),as(N+1);
	vector<ll> B(M),bs(M+1);
	rep(i, N) {
		cin >> A[i];
		as[0] = 0;
	    as[i+1] = as[i] + A[i];
	}
	rep(i, M) {
		cin >> B[i];
		bs[0] = 0;
		bs[i+1] = bs[i] + B[i];
	}
	long long int min, b,max,bsu,ans = 0;
	
	rep(i, N + 1) {
		if (as[i] > K)break;
		b = K - as[i];
		min = 0, max = M;
		

		bsu = (min + max) / 2;
		//最初から差が一の時も考慮
		if (max - min == 1) {
			if (bs[max] == b)bsu = max;
			else bsu = min;
			//break;
		}
		while(max - min != 1){
			bsu = (min + max) / 2;
			if (b > bs[M]) {
				bsu = M;
				break;
			}
			//負等号は別々に書く
			if (bs[min] <= b && b<= bs[bsu]) {
				max = bsu;
			}
			else if(bs[bsu] < b && b <=bs[max]){
				min = bsu;
			}
			if (max - min == 1) {
				if (bs[max] == b)bsu = max;
				else bsu = min;
				//break;
			}
			
		}
		if(i+bsu > ans) ans = i + bsu;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 9212
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) (i%(ll)(1e9 + 7))


int main(){
	ull n,t;
	ull sum = 0,now = 0;
	cin >> n >> t;
    
    rep(i,0,n){
        ull tt;
        cin >> tt;

        if(now >= tt){
            sum += (tt+t)-now;
            now = tt+t;
        }else{
            sum += t;
            now = tt+t;
        }
    }
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int k, x;
    cin>>k>>x;
    if((k*500) >= x)cout<<"Yes";
    else cout<<"No";
}


int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

Measured memory_bytes: 596
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
  for val in arr:
    if i-dic[val]<0:
      continue
    else:
      dp[i]=max(dp[i],dp[i-dic[val]]+1)
ans=''
tmp=n
while tmp>0:
  for val in arr:
    if tmp-dic[val]<0:
      continue
    if dp[tmp]==dp[tmp-dic[val]]+1 and dp[tmp-dic[val]]!=-1:
      ans+=str(val)
      tmp-=dic[val]
      break
print(ans)

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

#define MAX 2000000
#define INFTY (1<<30)

int H = 0;
int A[MAX + 1];

void heaplify(int i) {
    int max;
    int l = 2 * i;
    int r = 2 * i + 1;
    if (l <= H && A[i] < A[l])
        max = l;
    else
        max = i;
    if (r <= H && A[max] < A[r])
        max = r;
    if (max != i) {
        swap(A[i], A[max]);
        heaplify(max);
    }
}

void insert(int key) {
    H++;
    A[H] = -INFTY;
    if (key < A[H])
        return;
    A[H] = key;
    int i = H;
    while (i > 1  && A[i/2] < A[i]) {
        swap(A[i/2], A[i]);
        i = i / 2;
    }
}

int extract() {
    int max = A[1];
    A[1] = A[H];
    H--;
    heaplify(1);
    return max;
}

int main() {
    int key;
    string com;

    while (true) {
        cin >> com;
        if (com == "end")
            break;
        if (com == "insert") {      
            cin >> key;
            insert(key);
            //for (int i = 1; i <= H; i++)
              //  cout << A[i] << endl;
        }
        if (com == "extract") {
        //    for (int i = 1; i <= H; i++)
          //      cout << A[i] << endl;
            cout <<  extract() << endl;
        }
    }

    return  0;
}



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

vector<int>pr;
int root(int x){
	if(pr[x]==-1)return x;
	else return pr[x]=root(pr[x]);
}

void unify(int x,int y){
	x=root(x),y=root(y);
	if(x==y)return;
	pr[x]=y;
}

int same(int x,int y){return root(x)==root(y);}

int main(){

int n,q;cin>>n>>q;
pr.resize(n,-1);

rep(i,q){
int x,y,z;cin>>x>>y>>z;
if(x==0)unify(y,z);
else cout<<same(y,z)<<endl;

}

}


Measured memory_bytes: 3224
n = gets.to_i
a = gets.split.map(&:to_i)

if a.select { |x| x < 0 }.size.even?
  puts a.map(&:abs).reduce(&:+)
else
  min_abs = a.map(&:abs).min
  puts a.map(&:abs).reduce(&:+) - 2 * min_abs
end

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

const int INF = 1e9 + 1000;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> D(N), C(M);
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> C[i];
	}
	vector<int> dp(N + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < M; i++) {
		for (int j = N - 1; j >= 0; j--) {
			dp[j + 1] = min(dp[j + 1], dp[j] + D[j] * C[i]);
		}
	}
	cout << dp[N] << endl;
	return 0;
}



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

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

    int card[4][13] = {};
    for (int i =0 ;i<n;i++){
         string suit;
         int num;
         cin >> suit>>num;
         

         if (suit == "S") card[0][num-1] = 1;
         if (suit == "H") card[1][num-1] = 1;
         if (suit == "C") card[2][num-1] = 1;
         if (suit == "D") card[3][num-1] = 1;
     }

     string str[4] = {"S","H","C","D"};
     for (int i =0;i<4;i++){
          for (int j =0;j<13;j++){
              if (card[i][j] ==1) continue;
               cout<<str[i]<<" "<<j+1<<endl;
          }
     }

      return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> D(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    cin >> D[i][0] >> D[i][1];
  }
  
  bool bingo = false;
  
  for (int i = 0; i < N - 2; i++) {
    if (D[i][0] == D[i][1] && D[i + 1][0] == D[i + 1][1] && D[i + 2][0] == D[i + 2][1]) {
      bingo = true;
      break;
    }
  }
  
  if(bingo) puts("Yes");
  else puts("No");
  
  return 0;
}

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

const int MAX = 998244353;
 
 



signed main(){
    int n;
    string s;
    cin>>n>>s;
   
    int r=0,g=0,b=0,m=0,M=0,t=0;
    int dp[3*n];
    for(int i=0;i<3*n;i++){
        if(s[i]=='R'){
            r++;
           

        }
        if(s[i]=='G'){
            g++;
               
        }
        if(s[i]=='B'){
            b++;
                
        }
           if(min(r,min(g,b))>m){
                t--;
            
                m++;

            }
            if(max(r,max(g,b))>M){
                t++;
                M++;
            }
                dp[i]=t;
              //  cerr<<t;
       
    }
 int u=1;
    int ans1[3*n]={},ans2[3*n]={};
    for(int i=1;i<3*n;i++){
        if(dp[i-1]<dp[i])u++;
        if(dp[i-1]==dp[i]){
            ans1[i]=u;
           // cerr<<u<<' ';
            u--;
        }
    }
    u=0;
    for(int i=3*n-1;i>=1;i--){
        if(dp[i-1]>dp[i])u++;
        if(dp[i-1]==dp[i]){
            ans2[i]=u;
            //cerr<<u<<' ';
            u--;
        }
    }
    int ans=1;
    for(int i=1;i<3*n;i++){
        if(dp[i-1]==dp[i])ans=(ans*ans1[i]*ans2[i])%MAX;
    }
    for(int i=1;i<=n;i++)ans=(ans*i)%MAX;
    cout<<ans;
    return 0;
}


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

signed main(){
    int n,k; cin>>n>>k;
    vector<int> h(n); rep(i,n) cin>>h.at(i);
    vector<int> dp(n,INT_MAX); dp.at(0)=0;
    rep(i,n){
        int j=1;
        while(i-j>=0 and j<=k){
            dp.at(i)=min(dp.at(i),abs(h.at(i)-h.at(i-j))+dp.at(i-j));
            j++;
        }
    }
    cout<<dp.back()<<endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void init(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

int main() {
    ll n;
    cin >> n;
    ll med = n * (n + 1) / 2 / 2 + 1;
    VI a(n);
    REP(i,n) a[i] = in();
    VI b(a);
    sort(ALL(b));

    int ok = n - 1, ng = -1;
    while (ok - ng > 1){
        int m = (ok + ng) / 2;
        VI c(n);
        REP(i,n){
            if (a[i] <= b[m]) c[i] = 1;
            else c[i] = -1;
        }
        BIT bit(2*n+1);
        bit.add(n, 1);
        ll tmp = 0, s = 0;
        REP(i,n){
            s += c[i];
            tmp += bit.sum(s - 1 + n);
            bit.add(s + n, 1);
        }
        if (tmp >= med) ok = m;
        else ng = m;
    }
    cout << b[ok] << endl;

    return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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 ans = 0;
    string S;
    cin >> S;
    int N = S.length();
    REP(i,N){
        REP(j,N){
            bool cor = true;

            FORq(k,i,j){
                if (!((S[k] == 'A') or (S[k] == 'C') or (S[k] == 'G') or (S[k] == 'T'))){
                    cor = false;
                }
            }

            if (cor) chmax(ans,j-i+1);
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<(T)>())
#define REVERCE(x) reverce(ALL(x))

itn main() {
	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<int> d(n);

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

	int cnt = 0;

	REP(i, n - 1) {
		REP2(j, i + 1, n) {
			cnt += d[i] * d[j];
		}
	}

	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
import math
i = input()
a = i.split()
a = int(a[0])
b = a
s = 0
for i in range(len(i)):
    s = s + (a % 10)
    a = math.floor(a / 10)

ans = b % s


if (ans == 0):
    print("Yes")
else:
    print("No")




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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	int n;
	cin >> s; n = s.size();
	vector <ll> dp1, dp2;
	dp1.assign(n+1, 0);
	dp2.assign(n+1, 0);
	for (int i=1; i<=n; i++) {
		if (s[i-1] == '<') {
			dp1[i] = 1+dp1[i-1];
		}
	}
	for (int i=n-1; i>=0; i--) {
		if (s[i] == '>') {
			dp2[i] = 1+dp2[i+1];
		}
	}
	ll ans = 0;
	ans += dp2[0];
	ans += dp1[n];
	for (int i=1; i<n; i++) {
		if (s[i-1] == '>' && s[i] == '>') {
			ans += dp2[i];
		}
		if (s[i-1] == '<' && s[i] == '<') {
			ans += dp1[i];
		}
		if (s[i-1] == '<' && s[i] == '>') {
			ans += max(dp2[i], dp1[i]);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 8732