akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD_NUMBER 1000000007
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  int k;
  deque<long long> sample = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  cin >> k;
  if (k < 10) {
    cout << sample[k-1];
    return 0;
  }
  k -= 9;
  while (k > 0) {
    for (long long i = -1; i <= 1; i++) {
      if (0 <= sample[0]%10+i && sample[0]%10+i < 10) {
        sample.push_back(sample[0]*10+sample[0]%10+i);
        k--;
        if (k == 0) {
          break;
        }
      }
    }
    sample.pop_front();
  }
  cout << sample.at(sample.size()-1) << endl;
  return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

ll fact(ll n) {
    if (n == 1) {
        return 1;
    } else {
        return (n * fact(n - 1)) % MOD;
    }
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    ll ans = 0;
    if (abs(N-M) == 0) {
        ans = fact(N)*fact(M);
        ans *= 2;
        ans %= MOD;
    } else if (abs(N-M) == 1) {
        ans = fact(N)*fact(M);
        ans %= MOD;
    }

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

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

char x,y;

int main() {
    cin >> x >> y;
    int a = (int)x;
    int b = (int)y;
    char res;
    if(a<b){
        res = '<';
    }else if(a>b){
        res = '>';
    }else{
        res = '=';
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IOS ios::sync_with_stdio(false);cin.tie(0)

// *start on @date: 2020-02-16 20:03 

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


int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&b!=c)||(a==c&&c!=b)||(c==b&&b!=a))
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	function<int(int,int,int)> f = [&](int a, int b, int c) {
		if (a & 1 || b & 1 || c & 1)return 0;
		if (a == b&&b == c)return -1;
		return 1 + f((b + c) / 2, (a + c) / 2, (a + b) / 2);
	};
	cout << f(a, b, c) << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var tempArray = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var N = tempArray[0];
        var K = tempArray[1];
        var Q = tempArray[2];

        var memberPoints = new int[N];

        for(var i = 0; i < N; i++)
        {
            memberPoints[i] = K - Q;
        }

        for(var i = 0; i < Q; i++)
        {
            var A = int.Parse(Console.ReadLine());

            memberPoints[A - 1]++;
        }

        for (var i = 0; i < N; i++)
        {
            if (memberPoints[i] > 0)
            {
                Console.WriteLine("Yes");
            }
            else if (memberPoints[i] <= 0)
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 18012
n = int(input())
la = [int(w) for w in input().split()]

cnt = [0]*9
for a in la:
    if a > 3200:
        a = 3200
    cnt[a // 400] += 1

mi = len([_ for _ in cnt[:8] if _ > 0])
ma = mi+cnt[8]

if mi == 0:
    mi = 1

print(mi, ma)


Measured memory_bytes: 9124
N = int(input())
K = int(input())
p = (list(map(int,input().split())))
ans = 0
for i in range(N):
    if abs(p[i] - 0) < abs(p[i] - K):
        ans += abs((p[i]-0) * 2)
        
    else:
        ans += abs((p[i]-K) * 2)
        
print(ans)

Measured memory_bytes: 3060
S = input()
dict_S = {}
for s in S:
    if s not in dict_S:
        dict_S[s] = 1
    else:
        dict_S[s] += 1

if len(dict_S) > 2:
    print("No")
else:
    cnt = 0
    for s in dict_S.values():
        if s == 2:
            cnt += 1
    if cnt == 2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main(){

	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++){
	
		ans+=(s[i]-'0');
	}
	if(ans%9==0){
	
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3720
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

bool isP(string s) {
	int sz = s.length();
	int ptr1 = 0, ptr2 = sz - 1;
	while (ptr1 < ptr2) {
		if (s[ptr1] != s[ptr2]) return false;
		++ptr1; --ptr2;
	}
	return true;
}

int main() {
	string s; cin >> s;
	bool res = isP(s);
	res = res && isP(s.substr(0, (s.length() - 1) / 2));
	res = res && isP(s.substr((s.length() + 3) / 2 - 1, s.length() - (s.length() + 3) / 2 + 1));
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  sort(A.rbegin(), A.rend());
  i64 sum = 0;
  for (i64 i = 0; i < N; i++)
    sum += A[i];
  i64 cnt = 0;
  for (i64 i = 0; i < N; i++)
    if (sum <= A[i] * 4 * M)
      cnt++;
  if (M <= cnt)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int32_t main()
{
 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 int a,b,c,k;
 cin>>a>>b>>c;
 cin>>k;
 while(k>0)
 {
     if(b<=a){b*=2;}
     else{c*=2;}
     k--;
 }
 if(b>a && c>b){
    cout<<"Yes"<<endl;
 }
 else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
//#include "atcoder/all"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
//using namespace atcoder;
typedef long long int ll;
typedef pair<int, int> 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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = l; i <= r; ++i){
		if(i%d == 0) ++ans;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l.at(i);
  sort(l.begin(), l.end());
  ll sum = 0;
  for (int i = 0; i < n - 1; i++) sum += l.at(i);
  if (l.at(n - 1) < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    int i;
    for(i=0;i<n;i++)cin>>v.at(i);
    sort(v.begin(),v.end());
    double ans=(double)v.at(0);
    for(i=1;i<n;i++)
    {
        ans = (ans+v.at(i))/2.0;
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  auto did = mvec<bool>(N);
  auto uvw = mvec<P>(N,0);
  rep(i, 0, N-1){
    ll u, v, w;
    cin >> u >> v >> w;
    uvw[u-1].push_back(P(v-1,w%2));
    uvw[v-1].push_back(P(u-1,w%2));
  }
  auto ans = mvec<bool>(N);
  auto func = [&](auto& func, ll& u) -> void{
    for(auto&& i : uvw[u]){
      auto& v = i.first;
      auto& w = i.second;
      if(w) ans[v] = !ans[u];
      else ans[v] = ans[u];
      if(did[v]==0){
        did[v] = 1;
        func(func, v);
      }
    }
  };
  ll n{};
  func(func, n);
  for(auto&& i : ans){
    cout << i << rt;
  }
}

Measured memory_bytes: 8192
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        char c;
        cin >> c;
        if(isupper(c)){
            cout <<"A";
        }
        else{
            cout << "a";
        }
    }

    return 0;
}


Measured memory_bytes: 3584
fn main() {
    let n: usize = read();
    let m = n / 500;
    println!("{}", m * 1000 + ((n - m * 500) / 5) * 5);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
// 2000000000
// 2000000000

// =========


Measured memory_bytes: 4352
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

vector<vector<char>> grid;
vector<bool> visited;
ll W, H;

struct P {
    ll x;
    ll y;
    ll encode() {
        return x + y * W;
    }
    static P decode(ll code) {
        return {code % W, code / W};
    }
};

pair<ll, ll> collect(P now) {
    visited[now.encode()] = true;
    pair<ll, ll> ans;
    if (grid[now.x][now.y] == '#') {
        ans.first++;
    } else {
        ans.second++;
    }
    rep(d,0,4) {
        P vec;
        if (d == 0) {
            vec = {-1, 0};
        } else if (d == 1) {
            vec = {1, 0};
        } else if (d == 2) {
            vec = {0, 1};
        } else {
            vec = {0, -1};
        }
        P next = {now.x + vec.x, now.y + vec.y};
        if (!(0 <= next.x && next.x < W && 0 <= next.y && next.y < H)) {
            continue;
        }
        if (visited[next.encode()]) {
            continue;
        }
        if (grid[now.x][now.y] == grid[next.x][next.y]) {
            continue;
        }
        pair<ll,ll> ans_sub = collect(next);
        ans.first += ans_sub.first;
        ans.second += ans_sub.second;
    }
    return ans;
}

int main() {
    cin >> H >> W;
    grid = make_vec_nd('0', W, H);
    rep(y,0,H) {
        rep(x,0,W) {
            char c;
            cin >> c;
            grid[x][y] = c;
        }
    }
    visited = vector<bool>(W*H);
    ll ans = 0;
    rep(now,0,W*H) {
        if (!visited[now]) {
            pair<ll,ll> ans_sub = collect(P::decode(now));
            ans += ans_sub.first * ans_sub.second;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
int n,a,b,sum;
int main()
{
	 cin>>n;
	 for(int i=1;i<=n;i++)
	 {
	 	cin>>a>>b;
	 	if(a==b)
	 	{
	 		sum++;
		 }
		else
		sum+=b-a+1;
	 }
	 cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
#<<>>><>>

g=[0 for i in range(len(s)+1)]
l=[0 for i in range(len(s)+1)]

for i in range(len(s)):
  if s[i]=="<":
    g[i+1]=g[i]+1

for i in range(len(s)-1,-1,-1):
  if s[i]==">":
    l[i]=l[i+1]+1
    
ans=0
for i in range(len(s)+1):
  ans+=max(g[i],l[i])

print(ans)




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

int main()
{
    int n,i,c=0,a,b;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d%d",&a,&b);

        c = abs(b-a)+1+c;

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

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath> 
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a*100+b*10+c)%4==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
   int  a,b,c;
cin >> a >> b >>c;
   cout <<max(max((10*a+b+c),(10*b+a+c)),(10*c+a+b));
}


Measured memory_bytes: 256
/*
04:47 - 5:08
 */
#include<iostream>
#include<cmath>
#include<cassert>
#include<climits>
#include<algorithm>
#include<vector>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)

using namespace std;

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

string lcs(string A,string B){
  int lena = A.size();
  int lenb = B.size();
  int dp[lena+1][lenb+1],path[lena+1][lenb+1];
  for(int i=0;i<=lena;i++)for(int j=0;j<=lenb;j++)dp[i][j] = 0, path[i][j] = -1;

  for(int i=0;i<lena;i++){
    for(int j=0;j<lenb;j++){
      if(A[i] == B[j]){
	dp[i+1][j+1] = dp[i][j] + 1; 
	path[i+1][j+1] = 0;
      } else {
	if(dp[i+1][j] < dp[i][j+1]){
	  dp[i+1][j+1] = dp[i][j+1];
	  path[i+1][j+1] = 2;
	} else {
	  dp[i+1][j+1] = dp[i+1][j];
	  path[i+1][j+1] = 1;
	}
      }
    }
  }

  string ret = "";
  int x = lenb, y = lena;
  while(true){
    if(!( 0 <= x && x <= lenb && 0 <= y && y <= lena ))break;
    if(path[y][x] == -1)break;
    if(path[y][x] == 0){
      ret += A[y-1];
    }
    int dir = path[y][x];
    x += dx[dir], y += dy[dir];
  }
  reverse(ret.begin(),ret.end());
  return ret;
}

int main(){
  string line;
  while(cin >> line,line != "#END"){
    string ans = "";
    for(int i=0;i<line.size()-1;i++){
      string A = line.substr(0,i+1);
      string B = line.substr(i+1);
      string C = lcs(A,B);
      if( C.size() > ans.size() ){
	ans = C;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e9+9;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const int M =105;
int n,k;
int a[M];
int dp[M][M][M];
int solve(int left,int right,int step){ 
    if(step<0)
        return -OO;
    if(left>right||step==0)
        return 0;
    int &ret = dp[left][right][step];
    if(~ret)
        return ret;
    ret = 0;
    int leave_right = solve(left,right-1,step-2);
    int leave_left  = solve(left+1,right,step-2);
    int take_left = solve(left+1,right,step-1)+a[left];
    int take_right = solve(left,right-1,step-1)+a[right];
    return ret = max(ret,max(max(leave_left,leave_right),max(take_left,take_right)));
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    memset(dp,-1,sizeof(dp));
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    printf("%d",solve(1,n,k));
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, m, a;

	cin >> n >> m;

	vector<ll> v;
	priority_queue<ll> q;

	REP(i, n) {
		cin >> a;
		v.push_back(a);
		q.push(a);
	}

	REP(i, m) {
		ll x = q.top();
		q.pop();
		q.push(x / 2);
	}

	ll ans = 0;

	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}

	cout << ans << endl;
}

Measured memory_bytes: 2036
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	String S = sc.next();

	if(S.equals("Sunny")){

	System.out.println("Cloudy");

  }

	else if(S.equals("Cloudy")){

	System.out.println("Rainy");

  }

	else{

	System.out.println("Sunny");

  }

 }
}


Measured memory_bytes: 21588
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    loop {
        let nums: Vec<usize> = get_line().trim()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let (w, h): (usize, usize) = (nums[0], nums[1]);
        if w == 0 && h == 0 {
            break;
        }
        for wi in 0..w {
            for hi in 0..h {
                if wi % 2 == 0 {
                    if hi % 2 == 0 {
                        print!("#");
                    } else {
                        print!(".");
                    }
                } else {
                    if hi % 2 == 0 {
                        print!(".");
                    } else {
                        print!("#");
                    }
                }
            }
            println!("");
        }
        println!("");
    }
}



Measured memory_bytes: 5020
def LCS(X,Y):
    m,n=len(X),len(Y)
    MAP=[[0 for i in range(m)] for j in range(n)]
    for i in range(1,n):
        for j in range(1,m):
            if Y[i]==X[j]:
                MAP[i][j]=MAP[i-1][j-1]+1
            else:
                MAP[i][j]=max(MAP[i][j-1],MAP[i-1][j])

    i,j=n-1,m-1
    ans=""
    while MAP[i][j]!=0:
        if MAP[i][j]==MAP[i-1][j]:i -=1
        elif MAP[i][j]==MAP[i][j-1]:j -=1
        else:
            ans +=Y[i]
            i -=1
            j -=1
    return ans[::-1]

print(LCS(" "+input()," "+input()))

Measured memory_bytes: 119644
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let s: Vec<char> = sc.chars();
    let N = s.len();
    let mut ans = INF;
    for maxc in (b'a'..b'z'+1).map(|c| char::from(c)) {
        if s.iter().all(|&i| i == maxc) {
            println!("0");
            return;
        }
        let mut pt = s.clone();
        for c in 1..N {
            let mut t = vec!['0'; N-c];
            for i in 0..pt.len()-1 {
                if pt[i] == maxc || pt[i+1] == maxc {
                    t[i] = maxc;
                } else {
                    t[i] = pt[i];
                }
            }
            if t.iter().all(|&i| i == maxc) {
                ans = min(ans, c);
                break;
            }
            pt = t;
        }
    }
    println!("{}", ans);
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int N, K; cin >> N >> K;
    vector<int> l(N);
    rep(i, N) cin >> l[i];
    sort(all(l), greater<int>());
    int ans = 0;
    rep(i, K) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/
double len(pdd a, pdd b)
{
	return sqrt((b.first - a.first)*(b.first - a.first) + (b.second - a.second)*(b.second - a.second));
}

int main()
{
	int p[8];
	while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7])
	{
		int c[8] = { 1,2,1,2,1,4,1,4 };
		int l = -1, m = -1;
		long long v = LLONG_MAX;
		FOR(i, 8)
		{
			int s = 0;
			FOR(k, 8)
			{
				s += min(p[k], c[k]);
			}
			if (s > m)
			{
				long long t = 0;
				FOR(j, 8)
				{
					t += c[j] * pow(10, 7 - j);
				}

				m = s;
				l = i;
				v = t;
			}
			else if (s == m)
			{
				long long t = 0;
				FOR(j, 8)
				{
					t += c[j] * pow(10, 7 - j);
				}
				if (t < v)
				{
					m = s;
					l = i;
					v = t;
				}
			}

			FOR(k, 8 - 1)
			{
				swap(c[k], c[k + 1]);
			}
		}
		FOR(i, l)
		{
			FOR(k, 8 - 1)
			{
				swap(c[k], c[k + 1]);
			}
		}
		FOR(i, 8)
		{
			if (i)cout << " ";
			cout << c[i];
		}
		cout << endl;
	}
}

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

int main()
{
	long long n;
	cin>>n;
	long long ans=1;
	for (int i=1;i<=n;i++)
	 ans*=3;
	long long kurang=1;
	for (int i=1;i<=n;i++)
	{
		long long k;
		cin>>k;
		if (k%2==1)
		 kurang*=1;
		else
		 kurang*=2;
	}
	ans-=kurang;
	cout<<ans<<"\n";
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  string s;
  cin >> s;
  if(s <= "2019/04/30") cout << "Heisei\n";
  else cout << "TBD\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b ;
	cin >> a >> b ;
	if(a+1<b||b+1<a){
		cout << 0 << endl ;
		return 0 ;
	}
	ll ans = 1 ;
	for(int i=1;i<=a;i++) ans = ans*i%mod ;
	for(int i=1;i<=b;i++) ans = ans*i%mod ;
	if(a==b) ans = ans*2%mod ;
	cout << ans << endl ;
}


Measured memory_bytes: 256
using System;

namespace ALDS1_4
{
    class Program
    {
        const int M = 1046527;
        static string[] H = new string[M];

        static int char2int (char c)
        {
            switch (c)
            {
                case 'A': return 1;
                case 'C': return 2;
                case 'G': return 3;
                case 'T': return 4;
                default: return 0;
            }
        }

        static long getKey (string str)
        {
            long ret = 0, p = 1;
            for (var i = 0; i < str.Length; i++)
            {
                ret += p * char2int(str[i]);
                p *= 5;
            }
            return ret;
        }

        static long h1 (long key)
        {
           return key % M;
        }

        static long h2 (long key)
        {
            return 1 + (key % (M - 1)); 
        }

        static bool find (string str)
        {
            long key, h;
            key = getKey(str);        
            for (var i = 0; ;i++)
            {
                h = (h1(key) + i * h2(key)) % M;
                if (H[h] == str) return true;
                else if (H[h] == "\0") return false;
            }
        }

        static void insert (string str)
        {
            long key, h;
            key = getKey(str);
            for (var i = 0; ;i++)
            {
                h = (h1(key) + i * h2(key)) % M;
                if (H[h] == str) break;
                else if (H[h] == "\0")
                {
                  H[h] = str;
                  break;
                };
            }
        }

        static void Main()
        {
            for(var i = 0; i < M; i++)
                H[i] = "\0";
            
            var n = int.Parse(Console.ReadLine());
            for (var i = 0; i < n; i++)
            {
                var _t = Console.ReadLine();

                if (_t[0] == 'i')
                    insert(_t.Substring(7));
                else
                    Console.WriteLine(find(_t.Substring(5)) ? "yes" : "no");
            }
        }
    }
}

Measured memory_bytes: 37664
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,j,a,b,k=-1;
    cin >> a >> b;
    if(a != b){
        for(i=0;i<1000000000;i++){
            if(a-i<=0){
                if(b-i == -a+i){
                    k = 0;
                    cout << i;
                    break;
                }
            }
            else{
                if(a-i==-b+i){
                    k = 0;
                    cout << i;
                    break;
                }
            }
        }
        if(k==-1){
            cout << "IMPOSSIBLE";
        }
    }
    else{
        cout << "0";
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
int bfs(P sg,int home);
int w,h;
int mas[10][10];
int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
P sg;

int main(){
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		int home = 0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> mas[i][j];
				if(mas[i][j] == 1) home++;
				else if (mas[i][j] == 2) sg = P(j,i);
			}
		}
		cout << bfs(sg,home) << endl;
	}
}

int bfs(P now,int home){
	if(home == 0){
		if(now.first == sg.first || now.second == sg.second) return 1;
		else return 0;
	}
	int ret = 0;
	for(int i=0;i<4;i++){
		P p = now;
		while(1){
			p.first += dx[i]; p.second += dy[i];
			if(p.first >= 0 && p.second >= 0 && p.first < w && p.second < h){
				if(mas[p.second][p.first] == 1) break;
			}else{
				p = P(-1,-1); break;
			}
		}
		if(p.first == -1) continue;
		mas[p.second][p.first] = -1;
		ret += bfs(p,home-1);
		mas[p.second][p.first] = 1;
	}
	return ret;
}

Measured memory_bytes: 1160
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    string s, t; cin >> s >> t;
    int m = 0;

    rep(i, s.size() - t.size() + 1){
        int a = 0;
        rep(j, (int)t.size()){
            if(i+j >= (int)s.size()) break;
            if(s[i+j] == t[j]) a++;
        }
        chmax(m, a);
    }

    pr((int)t.size() - m);
    return 0;}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;


public class Main{

    static int INFTY = Integer.MAX_VALUE;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            
        int N = sc.nextInt();
        int L = sc.nextInt();
        int[] arr = new int[N+1];
        int minAbs=INFTY;
        int minNum=0;
        int ans=0;
        for(int i=1;i<=N;i++){
            arr[i]=L+i-1;
            ans+=arr[i];
            if(minAbs>Math.abs(arr[i])){
                minAbs=Math.abs(arr[i]);
                minNum=i;
            }
        }
        ans=ans-arr[minNum];
        System.out.println(ans);

    }


}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <limits>


//グラフクラス
class Graph {
public:
	//エッジ
	struct Edge {
		//接続先のノード番号
		int node;
		//移動コスト
		int cost;
	};
	//ノード
	struct Node {
		//近隣のノード
		std::vector<Edge> edges;
	};
	//コンストラクタ
	Graph(std::istream& in) {
		//ノードとエッジ数の読み込み
		int n, e;
		in >> n >> e >> startNode_;
		//ノード用の配列を初期化
		nodes_.resize(n);
		
		//エッジデータの読み込み
		for (int i = 0; i < e; i++) {
			//始点・終点のノード番号を読み込む
			int s, t, c;
			in >> s >> t >> c;
			nodes_[s].edges.push_back({t,c});
		}
	}
	//ノードを取得
	const Node& operator[](int index)const {
		return nodes_[index];
	}
	//ノード数を取得
	std::size_t node_const() const {
		return nodes_.size();
	}
	//スタートノード
	int StartNode()const {
		return startNode_;
	}
private:
	//ノード用配列
	std::vector<Node> nodes_;
	int startNode_;
};

//パス検索クラス
class PathFinder {
	//距離とノード番号のペア
	using dist_node = std::pair<int, int>;
public:
	static std::vector<int> path_cost(const Graph& graph, int start) {
		std::vector<int> result;

		//最大値
		const auto inf = std::numeric_limits<int>::max();
		//経路情報                          数                  初期値
		std::vector<dist_node> dist_nodes(graph.node_const(), { inf,-1 });
		//プライオリティキュー                               小さいほうからとるようになる
		std::priority_queue<dist_node, std::vector<dist_node>, std::greater<dist_node>> queue;
		//開始ノードをキューに登録
		dist_nodes[start] = { 0,-1 };
		queue.push({ 0,start });
		//キューにデータがあるか?
		while (!queue.empty()) {
			//先頭ノードをキューから取り出す
			const auto front = queue.top(); queue.pop();
			const auto front_g = front.first;
			const auto front_node = front.second;

			//キュー内のデータよりも経路情報の合計距離が小さい?
			if (dist_nodes[front_node].first < front_g) continue; //キュー内のデータは最短距離ではないので無視
																  //周辺のノードを取得
			for (const auto& edge : graph[front_node].edges) {
				//合計距離を求める(移動コストは1.0とする)
				const auto g = dist_nodes[front_node].first + edge.cost;
				//合計距離が小さい場合は最短経路としてキューに登録
				if (dist_nodes[edge.node].first > g) {
					//経路情報を保存
					dist_nodes[edge.node] = { g,front_node };
					//キューに登録
					queue.push({ g,edge.node });
				}
			}
		}

		for (int i = 0; i < graph.node_const(); i++) {
			if (dist_nodes[i].first == inf) {
				result.push_back(-1);
			}
			else {
				result.push_back(dist_nodes[i].first);
			}
		}
		return result;
	}
};


int main() {
	Graph graph(std::cin);
	std::vector<int> n = PathFinder::path_cost(graph, graph.StartNode());

	for (int i = 0; i < n.size(); i++) {
		if (n[i] == -1) {
			std::cout << "INF" << std::endl;
		}
		else {
			std::cout << n[i] << std::endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 13516
#include<stdio.h>

int N,data[100];

void input(){
  scanf("%d",&N);
  int i;
  for(i = 0; i < N; i++) scanf("%d",&data[i]);
}

void print(){
  int i;
  for(i = 0; i < N; i++){
    if(i) printf(" ");
    printf("%d",data[i]);
  }
  printf("\n");
}

void insertion_sort(){
  print();
  int i,j;
  for(j = 1; j < N; j++){
    int key = data[j];
    i = j-1;
    while(i >= 0 && data[i] > key){
      data[i+1] = data[i];
      i--;
    }
    data[i+1] = key;
    print();
  }
}

int main(){
  input();
  insertion_sort();
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vecll var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prseq(var, n)    rep(i,n){cout << var[i] << " ";} cout << endl
#define prseql(var, n)   rep(i,n){cout << var[i] << " " << endl;}

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(h,n);

  if(n==1){
    prt("Yes"); return 0;
  }

  rep(i,n-1){
    if(h[n-i-2]-h[n-i-1]>1){
      prt("No"); return 0;
    } else if (h[n-i-2]-h[n-i-1]==1){
      h[n-i-2]--;
    }
  }

  prt("Yes");

}


Measured memory_bytes: 1024
#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()
{
    int n;
    cin >> n;
    vector<string> s(n, "");
    rep(i, n)
    {
        cin >> s[i];
    }
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;

    rep(i, n)
    {
        if (s[i] == "AC")
        {
            a++;
        }
        else if (s[i] == "WA")
        {
            b++;
        }
        else if (s[i] == "TLE")
        {
            c++;
        }
        else if (s[i] == "RE")
        {
            d++;
        }
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}


Measured memory_bytes: 6428
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;
int isxor(int a[],int num,int j){
	int ans=0;
	for(int i=j;i<=num;i+=j){
		if(a[i]==1){
			ans^=1;
		}
	}
	return ans;
}
int main(){
	int num=0,a[200001]={},ans[200001]={};
	cin>>num;
	for(int i=1;i<=num;i++){
		cin>>ans[i];
	}
	for(int i=num;i>0;i--){
		ans[i]=isxor(ans,num,i)^a[i];
		if(ans[i]==1)ans[0]++;
	}
	cout<<ans[0]<<endl;
	for(int i=1;i<=num;i++){
		if(ans[i]==1)cout<<i<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

  public static void main(String[] args) {
    new Main().solve();
  }

  public void solve() {

    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    String s = input.next();

    String[] s1 = new String[n - 1];
    String[] s2 = new String[n - 1];
    for (int i = 0; i < n - 1; i++) {
      s1[i] = s.substring(0, i + 1);
      s2[i] = s.substring(i + 1);
    }

    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
      Map<Character, Integer> sum1 = new HashMap<>();
      Map<Character, Integer> sum2 = new HashMap<>();

      char[] c1 = s1[i].toCharArray();
      char[] c2 = s2[i].toCharArray();
      for (int j = 0; j < c1.length; j++)
        if (sum1.containsKey(c1[j])) {
          sum1.put(c1[j], sum1.get(c1[j]) + 1);
        } else {
          sum1.put(c1[j], 1);
        }
      for (int k = 0; k < c2.length; k++)
        if (sum2.containsKey(c2[k])) {
          sum2.put(c2[k], sum2.get(c2[k]) + 1);
        } else {
          sum2.put(c2[k], 1);
        }
      Set<Character> keys = sum1.keySet();
      Iterator<Character> it = keys.iterator();
      int tmp = 0;
      while (it.hasNext()) {
        if (sum2.containsKey(it.next())) {
          tmp++;
        }
      }
      cnt = Math.max(cnt, tmp);
    }

    System.out.println(cnt);
  }
}


Measured memory_bytes: 22996
# coding: utf-8
from itertools import *
import sys
import time


#################### library ####################


#################### naive ####################


#################### process ####################

def read_array():
	N = int(input())
	A = map(int, raw_input().split())
	return A


#################### main ####################

#t0 = time.clock()
A = read_array()
print 1./sum(1./a for a in A)
#print >>sys.stderr, "%.6fsec" % (time.clock() - t0,)


Measured memory_bytes: 2688
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;i++)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;


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

	vector<int> v(m);
	rep(i, 0, m)
		cin >> v[i];

	int INF = 100000;
	vector< vector<int> >dp(m+1,vector<int>(n+1,INF));

	dp[0][0] = 0;

	rep(i,0,m) {
		rep(j,0,n+1){
			if (j - v[i] >= 0) {
				dp[i + 1][j] = min(dp[i+1][j - v[i]] + 1, dp[i][j]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}

	cout << dp[m][n] << endl;
		

	return 0;
}



Measured memory_bytes: 7108
#include<stdio.h>
#define MOD 10000
int plan[110];
int dp[110][4][4];
int main(void){
    int n,k;
    int i,j,l,m,x,y,date;
    int a,b;
    int ans;

    scanf("%d%d",&n,&k);
    for(i=0;i<k;i++){
	scanf("%d%d",&a,&b);
	plan[a]=b;
    }

    for(i=1;i<=3;i++){
	for(j=1;j<=3;j++){
	    dp[1][i][j]=1;
	}
    }

    if(plan[1]!=0){
	for(i=1;i<=3;i++) for(j=1;j<=3;j++){
	    if(i!=plan[1]) dp[1][i][j]=0;
	}
    }
    if(plan[2]!=0){
	for(i=1;i<=3;i++) for(j=1;j<=3;j++){
	    if(j!=plan[2]) dp[1][i][j]=0;
	}
    }

/*
    for(i=1;i<=3;i++){
	for(j=1;j<=3;j++){
	    printf("%d,%d %d\n",i,j,dp[1][i][j]);
	}
    }
*/
 
    for(date=2;date<=n-1;date++){
	for(i=1;i<=3;i++) for(j=1;j<=3;j++){
	    for(l=1;l<=3;l++) for(m=1;m<=3;m++){
		if(j==l && !(i==j&&l==m)){
		    dp[date][l][m]=(dp[date][l][m]+dp[date-1][i][j])%MOD;
		}
		if(plan[date]!=0){
		    for(x=1;x<=3;x++) for(y=1;y<=3;y++){
			if(x!=plan[date]) dp[date][x][y]=0;
		    }
		}
		if(plan[date+1]!=0){
		    for(x=1;x<=3;x++) for(y=1;y<=3;y++){
		        if(y!=plan[date+1]) dp[date][x][y]=0;
		    }
		}
	    }
	}
    }

    ans=0;
    for(i=1;i<=3;i++){
	for(j=1;j<=3;j++){
	    ans=(ans+dp[n-1][i][j])%MOD;
	}
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 600
x,y=input().split()
a=["1","3","5","7","8","10","12"]
b=["4","6","9","11"]
c=["2"]
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")


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

int main() {
    int N;          //紙幣の合計枚数N枚
    int Y;          //合計金額Y円
    cin >> N >> Y;      
    int x, y, z;    //10000円x枚、5000円y枚、1000円z枚

    Y /= 1000;      //Yを1000で割った値をYに代入
    int t = 0;      /* tが0のとき条件を満たす組み合わせは存在しない。
                       tが1のとき条件を満たす組み合わせは存在する。 */

    for(int i = 0; i <= N; i++) {           //xがi枚(0<=i<=N)
        for(int j = 0; j <= N-i; j++) {     //yがj枚(0<=j<=N-i)
            if(Y == N + 9*i + 4*j) {
                x = i;
                y = j;
                z = N - i - j;
                cout << x << " " << y << " " << z;
                ++t;
                break;
            }
        }
        if(t > 0){
            break;
        }
    }

    if(t == 0) {
        cout << -1 << " " << -1 << " " << -1;
    }
    
    cout << endl;

    return 0;
}

Measured memory_bytes: 256