akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define Nmax 200005
#define OFF 100001
using namespace std;

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    if (a%2==0 || b%2==0 || c%2==0) cout << 0;
    else{
        if (a > b) swap(a,b);
        if (a > c) swap(a,c);
        if (b > c) swap(b,c);
        cout << 1LL * a * b << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, c;
    int ans = 0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    for(int i = a; i <= b; i++) {
        if(c % i == 0) {
            ans++;
        }
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<stack> 
const int MAXN = 105;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
int a[MAXN][MAXN];
int color[MAXN];
int d[MAXN];
int f[MAXN];
int nt[MAXN];
int n, tt = 0;
using namespace std;

int next(int u)
{
	for(int v = nt[u]; v < n; v++)
	{
		nt[u] = v + 1;
		if(a[u][v])
			return v;		
	}
	return -1;
}

void dfs(int r)
{
	for(int i = 0; i < n; i++)
		nt[i] = 0;
		
	stack<int> S;
	S.push(r);
	color[r] = GRAY;
	d[r] = ++tt;
	
	while(!S.empty())
	{
		int u = S.top();
		int v = next(u);
		if(v != -1)
		{
			if(color[v] == WHITE)
			{
				color[v] = GRAY;
				d[v] = ++tt;
				S.push(v);
			}
		}
		else
		{
			S.pop();
			color[u] = BLACK;
			f[u] = ++tt;
		}
	}	
}

void dfs_init()
{
	int u;
	for(u = 0; u < n; u++)
	{
		color[u] = WHITE;
		nt[u] = 0;
	}
	tt = 0;
	for(u = 0; u < n; u++)
	{
		if(color[u] == WHITE)
			dfs(u);
	}
	
	for(u = 0; u < n; u++)
	{
		cout << u+1 << " " << d[u] << " " << f[u] << endl;	
	}	
} 

int main ()
{
	int k, u, temp;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> u >> k;
		u--;
		for(int j = 0; j < k; j++)
		{
			cin >> temp;
			temp--;
			a[u][temp] = 1;
		}
	}
	dfs_init();
	return 0;
} 


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

#ifdef LOCAL

template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, class C<A...> c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;
#else
#define debug(...) {}
#endif

const int N = 1e6;
long long infLL = 1e18;
int inf = 1e9;

bool game(vector<int> A) {
	if (A.back() != 2) return false;
	long long a = 2;
	long long b = 2;
	for (int i = A.size() - 1; i >= 0; i --) {
		int g = A[i];
		long long x = (a + g - 1) / g;
		long long y = b / g;
		if (x > y) return false;
		a = x * g;
		b = y * g + g - 1;
	}
	cout << a << " " << b << "\n";
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	int k;
	cin >> k;
	vector<int> A;
	for (int i = 0; i < k; i ++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	if (not (game(A))) {
		cout << "-1\n";
	}
}


Measured memory_bytes: 1144
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back
 
using namespace std;

int main(){

    char n[4];
    cin >> n;

    if(n[0] == '7' || n[1] == '7' || n[2] == '7'){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 3640
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

void warshall_floyd(vector<vector<int>>&v) {
    int N = v.size();
    for (int k = 0; k <N; k++)//経由
        for (int i = 0; i < N; i++)//始点
            for (int j = 0; j < N; j++)//終点
                v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>>c(10, vector<int>(10));

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++)cin >> c[i][j];
    }
    warshall_floyd(c);
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a;
            cin >> a;
            if (a != -1)ans += c[a][1];
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int dx = x2 - x1;
    int dy = y2 - y1;
    cout << x2-dy << ' ' << y2+dx << ' ' << x2-dy-dx << ' ' << y2+dx-dy << '\n';
}

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
ll dp[3333][3333][2];
int main()
{
	ll n,s;
	cin>>n>>s;
	vector<ll>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<=s;j++){
		  dp[i+1][j][0]+=dp[i][j][0];
		  if(!j)dp[i+1][j][0]++;
		  dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1];
		  if(!j)dp[i+1][j][1]++;
		  dp[i+1][j][0]%=mod;
		  dp[i+1][j][1]%=mod;
		  if(j+a[i]<=s){
			  dp[i+1][j+a[i]][0]+=dp[i][j][0];
			  dp[i+1][j+a[i]][1]+=dp[i][j][0];
			  if(!j){
				  dp[i+1][j+a[i]][0]++;
				  dp[i+1][j+a[i]][1]++;
			  }
		  }
		  dp[i+1][j][0]%=mod;
		  dp[i+1][j][1]%=mod;
		}
	}
	cout<<dp[n][s][1]%mod;
}



Measured memory_bytes: 156256
use std::io;

fn main() {
    let mut n=String::new();
    io::stdin().read_line(&mut n).expect("Failed to read line");
    let mut ans=0;
    for i in n.trim().chars(){
        if i=='+'{
            ans+=1;
        }else{
            ans-=1;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    ll i, o, t, j, l, s, z;

    cin >> i >> o >> t >> j >> l >> s >> z;

    if(i >= 1 && j >= 1 && l >= 1){
        cout << max((i / 2) * 2 + o + (j / 2) * 2 + (l / 2) * 2, ((i - 1) / 2) * 2 + o + ((j - 1) / 2) * 2 + ((l - 1) / 2) * 2 + 3) << endl;
    }
    else{
        cout << (i / 2) * 2 + o + (j / 2) * 2 + (l / 2) * 2 << endl;
    }
}

Measured memory_bytes: 256
N, C = map(int, input().split())

x_list = [0, ]
v_list = [0, ]
x_oa = 0
x_2oa = 0
max_a = {0: 0}
max_2a = {0: 0}

tmp_v = 0

for i in range(N):
    x, v = map(int, input().split())

    tmp_v += v

    x_list.append(x)
    v_list.append(v)
    x_oa = max(tmp_v - x, x_oa)
    x_2oa = max(tmp_v - 2 * x, x_2oa)
    max_a[i + 1] = x_oa
    max_2a[i + 1] = x_2oa

x_list.append(C)
v_list.append(0)

tmp_v = 0
ans = 0
for i in reversed(range(1, N + 2)):

    x = x_list[i]
    v = v_list[i]
    tmp_v += v
    # print(x, v, i)

    tmp_oa = tmp_v - 2 * (C - x) + max_a[i - 1]
    tmp_2oa = tmp_v - C + x + max_2a[i - 1]
    ans = max(ans, tmp_oa, tmp_2oa)

print(ans)

Measured memory_bytes: 36880
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a[n];
    rep(i,n)a[i] = s[i] - '0';
    int k;
    cin >> k;

    int dp[n][4];
    int cnt = 0;

    rep(i,n)rep(j,4)dp[i][j] = 0;

    rep(i,n){
        if(i == 0){
            dp[i][1] = a[i] - 1;
            cnt = 1;
        }else{
            dp[i][1] = dp[i-1][1] + 9;
            dp[i][2] = dp[i-1][2] + dp[i-1][1] * 9;
            dp[i][3] = dp[i-1][3] + dp[i-1][2] * 9;
            if(a[i] > 0 && cnt <= 3){
                dp[i][cnt]++;
                if(cnt <= 2){
                    dp[i][cnt+1] += a[i] - 1;
                }
                cnt++;
            }
        }
    }

    int ans = dp[n-1][k];
    if(cnt == k)ans++;

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long          ll;
typedef unsigned long long ull;
using namespace std;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
};

int main() {
    Setup();

    string S;
    cin >> S;
    const int   len = S.size();
    stack<char> st;
    int ans = 0;
    for (int i = 0; i < len; i++) {
        char c = S[i];
        if (st.size() < 1) {
            st.push(c);
            continue;
        }
        if (st.top() != c) {
            st.pop();
            ans += 2;
        } else {
            st.push(c);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
string a[1000];
bool tmp(string s1,string s2)
{
//    return s1>s2;
     return s2 > s1 ;
}
int main()
{
   int n,l;
   while(cin>>n>>l)
   {
       for(int i=1;i<=n;i++)
        cin>>a[i];
       sort(a+1,a+1+n,tmp);
       for(int i=1;i<=n;i++)
        cout<<a[i];
       cout<<endl;
   }

}



Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<iomanip>

using namespace std;

typedef complex<double> P;
typedef vector<P> G;
#define EPS 1e-9
#define shosu(x) fixed<<setprecision(x)

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L(){;}
};
struct C{
  P c;double r;
  C(const P &c,double r):c(c),r(r){}
};

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real() && a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {//3点の関係性
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

P projection(const L &l, const P &p){//pの直線l上の射影の点
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

P reflection(const L &l, const P &p){//点pの直線lに関して対称な点
  return p+2.0*(projection(l,p)-p);
}

bool isOrthogonal(const L &l, const L &m){//2直線の直交判定
  return fabs(dot(l[1]-l[0], m[1]-m[0])) < EPS;
}

bool isParallel(const L &l, const L &m){//2直線の平行判定
  return fabs(cross(l[1]-l[0],m[1]-m[0])) < EPS;
}

bool intersectLL(const L &l, const L &m){//2直線の交差判定
  return !isParallel(l,m);
}

bool intersectSS(const L &s, const L &t) { //2線分の交差判定(完全に交差してないとだめ)
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

bool intersectSP(const L &s, const P &p) { //直線と点の交差判定
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

P crosspointSS(const L &a, const L &b){ //2線分の交点
double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
return b[0]+(b[1]-b[0])*t1/(t1+t2);
}

double distanceSP(const L &s, const P &p) {//直線と点との距離
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

double distanceSS(const L &s, const L &t) {//2線分の距離
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

double area(const G &g){ //多角形の面積
    double S =0;
    for(int i =0;i <g.size();i++){
        S +=(cross(g[i],g[(i+1)%g.size()]));
    }
    return abs(S/2.0);
}


P inP(){
  double x,y;
  cin >> x >> y;
  P p(x,y);
  return p;
}

L inL(){
  P p1=inP();
  P p2=inP();
  L l(p1,p2);
  return l;
}

int main(){

  int n;
  cin>>n;
  G g;
  for(int i=0;i<n;i++){
    P p = inP();
    g.push_back(p);
  }
  cout << shosu(1) << area(g) << endl;


}



Measured memory_bytes: 3260
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val l = cin.nextInt()
    val min = l
    val max = l + n - 1

    var ans = 0
    for (i in 0..n-1) {
        ans += l + i
    }
    if (min > 0) {
        ans -= min
    } else if (0 > max) {
        ans -= max
    }
    println(ans)
}

Measured memory_bytes: 31392
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; string s; cin >> n >> s;
    if(n%2 != 0){
        cout << "No" << endl;
        return 0;
    }

    if(s.substr(0, n/2) == s.substr(n/2)){
        cout << "Yes" << endl;
        return 0;
    }

    else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3640
//https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;//sft cmd .
}

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

using namespace std;

vector<bool> visited;
vector<long long int> X;
vector<long long int> P;
vector<vector<int>> G;

void dfs(int& v){
  visited[v] = true;
  for (int i = 0; i < G[v].size(); i++){
    if(!visited[G[v][i]]){
        P[G[v][i]]=X[G[v][i]]+P[v];
        dfs(G[v][i]);
    }
  }
}

int main(){

    int n,q;
    cin >> n >> q;

    visited = vector<bool>(n, 0);

    G=vector<vector<int>>(n,vector<int>(0));
    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);
    }


    X.resize(n);
    P.resize(n);
    fill(X.begin(),X.end(),0);
    fill(P.begin(),P.end(),0);

    for(int i=0;i<q;i++){
      long long int p,x;
      cin >> p >> x;
      X[p-1]+=x;
    }

    int a=0;
    P[0]=X[0];
    dfs(a);

    for(int i=0;i<n;i++){
      cout << P[i] <<" " ;
    }




    

}



Measured memory_bytes: 22784
#include<stdio.h>
#include<stdbool.h>
int d[] = {[0 ... 1<<17] -1};
int find(int x){
	if(d[x] < 0) return x;
	return d[x] = find(d[x]);
}
bool unite(int x, int y){
	x = find(x); y = find(y);
	if(x == y)return false;
	if(d[x] > d[y]){
		int tmp = x;
		x = y;
		y = tmp;
	}
	d[x] += d[y];
	d[y] = x;
	return true;
}
bool same(int x, int y){return find(x) == find(y);}
int size(int x){return -d[find(x)];}
int N, M, A[1<<17], B[1<<17];
long ans[1<<17];
int main(){
	scanf("%d%d", &N, &M);
	for(int i=0; i<M; i++)scanf("%d%d", A+i, B+i);
	ans[M] = (long)N * (N-1) / 2;
	for(int i=M-1; i; i--){
		long t = 0;
		if(!same(A[i], B[i])){
			t = (long)size(A[i]) * size(B[i]);
			unite(A[i], B[i]);
		}
		ans[i] = ans[i+1] - t;
	}
	for(int i=1; i<=M; i++)printf("%ld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
int main() {
	int n, m, x, rec;
	cin >> n >> m >> x;
	int cna = 0; int cnb = 0;
	for (int i = 0; i < m; i++) {
		cin >> rec;
		if (rec < x)cna++;
		else cnb++;
	}
	cout << min(cna, cnb) << endl;
	return 0;
}

Measured memory_bytes: 3568
/*
  author : Anand
*/

#include <bits/stdc++.h>

using namespace std;

#define PI 3.1415926535897932384626
#define int long long
#define ll long long

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

// #define LOCAL

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int INF = 1e18 + 5;
const int MOD = 1000000007;


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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes\n";
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No\n";
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
const int N=1005;
const int M=5005;
const int inf=N*M;
using namespace std;
vector<int>son[N];
int f[N],flag,n,w[N],g[2][M];
void dp(int now)
{
	if(son[now].size()==0)
	{
		f[now]=0;return;
	}
	int sz=son[now].size();
	for(int i=0;i<sz;++i) dp(son[now][i]);
	
	for(int i=0;i<=5000;++i) g[0][i]=inf;
	g[0][0]=0;
	int k=0;
	for(int i=0;i<sz;++i)
	{
		k=k^1;
		int too=son[now][i];
		int x=w[too];int y=f[too];
		for(int j=0;j<=5000;++j) g[k][j]=inf;
		for(int j=x;j<=5000;++j) g[k][j]=min(g[k][j],g[k^1][j-x]+y);
		for(int j=y;j<=5000;++j) g[k][j]=min(g[k][j],g[k^1][j-y]+x);
	}
	
	f[now]=inf;
	for(int i=0;i<=w[now];++i) f[now]=min(f[now],g[k][i]);
	
	if(f[now]==inf)
	   flag=-1;
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i)
	{
		int x;scanf("%d",&x);
		son[x].push_back(i);
	}
	for(int i=1;i<=n;++i) scanf("%d",&w[i]);
	dp(1);
	if(flag==-1) printf("IMPOSSIBLE\n");
    else printf("POSSIBLE\n");
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int i;
char t;
string a,b,c;
int main()
{
  cin>>a>>b>>c;
  t=a[0];
  a=a.substr(1,a.size()-1);
  for(;i<301;i++){
    if(t=='a'){
      if(a.size()==0)return cout<<'A', 0;
      t=a[0];
      a=a.substr(1,a.size()-1);
    }else if(t=='b'){
      if(b.size()==0)return cout<<'B', 0;
      t=b[0];
      b=b.substr(1,b.size()-1);
    }else{
      if(c.size()==0)return cout<<'C', 0;
      t=c[0];
      c=c.substr(1,c.size()-1);
    }
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab = sorted(ab, key=lambda x: x[1])

ans = 0
x = 0
for i in range(m):
    if ab[i][0] <= x:
        continue
    else:
        x = ab[i][1] - 1
        ans += 1

print(ans)

Measured memory_bytes: 29852
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 998244353  ;
const int N = 1e5+2;


void TEST_CASES(int cas)
{
    int x,y;
    cin>>x>>y;
    if(y>x*4 || y<x*2 || y%2)
        printf("No\n");
    else
        printf("Yes\n");


}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3580
<?php
$W = fgets(STDIN);
$W = trim($W);

$count = 0;
while (false !== ($line = fgets(STDIN))) {
    $line = trim($line);
    if ('END_OF_TEXT' === $line) {
        break;
    }

    $words = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
    $count += array_reduce($words, function ($carry, $item) use ($W) { return (strtolower($W) === strtolower($item)) ? $carry+1 : $carry; }, 0);
}

echo "$count\n";

Measured memory_bytes: 6712
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 2019;
    static void Main()
    {
        string s = rstr();
        int n = s.Length;
        long[] t = new long[2019];
        t[0]++;
        int ts = 0;
        long ct = 0;
        int dig = 1;
        for (int j = 0; j < n; j ++)
        {            
            ts = (ts + (s[n - 1 - j] - '0') * dig) % mod;
            t[ts]++;
            dig = dig * 10 % mod;
        }
        for (int i = 0; i < 2019; i++)
        {
            ct += t[i] * (t[i] - 1) / 2;
        }
        Write(ct);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 26468
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 
	int arr[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			arr[i][j]=Int;
		}
	}
	int dp[3][3];
	memset(dp,0,sizeof(dp));
	int n=Int;
	int pk[103];
	memset(pk,0,sizeof(pk));
	For(n) {
		int x=Int;
		pk[x]=1;
	}

	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(pk[arr[i][j]]==1){
				dp[i][j]=1;
			}
		}
	}
	int a1=dp[0][0]+dp[0][1]+dp[0][2];
	int a2=dp[1][0]+dp[1][1]+dp[1][2];
	int a3=dp[2][0]+dp[2][1]+dp[2][2];

	int a4=dp[0][0]+dp[1][0]+dp[2][0];
	int a5=dp[0][1]+dp[1][1]+dp[2][1];
	int a6=dp[0][2]+dp[1][2]+dp[2][2];
	int a7=dp[0][0]+dp[1][1]+dp[2][2];
	int a8=dp[0][2]+dp[1][1]+dp[2][0];

	if(a1==3 || a2==3 || a3==3 || a4==3 || a5==3|| a6==3 || a7==3 || a8==3){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	


 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
  ll k;
  cin>>k;
  cout<<a[k-1];
}

Measured memory_bytes: 256
a,b,c,d,e,f = map(int, input().split())

ma_per = -1
ma_w = -1
ma_s = -1

for aa in range(31):
    for bb in range(31):
        for cc in range(101):
            for dd in range(101):
                w = 100 * aa * a + 100 * bb * b
                s = cc * c + dd * d
                if (w + s) > f:
                    break
                if s > (w * e / 100):
                    break
                if w+s == 0:
                    break
                per = 100 * s / (w + s)
                if per > ma_per:
                    ma_per = per
                    ma_w = w
                    ma_s = s

print("{0} {1}".format(ma_w + ma_s, ma_s))


Measured memory_bytes: 42732
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    
    vector<string> str(3);
    
    cin>>str[0]>>str[1]>>str[2];

    cout<<str[0][0]<<str[1][0]<<str[2][0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}


const int N = 1e5 + 5, MX = 1e9;
int a[N];
int main(){
    int n = D();
    int m = D();
    int ans = abs(round(ceil((1.0 * n) / m)) - n / m);
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

n = IN()
a = 0

for i in range(1,100):
  a += 1
  if n <= 1000*a:
    print(1000*a - n)
    exit()

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef map<ll, vector<ll>> mll;
typedef unordered_map<ll, vector<ll>> ull;

#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()
#define rep(i, a, b) for(ll i = a; i < b ; i++)
#define repr(i, a, b) for(ll i = a; i >= b ; --i)
#define distinct(v) v.erase(unique(v.begin(), v.end()), v.end());
#define delt(v, x) (v).erase(std::remove((v).begin(), (v).end(), x), (v).end())
#define MAX 200010
#define INF 1000000007
const ll MAXN = 1e5 + 5;

void dfs(int u, int par, vector<bool> &v, unordered_map<int, vector<int>> g) {
    if (!v[u]) {
        v[u] = true;
        for (auto i:g[u]) {
            if (!v[i] && i != par)dfs(i, u, v, g);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    string s, t;
    cin >> s;
    char curr = '.';
    for (auto i:s) {
        if (i != curr)t += i, curr = i;
    }
    cout << t.length() << endl;
    return 0;
}




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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  while (cin >> n, n) {

    vector<int> dp(n+5);
    int maxv = -INF;
    reps(i, 1, n) {
      int a;
      cin >> a;
      dp[i] = max(dp[i-1] + a, a);
      chmax(maxv, dp[i]);
    }

    cout << maxv << "\n";
  }

  return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<vector>

using namespace std;

#define ll long long

int n;
int a[301];
int S;
ll dp[310][100000];
ll dp2[310][100000];

#define MOD (998244353ll)

int main(){
	cin >> n;
	// n = 300;
	S = 0;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		// a[i] = 200;
		S += a[i];
	}
	ll ans = 1;
	for(int i = 0;i < n;i++){
		ans *= 3;
		ans%=MOD;
	}

	// cout << ans << endl;

	ll ans2 = 0;
	ll ans3 = 0;

	fill_n(*dp, 310*100000, 0);
	fill_n(*dp2, 310*100000, 0);
	for(int d = n; d!=-1; d--){
		for(int sum = 0; sum < 90001; sum++){
			int border = S/2;
			if(S%2==1)border++;
			if(d == n && sum >= border){
				dp[d][sum] = 1;
			}else if(d == n){
				dp[d][sum] = 0;
			}else{
				dp[d][sum] += dp[d+1][sum+a[d]];//えらぶ場合
				dp[d][sum] += dp[d+1][sum]*2;//選ばない場合
			}
			if(d == n && (S%2==0 && sum == S/2)){
				dp2[d][sum] = 1;
			}else if(d == n){
				dp2[d][sum] = 0;
			}else{
				dp2[d][sum] += dp2[d+1][sum+a[d]];//えらぶ場合
				dp2[d][sum] += dp2[d+1][sum];//選ばない場合
			}
			dp[d][sum] %= MOD;
			dp2[d][sum] %= MOD;
		}
	}
	ans2 = 3 * dp[0][0];
	ans3 = 3 * dp2[0][0];

	ll fin = (ans - ans2 + ans3 + MOD*20)%MOD;
	cout << fin << endl;
}

Measured memory_bytes: 485116
#include <iostream>

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

    int A, B;
    std::cin >> A >> B;

    int n=0;
    while(n*A-n+1<B){
        ++n;
    }

    std::cout << n;

    return 0;
}


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 50

int N;
long long K;

typedef vector<long long> vl;
typedef vector<vl> vvl;

vvl a;
vvl tmp1;
vvl tmp2;
vvl ans1;

void init_mat( vvl &mat )
{
    for(int i = 0; i < mat.size(); i++) {
        for(int j = 0; j < mat.size(); j++) {
            mat[i][j] = 0;
        }
    }
}

void init_id_mat( vvl &mat )
{
    init_mat( mat );
    for(int i = 0; i < mat.size(); i++) {
        mat[i][i] = 1;
    }
}

int get_digits( long long n )
{
    int digits = 0;
    for( int i = 0; i < sizeof(long long) * 8; i++ ) {
        if(n & 1) {
            digits = i + 1;
        }
        n /= 2;
    }
    return digits;
}

void mul_mat(vvl &a, vvl &b, vvl &res)
{
    init_mat( res );
    for( int i = 0; i < a.size(); i++ ) {
        for( int j = 0; j < a.size(); j++ ) {
            for( int k = 0; k < a.size(); k++ ) {
                res[i][j] = (res[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
            }
        }
    }
}

void copy_mat( vvl &a, vvl &b )
{
    for( int i = 0; i < a.size(); i++ ) {
        for( int j = 0; j < a.size(); j++ ) {
            b[i][j] = a[i][j];
        }
    }
}

void powerm( vvl &input, long long k, vvl &res )
{
	int sz = input.size();
	tmp1.assign( sz, vl( sz, 0LL ));
	tmp2.assign( sz, vl( sz, 0LL ));
    init_id_mat( res );

    copy_mat( input, tmp1 );

    while( k ) {
        if( k & 1 ) {
            mul_mat( res, tmp1, tmp2 );
            copy_mat( tmp2, res );
        }
		mul_mat( tmp1, tmp1, tmp2 );
		copy_mat( tmp2, tmp1 );
        k /= 2;
    }
}

int main() {
	cin >> N >> K;
	a.assign( N, vl( N, 0LL ) );
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			cin >> a[i][j];
		}
	}

	ans1.assign( N, vl( N, 0LL ) );
	powerm( a, K, ans1 );

	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			ans = (ans + ans1[i][j]) % MOD;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){
if(u!=NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      //Node t = treeSearch(root, x);
      //if ( t != NIL ) printf("yes\n");
      //else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}



Measured memory_bytes: 25296
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    st = [LI() for _ in range(n)]
    # 開始時間が大丈夫で、終了時間の早いものから入れていく
    st.sort(key= lambda x: x[1])

    ans = 0
    end_time = 0
    for i in range(n):
        if st[i][0] > end_time:
            ans += 1
            end_time = st[i][1]

    print(ans)

if __name__ == '__main__':
    resolve()



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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  ll N; cin >> N;
  vector<string> s(N);
  REP(i, N) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());}

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

  vector<ll> flag(N, 0);
  ll ans = 0;
  REP(i, N-1){
    if (s[i] == s[i+1]){
      flag[i+1] = flag[i] + 1;
    }
    ans += flag[i+1];
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 6528
N,K=map(int,input().split())
p=list(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[i]=(p[i]+1)/2

sums=[0]*(N+1)

sums[0]=0
for i in range(1,N+1):
    sums[i]=sums[i-1]+a[i-1]

mx=0
for i in range(N-K+1):
    mx=max(mx,sums[i+K]-sums[i])

print(mx)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
int H[100100];
std::vector<int> G[100100];

bool ok(int v){
    for(int w : G[v]){
        if(H[w] >= H[v]){
            return false;
        }
    }

    return true;
}

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

  std::cin >> N >> M;

  for(int i=1;i<=N;++i){
      std::cin >> H[i];
  }

  for(int i=0;i<M;++i){
      int A, B;
      std::cin >> A >> B;

      G[A].emplace_back(B);
      G[B].emplace_back(A);
  }

  int res = 0;

  for(int i=1;i<=N;++i){
      if(ok(i)){
          res += 1;
          // std::cout << i << std::endl;
      }
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 9136
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long H = sn.nextInt();
        long W = sn.nextInt();
        long area = H * W;
        long result = 0;
        

        if(H == 1 | W == 1){
            result = 1;
        }else{
            if(area % 2 == 0){
                result = area/2;
            }else{
                result = area/2+1;
            }
        }

        

        System.out.println(result);
    }
}

Measured memory_bytes: 21716
N=int(input())
A=list(map(int, input().split()))
D={}
E={}
for i in range(N):
  a=i+A[i]
  b=i-A[i]
  D.setdefault(a,0)
  E.setdefault(b,0)
  D[a]+=1
  E[b]+=1
ans=0
for i in D.keys():
  if i in E.keys():
    ans+=D[i]*E[i]
print(ans)

Measured memory_bytes: 56844
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll n, k; cin >> n >> k;
	vector<int> a(n); rep(i, n)cin >> a[i];
	ll res = 0;
	ll MOD = 1e9 + 7;
	rep(i, n)
	{
		ll cnt = 0;
		rep(j, n)
		{
			if (a[i] > a[j])++cnt;
		}
		ll tmp = (k - 1)*k / 2;
		tmp %= MOD;
		res += cnt * tmp;
		res %= MOD;
	}
	rep(i, n)
	{
		ll cnt = 0;
		for (int j = i + 1; j < n; ++j)
		{
			if (a[i] > a[j])++cnt;
		}
		res += cnt * k;
		res %= MOD;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
// Aizu Vol-2 0286: Computation of Salary
// 2017.8.20

#include <stdio.h>

#define MAX 10000
#define MAX2 500000

typedef struct { int n, nxt, end; } WAK;
typedef struct { int nxt, t, e; } LNK;

WAK wak[MAX+5];
LNK lnk[MAX2+5]; int used;
int b[MAX+5];

int main()
{
	int N, M, L, s, t, e;
	int i, j, k, ans;
	WAK *w;

	scanf("%d%d", &N, &M);
	while (1) {
		scanf("%d%d%d", &s, &t, &e);
		if (!s) break;
		lnk[used].t = t, lnk[used].e = e;
		w = wak + s;
		if (w->n == 0) w->nxt = used;
		else lnk[w->end].nxt = used;
		w->end = used++, w->n++;
	}
	scanf("%d", &L);
	while (L--) {
		for (i = 1; i <= M; i++) scanf("%d", b+i);
		for (w = wak+1, i = 1; i <= N; i++, w++) {
			if (i > 1) putchar(' ');
			if (w->n == 0) { putchar('0'); continue; }
			for (ans = 0, k = w->nxt, j = w->n; j > 0; j--, k = lnk[k].nxt)
				ans += lnk[k].e * b[lnk[k].t];
			printf("%d", ans);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define ar array
#define INF 1e18;
#define ll long long
const int N=2e5+5;
 
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    cout<<(n>=30?"Yes":"No")<<endl;
 
 
    return 0;
}

Measured memory_bytes: 3648
# M = 2のときの答えを求めて、それをM-1倍する
# M = 2のときの答えは、
# 上昇するパターン：N - d個
# 下降するパターン：N - d個
# 従い((N-d) * 2) / (N ** 2)
# ただし、d = 0のときは上昇と下降が同じペアになるため1/2する

N,M,d = map(int,input().split())
print(((((N-d) * 2) / (N ** 2)) * (M - 1)) / (2 if d == 0 else 1))


Measured memory_bytes: 2940
u=str(input())
S=u.replace(' ','z')
A=[]
for i in range(len(S)+1):
    for j in range(len(S)+1):
        if i<=j:
            A.append(S.replace(S[i-1:j],'',1))
if 'keyence' in A:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 66044