akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n;
vd v;
ld ans;

int main(){
  cin >> n;
  v = vd(n);
  for(ll i = 0;i < n;i++) cin >> v[i];
  sort(v.begin(),v.end());
  ans = v[0];
  for(ll i = 1;i < n;i++){
    ans = (ans+v[i])/2;
  }
  cout << ans << endl;

}


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

int main(void){
    //入力
    vector<long> A(3);
    for(int i=0;i<3;i++){
        cin>>A.at(i);
    }
    
    //計算
    sort(A.begin(),A.end());
    
    //出力
    cout<<A.at(0)+A.at(1)<<endl;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())
X = abs(X)
if X // D > K:
    result = X - D*K
else:
    n = X//D
    rem_jump = K - n
    p1 = X % D
    p2 = D - p1

    if rem_jump % 2 == 0:
        result = p1
    else:
        result = p2

print(result)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  sort(A,A+N);
  string ans="YES";
  for(int i=0;i<N-1;i++){
    if(A[i]==A[i+1]){
      ans = "NO";
    }
  }
  cout << ans;
}


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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int a, b; cin >> a >> b;
    cout << a * b << '\n';
    
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
	
	while(t--){
		solve();
	}
	
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long int ll;
#define mod 1000000007


void solve()
{
	int n, l;
	cin >> n >> l;

	vector<string> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];

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

	string ans = v[0];
	for (int i = 1; i < n; i++)
		ans += v[i];

	cout << ans;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("1input.txt", "r", stdin);
	freopen("1output.txt", "w", stdout);
#endif

	int t = 1;
	// cin >> t;

	while (t--)
	{
		solve();
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll Q,H,S,D;
  cin >> Q >> H >> S >> D;
  ll N;
  cin >> N;
  ll ans = 0;
  if(N % 2 == 0){
    ll v1 = min(2*S, D);
    ll v2 = min(4*H, 8*Q);
    v1 = min(v1,v2);
    ans = N/2 * v1;
  }else{
    ll v1 = min(2*S, D);
    ll v2 = min(4*H, 8*Q);
    v1 = min(v1,v2);
    ans = N/2 * v1;
    ll v3 = min(S, 2*H);
    v3 = min(v3, Q*4);
    ans += v3;

  }
  print(ans);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	
	long long int beki[40] = {};

	LFOR(i, 0, 39) {
		beki[i] = pow(2, i);
	}

	long long int n;
	long long int now;
	long long int count = 0;

	cin >> n;
	vector<long long int >a(n);
	map<long long int, long long int> mp;

	LFOR(i, 0, n - 1) {
		cin >> a[i];
		if (mp[a[i]] == 0) {
			mp[a[i]] = 1;
		}
		else {
			mp[a[i]]++;
		}
		
	}

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


	LRFOR(i, n - 1, 1) {
		//sort(a.begin(), a.end());
		if (mp[a[i]] > 0) {
			mp[a[i]]--;
			LFOR(j, 1, 39) {
				if (a[i] < beki[j]) {
					now = beki[j] - a[i];
					break;
				}
			}

			vector<long long int >::iterator it1 = lower_bound(a.begin(), a.end(), now);
			vector<long long int >::iterator it2 = upper_bound(a.begin(), a.end(), now);

			if (it2 - it1>0 && i) {
				//cout << pos << " " << it1 - a.begin() << " "<<it2-a.begin()<<" "<<now << endl;
				if (mp[a[it1 - a.begin()]] > 0) {
					count++;
					mp[a[it1 - a.begin()]]--;
				}
				/*a[pos] = 0;
				a[it1 - a.begin()] = 0;
				count++;
				sort(a.begin(), a.end());*/
			}
		}
			

	}

	cout << count << endl;

	/*while (true) {
	if (a[pos] != 0&&pos!=0) {
	LFOR(j, 1, 39) {
	if (a[pos] < beki[j]) {
	now = beki[j] - a[pos];
	break;
	}
	}
	if (now == 0) {
	continue;
	}

	vector<long long int >::iterator it1 = lower_bound(a.begin(), a.end(), now);
	vector<long long int >::iterator it2 = upper_bound(a.begin(), a.end(), now);

	if (it2 - it1>0) {
	//cout << pos << " " << it1 - a.begin() << " "<<it2-a.begin()<<" "<<now << endl;
	if (mp[a[it1 - a.begin()]] > 0) {
	count++;
	mp[a[it1 - a.begin()]]--;
	}
	a[pos] = 0;
	a[it1 - a.begin()] = 0;
	count++;
	sort(a.begin(), a.end());
	}
	else {
	pos--;
	}
	}
	else {
	break;
	}
	}*/

	return 0;
}

Measured memory_bytes: 14336
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var a = Array.fill(3)(sc.nextInt())
  var k = sc.nextInt()
  for (i <- 0 until k){
    if (a(0) >= a(1)){
      a(1)*=2
    }else if(a(1) >= a(2)){
      a(2)*=2
    }else{
      a(2)*=2
    }
  }
  println(if(a(0)<a(1) & a(1) < a(2)) "Yes" else "No")
}


Measured memory_bytes: 55440
M,D=map(int,input().split())
if D<21:
        print('0')
else:
        ans=0
        for i in range(22,D+1):
                d10=int(str(i)[0])
                d1=int(str(i)[1])
                if d10<2 or d1<2:
                        pass
                else:
                        if d10*d1<=M:
                                ans+=1
        print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200005;
int l[N],r[N],A[N],B[N],sl[N],sr[N],i,j,k,n,m,d,an;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

int main()
{
	n=read();
	for (i=1;i<=n;++i) B[A[i]=read()]=i;
	A[n+1]=n+1;
	for (i=2;i<=n;++i)
		if (A[i-1]<A[i])
			l[i]=i-1;
		else
		{
			for (j=l[i-1];A[j]>A[i];--j);
			l[i]=j;
		}
	for (r[n]=n+1,i=n-1;i;--i)
		if (A[i]<A[i+1])
			r[i]=i+1;
		else
		{
			for (j=r[i+1];A[i]>A[j];++j);
			r[i]=j;
		}
	for (i=1;i<=n;++i)
	{
		sl[i]=1;
		if (B[i-1]<B[i])
			sl[i]+=sl[i-1];
	}
	for (i=n;i;--i)
	{
		sr[i]=1;
		if (B[i]<B[i+1])
			sr[i]+=sr[i+1];
	}
	for (i=1;i<=n;++i)
		sl[i]=i-sl[i]+1,
		sr[i]=i+sr[i]-1;
	//for (i=1;i<=n;++i) printf("%d %d %d O\n",i,sl[i],sr[i]);
	an=min(n-sr[1],sl[n]-1);
	//printf("%d\n",an);
	for (i=1;i<n;++i)
		if (B[i]<B[i+1])
			an=min(an,sl[i]-1+n-sr[i+1]);
		else
			an=min(an,min(sl[i]-1+n-i,n-sr[i+1]+i));
	printf("%d\n",an);
	return 0;
}

Measured memory_bytes: 6272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    const long mod = 998244353;
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var D = ReadLine().Split().Select(int.Parse).ToArray();

        var d = new int[N];
        for (int i = 0; i < N; i++)
        {
            d[D[i]]++;
        }
        d[0] = d[0] != 1 ? 0 : d[0];
        d[0] = D[0] != 0 ? 0 : d[0];
        var m = D.Max();
        var ans = 1L;
        for (int i = 0; i < m; i++)
        {
            ans *= ModPow(d[i], d[i + 1], mod);
            ans %= mod;
        }
        WriteLine(ans);
    }

    public static long ModPow(long x, long n, long m)
    {
        var res = 1L;
        while (n != 0)
        {
            if ((n & 1) == 1) res = res * x % m;
            x = x * x % m;
            n >>= 1;
        }
        return res;
    }
}

Measured memory_bytes: 19680
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<int, int> p;
typedef vector <int> VI;
typedef vector <string> VS;

vector <int> his;

int main(){

	int n,m;
	cin >> n;
	cin >> m;
	
	set <int> ans;
	ans.insert(1);	
	VI ballsnum(n+1,1);
	
	for(int i = 0; i < m; i++){
		int from, to;
		cin >> from;
		cin >> to;

		auto it = ans.find(from);

		if(it != ans.end()){
			if(ballsnum[from] == 1){
				ans.erase(it);
			}
			ans.insert(to);
		}
				
		ballsnum[from]--;
		ballsnum[to]++;		
	}	

	cout << ans.size() << endl;
	return 0;	
}


Measured memory_bytes: 5376
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			string s = cin.Next();
			string t = cin.Next();

			var sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.Append(s[i]);
				sb.Append(t[i]);
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}

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

  vector<int> v;
  int ref = 6;
  while(SZ(v)<n){
    if(isprime(ref)){
      v.PB(ref);
    }

    ref += 5;
  }

  FOR(i,0,n-1){
    cout << v[i] << " ";
  }
  cout << endl;
}



Measured memory_bytes: 256
s = input()
k = int(input())
n = len(s)

a = []
for i in range(n):
    a.append(ord(s[i])-ord('a'))

for i in range(n):
    need = (26 - a[i])%26
    if(k>=need):
        a[i]=0
        k-=need


k %= 26

for ii in range(n):
    i = n-1-ii
    rem = 25 - a[i]
    if(rem<=k):
        a[i]+=rem
        k-=rem
    else:
        a[i]+=k
        k=0
        
        break
ans = [' ' for i in range(n)]
for i in range(n):        
    ans[i] = chr(a[i]+ord('a'))
print(''.join(map(str,ans)))







Measured memory_bytes: 53100
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void){
    int N, count=0;
    double result;
    scanf("%d", &N);

    for(int i = 1; i <= N; i++){
        if(i % 2 == 1)
            count ++;
    }

    result = (double)count / N;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>(0)?(a):-(a))
int main(){
  char a[12];
  scanf("%s",a);
  int l=strlen(a);
  int ans=999,num,i;
  for(i=0;i<l-2;i++){
    num=0;
    num+=((int)a[i]-48)*100;
    num+=((int)a[i+1]-48)*10;
    num+=(int)a[i+2]-48;
    ans=min(ans,abs(753-num));
  }
  printf("%d",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
//#define n        (int)s.size()
#include <bits/stdc++.h>
using namespace std;
string s, q, x, z, w, y;
int n;
int main()
{
	cin >> q;
	n = (int)q.size();
	for (int i = n - 1; i >= 0; i--)
	{
		s += q[i];
	}
	//cout<<q<<" "<<s<<"\n";
	for (int i = 0; i <= ((n - 1) / 2) - 1; i++)
	{
		w += q[i];
	}
	for (int i = ((n - 1) / 2) - 1; i >= 0; i--)
	{
		z += q[i];
	}
	 //cout<<w<<" "<<z<<"\n";
	for (int j = ((n + 3) / 2) - 1; j<n; j++)
	{
		x += q[j];
	}
	for (int j = n - 1; j >= ((n + 3) / 2) - 1; j--)
	{
		y += q[j];

	}
	//cout<<x<<" "<<y;
	if (q == s&&z == w&&x == y)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


Measured memory_bytes: 256
import math
mod = 10 ** 9 + 7
N = int(input())
if N == 1:
  print(1)
  quit()

prime = []
def is_prime(n):#素数判定
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True  

for i in range(1, 1001):
  if is_prime(i):
    prime.append(i)
#print(prime)
x = len(prime)  
  
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = [0] * x
#print(factorization(24))#[[2, 3], [3, 1]]
for i in range(2, N + 1):
  now = factorization(i)
  for j in range(len(now)):
    index = prime.index(now[j][0])
    ans[index] += now[j][1]
  
answer = 1  
for i in range(x):
  if ans[i] != 0:
    answer *= (ans[i] + 1) 
    answer = answer % mod
#print(ans)
print(answer % mod)    
    
    
    
  
  

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int k,x;
	cin >> k >> x;
	for(int i=x-k+1;i<=k+x-1;i++)
		cout << i << (i==k+x-1 ? "" : " ");
	cout << endl;




}

Measured memory_bytes: 256
import sys

n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize]*n
dp[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))   
print(dp[n-1])

Measured memory_bytes: 52448
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int A[111];

int main(void){
    int N, M;
    cin >> N >> M;
    int sum=0;
    for(int i=0; i<N; ++i){
        cin >> A[i];
        sum += A[i];
    }
    sort(A, A+N, greater<>());
    if(A[M-1]*M*4>=sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int abcde[5],dist;
	for (int i = 0; i < 5; ++i) {
		cin >> abcde[i];
	}
	cin >> dist;
	if (abcde[4] - abcde[0] > dist) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}


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

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

    int n;
    cin >> n;
    
    unordered_map<int, int> mp;
    REP(i, n){
        int a;
        cin >> a;
        mp[a + 1]++;
        mp[a]++;
        mp[a - 1]++;
    }

    int ma = -1e9;
    for(auto x : mp) ma = max(ma, x.second);
    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 4260
n = str(input())

length = len(n)
flg = 0
for num in range(length):
    if (num+1)%2!=0:
        if n[num] == 'R' or n[num] == 'U' or n[num] == 'D':
            flg = 1
        else:
            flg = 0
            break
    else:
        if n[num] == 'L' or n[num] == 'U' or n[num] == 'D':
            flg = 1
        else:
            flg = 0
            break
if flg == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include<cmath>
#include<string>
#include <algorithm>
#include <stack> 
using namespace std; 
string s1,s2;
stack<int> sp;
int main(int argc, char** argv) {
   s2.push_back('S');
   s2.push_back('T');
   cin>>s1;
   int a;
   int b;
   int p=0;
    
   sp.push(p);
   p++;
   while(p<s1.size())
   {
    if(s1[p]=='T'&&sp.size()!=0&&s1[sp.top()]=='S')
    { sp.pop();p++;	
	  
	}
	else
	{sp.push(p);
	 p++;
	}
    
   }
   cout<<sp.size()<<endl;
	return 0;
}

Measured memory_bytes: 1280
using System;
namespace abc
{
    class program
    {
        static void Main()
        {
            string [] c;
            int x, y, z;
            c = Console.ReadLine().Split();
            x = int.Parse(c[0]);
            y = int.Parse(c[1]);
            while(x != 0 || y != 0)
            {
                if(x > y)
                {
                    z = x;
                    x = y;
                    y = z;
                }
                Console.WriteLine("{0} {1}", x, y);
                c = Console.ReadLine().Split();
                x = int.Parse(c[0]);
                y = int.Parse(c[1]);
            }
        }
    }
}


Measured memory_bytes: 13872
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)				(x).begin(),(x).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(ll)1e18
#define EPS					(double)1e-9
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/(n)))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/(n))*(n))	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int H, W, N;
	cin >> H >> W >> N;
	
	int ans;
	if (H < W) {
		ans = Ceil(N, W);
	} else {
		ans = Ceil(N, H);
	}

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



Measured memory_bytes: 256
from heapq import heappush, heappop
INF = 10 ** 10

direct = ((0, -1), (0, 1), (-1, 0), (1, 0))

def dist(fr, to, mp):
  que = []
  heappush(que, (0, fr))
  visited = [[False] * len(mp[0]) for _ in range(len(mp))]
  visited[fr[1]][fr[0]] = True
  while que:
    d, point = heappop(que)
    x, y = point
    for dx, dy in direct:
      nx, ny = x + dx, y + dy
      if (nx, ny) == to:
        return d + 1
      if not visited[ny][nx] and mp[ny][nx] != "x":
        visited[ny][nx] = True
        heappush(que, (d + 1, (nx, ny)))
  else:
    return -1

def my_hash(rest):
  return sum([10 ** i for i in rest])

def shortest(fr, rest, edges, dp):
  if rest == set():
    return 0
  if my_hash(rest) in dp[fr]:
    return dp[fr][my_hash(rest)]
  ret = INF
  for d, to in edges[fr]:
    if to in rest:
      score = d + shortest(to, rest - {to}, edges, dp)
      if score < ret:
        ret = score
  dp[fr][my_hash(rest)] = ret
  return ret

def main():
  while True:
    w, h = map(int, input().split())
    if w == 0:
      break
    mp = ["x" + input() + "x" for _ in range(h)]
    mp.insert(0, "x" * (w + 2))
    mp.append("x" * (w + 2))
    
    stains = []
    for y in range(1, h + 1):
      for x in range(1, w + 1):
        if mp[y][x] == "*":
          stains.append((x, y))
        elif mp[y][x] == "o":
          start = len(stains)
          stains.append((x, y))
    
    stain_num = len(stains)
    edges = [[] for _ in range(stain_num)]
    miss_flag = False
    for i in range(stain_num):
      for j in range(i + 1, stain_num):
        fr = stains[i]
        to = stains[j]
        d = dist(fr, to, mp)
        if d == -1:
          miss_flag = True
        edges[i].append((d, j))
        edges[j].append((d, i))
    if miss_flag:
      print(-1)
      continue

    dp = [{} for _ in range(stain_num)]
    print(shortest(start, {i for i in range(stain_num) if i != start}, edges, dp))

main()


Measured memory_bytes: 5900
a,b,m =  list(map(int, input().split()))

a_price =  list(map(int, input().split()))
b_price =  list(map(int, input().split()))

waribiki = [list(map(int, input().split())) for _ in range(m)]

ans = min(a_price) + min(b_price)

for i in waribiki:
    temp = a_price[i[0]-1] + b_price[i[1]-1] - i[2]
    if temp < ans:
        ans = temp

print(ans)

Measured memory_bytes: 38492
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> participant(N, K);
    REP(i, Q) {
        int A;
        cin >> A;
        participant.at(A-1) += 1;
    }
    REP(i, N) {
        participant.at(i) -= Q;
    }
    REP(i, N) {
        if(participant.at(i) <= 0) {
            cout << "No" << endl;
        }else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

	// 入力
	int n, m; cin >> n >> m;
	vector<int> p(m), y(m);
	for (int i = 0; i < m; i++) cin >> p[i] >> y[i], p[i]--;

	vector<vector<int> > vals(n);
	for (int i = 0; i < m; i++) vals[p[i]].push_back(y[i]);

	// 各pの値に対して
	for (int v = 0; v < n; v++)
	{
		sort(vals[v].begin(), vals[v].end());

		// 重複を消去
		vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
	}

	for (int i = 0; i < m; i++)
	{
		int v = p[i];
		printf("%06d", v + 1);

		int id = lower_bound(vals[v].begin(), vals[v].end(), y[i]) - vals[v].begin();
		printf("%06d\n", id + 1);
	}
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int n;
int arr[N];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll x;
cin>>x;
ll ans=0;
ll cnt=1;
if(x%2)
cout<<0;
else{
ll y=0;
x/=2;
while(x)
{


	ans+=x/5;
   x/=5;


}
cout<<ans;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define ll long long
//10:50
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,t,x,y,p=0,x1=0,y1=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t>>x>>y;
        if(t-p-abs(x-x1)-abs(y-y1)<0 || (t-p-abs(x-x1)-abs(y-y1))%2){
            cout<<"No";
            return 0;
        }
        p=t;x1=x;y1=y;
    }
    cout<<"Yes";
    return 0;
}


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

int main()
{
    int h, w, n, grids[100][100]{};
    scanf("%d%d%d", &h, &w, &n);
    int now_h{}, now_w{};
    for (int i = 1; i <= n; i++)
    {
        int a;
        scanf("%d", &a);
        for (int j = 0; j < a; j++)
        {
            grids[now_h][now_w] = i;
            if ((now_w == w - 1 && now_h % 2 == 0)
                || (now_w == 0 && now_h % 2 == 1)) now_h++;
            else if (now_h % 2) now_w--;
            else now_w++;
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (j) printf(" ");
            printf("%d", grids[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

ll calc(const vector<ll>& sumx, const vector<ll>& sumy, int n) {
  ll ret = 0;
  for(int d=0; d<n; d++) {
    // skip d-th tree at first
    ll now = 0;
    int cnt = n-d;
    int xpos = d+cnt/2;
    int ypos = (cnt-1)/2;
    now += (sumx[xpos] - sumx[d])*2;
    now += sumy[ypos]*2;
    if (cnt%2 == 0) {
      now += sumy[ypos+1] - sumy[ypos];
    } else {
      now += sumx[xpos+1] - sumx[xpos];
    }
    chmax(ret, now);
  }
  return ret;
}

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

  int L, n; cin >> L >> n;
  vector<ll> x(n); rep(i, n) cin >> x[i];
  vector<ll> y(n);
  rep(i, n) {
    y[i] = L - x[n-1-i];
  }
  vector<ll> sumx(n+1), sumy(n+1);
  rep(i, n) {
    sumx[i+1] = sumx[i] + x[i];
    sumy[i+1] = sumy[i] + y[i];
  }
  cout << max(calc(sumx, sumy, n), calc(sumy, sumx, n)) << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL N = 1e5;
vector<pair<LL, LL>> adj[(LL)1e5 + 1];
vector<bool> visited((LL)1e5 + 1, false);
vector<int> color((LL)1e5 + 1, -1);
void dfs(LL s, LL col)
{
    if (!visited[s])
    {
        visited[s] = true;
        color[s] = col;
        for (auto x : adj[s])
        {
            if (x.second & 1)
            {
                dfs(x.first, !col);
            }
            else
            {
                dfs(x.first, col);
            }
        }
    }
}

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, M, tc;
    cin >> n;
    for (i = 1; i <= n - 1; i++)
    {
        cin >> j >> k >> t;
        adj[j].pb({k, t});
        adj[k].pb({j, t});
    }

    dfs(1, 0);
    for(i=1;i<=n;i++)
    {
        cout<<color[i]<<endl;
    }

    return 0;
}


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

ll solve() {
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<string> S(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> S[i];
    }
    vector<int> X1(Q), Y1(Q), X2(Q), Y2(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
        X1[i]--, Y1[i]--, X2[i]--, Y2[i]--;
    }
    vector<vector<ll>> c(N+1, vector<ll>(M+1));
    for ( int n = 0; n < N; n++ ) {
        for ( int m = 0; m < M; m++ ) {
            if ( S[n][m] == '1' ) c[n+1][m+1] = 1;
        }
    }
    for ( int n = 0; n <= N; n++ ) {
        for ( int m = 0; m < M; m++ ) {
            c[n][m+1] += c[n][m];
        }
    }
    for ( int n = 0; n < N; n++ ) {
        for ( int m = 0; m <= M; m++ ) {
            c[n+1][m] += c[n][m];
        }
    }
    vector<vector<ll>> a(2*N, vector<ll>(2*M));
    for ( int n = 0; n < N; n++ ) {
        for ( int m = 0; m < M-1; m++ ) {
            if ( S[n][m] == '1' && S[n][m+1] == '1' ) a[2*n+1][2*m+2] = 1;
        }
    }
    for ( int n = 0; n < N-1; n++ ) {
        for ( int m = 0; m < M; m++ ) {
            if ( S[n][m] == '1' && S[n+1][m] == '1' ) a[2*n+2][2*m+1] = 1;
        }
    }
    for ( int n = 0; n < 2*N; n++ ) {
        for ( int m = 0; m < 2*M-1; m++ ) {
            a[n][m+1] += a[n][m];
        }
    }
    for ( int n = 0; n < 2*N-1; n++ ) {
        for ( int m = 0; m < 2*M; m++ ) {
            a[n+1][m] += a[n][m];
        }
    }
    for ( int q = 0; q < Q; q++ ) {
        ll x1 = 2*X1[q], y1 = 2*Y1[q];
        ll x2 = 2*X2[q]+1, y2 =2*Y2[q]+1;
        ll j = a[x2][y2] - a[x2][y1] - a[x1][y2] + a[x1][y1];
        ll b = c[X2[q]+1][Y2[q]+1] - c[X2[q]+1][Y1[q]] - c[X1[q]][Y2[q]+1] + c[X1[q]][Y1[q]];
        cout << b - j << "\n";
    }
    return 0;
}

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

Measured memory_bytes: 165632
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n; cin >> n;
  vector<int> x(n), y(n);
  map<pii, int> mp;
  if (n == 1) {print(1); return 0;}

  rep(i, n) {
    cin >> x[i] >> y[i];
    ++mp[make_pair(x[i], y[i])];
  }

  int ans = -1;

  rep(i, n) {
    rep(j, n) {
      if (i == j) continue;
      int cnt = 0;
      int dx = x[i] - x[j], dy = y[i] - y[j];
      rep(k, n) {
        if (mp[make_pair(x[k] - dx, y[k] - dy)] != 0) ++cnt;
      }
      chmax(ans, cnt);
    }
  }

  print(n - ans);

  return 0;
}

Measured memory_bytes: 4096
#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>;
#define PI 3.14159265359
const int INF = 1001001001;
const int MOD = 1000000007;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3580
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        s: chars,
        t: chars,
    }
    let n = s.len();
    let m = t.len();
    let mut dp = vec![vec![0; m + 1]; n + 1];
    for i in 0 .. n {
        for j in 0 .. m + 1 {
            dp[i + 1][j] = dp[i][j];
            if j > 0 {
                let u = if s[i] == t[j - 1] { 1 } else { 0 };
                dp[i + 1][j] = max(dp[i + 1][j],
                                   max(dp[i][j - 1] + u, dp[i + 1][j - 1]));
            }
        }
    }
    let mut ans = Vec::new();
    let (mut x, mut y, mut cur) = (n, m, dp[n][m]);
    while cur > 0 {
        assert_eq!(cur, dp[x][y]);
        if dp[x - 1][y - 1] + 1 == dp[x][y] && s[x - 1] == t[y - 1] {
            ans.push(s[x - 1]);
            x -= 1;
            y -= 1;
            cur -= 1;
            continue;
        }
        if dp[x - 1][y] == dp[x][y] {
            x -= 1;
            continue;
        }
        if dp[x][y - 1] == dp[x][y] {
            y -= 1;
            continue;
        }
        x -= 1;
        y -= 1;
    }
    ans.reverse();
    puts!("{}\n", ans.into_iter().collect::<String>());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main() {
  int N,T,ans = 1001;
  cin >> N >> T;
  for(int i=0; i<N; i++){
    int c,t;
    cin >> c >> t;
    if(t<=T){
      ans = min(ans,c);
    }
  }
  if(ans == 1001){
    cout << "TLE" << endl;
    return 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  vector<int> a(5);
  rep(i,5) cin >> a[i];
  int ans=0;
  rep(i,5){
    if(a[i]==0) ans=i+1;
  }
  cout << ans << endl;
}

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

int main() {
  int q;
  cin >> q;
  REP(k, q) {
    int m, n;
    cin >> m >> n;
    int cnt = 0;
    auto f = [](int x, int y) { return x * x + y * y; };
    REP(i, 2 * 200 + 1) REP(j, 2 * 200 + 1) {
      int x = i - 200;
      int y = j - 200;
      if (f(x, y) <= 0 || 20000 < f(x, y)) continue;
      if (abs(x * m + y * n) % f(x, y) == 0 && abs(x * n - y * m) % f(x, y) == 0) cnt++;
    }
    cout << ((cnt == 8) ? 'P' : 'C') << endl;
  }
}



Measured memory_bytes: 3044
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<limits>
#include<math.h>

using namespace std;

int main(){
    int n, h[100000]; cin >> n;

    for(int i=0; i<n; ++i) cin >> h[i];

    for(int i=n-2; i>=0; --i){
        if(h[i] > h[i+1]){
            --h[i];
            if(h[i] > h[i+1]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e5;
const long inf=1e9;
int main(){
	int N; long K; cin>>N>>K;
	int A[N];
	rep(i,0,N) cin>>A[i];
	if(K * K <= 2 * N){
		rep(i,0,K){
            int B[N+1] = {};
			rep(j,0,N){
				B[max(j - A[j], 0)]++;
				B[min(j + A[j] + 1, N)]--;
			}rep(j,0,N){
				A[j] = B[j];
				B[j+1] += B[j];
			}
		}print(A,,N);
	}else{
		rep(i,0,N) cout<<(i ? " ":"")<<N;
		cout<<endl;
	}
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 1;
//#define int long long
const ll INF = 1e18;

/*
task: https://atcoder.jp/contests/cf16-tournament-round3-open/tasks/asaporo_d
*/

struct sw{
    vector<ll> l, r;
    ll rmx;
    
    sw(){
        rmx = 0;
    }
    
    void push_back(ll x){
        r.push_back(x);
        rmx = max(rmx, x);
    }
    
    void pop_front(){
        if(l.empty()){
            for(ll mn = 0; !r.empty();){
                mn = max(mn, r.back());
                l.push_back(mn);
                r.pop_back();
            }
            rmx = 0;
        }
        l.pop_back();
    }
    
    ll get_max(){
        ll res = rmx;
        if(!l.empty()) res = max(res, l.back());
        return res;
    }
};

void solve2(){
  int n, m, k;
  cin >> n >> m >> k;

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

  //vector<vector<ll>> val(n, vector<ll> (k, 0));
  //vector<set<pair<ll, int>>> dp(k, set<pair<ll, int>> ());
  vector<sw> dp(k, sw());


  ll ans = 0LL;
  for (int i = 0; i < n; i++){
    //val[i][0] = a[i];
    for (int j = min(i+1, k) - 1; j > -1; j--){
      ll x = 0LL;
      if (j > 0)
        x = dp[j-1].get_max();

        //cerr << i << ' ' << j << ' ' << x<< '\n';
      //val[i][j] = x + (ll)(j + 1) * a[i];
      x += (ll)(j + 1) * a[i];
      if (j == k-1) ans = max(ans, x);
      dp[j].push_back(x);
      if (i - m - j > -1)
        dp[j].pop_front();
    }
  }

  //ll ans = 0LL;
  //for (int i = 0; i < n; i++) ans = max(ans, val[i][k-1]);

  cout << ans << '\n';
}


signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

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

    solve2();

    return 0;
}


Measured memory_bytes: 428748
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int a, b, c, i, sum;
	scanf("%d %d %d", &a, &b, &c);
	for (i = a, sum = 0; i <= b && i <= c; i++) {
		if (c % i == 0) sum++;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>>s(m);
    for(ll i=0;i<m;i++){
        ll k;
        cin >> k;
        for(ll j=0;j<k;j++){
            ll x;
            cin >> x;
            s[i].push_back(x-1);
        }
    }
    vector<ll>p(m);
    for(ll i=0;i<m;i++){
        cin >> p[i];
    }
    ll ans=0;
    for(ll i=0;i<(1<<n);i++){
        bool judge=true;
        for(ll j=0;j<m;j++){
            ll lamp=0;
            for(ll id:s[j]){
                if((i >> id) & 1){
                    lamp++;
                }
            }
            lamp%=2;
            if(lamp!=p[j]){
                judge=false;
            }
        }
        if(judge) ans++;
    }
    cout << ans << endl;
}

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

public class Main {
  private static boolean solve(int r, int g, int b) {
    return (10 * g + b) % 4 == 0;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int r = reader.nextInt();
    int g = reader.nextInt();
    int b = reader.nextInt();
    out.println(solve(r, g, b) ? "YES" : "NO");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 

int main()
{
    string S; cin >> S;
    vi f(26,0);
    rep(i,S.size()) f[S[i]-'a']=1;
    rep(i,f.size()) {
        if (!f[i]) {
            cout << S + (char)('a'+i) << endl;
            return 0;
        }
    }
    for (int i = 24; i >= 0; i--) {
        int ch = 256;
        for (int j = i+1; j < 26; j++) {
            if (S[i] < S[j]) {
                chmin(ch, (int)S[j]);
            }
        }
        if (ch != 256) {
            S[i] = ch;
            cout << S.substr(0, i+1) << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[3];


int main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;

}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;

    for (int i = 0; i < N; i++) {
        cout << S[i] << T[i];
    }
}

Measured memory_bytes: 256