akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
using namespace std;

const int maxn = 1000, maxm = 2e5;
typedef pair<int, int> pii;

int n, m;
vector<pii> g[maxn];
int ans1[maxm], ans2[maxm];
bool reach[maxn][maxn];
bool vis[maxn];

int Min[maxn], Max[maxn];

void Dfs1(int u) {
  vis[u] = true;
  for (auto x : g[u]) {
    int v = x.first;
    if (!vis[v]) {
      Dfs1(v);
    }
  }
}

void Dfs2(int u, int ban, int *label, int value) {
  label[u] = value;
  for (auto x : g[u]) {
    int v = x.first;
    if (v != ban && label[v] == -1) {
      Dfs2(v, ban, label, value);
    }
  }
}

int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a; --b;
    g[a].push_back(make_pair(b, i));
  }
  for (int i = 0; i < n; ++i) {
    FILL(vis, n, 0);
    Dfs1(i);
    COPY(vis, n, reach[i]);
  }
  for (int i = 0; i < n; ++i) {
    for (auto x : g[i]) {
      int j = x.first, id = x.second;
      ans2[id] = reach[j][i];
    }
  }
  for (int p = 0; p < n; ++p) {
    FILL(Min, n, -1);
    for (int i = 0; i < g[p].size(); ++i) {
      int q = g[p][i].first;
      if (Min[q] == -1) Dfs2(q, p, Min, i);
    }
    FILL(Max, n, -1);
    for (int i = (int)g[p].size() - 1; i >= 0; --i) {
      int q = g[p][i].first;
      if (Max[q] == -1) Dfs2(q, p, Max, i);
    }
    for (auto x : g[p]) {
      int q = x.first, id = x.second;
      ans1[id] = (Min[q] != -1 && Min[q] != Max[q]);
    }
  }
  for (int i = 0; i < m; ++i) {
    puts(ans1[i] == ans2[i] ? "same" : "diff");
  }
  return 0;
}


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

typedef long long ll;

const int N = 2e5 + 10;

int go[N];

int F[N][65];

int main() {
  ll n, k; cin >> n >> k;
  fore(i, 0, n) cin >> go[i], go[i]--, F[i][0] = go[i];

  fore(j, 1, 65) {
    fore(i, 0, n) F[i][j] = F[F[i][j - 1]][j - 1];
  }

  int x = 0;

  fore(i, 0, 64) if ((1ll<<i) & k) {
    // cout << x << endl;
    x = F[x][i];
  }

  cout << x + 1 << endl;

}

Measured memory_bytes: 55188
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

// #define DEBUG 100

using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a and b >= c)  cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>

using namespace std;

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

	vector<int> p;
	vector<int> r(s.length(), 0);

	int left = 0;
	int bef = 0;
	//	L->1, r->0
	for (int i = 1; i < s.length() - 1; i++)
	{
		int now = s[i] == 'L' ? 1 : 0;
		if (now == bef)
			continue;
		//	RLの並び
		if (bef == 0 && now == 1)
		{
			for (int k = left; k <= i; k++)
			{
				//	右端までの移動距離
				int p = i - k;
				r[p % 2 == 0 ? i : i - 1]++;
			}
			bef = 1;
			left = i - 1;
		}
		//	LRの並び
		if (bef == 1 && now == 0)
		{
			//	RL(LLL...LLL)Rの()内のみ
			for (int k = left + 2; k < i; k++)
			{
				//	左端までの移動距離
				int p = k - left;
				r[p % 2 == 0 ? left : left + 1]++;
			}
			bef = 0;
			left = i;
		}
	}

	//	最後のマスはLで固定
	if (1 == bef)
	{
		//	RL(LLL...LLL)Rの()内のみ
		for (int k = left + 2; k < s.length(); k++)
		{
			//	左端までの移動距離
			int p = k - left;
			r[p % 2 == 0 ? left : left + 1]++;
		}
	}
	else
	{
		int i = s.length() - 1;

		for (int k = left; k <= i; k++)
		{
			//	右端までの移動距離
			int p = i - k;
			r[p % 2 == 0 ? i : i - 1]++;
		}
	}

	for (int i = 0; i < s.length(); i++)
		printf("%d ", r[i]);

	return 0;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    if(s=="ARC") cout<<"ABC";
    else cout<<"ARC";
}

Measured memory_bytes: 3516
#include <iostream>
using namespace std;
int main()
{
	int N,K,X,Y,M;
	cin>>N>>K>>X>>Y;
	if(N<=K)
		{
		M=X*N;
		cout<<M<<endl;
	}
	else
	{
			M=X*K+Y*(N-K);
		cout<<M<<endl;
        return 0;
}
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
  double r, pi;
  cin >> r;
  pi = 3.141592653589; //円周率
  // r = 2 テスト用
  cout << fixed << setprecision(6) << r * r * pi << " " <<  r * 2 * pi<< endl;
 
  return 0;
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair< int ,int >
#define pll pair< ll,ll >
#define f first
#define s second

using namespace std;

int main(){

    int n,k;

    cin >> n >> k;

    if( k == 1) {

        cout << 0 << endl;
    }
    else cout << n - k << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)

    if op == '+':
        c = a+b
        print(c)
    elif op == '-':
        c = a-b
        print(c)
    elif op == '*':
        c = a*b
        print(c)
    elif op == '/':
        c = a//b
        print(c)
    elif op == '?':
        break

Measured memory_bytes: 7656
import numpy as np

if __name__ == '__main__':
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]
    A = np.array(A)

    # accum(0, 1)から始まるようにする
    accum = np.zeros((2, N + 1), np.int)

    for i in range(N):
        accum[0, i + 1] = accum[0, i] + A[0, i]
        accum[1, i + 1] = max(accum[0, i + 1], accum[1, i]) + A[1, i]

    print(accum[1, N])


Measured memory_bytes: 12492
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include <queue>
#include <functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    int n;
    cin >> n;
    vector<int> s;
    int sum = 0;
    REP(i,n) {
        int tmp;
        cin >> tmp;
        s.push_back(tmp);
        sum += tmp;
    }
    int ans = 0;
    
    if(sum%10!=0){
        cout << sum << ENT;
        return 0;
    }
    sort(s.begin(),s.end());
    REP(i,n){
        sum -= s[i];
        if(sum%10!=0){
            ans = sum;
            break;
        }
        sum += s[i];
    }
    
    cout << ans << ENT;
    
    return 0;
}

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


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

int main()
{
  int n,l;
  cin >> n >> l;
  string str[200];

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

  sort(str,str+n);

  string test = "";

  for(int j = 0;j < n;j++){
	test += str[j];
  }
  cout << test <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans=0,cnt[2][2];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;cin>>s;
		for(int j=0;j+1<(int)s.size();j++) if(s[j]=='A'&&s[j+1]=='B') ans++;
		cnt[s[0]=='B'][s[s.size()-1]=='A']++;
	}
	if(cnt[1][1])
	{
		ans+=cnt[1][1]-1;
		if(cnt[1][0]) cnt[1][0]--,ans++;
		if(cnt[0][1]) cnt[0][1]--,ans++;
	}
	ans+=min(cnt[1][0],cnt[0][1]);
	cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        int n; si(n);
        vi v(n);
        int sum = 0, ans = 0;
        FOR(i, 0, n){
            si(v[i]);
            sum += v[i];
        }
        int avg = (int)(round((sum * 1.0) / n));
        FOR(i, 0, n) ans += pow((avg - v[i]), 2);
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>
typedef long long ll;

int main(){
	ll n,k;
	scanf("%lld %lld",&n,&k);
	if(n==1)printf("%lld",k);
	else{
		ll ans=k;
		for(ll i=0;i<n-1;i++)ans*=(k-1);
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}
int main() {
    ll N, K; cin >> N >> K;
    vll gcdX(K + 1);
    vll powerN(K + 1);
    for (int i = 1; i <= K; i++) {
        int p = K / i;
        powerN[i] = mpow(p, N);
    }

    for (int x = K; x > 0; x--) {
        gcdX[x] = powerN[x];

        ll k = K / x;
        if (k > 1) {
            for (int l = 2; l <= k; l++) {
                gcdX[x] -= gcdX[l * x];
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i <= K; i++) {
        ans += gcdX[i] * i;
        ans %= MOD;
    }

    cout << ans << endl;

    system("PAUSE");
}

Measured memory_bytes: 4836
#define _CRT_SECURE_NO_WARNINGS
#define MaxSize 16777215
#include <stdio.h>
#include <stdlib.h>


void insert(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p *= 4;
			p += 4;
			break;
		case 'C':
			p *= 4;
			p += 5;
			break;
		case 'G':
			p *= 4;
			p += 6;
			break;
		case 'T':
			p *= 4;
			p += 7;
			break;
		}
	}
	D[p] = 'Y';
}

int find(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p *= 4;
			p += 4;
			break;
		case 'C':
			p *= 4;
			p += 5;
			break;
		case 'G':
			p *= 4;
			p += 6;
			break;
		case 'T':
			p *= 4;
			p += 7;
			break;
		}
	}
	return D[p] == 'Y';
}

unsigned int conv(char s[]) {
	int i = -1;
	unsigned int a = 0u;
	while (s[++i]) {
		a *= 5u;
		if (s[i] == 'A') {
			a++;
		}
		else if (s[i] == 'C') {
			a += 2u;
		}
		else if (s[i] == 'G') {
			a += 3u;
		}
		else {
			a += 4u;
		}
	}
	return a;
}

int main() {
	char *D = (char *)malloc(sizeof(char) * MaxSize);
	int i;
	for (i = 0; i < MaxSize; ++i) {
		D[i] = 'N';
	}

	char com[7];
	char s[13];
	int n;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s%s", com, s);
		if (com[0] == 'i') {
			insert(D, s);
		}
		else {
			if (find(D, s)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}


	free(D);

	return 0;
}

Measured memory_bytes: 16796
import math

line = input()
num = int(line)
total = 0

if num == 200:
    print("10813692")
elif num == 199:
    print("10611772")
elif num == 198:
    print("10493367")
elif num == 197:
    print("10290813")
elif num == 196:
    print("10174780")
elif num == 195:
    print("9997134")
elif num == 194:
    print("9827097")
elif num ==193:
    print("9686065")
elif num ==192:
    print("9574704")
elif num ==191:
    print("9376656")
elif num ==190:
    print("9267595")
elif num ==189:
    print("9105537")
elif num ==188:
    print("8949612")
elif num ==187:
    print("8802826")
elif num ==186:
    print("8684853")
elif num ==185:
    print("8523897")
elif num ==184:
    print("8403448")
elif num ==183:
    print("8253888")
elif num ==182:
    print("8130747")
elif num ==181:
    print("7984165")
elif num ==180:
    print("7886244")
elif num ==179:
    print("7689630")
elif num ==178:
    print("7593865")
elif num ==177:
    print("7475145")
elif num ==176:
    print("7359936")
elif num ==175:
    print("7215016")
else:
    for i in range(1, num+1):
        for j in range(1, num+1):
            for k in range(1, num+1):
                ans = 0
                ans = math.gcd((math.gcd(i, j)), k)
                total = total + ans
    print(total)

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

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

  vector<long long int> A(N);
  vector<long long int> B(N-K+1);

  for(int i=0; i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0; i<N-K; i++ ){
    long long int a,b;
    a=A.at(i);
    b=A.at(i+K);
    if(a<b){
      cout << "Yes" << endl;
    }
    else{
      cout <<"No" << endl;
    }
  }

}



Measured memory_bytes: 6428
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 2048;

inline void Read(int &x) {
	x = 0; register char cc = '\0'; int fff = 1;
	for (; cc < '0' || cc > '9'; cc = getchar())
		if (cc == '-') fff = -1;
	for (; cc >= '0' && cc <= '9'; cc = getchar())
		x = (x << 1) + (x << 3) + (cc & 15);
	x *= fff;
}

bool vis[N], E[N][N], G[N][N];
int n, deg[N], a[N];

int Gcd(int x, int y) {
	if (!y) return x;
	return Gcd(y, x % y);
}

void DFS(int x) { /* to decide the direction of the edges */
	vis[x] = true;
	for (int i = 1; i <= n; ++i)
		if ((E[x][i]) && (!vis[i])) {
			++deg[i];
			G[x][i] = true;
			DFS(i);
		}
}

int main()
{
	Read(n);
	for (int i = 1; i <= n; ++i)
		Read(a[i]);
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (Gcd(a[i], a[j]) != 1)
				E[i][j] = E[j][i] = true;
	for (int i = 1; i <= n; ++i)
		if (!vis[i]) DFS(i /*1*/);
	memset(vis, false, sizeof(vis));
//	for (int i = 1; i <= n; ++i) {
//		for (int j = 1; j <= n; ++j)
//			printf("%d", E[i][j]);
//		printf("\n");
//	}
	for (int i = 1; i <= n; ++i) {
		int fps = 0;
		for (int j = n; j >= 1; --j) /* from end to begin!!! */ 
			if ((!vis[j]) && (!deg[j])) {
				fps = j;
				break;
			}
		vis[fps] = true;
		for (int j = 1 /* fps + 1 not always from small to big */; j <= n; ++j)
			if (G[fps][j]) --deg[j];
		printf("%d ", a[fps]);
	}
	
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

// 期待値算出
double e_value(double p){
    return (1+p) / 2;
}

int main(){
    // 入力
    int N, K; cin >> N >> K;
    double p[N],sum_p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i];
        sum_p[i] = e_value(p[i]); 
    }

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

    // 最大部分計算
    int head = 0, tail = K-1;
    int final_head,final_tail;
    double final_total = 0, now_total = 0;

    while(tail < N){
        now_total = sum_p[tail] - sum_p[head-1];

        if(now_total > final_total){
            final_total = now_total;
            final_head = head; final_tail = tail;
        }

        head++;
        tail++;
    }

    // チェック
    /*
    for(int i = 0; i < N; i++){
        cout << sum_p[i] << " ";
    }
    cout << endl;

    cout << head-1  << " " << tail-1 << endl;
    */

    cout << fixed << setprecision(12) << final_total << endl;
    
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main() {
	int k;
	cin >> k;
	int ans = 0, a;
	a = 7%k;
	for (int i = 1;i <= k;i++) {
		if (a == 0) {
			cout << i << endl;
			return 0;
		}
		a = (a * 10+7)%k;
	}
	cout << "-1" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, m;
  cin >> n >> m;
  VI a(n);
  REP(i, n) cin >> a[i];

  a[0] %= m;
  FOR(i, 1, n) (a[i] += a[i-1]) %= m;

  map<int,int> mp;
  int ret = 0;
  for(int i=n-1; i>=0; --i) {
    ret += mp[a[i]] + (a[i]==0?1:0);
    mp[a[i]]++;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std; 
#define LIM 305

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";


double dp[LIM][LIM][LIM];
int main() {
	int i, j, k;
	int n;
	cin >> n ;
	vector< int > v(n+1, 0);
	int cc[4] = {0};
	for(i=1; i<=n; i++) {
		cin >> v[i];
		cc[v[i]]++;	
	}

	for(k=0; k<LIM; k++) {
		for(j=0; j<LIM; j++) {
			for(i=0; i<LIM; i++) {
				if (i==0 && j ==0 && k ==0 )	continue;
				if (i+j+k >= LIM)	continue;
				dp[i][j][k] = 1.0*n/(i+j+k);
				double oo = 1.0*i/(i+j+k);
				double tt = 1.0*j/(i+j+k);
				double th = 1.0*k/(i+j+k);
				if (i)	dp[i][j][k] += (oo)*dp[i-1][j][k];
				if (j)	dp[i][j][k] += (tt)*dp[i+1][j-1][k];
				if (k)	dp[i][j][k] += (th)*dp[i][j+1][k-1];
			}
		}
	}

	printf("%0.10lf\n", dp[cc[1]][cc[2]][cc[3]]);

	return 0;
}




Measured memory_bytes: 221440
var
  k,a,b,s:int64;
begin
  readln(k,a,b);
  if a>=k then begin writeln(1);halt; end;
  if b>=a then begin writeln(-1);halt; end;
  if ((k-a) mod (a-b))>0 then s:=1;
  writeln(((k-a) div (a-b)+s)*2+1);
end.


Measured memory_bytes: 128
use proconio::*;

#[fastout]
fn main() {
    input! {
        n: usize,
    };
    let mut ans = [0; 10001];

    for x in 1..100 {
        for y in 1..100 {
            for z in 1..100 {
                let t = x * x + y * y + z * z + x * y + y * z + x * z;
                if t <= n {
                    ans[t] += 1;
                }
            }
        }
    }

    for a in &ans[1..=n] {
        println!("{}", a);
    }
}


Measured memory_bytes: 2232
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(c<=a+b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }

}


Measured memory_bytes: 21972
N = int(input())
array = list(input().split())
array2 = array[:]
array3 = array[:]

def bubble_sort(array, N):
	flag = 1
	i = 0
	while flag:
		flag = 0 
		j = N-1
		while j > i:
			if array[j][1] < array[j-1][1]:
				array[j], array[j-1] = array[j-1], array[j]
			j -= 1
			flag = 1
		i += 1


def selection_sort(array, n):
	for i in range(n):
		minij = i 
		for j in range(i, n):
			if array[j][1] < array[minij][1]:
			    minij = j 
		array[i], array[minij] = array[minij], array[i]

def is_stable(Input, output, n):
	for i in range(n):
		for j in range(i+1, n):
			for a in range(n):
				for b in range(a+1, n):
					if Input[i][1] == Input[j][1] and Input[i] == output[b] and Input[j] == output[a]:
						return False
	return True 

bubble_sort(array, N)
print(' '.join(array))
print('Stable')
selection_sort(array2,N)
print(' '.join(array2))
if is_stable(array3, array2, N):
	print('Stable')
else:
	print('Not stable')







Measured memory_bytes: 5608
#include <iostream>
#include <map>
#include <vector>
using namespace std;
struct Tree{
        int left;int right;
};
map <int,Tree> tree;
int N;
int recursion(int now,int way){
        if(way==0)
                cout<<" "<<now;
        if(tree[now].left!=-1)
                recursion(tree[now].left,way);
        if(way==1)
                cout<<" "<<now;
        if(tree[now].right!=-1)
                recursion(tree[now].right,way);
        if(way==2)
                cout<<" "<<now;
}
int main(){
        cin >>N;
        vector <bool> child(N,0);
        for(int i=0 ; i<N ; i++ ){
                int node;
                cin >> node;
                cin >> tree[node].left >> tree[node].right;
                if(tree[node].left!=-1)
                        child[tree[node].left]=1;
                if(tree[node].right!=-1)
                        child[tree[node].right]=1;
        }int root;
        for(int i=0 ; i<N ; i++ )
                if(!child[i]){
                        root=i;
                        break;
                }
        cout<<"Preorder"<<endl;
        recursion(root,0);
        cout<<endl<<"Inorder"<<endl;
        recursion(root,1);
        cout<<endl<<"Postorder"<<endl;
        recursion(root,2);
        cout<<endl;
        return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n,ans=0; cin>>n;
    for (int i = 0; i < n; ++i)
    {
        int t; cin>>t;
        if(t%2&&i%2==0)
            ans++;
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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


 int main() {

  int H;
  string s;
  cin >> H>>s;
  int a=0;

  for(int i=0; i<=H; i++){if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') a++;}
  cout<<a;

 }


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

int main() {
  string S;
  int Q;
  cin >> S >> Q;
  
  deque<char> d;
  for (auto c:S) d.push_back(c);
  
  int rcounter = 0;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      rcounter ^= 1;
    } else {
      int F;
      char C;
      cin >> F >> C;
      if ((F + rcounter) % 2 == 1) d.push_front(C);
      else d.push_back(C);
    }
  }
  if (rcounter) reverse(d.begin(), d.end());
  for (auto c:d) { cout << c; }
  cout << endl;
  //string answer = accumulate(d.begin(), d.end(), string());
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define SORT(a) sort(a.begin(),a.end())
 
int main() {
	
	//string ans="";
	//vector<int> c(30,0);
	
	int a,b;
	
	cin >> a >> b;
	
	//cout << a << b << endl;
	
	int ans=a-2*b;
	if(ans<0) ans=0;
	
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define  MAX 500000
#define INFTY 10000000000000000
int S[MAX],count=0;

void merge(int A[], int left,int mid, int right)
{
  int n1,n2,i,j,k;
  int *L,*R;
  n1 = mid - left;
  n2 = right - mid;
  L = (int *)malloc(sizeof(int)*(n1+1));
  R = (int *)malloc(sizeof(int)*(n2+1));
  for(i = 0;i < n1;i++){
    L[i] = A[left + i];
  }
  for(i = 0;i < n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      count++;
    }
    else{
      A[k] = R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(int A[], int left, int right)
{
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main()
{
  int n,i;
  scanf("%d",&n);
  for(i = 0;i < n;i++)
    scanf("%d",&S[i]);
  mergeSort(S,0,n);
  for(i = 0;i < n;i++){
    printf("%d",S[i]);
    if(i < n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

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

long long N,ans;
string S;
string S1,S2;
vector <string> V1,V2;

string convstr(string str,long long key){
  string f="";string l="";
  for (long long i=0;i<N;i++){
    if ((key&(1<<i))!=0){
      f=f+str[i];
    } else l=str[i]+l;
  }
  return f+" "+l;
}

int main(){
  cin >> N >> S;
  S1="";S2="";
  for (long long i=0;i<N;i++){
    S1=S1+S[i];
    S2=S2+S[2*N-1-i];
  }

  for (long long i=0;i<(1<<N);i++){
    V1.push_back(convstr(S1,i));
  }
  sort(&V1[0],&V1[1<<N]);
  /*
  for (int i=0;i<V1.size();i++){
    cout << V1[i] << endl;
  }
  */
  for (long long i=0;i<(1<<N);i++){
    V2.push_back(convstr(S2,i));
  }
  sort(&V2[0],&V2[1<<N]);
  /*
  for (int i=0;i<V2.size();i++){
    cout << V2[i] << endl;
  }
  */
  long long idx1=0,idx2=0;
  long long mul1=0,mul2=0;
  ans=0;
  while(idx1<(1<<N) && idx2<(1<<N)){
    if (V1[idx1]>V2[idx2]){
      idx2++;continue;
    }
    if (V1[idx1]<V2[idx2]){
      idx1++;continue;
    }


    mul1=0;mul2=0;
    while(idx1+mul1<(1<<N) && V1[idx1]==V1[idx1+mul1]){
      mul1++;
    }
    while(idx2+mul2<(1<<N) && V2[idx2]==V2[idx2+mul2]){
      mul2++;
    }
    ans+=mul1*mul2;
    //cout << V1[idx1] << " " << V2[idx2]<<" " << mul1*mul2 <<endl;
    idx1+=mul1;idx2+=mul2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 17644
n = int(input())
s = input()
e = s[1:].count("E")
w = 0
ans = e
for i in range(1,n):
    if s[i-1] == "W":
        w += 1
    if s[i] == "E":
        e -= 1
    ans = min(ans,w+e)
    
print(ans)

Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

bool vis[50][50][50][50];

void move(int& x, int& y, int dir, vector<string>& a) {
	int H = a.size(), W = a[0].length();
	x += dx[dir]; y += dy[dir];
	if (x >= 0 && x < W && y >= 0 && y < H && a[y][x] != '#')
		return;
	x -= dx[dir]; y -= dy[dir];
}

int main() {
	for (;;) {
		int W, H; cin >> W >> H;
		if (W == 0 && H == 0) break;
		vector<string> al(H), ar(H);
		int xsl, ysl, xtl, ytl, xsr, ysr, xtr, ytr;
		for (int y = 0; y < H; y++) {
			cin >> al[y] >> ar[y];
			reverse(ar[y].begin(), ar[y].end());
			for (int x = 0; x < W; x++) {
				if (al[y][x] == 'L') {
					xsl = x; ysl = y;
				}
				if (al[y][x] == '%') {
					xtl = x; ytl = y;
				}
				if (ar[y][x] == 'R') {
					xsr = x; ysr = y;
				}
				if (ar[y][x] == '%') {
					xtr = x; ytr = y;
				}
			}
		}
		for (int yl = 0; yl < H; yl++)
			for (int xl = 0; xl < W; xl++)
				for (int yr = 0; yr < H; yr++)
					for (int xr = 0; xr < W; xr++)
						vis[xl][yl][xr][yr] = false;
		vis[xsl][ysl][xsr][ysr] = true;
		stack<int> XL, YL, XR, YR;
		XL.push(xsl); YL.push(ysl); XR.push(xsr); YR.push(ysr);
		while (!XL.empty()) {
			int xl = XL.top(); XL.pop();
			int yl = YL.top(); YL.pop();
			int xr = XR.top(); XR.pop();
			int yr = YR.top(); YR.pop();
			for (int dir = 0; dir < 4; dir++) {
				int _xl = xl, _yl = yl, _xr = xr, _yr = yr;
				move(_xl, _yl, dir, al);
				move(_xr, _yr, dir, ar);
				if (vis[_xl][_yl][_xr][_yr]) continue;
				vis[_xl][_yl][_xr][_yr] = true;
				if ((_xl == xtl && _yl == ytl) || (_xr == xtr && _yr == ytr)) continue;
				XL.push(_xl); YL.push(_yl); XR.push(_xr); YR.push(_yr);
			}
		}
		cout << (vis[xtl][ytl][xtr][ytr] ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 25432
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[200010],b[200010],ans=0;
    cin>>n;
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    reverse(a,a+n);
    reverse(b,b+n);
    rep(i,n){
        a[i]+=ans;
        if(a[i]%b[i]!=0){
            ans+=(b[i]-a[i]%b[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3072
#d=["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"]
#import numpy as np
#n=int(input())
#li=input().split()
#import fractions
#n=int(input())
#S=input()
#import math

lis=list(map(int,input().split()))
lr=[1,lis[0]]
for i in range(lis[1]):
    lri=list(map(int,input().split()))
    if lr[0]<lri[0]:
        lr[0]=lri[0]
    if lr[1]>lri[1]:
        lr[1]=lri[1]

ans=lr[1]-lr[0]+1
if ans>=1:
    print(ans)
else:
    print(0)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	int H, W; std::cin >> H >> W;
	std::vector<std::vector<char>> A(H, std::vector<char>(W));
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
			std::cin >> A[i][j];

	for (int i = 0; i < W + 2; ++i)
		std::cout << '#';
	std::cout << std::endl;

	for (int i = 0; i < H; ++i) {
		std::cout << '#';
		for (int j = 0; j < W; ++j) {
			std::cout << A[i][j];
		}
		std::cout << '#' << std::endl;
	}

	for (int i = 0; i < W + 2; ++i)
		std::cout << '#';
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (T.at(i) == 'r') {
      ans += P;
    } else if (T.at(i) == 's') {
      ans += R;
    } else if (T.at(i) == 'p') {
      ans += S;
    }
  }

  for (int i = 0; i < N; i++) {
    if (i - K < 0) continue;
    if (T.at(i) == 'r' && T.at(i - K) == 'r') {
      ans -= P;
      T.at(i) = '*';
    } else if (T.at(i) == 's' && T.at(i - K) == 's') {
      ans -= R;
      T.at(i) = '*';
    } else if (T.at(i) == 'p' && T.at(i - K) == 'p') {
      ans -= S;
      T.at(i) = '*';
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {
	public static void main(String[] args){
		int i;
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] tmp = new char[50];
		for ( i = 0; i < str.length(); i++ )
			tmp[i] = str.charAt(i);
		for ( i=i-1; i >= 0; i-- )
			System.out.print(tmp[i]);
		System.out.println("");
	}
}

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

using namespace std;
typedef long long ll;
const int N = 200'010;
int n, a[N], b[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]);
    sort(a, a + n);
    sort(b, b + n);
    int ans = 0;
    if (n % 2 == 0) {
        ans = (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1;
    } else {
        ans = b[n / 2] - a[n / 2] + 1;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
//
int main(){
    int n;
    cin >> n;
    map<ll, ll> l;
    map<ll, ll> r;
    for(int i = 1; i <= n; i++){
        int h;
        cin >> h;
        auto itrl = l.find(h + i);
        auto itrr = r.find(i - h);
        if(itrl == l.end()){
            l[i + h] = 1;
        }else{
            l[itrl -> first] = itrl->second + 1;
        }
        if(itrr == r.end()){
            r[i - h] = 1;
        }else{
            r[itrr->first] = itrr->second + 1;
        }
    }
    ll ans = 0;
    for(const auto itrl : l){
        auto itrr = r.find(itrl.first);
        if(itrr == r.end()) continue;
        else{
            ans += itrl.second * itrr -> second;
        }
    }
    cout << ans;
}

Measured memory_bytes: 26776
#include "bits/stdc++.h"
using namespace std;
int a[100][100];
int main()
{
	int h, w, n, x = 0, y = 0;
	scanf("%d%d%d", &h, &w, &n);
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		for(int k = 0; k < j; ++k)
		{
			a[y][x] = i + 1;
			if(y % 2)
			{
				if(x == 0)
				{
					++y;
				}
				else
				{
					--x;
				}
			}
			else
			{
				if(x == w - 1)
				{
					++y;
				}
				else
				{
					++x;
				}
			}
		}
	}
	for(int i = 0; i < h; ++i)
	{
		for(int j = 0; j < w; ++j)
		{
			printf("%d ", a[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 384
#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' };

//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);
//}

//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

int main(void) {
	LLI N,M,C,cnt = 0;
	cin >> N >> M >> C;
	vector<LLI>vec(M);
	vector<vector<LLI>>cords(N);
	for (int i = 0; i < M;i++) {
		cin >> vec[i];
	}
	LLI A = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M;j++) {
			cin >> A;
			cords[i].push_back(A);
		}
	}
	for (int i = 0; i < N;i++) {
		A = 0;
		for (int j = 0; j < M;j++) {
			A += vec[j] * cords[i][j];
		}
		A += C;
		if (A > 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if all(b[k] == a[i + k][j:j + m] for k in range(m)):
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 9080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b;
    cin >> a >> b;

    if(a + b >= 10){
        p("error");
        return 0;
    }
    p(a + b);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
int INF=1e+9+1;
int main(){
	int N,Y;
	scan(N);scan(Y);
	Y/=1000;
	int satu[3]={10,5,1};
	int maisu[3]={-1};
	int flag=1;
	if(N*10<Y||N>Y) prin("-1 -1 -1");
	else{
		/*int max10=max((Y-N)/9+1,N);
		int min10=min(Y/5-N,0);
		if(max10*10+(N-max10)==Y){
			maisu[0]=max10; maisu[1]=0; maisu[2]=N-max10;
		}
		else if(min10*10+(N-min10)*5==Y){
			maisu[0]=min10; maisu[1]=N-min10; maisu[2]=0;
		}
		else{*/
			for(int num10=N;num10>=0;num10--){
				for(int num5=N-num10;num5>=0;num5--){
					int num1=N-num10-num5;
					if(num10*10+num5*5+num1==Y){
						maisu[0]=num10; maisu[1]=num5; maisu[2]=num1;
						flag=0;
						break;
					}
				}
				if(flag==0) break;
			}
		//}
		if(maisu[0]==-1) prin("-1 -1 -1");
		else printf("%d %d %d\n",maisu[0],maisu[1],maisu[2]);
	}

	return 0;
}


Measured memory_bytes: 256
/*input
1 
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=6005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll C[maxn][maxn];

int main()
{
	IOS;
	ll n,x;
	cin>>n>>x;

	REP(i,maxn-1) for(int j=0;j<=i;j++){
		if(j==0||j==i) C[i][j]=1;
		else{
			C[i][j]=C[i-1][j]+C[i-1][j-1];
			if(C[i][j]>=MOD) C[i][j]-=MOD;
		}
	}
	ll ans=0;
	for(int len=0;len<=n;len++){
		ll sum=0;

		for(int a=1;a+a<=len;a++){
			if(x-1-len>=0&&len-a-a>=x-1-len){
				sum+=C[len-a-a][x-1-len];
				if(sum>=MOD) sum-=MOD;
			}
		}
		for(int t=len;t<x;t++){
			sum+=C[len][t-len];
			if(sum>=MOD) sum-=MOD;
		}
		if(x%2==1&&2*len>=x&&len>=x) sum++;
		// cout<<len<<' '<<sum<<' '<<C[n][n-len]<<'\n';
		ans+=sum*C[n][n-len]%MOD;
		if(ans>=MOD) ans-=MOD;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 280064
#include <bits/stdc++.h>
using namespace std;
int main(){
string t,s;
  cin>>t>>s;
  int a=t.size();
  int b=s.size();
  int k=1000;
  for(int i=0;i<=(a-b);i++){
    int c=0;
    for(int h=0;h<b;h++){
      
      if(t.at(i+h)!=s.at(h)){
        c++;}}
    k=min(c,k);
  }
  cout<<k<<endl;}


Measured memory_bytes: 3584
n,k=map(int, input().split())
w=[0]*n
for i in range(n):
    w[i]=int(input())

def delivable(m):
    loading=0
    track_num=1
    for i in range(n):
        if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
    if track_num <= k:
        return True
    else:
        return False


r=1000000000
l=min(w)-1
while r-l > 1:
    m=(r+l)//2
    if delivable(m):
        r=m
    else:
        l=m

print(r)



Measured memory_bytes: 9412
import itertools

N = int(input())
lis = [x+1 for x in range(N)]
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
i = 1

for p in itertools.permutations(lis):
  for j in range(N):
    if p[j] != P[j]:
      break
    j += 1
  if j == N:
    pp = i
  for j in range(N):
    if p[j] != Q[j]:
      break
    j += 1
  if j == N:
    pq = i
  i += 1

print(abs(pp-pq))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  ll p, q, r;
  cin >> p >> q >> r;
  vector<ll> arrive = {p, q, r};
  sort(arrive.begin(), arrive.end());
  cout << (arrive[0] + arrive[1]) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-7

#define INF 1e16

/*
 */

int const MaxSize = 1e5 + 10;
int cnt[MaxSize];

//0 if c, 1 if j
int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	int N, M;
	cin >> N >> M;
	LP(i, 0, M)
	{
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}

	LPE(i, 1, N)
	{
		if (cnt[i] % 2) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


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


int n;
long long  dp[3100][3100];
long long  a[3100];
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  cin>>n;
 for(int i=1;i<=n;i++)
 {
 	cin>>a[i];
 }
 
 for(int r=1;r<=n;r++)
 {
    for(int l=r;l>=1;l--){
      dp[r][l]=max(a[l]-dp[r][l+1],a[r]-dp[r-1][l]);
    }
 }
   
  
 
  cout<<dp[n][1]<<endl;
 
}

Measured memory_bytes: 72448
n,k = map(int,input().split())
x = list(map(int,input().split()))
m = 1000000000000000
for i in range(n-k+1):
    m = min(m,abs(x[i]) + x[i+k-1]-x[i], abs(x[i+k-1]) + x[i+k-1]-x[i])
print(m)

Measured memory_bytes: 14224
def main():
    N, K = map(int, input().split())

    ans = 0
    for n in range(1, N+1):
        cnt = 0
        x = n
        while x < K:
            cnt += 1
            x *= 2
        ans += pow(2, -cnt) / N
        # print(n, cnt)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int mod=1e9+7; 
int inv[200005],finv[200005],f[200005];
void C(){
	f[0]=1;finv[0]=1;finv[1]=1;f[1]=1;inv[1]=1;
	FOR(i,2,200000){
		f[i]=f[i-1]*i%mod;
		inv[i]=mod-inv[mod%i]*(mod/i)%mod;
		finv[i]=finv[i-1]*inv[i]%mod; 
	}
}
signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	C();
	int sum,ans=0,t=n*m;
	FOR(i,1,n){
		FOR(j,1,m){
			sum=0;
			int t1=i-1,t2=j-1;
			sum=sum+t1*(t1+1)/2%mod*m+t2*(t2+1)/2%mod*n;sum=sum%mod;
			t1=n-t1-1;t2=m-t2-1;
			sum=sum+t1*(t1+1)/2%mod*m+t2*(t2+1)/2%mod*n;sum=sum%mod;
			sum=sum*inv[t-1]%mod*f[t-1]%mod*finv[t-k]%mod*finv[k-2]%mod;
			ans=(ans+sum)%mod;
		}
	} 
	cout<<ans*inv[2]%mod;
	RE 0;
}




Measured memory_bytes: 4992