akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    int m, k;
    cin >> m >> k;

    if (k >= (1 << m) || k * m == 1)
    {
        cout << -1 << endl;
        return 0;
    }
    if (!m)
    {
        cout << 0 << ' ' << 0 << endl;
        return 0;
    }
    vector<pair<int, int>> a;
    set<int> st;

    rep(i, 1 << m)
    {
        if (st.find(i) == st.end())
        {
            a.push_back(make_pair(i, i ^ k));
            st.insert(i);
            st.insert(i ^ k);
        }
    }

    for (auto x : a)
        cout << x.first << ' ' << x.second << ' ';
    if (k)
        for (auto x : a)
            cout << x.second << ' ' << x.first << ' ';
    cout << endl;
    return 0;
}

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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)

bool cmp(pii a,pii b){
	if(a.F<b.F) return true;
	if(a.F==b.F&&a.S<b.S) return true;
	return false;
}

int main()
{
	int n,m;
	vector<pii> v;
	cin >> n >> m;
	forn(i,m){
		int a,b;
		cin >> a >> b;
		v.PB(MP(a,b));
	}
	sort(all(v),cmp);
	vector<pii> final;
	final.PB(v[0]);
	for(int i=1;i<m;i++){
		int c,d;
		c=max(final[final.size()-1].F,v[i].F);
		d=min(final[final.size()-1].S,v[i].S);
		if(c<d){
			final.pop_back();
			final.PB(MP(c,d));
		}
		else final.PB(v[i]);
	}
	cout << final.size() << endl;
	return 0;

}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> b(100001, -1);
    for(int i = 0; i < n; i++){
        auto p = lower_bound(begin(b), end(b), a[i]);
        if(p == b.end()){
            b.back() = a[i];
        }else{
            *(p - 1) = a[i];
        }
    }
    ans = b.end() - upper_bound(begin(b), end(b), -1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n, d;
int x[11][11];
int ans;
signed main() {
	cin >> n >> d;
	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int dis = 0;
			rep(k, d) {
				dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			rep(k, 1000) {
				if (k * k == dis) {
					ans++;
					break;
				}
				if (dis < k * k) break;
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

const int NS = (int)2e5 + 4;
char s[NS];
int N;

int main(){
    scanf("%s", s + 1); N = strlen(s + 1);
    int ans = 1, last = 1;
    for(int i = 2; i <= N; ++i){
        if(last == 2){
            ++ans; last = 1;
        }
        else{
            if(s[i] != s[i - 1]){
                ++ans; last = 1;
            }
            else{
                if(i < N){
                    ++ans; last = 2; ++i;
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
		string w,t;
		int num = 0;
		cin >> w;
		while(cin >> t){
				if( t == "END_OF_TEXT") break;
				for(int i = 0;i < t.size();i++){
						t[i] = tolower(t[i]);
				}
				if(w == t){
						num++;
				}
		}
		cout << num << endl;
		return 0;
}

Measured memory_bytes: 1192
// Ivan Carvalho
// Problem G - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 10;

vector<int> grafo[MAXN];
int dp[MAXN],vis[MAXN],N,M;

int solve(int v){

	if(vis[v]) return dp[v];

	vis[v] = 1;
	int best = 0;

	for(int u : grafo[v]){
		best = max(best, solve(u) + 1 );
	}

	return dp[v] = best;

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1;i<=M;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
	}

	int best = 0;
	for(int i = 1;i<=N;i++) best = max(best, solve(i) );
	printf("%d\n",best);

	return 0;

}

Measured memory_bytes: 8576
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   int T,H,S;
   while(cin>>T>>H>>S&&(T!=-1||H!=-1||S!=-1))
   {
     int kk=3600*T+60*H+S;
     kk=7200-kk;
     int kk3=kk*3;
     string s;
     int a=kk/3600;
     int c=kk%60;
     int b=(kk-a*3600)/60;
     printf("%02d:%02d:%02d\n",a,b,c);         
     int d=kk3/3600;
     int f=kk3%60;
     int e=(kk3-d*3600)/60;
     printf("%02d:%02d:%02d\n",d,e,f);             
   }
   //while(1);
   return 0; 
 }

 
  

Measured memory_bytes: 3148
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);

let startWithB = 0;
let endWithA = 0;
let startWithBandEndWithA = 0;
let ans = 0;

for (let i = 1; i <= N; i++) {
  const s = input[i];
  let foundA = false;
  let firstIsB = false;
  let lastIsA = false;

  for (let j = 0; j < s.length; j++) {
    if (s[j] === 'A') {
      foundA = true;
      if (j === (s.length - 1)) {
        lastIsA = true;
      }
    } else if (s[j] === 'B') {
      if (foundA) {
        ans++;
        foundA = false;
      } else if (j === 0) {
        firstIsB = true;
      }
    } else {
      foundA = false;
    }
  }

  if (firstIsB && lastIsA) {
    startWithBandEndWithA++;
  } else if (firstIsB) {
    startWithB++;
  } else if (lastIsA) {
    endWithA++;
  }
}

const diff = Math.abs(startWithB - endWithA);

ans += Math.min(startWithB, endWithA);

if (startWithBandEndWithA) {
  ans += startWithBandEndWithA - 1;
  if (startWithB || endWithA) { ans++; }
}

console.log(ans);


Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<vector<int>> A(N);
    rep(n,0,N){
        int a; cin>>a;
        A.at(a-1).push_back(n);
    }

    int maxP=0,minIdx=-1;
    rep(n,0,N){
        if(A.at(n).size()){
            int idx=INT_MAX;
            for(auto i:A.at(n)){
                if(i>minIdx) idx=min(idx,i);
            }
            if(idx==INT_MAX) break;
            minIdx=idx;
            maxP=n+1;
        }else break;
    }

    int ans=N-maxP;
    if(ans==N) ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main(void) {

  int h,w;
  scanf("%d %d", &h, &w);
  char s[h][w+1];
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }
  int move[h][w];
  int current;
  int flag;
  int max_move;
  int answer = 0;
  for (int start_i = 0; start_i < h; start_i++) {
    for (int start_j = 0; start_j < w; start_j++) {
      if (s[start_i][start_j] == '#') {
        continue;
      }
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          move[i][j] = -1;
        }
      }
      move[start_i][start_j] = 0;
      current = 0;
      while (1) {
        flag = 0;
        for (int i = 0; i < h; i++) {
          for (int j = 0; j < w; j++) {
            if (move[i][j] == current) {
              if (i > 0 && s[i-1][j] != '#' && move[i-1][j] == -1) {
                move[i-1][j] = current+1;
                flag = 1;
              }
              if (i < h-1 && s[i+1][j] != '#' && move[i+1][j] == -1) {
                move[i+1][j] = current+1;
                flag = 1;
              }
              if (j > 0 && s[i][j-1] != '#' && move[i][j-1] == -1) {
                move[i][j-1] = current+1;
                flag = 1;
              }
              if (j < w-1 && s[i][j+1] != '#' && move[i][j+1] == -1) {
                move[i][j+1] = current+1;
                flag = 1;
              }
            }
          }
        }
        if (flag == 0) {
          break;
        }
        current++;
      }
      max_move = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (move[i][j] > max_move) {
            max_move = move[i][j];
          }
        }
      }
      if (max_move > answer) {
        answer = max_move;
      }
    }
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 200000 + 5;
int a[N];

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		a[x] = i;
	}
	int sum = 0,t = n+1;
	for(int i = 1; i <= n; i++){
		if(a[i] < t){
			t = a[i];
			sum++;
		}
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    long long a, b, z=3000;
    scanf("%lld %lld",&a,&b);
    if(b-a>=2019)
        z=0;
    else
    {
    for(long long i=a;i<b;i++)
    {
        for(long long j=i+1;j<=b;j++)
        {
            if((i%2019)*(j%2019)%2019<z)
                z=(i%2019)*(j%2019)%2019;
        }
    }
    }
    printf("%lld\n",z);
    return 0;
}


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

int main(){
    int n,m,cnt,ok;
    int i,j;
    char *io;
    scanf("%d",&n);
    while(n){
        scanf("%d",&m);
        getchar();
        cnt = 0;
        io = (char *)calloc(m+2,sizeof(char));
        fgets(io,m+2,stdin);
        for(i=0;i<m-2*n;i++){
            if(io[i] == 'I'){
                ok = 1;
                for(j=1;j<=n;j++){
                    if(io[i+2*j-1]!='O'||io[i+2*j]!='I'){
                        ok = 0;
                        break;
                    }
                }
                if(ok)cnt++;
            }
        }
        free(io);
        printf("%d\n",cnt);
        scanf("%d",&n);
    }
}

Measured memory_bytes: 1796
import java.util.Scanner;

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();
    int x = sc.nextInt();
    int y = sc.nextInt();

    if (a + b < c * 2) {
      System.out.println(a * x + b * y);
    } else {
      if (x < y) {
        System.out.println(Math.min((c * 2) * x + (y - x) * b, c * 2 * y));
      } else {
        System.out.println(Math.min((c * 2) * y + (x - y) * a, c * 2 * x));
      }
    }
  }
}


Measured memory_bytes: 22228
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int N, M, A[1024], sum, nr;

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    for (int i = 0; i < N; ++i) {
        if (A[i] * 4 * M >= sum) {
            ++nr;
        }
    }
    if (nr >= M) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}




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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010, mod = 1e9 + 7;

LL n, t, res;

int main()
{
    cin >> n;

    for(int i = 1; i <= n / i; i++)
        if(n % i == 0)
            t = i;

    t = n / t;
    while(t)
    {
        t /= 10;
        res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,m,i,k,j,ans=0;
  int a[100],count[100]={0};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&a[j]);
      count[a[j]]++;
    }
  }
  for(i=1;i<=m;i++){
    if(count[i]==n) ans++;
  }
  printf("%d",ans);
  return 0;
}

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

using namespace std;

const int N = 3100;
int dp[N][N];
char from[N][N];

int main(){
	string s, t; cin >> s >> t;
	int lens = s.length(), lent = t.length();
	
	for(int i = 1; i <= lens; i++){
		for(int j = 1; j <= lent; j++){
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
				from[i][j] = 'd';
			}
			else{
				if(dp[i-1][j] >= dp[i][j-1]){
					dp[i][j] = dp[i-1][j];
					from[i][j] = 't';
				}
				else{
					dp[i][j] = dp[i][j-1];
					from[i][j] = 'l';
				}
			}
		}
	}
	
	string res = "";
	int i = lens, j = lent;
	while(i > 0 && j > 0){
		if(from[i][j] == 'd'){
		 // cout<<i<<" "<<j<<"\n";
		  res += s[i-1];
		  i--;
		  j--;
		}
		else if(from[i][j] == 'l'){
			j--;
		}
		else i--;
		
	}
	reverse(res.begin(), res.end());
	cout << res;
	return 0;
}

Measured memory_bytes: 45952
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e6 + 10;
char s[N];
int main() {
  scanf("%s", s);
  int n = strlen(s), len = 0;
  for (int i = 0; i < n; i += 2) {
    s[len++] = s[i];
  }
  s[len] = 0;
  puts(s);
  return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 300005

ll h , w , t;
ll x , y;
ll a[MAXX];
ll b[MAXX];

int main()
{
    _FastIO;
    cin >> h >> w >> t;
    map<ll , bool> m;
    while(t--){
        cin >> x >> y;
        a[x]++;
        b[y]++;
        ll k = (x - 1) * w + y;
        m[k] = true;
    }
    vector<pair<ll , ll> > v;
    for(ll i = 1; i <= h; i++){
        v.push_back({a[i] , i});
    }
    vector<pair<ll , ll> > p;
    for(ll i = 1; i <= w; i++){
        p.push_back({b[i] , i});
    }
    sort(v.begin() , v.end());
    reverse(v.begin() , v.end());
    sort(p.begin() , p.end());
    reverse(p.begin() , p.end());
    x = v[0].first;
    y = p[0].first;
    ll k = x + y;
    ll ans = k - 1;
    for(ll i = 0; i < v.size(); i++){
        bool f = false;
        for(ll j = 0; j < p.size(); j++){
            ll c = v[i].first;
            ll d = p[j].first;
            if(d < y){
                break;
            }
            if(c < x){
                f = true;
                break;
            }
            c = v[i].second;
            d = p[j].second;
            ll sum = (c - 1) * w + d;
            if(m[sum] == false){
                ans++;
                f = true;
                break;
            }
        }
        if(f == true){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 43688
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
ans = 0
ur = sorted(xy, key=lambda x: x[0]+x[1])[-1]
ul = sorted(xy, key=lambda x: x[1]-x[0])[-1]
dr = sorted(xy, key=lambda x: x[0]-x[1])[-1]
dl = sorted(xy, key=lambda x: -x[0]-x[1])[-1]

l = [ur, ul, dr, dl]
for i in l:
  for j in l:
    ans = max(ans, abs(i[0]-j[0])+abs(i[1]-j[1]))
print(ans)

Measured memory_bytes: 56556
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,h,ans = 1,a;
    cin >> n >> h;
    a = h;
    rep(i, n - 1){
        cin >> h;
        if (a <= h) {
            a = h;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void) {
    int n, m, l;
    int A[101][101], B[101][101];
    long C[101][101];
    int i, j, k;
     
     
    scanf("%d %d %d", &n, &m, &l);
     
    for(i = 0; i < n; i++) {
        for(j = 0; j < m; j++) {
            scanf("%d", &A[i][j]);
        }
    }
     
    for(i = 0; i < m; i++) {
        for(j = 0; j < l; j++) {
            scanf("%d", &B[i][j]);
        }
    }
     
    for(i = 0; i < n; i++) {
        for(j = 0; j < l; j++) {
            C[i][j] = 0;
        }
         
    }
     
    for(i = 0; i < n; i++) {
        for(j = 0; j < l; j++) {
            for(k = 0; k < m; k++) {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
     
    for(i = 0; i < n; i++) {
        for(j = 0; j < l; j++) {
            printf("%ld", C[i][j]);
            if(j != l-1) {
                printf(" ");
            }
        }
        printf("\n");
    }
     
    return 0;
}


Measured memory_bytes: 760
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in); 
		//input integer
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(A*B);
		sc.close();
	}

}


Measured memory_bytes: 27040
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = 0;
        int i = 0;
        for(i = 0; c < b; i++){
            c = a * i + a - i;
        }
        if(b == 1){
            System.out.println("0");
        }else if(a >= b){
            System.out.println("1");
        }else{
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 24020
#https://atcoder.jp/contests/abc110/submissions/10200775
s = input()
t = input()


alp = 'abcdefghijklmnopqrstuvwxyz'

scnt = [[] for i in range(28)]
tcnt = [[] for i in range(28)]

for i in range(len(s)):
    for j,v in enumerate(alp):
        if s[i] == v:
            scnt[j].append(i)

for i in range(len(t)):
    for j,v in enumerate(alp):
        if t[i] == v:
            tcnt[j].append(i)

scnt.sort()
tcnt.sort()


if scnt == tcnt:print("Yes")
else :print("No")

Measured memory_bytes: 20656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C;cin >> A >> B >> C;
  cout << (A^B^C) << endl;
  return 0;
}


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

const int N = 100 + 10;
int n, m;
int a[N];

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
    
    cin >> n >> m;
    double sum = 0.0;
    for (int i = 0; i < n; i++){
      cin >> a[i];
      sum += (double)a[i];
    }
    int cnt = 0;
    double cur = sum / (4.0 * m);
    sort(a, a + n);
    for (int i = 0; i < n; i++){
      cnt += a[i] >= cur;
      if (cnt == m){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 256
str = input()
n = len(str)
A = str[0]
B = str[1]
C = str[2]
D = str[3]

op_cnt = n - 1

for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    ans = A + op[0] + B + op[1] + C + op[2] + D
    if eval(ans) == 7:
        print(ans + "=7")
        break

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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    map<int, int> candidates;
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        /* 操作で生成しうる数を数える */
        candidates[a]++;
        candidates[a-1]++;
        candidates[a+1]++;
    }

    int mx = 0;
    for ( auto itr : candidates ) {
        if ( itr.second > mx ) {
            mx = itr.second;
        }
    }

    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 8032
// 173 b
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        int n = input.nextInt();
        for (int i = 0; i < n; i++){
            String s = input.next();
            if(s.equals("AC")){
                ac += 1;
            } else if (s.equals("WA")){
                wa += 1;
            } else if (s.equals("TLE")){
                tle += 1;
            } else {
                re += 1;
            }
        }
        System.out.printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
    }
}

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

void solve() 
{
    ll ans=0;
    ll n;cin>>n;
    ll s[n+1];s[0]=0;
    ll a[n];REP(i,n)cin>>a[i],s[i+1]=s[i]+a[i];
    map<ll,ll>sum;
    REP(i,n+1)sum[s[i]]++;
    for(auto it:sum)
        ans+=it.second*(it.second-1)/2;
    cout<<ans<<endl;
}

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

Measured memory_bytes: 15872
N, M ,K= map(int, input().split())
a=[0]*M
b=[0]*M
c=[0]*K
d=[0]*K

for i in range(M):
    a[i], b[i] = map(int, input().split())
for i in range(K):
    c[i], d[i] = map(int, input().split())

l=list(range(N+1))
r=[0]*(N+1)
size=[1]*(N+1)
la=N
di=[[]for _ in range(N+1)]
def find(x):
    if l[x]==x:
        return x
    else:
        return find(l[x])

def union(x,y):
    X=find(x)
    Y=find(y)
    if r[X]>r[Y]:
        l[Y]=l[X]
        size[X]+=size[Y]
    else:
        l[X]=l[Y]

        if r[X]==r[Y]:
            r[Y]+=1
        if X!=Y:
            size[Y] += size[X]
for i in range(M):
    union(a[i],b[i])
    di[a[i]].append(b[i])
    di[b[i]].append(a[i])
for i in range(K):
    if (find(c[i])==find(d[i])):
        di[c[i]].append(d[i])
        di[d[i]].append(c[i])

t=[]
for i in range(N+1):
    p=size[find(i)]-1-len(di[i])

    t.append(p)


print(" ".join(map(str, t[1:])))


Measured memory_bytes: 47076
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,h;
  cin>>a>>b>>h;
  cout<<(0.5*((a+b)*h));
  
  

}
return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
AB = [list(map(int,input().split())) for _ in range (N-1)]
edge = [[] for _ in range(N)]
for u,v in AB:
    edge[u-1].append(v-1)
    edge[v-1].append(u-1)

dists = [0]*N
distn = [0]*N
def dfs_s(v, p):
    for nv in edge[v]:
        if nv==p:continue 
        dists[nv] = dists[v] + 1
        dfs_s(nv, v)
    return 
def dfs_n(v, p):
    for nv in edge[v]:
        if nv==p:continue 
        distn[nv] = distn[v] + 1
        dfs_n(nv, v)
    return 
dfs_s(0,-1)
dfs_n(N-1,-1)

B = 0
W = 0
for i in range(N):
    if dists[i]<=distn[i]:
        B += 1
    else:
        W += 1

if B>W:
    print('Fennec')
else:
    print('Snuke')




Measured memory_bytes: 137204
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;
int gcd(int a, int b) {//最大公約数
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
	int g = gcd(a, b);
	return a / g * b;
}


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

	int X, Y; cin >> X >> Y;
	if (Y == 1 || gcd(X, Y) == Y)cout << -1 << endl;
	else if (X == 1) cout << Y + 1 << endl;
	else {
		cout << X * Y - X << endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<"\n";
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
// #define find(m,i) (m.find(i)!=m.end())
// #define find(m,i) (m.find(i)==m.end())
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 1000000000000000000
#define imin -1000000000000000000
// #define NP 50000
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
//  IIITA
//SUNEET KUMAR -->  ਸੁਨੀਤ
 
// scanning numbers extremely fast/////////
void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
// ========================================
int power(int a,int x)
{
        a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
double prob[3005];
double dp[3005][3005];
void nhi_degi()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>prob[i];
    }
    dp[0][0]=1.000000000;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-prob[i]);
            }
            else
            {
                dp[i][j]=(dp[i-1][j]*(1-prob[i]))+(dp[i-1][j-1]*(prob[i]));
            }
        }
    }
    double ans=0.000000000;
    for(int i=(n+1)/2;i<=n;i++)
    {
        // cout<<dp[n][i];el
        ans+=dp[n][i];
    }
    printf("%.9lf\n",ans);
    // cout<<ans;el
}
signed main()
{
    nhi_degi();
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e8
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

vector<int> alpha(26);

int main() {
    ll x;
    cin >> x;
    int ans = 0;
    ans += (x/500) * 1000;
    ans += ((x%500) / 5) * 5;
    cout << ans << endl;
    

    return 0;
}
 

Measured memory_bytes: 256
import bisect as bi
import numpy
n = int(input())
li = list(map(int,input().split()))

li = list(map(lambda x:2*x,li))
acc = list(numpy.cumsum(li))
m = acc[n-1]//2
ml = acc[bi.bisect_left(acc,m)-1]
mr = acc[bi.bisect_left(acc,m)]
#print("{} {} {}".format(m,ml,mr))
#print(acc)
print(min(m-ml,mr-m))

Measured memory_bytes: 34212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    int bingo[3][3];
    rep(i, 3) rep(j, 3) {
        cin >> bingo[i][j];
    }
    int n, b;
    scanInt(n);
    rep(step, n) {
        scanInt(b);
        rep(i, 3) rep(j, 3) {
            if (bingo[i][j] == b) {
                bingo[i][j] = 0;
                break;
            }
        }
    }
    if (!bingo[0][0] && !bingo[0][1] && !bingo[0][2] ||
        !bingo[1][0] && !bingo[1][1] && !bingo[1][2] ||
        !bingo[2][0] && !bingo[2][1] && !bingo[2][2] ||
        !bingo[0][0] && !bingo[1][0] && !bingo[2][0] ||
        !bingo[0][1] && !bingo[1][1] && !bingo[2][1] ||
        !bingo[0][2] && !bingo[1][2] && !bingo[2][2] ||
        !bingo[0][0] && !bingo[1][1] && !bingo[2][2] ||
        !bingo[0][2] && !bingo[1][1] && !bingo[2][0]) {
        printYes();
    } else printNo();
    return 0;
}


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

int main() {
  ll n,m,w=1;
  cin >> n >> m;
  r(i,m)w*=2;
  cout << (1900*m+100*(n-m))*w<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////
int x, y, ans;
signed main(){
  cin>>x>>y;ans = 0;
  while(x <= y){
    x *= 2;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const ll INF = (1LL << 60);
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/

/**************************************/
/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    int ng = 0;
    int ok = 1e9;

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        //答えをxとして全てのlogsはx以下にk回以内で切れるのか
        auto f = [&](int x){
            ll now = 0;
            rep(i,n){
                now += (a[i]-1)/x;
            }
            //切れる場合はtrueを返す
            return now<=k;
        };
        if (f(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 4720
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
using namespace std;

int main(void){
	double a, b, c;
	double S, L, h;

	cin >> a >> b >> c;

	h = b*sin(c * M_PI / 180);
	S = h * a * 0.5;
	L = a + b + sqrt((a - b*cos(c*M_PI / 180))*(a - b*cos(c*M_PI / 180)) + h*h);

	cout << fixed << setprecision(10) << S << "\n" << L << "\n" << h << "\n";

	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    char s; cin>>s;
    if(s=='a'||s=='i'||s=='u'||s=='e'||s=='o'){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
    
}


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if(x >= r && y >= r && x + r <= W && y + r <= H){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = (1LL<<61)-1; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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){
    int N; cin >> N;
    string ans;
    if(N%10 == 7){
        cout << "Yes" << en;
        return 0;
    }
    N /= 10;
    if(N%10 == 7){
        cout << "Yes" << en;
        return 0;
    }
    N /= 10;
    if(N == 7){
        cout << "Yes" << en;
    }
    else cout << "No" << en;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int h, w, K;
lint dp[2][3010][4];
vector<pair<int, lint>> item[3010];
int r[MAX], c[MAX];
lint v[MAX];
vector<int> vx, vy;

int main(){
    scanf("%d%d%d", &h, &w, &K);
    rep(i, K){
        scanf("%d%d%lld", &r[i], &c[i], &v[i]);
        vx.push_back(r[i]);
        vy.push_back(c[i]);
    }
    vx.push_back(0);
    vy.push_back(0);
    sort(vx.begin(), vx.end());
    vx.erase(unique(vx.begin(), vx.end()), vx.end());
    sort(vy.begin(), vy.end());
    vy.erase(unique(vy.begin(), vy.end()), vy.end());
    rep(i, K){
        int x = lower_bound(vx.begin(), vx.end(), r[i]) - vx.begin();
        item[x].emplace_back(c[i], v[i]);
    }
    h = vx.size();
    w = vy.size();
    rep(i, h) sort(item[i].begin(), item[i].end());

    rep(i, 2)rep(j, w + 1)rep(k, 4) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    rep(i, vx.size()){
        rep(j, w)rep(k, 4)if(dp[0][j][k] >= 0){
            chmax(dp[1][j][0], dp[0][j][k]);
            chmax(dp[0][j + 1][k], dp[0][j][k]);
            auto itr = lower_bound(item[i].begin(), item[i].end(), pair<int, lint>(vy[j], -1LL));
            if(k <= 2 && itr != item[i].end() && itr->fi == vy[j]){
                chmax(dp[1][j][0], dp[0][j][k] + itr->se);
                chmax(dp[0][j + 1][k + 1], dp[0][j][k] + itr->se);
            }
        }

        /*rep(j, w + 1){
            rep(k, 4) printf("%lld ", dp[1][j][k]);
            printf("\n");
        }
        printf("\n");*/

        rep(j, w + 1)rep(k, 4){
            dp[0][j][k] = dp[1][j][k];
            dp[1][j][k] = -1;
        }
    }

    lint ans = 0;
    rep(i, 4) chmax(ans, dp[0][w - 1][i]);
    printf("%lld\n", ans);
}

Measured memory_bytes: 13752
/**                                                     **\
 *    author:       Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
**/                                                     
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int max3(int a,int b,int c){
    return max(a,max(b,c));
}
int min3(int a,int b,int c){
    return min(a,min(b,c));
}
void under_rated(){
fast;
}
int32_t main(){
    under_rated();
    int m,d;
    cin>>m>>d;
    int tot=0;
    for(int i=1;i<=d;++i){
        if(i<22){
            continue;
        }
        int x=i/10;
        if(x<2 || (i%10)<2){
            continue;
        }
        if(x*(i%10)<=m){
            ++tot;
        }
    }
    cout<<tot;
    return 0;
}

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

#define int64 long long
#define all(x) (x).begin(),(x).end()


using namespace std;

int main() {
	int64 N, M;
	cin >> N >> M;
	vector<int64> A(N, 0);
	for (int64 i = 0; i < N; i++) {
		cin >> A[i];
	}
	int64 sumVote = (int64)accumulate(all(A), 0);
	//int64 minVote = (int64)(sumVote / (4.0 * M));
	sort(all(A), greater<int64>());
	for (int64 i = 0; i < M; ++i) {
		if (A[i]*(4.0 * M) < sumVote) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
main(){
  int H,W,N;
  cin>>H>>W>>N;
  list<pair<int,int>>list0,list1;
  for(int i=1;i<=N;++i){
    int p,q;
    cin>>p>>q;
    const vector<int>ks={0,1,2};
    const vector<int>ls={0,1,2};
    for(auto k:ks){
      for(auto l:ls){
        list0.push_back({p-k,q-l});
      }
    }
  }
  for(auto x:list0){
    const int row=x.first;
    const int col=x.second;
    if(row<1||H-2<row)continue;
    if(col<1||W-2<col)continue;
    list1.push_back(x);
  }
  vector<pair<int,int>>xs(list1.begin(),list1.end());
  sort(xs.begin(),xs.end());
  xs.push_back({-1,-1});
  array<int,10>n_count{},n_cumsum{};
  int n_continuous=1;
  for(int i=1;i<xs.size();++i){
    if(xs[i-1]==xs[i]){
      ++n_continuous;
    }else{
      ++n_count[n_continuous];
      n_continuous=1;
    }
  }
  n_cumsum=n_count;
  for(int i=1;i<n_cumsum.size();++i)n_cumsum[i]+=n_cumsum[i-1];
  n_count[0]=(H-2)*(W-2)-n_cumsum[9];
  for(auto x:n_count){
    cout<<x<<endl;
  }
}


Measured memory_bytes: 114560