akhauriyash/Code-Regression huggingface dataset:
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b, c, d = map(int, input().split())

print(((b - (b // c + b // d - b // lcm(c,d)))) - ((a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d))))

Measured memory_bytes: 5048
n = int(input())

l = list(map(int, input().split()))

if len([i for i in l if i < 0]) % 2 == 0:
  data = [abs(x) for x in l]
  print(sum(int(i) for i in data))
else:
  data = [abs(x) for x in l]
  print(sum(int(i) for i in data) - 2*min(data))

Measured memory_bytes: 14412
N,K = map(int, input().split())
S = input()
k = 0
for i in range(N):
    if i != N-1 and S[i] == 'R' and S[i] == S[i+1]:
        k += 1
    elif i != 0 and S[i] == 'L' and S[i] == S[i-1]:
        k += 1
k = k + 2*K
if k > N-1:
    print(N-1)
else:
    print(k)

Measured memory_bytes: 40176
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    for d in range(ct, D):
        if d != ct and T[d] == prei:
            break
        score += C[prei]*(d + 1 - ct - 1)
        score -= C[prei]*(d + 1 - last[prei])
    for d in range(ct, D):
        if d != ct and T[d] == ci:
            break
        score += C[ci]*(d + 1 - last[ci])
        score -= C[ci]*(d + 1 - ct - 1)
    T[ct] = ci
    return score, T


def evaluate(D, C, S, T, k):
    """
    d日目終了時点での満足度を計算し，
    d + k日目終了時点での満足度の減少も考慮する
    """
    score = 0
    last = [0]*26
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]

    for d in range(len(T), min(len(T) + k, D)):
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
    return score


def greedy(D, C, S):
    Ts = []
    for k in range(5, 10):
        T = []  # 0-indexed
        max_score = -INF
        for d in range(D):
            # d+k日目終了時点で満足度が一番高くなるようなコンテストiを開催する
            max_score = -INF
            best_i = 0
            for i in range(26):
                T.append(i)
                score = evaluate(D, C, S, T, k)
                if max_score < score:
                    max_score = score
                    best_i = i
                T.pop()
            T.append(best_i)
        Ts.append((max_score, T))
    return max(Ts, key=lambda pair: pair[0])


def local_search(D, C, S, score, T):
    ct = randint(0, D-1)
    ci = randint(0, 25)
    for _ in range(400000):
        new_score, new_T = update_score(D, C, S, T, score, ct, ci)
        if score < new_score:
            score = new_score
            T = new_T
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    init_score, T = greedy(D, C, S)
    T = local_search(D, C, S, init_score, T)
    for t in T:
        print(t+1)


Measured memory_bytes: 84548
n = int(input())
dp = [n]*(n+10)
dp[0] = 0
dp[1] = 1
for i in range(2, n+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i], 1 + dp[i-power])
        power *= 6
    power = 9
    while power <= i:
        dp[i] = min(dp[i], 1 + dp[i - power])
        power *= 9
print(dp[n])


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

int otakTakeshi;
string input, tambah="+";

int main (){
    cin>>input;
    for (int i=0; i<=3; i++){
        if (input [i]==tambah [0]){
            otakTakeshi++;
        } else {
            otakTakeshi--;
        }
    }
    cout<<otakTakeshi<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int h,m,s,jikoku,sum=0,maxi=0;
		int imos[250000]={0};
		REP(i,0,N){
			scanf("%2d:%2d:%2d",&h,&m,&s);
			jikoku=h*10000+m*100+s;
			imos[jikoku+1]++;
			scanf("%2d:%2d:%2d",&h,&m,&s);
			jikoku=h*10000+m*100+s;
			imos[jikoku+1]--;
		}

		REP(i,0,250000){
			sum+=imos[i];
			maxi=max(maxi,sum);
		}

		p(maxi);
	}

	return 0;
}

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

using namespace std;

using ll = long long;
using ii = std::pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>; //vector<vector<int>>
using vs = vector<string>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() 
#define sz(x) (int)((x).size())
#define arrsz(x) (int) (sizeof((x))/sizeof((x)[0]))

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

/* Usage: output_vector(solution), which prints elements with spaces and then new line*/
template<typename T>
void output_vector(const vector<T> &v, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] << " ";
    cout << endl;
}
// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int main()
{
  long long n, k;
  cin >> n;
  long long total = 0;
  unordered_map<int, int> counts;
  for (int i = 0; i < n; i++)
  {
    long long num;
    cin >> num;
    total += num;
    counts[num]++;
  }
  long long q;
  cin >> q;
  for (int j = 0; j < q; j++)
  {
      long long b, c;
      cin >> b >> c;
      total += counts[b] * (c-b);
      int val = counts[b];
      counts.erase(b);
      counts[c] += val;
      cout << total << endl;
  }
}
   

Measured memory_bytes: 6672
#include<bits/stdc++.h>
using namespace std;
void topo(int x,vector<vector<int> > &v,int* path)
{
  if(path[x]>=0) return;
  path[x]=0;
  for(int i=0;i<v[x].size();i++)
  {
    int u=v[x][i];
      topo(u,v,path);
	path[x]=max(path[x],path[u]+1);	
  }
}
int main()
{
  int n;
  cin>>n;
  int m;
  cin>>m;
  vector<vector<int> > v;
  for(int i=0;i<n;i++)
  {
    vector<int> r;
    v.push_back(r);
  }
	for(int i=0;i<m;i++)
    {
      int x,y;
      cin>>x>>y;
      v[x-1].push_back(y-1);
    }
   int path[n];
  memset(path,-1,sizeof(path));
  	for(int i=0;i<n;i++)
    {
      if(path[i]<0)
  		topo(i,v,path);
     }
  int ans=0;
     for(int i=0;i<n;i++)
     {
       ans=max(ans,path[i]);
     }
  cout<<ans;
}

Measured memory_bytes: 8816
H, W = map(int, input().split())
maze = []
for _ in range(H):
    maze.append([i for i in input()])
    
dp = [[0 for _ in range(W)] for _ in range(H)]

dp[0][0] = 1 if maze[0][0] == "#" else 0

for i in range(1, H):
    dp[i][0] = dp[i - 1][0] if maze[i][0] == maze[i - 1][0] else dp[i - 1][0] + 1 if maze[i][0] == "#" else dp[i - 1][0]

for i in range(1, W):
    dp[0][i] = dp[0][i - 1] if maze[0][i] == maze[0][i - 1] else dp[0][i - 1] + 1 if maze[0][i] == "#" else dp[0][i - 1]


for h in range(1, H):
    for w in range(1, W):
        cand_1 = dp[h - 1][w] if maze[h][w] == maze[h - 1][w] else dp[h - 1][w] + 1 if maze[h][w] == "#" else dp[h - 1][w]
        cand_2 = dp[h][w - 1] if maze[h][w] == maze[h][w - 1] else dp[h][w - 1] + 1 if maze[h][w] == "#" else dp[h][w - 1]
        dp[h][w] = min(cand_1, cand_2)

print(dp[H - 1][W - 1])

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {};
    ll z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n); reverse(a, a + n);
    for (int i = 1; i < n; i++) z += a[i / 2];
    cout << z;
}


Measured memory_bytes: 4464
n = int(input())
a = input().split() #食べた順番
b = input().split() #満足度
c = input().split() #追加満足度

x = 0 #合計満足度
p = 0 #今回食べている料理の番号
j = -2 #一個前に食べた料理の番号

for i in range(n):
  p = int(a[i]) - 1
  x += int(b[p])
  if j + 1 == p:
    x += int(c[j])
  j = p

print(x)

Measured memory_bytes: 3060
N = int(input())
a_list = [int(a) for a in input().split()]

if a_list[0] > 1:
    print(-1)
    exit()

ans = 1
temp1 = [""]*(N+1)
temp1[-1] = a_list[-1]
for n in range(N-1, 0, -1):
    temp1[n] = temp1[n+1]+a_list[n]
    
temp2 = 1
for n in range(1, N+1):
    temp2 = (temp2-a_list[n-1])*2
#     print(temp2, temp1[n])
    ans_temp = min(temp2, temp1[n])
    temp2 = min(temp2, temp1[n])
    
    if ans_temp < a_list[n]:
        print(-1)
        exit()
    
    ans += ans_temp
    
print(ans)

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

using namespace std;
typedef long long ll;

int n, m;
int x, a[10];
int cost[10] = {0,2,5,5,4,5,6,3,7,6};
pair < int , int> dp[10010][5000];
pair < int , int> f(int rem, int dig)
{
    if (rem < 0) return {-1e9, 0};
    if (!rem) return {dig, 0};
    pair<int, int> &ret = dp[rem][dig];
    if (~ret.first) return ret;
    int i;
    for (i = 9 ; i ; --i)
        if (a[i])
        {
            auto it = f(rem-cost[i], dig+1) ;
            if (it.first > ret.first)
                ret = {it.first, i};
        }
    return ret;
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i)
        scanf("%d", &x), a[x] = 1;
    memset(dp, -1, sizeof dp);
    f(n, 0);
    int dig = 0;
    while (n)
    {
        printf("%d", dp[n][dig].second);
        n -= cost[dp[n][dig].second];
        ++dig;
    }
    puts("");

    return 0;
}


Measured memory_bytes: 391680
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
 
#define FOR(i,a) for(int i=0;i<a;i++)
#define MOD 1000000007LL
 
 
int main(){
	long long int a,b,n;
	cin>>n>>a>>b;
	if((b-a)%2LL==0){cout<<(b-a)/2LL<<endl;}
	else{
 		cout<<min(a/2+b/2,(n-a)/2+(n-b)/2+1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
l = [int(x) for x in input().split()]
A, B, C, K = l[0], l[1], l[2], l[3]
ans = 0
while K > 0:
    if A > 0:
        if A > K:
            ans += K
            K = 0
        else:
            ans += A
            K -= A
            A = 0
    elif B > 0:
        if B > K:
            K = 0
        else:
            K -= B
            B = 0
    else:
        ans -= K
        K = 0
print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

const int N=105;
char a[N][N];

int main()
{
    fastio;
    int n,m;cin>>n>>m;
    ll dp[N][N];

    rep(i,0,N)rep(j,0,N)a[i][j]='#';
    a[0][1]=a[1][0]='.';
    rep(i,1,n+1)rep(j,1,m+1)cin>>a[i][j];

    rep(i,0,N)rep(j,0,N)dp[i][j]=dp[i][j]=1e9;
    dp[1][0]=dp[0][1]=0;

    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            if(a[i][j]=='#')
                dp[i][j]=min(dp[i][j-1] + (a[i][j-1]=='.'),dp[i-1][j] + (a[i-1][j]=='.'));
            else
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
        }
    }
    cout<<dp[n][m];
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 1000000
 
int a[N];
int main() {
    int n;
    a[1] = 1;
    for(int i=2; i*i<=N; i++) {
        if(a[i]) continue;
        for(int j=2; i*j<=N; j++)
            a[i*j] = 1;
    }
    for(int i=1; i<N; i++)
        a[i] = a[i-1] + !a[i];
    while(scanf("%d", &n) != EOF)
        printf("%d\n", a[n]);
}



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

int main(){
    char c;
    cin >> c;
    
    if((c == 'a')||(c == 'i')||(c == 'u')||(c == 'e')||(c == 'o')){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
import sys
import numpy as np

n, *aaa = map(int, sys.stdin.buffer.read().split())
aaa = [a for a in aaa if a != 0]

fft_len = 1 << 19

P = 200003
PR = 2
convert = [0] * P
rev_con = [0] * P
rev_con[0] = 1
tmp = 1
for i in range(1, P):
    tmp = tmp * PR % P
    convert[tmp] = i
    rev_con[i] = tmp

self_pair_products = 0
f = np.zeros(P)
for a in aaa:
    f[convert[a]] += 1
    self_pair_products += a * a % P

Ff = np.fft.rfft(f, fft_len)
Fff = Ff * Ff
g = np.rint(np.fft.irfft(Fff, fft_len))

g[:P - 1] += g[P - 1:2 * (P - 1)]
g[:fft_len - 2 * (P - 1)] += g[2 * (P - 1):]
g = g[:P - 1].astype(np.int64)
rev_con = np.array(rev_con[:-1])

ans = (g * rev_con).sum() - self_pair_products
print(ans // 2)


Measured memory_bytes: 76740
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/












int LIM = 10;
int N, V[1 << 19], W[1 << 19], Q;
//---------------------------------------------------------------------------------------------------
vector<pair<int, int>> memo[1 << 18];
void naive(int cu, vector<int>& arr) {
	if (memo[cu].size() != 0) return;

	int n = arr.size();
	map<int, int> dp;
	rep(msk, 0, 1 << n) {
		int val = 0, wei = 0;
		rep(i, 0, n) if (msk & (1 << i)) {
			val += V[arr[i]];
			wei += W[arr[i]];
		}
		chmax(dp[wei], val);
	}

	fore(p, dp) memo[cu].push_back(p);
	int ma = -inf;
	fore(p, memo[cu]) {
		chmax(ma, p.second);
		p.second = ma;
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 1, N + 1) cin >> V[i] >> W[i];
	cin >> Q;
	rep(_, 0, Q) {
		int v, L; cin >> v >> L;
		
		int v2 = v;
		vector<int> arr;
		while (1 <= v2) {
			arr.push_back(v2);
			v2 /= 2;
		}

		int n = arr.size();
		if (n <= LIM) {
			naive(v, arr);

			int ans = 0;
			auto idx = upper_bound(all(memo[v]), make_pair(L, inf)) - memo[v].begin();
			if (0 < idx) {
				ans = memo[v][idx - 1].second;
			}
			printf("%d\n", ans);
		}
		else {
			vector<int> arr2;
			rep(i, n - LIM, n) arr2.push_back(arr[i]);
			int p = arr[n - LIM];
			naive(p, arr2);

			int m = n - LIM;
			int ans = 0;
			rep(msk, 0, 1 << m) {
				int val = 0, wei = 0;
				rep(i, 0, m) if (msk & (1 << i)) {
					val += V[arr[i]];
					wei += W[arr[i]];
				}

				auto idx = upper_bound(all(memo[p]), make_pair(L - wei, inf)) - memo[p].begin();
				if (0 < idx) chmax(ans, memo[p][idx - 1].second + val);
			}
			printf("%d\n", ans);
		}

	}
}







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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    vector<vector<int> > grid(a, vector<int>(b));
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            char c;
            cin >> c;
            grid[i][j] = (c == '#');
        }
    }
    vector<int> col (b, 1);
    vector<int> row(a, 1);
        for (int i = 0; i < grid.size(); i++) {
            int ta = 0;
            for (int j = 0; j < grid[i].size(); j++) {
                ta += grid[i][j];
            }
            if ( ta == 0) {
                    row[i] = 0;
            }
        }
        for (int i = 0; i < grid[0].size(); i++) {
            int ta = 0;
            for (int j = 0; j < grid.size(); j++) {
                ta += grid[j][i];
            }
            if (ta == 0) {
                col[i] = 0;
            }
        }
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            if (row[i] && col[j])
                if (grid[i][j] == 1)
                    cout << '#';
                else
                    cout << '.';
    }   if(!row[i])
            continue;
        cout << endl;
    }
}


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

#define maxn 500010
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()

int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int sum,a[maxn];
int main() {
	int n=rd,m=rd;
	fo(i,1,n) {
		a[i]=rd;
		sum+=a[i];
	}
	sort(a+1,a+n+1);
	int x=m-sum;
	printf("%d\n",x/a[1]+n);
	return 0;
}

Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_3-C: Doubly Linked List

#include <cassert>
#include <cstdio>

template <typename T>
class doubly_linked_list {
  struct node {
    node* prev_;
    node* next_;
    T x_;
  };
  node sentinel_;
public:
  doubly_linked_list() {
    sentinel_.prev_ = sentinel_.next_ = &sentinel_;
  }
  void insert_elem_to_first(const T& x) {
    node* np = new node();
    np->x_ = x;
    np->prev_ = &sentinel_;
    np->next_ = sentinel_.next_;
    np->prev_->next_ = np;
    np->next_->prev_ = np;
  }
  void delete_first_elem(const T& x) {
    delete_node(search_first_elem(x));
  }
  void delete_first_node() {
    delete_node(sentinel_.next_);
  }
  void delete_last_node() {
    delete_node(sentinel_.prev_);
  }
private:
  void delete_node(node* np) {
    if (np == &sentinel_) {
      return;
    }
    np->next_->prev_ = np->prev_;
    np->prev_->next_ = np->next_;
    delete np;
  }
  node* search_first_elem(const T& x) const {
    node* np = sentinel_.next_;
    for (;np != &sentinel_; np = np->next_) {
      if (np->x_ == x) break;
    }
    return np;
  }
public:
  void print(const char* sep=" ") const {
    const char* out_sep = "";
    for (const node* np = sentinel_.next_; np != &sentinel_; np = np->next_) {
      printf("%s%d", out_sep, np->x_);
      out_sep = sep;
    }
    puts("");
  }
};

int main(void) {
  unsigned int n;
  std::scanf("%d", &n);
  doubly_linked_list<int> list;

  for (auto i = 0U; i < n; ++i) {
    char buf[11+1]; // max_length == "deleteFirst".size()+1('\0')
    int x;
    std::scanf("%11s", buf);
    if (buf[0] == 'i') { // insert x
      std::scanf("%d", &x);
      list.insert_elem_to_first(x);
    } else if (buf[6] == 'F') { // deleteFirst
      list.delete_first_node();
    } else if (buf[6] == 'L') { // deleteLast
      list.delete_last_node();
    } else { // (buf[6] == '\0') // delete x 
      std::scanf("%d", &x);
      list.delete_first_elem(x);
    }
  }
  list.print();

  return 0;
}
// end

Measured memory_bytes: 33856
# coding: utf-8
# Your code here!
H,W = list(map(int,raw_input().split()))
field = []
answer = "Yes"
for i in range (H):
    li = list(raw_input().strip())
    field.append(li[:])
def check(a,b):
    if field[a][b] ==".":
        return True
    check_li = [[a-1,b],[a+1,b],[a,b+1],[a,b-1]]
    check_li = filter(lambda x: 0 <= x[0] <= H-1 and 0<= x[1] <=W-1,check_li )
    for i in check_li:
        if field[i[0]][i[1]] == "#":
            return True
            break
    else:
        return False

for i in range (H):
    for j in range (W):
        if check(i,j) == False:
            answer = "No"
            break
print answer




        

Measured memory_bytes: 2692
//packages
#include <bits/stdc++.h>//C++14 GCC mode!!!
//alias and namespaces
using namespace std;
//macros
#define REP(i,O,N) for(int i=O;i<N;i++)//うーん、python同様にRange関数でも実装してしまおうかしら…？
#define rep(i,N) for(int i=0;i<N;i++)
#define all(v) v.begin(),v.end()//v.end()-i は[-i]相当
#define debug(x) cerr<< #x <<":"<<x<<endl;
#define v(type) std::vector<type>
#define v2(type)  std::vector<std::vector<type>>
#define v3(type)  std::vector<std::vector<std::vector<type>>>
//functions   



//solution
long sol(int N){
    v2(int) ab;
    
    rep(i,N){
    v(int) temp(2);
    cin >> temp.at(0) >>temp.at(1);
    ab.push_back(temp);
    }
    int m=0;
    int t;
    rep(i,N){
        if (m<ab[i][0]){
            m=ab[i][0];
            t=i;
        }
    }
    
    return (ab[t][0]+ab[t][1]);
}
int main(void){
    //input
    int N;
    cin >>N;
    //output
    //cout<<((ans==1)?"Yes":"No")<<endl;//true to yes
    cout << sol(N)<<endl;//value
    //cout << ans<<endl;//other
    
}


Measured memory_bytes: 6836
#include<stdio.h>
#define COUNT_RESET 0
#define LOOP_RESET 0
#define ARRAY_RESET 0

void array_reset(unsigned char * array, unsigned short size);
unsigned short serch_word(unsigned char * word, unsigned char * sent);
unsigned short s_scan_word(unsigned char * str, unsigned short length_max);

int main(){
	unsigned char ubW_D_word[10];
	unsigned char ubW_D_sent[1000];
	unsigned short usW_D_word_length;
	unsigned short usW_D_sent_length;
	unsigned short usW_C_count = 0;
	unsigned char ubW_D_sentence_end[] = {"END_OF_TEXT\n"};
	unsigned short usW_C_i;
	
	array_reset(ubW_D_word, 10);
	array_reset(ubW_D_sent, 1000);
	
	usW_D_word_length = s_scan_word(ubW_D_word, 1000);
	
	while(1){
		usW_D_sent_length = s_scan_word(ubW_D_sent, 1000);
		if(serch_word(ubW_D_sentence_end, ubW_D_sent) == 1){
			break;
		}
		
		for(usW_C_i = 0;usW_C_i < usW_D_word_length;usW_C_i++){
			ubW_D_word[usW_C_i] |= 0x60;
		}
		for(usW_C_i = 0;usW_C_i < usW_D_sent_length;usW_C_i++){
			ubW_D_sent[usW_C_i] |= 0x60;
		}
		if(usW_D_word_length == usW_D_sent_length){
			usW_C_count += serch_word(ubW_D_word, ubW_D_sent);
		}
		array_reset(ubW_D_sent, usW_D_sent_length);
	}
	
	printf("%d\n", usW_C_count);
	return 0;
}

void array_reset(unsigned char * array, unsigned short size)
{
	unsigned short usW_C_i; 	/* ループ変数 */
	/* 配列の初期化 */
	for(usW_C_i = COUNT_RESET;usW_C_i < size;usW_C_i++){
		*(array + usW_C_i) = ARRAY_RESET;
	}
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short serch_word(unsigned char * word, unsigned char * sent)
{
	unsigned int usW_F_frg = 0;
	unsigned int usW_C_i = 0;
	while(1){
		if(*(word + usW_C_i) == '\n'){
			usW_F_frg =1;
		}
		if(*(word + usW_C_i) != *(sent + usW_C_i)){
			break;
		}
		usW_C_i++;
	}
	
	return usW_F_frg;
}


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

int main() {
  int N, K, ret;
  cin >> N >> K;
  ret = 1;
  for (int i = 0; i < N; i++) {
    if (ret + K > 2 * ret)
      ret *= 2;
    else
      ret += K;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
//author: dazhong_feliks

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

int main() {
  int a,b;
  cin >> a >> b ; 
 
  if ( a * b % 2 != 0 )
    { cout << " Odd" << endl;
    }
    
   else if ( a * b % 2 == 0 )
    { cout << " Even" << endl;
    }
}

Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0; lli sum = 0ll;
	cin >> n;
	vector<lli> a(3 * n);
	for (auto &i : a)
		cin >> i;
	sort(a.begin(), a.end());
	for (int i = n; i < 3 * n; i += 2)
		sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 5572
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
(N,M) = (int(i) for i in input().split(" "))
a,b = min(N,M),max(N,M)

while b%a != 0:
	a,b = b%a,a
print(N*M//a)


Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, D;
  cin >> N >> D;
  ll ans = 0;
  D *= D;
  for (ll i = 0; i < N; ++i) {
    ll X, Y;
    cin >> X >> Y;
    if (pow(X, 2) + pow(Y, 2) <= D) {
      ans += 1;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;

int main(){
	int N;
	scanf("%d",&N);
	ll l[N+1];
	l[0] = 2;
	l[1] = 1;
	FOR(i,2,N+1) l[i] = l[i-1] + l[i-2];
	printf("%lld",l[N]);
	return 0;
}


Measured memory_bytes: 256
def solve(items)
  max = items[-1]
  ans = -(10 ** 10)
  (items.size-2).downto(0) do |i|
    ans = ans < (v = (max - items[i])) ? v : ans
    max = max < items[i] ? items[i] : max
  end
  ans
end
puts solve(Array.new(gets.to_i) { gets.to_i })



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

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

    long long r, D, x;
    cin >> r >> D >> x;
    
    for (int i=0; i<10; ++i) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

 int n,A[MAX+1];

void maxHeapify(int i){

  int l,r,largest,a;
  l = 2 * i;
  r = 2 * i +1;

  if(l<=n && A[l] > A[i]) largest = l;
  else largest = i;

  if(r<=n && A[r] > A[largest]) largest = r;

  if(largest != i){
    a=A[i];
    A[i]=A[largest];
    A[largest]=a;
      maxHeapify(largest);
  }
}

int main(){

  int i;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);

  for(i=n/2;i>=1;i--) maxHeapify(i);

  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
import Foundation

let inputLine = readLine()!.components(separatedBy: " ").map({Int($0)!})
let N = inputLine[0]
let M = inputLine[1]

let inputLine2 = readLine()!.components(separatedBy: " ").map({Int($0)!})

let sumVotes = inputLine2.reduce(0){$0 + $1}
let popularItems = inputLine2.filter({$0*4*M >= sumVotes})

if popularItems.count >= M {
    print("Yes")
} else {
    print("No")
}

Measured memory_bytes: 14060
#include <iostream>

using namespace std;

int main(){
  string s;
  int n;
  cin >> s;
  n = s.length();
  if (s[0] == s[n-1]) {
    if (n % 2 == 0) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
  } else {
    if (n % 2 == 0) {
      cout << "Second" << endl;
    } else {
      cout << "First" << endl;
    }
  }
  return(0);
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll L;
std::vector<std::pair<P, ll>> ps;

int main()
{
  std::cin >> L;

  /*if( L == 2 )
  {
    std::cout << "2 2" << std::endl;
    std::cout << "1 2 0" << std::endl;
    std::cout << "1 2 1" << std::endl;

    return 0;
  }*/

  ll t = L;
  ll b = 0;

  while( t > 0 )
  {
    t >>= 1;
    ++b;
  }

  rep( i, b-1 )
  {
    ps.emplace_back( P( i+1, i+2 ), 1<<(b-i-2) );
    ps.emplace_back( P( i+1, i+2 ), 0 );
  }
  
  repd( i, b-1 ) if( L>>i&1 )
  {
    ll cost = ((L^(1<<i))>>i)<<i;

    ps.emplace_back( P( 1, b-i ), cost );
  }

  std::cout << b << ' ' << ps.size() << std::endl;

  for( auto p : ps )
    std::cout << p.first.first << ' ' << p.first.second << ' ' << p.second << std::endl;

  return 0;
}

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

main(){
  int a,b;
  cin >> a >> b;
  if(a<=5){
    cout << "0\n";
  }else if(a>=13){
    cout << b << '\n';
  }else{
    cout << b/2 << '\n';
  }
  return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}
template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

struct UF
{
    vi par, sizes;

    UF() {}
    UF(int size) : par(size, -1), sizes(size, 1) {
	rep(i, size) par[i] = i;
    }

    int root(int x)
    {
	return par[x] == x ? x : par[x] = root(par[x]);
    }

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

    int size(int x)
    {
	return sizes[root(x)];
    }

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

	if(x == y) return ;

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

llint n, m;
int a[100001];
int b[100001];

int main()
{
    ci >> n >> m;
    rep(i, m) ci >> a[i] >> b[i];

    vl v;
    
    UF uf(n + 1);
    llint sum = n * (n - 1) / 2;

    for(int i = m - 1; i >= 0; i--) {
	v.push_back(sum);
	
	if(!uf.same(a[i], b[i])) {
	    sum -= uf.size(a[i]) * uf.size(b[i]);
	    uf.unite(a[i], b[i]);
	}
    }

    for(int i = v.size() - 1; i >= 0; i--) co << v[i] << en;

    return 0;
}


Measured memory_bytes: 3828
import std.conv;
import std.string;
import std.algorithm;
import std.array;
import std.stdio;

void main() {
	auto s = readln.chomp;
	auto t = readln.chomp;
	
	uint a;
	foreach (i;0..s.length) {
		if (s[i] != t[i]) {
			++a;
		}
	}

	a.writeln;
}


Measured memory_bytes: 3056
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

type point struct {
	x, l, r int
}

type ps []point

func (p ps) Len() int {
	return len(p)
}
func (p ps) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p ps) Less(i, j int) bool {
	return p[i].r < p[j].r
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	points := make([]point, N)
	for i := 0; i < N; i++ {
		points[i].x = nextInt(sc)
		L := nextInt(sc)
		points[i].l = points[i].x - L
		points[i].r = points[i].x + L
	}
	sort.Sort(ps(points))
	// 区間スケジューリング問題に帰着する
	start := points[0].r
	ans := 1
	for i := 0; i < len(points); i++ {
		if points[i].l < start {
			continue
		}
		start = points[i].r
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <time.h>
#include <assert.h>


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll n;
    cin>>n;
    ll val = n/1000;
    if(n%1000 == 0){
        cout<<0;
        return 0;
    }    
    val++;
    val *= 1000;
    cout<<val-n;
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
l,r = map(int, input().split())
MOD = 2019

if r - l >= MOD:
    print(0)
else:
    min = MOD
    for i in range(l, r):
        if min == 0: break
        for j in range(i+1, r+1):
            im, jm = i % MOD, j % MOD
            val = (im * jm) % MOD
            if val < min:
                min = val
    print(min)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
bool dp[81][321][321];
int L;
int t[80];

int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>L;
    for(int i=0;i<L;i++)cin>>t[i];
    if(L==1){
      cout<<t[0]<<endl;
      continue;
    }else if(L==2){
      cout<<t[1]<<endl;
      continue;
    }

    for(int i=0;i<=80;i++)
      for(int j=0;j<=320;j++)
        for(int k=0;k<=320;k++)
          dp[i][j][k]=false;

    dp[1][t[0]][t[1]]=true;
    for(int i=1;i+1<L;i++){
      for(int j=0;j<=320;j++){
        for(int k=0;k<=320;k++){
          if(dp[i][j][k]){
            if(k)dp[i+1][k-1][j+t[i+1]]=true;
            dp[i+1][k][t[i+1]]=true;
          }
        }
      }
    }

    int ans=t[L-1];
    for(int i=0;i<=320;i++){
      for(int j=1;j<=320;j++){
        if(dp[L-2][i][j]){
          ans=max(ans,t[L-1]+i);
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

typedef long long ll;
int N, M;
int A[100010];
int B[100010];
ll dp[2010][2010];
ll mod = 1000000007;

int main()
{
    cin >> N >> M;
    for(int i = 0; i < N; i++)cin >> A[i + 1];
    for(int i = 0; i < M; i++)cin >> B[i + 1];

    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= M; j++)
        {
            if(i == 0 || j == 0)
            {
                dp[i][j] = 1;
                continue;
            }
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mod) % mod;
            if(A[i] == B[j])dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % mod;
        }
    }

    cout << dp[N][M] << endl;
    return 0;
}


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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
string s;
cin>>s;
if(s[2]==s[3]&&s[4]==s[5])
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

}

Measured memory_bytes: 3588
#include <iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
int main (void) {
    int w,h,n,mx=0,Mx,my=0,My,x,y,a;
    cin >> w >> h >> n;
    Mx = w;
    My = h;
    while(n--){
        cin >> x >> y >> a;
        if(a==2){
            Mx=min(Mx,x);
        }
        else if(a==1){
            mx=max(mx,x);
        }
        else if(a==4){
            My=min(My,y);
        }
        else{
            my=max(my,y);
        }
    }
    if(mx>Mx||my>My)    cout << "0\n";
    else    cout << (Mx-mx)*(My-my) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	bool first = true;
	char str[2048];
	fgets(str, 2048, stdin);
	rep(i, strlen(str)){
		if(str[i] == '.' || str[i] == ',')
			str[i] = ' ';
	}

	int offset = 0;
	char word[2048];
	while(sscanf(str+offset, "%s", word) != EOF){
		int n = strlen(word);
		if(3<=n && n<=6){
			printf("%s%s", first?"":" ", word);
			first = false;
		}
		offset += n + 1;
	}
	puts("");

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
#define MAX 10000
#define NIL -1
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, y, a = -1, b = -1, c = -1, k;
    cin >> n >> y;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            k = n - (i+j);
            if (k >= 0) {
                if (y == i*10000+j*5000+k*1000) {
                    a = i;
                    b = j;
                    c = k;
                    break;
                }
            }
        }
    }

    printf("%d %d %d\n", a, b, c);
}

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

A = []
i = 1
j = 0
while j != N:
    if a[j] == i:
        i += 1
    j += 1
else:
    if i == 1:
        print(-1)
    else:
        print(N-(i-1))

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

typedef long long ll;

using namespace std;

void solve() {
    int n, w;

    cin >> n >> w;
    vector<int> weight(n);
    vector<int> value(n);
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> value[i];
    }

    //vector< vector<ll> > dp(n+1, vector<ll>(w+1, 0));
    vector<ll> dp(w+1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = w; j >= 1; j--) {
            if (weight[i-1] <= j) 
                dp[j] = max(dp[j], value[i-1] + dp[j-weight[i-1]]);
        }
        //for (int j = 1; j <= w; j++) {
        //    dp[i][j] = dp[i-1][j];
        //    if (weight[i-1] <= j) {
        //        dp[i][j] = max(dp[i][j], value[i-1] + dp[i-1][j-weight[i-1]]);
        //    }
        //}
    }

    //cout << dp[n][w] << endl;
    cout << dp[w] << endl;
}


int main() {
    solve();
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	boolean[][] map;

	void solve() {
		int[] ia = readNums();
		int h = ia[0];
		int w = ia[1];
		map = new boolean[h + 2][w + 2];
		for (int i = 1; i <= h; i++) {
			String line = readLine();
			if (line == null)
				break;
			for (int j = 1; j <= w; j++) {
				if (line.charAt(j - 1) == '#') {
					map[i][j] = true;
				}
			}
		}
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (map[i][j])
					p("#");
				else
					p(count9(i, j));
			}
			pln("");
		}
	}

	int count9(int y, int x) {
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			ans += count(y - 1, x - 1 + i);
			ans += count(y + 1, x - 1 + i);
		}
		ans += count(y, x - 1);
		ans += count(y, x + 1);
		return ans;
	}

	int count(int y, int x) {
		if (map[y][x])
			return 1;
		return 0;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

string S;
vector<int> posL,posR;
int ans[100005];

signed main(){
    cin>>S;
    for(int i=0;i<S.size();++i){
        if(S[i]=='L')posL.push_back(i);
        else posR.push_back(i);
    }
    for(int i=0;i<S.size();++i){
        if(S[i]=='R'){
            int id=lower_bound(posL.begin(),posL.end(),i)-posL.begin();
            int h=posL[id]-i;
            if(h%2==0)ans[i+h]++;
            else ans[i+h-1]++;
        }
        else {
            int id=lower_bound(posR.begin(),posR.end(),i)-posR.begin()-1;
            int h=i-posR[id];
            if(h%2==0)ans[i-h]++;
            else ans[i-h+1]++;
        }
    }
    for(int i=0;i<S.size();++i)cout<<ans[i]<<" ";
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N;
    cin >> N;
    vector<ll> H(N);
    repi(i, N, 0)
    {
        cin >> H[i];
    }
    ll ans = 0;
    ll cnt = 0;
    repi(i, N - 1, 0)
    {

        if (H.at(i + 1) - H.at(i) > 0)
        {
            // cout << "continue" << endl;
            continue;
        }
        else
        {
            ll j = i;
            while (true)
            {
                // cout << "j" << j << endl;
                if (H.at(j + 1) - H.at(j) <= 0)
                {
                    cnt++;
                    // cout << "cnt" << endl;
                }
                else
                {
                    i = j - 1;
                    break;
                }
                j++;
                if (j > N - 2)
                {
                    i = j - 1;
                    break;
                }
            }
            // cout << "i" << i << endl;
            // cout << "cnt" << cnt << endl;
            ans = max(ans, cnt);
            cnt = 0;
            // cout << ans << endl;
        }
    }

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

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

int H, W;
char maze[30][30];
int masu(int x, int y) {
  return x * W + y;
}
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int bfs(int a) {
  queue<int> q;
  vector<int> L(H * W, -1);
  q.push(a);
  L[a] = 0;
  while (q.size()>0) {
    int c = q.front();
    int x = c / W;
    int y = c - W * x;
    for (int i = 0; i < 4; i++) {
      if (x+dx[i]<0||x+dx[i]>=H||y+dy[i]<0||y+dy[i]>=W||maze[x+dx[i]][y+dy[i]]=='#') {
        continue;
      }
      else if (L[masu(x+dx[i], y+dy[i])]!=-1) {
        continue;
      }
      else {
        q.push(masu(x+dx[i], y+dy[i]));
        L[masu(x+dx[i], y+dy[i])] = L[masu(x, y)] + 1;
      }
    }
  q.pop();
  }
  int M = 0;
  for (int i = 0; i < H*W; i++) {
    M = max(M, L[i]);
  }
  return M;
}

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
    }
  }
  int m = 0;
  for (int i = 0; i < H*W; i++) {
    if (maze[i/W][i-(i/W)*W] != '#') {
      m = max(bfs(i), m);
    }
  }
  cout << m <<endl;
}

Measured memory_bytes: 256