akhauriyash/Code-Regression huggingface dataset:
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, T;
  cin >> n >> T;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int prof = 0;
  int mx = 0;
  for (int i = n - 1; i >= 0; i--) {
    prof = max(prof, mx - a[i]);
    mx = max(mx, a[i]);
  }
  int cnt = 0;
  set<int> st;
  for (int i = n - 1; i >= 0; i--) {
    if (st.find(a[i] + prof) != st.end()) {
      cnt++;
    }
    st.insert(a[i]);
  }
  cout << cnt << "\n";
}



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

const int mo=int(1e9+7);
int n,m,r[3010],sum[3010],f[3010][3010];
char s[3010];

void work()
{
	scanf("%d %d\n%s",&n,&m,s+1);
	for (int i=1; i<=n; i++)  sum[i]=sum[i-1]+(s[i]=='1'),r[i]=i;
	for (int i=1,x,y; i<=m; i++)  scanf("%d %d",&x,&y),r[x]=max(r[x],y);
	for (int i=1; i<=n; i++)  r[i]=max(r[i],r[i-1]);
	f[0][0]=1;
	for (int i=1; i<=n; i++)
		for (int j=0; j<=sum[r[i-1]]; j++)
			if (f[i-1][j])
				{
					if (sum[r[i]]>j)  f[i][j+1]=(f[i][j+1]+f[i-1][j])%mo;
					if (sum[r[i]]-j<r[i]-i+1)  f[i][j]=(f[i][j]+f[i-1][j])%mo;
				}
	printf("%d",f[n][sum[n]]);
}

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


Measured memory_bytes: 33920
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    a = int(input())
    print(a + (a**2) + (a**3))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9552
a, b = gets.split.map(&:to_i)

def calc(num)
  if num == 0
    return [0] * 40
  elsif num == 1
    return ([0] * 39) + [1]
  elsif num == 2
    return ([0] * 38) + [1,1]
  elsif num % 4 == 3
    return [0] * 40
  elsif num % 4 == 0
    return ("%040d" % num.to_s(2)).split('').map(&:to_i)
  elsif num % 4 == 1
    return (("%040d" % num.to_s(2)).split('').map(&:to_i)).zip(("%040d" % (num-1).to_s(2)).split('').map(&:to_i)).map{|q,w| (q + w) % 2}
  elsif num % 4 == 2
    return (("%040d" % num.to_s(2)).split('').map(&:to_i)).zip(
      ("%040d" % (num-2).to_s(2)).split('').map(&:to_i),
      ("%040d" % (num-1).to_s(2)).split('').map(&:to_i)
    ).map{|x| x.inject(:+) % 2}
  end
end

puts calc(b).zip(calc(a-1)).map{|x| x.inject(:+) % 2}.map(&:to_s).join.to_i(2)

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(),(x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int,int> P;
typedef vector<int> vi;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int n;
vector<P> a;

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

    cin>>n;
    rep(i,0,5) {
        int b; cin>>b;
        a.pb(P(i+1,b));
    }

    sort(ALL(a),pairCompare);
    int ans=4;
    ans+=n/a[0].se;
    if(n%a[0].se!=0) ans++;
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

const string dict[4]={"dream","erase","dreamer","eraser"};

const int N=1e5+10;


int h[N];
string s;
int main(){
    cin>>s;
    int n=s.length();
    h[0]=1;
    for(int i=0;i<n;i++) if (h[i]){
        for(auto cur:dict) if (i+cur.length()<=n){
            string need=s.substr(i,cur.length());
            if (cur==need) h[i+cur.length()]=1;
        }
    }
    if (h[n]) printf("YES");
    else printf("NO");
}


Measured memory_bytes: 896
def main():
    from heapq import heappush as sushi
    from heapq import heappop as tempra
    n, m, *ab = map(int, open(0).read().split())
    l = [[] for _ in range(m + 1)]
    for i, j in zip(*[iter(ab)] * 2):
        if i - m < 1:
            l[i].append(-j)

    w = []
    h = []
    for i in range(1, m + 1):
        for j in l[i]:
            sushi(h, j)
        if h:
            x = tempra(h)
            w.append(x)

    print(-sum(w))


if __name__ == '__main__':
    main()


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


int main(){
    ll k,n;
    cin>>k>>n;
    vector <ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    vector <ll> b;
    for(ll i=1;i<=n-1;i++){
        b.push_back(a[i]-a[i-1]);
    }
    b.push_back(k+a[0]-a[n-1]);
    sort(b.begin(),b.end());
    ll ans=0;
    for(ll i=0;i<b.size()-1;i++){
        ans+=b[i];
    }
    
    cout<<ans;
    
}



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

int main() {
  string s;
  cin >> s;

  int q;
  cin >> q;
  string t;
  rep(qi, q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      swap(s, t);
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        t += c;
      } else {
        s += c;
      }
    }
  }
  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 1128
#C問題現状それっぽいやつ
N,M=[int(i) for i in input().split()]
Y=list(map(int,input().split()))
X=sorted(Y)
Sa=[]
ans=0
if N>=M:
    print(0)
else:
    for i in range(M-1):
        Sa.append(X[i+1]-X[i])
    Sa.sort()
    for i in Sa[:(M-N)]:
        ans=ans+i
    print(ans)


Measured memory_bytes: 13968
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  int a[n];
  int i;
  i = 0;
  int cnt;
  cnt = 0;
  while (i < n)
  {
    scanf("%d",&a[i]);
    if ((i + 1) % 2 != 0 && a[i] % 2 != 0)
    {
      cnt++;
    }
    //printf("%d %d\n",i,a[i]);
    i++;
  }
  printf("%d",cnt);
}

Measured memory_bytes: 1684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);
double distance(int xi, int yi, int xj, int yj);

//main function
int main() {
    char s[100], t[100];
    stin(s);
    stin(t);
    printf("%s%s\n", t, s);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

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

/*
    int型の降順用比較関数
*/

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

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}

double distance(int xi, int yi, int xj, int yj) {
    return hypot(xj - xi, yj - yi);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){
	
	int count = 0;
	string answer = "CODEFESTIVAL2016";
	string S;

	cin >> S;

	for (int i = 0; i < 16; i++) {
		if (answer[i] != S[i])
			count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    S = [readline().rstrip() for _ in range(n)]
    c = collections.Counter(S)
    keys = sorted(c.keys())
    maxS = c.most_common()[0][1]
    for key in keys:
        if c[key] == maxS:
            print(key)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51064
#include <cstdio>
#include <unistd.h>
#include <algorithm>
#include <vector>
using namespace std;

using i64 = long long;

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

const int is = 1 << 17;
char ib[is], *ip = ib + is, it;
inline char getc() {
//	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }
	if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
	return *ip++;
}
inline i64 scan() {
	i64 r = 0;
	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
	else while ((it = *ip++) & 16) r = r * 10 + it - '0';
	return r;
}

const int os = 1 << 17;
char ob[os], *op = ob, ot;
inline void putc(const char c) {
	*op++ = c;
//	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }
	if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
}
// x shoud be greater than or equal to zero
inline void print(i64 x) {
	char d[20];
	int i = 0;
	while (true) {
		d[i] = x % 10 + 48;
		x /= 10;
		++i;
		if (x <= 0) break;
	}
	while (i--) {
		putc(d[i]);
	}
}

signed main() {
  i64 N = scan();
  i64 M = scan();
  vector<i64> A(N);
  REP(i, N) A[i] = scan();
  sort(A.begin(), A.end());
  vector<i64> S(N + 1);
  REP(i, N) S[i + 1] = S[i] + A[i];
  i64 h_ng = 0;
  i64 h_ok = A[N - 1] * 2 + 1;
  i64 h = h_ok;
  while (h_ok > h_ng + 1) {
    h = h_ng + h_ok >> 1;
    i64 q = 0;
    i64 gt = 0;
    RREP(i, N) {
      while (gt < N && !(A[i] + A[gt] > h)) gt++;
      q += N - gt;
    }
    if (q <= M) {
      h_ok = h;
    } else {
      h_ng = h;
    }
  }
  h = h_ok;
  i64 s = 0;
  i64 q = 0;
  i64 gt = 0;
  RREP(i, N) {
    while (gt < N && !(A[i] + A[gt] > h)) gt++;
    q += N - gt;
    s += S[N] - S[gt] + A[i] * (N - gt);
  }
  print(s + (M - q) * h);
//  fwrite_unlocked(ob, 1, op - ob, stdout);
  write(STDOUT_FILENO, ob, op - ob);
}


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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end

typedef pair<P,ll> T;
int n,m,l; vector<P> g[310]; P dist[310][310];
void dijkstra(int i){
    dist[i][i]={0,0}; priority_queue<T,vector<T>,greater<T>> pq; pq.push({{0,0},i});
    while(!pq.empty()){
        T t=pq.top(); pq.pop();
        P d=t.first; int v=t.second;
        if(dist[i][v]<d)continue;
        for(auto to:g[v]){
            if(d.second+to.second<=l){
                if(chmin(dist[i][to.first],{d.first,d.second+to.second}))pq.push({dist[i][to.first],to.first});
            }
            else{
                if(chmin(dist[i][to.first],{d.first+1,to.second}))pq.push({dist[i][to.first],to.first});
            }
        }
    }
}

int main(){
    scanf("%d%d%d",&n,&m,&l);
    rep(i,0,m){
        int a,b,c; scanf("%d%d%d",&a,&b,&c); a--; b--;
        if(c>l)continue;
        g[a].push_back({b,c}); g[b].push_back({a,c});
    }
    Fill(dist,P{INF,INF}); rep(i,0,n)dijkstra(i);
    int q; scanf("%d",&q);
    rep(rot,0,q){
        int s,t; scanf("%d%d",&s,&t); s--; t--;
        ll ans=min(dist[s][t].first,dist[t][s].first);
        printf(ans==INF?"-1\n":"%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5740
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

bool isPrime(int n) {

  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int x;
  cin >> x;
  while (!isPrime(x)) x++;
  cout << x;
}
#endif


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N=100;
const int MAX_W=10000;
int w[MAX_N];
int v[MAX_N];
int dp[MAX_N+1][MAX_W+1];
int n,W;

int rec(int i,int j){
	if(dp[i][j]>=0){
		return dp[i][j];
	}
	int res;
	if(i==n){
		res=0;
	}
	else if(j<w[i]){
		res=rec(i+1,j);
	}
	else{
		res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i]);
	}
	return dp[i][j]=res;
}
int main(){
	scanf("%d %d",&n,&W);
	for(int i=0;i<n;i++){
		scanf("%d %d",&v[i],&w[i]);
	}
	memset(dp,-1,sizeof(dp));
	printf("%d\n",rec(0,W));
	return 0;

}

Measured memory_bytes: 4980
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-7
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(n) ((n) * (n))
#define INF 300000005
#define MAXN 10001

bool used[26];

int main()
{
	string str;
	cin >> str;
	CL(used, false);
	REP(i, sz(str))
	{
		used[int(str[i] - 'a')] = true;
	}
	REP(i, 26)
	{
		if (!used[i])
		{
			printf("%c", char('a' + i));
			return 0;
		}
	}
	printf("None");
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
         int n=sc.nextInt();
         int strike=0;
         for(int i=0;i<n;i++) {
        	 int x=sc.nextInt();
        	 int y=sc.nextInt();
        	 if(x==y)strike++;
        	 else strike=0;
        	 if(strike==3) {
        		 System.out.println("Yes");
        		 return;
        	 }
         }
         System.out.println("No");

	}

}

Measured memory_bytes: 35992
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
//
// using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;

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

  ll n;
  cin >> n;
  for (int i = sqrt(n) + 1; i >= 1; i--) {
    if(n % i == 0){
      ll a = i;
      ll b = n / i;
      cout << (a-1) + (b-1) << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll h,w; cin>>h>>w;
  auto A=make_v(h,w,0);
  auto B=make_v(h,w,0);
  rep(i,h)rep(j,w) cin>>A[i][j];
  rep(i,h)rep(j,w) cin>>B[i][j];
  const ll ofs=12800;
  const ll M=2*ofs+1;
  auto dp=make_v(h,w,bitset<M>(0));
  ll x=abs(A[0][0]-B[0][0]);
  dp[0][0].set(ofs+x);
  dp[0][0].set(ofs-x);
  
  rep(i,h)rep(j,w){
    if(i==0 && j==0) continue;
    ll x=abs(A[i][j]-B[i][j]);
    bitset<M> S;
    if(i>0) S|=dp[i-1][j];
    if(j>0) S|=dp[i][j-1];
    dp[i][j]=(S<<x)|(S>>x);
  }
  rep(i,ofs+1){
    if(dp[h-1][w-1].test(i+ofs)){
      cout<<i<<"\n";
      return;
    }
  }
}

Measured memory_bytes: 20736
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100010;
int n,m,ck,a[N],b[N];
bool cmp(int a,int b){
	return (a&1)>(b&1);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",a+i);
		ck+=(a[i]&1);
	}
	if(ck>2){
		puts("Impossible");
		return 0;
	}
	sort(a+1,a+m+1,cmp);
	if(m==1){
		if(a[1]==1)
			printf("1\n1\n1");
		else printf("%d\n2\n%d %d",a[1],a[1]-1,1);
		return 0;
	}
	if(a[2]&1)
		swap(a[2],a[m]);
	for(int i=1;i<=m;i++)
		printf("%d ",a[i]);
	printf("\n%d\n%d ",m-(a[m]==1),a[1]+1);
	for(int i=2;i<m;i++)
		printf("%d ",a[i]);
	if(a[m]!=1)
		printf("%d ",a[m]-1);
	return 0;
}

Measured memory_bytes: 128
#include <map>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
int main(){
	std::string s;
	std::map<std::string,int> M;
	int maxlen=0;
	while(std::cin>>s){
		maxlen = std::max(maxlen, (int)s.size());
		M[s]++;
	}
	int maxapp=0;
	for(std::map<std::string,int>::iterator it = M.begin(); it != M.end(); ++it){
		maxapp = std::max(maxapp, it->second);
	}	
	for(std::map<std::string,int>::iterator it = M.begin(); it != M.end(); ++it){
		if(maxapp == it->second)std::cout<<it->first<<" ";
	}
	for(std::map<std::string,int>::iterator it = M.begin(); it != M.end(); ++it){
		if(maxlen == (it->first).size())std::cout<<it->first<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1192
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())

dp = [0 for _ in range(N+1)]
dp[0] = 2
dp[1] = 1
#print(dp)

for i in range(2, N+1) :
  dp[i] = dp[i-1] + dp[i-2]

print (dp[N])

Measured memory_bytes: 38256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <map>


const int mod = 1000000007;
//const int mod = 998244353;
int maximum(int a, int b) { return a < b ? b : a; }
int main() {
	int N;
	scanf("%d", &N);
	auto A = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", A + i);
	bool ap = true;
	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0)ap = false;
	}
	printf(ap ? "APPROVED" : "DENIED");
	return 0;
}

Measured memory_bytes: 256
function abc175b(input: string) {
    let array: string[] = input.split('\n');
    let n: number = parseInt(array[0]);
    let l: number[] = array[1].split(' ').map(l => parseInt(l)).sort((a, b) => a - b);

    let count: number = 0;
    for (let i: number = 0; i < n; i++) {
        for (let j: number = i + 1; j < n; j++) {
            for (let k: number = j + 1; k < n; k++) {
                if (l[i] < l[j] && l[j] < l[k]) {
                    if (l[i] + l[j] > l[k]) {
                        count++;
                    }
                }
            }
        }
    }
    console.log(count);
}

abc175b(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32320
from math import floor
A, B = list(map(int, input().split()))
for x in range(1, 1001):
    a = floor(x*0.08)
    b = floor(x*0.1)
    if a==A and b==B:
        print(x)
        break
    else:
        continue
else:
    print(-1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;

int main() {
	int n, p;

	while (scanf("%d %d", &n, &p)) {
		if (n == 0)
			return 0;

		int turn = 0, wan = p;
		array<int, 50> mayer = {};
		while (1) {

			if (wan == 0) {
				wan = mayer[turn];
				mayer[turn] = 0;
			}
			else if (wan == 1 && mayer[turn]+1 == p) 
				break;
			else {
				wan--;
				mayer[turn]++;
			}
			turn++;
			turn -= ((int)(turn / n) * n);
		}
		printf("%d\n", turn);
	}

	return 0;
}

Measured memory_bytes: 3160
import java.util.*

fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun solve(sc: java.util.Scanner) {
    val N = sc.nextInt()
    val M = sc.nextInt()
    val A = Array(N) { sc.nextLong() }

    val q = PriorityQueue<Long>(N) { x, y -> return@PriorityQueue if (y > x) 1 else -1 }
    q.addAll(A.toList())
    var m = M
    while (m > 0) {
        val a = q.first()!!
        q.remove(a)
        q.add(a / 2)
        m--
    }
    println(q.sum())
}


Measured memory_bytes: 55868
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    const int mod = 1e9 + 7;
    int n, m;
    cin >> n >> m;
    vector<int> vs(n + 1, 0), vt(m + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> vs[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> vt[i];
    }

    vector<vector<long long int>> res(n + 1, vector<long long int> (m + 1, 1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (vs[i] == vt[j]) {
                res[i][j] = (res[i - 1][j] + res[i][j - 1] - res[i - 1][j - 1]) + res[i - 1][j - 1];
            } else {
                res[i][j] = (res[i][j - 1] + res[i - 1][j] - res[i - 1][j - 1]);
            }            
            res[i][j] %= mod;
            res[i][j] += mod;
            res[i][j] %= mod;
        }
    }
    cout << res[n][m] << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> point(n);
  
  for (int i = 0; i < n; i++)
    cin >> point[i];
  
  sort(point.begin(), point.end());
  
  /*
  cout << point[0] << point[1] << point[2] << endl;
  cout << point.size() << endl;
  cout << 1 + point.back() << endl;
  point.pop_back();
  cout << point.size() << endl;
  cout << 2 + point.back() << endl;
  */
  
  int pointA = 0, pointB = 0, turn = 0;
  while (point.size() > 0) {
    if (turn % 2 == 0) {
      pointA += (int)point.back();
      point.pop_back();
    }
    else {
      pointB += (int)point.back();
      point.pop_back();
    }
    
    turn++;
  }
  
  cout << pointA - pointB << endl;
  
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string a, b;
    std::cin >> a >> b;
    int c = std::stoi(a + b);
    for (int i = 0; i < c; ++i) {
        if (i * i == c) {
            std::cout << "Yes";
            return 0;
        }
    }
    std::cout << "No";
    return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
X = []
Y = []
for i in range(n):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
sum = 0
D = []

for i in range(n):
    for j in range(n):
        d = math.sqrt((X[i]-X[j])**2 + (Y[i]-Y[j])**2)
        sum+=d

ave = sum/n
print(ave)


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

int main(){
    int n;
    cin>>n;
    for(int i=1; i<=9;i++){
        for(int j=1; j<=9;j++){
            if(i*j==n){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
vector<pair<int,int>> e[100000];

int ans[100000];
void dfs(int n, int p, int b){
    int cnt = 0;
    if(cnt == b) cnt++;
    rep(i, e[n].size()){
        if(e[n][i].first == p) continue;
        ans[e[n][i].second] = cnt;
        dfs(e[n][i].first, n, cnt);
        cnt++;
        if(cnt == b) cnt++;
    }
}

signed main(){
    cin >> N;
    rep(i, N-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].pb({ b, i });
        e[b].pb({ a, i });
    }

    int K = 0;
    rep(i, N){
        K = max(K, (int)e[i].size());
    }
    cout << K << endl;

    dfs(0, -1, -1);
    rep(i, N-1) cout << ans[i]+1 << endl;
}

Measured memory_bytes: 9344
// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2e5+5;
pii a[N+N];
int u[N],wu[N];
int32_t main(){
    int n,m=0;
    cin>>n;
    forn(i,n){
        forn(j,2){
            int x;cin>>x;
            a[m++]={x,i};
        }
    }
    sort(a,a+m);
    int ans=1e18;
    int s=0,nes=n;
    int ptr=0,fdu=-1,ldu=-1;
    forn(i,m){
        while(ptr<m&&s<n){
            int v=a[ptr].s;
            u[v]++,wu[v]++;
            if(u[v]==1)s++;
            if(wu[v]==1){
                --nes;
                if(nes==0)ldu=ptr;
            }
            if(wu[v]==2&&fdu==-1){
                fdu=ptr;
            }
            ptr++;
        }
        if(s<n)break;
        int mnx=a[i].f,mxx=a[ptr-1].f,mny=a[0].f,mxy=a[m-1].f;
        if(!i){
            if(fdu==-1)mny=a[n].f;
            else mny=a[fdu].f;
        }else if(ptr==m){
            mxy=a[ldu].f;
        }
        upn(ans,(mxx-mnx)*(mxy-mny));
        int v=a[i].s;
        u[v]--;
        if(u[v]==0)s--;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 12972
// https://atcoder.jp/contests/abc073/tasks/abc073_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, c = 0;

  cin >> n;

  REP(i, n)
  {
    int l, r;
    cin >> l >> r;
    c += r - l + 1;
  }

  cout << c << '\n';

  return 0;
}


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

int main(){
  int N, Q, S_len;
  string S;
  cin >> N >> Q >> S;
  
  S_len = (int)(S.length());
  
  vector<int> ACnum(S_len);
  int num = 0, flag = 0;
  
  for (int i = 0; i < S_len; i++){
    if (S.at(i) == 'A'){
      flag = 1;
    }
    else if (S.at(i) == 'C'){
      if (flag == 1){
        num++;
      }
      flag = 0;
    }
    else{
      flag = 0;
    }
    ACnum.at(i) = num;
  }
  
  /*for (int i = 0; i < S_len; i++){
    cout << ACnum.at(i) << endl;
  }*/
  
  for (int i = 0; i < Q; i++){
    int L, R;
    cin >> L >> R;
    
    cout << ACnum.at(R - 1) - ACnum.at(L - 1) << endl;
  }
  
}

Measured memory_bytes: 3816
import java.util.Scanner;

class Segment{
	int left, right;
	public Segment(int l, int r) {
		left = l; right = r;
	}
}
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		Segment[] seg = new Segment[H];
		for(int i = 0; i < H; i++) {
			int l = 0, r = 0;
			String A = sc.next();
			l = A.indexOf('#');
			r = A.lastIndexOf('#');
			seg[i] = new Segment(l, r);
		}
		boolean check = true;
		for(int i = 1; i < H; i++) {
			if(seg[i - 1].right != seg[i].left) check = false;
		}
		System.out.println(check ? "Possible" : "Impossible");
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
    }
    bool ans = true;
    rep(i,n){
        if(a[i]%2==1)continue;
        if(a[i]%3!=0 && a[i]%5!=0){
            ans = false;
            break;
        }
    }
    if(ans){
        print("APPROVED");
    }else{
        print("DENIED");
    }
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

vector<string> ans;

void dfs(string s, ll c, ll d) {
  if (d == 0) {
    ans.push_back(s);
    return;
  }
  for (ll i = 0; i <= c; i++) {
    char addc = 'a' + i;
    string adds = {addc};
    dfs(s + adds, c, d - 1);
  }
  char addc = 'a' + c + 1;
  string adds = {addc};
  dfs(s + adds, c + 1, d - 1);
}

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

  dfs("a", 0, n-1);

  rep(i, (ll)ans.size()) { cout << ans[i] << endl; }

  return 0;
}


Measured memory_bytes: 7796
#include <cstdio>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N;

int main()
{
  scanf( "%lld", &N );

  rep( i, N+1 )
  {
    if( (ll)((double)i*1.08) == N )
    {
      printf( "%lld\n", i );

      return 0;
    }
  }

  puts(":(");

  return 0;
}

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

bool is_ok(vector<int> seq, int dnum, int tnum) {
  int target = -1;
  for (int i = 0; i < 9; ++i) {
    if (0 < seq[i]) {
      target = i;
      break;
    }
  }
  int maxv = *max_element(seq.begin(), seq.end());
  int minv = *min_element(seq.begin(), seq.end());

  if ((5 <= maxv) || (minv < 0))
    return false;

  if ((dnum == 0) && (tnum == 0))
    return true;

  vector<int> copy = seq;
  if ((dnum != 0)) {
    copy[target] -= 2;
    if (is_ok(copy, dnum - 1, tnum))
      return true;
  }

  if ((tnum != 0) && (target < 7)) {
    copy = seq;
    copy[target] -= 1;
    copy[target + 1] -= 1;
    copy[target + 2] -= 1;
    if (is_ok(copy, dnum, tnum - 1))
      return true;
  }

  if ((tnum != 0)) {
    copy = seq;
    copy[target] -= 3;
    if (is_ok(copy, dnum, tnum - 1))
      return true;
  }

  return false;
}

int main() {
  string tmp;

  while (cin >> tmp) {
    vector<int> seq(9);
    for (int i = 0; i < 13; ++i) {
      int idx = tmp[i] - '1';
      ++seq[idx];
    }

    vector<int> res;
    for (int i = 0; i < 9; ++i) {
      vector<int> seq_copy = seq;
      seq_copy[i] += 1;
      if (is_ok(seq_copy, 1, 4))
        res.push_back(i + 1);
    }

    if (res.empty()) {
      cout << 0 << endl;
    } else {
      for (auto &v : res)
      {
        if (v == res[0])
          cout << v;
        else
          cout << " " << v;
      }
      cout << endl;
    }
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 3148
h,w = map(int,input().split())

s = []
for i in range(h):
    tmp = list(input())
    if "#" in tmp:
        s.append(tmp)

c = [0]*w
for i in s:
    for j in range(w):
        if i[j] == "#":
            c[j] = 1

for i in s:
    for j in range(w):
        ans = i[j] if c[j] == 1 else ""
        print(ans, end="")
    print("")

Measured memory_bytes: 4596
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = input()
L = []
for i in range(N):
    L.append(T[i])
for i in range(N-K):
    if L[i] == L[i+K]:
        L[i+K] = 0
for i in range(N):
    if L[i] == 'r':
        L[i] = P
    elif L[i] == 's':
        L[i] = R
    elif L[i] == 'p':
        L[i] = S
print(sum(L))

Measured memory_bytes: 53104
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
LL BIT[SIZE];
void ins(int x,int v){
    for(;x;x-=x&-x)BIT[x]+=v;
}
LL qq(int x){
    LL ret=0;
    for(;x<SIZE;x+=x&-x)ret+=BIT[x];
    return ret;
}
int a[SIZE];
int main(){
    DRI(n);
    LL sum=0;
    REPP(i,1,n+1){
        RI(a[i]);
        sum+=a[i];
    }
    LL one_time=(n+1LL)*n/2;
    if(sum%one_time)return 0*puts("NO");
    LL tt=sum/one_time;
    a[0]=a[n];
    LL now=0;
    REPP(i,1,n+1){
        int dif=a[i]-a[i-1];
        LL v=(tt-dif);
        if(v<0)return 0*puts("NO");
        if(v%n)return 0*puts("NO");
        now+=v/n;
    }
    if(now!=tt)return 0*puts("NO");
    return 0*puts("YES");
}


Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;

main(){
	string s;
	cin >> s;
	int ans = 0;
	if(s[0] != '-') s = "0" + s;
	for(int i=(s[0] == '-'?2:1);i<s.size();i++)
		if(s[i]!='0' && (atoi(s.substr(0, i).c_str()) + atoi(s.substr(i).c_str()))%2==0 && (atoi(s.substr(0, i).c_str()) <= atoi(s.substr(i).c_str())))
			ans ++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1204
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int h, w; cin >> h >> w;
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	vector<vector<int>> ans(h);
	int clr = 1;
	rep(i, 0, h) {
		ans[i].resize(w);
		rep(j, 0, w) {
			if (i % 2) ans[i][j] = clr;
			else ans[i][w - 1 - j] = clr;
			a[clr-1]--;
			if (a[clr-1] == 0) clr++;
		}
	}
	rep(i, 0, h) {
		rep(j, 0, w) printf("%d ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<22)

int n;
int a[22];
int ans;

void solve(int now,int idx){
  if(idx == n){
    ans = min(ans,abs(now));
    return;
  }
  solve(now-a[idx],idx+1);
  solve(now+a[idx],idx+1);
}

int main(){
  while(cin >> n ,n){
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    ans = INF;
    solve(0,0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,m;
vector<int> graf[60];
pair<int,int> c[30];
map<pair<int,int>,int> grane;
ll c2[30];
bool mark[60];
stack<int> stek;
bool gotov;
ll sol;

void dfs(int cvor, int kraj)
{
    mark[cvor]=true;
    stek.push(cvor);
    if(cvor==kraj)
    {
        gotov=true;
        return;
    }
    for(int i=0;i<graf[cvor].size();i++)
        if(!mark[graf[cvor][i]] && !gotov)
            dfs(graf[cvor][i],kraj);
    if(gotov)
        return;
    stek.pop();
}

void napravi(int index)
{
    ll br=0;
    int pret=stek.top();
    stek.pop();
    while(!stek.empty())
    {
        int tek=stek.top();
        stek.pop();
        br+=(((ll)1)<<(ll)grane[{pret,tek}]);
        pret=tek;
    }
    c2[index]=br;
    //cout<<"*"<<br<<endl;
}

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

	cin>>n;
	int a,b;
	int f=0;
	for(int i=0;i<n-1;i++)
    {
        cin>>a>>b;
        graf[a].push_back(b);
        graf[b].push_back(a);
        grane[make_pair(a,b)]=f;
        grane[make_pair(b,a)]=f;
        f++;
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        c[i]=make_pair(a,b);
        for(int i=1;i<=n;i++)
            mark[i]=false;
        gotov=false;
        dfs(a,b);
        napravi(i);
        //cout<<c2[i]<<endl;
    }
    sol=1;
    for(int i=0;i<n-1;i++)
        sol*=2;
    //cout<<"-"<<sol<<endl;
    int maxi=1<<m;
    ll tmp=(((ll)1)<<n)-1;
    for(int i=1;i<maxi;i++)
    {
        tmp=0;//(((ll)1)<<(n-1))-1;
        for(int j=0;j<m;j++)
        {
            int mask=1<<j;
            if((mask&i)>0)
                tmp=(tmp|c2[j]);//, cout<<"USO"<<i<<" "<<j<<" "<<c2[j]<<" "<<tmp<<endl;
        }
        ll teksol=1;
        int ostalo=n-1-__builtin_popcountll(tmp);
        //cout<<ostalo<<" "<<tmp<<" "<<__builtin_popcount(tmp);
        for(int i=0;i<ostalo;i++)
            teksol*=2;
        //cout<<"*"<<teksol<<endl;
        /*bitset<5> x(i);
        cout<<x<<" "<<ostalo<<endl;*/
        if(__builtin_popcountll(i)%2==1)
            sol-=teksol;
        else
            sol+=teksol;
    }
    cout<<sol;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n,m,c;
    cin >> n >> m >> c;
    int a[n][m];
    int b[m];
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int D = c;
        for (int j = 0; j < m; j++)
        {
            D += a[i][j] * b[j];
        }
        if (D>0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<iostream>
 
using namespace std;
 
int main(){
	int D, N;
	cin >> D >> N;
	if(N == 100){
		N += 1;
	}
	unsigned long long int ans = N;
	for(int i = 0; i < D; i++){
		ans *= 100;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int answer=1;
    for(int i=1;i<=N;i++){
       
       
       if(i*i>N){
        answer=(i-1)*(i-1);
        break;
       }

    }
    cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

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


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

#define MAX 10005
#define INF 200000000
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long llu;

using namespace std;

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

void IO()
{
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
}

bool isprime[MAX+5];

void sieve()
{
    int sq=sqrt(MAX);
    isprime[1]=true;
    for(int i=4;i<=MAX;i+=2)isprime[i]=true;
    for(int i=3;i<=sq;i+=2){
        if(!isprime[i]){
            for(int j=i*i;j<=MAX;j+=i*2){
                isprime[j]=true;
            }
        }
    }
}

int main()
{
    //IO();
    sieve();
    int n;
    while(~scanf("%d",&n)){
        bool flag=false;
        int cnt=0,lo=1,hi=n;
        while(lo<=hi){
            if(!isprime[lo]&&!isprime[hi]){
                cnt++;
                if(lo==hi)flag=true;
            }
            lo++,hi--;
        }
        printf("%d\n",flag?2*cnt-1:2*cnt);
    }
    return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main() {
    int n, q, a, b, c;
    cin >> n >> q;

    vector<queue<int>> v(n);

    for (int i = 0; i < q; i++) {
        cin >> a;

        if (a == 0) {
            cin >> b >> c;
            v[b].push(c);
        }
        else if (a == 1) {
            cin >> b;
            if (!v[b].empty())   cout << v[b].front() << endl;
        }
        else if (a == 2) {
            cin >> b;
            if (!v[b].empty())   v[b].pop();
        }
    }

    return 0;
}


Measured memory_bytes: 4228
s = input()
k = int(input())
l = []
for i in range(len(s)):
    l.append(s[i:])
    l.sort()
    if len(l) > 5:
        l.pop()

p = set()
for i in l:
    for j in range(1,len(i)+1):
        p.add(i[:j])

print(sorted(list(p))[k-1])

Measured memory_bytes: 41840
#include<stdio.h>
int main()
{
    int n, x, count=0;
    double probability;

    scanf("%d", &n);
    for(x=1; x<=n; x=x+2){
        count++;

    }
    probability = count/(double)n;

    printf("%.10lf\n", probability);

    return 0;
}


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

int main(){

    auto S = [](long a, long b, long h){
        a -= h;
        b -= h;
        if(a * b >= 0){
            return abs(a + b) / static_cast<long double>(2);
        }else{
            return (a * a + b * b) / static_cast<long double>(2 * (abs(a) + abs(b)));
        }
    };

    long n;
    cin >> n;

    vector<long> h(n);
    for(auto& i : h)cin >> i;

    constexpr int mx = 300;

    vector<vector<long double>> dp(n + 1, vector<long double>(mx, numeric_limits<long double>::max() / 100));

    dp[0][1] = 0;

    for(int i = 1; i <= n; ++i){
        for(int j = 1; j < mx; ++j){
            for(int k = 1; k < mx; ++k){
                dp[i][j] = min(dp[i][j], dp[i - 1][k] + S(j, k, h[i - 1]));
            }
        }
    }

    cout << setprecision(20) << *min_element(dp[n].begin(), dp[n].end()) << endl;

    return 0;
}


Measured memory_bytes: 3656