akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 1e5 + 10;
int a[N];
int main() {
	int n; scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);	
	int cnt = 0;
	rep(i,1,n) if (a[i] & 1) cnt++;
	if (cnt & 1) cout <<"NO"<<endl;
	else cout <<"YES"<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[][] a = new int[2][N];

    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < N; j++) {
        a[i][j] = scanner.nextInt();
      }
    }

    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += a[0][i];
    }
    sum += a[1][N - 1];

    int max = sum;
    for (int i = N - 2; i >= 0; i--) {
      sum += a[1][i] - a[0][i + 1];
      if (sum > max) max = sum;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 22736
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cstring>
#include <ostream>
#include <cmath>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << "\n";
  }
  return os;
}

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

  int N;
  std::vector<int> a;

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

  ll sum_[200002] = { 0LL };

  for (int i = 1; i <= N; ++i) {
    sum_[i] = sum_[i - 1] + a[i - 1];
  }

  ll ans = ll(1e18);

  for (int i = 0; i < N - 1; ++i) {
    ans = std::min(ans, llabs(sum_[i + 1] - (sum_[N] - sum_[i + 1])));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def scan_domino(a: list, b: list):
    n = len(a)
    cnt = 0
    domino = ""

    while cnt < n:
        if a[cnt] == b[cnt]:
            domino += "x"
            cnt += 1
        else:
            domino += "y"
            cnt += 2

    return domino


def cnt_pattern(domino, mod):
    ans = 3 if domino[0] == "x" else 6
    for dleft, dright in zip(domino[:-1], domino[1:]):
        if dleft == "x" and dright == "x":
            ans *= 2
        elif dleft == "x" and dright == "y":
            ans *= 2
        elif dleft == "y" and dright == "x":
            ans *= 1
        else:
            ans *= 3

        ans %= mod

    return ans


n = ni()
a = lc()
b = lc()

MOD = 10**9 + 7

domino = scan_domino(a, b)
pats = cnt_pattern(domino, MOD)

print(pats)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl
//cout << "Yes" << endl;
//cout << "No" << endl;



int main(void) {
	double a;
	cin >> a;
	cout << (2 * a) * 3.14159265359 << endl;
}

Measured memory_bytes: 3260
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

// 0 black
// 1 white

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

    // input
    ll N, K;
    cin >> N >> K;

    string s;
    cin >> s;
    ll L = s.size();

    // count 
    vector<ll> C;

    char current = s[0];
    ll count = 1;
    FOR(i, 1, L){
        char c = s[i];
        if(c==current){
            count++;
        }else{
            C.push_back(count);
            count = 1;
        }
        current = c;
    }
    C.push_back(count);

    // pn(s);
    // pn(C.size());
    // vprint(C);

    vector<ll> B;
    vector<ll> W;
    if(s[0]=='0'){
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==0){
                B.push_back(c);
            }else{
                W.push_back(c);
            }
        }
    }else{
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==1){ // !
                B.push_back(c);
            }else{
                W.push_back(c);
            }
        }
    }

    // pn(B.size());
    // vprint(B);
    // pn(W.size());
    // vprint(W);

    // 全員１にできる
    if(B.size()<=K){
        p(N);
        return 0;
    }

    // 以降、B.size()>K

    // 累積和
    vector<ll> AcB(B.size()+1);
    FOR(i, 0, B.size()){
        AcB[i+1] = AcB[i] + B[i];
    }

    vector<ll> AcW(W.size()+1);
    FOR(i, 0, W.size()){
        AcW[i+1] = AcW[i] + W[i];
    }

    bool is_head_white;
    if(s[0]=='0'){
        is_head_white = false;
    }else{
        is_head_white = true;
    }

    ll max_sum = 0;
    FOR(i, 0, B.size()-K+1){
        // i ~ i+K-1までの和
        ll b_sum = AcB[i+K] - AcB[i];
        // pn(b_sum);

        if(is_head_white){
            // i ~ i+K-1までの和
            ll w_sum = AcW[i+K] - AcW[i];
            if(i+K<W.size()){
                w_sum += W[i+K];
            }
            //pn(w_sum);
            ll sum = b_sum + w_sum;
            max_sum = max(max_sum, sum);
        }else{
            // i ~ i+K-2までの和
            ll w_sum = AcW[i+K-1] - AcW[i];
            if(i+K-1<W.size()){
                w_sum += W[i+K-1];
            }
            if(i-1>=0){
                w_sum += W[i-1];
            }
            ll sum = b_sum + w_sum;
            max_sum = max(max_sum, sum);
        }
    }

    p(max_sum);
    

    // pn(W.size());
    // pn(B.size());


    
    return 0;
}

Measured memory_bytes: 3140
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
      
        int n, m; cin >> n >> m;
        int dsu[n + 1], size[n + 1] = {0};

        for(int i = 1; i <= n; i++){
            dsu[i] = i;
            size[i] = 1;
        }
        function<int(int)> root = [&](int u){
            if(dsu[u] == u)
                return u;
            return dsu[u] = root(dsu[u]);
        };

        function<void(int, int)> update = [&](int u, int v){
            u = root(u);
            v = root(v);
            if(u == v)
                return;
            size[u] += size[v];
            dsu[v] = u;
        };
        for(int i = 0; i < m; i++){
            int x, y; cin >> x >> y;
            update(x, y);
        }
        cout << *max_element(size + 1, size + n + 1);
        return 0;
}

Measured memory_bytes: 6728
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define N 100010
#define ll long long int
using namespace std;
ll an[N];
struct Node{
  int to;
  ll cost;
};
vector<Node> v[N];
void dfs(int x,int fa){
  for(int i=0;i<v[x].size();i++){
    if(v[x][i].to==fa)
      continue;
    an[v[x][i].to]=an[x]+v[x][i].cost;
    dfs(v[x][i].to,x);
  }
}
int main(){
  int n;
  scanf("%d", &n);
  int x,y;
  ll z;
  for(int i=1;i<n;i++){
    scanf("%d%d%lld",&x,&y,&z);
    v[x].push_back({y,z});
    v[y].push_back({x,z});
  }
  int q,t;
  scanf("%d%d",&q,&t);
  dfs(t,-1);
  while(q--){
    scanf("%d%d",&x,&y);
    printf("%lld\n",an[x]+an[y]);
  }
  return 0;
}






Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int n,k;
int data1[max_n];
bool cmp(int a,int b)
{
	return a>b;
}
ll sum1;
int main()
{
	cin>>n>>k;
	if(k>=n)
	{
		cout<<"0";return 0;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>data1[i];
		sum1+=data1[i];
	}
	sort(data1+1,data1+1+n,cmp);
	for(int i=1;i<=k;i++)
	{
		sum1-=data1[i];
	}
	if(sum1!=0)
	{
		cout<<sum1;
	}
	else cout<<"0";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int M,D,ans;
bool check(int i,int j){
	int a=j%10,b=j/10;
	if(a<=1||b<=1)return false;
	return (a*b==i);
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>M>>D;
	for(int i=1;i<=M;++i)for(int j=1;j<=D;++j){
		if(check(i,j))++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int add = 0;
        int[] array = new int[3];
        for(int i=0; i < 3; i++){
            array[i] = sc.nextInt();
            add = add + array[i];
        }
        if(add >= 22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 23892
N = int(input())
A = list(map(int,input().split()))

flag = 0
for i in range(N):
	if A[i] % 2 ==0:
		if (A[i] % 3 !=0) and (A[i] % 5 !=0):
			flag = 1
if flag == 0:
	print("APPROVED")
else:
	print("DENIED")

Measured memory_bytes: 9160
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
A = 0
for x in b:
  i = bisect.bisect_left(a, x)
  j = bisect.bisect_right(c, x)
  if i > 0 and j != len(c):
    A += i * (n - j)
print(A)


Measured memory_bytes: 23232
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 2 * int(1e5);
int N;
ll T, t[MAX_N], dp = 0;

int main() {
    cin >> N >> T;
    REP(i, N) {
        cin >> t[i];
        if (i == 0) dp += T;
        else if (t[i - 1] + T < t[i]) dp += T;
        else dp += (t[i] - t[i - 1]);
    }
    cout << dp << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  int N;
  double res;
  cin >> N;
  vector<pii> pos(N);
  for (int i = 0; i < N; i++) {
    cin >> pos[i].first;
    cin >> pos[i].second;
  }
  vector<vector<double>> dis(N, vector<double> (N, 0));
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      dis[i][j] =
          (pos[i].first - pos[j].first) * (pos[i].first - pos[j].first) +
          (pos[j].second - pos[i].second) * (pos[j].second - pos[i].second);
      dis[i][j] = sqrt(dis[i][j]);
      dis[j][i] = dis[i][j];
    }
  }
  vector<int> order(N);
  for (int i = 0; i < N; i++) {
    order[i] = i;
  }
  double sum = 0;
  double count = 0;
  do {
    for (int i = 0; i < N - 1; i++) {
      sum += dis[order[i]][order[i + 1]];
    }
    count++;
  } while (next_permutation(order.begin(), order.end()));
  res = sum / count;
  cout << setprecision(20) << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e6 + 123;
const ld pi = acos(-1.0);
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
 
int x;

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));

//	speed;

	x = 1^2^3;
	int a;
	cin >> a;
	x ^= a;
	cin >> a;
	x ^= a;

	cout << x;
          
    return 0;                                        
}

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

int main(){
  int n;
  cin>>n;
  int w[n];
  for(int i=0;i<n;i++){
    cin>>w[i];
  }
  
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=w[i];
  }
  
  int sumsub=0;
  int mi=sum;
  for(int i=0;i<n-1;i++){
    sumsub+=w[i];
    mi=min(mi,abs(sum-2*sumsub));
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
# include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

vector<vector<ll>> dp(100, vector<ll>(100, -1));

ll dfs(int n, int k){
  if (dp[n][k]!=-1) return dp[n][k];
  if (k==0||k==n) return dp[n][k] = 1;
  else return dp[n][k] = (dfs(n-1, k-1) + dfs(n-1, k));
}

int main() {
  int N, A, B; cin >> N >> A >> B;
  map<ll, int> v; rep(i,N) {ll n; cin >> n; v[n]++;}
  rep(i, 51) dfs(50,i);

  ll sum = 0, c = 0, A_t = A;
  long double ave = 0;
  for (auto i=v.rbegin(), e=v.rend(); i!=e; i++) {
    if (i==v.rbegin() && A_t <= i->second) {
      ave = i->first;
      for (int x=A_t; x<=min(B,i->second); x++) {
        c += dp[i->second][x];
      }
      break;
    }

    if (A_t>=i->second) {
      sum += i->first * i->second;
      A_t -= i->second;
    }
    else {
      sum += i->first * A_t;
      ave = (long double)sum / A;
      c = dp[i->second][A_t]; 
      break;
    }
  }
  cout<< fixed << setprecision(10) << ave << endl;
  cout << c << endl;
  return 0;
}

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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)

/*
*	verified : http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4713284#1
*	last revised : 29.July.2020 
 */
template<class T> class BIT {
private:
	int n;
	vector<T> dat;//[1,n]
public:
	BIT(int maxn, int _n) {
		dat.assign(maxn + 1, 0);
		n = _n;
	}
	T sum(int i) {
		T res = 0;
		while (i > 0) {
			res += dat[i];
			i -= i & -i;
		}
		return res;
	}
	void add(int i, T x) {
		while (i <= n) {
			dat[i] += x;
			i += i & -i;
		}
	}
};
#define maxn 500050
#define F first
#define S second
struct range{
  int l,r,id;
  range(){}
  range(int l,int r,int id):l(l),r(r),id(id){}
};
bool comp(range& a,range& b){
  return a.r < b.r;
}
int main(){
  cin.tie(0);ios::sync_with_stdio(false);  
  int N,Q;cin >> N >> Q;
  vector<int> c(N+1);
  for(int i=1;i<=N;i++)cin>>c[i];
  vector<range> a(Q);
  for(int i=0;i<Q;i++){
    int l,r;cin >> l >> r;
    a[i] = range(l,r,i);
  }
  sort(a.begin(),a.end(),comp);
  BIT<int> bit(maxn,maxn);
  vector<int> good(maxn,0);
  vector<int> ans(Q,0);
  int i = 0,j = 1;
  for(;i < Q;i++){
    for(;j <= a[i].r;j++){
      if(good[c[j]] == 0){
        bit.add(j,1);
      }else{
        bit.add(good[c[j]],-1);
        bit.add(j,1);
      }
      good[c[j]] = j;
    }
    ans[a[i].id] = bit.sum(a[i].r) - bit.sum(a[i].l-1);
  }
  for(int i=0;i<Q;i++)cout << ans[i] << '\n';
}


Measured memory_bytes: 17416
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll a[200000];
int main()
{
	ll n; cin >> n;
	rep(i, 0, n)cin >> a[i];

	ll c = 1;
	ll ans = 0;
	rep(i, 0, n) {
		if (a[i] == c) {
			c++;
			ans++;
		}
	}

	cout << ((ans == 0) ? -1 : n-ans) << endl;


}



Measured memory_bytes: 1792
P = (10**9)+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
res_p = 0
res_n = 0

for i in range(N):
    for j in range(i+1,N):
        if A[i]>A[j]:
            res_p += 1
        if A[-i-1]>A[-j-1]:
            res_n += 1
res = (res_p + res_n) * K * (K+1) // 2 - (K * res_n)


print(res % P)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
  int n;
  long long a[10001]={0};
  cin>>n;
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  long long int min=1000000,max=-1000000,sum=0;
  for(int i=0; i<n; i++){
      if(a[i]<min){
          min=a[i];
      }
      if(a[i]>max){
          max=a[i];
  }
     sum=sum+a[i];
}
  cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3184
def main():
    n = int(input())
    h_list = list(map(int, input().split()))

    dp = [100000]*n

    dp[0] = 0
    for i in range(1,n):

        tmp_dp1 = 1000000
        tmp_dp2 = 1000000
        if i - 1 >= 0:
            tmp_dp1 = dp[i-1] + abs(h_list[i] - h_list[i-1])

        if i - 2 >= 0:
            tmp_dp2 =  dp[i-2] + abs(h_list[i] - h_list[i-2])
        dp[i]=min(tmp_dp1, tmp_dp2)
    print(dp[n-1])
main()


Measured memory_bytes: 20496
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String keyence = "keyence";
		String[][] keyarr = new String[8][2];
		for(int i = 0;i < 8;i ++) {
			keyarr[i][0] = keyence.substring(0, i);
			keyarr[i][1] = keyence.substring(i, 7);
			if(s.startsWith(keyarr[i][0]) && s.endsWith(keyarr[i][1])) {
				System.out.println("YES");
				return;
			}
			/*if(i < 7) {
				if(s.indexOf(keyarr[i][0]) == 0 && 
						s.indexOf(keyarr[i][1]) == s.length() - keyarr[i][1].length()) {
					System.out.println("YES");
					return;
				}
			}else {
				if(s.indexOf(keyarr[i][0]) == 0) {
					System.out.println("YES");
					return;
				}
			}*/
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 24916
#include<stdio.h>
 
int main(void)
 
{
 
int a,b;
 
scanf("%d",&a);
 
scanf("%d",&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: 580
#include<iostream>
using namespace std;
int main(){
    int r,c;
    cin>>r>>c;
    int a[r][c];
    int sum[c];
    int sum_all=0;
    //行列の行の和の初期化
    for(int j=0;j<c;j++)
        sum[j]=0;


    //行列Aの入力・出力・行の和の出力
    for(int i=0;i<r;i++){
        int sumc =0; 
        for(int j=0;j<c;j++){
            cin>>a[i][j];
            sumc+=a[i][j];          //行の和
            cout<<a[i][j]<<" ";
            sum[j]+=a[i][j];//列の和
        }   
        cout<<sumc<<"\n";
    }   
    for(int j=0;j<c;j++){                                      
        cout<<sum[j]<<" ";
        sum_all+=sum[j];
    }   
    cout<<sum_all<<"\n";
    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int  c[2000000],d[2000000];

int main()
{
    int i,n,m,j,k=0,l=0;
    int x,y,z=0;
    scanf("%d %d",&n,&m);
    for(i=1; i<=m; i++)
    {
        scanf("%d %d",&x,&y);
        if(x==1)
        {
            c[y]=y;
        }if(y==n)
        {
            d[x]=x;
        }
    }
    for(i=1;i<=200005;i++)
    {
        if(d[c[i]]==c[i]&&c[i]!=0)
        {
            z=1;
            break;
        }
    }

    if(z==1)
    {
        printf("POSSIBLE");
    }else
    {
        printf("IMPOSSIBLE");
    }
    return 0;
}


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


int main(int argc, char const *argv[])
{
    char c;
    cin>>c;
    
    if (c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
        cout<<"vowel"<<endl;
    }
    else
    {
        cout<<"consonant"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine().trim();
        System.out.println(payment(s));
    }

    public static long payment(String s) {
        int[] client = new int[s.length()+1];
        int[] cashier = new int[s.length()+1];
        for (int i = 0; i < s.length(); i++) {
            client[i+1]=s.charAt(i)-'0';
        }
        for (int j = 0; j < 10; j++) {
            for (int i = client.length-1; i >0 ; i--) {
                //check if cachier can boost
                if(cashier[i]>0 && client[i]>0){
                    int min = Math.min(cashier[i], client[i]);
                    cashier[i]-=min;
                    client[i]-=min;
                }
                if(client[i]>=10){
                    client[i-1]+=client[i]/10;
                    client[i] = client[i]%10;
                }
                if(client[i]>5){
                    cashier[i]+=10-client[i];
                    client[i-1]+=1;
                    client[i]=0;
                }
                if(client[i]==5 && cashier[i-1]>0){
                    client[i]=0;
                    cashier[i-1]-=1;
                    cashier[i]+=5;
                }
                if(client[i]==5 && client[i-1]==5){
                    client[i-2]+=1;
                    client[i-1]=0;
                    client[i]=0;
                    cashier[i-1]+=4;
                    cashier[i]+=5;
                }
            }
        }

        long c = 0;
        for (int i = 0; i < client.length; i++) {
            c+=client[i]+cashier[i];
        }
        return c;
    }
}


Measured memory_bytes: 46816
// https://atcoder.jp/contests/abc166/tasks/abc166_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> H(N), J(N);
    REP(i, N) { cin >> H[i]; }
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        // 隣接する山の最高値
        J[a] = max(J[a], H[b]);
        J[b] = max(J[b], H[a]);
    }
    int ans = 0;
    REP(i, N) { ans += H[i] > J[i]; }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

set<int> divisor(int x) {
    set<int> res;
    for (int i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            res.insert(i);
            res.insert(x / i);
        }
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep (i, n) cin >> a[i];
    sort(a.begin(), a.end());
    map<int, int> mp;
    rep (i, n) mp[a[i]]++;
    int res = 0;
    rep (i, n) {
        mp[a[i]]--;
        bool ok = true;
        auto v = divisor(a[i]);
        for (auto e : v) {
            if (mp[e] > 0) {
                ok = false;
                break;
            }
        }
        if (ok) res++;
        mp[a[i]]++;
    }
    cout << res << endl;
    
    return 0;
}



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

int main() {
    int p, q, r;
    cin >> p >> q >> r;

    int ma = min(p + q, r + q);
    int mb = min(q + r, p + r);
    int mc = min(r + p, q + p);
    
    cout << min(ma, min(mb, mc)) << endl;

}

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

signed main()
{
  string w, t;
  int cnt = 0;
  int i;
  cin >> w;

  transform(w.begin(), w.end(), w.begin(), ::toupper);
  while(1){
    cin >> t;
    if (t == "END_OF_TEXT"){
      break;
    }
    transform(t.begin(), t.end(), t.begin(), ::toupper);
    if (w == t){
      cnt++;
    }
  }
  
  cout << cnt << endl;

  return (0);
}

Measured memory_bytes: 3144
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = _I()
H = LI()
ans = 1
for i in range(1, N):
    if all(H[j] <= H[i] for j in range(0,i)):
        if H[i-1] <= H[i]:
            ans += 1
print(ans)


Measured memory_bytes: 6740
#include <stdio.h>
int main(void){
    int a, b;
    char op;
    
    while(scanf("%d %c %d\n", &a, &op, &b) != EOF) {
        if (op == '?') break;
        if (b == 0 && op == '/') break;
        if (op == '+') printf("%d\n", a + b);
        if (op == '-') printf("%d\n", a - b);
        if (op == '*') printf("%d\n", a * b);
        if (op == '/') printf("%d\n", a / b);
    }
    
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int f = 0, res = 1;
	for (int i = 1; i < N; i++) {
		if (A[i] > A[i - 1]) {
			if (f > 0) {
				;
			}
			else if (f < 0) {
				f = 0;
				res++;
			}
			else {
				f = 1;
			}
		}
		else if (A[i] == A[i - 1]) {
			;
		}
		else {
			if (f > 0) {
				f = 0;
				res++;
			}
			else if (f < 0) {
				;
			}
			else {
				f = -1;
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> T;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int H, W, D;
int A[300][300];
int Q;
int y[90000];
int x[90000];

int d[90000];
void solve(){
	rep(i, H * W){
		if(d[i] == 0){
			for(int j = i; j < H * W - D; j += D){
				d[j + D] = d[j] + abs(x[j + D] - x[j]) + abs(y[j + D] - y[j]);
			}
		}
	}
	rep(i, Q){
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		cout << d[r] - d[l] << endl;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W >> D;
	rep(i, H) {
		rep(j, W) {
			cin >> A[i][j];
			A[i][j]--;
			y[A[i][j]] = i;
			x[A[i][j]] = j;
		}
	}
	cin >> Q;
	solve();
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
long long arr[100000];
using namespace std;

int main(void)
{
    //freopen("C:\\Users\\ACER\\Desktop\\input.txt","r",stdin);
    //freopen("C:\\Users\\ACER\\Desktop\\output.txt","w",stdout);

    long long n,c,k;
    cin>>n>>c>>k;
    long long ans=0;
    long long bus=-1;
    long long cap=0;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {

        long long temp;
        temp=arr[i];
        //cout<<bus<<" "<<ans<<endl;
        if(bus<0)
        {
            bus=temp+k;
            cap=1;
            ans++;
        }
        else if(cap==c||bus<temp)
        {
            ans++;
            cap=1;
            bus=temp+k;
        }
        else
            cap++;
        //cout<<temp<<" "<<bus<<" "<<ans<<endl;
    }
    cout<<ans;
}


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

typedef long long ll;

int main() {
    int k; cin >> k;
    vector<ll> a(k);
    for (int i=0; i<k; ++i) {
        cin >> a[i];
    }
    ll mn=2, mx=2;
    for (int i=k-1; i>=0; --i) {
        mn=(mn+a[i]-1)/a[i]*a[i];
        mx=mx/a[i]*a[i]+a[i]-1;
        if (mn>mx) {
            cout << -1;
            return 0;
        }
    }
    cout << mn << ' ' << mx;
    return 0;
}

Measured memory_bytes: 1024
def main():
    S = input()

    ans = f(S)
    print(ans)


def f(S):
    if S[0] != "A":
        return "WA"

    nc = S[2:-1].count("C")
    if nc != 1:
        return "WA"

    import string
    for c in S[1] + S[-1]:
        if c in string.ascii_uppercase:
            return "WA"

    return "AC"


if __name__ == '__main__':
    main()


Measured memory_bytes: 3892
#include <stdio.h>

int main(void)
{
	int n,b,f,r,v,i,j,k,l;
	int h[4][3][10]={0};
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		h[b-1][f-1][r-1]+=v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",h[i][j][k]);
			}
			printf("\n");
		}
		if(i==3) break;
		for(l=0;l<20;l++){
			printf("#");
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2060
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005
ll n,m,mod=1e9+7;
char arr[1000][1000];
int dp[1000][1000];
int solve(int x,int y)
{
	if(x==n-1&&y==m-1)
		return 1;
	if(x>=n||y>=m||arr[x][y]=='#')
		return 0;
	if(dp[x][y]!=-1)
		return dp[x][y];
	dp[x][y]= (solve(x+1,y)+solve(x,y+1))%mod;
	return dp[x][y];
}
int main()
{
    fastread;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    	for(int j=0;j<m;j++)
    		dp[i][j]=-1;
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<m;j++)
    		cin>>arr[i][j];
    }
    cout<<solve(0,0)<<endl;
    return 0;
}

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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

bool comp(const pair<int, int> &a, const pair<int, int> &b) {
    return ((ll)a.first + a.second) < ((ll)b.first + b.second);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end(), comp);
    vector<vector<ll> > dp(n + 1, vector<ll>(n + 1, LLONG_MAX));
    int ans = 0;
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (v[i].first >= dp[i][j]) {
                dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + (ll)v[i].second);
                ans = max(ans, j + 1);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 195840
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvii;
typedef pair<int, int> ii;
typedef vector<ii> vii;

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

void solve() {
	
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	cin >> t;
	string str;
	cin >> str;
	string end = "";
	for (int i = 0; i < str.size(); ++i) {
		if (i == t) {
			end += "...";
			break;
		}
		end += str[i];
	}
	cout << end << endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
using namespace std;
char A[100000];
int main() {
	cin >> A;
	for (int i = 0; i < strlen(A); i++) {
		if (A[i] == 'A') {
			cout << "T";
		}
		else if (A[i] == 'T') {
			cout << "A";
		}
		else if (A[i] == 'C') {
			cout << "G";
		}
		else {
			cout << "C";
		}

	}
	return 0;
}

Measured memory_bytes: 256
def solve():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])

    ans = 0
    j = M
    for i in range(N+1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 47504
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front
#define accept_sho ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int maxn = 1000* 100 + 5;
int a[maxn];

int32_t main(){
    int n, mx = 0, mn = 1000* 100 + 5;
    cin >>n;
    for(int i = 0; i < n; i ++){
        cin >>a[i];
        xmax(mx, a[i]);
        xmin(mn, a[i]);
    }
    if(mx - mn > 1)
        return cout <<"No" <<endl, false;
    if(mx == mn){
        if(mn == n - 1 or ((mn >= 1) and (mn <= n/ 2)))
            cout <<"Yes" <<endl;
        else
            cout <<"No" <<endl;
        return false;
    }
    int cn = 0;
    for(int i = 0; i < n; i ++){
        if(a[i] == mn)
            cn ++;
    }
    if(mx >= cn + 1 and mx <= cn + (n - cn)/ 2)
        cout <<"Yes" <<endl;
    else
        cout <<"No" <<endl;
    return false;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>
 
using namespace std;
 


int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
 
	int r, g;
	cin >> r >> g;

	cout << g * 2 - r << endl;

	return 0;
}

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

#define int long long
using namespace std;

int N, M, C, B[30], A[30][30];
int ans;

signed main()
{
	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		int SUM = 0;
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
			SUM += A[i][j] * B[j];
		}
		if (SUM + C > 0) {
			ans++;
		}
		
	}

	cout << ans << endl;

//	system("pause");

	return 0;
}



Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
s = [list(input()) for _ in range(h)]
INF=10**7

queue = deque()

cost = [[INF]*w for _ in range(h)]
cost[ch-1][cw-1]=0

dxdy = [[1,0],[-1,0],[0,1],[0,-1]]
warp = []
for m in range(-2,3):
    for n in range(-2,3):
        if [m,n] not in [[0,0],[1,0],[-1,0],[0,1],[0,-1]]:
            warp += [[m,n]]

queue.append([ch-1,cw-1,0])

while queue:
    x,y,d = queue.popleft()
    if d>cost[x][y]:
        continue
    for dx,dy in dxdy:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and d<cost[nx][ny]:
            cost[nx][ny]=d
            queue.appendleft([nx,ny,d])

    for dx,dy in warp:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and d+1<cost[nx][ny]:            
            cost[nx][ny]=d+1
            queue.append([nx,ny,d+1])

if cost[dh-1][dw-1]<INF:
    print(cost[dh-1][dw-1])
else:
    print(-1)


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

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(e, x) for (auto &e : x)
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)

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

const ll A = 26;
int fixed_mod(ll a, int b) {
	return (a + b - 1) % b + 1;
}

void recur(ll n) {
	if (n <= 0) return;
	recur((n - fixed_mod(n, A)) / A);

	// cout << n << ": ";
	cout << char('a' + fixed_mod(n, A) - 1);
	// cout << '\n';
}

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

	ll n; cin >> n;
	recur(n);
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define nl printf("\n")
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
using namespace std;
ll n,wt;
ll dp[100002][2];
ll w[101],v[101];
int solve(int val){
    for(int i=1;i<=n;i++){
        int prev=i%2;
        int now=(i+1)%2;
        for(int j=1;j<=val;j++){
            if(v[i]>=j){
                if(dp[j][prev]!=-1) dp[j][now]=min(dp[j][prev],w[i]);
                else dp[j][now]=w[i];
            }
            else{
                if(dp[j-v[i]][prev]!=-1){
                    if(dp[j][prev]!=-1) dp[j][now]=min(dp[j-v[i]][prev]+w[i],dp[j][prev]);
                    else dp[j][now]=dp[j-v[i]][prev]+w[i];
                }
                else dp[j][now]=dp[j][prev];
            }
        }
    }
    int now=(n+1)%2;
    while(val){
        if(dp[val][now]<=wt&&dp[val][now]!=-1){
            break;
        }
        val--;
    }
    return val;
}
int main(){
    scnll(n);
    scnll(wt);
    int val=0;
    for(int i=1;i<=100000;i++){
        dp[i][0]=-1;
        dp[i][1]=-1;
    }
    for(int i=1;i<=n;i++){
        scn(w[i]);
        scn(v[i]);
        val+=v[i];
    }
    int ans=solve(val);
    printf("%d\n",ans);
}




Measured memory_bytes: 5360
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

vector<vector<int>> G(200010);
vector<int> c(200010, 0), ans(200010, 0), used(200010, 0);
void dfs(int s, int cnt){
    if(used[s]) return;
    used[s] = 1;
    ans[s] = c[s]+cnt;
    for(auto v : G[s]){
        dfs(v, c[s]+cnt);
    }
}
int main(){
    int N, Q;
    cin >> N >> Q;
    for(int i = 0; i < N-1;i++){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for(int i = 0;i < Q;i++){
        int p, x;
        cin >> p >> x;
        c[p-1] += x;
    }
    dfs(0, 0);
    for(int i = 0;i < N;i++)    cout << ans[i] << endl;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
const int N=201000;
const int K=20;
double EPS=1e-7;
typedef long long ll;
#define lef(x) (x<<1)
#define rig(x) (lef(x)+1)

ll a[N],p[N];
map<ll,ll> mp;
    ll n,k;

int32_t main()	
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for (int i = 1; i <= n; ++i)
    {
    	cin>>a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
    	p[i]=(a[i]+p[i-1])%k;
    }
    ll rs=0;
    for (int i = 0; i <= n; ++i)
    {

    	if(i-k>=0)
    		mp[p[i-k]-i+k]--;

    	rs+=mp[p[i]-i+k]+mp[p[i]-i];
    	// cout<<mp[p[i]-i+k]+mp[p[i]-i]<<" "<<p[i]-i<<" "<<p[i]-i+k<<" "<<i<<"\n";
    	mp[p[i]-i]++;

    }
    cout<<rs<<"\n";
    return 0;
}

Measured memory_bytes: 28416
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;

int main(){
	int n;
	bool next = false;
	int w,l,d=0;
	while(cin>>n && n)
	{
		 if ( next )
        {
            cout << endl;
        }
        next = true;
		multimap< int,string,greater<int> >m;
		for(int i=0; i<n; i++)
		{
			string t;
			cin>>t>>w>>l>>d;
			m.insert( make_pair( w*3+d , t ) );
		}
		for(multimap< int,string,greater<int> >::iterator it=m.begin(); it != m.end(); it++)
			cout<< (*it).second << ',' << (*it).first << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
#define FOR(a,b) for(int i=a; i<b+1; i++)
using namespace std;
typedef long long ll;



int main() {
    ll a,b,c;
    ll k;
    cin >> a >> b >> c >> k;
    if(k%2==0){
        cout << a-b << endl;
    }
    else{
        cout << b-a << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

int par[100010];
int sz[100010];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        sz[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x)
        return x;
    else 
        return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x);    y = find(y);

    if (x == y)
        return ;
    else if (sz[x] < sz[y])
        par[x] = y;
    else {
        par[y] = x;
        if (sz[x] == sz[y])
            sz[x]++;
    }
}

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

typedef long long ll;

int main() {
    int n;  cin >> n;
    vector<pair<pair<ll,ll>,ll > > Gx(n), Gy(n);
    for (int i = 0; i < n; i++) {
        cin >> Gx[i].first.first >> Gx[i].first.second;
        Gy[i].first.second = Gx[i].first.first; 
        Gy[i].first.first = Gx[i].first.second;
        Gx[i].second = Gy[i].second = i;
    }

    sort(Gx.begin(), Gx.end());

    sort(Gy.begin(), Gy.end());

    vector<pair<ll,pair<ll, ll> > > G;
    for (int i = 0; i < n-1; i++) {
        ll w1 = abs(Gx[i].first.first - Gx[i+1].first.first);
        G.push_back(pair<ll,pair<ll,ll> > (w1, pair<ll,ll>(Gx[i].second,Gx[i+1].second)));
    }

    for (int i = 0; i < n-1; i++) {
        ll w1 = abs(Gy[i].first.first - Gy[i+1].first.first);
        G.push_back(pair<ll,pair<ll,ll> > (w1, pair<ll,ll>(Gy[i].second,Gy[i+1].second)));
    }    

    sort(G.begin(), G.end());

    init(n);

    ll ans = 0;

    for (int i = 0; i < 2*n-2; i++) {
        ll w = G[i].first;
        ll l = G[i].second.first, m = G[i].second.second;
        if (!same(l, m)) {
            ans += w;
            unite(l, m);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13168
while 1:
    N,M = map(int,raw_input().split())
    if N == M == 0: break
    DP = [map(int,raw_input().split()) for _ in xrange(N)]
    DP = sorted(DP, key = lambda x:x[1], reverse = True)

    ans = 0
    for i in xrange(N):
        if M-DP[i][0] >= 0:
            M -= DP[i][0]
        else:
            ans += DP[i][1]*(DP[i][0]-M)
            ans += sum(DP[j][1]*DP[j][0] for j in xrange(i+1,N))
            break
    print ans

Measured memory_bytes: 5908