akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll x;
  cin>>x;
  ll ans=0;

  ll kai = x/11;
  ans=ans+kai*2;
  ll amari = x%11;

  if(amari>=1&&amari<=6){
    ans++;
  }else if(amari>=7&&amari<=10){
    ans++;
    ans++;
  }

  cout<<ans<<endl;

  return 0;
}
 


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

int main()
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if( a <= c && c <= b ) puts( "Yes");
    else puts( "No");
    
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }

#define int long long
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for (int i=0;i<(n);++i)
#define forit(beginIt, endIt) for(auto it=(beginIt);it!=(endIt);++it)

using namespace std;

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

  double num = 0;
  int n; cin >> n;

  for (int i = 0; i < n; ++i) {
    double x; cin >> x;
    string u; cin >> u;
    if (u == "JPY") num += x;
    else num += 380000.0 * x;
  }

  cout << num << endl;
  
  
  
  // int num = 0;
  // int n;
  // cin >> n;
  // vector<int> v(n);
  // forit (v.begin(), v.end()) cin >> *it;
  // for (auto it = v.begin(); it < v.end(); ++it) num += *it;
  // cout << num << endl;

  return 0;
}


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

int main() {
   int N;
   cin >> N;
   vector<int> A(N);
   for(int &x : A) cin >> x;

   double ans = 0.0;
   for(int &x : A) ans += 1/(double)x;
   ans = 1 / ans;

   printf("%.5lf\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

ll N, M, X, C, A;

void calc(vector<vector<ll>> &vec, int it, vector<ll> now, ll &min) {
  bool flag = true;
  for (auto i = 1; i < M + 1; i ++) {
    if (now[i] < X) {
      flag = false;
      break;
    }
  }
  if (flag) {
    if (min == -1) {
      min = now[0];
    } else {
      min = std::min(now[0], min);
    }
    return;
  }
  if (it >= N) {
    return;
  }

  calc(vec, it + 1, now, min);
  for (auto i = 0; i < M + 1; i ++) {
    now[i] += vec[it][i];
  }
  calc(vec, it + 1, now, min);

}

int main() {
  vector<vector<ll>> vec;
  vector<ll> now;
  vec.reserve(20);
  now.reserve(20);
  cin >> N >> M >> X;
  for (auto i = 0; i < N; i ++) {
    vec[i].reserve(20);
    cin >> C;
    vec[i].push_back(C);
    for (auto j = 0; j < M; j ++) {
      cin >> A;
      vec[i].push_back(A);
    }
  }
  for (auto j = 0; j < M + 1; j ++) {
    now.push_back(0);
  }
  ll min = -1;
  calc(vec, 0, now, min);

  cout << min << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
main()
{
	long int a,b,q,r[2];
	while(~scanf("%d%d",&a,&b))
	{
	r[0]=a,r[1]=b;
	while(r[0]%r[1]!=0)
		q=r[0]%r[1],r[0]=r[1],r[1]=q;
	printf("%ld %ld\n",r[1],a/r[1]*b);
	}
	return 0;
}

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

int main()
{
	int h ,w;
	cin >> h >> w;
	vector<string> st(h);
	for(int i = 0; i < h; i++) 
		cin >> st[i];
	for(int i = 0; i < h; i++) {
		cout << st[i] << endl;	
		cout << st[i] << endl;	
	}
}


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

void solve()
{
  cout << (N - 1) + ((N - 1) * (N - 2) / 2) - K << endl;
  for (int i = 2; i <= N; i++)
  {
    cout << 1 << ' ' << i << endl;
  }
  int64_t cnt = (N - 1) * (N - 2) / 2;
  for (int i = 2; i <= N - 1; i++)
  {
    for (int j = i + 1; j <= N; j++)
    {
      if (cnt == K)
        return;
      cout << i << ' ' << j << endl;
      cnt--;
    }
  }
}

int main()
{
  cin >> N >> K;
  int64_t maxk = (N - 1) * (N - 2) / 2;
  if (K <= maxk)
    solve();
  else
    cout << -1 << endl;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n, k;
    cin >> n >> k;
    if (!n && !k) return 0;
    int a[n];
    long long result = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i < k)
        result += a[i];
    }
    long long sum = result;
    for (int i = k; i < n; i++) {
      sum = sum - a[i-k] + a[i];
      result = max(result, sum);
    }
    cout << result << endl;
  }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1100000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};
const int max_n = 1 << 20;

int n;bool s[210][210];vector<int> v[210];int a[210];
signed main() {
	cin>>n;
  rep(i,n)rep(j,n){
    char c;cin>>c;
    s[i][j] = c-'0';
  }
  rep(i,n){
    rep(j,n)if(s[i][j])v[i].push_back(j);
  }
  int ans = 0;
  queue<int> q;
  rep(x,n){
    rep(i,210)a[i] = 0;
    q.push(x);a[x] = 1;
    while(!q.empty()){
      int e = q.front();q.pop();
      rep(i,v[e].size()){
        int to = v[e][i];
        if(a[to] == a[e]){
          cout << -1 << endl;
          return 0;
        }
        if(a[to])continue;
        a[to] = a[e]+1;
        ans = max(ans, a[to]);
        q.push(to);
      }
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 640
fun main(args: Array<String>){
	val S = readLine()!!
  	var flag = true
  	for(i in 0 until S.length){
    	if((i%2==0 && S[i] == 'L') || (i%2==1 && S[i] == 'R')){
        	flag = false
         	break
        }
    }
  print(if(flag) "Yes" else "No")
	
}

Measured memory_bytes: 33604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    int ans=0;
    rep(i,n){
        cin>>a[i];
    }
    for(int i=1;i<n-1;i++){
        if(a[i-1]>a[i]&&a[i]>a[i+1]){
            ans++;
        }
        if(a[i-1]<a[i]&&a[i]<a[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define int long long
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define F first
#define S second
#define vi vector<int>
#define all(c) (c).begin(),(c).end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b)) / gcd((a),(b))
#define bc(n) __builtin_popcountll(n)
#define lps(v,x) (lower_bound(all(v),x)-v.begin())
#define ups(v,x) (upper_bound(all(v),x)-v.begin())

typedef long double ld;

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

auto clk=clock();
const int inft = (1LL<<61) ;
const int inf = 5e18;
const int mod = 1e9+7;
const int mod1 = 998244353;

int modpow(int x,int n,int mod){x %= mod ; int res = 1; while(n>0){ if(n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res;}


signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin.exceptions(cin.failbit);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
       //freopen("input.txt", "r", stdin);
       //freopen("output.txt", "w", stdout) ;
    #endif // ONLINE_JUDGE

    int a,b ;
    cin >> a >> b ;

    if(a<b)
    {
        cout << "0" ;
    }
    else
    {
        cout << "10" ;
    }

return 0 ;
}







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

using namespace std;

typedef long long llint;

vector<long long> divisors(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i != 0) continue;
    res.push_back(i);
    if (n / i == i) continue;  // 上の行で追加済み。
    res.push_back(n / i);
  }
  return res;
}

bool func(llint k, llint n) {
  while (n % k == 0) n /= k;
  return (n % k == 1);
}

int main() {
  llint n;
  cin >> n;
  auto v1 = divisors(n);
  auto v2 = divisors(n - 1);
  set<llint> ans;
  for (auto v : v1) {
    if (v == 1) continue;
    if (func(v, n)) ans.insert(v);
  }
  for (auto v : v2) {
    if (v == 1) continue;
    ans.insert(v);
  }
  cout << ans.size() << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <set>


using namespace std;

long long int n;
long long int a[250000];
int main() {
    cin>>n;
    long long int res = 0;
    for(int i=0;i<n;i++ ) {
        cin>>a[i];
        res^=a[i];
    }
    for(int i=0;i<n;i++) {
        cout<<(res^a[i])<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5140
import java.util.*;
class Main
{
	public static void main (String[] args)
	{
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		while(!str.equals(".")){
			if(is(str))
				System.out.println("yes");
			else
				System.out.println("no");
			str = in.nextLine();
		}
	}

	public static boolean is(String input){
		char c;
		Stack<Character> s = new Stack<Character>();
		for(int i = 0;i < input.length();i++){
			c = input.charAt(i);
			switch(c){
			case '(':
				s.push(')');
				break;
			case '[':
				s.push(']');
				break;
			case ')':
			case ']':
				if(s.empty())
					return false;
				if(s.pop() != c)
					return false;
				break;
			}
		}
		return s.empty();
	}
}

Measured memory_bytes: 32456
N, M = map(int, input().split())
shop = []
for i in range(N):
    a, b = map(int, input().split())
    shop.append([a, b])
shop.sort(key=lambda x: x[0])

amount = 0
quantity = 0
for s in shop:
    if quantity + s[1] < M:
        amount += s[0] * s[1]
        quantity += s[1]
    else:
        amount += (M - quantity) * s[0]
        quantity = M
        break

print(amount)


Measured memory_bytes: 21216
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	long long A, B, C, K; 
	cin >> A >> B >> C >> K; 
	if(K <= A) cout << K << endl; 
	else if(K <= A + B) cout << A << endl;
	else cout << A * 2 + B - K << endl; 
}

Measured memory_bytes: 3648
using System;

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b ;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);

            if (a + b >= a - b && a - b >= a * b||a + b >= a * b && a * b >= a - b)
                Console.WriteLine(a + b);
            else if (a - b >= a + b && a + b >= a * b||a - b >= a * b && a * b >= a + b)
                Console.WriteLine(a - b);
            else if (a * b >= a - b && a - b >= a + b||a * b >= a + b && a + b >= a - b)
                Console.WriteLine(a * b);
            Console.ReadKey();
           
        


        }
    }
}


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

struct bydol
{
  int C;
  int vals[3];
};

int do_dp(const vector<bydol>& v, int M, int n)
{
  const int N = v.size();
  vector<int> dp(M+1, 0);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j+v[i].C <= M; j++) {
      dp[j+v[i].C] = max(dp[j+v[i].C], dp[j] + v[i].vals[n]);
      ans = max(ans, dp[j+v[i].C]);
    }
  }

  return ans;
}

int main()
{
  string line;
  while (getline(cin, line)) {
    int N, M;
    {
      istringstream iss(line);
      iss >> N >> M;
    }
    vector<bydol> v(N);
    for (int i = 0; i < N; i++) {
      getline(cin, line); // ignore name
      getline(cin, line);
      {
        istringstream iss(line);
        iss >> v[i].C >> v[i].vals[0] >> v[i].vals[1] >> v[i].vals[2];
      }
    }

    int w = do_dp(v, M, 0);
    int d = do_dp(v, M, 1);
    int l = do_dp(v, M, 2);
    cout << max(w, max(d, l)) << endl;
  }
  return 0;
}

Measured memory_bytes: 940
n = int(input())
L = list(map(int, input().split()))
E = []
for i in range(n):
  if L[i]%2 != 1:
    E.append(L[i])

out = 0    
for i in range(len(E)):
  out += bin(E[i])[::-1].find('1')
  
print(out)  

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	long long ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'W') {
			ans += 1LL * i - 1LL * cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

using namespace std;

const int N=3005,mo=1e9+7;

typedef long long LL;

int n,m,f[N][N][2],ans;

int main()
{
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for (int i=1;i<=n;i++) f[0][i][0]=1;
	for (int i=1,j,k;i<=m;i++)
	{
		for (j=0;j<=n;j++)
		{
			if (j>0)
			{
				k=(j==1)?1:0;
				f[i][j-1][1]=(f[i][j-1][1]+f[i-1][j][1])%mo;
				f[i][j][1]=(f[i][j][1]+f[i-1][j][1])%mo;
				f[i][j-1][k]=(f[i][j-1][k]+f[i-1][j][0])%mo;
				f[i][j][k]=(f[i][j][k]+f[i-1][j][0])%mo;
			}
			if (j<n)
			{
				for (k=0;k<2;k++)
				{
					f[i][j+1][k]=(f[i][j+1][k]+f[i-1][j][k])%mo;
					f[i][j][k]=(f[i][j][k]+f[i-1][j][k])%mo;
				}
			}
		}
	}
	for (int j=0;j<=n;j++) ans=(ans+f[m][j][1])%mo;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;

    return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
int main(){
   int A,B,K,i,j,k;
   scanf("%d%d%d",&A,&B,&K);
   if(K*2>=B-A+1){
     for(i=A;i<=B;i++){
     printf("%d\n",i);
     }
   }else{
     for(j=A;j<=A+K-1;j++){
     printf("%d\n",j);
     }
     for(k=B-K+1;k<=B;k++){
     printf("%d\n",k);
     }
   
   }
}

Measured memory_bytes: 128
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readLine
  val digit = n.size
  val res = {
    if(n.tail.forall(_ == '9')) n
    else if(n.head == '1') Array.fill(digit-1)(9).mkString
    else (n.head.toString.toInt - 1) + Array.fill(digit-1)(9).mkString
  }
  // println(res)
  val ans = res.map(_.toString.toLong).reduce(_+_)
  println(ans)
}

Measured memory_bytes: 25544
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());

    String result = "NO";
    if (A + B >= X && A <= X)
      result = "YES";
    System.out.println(result);

  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
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};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	int a,b;
	cin>>a>>b;
	cout<<6-a-b<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
  if ( a==25){
    cout<<"Christmas";}
  else if ( a==24){
    cout<<"Christmas Eve";}
 else if ( a==23){
    cout<<"Christmas Eve Eve";}
 else if ( a==22){
    cout<<"Christmas Eve Eve Eve";}

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    ll sum = 0;
    cin >> n;
    vector<ll> v(n), s(n+1, 0);
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d", &k);
        v[i] = k;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; ++i) {
        sum += v[i];
        s[i+1] = sum;
    }
    for (int i = n-2; i >= 0; --i) {
        if(2*s[i+1] < v[i+1]){
            cout << n-i-1 << "\n";
            return 0;
        }
    }
    cout << n << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;

int main() {
    string s, t; 
    cin >> s;
    cout << string(s.size(), 'x') << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 900010
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll inv[MAXN],fac[MAXN],pow3[MAXN];
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;	
	}
	return res;
}
ll C(int x,int y){
	return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int main(){
	int n,m,k;
	SF("%d%d%d",&n,&m,&k);
	pow3[0]=1;
	fac[0]=1;
	for(int i=1;i<=n+m+k;i++){
		pow3[i]=pow3[i-1]*3ll%MOD;	
		fac[i]=fac[i-1]*i%MOD;
	}
	inv[n+m+k]=fsp(fac[n+m+k],MOD-2);	
	for(int i=n+m+k;i>0;i--)
		inv[i-1]=inv[i]*i%MOD;
	n--;
	if(m<k)
		swap(m,k);
	ll j=1,ans=0;
	for(int i=0;i<=m+k;i++){
		ans=(ans+C(n+i,n)*pow3[m+k-i]%MOD*j)%MOD;	
		if(i<k)
			j=j*2ll%MOD;
		else if(i<m)
			j=(j*2ll-C(i,k))%MOD;
		else 	
			j=(j*2ll-C(i,k)-C(i,m))%MOD;
	}
	ans=(ans+MOD)%MOD;
	PF("%lld",ans);
}

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

typedef long long ll;

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


int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    int bomb[51][51];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            bomb[i][j] = -1;
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                continue;
            } else {
                int cnt = 0;
                for (int dir = 0; dir < 8; dir++) {
                    int x = i + dx[dir];
                    int y = j + dy[dir];
                    if (x >= 0 && x < H && y >= 0 && y < W) {
                        if (S[x][y] == '#') {
                            cnt++;
                        }
                    }
                }
                bomb[i][j] = cnt;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (bomb[i][j] == -1) {
                cout << "#";
            } else {
                cout << bomb[i][j];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main()
        {
            var a = int.Parse(Console.ReadLine());
            if(a >= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

ll dp[3030][3030][4];

int main() {
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<ll>> grid(r, vector<ll>(c, 0));
    for (int i = 0; i < k; ++i) {
        int ri, ci;
        ll ki;
        cin >> ri >> ci >> ki;
        ri--, ci--;
        grid[ri][ci] = ki;
        if(ri == ci && ri == 0) dp[0][0][1] = max(dp[0][0][1], ki);
    }
    
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            for (int k = 0; k < 3; ++k) {
                if(i+1 < r) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                if(i+1 < r) dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k] + grid[i+1][j]);
                if(j+1 < c) dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
                if(j+1 < c) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + grid[i][j+1]);
            }
            if(i+1 < r) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][3]);
            if(i+1 < r) dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][3] + grid[i+1][j]);
            if(j+1 < c) dp[i][j+1][3] = max(dp[i][j+1][3], dp[i][j][3]);
        }
    }

    ll ans = 0;
    for (int i = 0; i < 4; ++i) {
        ans = max(ans, dp[r-1][c-1][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 357644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

struct item
{
	//weight, value
	ll w = 0, v = 0;
	item(ll a = 0, ll b = 0)
	{
		w = a;
		v = b;
	}
};

const ll INF = 1e15;
ll n, cap;
vector<item> items(10000);
bool cached[100][100000];
ll memo[100][100000];

ll knap(int i, int curcap)
{
	if (curcap < 0)
		return -INF;
	if (i == n)
		return 0LL;
	if (cached[i][curcap])
		return memo[i][curcap];

	ll res1 = knap(i + 1, curcap - items[i].w) + items[i].v;
	ll res2 = knap(i + 1, curcap);
	ll res = max(res1, res2);
	cached[i][curcap] = true;
	memo[i][curcap] = res;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> cap;
	for (int i = 0; i < n; i++)
	{
		ll w, v;
		cin >> w >> v;
		items[i] = item(w, v);
	}
	cout << knap(0, cap);
}

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

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

  if (n % 2 == 0) {
    cout << n / 2 << endl;
  }

  else {
    cout << (n/2) + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <complex>
using namespace std;
using Point = complex<double>;
const double th = acos(-1) / 3;

void koch(int n, Point a, Point b) {
    if (n == 0) {
        cout << b.real() << " " << b.imag() << endl;
        return ;
    }
    Point s = (a * 2.0 + b) / 3.0, t = (a + b * 2.0) / 3.0;
    Point u = (t - s) * Point(cos(th), sin(th)) + s;
    koch(n - 1, a, s);
    koch(n - 1, s, u);
    koch(n - 1, u, t);
    koch(n - 1, t, b);
}

#include <iomanip>
int main() {
    cout << fixed << setprecision(8);
    int n; cin >> n;

    Point a(0, 0), b(100, 0);
    cout << a.real() << " " << a.imag() << endl;
    koch(n, a, b);

    return 0;
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#define pi acos(-1)
#define el << endl
using namespace std;
typedef long long ll;
typedef long double ld;
///----------------------------------------------

int main()

{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    int a,b,c,d;
    cin>>a>>b>>c>>d;

    while(a>=0 && c>=0){
		c = c-b;
		a = a-d;
		if(c<=0) {cout << "Yes" << endl; return 0;}
		else if(a<=0) {cout << "No" << endl; return 0;}
    }

    //else
    return 0;
}






Measured memory_bytes: 3576
n,m = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
#print(l)

d = []
for i in range(m-1):
    x = l[i+1]-l[i]
    d.append(x)
#print(d)
d.sort()
ans = 0
for i in range(m-n):
    ans += d[i]
print(ans)

Measured memory_bytes: 56872
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(ll)(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vector<pair<pll,ll>> blocks;

vvl dp;
ll f(ll ind, ll wei){
  if(wei < 0) return -1 * oo;
  if(ind >= sz(blocks)) return 0;
  if(dp[ind][wei] != -1) return dp[ind][wei];
  ll base = f(ind+1, wei);
  ll wei_new = wei - blocks[ind].xx.xx;
  wei_new = min(wei_new, blocks[ind].xx.yy);
  ll take = f(ind+1, wei_new) + blocks[ind].yy;
  ll res = max(base, take);
  dp[ind][wei] = res;
  return res;
}

int main(){
  ll N;
  cin >> N;
  dp.resize(N,vl(20005,-1));
  FOR(i,0,N){
    ll w,s,v;
    cin >> w >> s >>v;
    blocks.pb(mp(mp(w,s),v));
  }
  auto cmp = [&] (pair<pll,ll> in, pair<pll,ll> in2) {
    ll s1 = in.xx.xx;
    ll s2 = in2.xx.xx;
    ll w1 = in.xx.yy;
    ll w2 = in2.xx.yy;
    ll op1 = min(s1 - w2, s2);
    ll op2 = min(s2 - w1, s1);
    return op1 > op2;
  };
  sort(all(blocks), cmp);
  cout << f(0, 20004) << endl;
} //cin.tie(0) bei schnellem Wechseln


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

int main () {
  int n;
  long long a[110];
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  long long min=a[1], max=0;
  for(int i = 0; i < n; ++i) {
    if (min > a[i]) min = a[i];
    if (max < a[i]) max = a[i];
  }
  
  cout << max-min;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.length(); ++i){
        if(s.at(i) <= 'Z'-n){
            s[i] += n;
        }
        else{
            s[i] += n - 26;
        }
    }
    cout << s << endl;
    
    
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> t(n);
    for(int i = 0; i < n; ++i) {
        cin >> t[i];
    }

    const int ma = *max_element(begin(t), end(t));
    vector<int> ps;
    for(int i = 1; i <= ma; ++i) {
        if(ma % i == 0) ps.push_back(i);
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += *lower_bound(begin(ps), end(ps), t[i]) - t[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 3276
def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10**9+7
    # Aの中でd桁目が0,1であるものの個数を求める(p,qとする)
    # 全部のd桁目についてループして、ans+=(2**d)*(p*q)
    ans = 0
    for d in range(60):
        p,q = 0,0
        for i in range(N):
            if A[i]%2==0: p+=1
            else: q+=1
            A[i] //= 2
        ans += ((2**d)*p*q)%MOD
        ans %= MOD
    print(ans)

main()


Measured memory_bytes: 123000
def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0

    fac = [0] * (n + 1)
    fac[0] = 1
    for i in range(n):
        fac[i + 1] = fac[i] * (i + 1) % p
    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p


p = 1000000007

X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
    exit()

a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if a < 0 or b < 0:
    print(0)
    exit()

print(mcomb(a + b, min(a, b)))


Measured memory_bytes: 29300
#include <stdio.h>
#include <string.h>
 
int main(void){
    int flag = 0;
    char str[1025];
    scanf("%s",str);
    while(1){
        int tail = strlen(str) - 1;
        if(str[tail] == ',' || str[tail] == '.'){
            str[tail] = '\0';
        }
        if(3 <= strlen(str) && strlen(str) <= 6){
			if(flag == 1){
				printf(" ");
			}
	        printf("%s",str);
			flag = 1;
        }
        if(scanf("%s",str) == EOF){
            break;
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 968
L,R = map(int,input().split())
mod = 2019
sa = R-L
if sa >= mod*2:
    ans = 0
else:
    ans = mod
    for i in range(L,R):
        for j in range(i+1,R+1):
            x = i*j
            ans = min(ans,x%mod)
    
print(ans)

Measured memory_bytes: 40428
N = int(input())
A = list(map(int,input().split()))

up = False
down = False
count = 1
for i in range(N-1):
    if A[i] < A[i+1]:
        up = True
    elif A[i] > A[i+1]:
        down = True
    if up ==True and down == True:
        count += 1
        up = False
        down = False
print(count)


Measured memory_bytes: 14224
N = int(input())
p = [int(i) for i in input().split()]
a = sorted(p)
from itertools import combinations

if a==p:
    print('YES')
    exit()

for i,j in combinations(range(N), 2):
    p[i], p[j] = p[j], p[i]
    if a == p:
        print('YES')
        exit()
    p[j], p[i] = p[i], p[j]

print('NO')

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

using namespace std;

int n,m,i,j,tree[400005],lx,ly,lval;

pair <int, int> a[300005];

bool cmp(pair <int, int> u, pair<int, int> v){
	return u.second - u.first < v.second - v.first;
}

void update(int l, int r, int ind){
	if(lx <= l && r <= ly){
		tree[ind]++;
		return;
	}
	
	int mid = (l + r) / 2;
	
	if(lx <= mid)
	update(l, mid, ind * 2);
	if(ly > mid)
	update(mid + 1, r, ind * 2 + 1);
}

void query(int l, int r, int ind){
	lval += tree[ind];
	
	if(l == r)
	return;
	
	int mid = (l + r) / 2;
	
	if(lx <= mid)
	query(l, mid, ind * 2);
	else
	query(mid + 1, r, ind * 2 + 1);
}

int main(){
	scanf("%d%d", &n, &m);
	for(i = 0; i < n; i++)
	scanf("%d%d", &a[i].first, &a[i].second);
	
	sort(a, a + n, cmp);
	
	int p = 0;
	
	for(i = 1; i <= m; i++){
		int res = 0;
		
		while(p < n && a[p].second - a[p].first + 1 <= i){
			lx = a[p].first;
			ly = a[p].second;
			update(1, m, 1);
			p++;
		}
		
		res += n - p;
		
		for(j = i; j <= m; j += i){
			lx = j;
			lval = 0;
			query(1, m, 1);
			res += lval;
		}
		
		printf("%d\n", res);
	}
	
}


Measured memory_bytes: 4352
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

int main(void)
{
    std::string s;

    for (uint32_t idx = 0; idx < 3; ++idx) {
        std::cin >> s;
        std::cout << s.at(idx);
    }

    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  // 全ての頂点でaだけ, すべての頂点でbだけ, aとb両方取る頂点が存在 → n個貪欲に取ればよい
  // 

  ll n;
  cin >> n;
  vector<pair<ll,ll>> v;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    v.push_back({a, i});
    v.push_back({b, i+n});
  }

  sort(ALL(v));

  vector<ll> cnt(n, 0);
  vector<ll> parity(2, 0);
  REP(i, n) {
    int tmp = v[i].second < n ? v[i].second : v[i].second - n;
    cnt[tmp]++;
    parity[(v[i].second < n)]++;
  }

  bool flag = false;
  if(parity[0] == n || parity[0] == 0) {
    flag = true;
  }
  REP(i, n) if(cnt[i] == 2) flag = true;
  
  ll ret = 0;
  if(flag) {
    REP(i, n) ret += v[i].first;
  } else {
    REP(i, n-1) ret += v[i].first;
    if(abs(v[n-1].second - v[n].second) == n) {
      ret = min(ret - v[n-2].first + v[n-1].first + v[n].first,
                ret + v[n+1].first);
    } else {
      ret += v[n].first;
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 6512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
signed main(){
	ic(n)
	sc(s)
	int ss=s.size();
	rep(0,i,ss){
		s[i]+=n;
		if(s[i]>=91){
			s[i]-=26;
		}	
	}
	c(s)
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
c = {n:0 for n in range(0, 9)}
for a_ in a:
    a__ = a_ // 400
    if a__ <= 7:
        c[a__] += 1
    else:
        c[8] += 1
count = 0
for k, v in c.items():
    if k <= 7:
        if v > 0:
            count += 1
    elif k == 8:
        cc = v + count
if count == 0:
    count = 1
ans = str(count) + " " + str(cc)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

void solve() {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    while (k--) {
        std::vector<int> ys(n + 1, 0);
        for (int i = 0; i < n; ++i) {
            int l = std::max(i - xs[i], 0),
                r = std::min(i + xs[i] + 1, n);
            ++ys[l], --ys[r];
        }

        bool changed = false;
        for (int i = 0; i < n; ++i) {
            if (xs[i] != ys[i]) changed = true;
            xs[i] = ys[i];
            ys[i + 1] += ys[i];
        }
        if (!changed) break;
    }

    for (auto x : xs) std::cout << x << " ";
    std::cout << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    int N, X;
    cin >> N >> X;
    vector<ll> L(N);
    ll sum = 0;
    bool flag = 1;
    REP(i,N){
        cin >> L[i];
        sum += L[i];
        if(sum >X) {
            cout << i + 1<< endl;
            flag = 0;
            break;
        }
    }
    if(flag) cout << N + 1<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0;i<n;i++){
        cin >> p[i];
    }
    int cnt = 0;
    string str = "NO";
    for (int i=1;i<=n;i++){
        if (i!=p[i-1]){
            cnt++;
        }
    }
    if (cnt==0 || cnt==2){
        str = "YES";
    }
    cnt = 0;
    for (int i=n;i>0;i--){
        if (i!=p[i-1]){
            cnt++;
        }
    }
    if (cnt==0 || cnt==2){
        str = "YES";
    }
    cout << str << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int M = scan.nextInt();
			
			int[]p =new int[M];
			String[]S = new String[M];
			for(int i = 0;i<M;i++) {
				p[i] = scan.nextInt();
				S[i] = scan.next();
			}
			
			long seitou = 0;
			long pena = 0;
			String[]res = new String[N];
			int[]pe = new int[N];
			
			for(int i = 0;i<M;i++) {
				if(res[p[i]-1]==null) {//まだ一回も回答されてない
					if(S[i].equals("WA")) {
						res[p[i]-1] = "WA";
						pe[p[i]-1]++;
					}else {
						res[p[i]-1] = "AC";
						seitou++;
					}
				}else{//一回回答した問題。ACなら無視
					if(res[p[i]-1].equals("WA")) {
						if(S[i].equals("WA")) {
							pe[p[i]-1]++;
						}else{
							res[p[i]-1] = "AC";
							pena+=pe[p[i]-1];
							seitou++;
						}
					}
				}
			}
			
			System.out.println(seitou);
			System.out.println(pena);
			
			
			
			
			
		}
	}
}


Measured memory_bytes: 68948
MOD = int(1e9+7)

def fast_power(b, e):
    res = 1
    while e > 0:
        if e % 2 == 1:
            res = res * b % MOD
        b = b * b % MOD
        e >>= 1
    return res

def mod_inverse(n):
    return fast_power(n, MOD-2)
def mul(x, y):
    return ((x % MOD) * (y % MOD) % MOD + MOD) % MOD
def multiply(x, y, z):
    return mul(mul(x, y), z)

def nCr(n, r):
    if r == 0:
        return 1
    fac = [1] * (n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
    # n! / (r! * (n-r)!)
    return multiply(fac[n], mod_inverse(fac[r]), mod_inverse(fac[n-r]))

x, y = map(int, input().split())
n = (2*x-y) // 3
m = (2*y-x) // 3
if min(n, m) < 0 or (x+y)%3 != 0:
    print(0)
    exit()
print(nCr(m+n, n))

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

long long dp[3005][3005];

int main()
{
int n;
cin>>n;
vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
for(int L = n - 1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if(L == R) {
                dp[L][R] = a[L];
            }
            else {
                dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);
            }
        }
    }
printf("%lld",dp[0][n-1]);
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	VI ck(n+5);
	ck[0] = 3;
	ll ans = 1;
	for(auto x: a){
		(ans *= ck[x]) %= MD;
		ck[x]--;
		ck[x+1]++;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)


int main() {
    const int MOD = 1000000007;
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);

    rep(i, n) cin >> a[i];

    ll cnt = 0;
    rep(i, n) {
        rep2(j, i+1, n) {
            if (a[i] > a[j]) cnt ++;           
        }
    }


    ll choose = 0;
    rep(i, n) {
        rep(j, n) {
            if (a[i] > a[j]) choose++;
        }
    }

    ll ans = cnt * k;
    ans += ((k*(k-1)/2)%MOD) * choose;
    ans %= MOD;
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    cin >> n;
    int c = __builtin_clz(n);
    cout << (1 << (31 - c)) << endl;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    a = []
    b = []
    for i in range(n):
        a.append([int(x) for x in input().split()])
    for i in range(n):
        a[i].append(sum(a[i]))
    for i in range(n + 1):
        sum_ = 0
        for j in range(n):
            sum_ += a[j][i]
        b.append(sum_)
    a.append(b)

    for i in range(n + 1):
        for j in range(n + 1):
            if j == n:
                print('{:>5}'.format(a[i][j]))
            else:
                print('{:>5}'.format(a[i][j]), end='')

Measured memory_bytes: 7744
#include <iostream>

using namespace std;

int main()
{
	unsigned int n;
	unsigned int s[14];
	unsigned int h[14];
	unsigned int c[14];
	unsigned int d[14];
	for (int i = 1; i < 14; ++i) {
		s[i] = h[i] = c[i] = d[i] = false;
	}

	cin >> n;
	for (int i = 0; i < n; ++i) {
		char a;
		int x;
		cin >> a >> x;
		switch (a) {
		case 'S':
			s[x] = true;
			break;
		case 'H':
			h[x] = true;
			break;
		case 'D':
			d[x] = true;
			break;
		case 'C':
			c[x] = true;
			break;
		}
	}

	for (int i = 1; i < 14; ++i) {
		if ( ! s[i])
			cout << "S " << i << endl;
	}
	for (int i = 1; i < 14; ++i) {
		if ( ! h[i])
			cout << "H " << i << endl;
	}
	for (int i = 1; i < 14; ++i) {
		if ( ! c[i])
			cout << "C " << i << endl;
	}
	for (int i = 1; i < 14; ++i) {
		if ( ! d[i])
			cout << "D " << i << endl;
	}
	return 0;
}



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

int main() {
	string S;

	cin >> S;

	int ans = S.size();

	for (int i = 0; i < 2; i++) {
		int count = 0;
		for (int j = 0; j < S.size(); j++) {
			if (j % 2 == 0 && S[j] != (char)(i + '0')) count++;
			if (j % 2 == 1 && S[j] == (char)(i + '0')) count++;
		}

		ans = min(ans, count);
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N;
  cin >> N;
  cin >> A;
 
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3608