akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

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

ll gcd(ll x, ll y) {
    while (x > 0 && y > 0) {
        if (x > y) x %= y;
        else y %= x;
    }
    return x + y;
}

int main(void){

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	ll a[n], l[n + 1], r[n + 1];
	ll ans = 0;
	
	FOR(i,n) {
		cin >> a[i];
	}

	l[0] = 0;
	for (int i = 0; i < n; i++) {
		l[i + 1] = __gcd(l[i], a[i]);
	}

	// FOR(i, n+1){
	// 	cout << l[i] << '\n';
	// }
	// return 0;
	r[n] = 0;
	for (int i = n - 1; i >= 0; i--) {
		r[i] = __gcd(r[i + 1], a[i]);
	}
 
 	FOR(i, n){
		ans = max(ans, __gcd(l[i], r[i + 1]));
	}

	cout << ans;
	return 0;
}


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

int main(){
  long long A[100][100], B[100][100], C[100][100];
  int n, m, l;

  cin >> n >> m >> l;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> A[i][j];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < l; j++) cin >> B[i][j];


  for (int i = 0; i < n; i++){
    for (int j = 0; j < l; j++){
        C[i][j] = 0;
      for (int k = 0; k < m; k++){
        C[i][j] += A[i][k]*B[k][j];
      }
    }
  }

  for (int i = 0 ; i < n; i++){
    for (int j = 0 ; j < l; j++){
      if( j ) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }

return 0;
}

Measured memory_bytes: 3296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

// ■■■■■■■■■■■■■■■■headerここまで■■■■■■■■■■■■■■■■

int main() {

    string t;
    cin >> t;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << endl;

    return 0;

}

Measured memory_bytes: 3736
(function(input) {
    inputs = input.split(' ').map(Number);
    var a = inputs[0];
    var b = inputs[1];
    var d = Math.floor(a / b);
    var r = a % b;
    var f = (a / b).toFixed(5);
    console.log('%d %d %d', d, r, f);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7908
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int a,b,c,cnt;
    cnt=0;
    cin>>a>>b>>c;
    for(int i=a;i<b+1;i++){
        if(c%i==0)  cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}



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

int main(){
	ll H, W, N; cin >> H >> W >> N;
	map<pair<ll, ll>, ll> m;
	for(int i = 0; i < N; ++i){
		ll a, b; cin >> a >> b;
		for(int j = -1; j <= 1; ++j){
			for(int k = -1; k <= 1; ++k){
				if(a + j <= 1 || a + j > H - 1 || b + k <= 1 || b + k > W - 1) continue;
				++m[pair<ll, ll>(a + j, b + k)];
			}
		}
	}
	ll ans[10] = {(H - 2) * (W - 2) - (ll)m.size()};
	for(auto ite = m.begin(); ite != m.end(); ++ite) ++ans[ite->second];
	for(int i = 0; i < 10; ++i) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 56448
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n),b(100001);
    for(int i= 0;i < n;i ++){
        cin >> a.at(i);
    }

    for(int i = 0;i < n;i ++){
        b.at(a.at(i)) ++;
    }

    int sum = b.at(0)+b.at(1)+b.at(2);
    int ans = sum;

    for(int i = 0;i < 99997;i ++){
        sum -= b.at(i);
        sum += b.at(i+3);
        ans = max(ans,sum);
    }

    cout << ans << endl;
}



Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


int main() {
	int N;
	int ans = 0;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		ans += A[i] - 1;
}
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n,m = LI()
    a = []
    for i in range(n):
        t = 0
        for c in S():
            t <<= 1
            if c == '#':
                t += 1
        a.append(t)

    b = []
    for i in range(m):
        t = 0
        for c in S():
            t <<= 1
            if c == '#':
                t += 1
        b.append(t)

    mask = 2**m-1
    for i in range(n-m+1):
        for j in range(n-m+1):
            f = True
            for k in range(m):
                ak = (a[k+j] >> i) & mask
                if ak != b[k]:
                    f = False
                    break
            if f:
                return 'Yes'
    return 'No'


print(main())


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

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  for(int i=0; i<=N; i++){
    for(int j=0; j<=M; j++){
      if(i*M+j*N-2*i*j==K){
        cout << "Yes" << endl;
        goto finish;
      }
    }
  }
  cout << "No" << endl;
  finish: N=0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s,t;
    ll sum=0;
    cin >> s >> t;
    rep(i,3){
        if(s[i]==t[i]) sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ;i++)

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  int n;
  cin >>n;
  string s;
  cin >> s;
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  int g=n/2;
  rep(i,g){
    if(s[i]!=s[i+g]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  

  return 0;

}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  string s; cin >> s;
  string t;
  for (int i = 0; i < s.size() / 2; i++) {
    t += "hi";
  }
  cout << (s == t ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto S = sread();
    DList!char ans;
    foreach (c; S)
    {
        if (c == 'B')
        {
            if (!ans.empty)
                ans.removeBack();
            continue;
        }
        ans.insertBack(c);
    }
    writeln(ans[]);
}


Measured memory_bytes: 3660
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;





int main() {
	int n;
	cin >> n;
	vector <vector<ll>> dp(n, vector<ll>(4));
	dp[0] = { 0,1,1,8 };
	for (int i = 1; i < n; i++) {
		dp[i][0] = (dp[i - 1][0] * 10 + dp[i - 1][1] + dp[i - 1][2]) % MOD;
		dp[i][1] = (dp[i - 1][3] + dp[i - 1][1] * 9) % MOD;
		dp[i][2] = (dp[i - 1][3] + dp[i - 1][2] * 9) % MOD;
		dp[i][3] = (dp[i - 1][3] * 8)%MOD;
		
		/*
		for (int dpi : dp[i]) {
			cout << dpi << " ";
		}
		cout << endl;
		*/
	}

	cout << dp[n - 1][0] << endl;
}

Measured memory_bytes: 73388
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define mp       make_pair
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int dp[100005][101], wt[101], vl[101];
int fn(int w, int n)
{	if (n == 0 || w == 0)
		return 0;
	if (dp[w][n] != -1)
		return dp[w][n];
	int tp1 = 0, tp2 = 0;
	tp1 = fn(w, n - 1);

	if (wt[n - 1] <= w)
		tp2 = vl[n - 1] + fn(w - wt[n - 1], n - 1);

	
	dp[w][n] = max(tp1, tp2);
	return dp[w][n];
}
int32_t main()
{	//pre();
	//case
	{	int n, W;
		cin >> n >> W;
		for (int i = 0; i < n; i++)
			cin >> wt[i] >> vl[i];
		for (int i = 0; i <= 100002; i++)
			for (int j = 0; j <= 101; j++)
				dp[i][j] = -1;
		cout << fn(W, n);
	}
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

signed main()
{
    int n;
    vector<int> a;
    vector<int> b;

    cin >> n;

    a.resize(n + 1);
    b.resize(n);

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

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

    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        int current_kill = min(a[i], b[i]);
        int next_kill = min(a[i + 1], b[i] - current_kill);
        a[i] -= current_kill;
        a[i + 1] -= next_kill;
        ans += current_kill + next_kill;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 998244353;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m, k;
const ll M = 998244353;

vector<ll>
    fac(20000001);         //n!(mod M)
vector<ll> ifac(20000001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n)
{ //x^n(mod M)
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
//conbination
ll comb(ll a, ll b)
{ //aCb(mod M)
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> k;
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i <= 2000000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % M;              // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
    ll ans = m*mpow(m-1,n-1);
    ans%=MOD;
    //cout<<ans<<"\n";
    for(ll i=1;i<=k;i++){
        ll temp=comb(n-1,i);
        temp*=m;
        temp%=MOD;
        temp*=mpow(m-1,n-1-i);
        temp%=MOD;
        ans+=temp;
        ans%=MOD;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 315672
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int ,int >, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
int32_t main()
{
	fast;
	int s, w;
	cin >> s >> w;
	if (w >= s)
	{
		cout << "unsafe";
	}
	else
	{
		cout << "safe";
	}

}

Measured memory_bytes: 3652
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        for(int i=0; i<M; i++){
          int Ai = sc.nextInt();
          N = N - Ai;
        }
        if(N < 0){
          System.out.println("-1");
        }else{
          System.out.println(N);
        }
    }
}

Measured memory_bytes: 46464
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long int> A(N);
  long long int A_sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i) = A.at(i) % 1000000007;
    A_sum += A.at(i);
    A_sum = A_sum % 1000000007;
  }
  long long int ans = 0;
  for(int i = 0; i < N; i++) {
    ans = ans + A.at(i) * (A_sum - A.at(i) + 1000000007);
    ans = ans % 1000000007;
    if(A_sum > A.at(i)) {
      A_sum = A_sum - A.at(i);
    }
    else {
      A_sum = A_sum - A.at(i) + 1000000007;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 10000007;
const int maxn = (int) 2 * 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int n, x, a[maxn], t[maxn];

int main() {
//    fin("t.in");
    sync;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1)
        cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        clean(a);
        clean(t);
        if (x == 2 * n - 2) {
            a[n] = x;
            a[n - 1] = x - 1;
            a[n + 1] = x + 1;
            a[n + 2] = x - 2;
            t[x] = 1;
            t[x - 1] = 1;
            t[x - 2] = 1;
            t[x + 1] = 1;
        } else {
            a[n] = x;
            a[n - 1] = x - 1;
            a[n - 2] = x + 1;
            a[n + 1] = x + 2;
            t[x] = 1;
            t[x - 1] = 1;
            t[x + 2] = 1;
            t[x + 1] = 1;

        }
        x = 1;
        fi(1, 2 * n - 1) {
            while (t[x])
                ++x;
            if (a[i] != 0)
                continue;
            a[i] = x;
            ++x;
        }
        ri(1, 2 * n) {
            cout << a[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3072
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

long long result, n,d,x;
long long a[100000] = {};
long long b[100005] = {};


typedef pair<long long, long long> pl;
vector<pl> re;
vector<pl> bl;
pl buf;



int main() {
	result = 0;
	d = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i >= 1) {
			b[i] = abs(a[i] - a[i - 1]);
		}

		d += b[i];
	}
	b[0] = abs(a[0]);
	b[n] = abs(a[n - 1]);
	d += b[0] + b[n];
	
	cout << d-b[0]-b[1]+abs(a[1]) << endl;

	for (int i = 1; i < n-1; i++) {
		cout << d - b[i]- b[i+1] + abs(a[i+1]- a[i - 1]) << endl;
	}

	cout << d - b[n]-b[n-1] + abs(a[n-2]) << endl;
	//cout << result << endl;

return 0;
}

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

using LL = long long;
LL get(auto S, auto i) {return (S >> i) & 1;}
LL add(auto S, auto i) {return S | (LL(1) << i);}
int bitcount(auto n) {return n ? 1 + bitcount(n & (n - 1)) : 0;}

class Tree {
 public:
  Tree(vector<vector<int>>& G, int root = 0) : root(root), depth(G.size()), parent(G.size()) {
    function<void(int,int,int)> dfs = [&](auto cur, auto pre, auto d) {
      depth[cur] = ++d;
      for(auto nex: G[cur]) if(nex != pre) dfs(nex, parent[nex] = cur, d);
    };
    dfs(root, -1, 0);
  }
  LL path(auto u, auto v) {
    LL S = 0;
    while(u != v) {
      if(depth[u] > depth[v]) swap(u, v);
      S = add(S, v);
      v = parent[v];
    }
    return S;
  }
 private:
  int root;
  vector<int> depth, parent;
};

int main() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(auto i=1; i<N; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  Tree T(G);

  int M;
  cin >> M;
  vector<LL> vertex(M);
  for(auto i=0; i<M; ++i) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    vertex[i] = T.path(u, v);
  }

  vector<LL> pow{1};
  while(pow.size() < N*N) pow.emplace_back(2 * pow.back());

  vector<LL> dp(pow[M]);
  for(LL S=0; S<pow[M]; ++S) {
    for(auto i=0; i<M; ++i) if(!get(S, i)) {
      dp[add(S, i)] = dp[S] | vertex[i];
    }
  }

  vector<LL> pie(M+1);
  for(LL S=1; S<pow[M]; ++S) {
    auto n = bitcount(S);
    auto m = bitcount(dp[S]);
    pie[n] += pow[N-1-m];
  }

  auto res = pow[N-1];
  for(auto i=1; i<=M; ++i) {
    res += pie[i] * (i&1 ? -1 : 1);
  }
  cout << res << endl;
}


Measured memory_bytes: 8576
#include <stdio.h>
int binarySearch(int);
int n,A[100000];
 
int main()
{
  int q,i,x,judge,num=0;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
   
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&x);
    judge=binarySearch(x);
    if(judge) num++;
  }
   
  printf("%d\n",num);
 
  return 0;
}
 
int binarySearch(int key)
{
  int left=0;
  int right=n;
  int mid;
   
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key) return 1;
    else if(key<A[mid]) right=mid;
    else left=mid+1;
  }
 
  return 0;
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define for_p(i, a, b) for(int i = a; i < b; i++)
#define for_m(i, a, b) for(int i = a - 1; i >= b; i--)

//a = s1.size();
//vector<string> s1;
//string s2 = accumulate( s1.begin(), s1.end(), string() );

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0;
  int i = 0, j = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  char s1[200000], s2[200000], s3[200000];
  
  cin >> a;
  
  if(a % 2 == 0){
    d1 = 0.5;
  }else{
    d2 = ((a - 1) / 2);
    d1 = 1 - d2 / double(a);
  }
  cout << d1 << endl;
}

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

int main(){
 int c = 0;
 int N;
 string S;
 cin >> N >> S;
 for(int k=1;k<N;k++){
    int a[26]={0};
 	int b[26]={0};
    int ans = 0;
 	for(int i=0;i<k;i++){
  		a[S[i]-97]++;
 	}
   for(int j=k;j<N;j++){
   		b[S[j]-97]++;
   }
   for(int l=0;l<26;l++){
   		if(a[l]>0&&b[l]>0){
          ans++;
        }
   }
   c = max(ans,c);
 }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,a;
    cin >> h >>a;
    cout << (h+a-1)/a;

    return 0;
}

Measured memory_bytes: 3624
prime = [2]
pr5 = []
fl = False
for i in range(3,5555):
    for j in prime:
        if i % j == 0:
            fl = True
    if fl == False:
        prime.append(i)
        if i % 5 == 1:
            pr5.append(i)
    fl = False
n = int(input())
ans = []
for i in range(n):
    ans.append(str(pr5[i]))
print(" ".join(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;
    rep(i, n) {
        ll x = lower_bound(all(a), b[i]) - a.begin();
        ll y = c.end() - upper_bound(all(c), b[i]);
        ans += x * y;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, n + 1){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int n,k;cin>>n>>k;

  int cnt=1;
  while(1){
    ll t = pow(k,cnt);
    if(t>n){
      cout<<cnt<<endl;
      break;
    }
    cnt++;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) cout << "Yes" << endl;
    else if (b <= c && c <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==f==r==-1:
        break
    else:
        if m==-1 or f== -1 or m+f<30:
            print("F")
        elif m+f>=80:
            print("A")
        elif 65<=m+f<80:
            print("B")
        elif 50<=m+f<65 or r>=50:
            print("C")
        elif 30<=m+f<50 and r<50:
            print("D")
            
        


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 300;

int N;
std::string S[MAX_N+1], tS[MAX_N+1];
bool ver[MAX_N+1][MAX_N+1];

int main()
{
  std::cin >> N;
  rep( i, N )
    std::cin >> S[i];
  rep( i, N ) rep( j, N )
    tS[j] += S[i][j];

  rep( i, N ) rep( j, N ) if( S[i].substr( j )+S[i].substr( 0, j ) == tS[j].substr( i )+tS[j].substr( 0, i ) )
    ver[i][j] = true;

  int ans = 0;

  rep( i, N ) rep( j, N ) if( ver[i][j] )
  {
    bool fl = true;

    rep( k, N )
      fl &= ver[(i+k)%N][(j+k)%N]; 

    if( fl )
      ++ans;
  }

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

  return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main implements Runnable {
    static boolean use_n_tests = false;
    static int stack_size = 1 << 20;
    static long mod = 1_000_000_007;

    void solve(FastScanner in, PrintWriter out, int testNumber) {
        int n=  in.nextInt();
        if (n >= 30) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    // ****************************** template code ***********

    static class Range {
        int l, r;
        public Range(int l, int r) {
            this.l = l;
            this.r = r;
        }
    }
    static class Array {
        static Range[] readRanges(int n, FastScanner in) {
            Range[] result = new Range[n];
            for (int i = 0; i < n; i++) {
                result[i] = new Range(in.nextInt(), in.nextInt());
            }
            return result;
        }
        Integer[] read(int n, FastScanner in) {
            Integer[] out = new Integer[n];
            for (int i = 0; i < out.length; i++) {
                out[i] = in.nextInt();
            }
            return out;
        }
    }
    class Graph {
        List<List<Integer>> create(int n) {
            List<List<Integer>> graph = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                graph.add(new ArrayList<>());
            }
            return graph;
        }
    }
    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream io) {
            br = new BufferedReader(new InputStreamReader(io));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

    void run_t_tests() {
        int t = in.nextInt();
        int i = 0;
        while (t-- > 0) {
            solve(in, out, i++);
        }
    }

    void run_one() {
        solve(in, out, -1);
    }

    @Override
    public void run() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        if (use_n_tests) {
            run_t_tests();
        } else {
            run_one();
        }
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(null, new Main(), "", stack_size);
        thread.start();
        thread.join();
    }
}

Measured memory_bytes: 32960
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
l = []
for i in a:
    for j in b:
        l.append(i + j)
c.sort(reverse=True)
l.sort(reverse=True)
l = l[:k]
l2 = []
for i in c:
    for j in l:
        l2.append(i + j)
l2.sort(reverse=True)
print(*l2[:k], sep="\n")


Measured memory_bytes: 217696
#include <iostream>
#include <queue>
#include <set>
#define N 52
#define y1 first.first
#define x1 first.second
#define y2 second.first
#define x2 second.second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;

int bfs();

int w,h,sy1,sx1,sy2,sx2,gy1,gx1,gy2,gx2;
string r1[N],r2[N];
bool visited[N][N][N][N];

int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h) break;
    for(int i=0;i<h;i++) cin>>r1[i]>>r2[i];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	for(int k=0;k<h;k++)
	  for(int l=0;l<w;l++) visited[i][j][k][l]=false;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	if(r1[i][j]=='L') sy1=i,sx1=j;
	if(r1[i][j]=='%') gy1=i,gx1=j;
	if(r2[i][j]=='R') sy2=i,sx2=j;
	if(r2[i][j]=='%') gy2=i,gx2=j;
      }
    if(bfs()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

int bfs(){
  int dy[4]={0,-1,0,1},dx[4]={-1,0,1,0};
  queue<P1> q;
  P1 k=make_pair(P(sy1,sx1),P(sy2,sx2));
  q.push(k);
  visited[sy1][sx1][sy2][sx2]=true;
  while(!q.empty()){
    P1 t=q.front(); q.pop();
    for(int i=0;i<4;i++){
      int ny1=t.y1+dy[i],nx1=t.x1+dx[i];
      int ny2=t.y2+dy[i],nx2=t.x2-dx[i];
      if(ny1<0) ny1=0;
      if(nx1<0) nx1=0;
      if(h<=ny1) ny1=h-1;
      if(w<=nx1) nx1=w-1;
      if(ny2<0) ny2=0;
      if(nx2<0) nx2=0;
      if(h<=ny2) ny2=h-1;
      if(w<=nx2) nx2=w-1;
      if(r1[ny1][nx1]=='#') ny1=t.y1,nx1=t.x1;
      if(r2[ny2][nx2]=='#') ny2=t.y2,nx2=t.x2;
      P1 u=make_pair(P(ny1,nx1),P(ny2,nx2));
      if(ny1==gy1&&nx1==gx1&&ny2==gy2&&nx2==gx2) return 1;
      if(visited[ny1][nx1][ny2][nx2]||(ny1==gy1&&nx1==gx1)||(ny2==gy2&&nx2==gx2)) continue;
      visited[ny1][nx1][ny2][nx2]=true;
      q.push(u);
    }
  }
  return 0;
}

Measured memory_bytes: 8996
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
bool field[4001][4001]={};
int za[1005][4];
int main(){
	while(1){
        memset(field,0,sizeof(field));
	int n,m;
	scanf("%d %d",&n,&m);
	if(!n) break;
	vector<int>x,y;
	x.pb(0);
	x.pb(n-1);
	y.pb(0);
	y.pb(m-1);
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		int w,xx,yy,z;
		scanf("%d %d %d %d",&w,&xx,&yy,&z);
		za[i][0]=w;
		za[i][1]=xx;
		za[i][2]=yy;
		za[i][3]=z;
		x.pb(w-1);
		x.pb(w);
		x.pb(yy);
		x.pb(yy-1);
		y.pb(xx-1);
		y.pb(xx);
		y.pb(z);
		y.pb(z-1);
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	x.erase(unique(x.begin(),x.end()),x.end());
	y.erase(unique(y.begin(),y.end()),y.end());
	vector<int>px,py;
	for(int i=0;i<x.size();i++){
		if(x[i]>=0 && x[i]<n){
			px.pb(x[i]);
		}
	}
	for(int i=0;i<y.size();i++){
		if(y[i]>=0 && y[i]<m){
			py.pb(y[i]);
		}
	}
	for(int i=0;i<Q;i++){
			int le1=lower_bound(px.begin(),px.end(),za[i][0])-px.begin();
			int le2=lower_bound(py.begin(),py.end(),za[i][1])-py.begin();
			int ri1=lower_bound(px.begin(),px.end(),za[i][2]-1)-px.begin();
			int ri2=lower_bound(py.begin(),py.end(),za[i][3]-1)-py.begin();
			for(int i=le1;i<=ri1;i++){
				for(int j=le2;j<=ri2;j++){
					field[i][j]=true;
				}
			}
	}
	int ans=0;
	for(int i=0;i<px.size();i++){
		for(int j=0;j<py.size();j++){
			if(!field[i][j]){
				ans++;
				field[i][j]=true;
				queue<P>que;
				que.pu(mp(i,j));
				int dx[4]={0,1,0,-1};
				int dy[4]={1,0,-1,0};
				while(!que.empty()){
					P p=que.front(); que.pop();
					int x=p.first;
					int y=p.second;
					for(int k=0;k<4;k++){
						int ax=x+dx[k];
						int bx=y+dy[k];
						if(ax>=0 && ax<px.size() && bx>=0 && bx<py.size()){
							if(!field[ax][bx]){
								que.push(mp(ax,bx));
								field[ax][bx]=true;
							}
						}
					}
				}
			}
		}
	}
	printf("%d\n",ans);
	}
}

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

int main(){
  int N;
  cin >> N;
  long a[N+1]={};
  a[0]=2;
  a[1]=1;
  for(int i=2;i<=N;i++){
    a[i] = a[i-1]+a[i-2];
  }
  cout << a[N] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <vector>
#include <queue>

using namespace std;
using ll = long long;
using pii = pair<ll, int>;
#define rep(i,n) for(int i=0;i<(n);++i)
#define out(v) cout<<v<<"\n"
const int INF = numeric_limits<int>::max();

int edge[10][10];
int dijkstra(int start, int end, int N) {
  ll cost[N];
  priority_queue<pii, vector<pii>, greater<pii> > q;
  fill(cost, cost + N, INF); cost[start] = 0;
  q.push(pii(0, start));

  while (!q.empty()) {
    pii p = q.top(); q.pop();
    int u = p.second;
    ll cur_cost = p.first;

    if (cost[u] < cur_cost)
      continue;
    rep(v, N) {
      if (edge[u][v] == INF)
        continue;
      if (cost[v] > cost[u] + edge[u][v]) {
        cost[v] = cost[u] + edge[u][v];
        q.push(pii(cost[v], v));
      }
    }
  }
  return cost[end];
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;

  int cost[10];
  rep(i, 10) rep(j, 10) cin >> edge[i][j];
  rep(i, 10) cost[i] = dijkstra(i, 1, 10);

  int ans = 0;
  rep(i, H) rep(j, W) {
    int a; cin >> a;
    if (a != -1)
      ans += cost[a];
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    ll ans = LONG_LONG_MAX;
    rep(i, 100) {
        ll tmp = 0;
        rep(j, n) {
            tmp += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


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

const long long MOD = 1000000007;
typedef long long LL;
LL mof = MOD;
inline LL pow_mod(LL a,LL k,LL mo)
{
    LL ans=1;
    while(k)
    {
        if(k%2) ans=ans*a%mo;
        a=a*a%mo;
        k>>=1;
    }
    return ans%mo;
}
const int maxn = 2e5+7;
LL jc[maxn+7];
inline LL inv(LL x)
{
    return pow_mod(x,mof-2,mof);
}
LL Inv[maxn+7];
LL C(LL N,LL k)
{
    if(k>N||k<0)return 0;
    if(k==0||k==N)return 1;
    LL ans=1;
    ans=ans*jc[N]*Inv[k]%mof*Inv[N-k]%mof;
    return ans;
}
void init()
{
    jc[1]=jc[0]=1;
    for(LL i=2; i<=maxn; ++i) jc[i]=jc[i-1]*i%mof;
    for(int i=0; i<=maxn; ++i) Inv[i]=inv(jc[i]);
}
void solve(long long n, long long k){
    if(k >= n) k = n-1;
    LL ret = 0;
    for(int i=k;i>=0;--i)
    {
        ret += C(n,i)*C(n-1,n-i-1) % MOD;
        ret %= MOD;
    }
    cout<< ret << endl;
}

int main(){
    init();
    long long n;
    scanf("%lld",&n);
    long long k;
    scanf("%lld",&k);
    solve(n, k);
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> G, rG;
	G.resize(n);
	rG.resize(n);
	rep(i, 0, m){
		ll x, y;
		cin >> x >> y;
		G[x-1].push_back(y-1);
		rG[y-1].push_back(x-1);
	}
	
	ll dp[n];
	memset(dp, 0, sizeof(dp));
	queue<ll> q;
	rep(i, 0, n){
		if(rG[i].size() == 0){
			q.push(i);
		}
	}
	
	ll cnt[n];
	memset(cnt, 0, sizeof(cnt));
	while(!q.empty()){
		ll at = q.front(); q.pop();
		rep(j, 0, G[at].size()){
			dp[G[at][j]] = max(dp[at]+1, dp[G[at][j]]);
			cnt[G[at][j]]++;
			if(cnt[G[at][j]] == rG[G[at][j]].size()){
				q.push(G[at][j]);
			}
		}
	}
	
	ll ans = 0;
	rep(i, 0, n){
		ans = max(dp[i], ans);
	}
	print(ans)
	//printa(dp, 0, n-1)
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
using namespace std;
int main(){
    long s;
    cin >> s;

    s = s%10;
    
    if(s == 3){
        cout << "bon" << endl;
    }else if (s == 0 || s == 1 || s == 6 || s == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3660
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    ans = [0] * (N - K)
    for i in range(N - K):
        if A[i] < A[K + i]:
            ans[i] = "Yes"
        else:
            ans[i] = "No"

    print("\n".join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 31744
#include <iostream>
using namespace std;
 
int main() {

    int S,h,m;
    
    cin >> S;

    h = S / (60 * 60);
    S %= 60 * 60;
    m = S / 60;
    S %= 60;
    
    cout << h << ":" << m << ":" << S << endl;
    
}


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

void Counting_Sort(int*, int*, int);

int n;
main(){
  int i,*A,*B,k=0;

  scanf("%d",&n);
  A=(int *)malloc(sizeof(int)*(n+1));
  B=(int *)malloc(sizeof(int)*(n+1));
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];
  }
  Counting_Sort(A,B,k);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i<n)printf(" ");
  }
  printf("\n");
  return 0;
}

void Counting_Sort(int *A, int *B, int k){
  int i,j,*C;
  C=(int *)malloc(sizeof(int)*(n));

  for(i=0;i<=k;i++){
    C[i]=0;
  }
  
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=k;i++){
    C[i]+=C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16276
// abc056_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int W, a, b;
    cin >> W >> a >> b;
    if (a > b) swap(a, b);
    int ans = max(0, b - (a + W));
    print(ans);


    return 0;
}


Measured memory_bytes: 256
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
int n,A[maxn];
int main() {
	n=read();
	rep(i,1,n) A[i]=read();
	sort(A+1,A+n+1);
	reverse(A+1,A+n+1);
	rep(x,0,n) if(x+1==n||A[x+2]<=x+1) {
		rep(i,x+1,n+1) if(A[i]<=x) {
			if((i-x-1)%2==1&&(A[x+1]-x)%2==1) puts("Second");
			else puts("First");
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 640