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

int main(void) {
  char a; /* 加算の結果 */

  scanf("%c", &a);
  switch (a) {
    case 'A':
      printf("T");
      break;
    case 'C':
      printf("G");
      break;
    case 'G':
      printf("C");
      break;
    case 'T':
      printf("A");
      break;
  }


  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
all = sum(a)
mod = pow(10, 9)+7
all %=mod
count = 0
for i in range(n-1):
    all=(all+mod-a[i])%mod
    x = a[i]
    seki = (x*all)%mod
    count += seki
    count%=mod
print(count)

Measured memory_bytes: 94136
# abc173_b.py
N = int(input())
M = [input() for i in range(N)]
ac=0
wa=0
tle=0
re=0
for i in M:
    if i =="AC":
        ac+=1
    if i =="WA":
        wa+=1
    if i =="TLE":
        tle+=1
    if i =="RE":
        re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int n,k;
  cin>>n>>k;
  double ans = 0.0;
  for (int i=1; i<=n; i++) {
    int t=1;
    while(i*t<k) {
      t*=2;
    }
    ans += 1.0/(double)n/(double)t;
  }
  cout << setprecision(12) << ans << endl;
}

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


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

int main(){
    string S;
    cin >> S;
    if(S == "SUN"){
        cout << 7 << endl;
    }
    else if(S == "MON"){
        cout << 6 << endl;
    }
    else if(S == "TUE"){
        cout << 5 << endl;
    }
    else if(S == "WED"){
        cout << 4 << endl;
    }
    else if(S == "THU"){
        cout << 3 << endl;
    }
    else if(S == "FRI"){
        cout << 2 << endl;
    }
    else if(S == "SAT"){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}
lli modInverse(lli a, lli m) 
{
    lli m0 = m; 
    lli y = 0, x = 1; 
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    {  
        lli q = a / m; 
        lli t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }  
    if (x < 0) 
       x += m0; 
    return x; 
} 
const int N=(1<<20);

int main() 
{ 
  fastio;
  int n,r;cin>>n>>r;
  if(n<10){
      cout<<r+100*(10-n)<<"\n";
  }  
  else{
      cout<<r<<"\n";
  }
  return 0; 	
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	int n, x; cin >> n >> x;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) a[i] = abs(x-a[i]);
	
	int ans = 0;
	rep(i, n) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout<<(a)<<endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

void solve(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--; y--;
        uf.merge(x,y);
    }
    int part=0;
    int child=0;
    map<int,int>used;
    rep(i,n){
      if(used[uf.root(i)]==0){
          part++;
          used[uf.root(i)]++;
          
      }else{
          child++;
      }
    }
    cout<<n-child<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Measured memory_bytes: 6528
N = int(input())

W = [None] * N

for i in range(N):
    W[i] = input()

W_uniq = set(W)
if len(W) != len(W_uniq):
    print("No")
    exit()

last = W[0][-1]

for i in range(1, N):
    if W[i][0] != last:
        print("No")
        exit()
    last = W[i][-1]
print("Yes")

Measured memory_bytes: 3064
# https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_b
n = gets.to_i
tasks = Hash.new(0)
gets.split.map { |i| tasks[i.to_i] += 1 }
m = gets.to_i
scores = gets.split.map(&:to_i)

valid = true
scores.each do |score|
  valid = false unless tasks[score] > 0
  break unless valid

  tasks[score] -= 1
end

puts valid ? 'YES' : 'NO'


Measured memory_bytes: 40396
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,t,k,B,dp[1001][1001];
char arr[1001][1001];
int main () {
    cin>>n>>m;
    for (i=1;i<=n;i++) {
        for (j=1;j<=m;j++) {
            cin>>arr[i][j];
        }
    }
    B=1e9+7;
    for (i=1;i<=m;i++) {
        if (arr[1][i]=='#') break;
        dp[1][i]=1;
    }
    for (i=1;i<=n;i++) {
         if (arr[i][1]=='#') break;
        dp[i][1]=1;
    }
    for (i=2;i<=n;i++) {
        for (j=2;j<=m;j++) {
            if (arr[i][j]=='#') continue;
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]=dp[i][j]%B;
        }
    }
    cout<<dp[n][m]<<endl;
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int N;

int dfs(int depth, int a, int b, int c)
{
    if(N == a && N == b && N == c) return depth;
    else if( (a - N == 1 && b - N == 1) || (a - N == 1 && c - N == 1) && (c - N == 1 && b - N == 1)) return depth +1;
    else if( (a == N && b == N && N - c == 1) || (a == N && c == N && N - b == 1) || (b == N && c == N && N - a == 1) ) return depth + 2;

    int score = INF;
    bool flag = true;
    if(N - a > 0 && N -b > 0)
    {
        score = min(score, dfs(depth + 1, a + 1, b + 1, c));
        flag = false;
    }
    if(N - a > 0 && N -c > 0)
    {
        score = min(score, dfs(depth + 1, a + 1, b, c + 1));
        flag = false;
    }
    if(N - c > 0 && N -b > 0)
    {
        score = min(score, dfs(depth + 1, a, b + 1, c + 1));
        flag = false;
    }
    if(flag)
    {
        if(N-a > 1) score = min(score, dfs(depth + 1, a + 2, b, c));
        if(N-b > 1) score = min(score, dfs(depth + 1, a, b+2, c));
        if(N-c > 1) score = min(score, dfs(depth + 1, a, b, c+2));
    }
    return score;
}

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    N = max(A, max(B, C));
    cout << dfs(0, A, B, C) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
        int count = 0;

        for(int i = 0; i < n; i++){
            if(sc.nextInt() >= k) count++;
        }

        System.out.println(count);

    }

}


Measured memory_bytes: 46276
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

const uint64_t INF = static_cast<uint64_t>(-1);

struct VectorItem
{
  uint64_t w, v;
  VectorItem(uint64_t w = INF, uint64_t v = 0) : w(w), v(v) {}
};

istream& operator>>(istream &is, VectorItem &item)
{
  is >> item.w >> item.v;
  return is;
}

const uint64_t MAX_VALUE = 1e+2 * 1e+3;

int main()
{
  uint64_t N, W;
  cin >> N >> W;

  vector<VectorItem> items(N);
  N_TIMES(n, N) { cin >> items[n]; }

  array<vector<uint64_t>, 2> dp;
  N_TIMES(i, 2) { dp[i] = vector<uint64_t>(MAX_VALUE + 1, INF); }
  dp[0][0] = 0;

  N_TIMES(n, N) {
    N_TIMES(v, MAX_VALUE + 1) {
      if (dp[n % 2][v] == INF) { continue; }

      dp[(n + 1) % 2][v] = min(dp[(n + 1) % 2][v], dp[n % 2][v]);

      if ((v + items[n].v <= MAX_VALUE) && (dp[n % 2][v] + items[n].w <= W)) {
        dp[(n + 1) % 2][v + items[n].v] = min(
          min(
            dp[(n + 1) % 2][v + items[n].v],
            dp[n % 2][v + items[n].v]
          ),
          dp[n % 2][v] + items[n].w
        );
      }
    }
  }

  uint64_t max_value = 0;
  N_TIMES(v, MAX_VALUE + 1) {
    if (dp[N % 2][v] == INF) { continue; }
    max_value = v;
  }
  cout << max_value << endl;

  return 0;
}

Measured memory_bytes: 1792
w = input()
abc = 'abcdefghijklmnopqrstuvwxyz'
dic = {}
for s in abc:
    dic[s] = 0

for s in w:
    dic[s] += 1
ch = 0
for s in abc:
    if dic[s]%2 != 0:
        ch = 1
if ch == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	
	
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	
	ll ans=H*W-(h*W)-(H*w)+(h*w);
	ce(ans)
	

}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;




public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e18;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 32;
    public static int[] Bit;
    public static long[] dp;
    public static long[] fac,inv;
	public static void main(String[] args) {
	
	FastReader sc = new FastReader();
	
	int n = sc.nextInt();
	int[][] dp = new int[10][10];
	for(int i=1;i<=n;++i) {
		int dig = (int) Math.log10(i);
		dp[(int) (i/Math.pow(10, dig))][i%10]++;
	}
	long ans = 0;
	for(int i=1;i<10;++i) {
		for(int j=1;j<10;++j)
			ans+=dp[i][j] * dp[j][i];
	}
	
	out.print(ans);
	out.close();
}
}

Measured memory_bytes: 21332
import itertools
n = int(input())
l = []
counts = []
ans = 0
for i in range(5):
  l.append(set([]))

for i in range(n):
  temp = input()
  
  if temp[0] == 'M':
    l[0].add(temp)
  elif temp[0] == 'A':
    l[1].add(temp)
  elif temp[0] == 'R':
    l[2].add(temp)
  elif temp[0] == 'C':
    l[3].add(temp)
  elif temp[0] == 'H':
    l[4].add(temp)

for i in l:
  if not len(i) == 0:
    counts.append(len(i))

if len(counts) >= 3:
  for count in itertools.combinations(counts, 3):
    ans += count[0]*count[1]*count[2]

print(ans)


Measured memory_bytes: 14316
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        HashSet<Integer> hs = new HashSet<Integer>();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        for(int i = a; i < a+k; i++){
            hs.add(i);
            if(i == b) break;
        }
        for(int i = b; i > b-k; i--){
            hs.add(i);
            if(i == a) break;
        }
        List<Integer> sl = new ArrayList<>(hs);
        Collections.sort(sl);
        for(int s : sl){
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<string>
using namespace std;
int main () {
  string co;
  cin >> co;
  int p = 0;
  int q = 0;
  for (int i = 0; i < co.size(); i ++) {
    if (i % 2) {
      if (co[i] == '0') p ++;
      else q ++;
    }
    else {
      if (co[i] == '0') q ++;
      else p ++;
    }
  }
  cout << min(p, q) << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int alice=0,bob=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            //アリスのターン
            alice+=a.at(i);
        }
        else{
            bob+=a.at(i);
        }
    }
    cout << alice-bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		res%=MOD;
		b--;}
        a=(a*a);
        a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}

int nCrModPFermat(int n,int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * fermat_inv(fac[r]) % p * fermat_inv(fac[n - r]) % p) % p; 
} 

int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	p=n/3;
	for(i=1;i<=p;i++)
	{
	    sum+=nCrModPFermat(n-1-2*i,i-1,MOD)%MOD;
	}
	cout<<(sum+MOD)%MOD;
	
	
	
	
	 
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import sys
from queue import Queue

K = int(input())

q = Queue()
if K<10:
    print(K)
    sys.exit()

for i in range(1,10):
    q.put(i)

idx = 9

while idx<=K and not(q.empty()):
    cur = q.get()
    num = cur%10
    if num==0:
        for i in range(2):
            nxt = cur*10 + (num+i)
            if idx+1==K:
                ans = nxt
                break
            idx += 1
            q.put(nxt)
        else:
            continue
        break

    elif num==9:
        for i in range(2):
            nxt = cur*10 + (num+i-1)
            if idx+1==K:
                ans = nxt
                break
            idx += 1
            q.put(nxt)
        else:
            continue
        break
        
    else:
        for i in range(3):
            nxt = cur*10 + (num+i-1)
            if idx+1==K:
                ans = nxt
                break
            idx += 1
            q.put(nxt)
        else:
            continue
        break

print(ans)

Measured memory_bytes: 51432
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <limits>

using namespace std;

int main() {
  string s;
  string t;
  
  cin >> s;
  cin >> t;
  
  
  int num;
  num =  1 + s.size() - t.size();
  
  int ans;
  ans = t.size();
  
  for(int i = 0;i < num;i++){
    int sum;
    sum = t.size();
   
    for(int j = 0;j < t.size();j++){
      int k;
      k = j + i;
      if(s.at(k) == t.at(j)){
        sum = sum - 1;
    
        
      }
    if(ans > sum)ans = sum;
    }
  }
  
    cout << ans << endl;
  
  
}

Measured memory_bytes: 3556
n = int(input())
s = input().split()
a = [0]*4

for i in s:
    if i == 'P':
        a[0] += 1
    elif i == 'W':
        a[1] += 1
    elif i == 'G':
        a[2] += 1
    elif i == 'Y':
        a[3] += 1

if a.count(0) == 0:
    print('Four')
else:
    print('Three')

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

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

Measured memory_bytes: 3916
#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(){
    string s2,t;
    cin >> s2 >> t;
    int l,l2;
    l=s2.size();
    l2=t.size();
    vector <string> ans;
    string s;
    
    rep(i,l+1-l2){
        rep(j,l2){
            //cout << i << j << endl;
            if(s2[i+j]!=t[j] and s2[i+j]!='?'){
                break;
            }
            if(j==l2-1){
                s=s2;
                rep(k,l2){
                    s[k+i]=t[k];
                }
                rep(k,l){
                    if(s[k]=='?'){
                        s[k]='a';
                    }
                }
                ans.push_back(s);
            }
        }
    }

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


    if(ans.size()!=0){
    cout << ans[0] << endl;
    }
    else{
        cout << "UNRESTORABLE" << endl;
    }
    


    return 0;
}

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

int w, h, n, x, y, t, c;
bool a[105][105];
int main()
{
    int i, j;
    cin >> w >> h >> n;
    while (n--) {
        scanf("%d %d %d", &x, &y, &t);
        if (t == 1) {
            for (i = 0; i < h; i++) {
                for (j = 0; j < x; j++) {
                    a[i][j] = 1;
                }
            }
        } else if (t == 2) {
            for (i = 0; i < h; i++) {
                for (j = x; j < w; j++) {
                    a[i][j] = 1;
                }
            }
        } else if (t == 4) {
            for (i = y; i < h; i++) {
                for (j = 0; j < w; j++) {
                    a[i][j] = 1;
                }
            }
        } else {
            for (i = 0; i < y; i++) {
                for (j = 0; j < w; j++) {
                    a[i][j] = 1;
                }
            }
        }
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            c += 1 - a[i][j];
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char alfabet;
	
	scanf("%c", &alfabet);
		if (alfabet >= 'a' && alfabet <= 'z'){
		
			printf("a\n");
	}
		else if (alfabet >= 'A' && alfabet <= 'Z'){
		
			printf("A\n");
	}
	return 0;
}

Measured memory_bytes: 1588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)


int main(int argc, char *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> u1(N-1), u2(N-1);
    Rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        u1[i] = make_pair(a, b);
        u2[i] = make_pair(b, a);
    }
    vector<pair<int, int>> v(2*N-2);
    Rep(i, N-1) {
        v[i] = u1[i];
        v[N-1+i] = u2[i];
    }
    sort(v.begin(), v.end());
    vector<int> w1(2*N-2), w2(2*N-2);
    Rep(i, 2*N-2) {
        w1[i] = v[i].first;
        w2[i] = v[i].second;
    }

    // 対象の頂点番号, 分岐の数
    queue<int> q;
    
    // 色
    LLI S = K;

    // 既に訪れた頂点かどうか
    deque<bool> visit(N+1, false);

    // 1から
    int l, r;
    l = 0;
    r = distance(w1.begin(), lower_bound(w1.begin(), w1.end(), 2));
    visit[1] = true;
    int p = K;
    for (int i=l; i<r; i++) {
        int next = w2[i];
        q.push(next);
        visit[next] = true;
        S *= --p;
        S %= 1000000007;
    }

    while (!q.empty()) {
        int front = q.front();
        q.pop();

        l = distance(w1.begin(), lower_bound(w1.begin(), w1.end(), front));
        r = distance(w1.begin(), lower_bound(w1.begin(), w1.end(), front+1));
        p = K - 1;

        for (int i = l; i < r; i++) {
            int next = w2[i];
            if (!visit[next]) {
                q.push(next);
                visit[next] = true;
                S *= --p;
                S %= 1000000007;
            }
        }
    }

    cout << S <<endl;




    


    return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, p; cin >> n >> p;
	int A[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	int cnt_even = 0, cnt_odd = 0;
	for (int i = 0; i < n; i++) {
		if (A[i] % 2 == 0) cnt_even++;
		else cnt_odd++;
	}
	long long ans;
	if (cnt_odd == 0) {
		if (p == 0){
          ans=pow(2,n);
          cout << ans<< endl;
        }
		else cout << 0 << endl;
	}
	else {
      ans=pow(2, n - 1);
		cout <<ans<< endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

void debug_vec(string name, vector<int> vec) {
    cout << name << endl;
    for (auto e: vec) cout << e << endl;
}

void debug_vec(string name, vector<long> vec) {
    cout << name << endl;
    for (auto e: vec) cout << e << endl;
}

void debug_mat(string name, vector<vector<long>> mat) {
    cout << name << endl;
    for (auto vec: mat) {
        for (auto e: vec) cout << e << "   ";
        cout << endl;
    }
}

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

    vector<int> C(26);
    for (int i = 0; i < 26; i++) cin >> C[i];

    vector<vector<int>> S(D, vector<int>(26));
    for (int d = 0; d < D; d++) {
        for (int i = 0; i < 26; i++) {
            cin >> S[d][i];
        }
        cout << distance(S[d].begin(), max_element(S[d].begin(), S[d].end())) + 1 << endl;
    }

    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int n, u, v;



int main() {
  cin >> n >> u >> v;
  vector<vector<int>> edges(n);
  rep(i, n - 1) {
    in(int, a, b);
    --a, --b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }

  map<int, int> aoki;
  aoki[v - 1] = 0;
  queue<int> que;
  que.push(v - 1);

  while (!que.empty()) {
    int here = que.front();
    que.pop();
    // dbg(here, aoki[here]);
    for (int there : edges[here]) {
      if (aoki.count(there)) continue;
      aoki[there] = aoki[here] + 1;
      que.push(there);
    }
  }

  map<int, int> takahashi;
  takahashi[u - 1] = 0;
  que.push(u - 1);

  int maxi = -1;
  while (!que.empty()) {
    int here = que.front();
    que.pop();
    maxi = max(maxi, aoki[here]);
    // dbg(here, takahashi[here]);
    for (int there : edges[here]) {
      if (takahashi.count(there)) continue;
      if (aoki[there] <= takahashi[here] + 1) continue;
      takahashi[there] = takahashi[here] + 1;
      que.push(there);
      maxi = max(maxi, aoki[there]);
    }
  }
  dbg(maxi);
  if (maxi == -1) {
    if (aoki[u - 1] == 1) {
      out(0);
    } else {
      out(1);
    }
  } else {
    out(maxi - 1);
  }
}


Measured memory_bytes: 15232
#include <cstdio>
#include <utility>

using namespace std;

int N;
char str[200007];

int main(){

    scanf("%d\n",&N);
    scanf("%s",str+1);
    int l=1,r=N;
    int count=0;
    while(l<r){
        while(l<=N&&str[l]=='R') l++;
        while(r>=1&&str[r]=='W') r--;
        if (l>=r) break;
        swap(str[l],str[r]);
        count++;
    }

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

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 200010, mod = 998244353;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
// ll ans;
// vecl arr(N);
// ll dp[509][509];
// ll pre[N];



void test_case() {
	
   
   int a, b;
   cin>>a>>b;

   char x = a + '0';
   char y = b + '0';

   string s = string(a,y);
   string t = string(b,x);

   if(s>t) {
       cout<<t<<endl;
   } else {
       cout<<s<<endl;
   }

   


    



}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

Measured memory_bytes: 3616
#include <stdio.h>
main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b)
	{
		printf("a < b\n");
	}
	else if (a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
}


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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	while (*name == ',' || *name == ' ')
		name++;
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
	while (*names == ',' || *names == ' ')
		names++;
	const char *comma = strchr(names, ',');
	std::cerr.write(names, comma - names) << " { ";
	for (const auto &v : arg1)
		cerr << v << ' ';
	cerr << " }\n";
	PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10, mod = 1000000007;

void solve(int caseNo)
{
	int n;
	ll x;
	cin >> n >> x;
	vector<int> a(n);
	ll ret = 0;
	for (auto &x : a)
	{
		cin >> x;
		ret += x;
	}
	auto b = a;
	for (int cnt = 1; cnt < n; ++cnt)
	{
		ll temp = 0;
		for (int i = 0; i < n; ++i)
		{
			b[i] = min(b[i], a[(i - cnt + n) % n]);
			temp += b[i];
		}
		ret = min(ret, temp + cnt * x);
	}
	cout << ret << '\n';
}

int main()
{
#ifndef WIN32
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	for (int i = 0; i < t; ++i)
		solve(i);
#ifdef TIME
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

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

int n;
int a[MAX];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        scanf("%1d", &a[i]);
    }
    if(n == 1){
        cout << a[1] << endl;
        return 0;
    }
    n--;
    for(int i = 1; i <= n; i++){
        a[i] = abs(a[i+1]-a[i]);
    }
    int flag = 0;
    for(int i = 1; i <= n; i++){
        if(a[i] == 1) flag = 1;
    }
    if(!flag){
        for(int i = 1; i <= n; i++){
            a[i] >>= 1;
        }
    }

    int t = 0;
    for(int i = 1; i <= n; i++){
        t ^= (a[i]&1)*(((n-1)&(i-1)) == i-1);
    }
    if(!flag) t <<= 1;
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        boolean hasEven = false;
        if (a % 2 == 0 || b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
        scanner.close();
    }
}


Measured memory_bytes: 26812
from collections import deque
import copy
import sys
sys.setrecursionlimit(50000)
N = int(input())
d_1, d_2 = deque([]), deque([])
l = []
for i in range(N):
  l.append(int(input()))
  
l.sort()
l_1, l_2 = copy.copy(l), copy.copy(l)
d_1.append(max(l))
d_2.append(min(l))
l_1.pop()
l_2.pop(0)

def main1(d, l):
  d.appendleft(l[0])
  l.pop(0)
  if l == []:
    return d
  d.append(l[0])
  l.pop(0)
  if l == []:
    return d
  d.appendleft(l[-1])
  l.pop()
  if l == []:
    return d
  d.append(l[-1])
  l.pop()
  if l == []:
    return d
  else:
    return main1(d, l)
  
def main2(d, l):
  d.appendleft(l[-1])
  l.pop()
  if l == []:
    return d
  d.append(l[-1])
  l.pop()
  if l == []:
    return d
  d.appendleft(l[0])
  l.pop(0)
  if l == []:
    return d
  d.append(l[0])
  l.pop(0)
  if l == []:
    return d
  else:
    return main2(d, l)
  
x, y = 0, 0
a = main1(d_1, l_1)
b = main2(d_2, l_2)
for i in range(N-1):
  x += abs(a[i+1]-a[i])
  y += abs(b[i+1]-b[i])
print(max(x, y))

Measured memory_bytes: 34668
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x)     		(x).begin(),(x).end()
#define ub    			upper_bound
#define lb 				lower_bound
#define ins				insert
#define int 			long long
#define endl			'\n'
#define ff              first
#define ss              second
#define ull				unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si 				set<int>
#define usi 			unordered_set<int>		
#define mii             map<int,int>
#define umii			unordered_map<int ,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)		for(int i=a;i<n;++i)
#define repd(i,a,n)		for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)			cout<<#x <<"="<<x<<endl;
#define deb2(x,y)		cout<<#x<<"="<<x<<"  "<<#y<<"="<<y<<endl;
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}
int log(int x){return 64-__builtin_clzll(x)-1;}

void c_p_p()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
}
struct Node
{
	int a,b,c,d;
	
};
bool cmp(Node A,Node B)
{
	return A.a<B.a;
}
const int Max=1e5+1;

int32_t main()
{
	c_p_p();
	int n;
	cin>>n;
	int A[Max]={};
	int sum=0;
	rep(i,0,n)
	{
		int a;
		cin>>a;
		A[a]+=1;
		sum+=a;
	}
	w(q)
	{
		int a,b;
		cin>>a>>b;
		A[b]+=A[a];
		sum+=(b-a)*(A[a]);
		A[a]=0;
		cout<<sum<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 4348
N = int(input())
X = [int(x) for x in input().split()]
Xs = sorted(X)

high,low = Xs[N//2], Xs[N//2 - 1]

if high == low:
    for i in range(N):    print(high)
else:
    for i in range(N):
        if X[i] >= high:    print(low)
        else:   print(high)

Measured memory_bytes: 26772
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, c, d, e;  cin >> n >> a >> b >> c >> d >> e;
	if (n + a * 5 + b * 10 + c * 50 + d * 100 + e * 500 >= 1000) {
		cout << 1 << endl;
	}
	else { cout << 0 << endl; }
	cin >> n;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;

int main() {
	int n, m, x[100010], y[100010], num[100010];
	bool r[100010];
	cin >> n >> m;
	for (int i = 0; i < n; i++)r[i] = 0;
	r[0] = 1;
	for (int i = 0; i < m; i++)cin >> x[i] >> y[i];
	for (int i = 0; i < n; i++)num[i] = 1;
	for (int i = 0; i < m; i++) {
		num[x[i]-1]--;
		num[y[i]-1]++;
		if (r[x[i]-1]) {
			r[y[i]-1] = 1;
			if (num[x[i]-1] == 0)r[x[i]-1] = 0;
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (r[i])ans++;
	}
	cout << ans << endl;

	return 0;
}

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

a = []
xy = []

for i in range(n):
    a.append(int(input()))
    temp = []
    for j in range(a[i]):
        temp.append(list(map(int, input().split())))
    xy.append(temp)

# print(a)
# print(xy)

ans = 0

for i in range(2 ** n):
    memo = [1] * n
    for j in range(n):
        if (i >> j) & 1:
            memo[n - j - 1] = 0
    # print(memo)

    for p in range(n):
        flag = True
        for q in range(a[p]):
            x = xy[p][q][0] - 1
            y = xy[p][q][1]
            if memo[p] == 1 and memo[x] != y:
                flag = False
                break
            #elif memo[p] == 0 and memo[x] == y:
            #    flag = False
            #    break
        if not flag:
            break

    if flag:
        ans = max(ans, memo.count(1))

print(ans)


Measured memory_bytes: 3064
"""
愚直にやるなら、操作のたびに、各座標ごとに照らしている電球の個数をカウントする。
1回の操作でこの作業をするのに、O(N^2)かかる。
K回やるなら、O(KN^2)かかる。

まず、各座標ごとに照らしている電球の個数はいくつか？というカウント作業を短縮する必要がある。
これを短縮しないと、初期状態の把握すら困難。
O(N)くらいでできないだろうか -> imosつかえばできる。


いや、各座標ごとに照らしている電球がいくつあるのかはそもそも把握不可能ではないのか？
長さNの配列を用意して、各座標ごとに


順番に1ずつ増えていく気配。
とりあえず、最初の配列の段階で


imosが使えるのでは？


で、これ最初全部の光の強さが0だとしても、操作はlogN+a回以内に終わる。
のでimosで毎回各座標を照らす電球の個数を計算していけば、答えにたどり着ける

"""

N,K = map(int,input().split())
A = list(map(int,input().split()))

for _ in range(K):
    imos = [0]*(N+1)
    for i in range(N):
        d = A[i]
        #lは照らす範囲の左側
        l = max(0,i-d)
        #rは照らす範囲の右端
        r = min(N-1,i+d)

        #この辺、コーナーで間違える可能性あり
        ls = l
        lt = i
        rs = i+1
        rt = r+1
        imos[ls]+=1
        imos[lt]+=-1
        imos[rs]+=1
        imos[rt]+=-1
    for i in range(1,N):
        imos[i] += imos[i-1]
    #自分自身を照らすのをカウントに入れる
    for i in range(N):
        imos[i] += 1
    #Aを上書き
    A = imos
    if A.count(N)>=N:
        break
ans = []
for i in range(N):
    ans.append(str(A[i]))
print(" ".join(ans))


Measured memory_bytes: 116760
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    if(a<b){
        for(int i=0; i<b; i++){
            cout << a;
        }
    }else{
        for(int i=0; i<a; i++){
            cout << b;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>?): Unit {
    val (c, n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val memo = Array(c + 1){0L}
    repeat(n){
        val (s, p) = readLine()!!.trim().split(' ').map(String::toInt)
        for (i in (0 .. c - s).reversed()) if (memo[i + s] < memo[i] + p) memo[i + s] = memo[i] + p
    }
    for (i in 1 .. c) memo[i] = java.lang.Math.max(memo[i], memo[i - 1])
    for (k in 1 .. m) println(k * memo[c / k])
}


Measured memory_bytes: 109760
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#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) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

class Dice {
public:
	//string d = "UFRLBD";
	string d = "RENSWL";
	map<char, string> mp;
	vector<int> v; //UFRLBD:123456
	Dice(vector<int> v) :v(v) {
		mp[d[0]] = "2354";
		mp[d[1]] = "1463";
		mp[d[2]] = "1265";
		mp[d[3]] = "1562";
		mp[d[4]] = "1364";
		mp[d[5]] = "2453";
	};
	void roll(char c) {
		roll(mp[c]);
	}
	void roll(string s) {
		int tmp = v[s[0] - '1'];
		rep(i, 1, s.size())v[s[i - 1] - '1'] = v[s[i] - '1'];
		v[s[s.size() - 1] - '1'] = tmp;
	}
};

signed main() {
	vector<int> v(6); rep(i, 0, 6) { cin >> v[i]; }
	Dice D(v);
	string  s; cin >> s;
	rep(i, 0, s.size()) {
		D.roll(s[i]);
	}
	cout << D.v[0] << endl;
	return 0;
}

Measured memory_bytes: 3208
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  if(k > n) {
    cout << 0 << endl;
    return 0;
  }
  sort(all(h));
  reverse(all(h));
  rep(i, k) h[i] = 0;
  ll ans = 0;
  rep(i, n) ans += h[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int t[200200];

int main() {
	int x,n;
	scanf("%d%d", &n, &x);
	if (x==1 || x==2*n-1) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	if (x==2*n-2) {
		FORI(i,n-1) printf("%d ", i);
		printf("%d %d ", 2*n-1, x);
		FOR(i,n-2) printf("%d ", i+n);
		printf("\n");
		return 0;
	}
	t[n] = x-1;
	t[n-1] = x;
	t[n-2] = x+1;
	t[n+1] = x+2;
	int j=0;
	FORI(i,2*n-1) {
		if (i<x-1 || i>x+2) {
			while (t[j]!=0) j++;
			t[j] = i;
			j++;
		}
	}
	FOR(i,2*n-1) printf("%d ", t[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll n;
    for(;cin >> n;){
        ll ans = 0;
        ans = n / 11 * 2;
        if(n % 11 > 6)ans += 2;
        else if(n % 11)ans++;
        cout << ans << endl;        
    }

}


Measured memory_bytes: 256
def check(x, d):
    str_x = str(x)
    for s in str_x:
        if s in d:
            return False
    return True


n, k = map(int, input().split())
d = list(input().split())

for x in range(n, 10**10):
    if check(x, d):
        print(x)
        exit()

Measured memory_bytes: 3060