akhauriyash/Code-Regression huggingface dataset:
//prepared by dumb
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma warning(disable:4786)
#pragma warning(disable:4996)
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   eps 1e-8
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b)
{
    return (a * b) / __gcd(a, b);
}
ll n;
bool chk(ll arr[],dl sz,ll k)
{
    ll c=0;
    for(int i=0;i<n;i++)
      c+=ceil(arr[i]/(1.0*sz))-1;
   if(c>k)
   	return false;
   else
   	return true;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a, b, c, d, e, f = 0, g, h, i, j, k, l, m, o, p, q, r, s, t, u, v, w, x, y, z;
    ll cnt = 0, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
    ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
    string str, str1, str2,str3="",str4="";


    scll(n);
    scll(k);
    ll arr[n];
    ll maxi=0;
    for(i=0;i<n;i++){
    	scll(arr[i]);
        maxi=max(maxi,arr[i]);
    }
    
    dl low=0;
    dl high=maxi;
dl ANS=1e18;
c=0;
    while(high-low>eps)
    {
       dl mid=(high+low)/2.0;

       if(chk(arr,mid,k))
       {
       	high=mid;
        ANS=min(ANS,mid); 
       }
       else
          low=mid;
      if(c==1000)
      	break;
      c++;
    }
   l1=ceil(ANS);
     if(k==0)
     cout<<maxi;
   else
   	cout<<l1;
    
 return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    string s;
    int n,k;
    cin>>n>>k>>s;
    s[k-1]=s[k-1]-'A'+'a';
    cout<<s;
}

Measured memory_bytes: 256
N,K =map(int,input().split())
S =input()
lis = [[],[]]
if S[0]=="0":
    lis[1].append(0)
j = S[0]
su = 0
for i in S:
    if i ==j:
        su += 1
    else:
        lis[int(j)].append(su)
        j = i
        su = 1
lis[int(j)].append(su)
if j=="0":
    lis[1].append(0)
if len(lis[0])<=K:
    print(N)
else:
    ans = 0

    ans = sum(lis[0][0:K]) + sum(lis[1][0:K+1])
    foo = ans
    for i in range(len(lis[0])-K):
        foo += lis[0][K+i] -lis[0][i] +lis[1][K+1+i] -lis[1][i]
        if ans < foo:
            ans = foo
    print(ans)


Measured memory_bytes: 4484
N = int(input())
nowx = nowy = time1 = 0
for i in range(N):
    t,x,y = map(int,input().split())
    time2 = abs(abs(nowx)-x)+abs(abs(nowy)-y)
    if ((t-time1)-time2)%2!=0 or time2>t-time1:
        print("No")
        exit()
    time1 = t
    nowx = x
    nowy = y
print("Yes")

Measured memory_bytes: 3064
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var h = int.Parse(Console.ReadLine());
            var odd = h % 2 == 0 ? h / 2 : h / 2 + 1;
            Console.WriteLine(string.Format("{0:f10}",(1.0 * odd) / h));
        }
    }
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    vector<vi> cnt(10, vi(10, 0));
    ll res=0;
    for(int i=1; i<=N; i++){
        int a, b;
        a=i%10;
        b=i;
        while(b >= 10) b/=10;
        cnt[a][b]++;
    }
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            res+=cnt[i][j]*cnt[j][i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
def inner_rate(num_participate, outer_rate):
    if(num_participate >= 10):
        return outer_rate
    else:
        return outer_rate + 100 * (10 - num_participate)

if __name__ == '__main__':
  num_participate, outer_rate = input().split()
  num_participate = int(num_participate)
  outer_rate = int(outer_rate)
  
  print(inner_rate(num_participate, outer_rate))


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int MAX_N = 100010;
const ll mod = 1000000007;
ll fact[MAX_N] = {};
ll rfact[MAX_N] = {};


ll quick_power(ll x, ll p){
    if(p == 0) return 1;
    if(p % 2 == 0){
        ll buf = quick_power(x, p / 2);
        return buf * buf % mod;
    }else{
        return x * quick_power(x, p - 1) % mod;
    }
}

ll factrial(ll x){
    if(x == 0) return 1;
    if(fact[x] != 0) return fact[x];
    else return fact[x] = x * factrial(x - 1) % mod;
}

ll rfactrial(ll x){
    //if(rfact[x] != 0) return rfact[x];
    return rfact[x] = quick_power(factrial(x), mod - 2);
}

ll combi(ll n, ll k){
    // n >= 0，k >= 0，n - k >= 0を保証する必要がある．
    // 逆に，上記を満たさない場合の処理をifで定める．
    if(n < k) return 0;
    if(k == 0) return 1;
    return (factrial(n) * rfactrial(n - k) % mod) * rfactrial(k) % mod;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l1, l2;
    int hash[MAX_N] = {};
    fill(hash, hash + MAX_N, -1);
    cin >> n;
    REP(i, n + 1){
        int a;
        cin >> a;
        if(hash[a] != -1){
            l1 = hash[a];
            l2 = i;
        }
        hash[a] = i;
    }

    FOR(k, 1, n + 1){
        ll ans = combi(n + 1, k) - combi(n + l1 - l2, k - 1) + mod;
        cout << ans % mod << "\n";
    }

    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main() {

    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    
    string AS=s.substr(a-1,c-a+1);
    string BS=s.substr(b-1,d-b+1);
    rep(i,AS.size()-1){
        if(AS[i]=='#'&&AS[i+1]=='#'){
            fin("No");
            return 0;
        }
    }
    rep(i,BS.size()-1){
        if(BS[i]=='#'&&BS[i+1]=='#'){
            fin("No");
            return 0;
        }
    }
    if(c<d){
        fin("Yes");
    } else {
        string TS=s.substr(b-2,d-b+3);
        rep(i,TS.size()-2){
            if(TS[i]=='.'&&TS[i+1]=='.'&&TS[i+2]=='.'){
                fin("Yes");
                return 0;
            }
        }
        fin("No");
    }
}



Measured memory_bytes: 772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define INF (1 << 30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

/* template end */

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

    int n;
    cin >> n;
    for (int i = 0; i < 10; i++)
    {
        if (n <= 111 * i)
        {
            cout << (111 * i) << endl;
            break;
        }
    }
#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif

    return 0;
}


Measured memory_bytes: 256
n,k,q = map(int, input().split())
A = list(map(int, input().split()))

ans = 10**18
for x in A:
    B = []
    C = []
    for a in A:
        if a >= x:
            C.append(a)
        else:
            if len(C) >= k:
                C.sort()
                B += C[0:len(C)-k+1]
            C = []
    else:
        if len(C) >= k:
            C.sort()
            B += C[0:len(C)-k+1]
    if len(B) >= q:
        B.sort()
        ans = min(ans, B[q-1]-x)
print(ans)


Measured memory_bytes: 9312
N, K = map(int, input().split())
a = list(map(int, input().split()))

max_a = 10**9
min_a = 0
while True:
    k = K
    res = (max_a+min_a)//2
    for i in range(N):
        if a[i] <= res:
            continue
        k -= (a[i]//res)
    if k >= 0:
        max_a = res
    else:
        min_a = res
    if max_a - min_a == 1:
        break
print(max_a)

Measured memory_bytes: 93920
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
void solve()
{
	ll a,b;
	rl2(a,b);
	//a++,b++;
	ll ans=(double)a/0.08;
	ll ans2=(double)b/0.1;
	ll x=ans*0.08;
	ll y=ans*0.1;
	if(x==a&&y==b)
	{

	}
	else
	{
		ans+=1;
		ll x=ans*0.08;
		ll y=ans*0.1;
		if(x==a&&y==b)
		{

		}
		else
		{
			ans=inf;
		}
	}
	x=ans2*0.08;
	y=ans2*0.1;
	if(x==a&&y==b)
	{

	}
	else
	{
		ans2+=1;
		ll x=ans2*0.08;
		ll y=ans2*0.1;
		if(x==a&&y==b)
		{

		}
		else
		{
			ans2=inf;
		}
	}
	ans=min(ans,ans2);
	if(ans==inf)
		cout<<"-1\n";
	else
		cout<<ans<<endl;
	//cout<<ans2<<" "<<ans<<endl;
	return;
}
int main()
{
	
	ll t=1;
	//rl(t);

	//cin>>t;
	//scanf()
	while(t--)
	{
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 384
N, K = map(int,input().split())
A = list(map(int,input().split()))
L = [0 for _ in range(40)]
for a in A:
    for i in range(40):
        L[i] += a & 1
        a >>= 1
L.reverse()
K = '{:040b}'.format(K)
dp1 = [0 for _ in range(41)]
dp2 = [0 for _ in range(41)]

for i in range(40):
    dp1[i+1] += 2 * dp1[i]
    if K[i] == '0':
        dp1[i+1] += L[i]
    else:
        dp1[i+1] += N - L[i]
    if dp2[i] != 0:
        dp2[i+1] = 2 * dp2[i] + max(L[i], N - L[i])
    if K[i] == '1':
        dp2[i+1] = max(dp2[i+1], 2 * dp1[i] + L[i])

ans = max(dp1[40], dp2[40])

print(ans)

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

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

const ll INF=1LL<<60;

// 入力
ll n;
ll h[110000];

// DPテーブル
ll dp[110000];

int main(){
  int n,k;cin>>n>>k;
  for(int i=0;i<n;++i)cin>>h[i];
  // for(int i=0;i<n;++i)cin>>h[i];
  for(int i=0;i<110000;++i)dp[i]=INF;
  dp[0]=0;
  for(int i=0;i<n;++i){
    for(int j=1;j<=k;++j){
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1920
N = int(input())
h = list(map(int, input().split()))
h.append(1000000001)
max_n = 0
counter = 0
while counter < N-1:
    add = 0
    count = 0
    while h[counter+add] >= h[counter+add+1]:
        count += 1
        add += 1
    counter += add +1
    max_n = max(max_n, count)
print(max_n)

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

int main()
{
    int N, Y;
    cin >> N >> Y;

    int mod = Y % 5000;
    Y = Y - mod;
    N = N - mod / 1000;
    for (int i = 0; i <= Y / 10000; i++)
    {
        for (int j = 0; j <= (Y - 10000 * i) / 5000; j++)
        {
            if ((10000 * i + 5000 * j + 1000 * (N - i - j)) == Y)
            {
                cout << i << ' ' << j << ' ' << N - i - j + mod / 1000 << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if (n >= 30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 35804
#include<stdio.h>

int main(void){

	int a,b,c,d,n,count;
	
	while(scanf("%d",&n)!=EOF){
		
		count=0;	
		
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(n==a+b+c+d){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}
	

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll mod=1000000007;



int main(){
    ll N=ii();
    ll ret=0;
    REP(i,1,N+1){
        ll n = (N/i);
        ret += n*(2*i+(n-1)*i)/2;
    }
    oie(ret);
    return 0;
}

Measured memory_bytes: 3624
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;

void rec(int& ans, int n, int G, vector<int>& comp, vector<int>& p, vector<int>& c) {
  // ベースケース
  if (n == comp.size()) {
    int sum = 0;
    int num = 0;
    rep(i, comp.size()) {
      if (comp[i]) {
        sum += p[i] * (i + 1) * 100 + c[i];
        num += p[i];
      }
    }

    if (sum < G) {
      for (int i = comp.size() - 1; i >= 0; --i) {
        if (comp[i] == 0) {
          int point = (i + 1) * 100;
          int a = (G - sum + point - 1) / (point); // 足りない問題数
          if (a < p[i]) {
            sum += a * point;
            num += a;
            break;
          } else {
            // 他にもコンプが必要というシチュエーションは、再帰によって網羅しているはずなので処理を打ち切る
            return;
          }
        }
      }
    }

    ans = min(ans, num);
    
    return;
  }

  // 再帰ステップ
  comp[n] = 0;
  rec(ans, n + 1, G, comp, p, c);
  comp[n] = 1;
  rec(ans, n + 1, G, comp, p, c);
}


int main(void) {
  int D, G;
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  rep(i, D) {
    cin >> p[i] >> c[i];
  }

  int ans = 10 * 100 + 50;
  vector<int> comp(D, 0);
  rec(ans, 0, G, comp, p, c);

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

Measured memory_bytes: 3632
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		System.out.println(fact(sc.nextInt()));
	}
	private static long fact(long n)
	{
		if (n == 1) return 1;
		return fact(n - 1) * n;
	}
}

Measured memory_bytes: 11000
def dfs(v, cnt):
    D[v] = cnt
    cnt += 1
    for c in edge[v]:
        if D[c] == -1:
            cnt = dfs(c, cnt)
    F[v] = cnt
    cnt += 1
    return cnt
 
 
V = int(input())
edge = [[] for _ in range(V)]
for _ in range(V):
    u, _, *v = map(lambda x: int(x)-1, input().split())
    edge[u] = sorted(v)
D, F = [-1] * V, [-1] * V
c = 1
for i in range(V):
    if D[i] == -1:
        c = dfs(i, c)
for i, (d, f) in enumerate(zip(D, F)):
    print(i+1, d, f)


Measured memory_bytes: 5660
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>

#define MAX_N (100)
#define INF (1000000000)

using namespace std;

typedef struct {
  int to;
  int cap;
  int rev;
} edge;

int find_path(vector<vector<edge>> &adj_lists, int cur, int min_to_cur, int dst,
              vector<int> &useds) {
  if (cur == dst) {
    return min_to_cur;
  }
  useds[cur] = 1;
  int ret = 0;
  for (edge &e : adj_lists[cur]) {
    if (!useds[e.to] && e.cap > 0) {
      int cap_path =
          find_path(adj_lists, e.to, min(min_to_cur, e.cap), dst, useds);
      if (cap_path > 0) {
        ret = cap_path;
        edge &r = adj_lists[e.to][e.rev];
        e.cap -= cap_path;
        r.cap += cap_path;
        break;
      }
    }
  }
  return ret;
}

int maximum_flow(vector<vector<edge>> &adj_lists, int src, int dst) {
  int ret = 0, cap_path;
  vector<int> useds(adj_lists.size());
  while (1) {
    for (int &used : useds) {
      used = 0;
    }
    cap_path = find_path(adj_lists, src, INF, dst, useds);
    if (cap_path > 0) {
      ret += cap_path;
    } else {
      break;
    }
  }
  return ret;
}

int main(int argc, char *argv[]) {
  // read inputs
  int N, as[MAX_N], bs[MAX_N], cs[MAX_N], ds[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &as[i], &bs[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &cs[i], &ds[i]);
  }

  // create graph
  // node [0, N)   : red points
  // node [N, 2*N) : blue points
  // node 2*N      : start
  // node 2*N + 1  : finish
  vector<vector<edge>> adj_lists(2 * N + 2, vector<edge>());
  // add edges from red points to blue points
  for (int i = 0; i < N; i++) {
    const int a = as[i], b = bs[i], node_r = i;
    for (int j = 0; j < N; j++) {
      const int c = cs[j], d = ds[j], node_b = j + N;
      if (a < c && b < d) {
        const edge e = {node_b, 1, adj_lists[node_b].size()};
        const edge r = {node_r, 0, adj_lists[node_r].size()};
        adj_lists[node_r].push_back(e);
        adj_lists[node_b].push_back(r);
      }
    }
  }
  // add edges from start to red points
  for (int i = 0; i < N; i++) {
    const edge e = {i, 1, adj_lists[i].size()};
    const edge r = {2 * N, 0, adj_lists[2 * N].size()};
    adj_lists[2 * N].push_back(e);
    adj_lists[i].push_back(r);
  }
  // add edges fron blue points to finish
  for (int j = 0; j < N; j++) {
    const edge e = {2 * N + 1, 1, adj_lists[2 * N + 1].size()};
    const edge r = {j + N, 0, adj_lists[j + N].size()};
    adj_lists[j + N].push_back(e);
    adj_lists[2 * N + 1].push_back(r);
  }

  // maximum match
  printf("%d\n", maximum_flow(adj_lists, 2 * N, 2 * N + 1));

  return 0;
}


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

int main() {
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d;
	e = a + b + c + d;
	cin >> a >> b >> c >> d;
	f = a + b + c + d;
	if (e > f) cout << e << endl;
	else cout << f << endl;
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		if(x!=y)cnt=0;
		else{
		    cnt++;
		    if(cnt>2)break;
		} 
	} 
	cout<<(cnt>2?"Yes":"No");
} 

Measured memory_bytes: 3648
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

l = []
for i in range(n):
  S = s.count(s[i])
  T = t.count(s[i])
  l.append(S - T)
  
if max(l) < 0:
  print(0)
else:
  print(max(l))


Measured memory_bytes: 3060
n, k = map(int, input().split())
hs = list(map(int, input().split()))
min_cost = [float('inf')] * n
min_cost[0] = 0
for i in range(1, n):
    min_cost[i] = min([min_cost[i-j] + abs(hs[i] - hs[i-j]) for j in range(1, k+1) if i-j >= 0])
print(min_cost[n-1])


Measured memory_bytes: 55264
chomp (my ($n, $m) = split / /, <STDIN>);
my @a;
for my $i (1..$m) {
  chomp (my $in = <STDIN>);
  $a[$i] = $in;
}
$a[0] = -1;
push @a, $n + 1;
my @b;
for my $i (1..$m+1) {
  if ($i != 1 && $a[$i] - $a[$i - 1] == 1) {
    print "0\n";
    exit;
  }
  push @b, $a[$i] - $a[$i - 1] - 1;
}
my @memo;
$memo[1] = 1;
$memo[2] = 1;
for my $i (3..$n+1) {
  $memo[$i] = $memo[$i - 1] + $memo[$i - 2];
  $memo[$i] %= 1e9 + 7;
}
my $ans = 1;
for my $i (@b) {
  $ans *= $memo[$i];
  $ans %= 1e9 + 7;
}
print "$ans\n";

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 5e6+17;
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int tmp = n/4,dap = n%4;
	if(n==3) return cout<<"2 5 63"<<endl,0;
	if(n==4) return cout<<"2 5 20 63"<<endl,0;
	if(n%8==4)
	{
		int x = 2;
		for (int i = 0; i < tmp-1; ++i)
		{
			cout<<x<<" "<<x+1<<" "<<x+2<<" "<<x+4<<" ";
			x+=6;
		}
		cout<<x+1<<" "<<x+4<<" "<<x+7<<" "<<x+10<<" ";
	}
	else
	{
		int x = 2;
		for (int i = 0; i < tmp; ++i)
		{
			cout<<x<<" "<<x+1<<" "<<x+2<<" "<<x+4<<" ";
			x+=6;
		}
		if(tmp&1&&dap==1)
			cout<<x+1<<endl;
		if(tmp%2==0&&dap==1)
			cout<<x+4<<endl;
		if(tmp&1&&dap==2)
			cout<<x+1<<" "<<x+4<<endl;
		if(tmp%2==0&&dap==2)
			cout<<x+1<<" "<<x+7<<endl;
		if(tmp&1&&dap==3)
			cout<<x<<" "<<x+1<<" "<<x+2<<endl;
		if(tmp%2==0&&dap==3)
			cout<<x<<" "<<x+2<<" "<<x+4<<endl;
	}
	return 0;	
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n,k;scanf("%d %d",&n,&k);

    int x=1;
    int ans=0;
    while(x<=n){
        x*=k;
        ans++;
    }

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

Measured memory_bytes: 128
# AtCoder Beginner Contest 077 C - Snuke Festival　

import sys

N = int(input())
A = list(map(int, sys.stdin.readline().strip().split()))
B = list(map(int, sys.stdin.readline().strip().split()))
C = list(map(int, sys.stdin.readline().strip().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)


def search(i, S):  # i : search する数値  S: search対象の数列　　大きいものの個数を返す
    if S[0] > i:
        return len(S)
    if S[-1] <= i:
        return 0

    left = 0
    right = len(S) - 1

    while right - left != 1:
        # print(f'right:{right}, left:{left}')
        mid = int((left + right) / 2)
        if S[mid] <= i:
            left = mid
        else:
            right = mid

    return len(S) - (left + 1)


def search1(i, S):  # i : search する数値  S: search対象の数列  小さいものの個数を返す
    if S[0] >= i:
        return 0
    if S[-1] < i:
        return len(S)

    left = 0  # 満たす
    right = len(S) - 1  # 満たさない

    while right - left != 1:
        mid = int((left + right) / 2)
        if S[mid] < i:
            left = mid
        else:
            right = mid

    return left + 1


ans = 0
for b in B:
    ans_a = search1(b, A)
    ans_c = search(b, C)

    ans += ans_a * ans_c

print(ans)


Measured memory_bytes: 24052
#include<cstdio>
#include<cmath>
const double PI = acos(-1);
int main() {
	double x, a, b;
	scanf("%lf%lf%lf", &a, &b, &x), x /= a;
	if( a * b / 2 >= x ) {
		double p = 2 * x / b;
		printf("%.8lf\n", atan(b / p)/2/PI*360);
	}
	else {
		double p = 2*(a*b - x) / a;
		printf("%.8lf\n", atan(p / a)/2/PI*360);
	}
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int N, X, T;
    cin >> N >> X >> T;
    
    cout << ((N - 1) / X + 1) * T << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<vector>
#include<list>
using namespace std;
//并?集3
struct uf_note3
{
	unsigned type;
	list<size_t>lst;
};
class union_find3
{
	unsigned l;
	uf_note3*ufn;
public:
	void init(unsigned length)
	{
		unsigned i, j, k, t;
		l = length;
		ufn = new uf_note3[l];
		for (i = 0; i < l; ++i)ufn[i].type = i;
	}
	void unite(unsigned x, unsigned y)
	{
		if (ufn[x].type != ufn[y].type) {
			unsigned t = ufn[y].type;
			list<size_t>::iterator it, end = ufn[t].lst.end();
			ufn[ufn[x].type].lst.push_back(t);
			ufn[t].type = ufn[x].type;
			for (it = ufn[t].lst.begin(); it != end; ++it) {
				ufn[*it].type = ufn[x].type;
				//ufn[ufn[x].type].lst.push_back(*it);
			}
			list<size_t>::iterator itt = ufn[ufn[x].type].lst.end();
			--itt;
			ufn[ufn[x].type].lst.splice(itt, ufn[t].lst);
			//ufn[t].lst.clear();
		}
	}
	bool same(unsigned x, unsigned y)
	{
		return ufn[x].type == ufn[y].type;
	}
	void del()
	{
		unsigned i;
		for (i = 0; i < l; ++i)ufn[i].lst.clear();
		delete[]ufn;
	}
};
class union_find2
{
	size_t l;
	size_t*type;
	bool inUse;
	size_t findType(size_t x)
	{
		return x == type[x] ? x : findType(type[x]);
	}
public:
	union_find2()
	{
		inUse = false;
	}
	void init(size_t length)
	{
		size_t i;
		l = length;
		type = new size_t[l];
		for (i = 0; i < l; ++i)type[i] = i;
		inUse = true;
	}
	void unite(size_t x, size_t y)
	{
		type[findType(y)] = findType(x);
	}
	bool same(size_t x, size_t y)
	{
		return findType(x) == findType(y);
	}
	void del()
	{
		delete[]type;
		inUse = false;
	}
	~union_find2()
	{
		if (inUse)del();
	}
};
int main()
{
	union_find3 uf;
	int n, q, com, x, y, i;
	scanf("%d%d", &n, &q);
	uf.init(n);
	for (i = 0; i < q; ++i) {
		scanf("%d%d%d", &com, &x, &y);
		if (com == 0) uf.unite(x, y);
		else printf("%d\n", (uf.same(x, y) ? 1 : 0));
	}
	uf.del();
	return 0;
}

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

int main() {
  string x;
  cin >> x;
  int ans = 0;
  for (int i=0; i< x.size(); i++) {
    char y = x.at(i);
    if (y=='1') {
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

bool Solve() {
  int n;
  cin >> n;

  auto graph = ReadUndirectedGraph(n, n - 1, true);

  if (n % 2 == 1) {
    return true;
  }

  if (n == 2) {
    return false;
  }

  vector<int> degrees(n);
  for (int v = 0; v < n; v++) {
    degrees[v] = graph[v].size();
  }
  vector<int> removed(n);

  queue<int> q;
  for (int v = 0; v < n; v++) {
    if (degrees[v] == 1) {
      q.push(v);
    }
  }

  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (removed[v]) {
      continue;
    }
    int p = -1;
    for (const auto& e : graph[v]) {
      if (removed[e.to]) {
        continue;
      }
      p = e.to;
    }

    if (p == -1) {
      return true;
    }

    vector<int> us;
    for (const auto& e : graph[v]) {
      if (removed[e.to]) continue;
      if (e.to == p) continue;
      us.push_back(e.to);
    }
    for (const auto& e : graph[p]) {
      if (removed[e.to]) continue;
      if (e.to == v) continue;
      us.push_back(e.to);
    }

    for (int u : us) {
      degrees[u]--;
      if (degrees[u] == 1) {
        q.push(u);
      }
    }
    degrees[v] = 0;
    degrees[p] = 0;
    removed[v] = true;
    removed[p] = true;
  }
  return false;
}

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

  if (Solve()) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 2e5 + 48, mod = 1e9 + 7;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


ll ans;
int n, k, a[N];
unordered_map < int, int > cnt;



main () {
	cin >> n >> k;
	forn (i, 1, n) {
		cin >> a[i]; 
		a[i] = (a[i - 1] + a[i]) % k;
	}
		
	forn (i, 0, n) {
		ans += cnt[a[i] - i]++;
		ans += cnt[a[i] - i + k];
		if (i >= k - 1) 
			--cnt[a[i - k + 1] - (i - k + 1)];
	}	
	cout << ans << endl;
}                        
 

Measured memory_bytes: 17652
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int a[6];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a,a+5,greater<int>());
	rep(i,4)cout<<a[i]<<" ";
	cout<<a[4]<<endl;

	return 0;
}



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n,k;
  cin >> n >> k;
  const int MINF = -(1<<30);
  int r,s,p;
  cin >> r >> s >> p;
  
  string t;
  cin >> t;
  int dp[n+1][3] = {};
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  
  int index = 0;
  for(auto c:t){
    index++;
    int prev = max(max(dp[index-1][0],dp[index-1][1]),dp[index-1][2]);
    dp[index][0] = dp[index][1] = dp[index][2] = prev;
    switch(c)
    {
        case 'r':
          dp[index][2] += p;
          break;
        case 's':
          dp[index][0] += r;
          break;
        case 'p':
          dp[index][1] += s;
          break;
    }
    if(index>k){
      switch(t[index-k-1])
      {
        case 'r':
          dp[index][2] += max(dp[index-k][0],dp[index-k][1])-dp[index-k][2];
          break;
        case 's':
          dp[index][0] += max(dp[index-k][2],dp[index-k][1])-dp[index-k][0];
          break;
        case 'p':
          dp[index][1] += max(dp[index-k][2],dp[index-k][0])-dp[index-k][1];
          break;
      }
    }
  }
  
  cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << endl;

  
  return 0;
}




Measured memory_bytes: 5000
N = int(input())
D,X = map(int,input().split())
A = [int(input()) for i in range(N)]
a = []
for i in range(N):
    if D % A[i] == 0:
        a.append(D // A[i])
    else:
        a.append(D // A[i] + 1)

print(sum(a) + X)

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  if (k > 100) k = 100;
  vector<int> a(n);

  arep(i, a) cin >> i;

  rep(i, 0, k) {
    vector<int> next(n + 1, 0);
    rep(j, 0, n) {
      // cout << j - a[j] << ' ';
      if (a[j] == 0) {
        next[j]++;
        next[j + 1]--;
        // cout << j << ' ';
        // cout << j + 1 << ' ';
      } else {
        if (j - a[j] < 0) {
          next[0]++;
          // cout << 0 << ' ';
        } else {
          next[j - a[j]]++;
          // cout << j - a[j] << ' ';
        }
        // cout << j + 1 + a[j] << ' ';
        if (j + 1 + a[j] < n) next[j + 1 + a[j]]--;
      }
      // cout << '\n';
    }
    rep(j, 0, n) {
      a[j] = next[j];
      next[j + 1] += next[j];
      // cout << next[j] << ' ';
      // cout << a[j] << ' ';
    }
    // cout << '\n';
  }

  rep(i, 0, n) cout << a[i] << ' ';
  cout << '\n';
  return 0;
}

Measured memory_bytes: 6320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

const int NM = 110;
int f[NM][10];
int p[NM][11];

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

    rep(i,n){
        rep(j, 10){
            cin >> f[i][j];
        }
    }
    rep(i, n){
        rep(j, 11){
            cin>>p[i][j];
        }
    }
    // bit全探索
    ll ans = -1e15;
    for(int bit=1; bit<(1<<10); bit++){
        // このパターンにおける共通Openの数をカウントする
        ll score = 0;
        for(int j=0; j<n; j++){ // 店Jに対して
            int cnt = 0;
            for(int i=0; i<10; i++){
                if(bit & (1<<i)){
                    if(f[j][i] == 1){
                        cnt++;
                    }
                }
            }
            score += p[j][cnt];
        }
        ans = max(ans, score);
    }
    cout<<ans<<endl;

}

// abc080_c

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

int main(){
  int k;
  cin >> k;
  int ret = 0;
  for(int i=1; i<=k; i++)for(int j=1; j<=k; j++)for(int l=1; l<=k; l++){
    ret += gcd(gcd(i, j), l);
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A[3],i,mx=0,Mx,K,c=0;
  for(i=0;i<3;i++)
  {
    cin>>A[i];
  }
  cin>>K;
  for(i=0;i<3;i++)
  {
    mx=max(mx,A[i]);
  }
  Mx=mx*pow(2,K);
  for(i=0;i<3;i++)
  {
    c=c+A[i];
  }
  c=c-mx;
    cout<<Mx+c;
   return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		int B[] = new int[N];
		for(int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		int C[] = new int[N-1];
		for(int i = 0; i < N-1; i++) {
			C[i] = sc.nextInt();
		}
		int result = 0;
		for(int i = 0; i < N; i++) {
			result += B[A[i]];
			if(1 <= i && A[i-1] == A[i]-1) {
				result += C[A[i-1]];
			}
		}
		System.out.println(result);
		sc.close();
	}

}
/*
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□■■□□
■■■■■■□□□■□■■■□□□
□□□□□■□□□■■■□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□■■■□□□■□□□□□□□
□■■■□■□□□■□□□□□■□
■■□□□■□□□■■□□□■■□
□□□□□■□□□□■■■■■□□
□□□□□■□□□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
■■■■■■■■■■■■■■■■□
□□□□□□□■□□□□□□□□□
□□□□□□■■■□□□□□□□□
□□□□□□■□■□□□□□□□□
□□□□□□■□■■□□□□□□□
□□□□□■■□□■□□□□□□□
□□□□□■□□□■■□□□□□□
□□□□■■□□□□■■□□□□□
□□□■■□□□□□□■■□□□□
□□■■□□□□□□□□■■□□□
■■■□□□□□□□□□□■■■□
*/

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    float N;
    cin >> N;
    
    cout << ceil(N/2) << endl;

    return 0;
}

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

void solve(long long K, long long T, std::vector<long long>&& as)
{
    auto cake_max = *max_element(begin(as), end(as));
    if (cake_max * 2 - K <= 1) {
        cout << 0 << endl;
    } else {
        cout << cake_max * 2 - K - 1 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long K;
    scanf("%lld",&K);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> a(T);
    for(int i = 0 ; i < T ; i++){
        scanf("%lld",&a[i]);
    }
    solve(K, T, std::move(a));
    return 0;
}


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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


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

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  double a,b,h,m;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);

  double pi=3.14159265358979;
  /*

  時計の中心と文字盤の0を結んだ線を基準線と呼ぶことにします．

  時計の中心と文字盤のh(0<=h<12)を結んだ線と基準線が作る角の大きさx(0<=x<180)は
  度数法で(30*h)と表すことができます．
  
  また，m分(0<=m<60)の時の長針と基準線が作る角の大きさy(0<=y<180)は
  度数法で(6*m)と表すことができます．

  これらをまとめてh時m分の時の長針と短針が作る角の大きさは
  abs(30*h-6*m)と表すことができそうです(これが180を超える場合は360から引いてやればいいです)

  が，短針は時間が変わったら30度一気に動くわけではなく，60分かけて30度を動いていくので，それも考慮しなければなりません．

  つまり，30*(m/60)=m/2をxに足してやる必要があります．

  改めて，h時m分の時の長針と短針が作る角の大きさzは
  abs(30*h+m/2-6*m)と表すことができます．

  ここで余弦定理を用いて求める長さが欲しいわけですが，注意しなければいけないのは
  sin(z)の引数(渡してあげるzのこと)は度数法ではなく弧度法でないといけません．

  pi==180\degreeであるのでpi:180==?:zの式を?について解くと
  ?=z*pi/180であることがわかります．

  以上のことより，答えは

  a*a+b*b-2*a*b*cos(z*pi/180)

  となります．
  
  */
  
  //0<=h<12にする
  if(h>=12){
    h-=12;
  }

  //hは基準線とそれが作る角度
  h=30*h+m/2;

  //mは基準線とそれが作る角度
  m*=6;
  
  
  double z=h-m;
  
  //この部分，なんでこんな実装をしているかというと，
  //abs(h-m)を渡してやったら誤差で消えるケースがあったので
  //こういう実装をしました．
  if(z<0){
    z*=-1;
  }
  
  
  if(z>180){
    z=360-z;
  }


  z=z*pi/180;
  
  double ans=a*a+b*b-2*a*b*cos(z);

  printf("%.16lf\n",sqrt(ans));

  return 0;
}

Measured memory_bytes: 2660
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<=(n);i++)
using namespace std;
typedef long long ll;
int a,b,c;
int main(){
  cin >> a >> b;
  int ans;
  rep(i,30){
    ans=a + (a-1)*(i-1);
    if(ans>=b){
      cout << i <<endl;
      break;
    }
  }
  return 0;
}

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

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

vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i,0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        } 
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ab_gcd = gcd(a,b);
    auto f = factorize(ab_gcd);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256