akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int euclidean_gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


void solve(void)
{
  int A,B;
  cin>>A>>B;
  int GCD = euclidean_gcd(A,B);
  map<int,int> mp = prime_factor(GCD);
  cout<<mp.size()+1<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
int a[N],i,j,n,m=0,tmp,b;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<n;i++){
tmp = i;
for(j=i;j<n;j++){
if(a[j]<a[tmp]){
tmp=j;
}}
if(i!=tmp){
b=a[i];
a[i]=a[tmp];
a[tmp]=b; 
m++;

}
}
for(i=0;i<n;i++){
if(i==n-1)printf("%d\n",a[i]);
else printf("%d ",a[i]);
}
printf("%d\n",m);
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)
{
	//変数の宣言
	int a,b;
	int n,ans;
	
	//データの読み込み
	
	scanf("%d %d",&a,&b);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	
	//実際の処理
	
	n=b-a;
	ans=n*(n+1)/2-b;
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
	
//	printf("結果の出力終了\n");
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    int n, m; cin >> n >> m;
    vector<ll> a(n);
    vector<pair<ll, ll>> key;

    for(int i=0; i<n; i++)  cin >> a.at(i);
    for(int i=0; i<m; i++){
        ll x, y;    cin >> x >> y;
        key.push_back({y, x});
    }
    sort(a.begin(), a.end());
    sort(key.begin(), key.end(), greater<pair<ll, ll>>());

    
    for(int i=0, j=0; i<n && j<m; i++){
        if(a[i]<key[j].first){
            a[i] = key[j].first;
            key[j].second -= 1;
            if(key[j].second==0) j += 1;
        }
    }
    ll ans=0;
    for(int i=0; i<n; i++)  ans += a[i];
    cout << ans << endl;


}

Measured memory_bytes: 3188
import sys


sys.setrecursionlimit(10 ** 6)

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append((b - 1, i))
    edge[b - 1].append((a - 1, i))
ec = [0] * (N - 1)


def dfs(node, pc):
    color = 1

    for to, idx in edge[node]:
        if ec[idx] == 0:
            if color == pc:
                color += 1
            ec[idx] = color

            dfs(to, color)
            color += 1


dfs(0, -1)
print(max(ec))
for c in ec:
    print(c)


Measured memory_bytes: 74720
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<=5){
      System.out.println(0);
    }else if(a<=12){
      System.out.println(b/2);
    }else{
      System.out.println(b);
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

bool isSeisu(vector<int>& v1, vector<int>& v2) {
	int sum = 0;
	for (int i = 0; i < v1.size(); i++) {
		sum += (v1[i] - v2[i]) * (v1[i] - v2[i]);
	}
	double d = pow(sum, 0.5);
	return ceil(d) == floor(d);
}

int main()
{
	int n, d;
	cin >> n;
	cin >> d;
	vector<vector<int>> p(n, vector<int>(d, 0));

	for (int i = 0; i < n; i++) {
		for (int k = 0; k < d; k++) {
			cin >> p[i][k];
		}
	}
	
	int c = 0;
	int start = 0;
	for (int k = 0; k < (n - 1); k++) {
		int t = n - 1 - start;
		for (int i = 0; i < t; i++) {
			if (isSeisu(p[start], p[start + i + 1]))
				c++;
		}
		start++;
	}
	cout << c;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    int N;
    int[] A;
    void Solve() {
        //input
        N = io.Int;
        A = new int[N];
        for (int i = 0; i < N; ++i)
            A[i] = io.Int;
        var dic = new Dictionary<int, int>();
        foreach (var v in A) {
            if (!dic.ContainsKey(v)) dic[v] = 0;
            dic[v]++;
        }
        var twoOrMore = dic.Where(kp => kp.Value >= 2).
            Select(kp => kp.Key).OrderByDescending(v => v).ToArray();
        var fourOrMore = dic.Where(kp => kp.Value >= 4).
            Select(kp => kp.Key).OrderByDescending(v => v).ToArray();
        var ans = 0L;
        if (twoOrMore.Length >= 2 && fourOrMore.Length >= 1) {
            ans = Max((long)twoOrMore[0] * twoOrMore[1],
                      (long)fourOrMore[0] * fourOrMore[0]);
        } else if (twoOrMore.Length >= 2) {
            ans = (long)twoOrMore[0] * twoOrMore[1];
        } else if (fourOrMore.Length >= 1) {
            ans = (long)fourOrMore[0] * fourOrMore[0];
        }
        //ret
        WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 26080
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  //int n; cin>>n;
  //string s; cin>>s;
  int x; cin>>x;
  int ans;
  if(x>=400&&x<=599) ans=8;
  else if(x<800) ans=7;
  else if(x<1000) ans=6;
  else if(x<1200) ans=5;
  else if(x<1400) ans=4;
  else if(x<1600) ans=3;
  else if(x<1800) ans=2;
  else ans=1;
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){

	int a,b,c,d,e;
	b=0;
	d=0;
	e=0;
	for(a=1;a<10;a++){
		b=a;

		for(c=1;c<10;c++){
			d=c;
			e = b*d;
			printf("%dx%d=%d\n",b,d,e);
		}
	}
			
	return 0;

}

Measured memory_bytes: 524
#include <bits/stdc++.h>
int c[26],d[26];
using namespace std;

int main()
{
  int a,b,s=0,t=0,u=0;
  scanf("%d %d",&a,&b);
  s=a+b;t=a-b;
  u=max(s,t);
  u=max(u,(a*b));
  printf("%d",u);
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int a[5];

for (int i = 0; i < 5; i++){
scanf("%d", &a[i]);
}

for (int i = 0; i < 5; i++){
for (int j = i + 1; j < 5; j++){
if (a[i] < a[j]){
a[i] ^= a[j];
a[j] ^= a[i];
a[i] ^= a[j];
}
}
}

printf("%d", a[0]);
for (int i = 1; i < 5; i++){
printf(" %d", a[i]);
}
puts("");

return (0);
}

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

using namespace std;
int n,m;
vector<vector<int> > graph;
vector<int> dp;

int dfs(int curr)
{
    if(dp[curr] != -1)
    {
        return dp[curr];
    }

    int res = 0;

    for(auto i : graph[curr])
    {
        res = max(res,dfs(i)+1);
    }

    return dp[curr] = res;
}

int main()
{
    int i,j;

    cin>>n>>m;
    int x,y;
    graph = vector<vector<int>>(n,vector<int>());

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        graph[x-1].push_back(y-1);
    }
    dp = vector<int>(n,-1);

    int ans = -1;

    for(i=0;i<n;i++)
    {
        ans = max(ans,dfs(i));
    }
    cout<<ans;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

ll comb[51][51];

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setp(12);
    int n,a,b; cin>>n>>a>>b;
    vll v(n);
    rep(i,n) cin>>v[i];
    sort(rall(v));
    double ave=0;
    rep(i,a){
        int step=i+1;
        ave+=((double)(v[i])-ave)/step;
    }
    cout<<ave<<"\n";
    //Combination
    comb[0][0] = 1;
    rep(i,50)rep(j,51){
        if (j>=1) comb[i+1][j]=comb[i][j]+comb[i][j-1];
        else comb[i+1][j]=comb[i][j];
    }
    int cnt=0;
    rep(i,n){
        if (v[i]==v[a-1]) cnt++;
    }
    ll ans=0;
    if (v[0]==v[a-1]){
        FOR(i,a-1,b-1){
            if (v[i]!=v[0]) break;
            ans+=comb[cnt][i+1];
        }
        cout<<ans<<"\n";
        return 0;
    }
    int cnt2=0;
    rep(i,a){
        if (v[i]==v[a-1]) cnt2++;
    }
    cout<<comb[cnt][cnt2]<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <set>

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()

using namespace std;
const int MOD = 1000000007;

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	return ((m / gcd(m, n)) * n);
}


long kake(long x, long y){
	return x * y % MOD;
}

long fact_mod(long x){
	long ans = x;
	x-=1;
	while(x>1){
		ans = ans * x % MOD;
		x-=1;
	}
	return ans;
}


int main(){


	long N, M;
	scanf("%ld %ld",&N,&M);

	if(abs(N-M)>1){
		cout << 0 << endl;
	} else {
		if(N!= M){
			cout << fact_mod(N) * fact_mod(M) % MOD << endl;;
		} else {
			cout << (2 * fact_mod(N) % MOD) * fact_mod(M) % MOD << endl;
		}

	}

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main ()
{
	int n,day[99],i;
	cin >> n;
	for( i =0;i<n;i++){
	cin >> day[i];
	}

	for( i =1;i<n;i++){
    	cout << day[n - i] << " ";

    }cout <<day[0]<< endl;


}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

vector<vector<int>>ans;
int n;

void rec(int l,int r,int d){
  int mid=(l+r)/2;
  if(r-l>1){
    rec(l,mid,d+1);
    rec(mid,r,d+1);
  }
  for(int i=l;i<mid;++i){
    for(int j=mid;j<r;++j){
      ans[i][j]=d;
    }
  }
}

void solve(){
  cin>>n;
  ans.resize(n,vector<int>(n,1));
  rec(0,n,1);
  rep(i,n-1){
    for(int j=i+1;j<n;++j){
      cout<<ans[i][j]<<" ";
    }
    cout<<"\n";
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

int main()
{
    int n;
    int *a;
    int num;

    cin >> n;

    if (n > 0 && n <= 100) {
        a = new int[n];

        num = 0;
    
        for (int i = 0; i < n; i++) {
            cin >> a[num];
            if (a[num] >= 0 && a[num] <= 1000) {
                num++;
            }
        }

        for (int j = num-1; j >= 0; j--) {
            cout << a[j];
            if (j) {
                cout << " ";
            }
        }
        cout << endl;

        delete [] a;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
ll mod = 1e9+7;
int main()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    ll s1 = 0, s2 = 0;
    for (int i=0; i<n; i++) {
        cin>>a[i];
        s1 += a[i];
        s2 += (a[i] * a[i]);
        s1 %= mod;
        s2 %= mod;
    }
    ll res = (s1 * s1 - s2);
    res %= mod;
    while (res < 0) res += mod;
    ll ans;
    if (res % 2) ans = (res + mod) / 2;
    else ans = res / 2;
    
    cout << ans << '\n';
}

Measured memory_bytes: 4828
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int A = 0, B = 0, C = 0;
	int ans = 0;
	scanf("%d %d %d", &A, &B, &C);
	ans = C - (A-B);
	if (ans < 0) {
		ans = 0;
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

const int MX_A = 300001;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

void solve(int N, int K, vector<int> A) {
    segtree<int, op, e> seg(MX_A);
    for (int i = 0; i < N; i++) {
        int l = max(0, A.at(i) - K);
        int r = min(MX_A, A.at(i) + K + 1);
        int mx = seg.prod(l, r);
        seg.set(A.at(i), mx + 1);
    }
    cout << seg.all_prod() << endl;
}

int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    solve(N, K, move(A));
    return 0;
}


Measured memory_bytes: 9592
y = int(input())
x = input()
list = x.split()
list.reverse()

k = " "


b = list[0]


if y >= 2:
    a = list[0]
    b = a + k

    for i in range(y - 2):
        c = list[i + 1]
        b = b + c + k

    a = list[-1]
    b = b + a

print(b)


Measured memory_bytes: 5592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> p(n); rep (i, n) cin >> p[i];
    int ans = 0;
    rep (i, n - 2)
        if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2]))
            ans++;
    cout << ans << "\n";
    return 0;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
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);
}

//////////////////

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)



void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    rep(_,K){
        vector<int> s(N+1,0);
        rep(i,N){
            s[ max(0LL,i-A[i]) ] ++;
            s[ min(N,i+A[i]+1) ] --;
        }
        rep(i,N) s[i+1] += s[i];
        rep(i,N) A[i] = s[i];
//        dump(A);
        
        if(_ > 500) break;
    }
    rep(i,N) cout << A[i] << " ";
    cout << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 6428
#include<stdio.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
typedef long long lint;
const int mod=1000000007;
int k,n=-1,cnt=13;
char c[15];
lint fact[2000010],inv[2000010];
int main(){
	while(true){
		*c=getchar_unlocked();
		if(*c=='\n')break;
		k*=10;
		k+=*c-'0';
	}
	while(getchar_unlocked()!=-1)n++;
	fact[0]=1;
	for(int i=1;i<=n+k;i++)fact[i]=fact[i-1]*i%mod;
	inv[n+k]=1;
	lint now=fact[n+k];
	int b=mod-2;
	while(b){
		if(b&1){
			inv[n+k]*=now;
			inv[n+k]%=mod;
		}
		b>>=1;
		now*=now;
		now%=mod;
	}
	for(int i=n+k-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	lint ans=1;now=1;
	for(int i=1;i<=k;i++){
		now*=25;
		now%=mod;
		ans+=fact[n+k]*inv[n+k-i]%mod*inv[i]%mod*now;
		ans%=mod;
	}
	*(c+14)='\n';
	while(ans){
		*(c+cnt)=ans%10+'0';
		ans/=10;
		cnt--;
	}
	fwrite(c+cnt+1,1,14-cnt,stdout);
	return 0;
}

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

int main()
{
ll n ;
cin >> n ;
vector<pair<ll,ll>> v,vv;
ll cnt=0;
rep(i,n){
  string s ;
  cin >> s ;
  ll te=0,tt=0;
  rep(j,s.size()){
    if(s[j]==')'&&te==0){tt++;cnt--;}
    else if(s[j]==')'){te--;cnt--;}
    else {te++;cnt++;}
  }
  if(te>=tt)v.emplace_back(tt,te);
  else vv.emplace_back(te,tt);
}
if(cnt!=0){cout << "No" << endl;return 0;}
sort(v.begin(),v.end());
sort(vv.begin(),vv.end());
reverse(vv.begin(),vv.end());
ll nw=0;
for(auto r:v){
  nw-=r.first;
  if(nw<0){cout << "No" << endl;return 0;}
  nw+=r.second;
}
for(auto r:vv){
  nw-=r.second;
  if(nw<0){cout << "No" << endl;return 0;}
  nw+=r.first;
}
cout << "Yes" << endl;
return 0;
}


Measured memory_bytes: 18928
#include <stdio.h>
#include <inttypes.h>

int getID(const char* kitaeri) {
	switch (kitaeri[0]) {
		case 'M': return 1;
		case 'A': return 2;
		case 'R': return 3;
		case 'C': return 4;
		case 'H': return 5;
		default: return 0;
	}
}

int64_t mult(const int64_t data[], int a, int b, int c) {
	return data[a] * data[b] * data[c];
}

int main(void) {
	int N;
	int i;
	int64_t count[6] ={0};
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		char S[12];
		if (scanf("%11s", S) != 1) return 1;
		count[getID(S)]++;
	}
	printf("%" PRId64 "\n",
		mult(count, 1, 2, 3) + mult(count, 1, 2, 4) + mult(count, 1, 2, 5) +
		mult(count, 1, 3, 4) + mult(count, 1, 3, 5) + mult(count, 1, 4, 5) +
		mult(count, 2, 3, 4) + mult(count, 2, 3, 5) + mult(count, 2, 4, 5) +
		mult(count, 3, 4, 5));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  
  int sum = 0;
  
  rep(i, n) {
    sum += x[i];
  }
  
  int p1 = sum / n;
  int p2 = p1 + 1;
  
  int ans1 = 0;
  int ans2 = 0;
  
  rep(i, n) {
    ans1 += pow((x[i] - p1), 2);
  }
  
  rep(i, n) {
    ans2 += pow((x[i] - p2), 2);
  }
  
  cout << min(ans1, ans2) << endl;
  return 0;
}


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

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

	int cnt = 0;


	for( int i=0 ; i<=a ; i++ )
	{
		int tmp = i;
		int sum = 0;

		while( tmp > 0 )
		{
			sum += tmp % 10;
			tmp /= 10;
		}

		if( b <= sum && sum <= c )
		{
			cnt += i;
		}
	}





	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
const ll MOD = 998244353;

inline void maxch(int& a, int b) { if (a < b) a = b; }

int main() {
	int n;
	cin >> n;
	
	vector<int> x(n), y(n);
	rep(i,n) cin >> x[i] >> y[i];

	long double ans = 0;
	vector<int> perm(n);
	rep(i,n) perm[i] = i;
	do {
	  rep(i,n-1) ans += sqrt(pow(x[perm[i]] - x[perm[i+1]],2) + pow(y[perm[i]] - y[perm[i + 1]], 2));
	}while(next_permutation(perm.begin(),perm.end()));

	int a = 1;
	rep(i,n) a *= i+1;

	printf("%Lf",ans / (long double) a);
}

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vec.push_back(0);
    int ans = 0;
    int cnt = 0;
    rep(i,N + 1){
        if (vec[i] == i + 1){
            cnt++;
        }
        else{
            ans += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,ans=1000;
    cin >>n;
    vector<int>a(n);
    
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    
    for(int i=1;i<n;i++){
        if(a[i-1]<a[i]){
            ans=ans/a[i-1]*a[i]+ans%a[i-1];
        }
    }
    cout <<ans;
    
    
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		long d = scan.nextInt();
		d *= d;
		
		long[] x = new long[n];
		long[] y = new long[n];
		long[] dis = new long[n];
		
		for(int i = 0; i < n; i++) {
			x[i] = scan.nextLong();
			y[i] = scan.nextLong();
			dis[i] = x[i] * x[i] + y[i] * y[i]; 
		}
		int ans = 0;
		
		for( int i = 0; i < n; i++) {
			if(dis[i] <= d) {
				ans++;
			}
		}
		
		System.out.print(ans);
	}

}


Measured memory_bytes: 64336
use std::cmp::{max, min};
use std::io::{self, Read};
use std::iter::FromIterator;

#[allow(dead_code)]
struct Source {
    chars: Box<Iterator<Item = char>>,
}

#[allow(dead_code)]
impl Source {
    fn next_chr(&mut self) -> char {
        self.chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .next()
            .expect("eof")
    }

    fn next_str(&mut self) -> String {
        let it = self
            .chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .take_while(|c| !char::is_whitespace(*c));
        let s = String::from_iter(it);
        if s.is_empty() {
            panic!("eof")
        } else {
            s
        }
    }

    fn from_stdin() -> Self {
        let mut data = String::new();
        io::stdin().read_to_string(&mut data).expect("Input error");
        Self::from_str(&data)
    }

    fn from_str(s: &str) -> Self {
        let data = String::from(s);
        let chars = data.chars().collect::<Vec<char>>().into_iter();
        Source {
            chars: Box::new(chars),
        }
    }
}

#[allow(unused_macros)]
macro_rules! input {
    ($src:expr; $($elem:tt)*) => {
        input_inner!($src, $($elem)*)
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($src:expr) => {};
    ($src:expr,) => {};
    ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {
        let mut $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
    ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {
        let $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
}

#[allow(unused_macros)]
macro_rules! parse {
    ($src:expr, ( $($ty:tt),* )) => {
        ( $(parse!($src,$ty)),* )
    };
    ($src:expr, char) => {
        $src.next_chr()
    };
    ($src:expr, [ $ty:tt; $len:expr ]) => {
        (0..$len).map(|_| parse!($src,$ty)).collect::<Vec<_>>()
    };
    ($src:expr, $ty:tt) => {
        parse_str!($src,$ty)
    };
}

#[allow(unused_macros)]
macro_rules! parse_str {
    ($src:expr, chars) => {
        $src.next_str().chars().collect::<Vec<char>>()
    };
    ($src:expr, $ty:ty) => {
        $src.next_str().parse::<$ty>().expect("Parse error")
    };
}

fn main() {
    let mut src = Source::from_stdin();
    input! { src;
             n: usize, h: [usize; n],
    }

    let mut res = 0;
    let mut c = vec![0; n];
    loop {
        let mut b = false;
        let mut prev = n;
        for i in 0..n {
            if c[i] < h[i] {
                b = true;
                c[i] += 1;
                if prev + 1 != i {
                    res += 1;
                }
                prev = i;
            }
        }
        if !b {
            println!("{}", res);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (N == 1 && M == 1)
    {
        cout << 1 << endl;
    }
    else if (N == 1 || M == 1)
    {
        cout << max(N, M) - 2 << endl;
    }
    else
    {
        cout << (N - 2) * (M - 2) << endl;
    }
    return 0;
}


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

int main() {
   int A, B, C, D;
   cin >> A >> B >> C >> D;

   for(;;) {
      C -= B;
      A -= D;
      if(C <= 0) {
         cout << "Yes" << endl;
         return 0;
      }
      else if(A <= 0) {
         cout << "No" << endl;
         return 0;
      }
   }
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll x,k,d,q,r;
	scanf("%lld%lld%lld",&x,&k,&d);
	x=abs(x),q=x/d,r=x%d;
	if(k<=q) printf("%lld\n",x-d*k);
	else printf("%lld\n",(k-q)&1?d-r:r);
}

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

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

      n = Integer.parseInt(sc.next());

      int a[] = new int[n];

      for(int i=0; i<n; i++){
        a[i] = Integer.parseInt(sc.next());
      }

      Arrays.sort(a);
      int min = a[0];

      while(true){
        for(int j=1; j<n; j++){
          if(a[j]%min == 0){
            a[j] = min;
          }else{
            a[j] = a[j]%min;
          }
        }
        Arrays.sort(a);
        if(min == a[0]){
          break;
        }else{
          min = a[0];
        }
      }
            
      System.out.println(min);
    }
    catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 49936
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,a,Min=N,sum=0,count=0;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        if(a<0){
            count++;
        }
        Min=min(Min,abs(a));
        sum+=abs(a);
    }
    if(count%2==1){
        sum-=2*Min;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		int n = Integer.parseInt(reader.readLine());
		Deque<Integer> deque = new ArrayDeque<Integer>();
		for (int i = 0; i < n; i++) {
			String line = reader.readLine();
			if(line.charAt(0) == 'i')
				deque.push(Integer.parseInt(line.substring(7)));
			else if(line.charAt(6)=='F')
				deque.removeFirst();
			else if(line.charAt(6)=='L')
				deque.removeLast();
			else
				deque.remove(Integer.parseInt(line.substring(7)));
			/*System.out.println(deque.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		builder.append(deque.poll());
		for(int num2 : deque)
			builder.append(" ").append(num2);
		System.out.println(builder);
	}
}


Measured memory_bytes: 125364
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
vector<int> G[1005];
vector<int> rG[1005];
bool used[1005];
int gr[1005];
int cnt[10000];

void dfs2(int v,int g){
	int su=0;
	for(int i=0;i<G[v].size();i++){
		su^=gr[G[v][i]];
	}
	cnt[g^su]++;
	for(int i=0;i<G[v].size();i++){
		dfs2(G[v][i],su^gr[G[v][i]]^g);
	}
}

int dfs(int v){
	used[v]=true;
	if(G[v].size()==0)return gr[v]=1;
	int su=0;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			su^=dfs(G[v][i]);
		}
	}
	memset(cnt,0,sizeof(cnt));
	cnt[su]++;
	//printf("v=%d %d\n",v,su);
	for(int i=0;i<G[v].size();i++){
		dfs2(G[v][i],su^gr[G[v][i]]);
	}
	int val=0;
	while(cnt[val]>0){
		val++;
	}
	return (gr[v]=val);
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a;
		scanf("%d",&a);
		a--;
		G[a].push_back(i);
		rG[i].push_back(a);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(rG[i].size()==0){
			int md=dfs(i);
			ans^=md;
			//printf("%d %d\n",i,md);
		}
	}
	printf("%s\n",ans==0?"Bob":"Alice");
	return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
long long mod=1000000007;
using namespace std;


int main(){
    long long n,k,i;
    cin>>n>>k;
    n++;
    long long sum=1;
    for(i=k;i<n;i++)
    {
        sum++;
        sum+=(n-i)*i;
        sum%=mod;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3552
# abc173_b.py
# https://atcoder.jp/contests/abc173/tasks/abc173_b
# B - Judge Status Summary /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点
# 問題文
# 高橋君は、プログラミングコンテスト AXC002 に参加しており、問題 A にコードを提出しました。
# この問題には N個のテストケースがあります。
# 各テストケース i(1≤i≤N) について、ジャッジ結果を表す文字列 Siが与えられるので、
# ジャッジ結果が AC, WA, TLE, RE であったものの個数をそれぞれ求めてください。

# 出力形式は、出力欄を参照してください。
# 制約
#     1≤N≤105
# Si は AC, WA, TLE, RE のいずれか

# 入力
# 入力は以下の形式で標準入力から与えられる。

# N
# S1
# ⋮
# SN

# 出力
# AC, WA, TLE, RE のテストケースの個数をそれぞれ C0, C1, C2, C3
# としたとき、以下の形式で出力せよ。

# AC x C0
# WA x C1
# TLE x C2
# RE x C3

# 入力例 1
# 6
# AC
# TLE
# AC
# AC
# WA
# TLE

# 出力例 1
# AC x 3
# WA x 1
# TLE x 2
# RE x 0

# ジャッジ結果が AC であったケースが 3個、WA であったケースが 1 個、
# TLE であったケースが 2 個、RE であったケースが 0個でした。

# 入力例 2
# 10
# AC
# AC
# AC
# AC
# AC
# AC
# AC
# AC
# AC
# AC

# 出力例 2
# AC x 10
# WA x 0
# TLE x 0
# RE x 0

# 解答
def abc173_b(lines):
    labels = ['AC', 'WA', 'TLE', 'RE']
    ns = [0, 0, 0, 0]
    for line in range(1, len(lines)):
        for i, label in enumerate(labels):
            if label == lines[line]:
                ns[i] += 1
    answers = list()
    for i, label in enumerate(labels):
        answers.append(label + ' x ' + str(ns[i]))
    return answers


# 引数を取得
def get_input_lines_1stline_as_n_lines():
    lines = list()
    lines.append(input())
    for _ in range(int(lines[0])):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'AC', 'TLE', 'AC', 'AC', 'WA', 'TLE']
        lines_export = ['AC x 3', 'WA x 1', 'TLE x 2', 'RE x 0']
    elif pattern == 2:
        lines_input = ['10', 'AC', 'AC', 'AC', 'AC', 'AC', 'AC', 'AC', 'AC', 'AC', 'AC']
        lines_export = ['AC x 10', 'WA x 0', 'TLE x 0', 'RE x 0']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines_1stline_as_n_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = abc173_b(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 16188
// AOJ ITP1_10_C Standard Deviation
// 2018.4.28 bal4u
 
#include <stdio.h>
#include <math.h>
 
int s[1002];
 
#define gc() getchar_unlocked()
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc();
    while (c >= '0');
    return n;
}
 
int main()
{
    int n, i, is;
    double m, fs, a;
     
    while (n = in()) {
        is = 0; for (i = 0; i < n; i++) is += s[i] = in();
        m = (double)is/n;
        fs = 0; for (i = 0; i < n; i++) {
            a = s[i]-m;
            fs += a*a;
        }
        printf("%.8lf\n", sqrt(fs/n));
    }
    return 0;
}


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

int main(){
  int k,s;
  cin >> k >> s;
  int counter = 0;

  for(int x = 0; x<=k; x++){
    for(int y = 0; y<=k && y<=(s-x); y++){
      int z;
      z = s-x-y;
      if(0<=z && z<=k){
        counter += 1;
      }
    }
  }
  cout << counter << endl;
}


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

using namespace std;

int main(){
  int H,N;
  cin>>H>>N;
  vector<int>a(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  if(H>sum)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;


/** Problem0229 : Big Hit ! **/
int main()
{
	int b, r, g, c, s, t, ans;;
	while (1) {
		cin >> b >> r >> g >> c >> s >> t;
		if (b==0 && r==0 && g==0 && c==0 && s==0 && t==0)
			break;
		
		ans=100;
		ans += -t*3 + r*3+b*5 + s*3;
		ans += b*15 + r*15 + g*7 + r*3*15 + b*5*15 + c*2;
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N=int(input())
h=[[0,0,0] for i in range(N)]
dp=[[0,0,0] for j in range(N)]
for i in range(N):
    h[i][0],h[i][1],h[i][2]=map(int,input().split())
dp[0][0],dp[0][1],dp[0][2]=h[0][0],h[0][1],h[0][2]
for i in range(1,N):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+h[i][0]
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+h[i][1]
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+h[i][2]

print(max(dp[N-1][0],dp[N-1][1],dp[N-1][2]))

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

int main() {

	int n;

	cin >> n;

	vector<int> a(n);

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

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

	int ans = 0;

	for (int i = 0;i < n;i++) {
		if (i == n - 1) {
			ans += a[i] / 2;
		}

		else {
			ans += a[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i,n)for(int i=0; i<(int)(n); i++)
#define bitrep(tmp, N)for (int tmp=0; tmp < (1<<N);tmp++)
#define all(v) v.begin(), end.bigin()

int INF = 10e9;
using P = pair<int,int>;


int main(){
  int64_t X, Y, cnt=0;
  cin >> X >> Y;
  while(X<=Y){
    cnt++;
    X=X*2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd



def solve(L: int):
    r = 0
    while (2 ** r) <= L:
        r += 1
    r -= 1

    edges = []
    nodes = list(range(1, r+2))
    for s, d in zip(nodes, nodes[1:]):
        edges.append((s, d, 0))
        edges.append((s, d, 2 ** (s - 1)))

    base = 2 ** r
    for n in list(reversed(nodes))[1:]:
        c = 2 ** (n - 1)
        if base <= (L - c):
            edges.append((n, nodes[-1], L - c))
            L -= c
    ret = ['{} {}'.format(r + 1, len(edges))]  + ['{} {} {}'.format(s, d, c) for s, d, c in edges]
    return '\n'.join(ret)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    result = solve(L)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5124
// Problem : B - ∵∴∵
// Contest : AtCoder - AtCoder Beginner Contest 058
// URL : https://atcoder.jp/contests/abc058/tasks/abc058_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string e, o;
	cin >> o >> e;
	int n = e.size() + o.size();
	for(int i = 0; i < n; i ++){
	    if(i&1){
	        cout << e[i/2];
	    }
	    else{
	        cout << o[i/2];
	    }
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=405;
ll dp[N][N],sum[N];
int n,x[N];
int main()
{
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j]=1e15;
		}
	}
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
		dp[i][i]=x[i];
		sum[i]=sum[i-1]+x[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j+i<=n;j++)
		{
			for(int k=j;k<i+j&&k<=n;k++)
			{
				dp[j][i+j]=min(dp[j][i+j],dp[j][k]+dp[k+1][j+i]+sum[i+j]-sum[j-1]);
//				cout<<j<<' '<<i+j<<"="<<dp[j][i+j]<<endl;
			}
		}
	}
	cout<<dp[1][n]-sum[n]<<endl;
	return 0;
}

Measured memory_bytes: 1536
var sum  = function(arr) {
    return arr.reduce(function(prev, current, i, arr) {
        return prev+current;
    });
};

function main(input) {
  	input = input.split("\n");
    const args = input[1].split(' ').map(n =>{
      return parseInt(n, 10);
    });
    const args_sorted = args.sort(
      function(a,b){
        return (a < b ? 1 : -1);
      }
    );
    const odd_numbers = args_sorted.filter((n, i) => {
      if (i % 2 == 0) return n;
    });
    const even_numbers = args_sorted.filter((n, i) => {
      if (i % 2 != 0) return n;
    });
    console.log(sum(odd_numbers) - sum(even_numbers));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int r, g, b; readV(r, g, b);
  writeln((g*10+b)%4 == 0 ? "YES" : "NO");
}


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

using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  vector<pair<int, ll>> bc;
  for (int i = 0; i < m; i++) {
    int b;
    ll c;
    cin >> b >> c;
    bc.push_back({b, c});
  }

  sort(bc.begin(), bc.end(), [](auto &p1, auto &p2) {
    return p1.second > p2.second;
  });

  int i = 0;
  for (auto [b, c] : bc) {
    for (int j = 0; j < b && i < n; j++, i++) {
      a[i] = max(a[i], c);
    }
  }

  cout << accumulate(a.begin(), a.end(), 0ll) << endl;

  return 0;
}


Measured memory_bytes: 6024
# // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2331

#include <vector>
#include <iostream>

using namespace std;

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

	int* hojo = new int[numOfFriends]; // ?????????????????????????????? 
	for (int i = 0; i < numOfFriends; i++) {
		hojo[i] = 0;
	}
	
	// hojo[i] ??????(i+1)?????§???????????¨???????????????????????????????????°????????\??????
	for (int i = 0; i < numOfFriends; i++) {
		int min, max;
		cin >> min;
		min--; // ????????????????????????
		cin >> max;
		max--; // ????????????????????????
		for (int j = min - 1; j <= max - 1 && j < numOfFriends ; j++) {
			hojo[j]++;
		}
	}

	int i = numOfFriends;
	for (; i >= 1; i--) {
		if (hojo[i - 1] >= i) {
			break;
		}
	}

	cout << i << endl;

	delete[] hojo;
}

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

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

    ll x; cin >> x;

    ll rot = x / 11;
    if (x % 11 == 0) {
        cout << 2 * rot << endl;
    } else if (x % 11 <= 6) {
        cout << 2 * rot + 1 << endl;
    } else {
        cout << 2 * rot + 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define s second
#define pb(x) push_back(x)
#define f first
using namespace std;
ll pw(ll a, ll n)
{
    ll ans=1;
    while(n>0)
    {
        if (n%2!=0)
        {
            ans=ans*a;
        }
        a=a*a;
        n=n/2;
    }
    return ans;
}

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

  ll t;
  cin >> t;
  ll n=floor(log2(t));
  ll sum=1;
  if(t==1)
    return cout << 1,0;
  if(t==0)
    return cout << 0,0;
  for(int i=1;i<=n;i++)
  {
      sum+=pow(2,i);
  }
  cout << sum;


return 0;


    }






Measured memory_bytes: 512