akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node{
	int key;
	struct Node *l, *r, *p;
};

struct Node *root, *NIL;

struct Node * find(struct Node *u,int k){
  while(u != NIL && k != u->key){
    if(k < u->key)u=u->l;
    else u=u->r;
  }
  return u;
}

void insert(int v){
struct Node *y = NIL;
struct Node *x = root;
struct Node *z;

z = (struct Node *)malloc(sizeof(struct Node));
z->key = v;
z->l = NIL;
z->r = NIL;

while(x != NIL){
y = x;
if( z->key < x->key ){
	x = x->l;
	}
else{
x = x->r;
	}
}
z->p = y;
if(y == NIL){
	root = z;
}
else if(z->key < y->key){
	y->l =z;
}
else{
	y->r =z;
}
}

void Iorder(struct Node *u){
	if(u == NIL){
		return;
	}
	Iorder(u->l);
	printf(" %d", u->key);
	Iorder(u->r);
}
void Porder(struct Node *u){
	if(u == NIL){
		return;
	}
	printf(" %d", u->key);
	Porder(u->l);
	Porder(u->r);
}

int main(){
	int n,i,v;
  struct Node *t;
	char *sent = malloc(7);
char *s1 = "insert";
char *s2 = "print";

	scanf("%d",&n);

	for(i = 0;i <n;i++){

		scanf("%6s",sent);
    if(sent[0] == 'f'){
      scanf("%d",&v);
      t = find(root,v);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
		else if(0==strcmp(sent,s1)){
			scanf("%d", &v);
			insert(v);
		}
		else if(0==strcmp(sent,s2)){
			Iorder(root);
			printf("\n");
			Porder(root);
			printf("\n");
		}
	}

return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n) {
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n << ":" << endl;
	for (int i = 2; i <= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/


signed main() {
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;

	endre;
}


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

int main()
{
	int n;
	cin >> n;

	vector<int> v;
	bool odd = false;
	for (int i = 0; i < n; ++i)
	{
		int num;
		cin >> num;
		if (num < 0)
		{
			odd = !odd;
			num *= -1;
		}
		v.push_back(num);
	}

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

	if (odd)
	{
		v[0] *= -1;
	}

	int64_t max = 0;
	for (int i = 0 ; i < n; ++i)
	{
		max += v[i];
	}

	cout << max;
	return 0;
}

Measured memory_bytes: 892
a, b, k = map(int, input().split())

if (b-a +1) <= 2 * k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)

Measured memory_bytes: 9068
io = STDIN
n,l=io.gets.split.map(&:to_i)
#Σ l+0,l+1,l+2,,,l+(n-1)
#l*n+(n-1)n/2
sum=l*n+(n-1)*n/2
if l<=0 && l+n-1>=0
  puts sum
elsif l>0
  puts sum-l
else      # 1+(n-1) < 0
  puts sum-(l+(n-1))
end


Measured memory_bytes: 1916
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto X=vecin(N);
	auto maxX=*max_element(ALL(X));
	int minR = maxX,maxV;
	REP(i,N){
		if(X[i]==maxX) continue;
		int v=abs(maxX/2-X[i]);
		if(minR>v){
			minR = v;
			maxV = X[i];
		}
	}
	out(maxX,maxV);

	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

ll dp[200010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N];
    REP(i, 0, N) {
        cin >> A[i];
    }
    dp[0] = 0;
    ll ans = 0;
    REP(i, 0, N) {
        if (i - A[i] >= 0) {
            ans += dp[i - A[i]];
        }
        if (i + A[i] < N) {
            dp[i + A[i]]++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6748
/*
    https://atcoder.jp/contests/abc128/tasks/abc128_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    vector<tuple<string, int, int>> guide(n);
    // vector<pair<string, int>> guide(n);
    for (int i = 1; i <= n; i++) {
        string name;
        int point;
        cin >> name >> point;
        point = -point;
        guide[i - 1] = tie(name, point, i);
    }

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

    for (auto x : guide) {
        cout << get<2>(x) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int k;
    cin >> k;
    queue<string> que;
    rep(i, 1, 10) {
        que.push(to_string(i));
    }
    vector<string> ans;
    rep(i, 0, 100000) {
        string s = que.front();
        que.pop();
        ans.push_back(s);
        int d = s.back() - '0';
        rep(j, max(0, d - 1), min(9, d + 1) + 1) {
            que.push(s + to_string(j));
        }
    }
    while (!que.empty()) {
        ans.push_back(que.front());
        que.pop();
    }
    rep(i, 0, ans.size()) {
        if (i + 1 == k) {
            cout << ans[i] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 21488
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    ll n; cin >> n;
    ll ans = 0;
    for(int i=1;i<=n;i++) {
        if(i%3!=0&&i%5!=0) ans += i;
    }
    cout << ans;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans=1e9;
    rep(i,201){
        ll m=i-100;
        ll count=0;
        rep(j,n){
            count+=(a[j]-m)*(a[j]-m);
        }
        ans=min(ans,count);
    }
    cout << ans << endl;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"



void Main()
{
	int a;
	cin>>a;
	cout<<(a+a*a+a*a*a)<<_n;
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N, M, Q;
vector<int> a, b, c, d;

int score(vector<int> &A) {
  int ans = 0;
  rep(i, Q) {
    if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) ans += d.at(i);
  }
  return ans;
}

int dfs(vector<int> &A) {
  // Aが完成していたら得点をチェック
  if (A.size() == N) return score(A);

  // 数列を作成
  int res = 0;
  int prev = (A.empty() ? 1 : A.back());
  for (int i = prev; i <= M; i++) {
    A.push_back(i);
    res = max(res, dfs(A));
    A.pop_back();
  }
  return res;
}

int main() {
  cin >> N >> M >> Q;
  a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
  rep(i, Q) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--; b.at(i)--;
  }

  vector<int> A;
  cout << dfs(A) << endl;
  return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 1;i<=N-1;i++){
    for(int j = 1; i*j<N;j++){
      sum++;
    }
  }
  cout << sum << endl;
}
     

Measured memory_bytes: 3648
#include<iostream>
#define int long long
using namespace std;
int n,p[200000],w[200000],m;
int find(int x)
{
	if(p[x]==x)return x;
	int F=p[x];
	p[x]=find(p[x]);
	w[x]+=w[F];
	return p[x];
}
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)p[i]=i;
	while(m--)
	{
		int l,r,d;
		cin>>l>>r>>d;
		int x=find(l),y=find(r);
		if(x==y&&w[r]-w[l]!=d){cout<<"No"<<endl;return 0;}
		else p[y]=x,w[y]=w[l]+d-w[r];
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x,y = y,x
            self.parents[y] = x
            self.size[x] += self.size[y]

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        a, b = map(lambda x: int(x)-1, input().split())
        uf.union(a,b)

    ans = [None] * N
    # for i in range(N):
        # ans[i] = uf.find(i)
    
    # print(ans)
    print(max(uf.size))
    # l = Counter(ans)
    # print(max([*l.values()]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 82480
package main

import "fmt"

func main() {
	var n,i int64
	fmt.Scanf("%d", &n)
	//n =10
	var currentMin int64 = 0
	for i = 1; i*i <= n; i++ {
		//fmt.Println(i)
		if (n % i == 0){
			currentMin = (i + n/i - 2)
		}

	}
	fmt.Println(currentMin)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int A, B, C;
	cin >> A >> B >> C;

	cout << (A == B ? C : (A == C ? B : A)) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    String str1=reader.readLine();
	    String s1[]=str1.split(" ");

	    String o=s1[0];
	    String e=reader.readLine();

	    char[] c1=o.toCharArray();
	    char[] c2=e.toCharArray();

	    StringBuilder sb=new StringBuilder();

	 

	    for(int i=0;i<c2.length;i++){
		    sb.append(c1[i]);
		    sb.append(c2[i]);
	    }
	    if(c1.length!=c2.length){
		sb.append(c1[c1.length-1]);
	    }

	    System.out.println(sb);
		
	    reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}


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

using namespace std;

void die() { printf("No\n"); exit(0); }

char str[1010];
int K[33];
int n, m;

int main()
{
	int i, j, s, d;
	
	s = d = 0;
	
	scanf("%d%d", &n, &m);
	
	for(i=0; i<n; i++){
		scanf("%s", str);
		for(j=0; j<m; j++){
			K[str[j] - 'a'] ++;
		}
	}
	
	for(i=0; i<26; i++){
		if(K[i] & 1) s ++;
	}
	
	if(s > 1) die();
	if((n * m & 1) && s != 1) die();
	
	if(n & 1) d += m / 2;
	if(m & 1) d += n / 2;
	
	for(i=0; i<26; i++){
		if(K[i] % 4 == 2) d --;
	}
	
	if(d < 0) die();
	
	printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
using namespace std;
int main(){
	int N,M,K;
	cin>>N>>M>>K;
	bool dekiru=false;
	REP(i,N+1){
		REP(j,M+1){
			if(i*(M-j) + (N-i)*j == K){
				dekiru=true;
			}
		}
	}
	if(dekiru){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
	return 0;
}


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

long long N, M;

int main () {
    scanf("%lld%lld", &N, &M);
    if (N == 1 && M == 1) printf("1\n");
    else if (N == 1 || M == 1) printf("%lld\n", N * M - 2 < 0 ? 0 : N * M - 2);
    else printf("%lld\n", (N - 2) * (M - 2));
    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-1 0112: A Milk Shop
// 2017.8.3

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *gets(char *);
char buf[100];

int f[65];

int main()
{
	int i, n;
	unsigned m, k;
	long long ans, a;

	while (1) {
		gets(buf);
		if (!(n = atoi(buf))) break;
		memset(f, 0, sizeof(f));
		for (i = 0; i < n; i++) {
			gets(buf);
			f[atoi(buf)]++;
		}
		if (n == 1) { puts("0"); continue; }
		n -= f[0];
		for (i = 1, ans = 0, m = n; m > 0; i++) {
			k = f[i];
			if (k == 1) ans += (m - 1) * i;
			else if (k > 1) {
				a = m*k - ((k*(k + 1)) >> 1);
				ans += a * i;
			}
			m -= k;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 536
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node{
	unsigned int key;
	struct Node *next;
	struct Node *prev;
};

typedef struct Node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	NodePointer cur = nil->next;
	while( cur != nil && cur->key != key ){
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = malloc(sizeof(struct Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	NodePointer cur = nil->next;
	int isf = 1;
	printf( "%d", cur->key );
	cur = cur->next;
	while( 1 ){
		if( cur == nil ) break;
		if( isf++ > 0 ){
			printf(" ");
			printf( "%d", cur->key );
			cur = cur->next;
			isf = 0;
		}
	}
	printf( "\n" );
}

void deleteNode(NodePointer t){
	if( t == nil ) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void insert(int key){
	NodePointer x = (NodePointer *)malloc(sizeof(NodePointer));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key, n, i, np, nd;
	int size = 0;
	char com[20];
	np = 0;
	nd = 0;
	
	scanf( "%d", &n );
	init();
	for( i = 0; i < n; i++ ){
		scanf( "%s%d", com, &key );
		if( com[0] == 'i' ){
			insert(key);
			np++;
			size++;
		}else if( com[0] == 'd' ){
			if( strlen(com) > 6 ){
				if( com[6] == 'F' ) deleteFirst();
				else if( com[6] == 'L' ) deleteLast();
			}else{
				deleteKey(key);
				nd++;
			}
			size--;
		}
	}
	
	printList();
	
	return 0;
}



Measured memory_bytes: 32964
A = list(input())
B = list(input())
C = list(input())

turn = A
player = "A"
while True:
    if len(turn) == 0:
        print(player)
        exit()

    else:
        if turn[0] == "a":
            turn.pop(0)
            turn = A
            player = "A"

        elif turn[0] == "b":
            turn.pop(0)
            turn = B
            player = "B"

        elif turn[0] == "c":
            turn.pop(0)
            turn = C
            player = "C"


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    int N=S.size();
    S=S+"##";
    for(int i=0;i<N;i++){
        if(S[i]==S[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(S[i]==S[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;  
}

Measured memory_bytes: 512
def resolve():
    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))

    total = sum(a)
    count = 0

    for i in a:
        if i >= total / (4 * m):
            count += 1

    print('Yes' if count >= m else 'No')
resolve()


Measured memory_bytes: 61892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll h, w;
  while (cin >> h >> w) {
    if (h!=0 && w!=0) {
      rep(i, h) {
        rep(j, w) {
          if (i==0 || i==h-1) {
            cout << '#';
          } else {
            if (j==0 || j==w-1) {
              cout << '#';
            } else {
              cout << '.';
            }
          }
        }
        cout << endl;
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll x,i,j,flag=0;
	cin>>x;
	for(i=-1000;i<=1000;i++)
	{
		for(j=-1000;j<=1000;j++)
		{
			if(i*i*i*i*i-j*j*j*j*j==x)
		    {
		    	flag=1;
		    	break;
			}
		}
		if(flag==1)
		break;
	}
	cout<<i<<' '<<j;
	return 0;
}

Measured memory_bytes: 3588
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
ll N, M, K,H,W, ans, mi1,mi2,sum;
string s;
int main() {
	cin >> N;
	ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i > 0 && i < 10)ans++;
		if (i > 99&& i < 1000)ans++;
		if (i > 9999 && i < 100000)ans++;
	}
	cout <<ans<< endl;
	return 0;
}



Measured memory_bytes: 256
/*input
3 3
1 2 3
1 2 3
*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a %= MOD, b %= MOD, a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;
vector < int > v1, v2;
ll dp[2005][2005];

ll func(int n, int m)
{
  if(n <= 0 or m <= 0) {
    return 1;
  }
  if(dp[n][m] > -1) {
    return dp[n][m];
  }
  ll res = 0;
  if(v1[n - 1] == v2[m - 1]) {
    res = add(func(n - 1, m), func(n, m - 1));
  } else {
    res = sub(add(func(n - 1, m), func(n, m - 1)), func(n - 1, m - 1));
  }
  return dp[n][m] = res;
}

ll func2(int n, int m) 
{
  for(int i = 0; i <= n; i ++) {
    dp[i][0] = 1;
  }
  for(int i = 0; i <= m; i ++) {
    dp[0][i] = 1;
  }
  for(int i = 1; i <= n; i ++) {
    for(int j = 1; j <= m; j ++) {
      dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
      if(v1[i - 1] != v2[j - 1]) {
        dp[i][j] = sub(dp[i][j], dp[i - 1][j - 1]);
      }
    } 
  }
  return dp[n][m];
}

int main()
{
  ifalse;
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < n; i ++) {
    int x;
    cin >> x;
    v1.push_back(x);
  }
  for(int j = 0; j < m; j ++) {
    int x;
    cin >> x;
    v2.push_back(x);
  }
  // memset(dp, -1, sizeof(dp));
  cout << func2(n, m);
  return 0;
}

Measured memory_bytes: 31616
from itertools import combinations

def main():
    N, M, X = list(map(int, input().split()))

    row = []

    ans = 10 ** 10

    for i in range(N):
        row.append(list(map(int, input().split())))

    for k in range(1, N+1):
        co = list(combinations(row, k))

        for t in co:
            cost = 0
            skill = [0] * M
            for v in t:
                cost += v[0]
                for s in range(M):
                    skill[s] += v[s+1]

            if(min(skill) >= X):
                ans = min(ans, cost)

    if(ans == 10 ** 10):
        ans = -1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=1000,X=1000,Y;
  cin>>N;ll A[N];REP(i,N)cin>>A[i];i=0;
  while(i<N){
    while(i<N-1&&A[i+1]<=A[i])i++;
    if(i==N-1)break;
    Y=X/A[i];X%=A[i];
    while(i<N-1&&A[i+1]>=A[i])i++;
    X+=Y*A[i];ans=X;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

int dp[100010][26];

signed main() {
	int n;
	cin >> n;
	int a[n];
	int b[n];
	REP (i,n) {cin >> a[i];b[i] = a[i];}
	map<int,int> ma;
	sort(b,b+n);
	REP (i,n) {
		ma[b[i]] = i % 2;
	}
	int ans = 0;
	REP (i,n) {
		if (i % 2 != ma[a[i]]) ans++;
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 8192
class Dice:	
	def __init__( self, nums ):
		self.face = nums
	
	def rolltoTopIndex( self, faceindex ):	
		if faceindex == 1:
			self.roll( "N" )
		elif faceindex == 2:
			self.roll( "W" )
		elif faceindex == 3:
			self.roll( "E" )
		elif faceindex == 4:
			self.roll( "S" )
		elif faceindex == 5:
			self.roll( "NN" )
	
	def roll( self, actions ):
		for act in actions:
			t = 0
			if act == "E":
				t =   self.face[0]
				self.face[0] =   self.face[3]
				self.face[3] =   self.face[5]
				self.face[5] =   self.face[2]
				self.face[2] = t
			elif  act == "N":
				t =   self.face[0]
				self.face[0] =   self.face[1]
				self.face[1] =   self.face[5]
				self.face[5] =   self.face[4]
				self.face[4] = t
			elif  act == "S":
				t =  self.face[ 0]
				self.face[0] =  self.face[4]
				self.face[4] =  self.face[5]
				self.face[5] =  self.face[1]
				self.face[1] = t	
			elif  act == "W":
				t =  self.face[0]
				self.face[0] =  self.face[2]
				self.face[2] =  self.face[5]
				self.face[5] =  self.face[3]
				self.face[3] = t	
			elif  act == "M":
				t =  self.face[1]
				self.face[1] =  self.face[2]
				self.face[2] =  self.face[4]
				self.face[4] =  self.face[3]
				self.face[3] = t

diceface = [ int( val ) for val in raw_input( ).split( " " ) ]
dice1 = Dice( diceface )
diceface = [ int( val ) for val in raw_input( ).split( " " ) ]
dice2 = Dice( diceface )


cnt = 0
for i in range( 6 ):
	if dice1.face[0] == dice2.face[i]:
		dice2.rolltoTopIndex( i )
		for j in range( 1, 5 ):
			if dice1.face[1] == dice2.face[1]:
				cnt = 0
				for k in range( 6 ):
					if dice1.face[k] == dice2.face[k]:
						cnt += 1
				if cnt == 6:
					break
			dice2.roll( "M" )
	if cnt == 6:
		break
	dice2.face = diceface


if cnt == 6:
	print( "Yes" )
else:
	print( "No" )

Measured memory_bytes: 4388
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
using ll = long long ;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int n, k;
int main(){
  cin >> n;
  vector<int>a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];  a[i] -= (i + 1);
  }

  sort(a.begin(), a.end());
  int med = a[n / 2];
  long long out = 0;
  for(int i = 0; i < n; i++)
    out += abs(a[i] - med);

  cout << out << '\n';

  return 0;
}


Measured memory_bytes: 1024
/*
 * @Author: Kaizyn
 * @Date: 2020-05-21 14:40:38
 * @LastEditTime: 2020-05-21 16:35:09
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 1e3+7;
const int dir[] = {0,-1,0,1,0};

int n, m;
long long S;
bool a[N*6][N*6], vis[N*6][N*6];
int row[N][3], col[N][3];
vector<int> disx, disy;

inline void discrete() {
  disx.emplace_back(0);
  disy.emplace_back(0);
  for (int i = 1; i <= n; ++i) {
    disx.emplace_back(row[i][0]);
    disx.emplace_back(row[i][1]);
    disy.emplace_back(row[i][2]);
  }
  for (int i = 1; i <= m; ++i) {
    disx.emplace_back(col[i][0]);
    disy.emplace_back(col[i][1]);
    disy.emplace_back(col[i][2]);
  }
  sort(disx.begin(), disx.end());
  sort(disy.begin(), disy.end());
  disx.erase(unique(disx.begin(), disx.end()), disx.end());
  disy.erase(unique(disy.begin(), disy.end()), disy.end());
#define lb(dis,val) val=(lower_bound(dis.begin(),dis.end(),val)-dis.begin())*2
  for (int i = 1; i <= n; ++i) {
    lb(disx, row[i][0]);
    lb(disx, row[i][1]);
    lb(disy, row[i][2]);
  }
  for (int i = 1; i <= m; ++i) {
    lb(disx, col[i][0]);
    lb(disy, col[i][1]);
    lb(disy, col[i][2]);
  }
#undef lb
}

inline long long calc(const int &x, const int &y) {
  long long h = x&1 ? disx[x/2+1]-disx[x/2] : 0;
  long long w = y&1 ? disy[y/2+1]-disy[y/2] : 0;
  return h*w;
}

void bfs(const int &sx, const int &sy) {
  static queue<pii> q;
  q.push({sx, sy});
  vis[sx][sy] = 1;
  while (q.size()) {
    int ux = q.front().first;
    int uy = q.front().second;
    if (ux == 0 || uy == 0 || ux == n-1 || uy == m-1) {
      cout << "INF" << endl;
      exit(0);
    }
    S += calc(ux, uy);
    q.pop();
    for (int i = 0, vx, vy; i < 4; ++i) {
      vx = ux+dir[i];
      vy = uy+dir[i+1];
      if (vx < 0 || vy < 0 || vx >= n || vy >= m ||
          a[vx][vy] || vis[vx][vy]) continue;
      vis[vx][vy] = 1;
      q.push({vx, vy});
    }
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> row[i][j];
    }
  }
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> col[i][j];
    }
  }
  discrete();
  for (int i = 1; i <= n; ++i) {
    for (int j = row[i][0]; j <= row[i][1]; ++j) {
      a[j][row[i][2]] = 1;
    }
  }
  for (int i = 1; i <= m; ++i) {
    for (int j = col[i][1]; j <= col[i][2]; ++j) {
      a[col[i][0]][j] = 1;
    }
  }
  n = disx.size()*2-1;
  m = disy.size()*2-1;
#ifdef DEBUG
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << a[i][j];
    }
    cout << endl;
  }
#endif
  bfs((lower_bound(disx.begin(), disx.end(), 0)-disx.begin())*2,
      (lower_bound(disy.begin(), disy.end(), 0)-disy.begin())*2);
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 72936
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
int a[2222];
int b[2222];
int c[2222];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n; 
	int ans = 0;
	for(int i=1;i<n;i++){
		cin>>b[i];
	}
	ans+=b[1];
	ans+=b[n-1];
	for(int i=2;i<n;i++){
		ans+=min(b[i],b[i-1]);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,h,w;cin>>n>>h>>w;
    int a,b,ans=0;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a>=h&&b>=w)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


ll dp[53][53];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int H,W;
int a[53][53]={0};
bool visited[53][53];
bool flag=false;

void dfs(int p,int q,int cost){
  // if(visited[p][q])return dp[p][q];
  //visited[p][q]=true;
  if(p==H-1 && q==W-1){
    flag =true;
    dp[p][q]=cost+1;
    return;
  }
  if(dp[p][q]>cost){
    dp[p][q]=cost;
    for(int i=0;i<4;i++){
      int x=p+dx[i],y=q+dy[i];
      if(a[x][y]==1)continue;
      if(x<0 || y<0 || x>=H || y>=W) continue;
      dfs(x,y,cost+1);
    }
  }
  return;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> H >> W;
  char c;
  ll kuro=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> c;
      if(c=='#'){
        a[i][j]=1;
        kuro++;
      }
      dp[i][j]=100000;
    }
  }
  dfs(0,0,1);
  if(!flag){
    cout << -1 << endl;
    return 0;
  }
  ll ans=H*W-kuro-dp[H-1][W-1]+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
int main(){
  int N, M;
  cin >> N;
  string s[101],t[101];
  map<string, int> numS;
  for(int i = 0; i < N; i++){
    cin >> s[i];
    numS[s[i]]++;
  }
  //cout << numS.size() << endl;
  cin >> M;
  map<string, int> numT;
  for(int i = 0; i < M; i++){
    cin >> t[i];
    numT[t[i]]++;
  }
  //cout << numT.size() << endl;

  int ans = 0;
  for(int i = 0; i < N; i++){
    numS[s[i]] = numS[s[i]] - numT[s[i]];
    //cout << numS.size() << endl;
    ans = max(ans,numS[s[i]]);
    //cout << ans << endl;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin>>t;
  string s;
  int cAC = 0;
  int cRE = 0;
  int cTLE = 0;
  int cWA = 0;
  while(t--)
  {
    cin>>s;
    if( s.compare("AC") == 0 )
    {
      cAC++;
      continue;
    }
    if(s.compare("TLE") == 0)
      {
      cTLE++;
      continue;
    }
    if(s.compare("WA") == 0)
     {
      cWA++;
      continue;
    }
    if(s.compare("RE") == 0)
     {
      cRE++;
      continue;
    }
  }
  
  cout<<"AC"<<" "<<"x"<<" "<<cAC<<"\n";
  cout<<"WA"<<" "<<"x"<<" "<<cWA<<"\n";
  cout<<"TLE"<<" "<<"x"<<" "<<cTLE<<"\n";
  cout<<"RE"<<" "<<"x"<<" "<<cRE;
}


Measured memory_bytes: 3600
#include <stdio.h>

char s[100001];

int main(void) {
	int len;

	scanf("%s%n", s, &len);

	int ans = 0;
	for (int l = 0, r = len - 1; l <= r; ) {
		if (s[l] == s[r]) {
			l++;
			r--;
		} else if (s[l] == 'x') {
			l++;
			ans++;
		} else if (s[r] == 'x') {
			r--;
			ans++;
		} else {
			puts("-1");
			return 0;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> G(H);
    REP(i,H) cin >> G[i];
    REP(i,H) {
        cout << G[i] << endl;
        cout << G[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100010;


int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	cin >> s ;
	for(int i = 0;i<s.size() - 1;++i){
		if(s[i] == s[i+1]){
			cout << i + 1 << ' ' << i+2 << endl;
			return 0;
		}
		if(i < s.size() - 2 && s[i] == s[i+2]){
			cout << i + 1 << ' ' << i+3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}


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

const int MAX = 2000005;
int prime[MAX];

int main(){
    prime[0] = prime[1] = 1;
    for(int i = 2; i * i <= MAX; i++){
        if(prime[i] == 0){
            for(int j = 2; i * j < MAX; j++){
                prime[i * j] = 1;
            }
        }
    }
    int a, d, n;
    while(cin >> a >> d >> n){
        if(a == 0 && d == 0 && n == 0) break;
        int cnt = 0;
        while(1){
            if(prime[a] == 0){
                cnt++;
                if(cnt == n) break;
            }
            a += d;
        }
        cout << a << endl;
    }
}



Measured memory_bytes: 10816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(vecto) vecto.begin(),vecto.end()
typedef long long ll;

int main(){
    int a,b;
    cin>>a>>b;
    if(a<9&&b<9){
        cout << "Yay!" << endl;
    }
    else
        cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<vector>
#include<cmath>
#include<random>
#include<cassert>
//This code is written by Itst
using namespace std;

int w[107] , val[107] , dp[107][307];
int N , W , allW;

int main(){
    cin >> N >> W;
    for(int i = 1 ; i <= N ; ++i)
        cin >> w[i] >> val[i];
    allW = w[1];
    for(int i = 1 ; i <= N ; ++i) w[i] -= allW;
    for(int i = 1 ; i <= N ; ++i)
        for(int j = N ; j ; --j)
            for(int k = 3 * N ; k >= w[i] ; --k)
                dp[j][k] = max(dp[j][k] , dp[j - 1][k - w[i]] + val[i]);
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i){
        int cur = W - allW * i;
        if(cur < 0) break;
        ans = max(ans , dp[i][min(cur , 3 * N)]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Problem {
    int N;
    int[][] hs;

    Problem() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        hs = new int[N][3];

        for (int i = 0; i < N; i++) {
            for (int k = 0; k < 3; k++) {
                hs[i][k] = sc.nextInt();
            }
        }
    }

    int solve() {
        int[][] dp = new int[N][3];

        for (int k = 0; k < 3; k++) {
            dp[0][k] = hs[0][k];
        }

        for (int i = 1; i < N; i++) {
            for (int k = 0; k < 3; k++) {
                dp[i][k] = -1;
                for (int j = 0; j < 3; j++) {
                    if (k == j) continue;
                    dp[i][k] = Math.max(dp[i][k], dp[i-1][j]);
                }
                dp[i][k] += hs[i][k];
            }
        }

        int max = -1;
        for (int k = 0; k < 3; k++) {
            if (max < dp[N-1][k]) {
                max = dp[N-1][k];
            }
        }

        return max;
    }
}

public class Main {
    public static void main(String[] args) {
        int ans = new Problem().solve();
        System.out.println(ans);
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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



template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
/*
WeightedGraph<ll> g(V);
g[a].emplace_back(b, c);
*/
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	ll N, M;
	cin >> N >> M;

	vector<ll> H(N);
	REP(i, N) cin >> H[i];
	UnWeightedGraph g(N);
	REP(i, M) {
		ll A, B;
		cin >> A >> B;
		A--; B--;
		g[A].emplace_back(B);
		g[B].emplace_back(A);
	}
	ll cnt = 0;
	REP(i, N) {
		ll tmp = 0;
		REP(j, g[i].size()) {
			if (H[i] > H[g[i][j]]) tmp++;
		}
		if (tmp == g[i].size()) cnt++;
	}
	PRINT(cnt);
	return 0;
}


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

int main(){
    int k, s;   cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  [m, k] <- map read.words <$> getLine
  putStrLn . maybe "-1" (unwords.map show) $ solve m k

solve :: Int -> Int -> Maybe [Int]
solve m 0 = Just $ concatMap (\i -> [i, i]) [0..2^m-1]
solve 1 _ = Nothing
solve m k
    | k < 2 ^ m = Just $ k : reverse xs ++ 0:k:0:xs
    | otherwise = Nothing
  where
    xs = [1..k-1] ++ [k+1..2^m-1]

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;
	const int n = s.size();

	int ans = n - 1;

	rep(i,26){
		char cur = i + 'a';
		string cs = string(n,'?');
		rep(j,n) if(s[j]==cur) cs[j] =cur;

		while(1){
			const int m = cs.size();
			bool ok = true;
			rep(j,m) if(cs[j]!=cur) ok = false;
			
			if(ok){
				chmin(ans,n-m);
				break;
			}

			string ns=string(m-1,'?');

			rep(j,m-1){
				if(cs[j]==cur) ns[j]=cur;
				if(cs[j+1] == cur) ns[j]=cur;
			}

			cs = ns;
		}
	}

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

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

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

typedef long long ll;

int main(int argc, char const *argv[]) {
    int i,N;
    scanf("%d",&N);
    int count=0;
    int a, even;
    for(i=1;i<=N;i++){
        even=0;
        a=i;
        while(a!=0){
            a=a/10;
            even++;
        }
        if(even % 2 == 1){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}


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

int dp[100005];

int main(){
    string s;
    cin>>s;
    dp[0]=1;
    for(int i=0;i<s.size();i++){
        if(dp[i]==0) continue;
        if(i+5<=s.size()&&s.substr(i,5)=="dream") dp[i+5]=1;
        if(i+7<=s.size()&&s.substr(i,7)=="dreamer") dp[i+7]=1;
        if(i+5<=s.size()&&s.substr(i,5)=="erase") dp[i+5]=1;
        if(i+6<=s.size()&&s.substr(i,6)=="eraser") dp[i+6]=1;
    }
    if(dp[s.size()]==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 896
#define first f
#define second s
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	bool c = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == 'L') c = false;
		if (i % 2 == 1 && s[i] == 'R') c = false;
	}
	if (c) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256