akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        H: [i64; N],
    }
    let mut dp = vec![0; N];
    for i in 1..N{
        let mut cost = dp[i-1] + (H[i]-H[i-1]).abs();
        if i>=2{
            cost = min(cost, dp[i-2] + (H[i]-H[i-2]).abs());
        }
        dp[i] = cost;
    }
    println!("{}", dp[N-1]);
}

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


int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (x >= a && a+b >= x) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0; 
}

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

#define SZ(v) ((int)(v).size())
using ll = long long;

int calc_salsa(int u)
{
	int ret(0);
	int p(1);
	while (u > 0)
	{
		int dig = u%3;
		if (dig==1)
			dig = 2;
		else if (dig == 2)
			dig = 1;
		ret += dig * p;
		p *= 3;
		u /= 3;
	}
	return ret;
}

int fast_pow(int a, int b)
{
	int ret(1);
	for (int p(a); b; p *= p, b /= 2)
		if (b%2)
			ret *= p;
	return ret;
}

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int N;
	cin >> N;
	int MAGIC = N/2;

	int nb_tot = fast_pow(3, N);
	vector<int> salsa(nb_tot);
	for (int i(0); i < nb_tot; ++i)
		salsa[i] = calc_salsa(i);
	int pref_sz = fast_pow(3, MAGIC);
	int suff_sz = fast_pow(3, N - MAGIC);
	vector<int> perm_pref(pref_sz);
	vector<int> cur_suf(nb_tot);
	for (int i(0); i < nb_tot; ++i)
		cur_suf[i] = i/pref_sz;
	for(int i(0); i < pref_sz; ++i)
		perm_pref[i] = i;
	int nb_salsa(0);
	vector<int> salsa_faites(nb_tot);

	string danse;
	cin >> danse;

	for (auto c : danse)
	{
		if (c == 'S')
		{
			++nb_salsa;
			for (int i(0); i < pref_sz; ++i)
				perm_pref[i] = salsa[perm_pref[i]];
		}
		else
		{
			for (int i(0); i < pref_sz; ++i)
			{
				perm_pref[i] = (perm_pref[i] + 1)%pref_sz;
				if (!perm_pref[i])
					for (int j(0); j < suff_sz; ++j)
					{
						if (salsa_faites[i + j*pref_sz] % 2 != nb_salsa%2)
							cur_suf[j*pref_sz+i] = salsa[cur_suf[j*pref_sz+i]];
						salsa_faites[i + j * pref_sz] = nb_salsa;
						cur_suf[j * pref_sz + i] = (cur_suf[j*pref_sz+i] + 1)%suff_sz;
					}

			}
		}
	}
	for (int i(0); i < nb_tot; ++i)
	{
		int pref = i % pref_sz;
		if (salsa_faites[i] % 2 != nb_salsa%2)
			cur_suf[i] = salsa[cur_suf[i]];
		cout << pref_sz * cur_suf[i] + perm_pref[pref] << ' ';
	}
	cout << endl;

}


Measured memory_bytes: 10528
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	map<string,int> mp;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	int mx=0;
	for(auto it:mp){
		if(it.second>mx){
			mx=it.second;
		}
	}
	for(auto it: mp){
		if(it.second==mx){
			cout<<it.first<<endl;
		}
	}
	
	return ;
}
 
int main(){
	fastio();

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

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, ans;
  ans = 0;
  cin >> A >> B;
  for(int i=0;i<2;i++){
   if(A <= B){
     ans += B;
     B--;
   }
   else if(A > B){
     ans += A;
     A--;
   }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a = int(input())
l = list(map(int,input().split()))

le,ri = 0,sum(l)
ans = 10**10
for i in range(len(l)-1):
    le += l[i]
    ri -= l[i]
    if ans < min(ans,abs(le-ri)):
        print(ans)
    else:
        ans = min(ans,abs(le-ri))
else:
    print(ans)

Measured memory_bytes: 24824
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n;
struct Point{double x,y;}p[105];
double cross(Point a,Point b){return a.x*b.y-a.y*b.x;}
double getarea()
{
	double res=0;
	for(int i=2;i<=n;i++)res+=cross(p[i-1],p[i])/2;
	res+=cross(p[n],p[1])/2;
	return res;
}
void read(Point &a){a.x=read(),a.y=read();}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)read(p[i]);
	cout<<fixed;cout.precision(1);
	cout<<getarea()<<endl;
}



Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> c(31);
    for(int i=0;i<28;i++){
        int a;cin >> a;
        c[a]++;
    }
    for(int i=1;i<=30;i++){
        if(!c[i]){
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll x,a;cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k,q;
  int i,j;
  
  scanf("%d %d %d",&n,&k,&q);
  int point[n];
  int answer[q];
  for(i=0;i<n;i++){
    point[i] = k-q;
  }
  
  for(i=0;i<q;i++){
    scanf("%d",&answer[i]);
    point[answer[i]-1]++;
  }
  
  for(i=0;i<n;i++){
    if(point[i]<=0){
      printf("No\n");
    }else{
      printf("Yes\n");
    }
  }
  
  return(0);
}
         
  

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

#define int long long 

int to_int(int i, int j, int k);

int h, w;

struct FF
{
  
  struct edge {
    int to, rev;
    bool used;
  };
  
  vector < edge > G[22222];
  bool flag[22222];
  
  int goal;

  void add_edge(int s, int t) {
    G[s].push_back( (edge) { t, G[t].size(), false });
    G[t].push_back( (edge) { s, G[s].size() - 1, true });
  }

  bool dfs(int v) {
    // cout << v << endl;
    if(v == goal) return true;
    flag[v] = true;
  
    for(int i = 0; i < G[v].size(); i++) {
      int u = G[v][i].to, rev = G[v][i].rev;
      bool &used = G[v][i].used;
      //cout << u << " " << used << " " << u / w / 2 << " " << u % (w * 2) / 2 << endl;
      if(!used && !flag[u] && dfs(u)) {
	used = true;
	G[u][rev].used = false;
	return true;
      }
    }
    return false;
  }
  
  int max_flow(int snode) {
    int flow = 0, f = -114514;
    while(f) {
      fill_n(flag, 22222, false);
      f = dfs(snode);
      flow += f;
    }
    
    return (flow);
  }
    
};

main()
{
  
  char mas[105][105];
  int sy, sx;
  
  cin >> h >> w;

  FF flow;
  
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> mas[i][j];
      if(mas[i][j] == 'S' || mas[i][j] == 'o' || mas[i][j] == 'T') {
	flow.add_edge(to_int(i, j, 0), to_int(i, j, 1));
	if(mas[i][j] == 'S') {
	  sy = i, sx = j;
	} else if(mas[i][j] == 'T') {
	  flow.goal = to_int(i, j, 0);
	}
      }
    }  
  }

  bool flag = false;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(mas[i][j] == 'S' || mas[i][j] == 'o' || mas[i][j] == 'T') {
	for(int x = j + 1; x < w; x++) {
	  if(mas[i][x] == 'S' || mas[i][x] == 'o' || mas[i][x] == 'T') {
	    if(mas[i][j] == 'S' && mas[i][x] == 'T' || mas[i][j] == 'T' && mas[i][x] == 'S') flag = true;
	    flow.add_edge(to_int(i, j, 1), to_int(i, x, 0));
	    flow.add_edge(to_int(i, x, 1), to_int(i, j, 0));
	  }
	}
	
	for(int y = i + 1; y < h; y++) {
	  if(mas[y][j] == 'S' || mas[y][j] == 'o' || mas[y][j] == 'T') {
	    if(mas[i][j] == 'S' && mas[y][j] == 'T' || mas[i][j] == 'T' && mas[y][j] == 'S') flag = true;
	    flow.add_edge(to_int(i, j, 1), to_int(y, j, 0));
	    flow.add_edge(to_int(y, j, 1), to_int(i, j, 0));
	  }
	}
      }
    }
  }

  if(flag) cout << -1 << endl;
  else cout << flow.max_flow(to_int(sy, sx, 1)) << endl;
  
  return (0);
}

int to_int(int i, int j, int k)
{
  return (k + 2 * j + w * 2 * i);
}


Measured memory_bytes: 125312
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, m;
    cin >> n >> m;

    vector<int> a(n, 1), b(n);
    b[0] = 1;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        a[x]--;
        a[y]++;
        if (b[x] != 0) b[y] = 1;
        if (a[x] == 0) b[x] = 0;
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        r += b[i];
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>

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

using namespace std;

int main(void)
{
	int t, x;
	cin >> t >> x;
	cout << setprecision(9) << (double)t/x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int dp[105][10005]={};
    int n; cin>>n;
    int W; cin>>W;
    int w[105],v[105];
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[n][W]<<endl;
    
}



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

using namespace std;
#define int long long int
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define loop(i,k,n) for(int i=k;i<n;i++)
#define MOD 1000000007
#define r0 return 0
/*
//gcd in O(log(a))
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
*/
/*
int gcd, x, y;

void extendedEuclid (int a, int b)
{
    if (b==0)
    {
        x=1;
        y=0;
        gcd=a;
        return;
    }
    extendedEuclid(b, a%b);
    int x1=y;
    int y1=x-(a/b)*y;
    x=x1;
    y=y1;
}

int nCr (int n, int r)
{
    int p=1, k=1, modInv;
    if (n-r<r)
        r=n-r;
    if (r!=0)
    {
        while (r)
        {
            p=(p*n)%MOD;
            k*=r;
            n--;
            r--;
        }
        extendedEuclid(k, MOD);
        modInv=(x+MOD)%MOD;
        p=(p*modInv)%MOD;
    }
    else
        p=1;
    return p;
}
*/


int32_t main(void)
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        //int n;
        string a,b;
        cin>>a>>b;
        int n=a.length();
        int m=b.length();
        int dp[n][m]={0};

        for(int i=0;i<n;i++)
        {

            for(int j=0;j<m;j++)
            dp[i][j]=0;

        }
        for(int i=0;i<m;i++)
        {
            if(a[0]==b[i])
                dp[0][i]=1;
            else if(i!=0&&dp[0][i-1]==1)
                dp[0][i]=1;
        }
         for(int i=0;i<n;i++)
        {
            if(a[i]==b[0])
                dp[i][0]=1;
            else if(i!=0&&dp[i-1][0]==1)
                dp[i][0]=1;
        }
        for(int i=1;i<n;i++)
        {
            for(int j=1;j<m;j++)
            {
                if(a[i]==b[j])
                    dp[i][j]=dp[i-1][j-1]+1;
                else
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
        string s;
        int c=1;
       /* for(int i=0;i<n;i++)
        {

            for(int j=0;j<m;j++)
            {
            cout<<dp[i][j]<<" ";
            }

            cout<<endl;
        }*/
        int i=n-1,j=m-1;
        c=0;
        while(i>=0&&j>=0&&c<dp[n-1][m-1])
        {
            if(a[i]==b[j])
            {
                s=a[i]+s;
                i--;
                j--;
                c++;
            }
            else
            {
                if(dp[i][j-1]>dp[i-1][j])
                    j--;
                else
                    i--;
            }
        }
        if(c!=dp[n-1][m-1])
            s=a[0]+s;
        cout<<s;


    }
}



Measured memory_bytes: 70528
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

ll  gcd(ll  a, ll  b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int n, k[105];
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	ll mon = k[0];
	double add;
	for (int i = 1; i < n; ++i) {
		mon = lcm(mon, k[i]);
	}

	for (int i = 0; i < n; ++i) {
		add += mon / k[i];
	}

	cout << setprecision(20) << (double)(mon / add) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<long long> a;
   for(int i = 0;i < n;i++) {
       long long x;
       cin >> x;
       a.push_back(x);
   }
   sort(a.begin(), a.end());
   cout << a[n-1]-a[0] << endl;
   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n){
        if (to_string(i+1).size() % 2 == 1)
            ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
ll mod = 1e9+7;
int prime[100005];
bool b[100005];
int cnt =0 ;
int pri[100000];
int num[100000];
ll up[1000005],inv[1000005],down[1000005];//down就是分子(分母*乘法逆元
void init(){
    for(int i=2;i<=100000;i++){
        if(b[i])
            continue;
        prime[cnt++] = i;
        for(int j=1;j*i<=100000;j++){
            b[i*j]=1;
        }
    }
    up[0]=1;
    for(int i=1;i<=1000000;i++){
        up[i]=up[i-1]*i % mod;
    }
    inv[1]=1;//乘法逆元板纸，其实我也不懂...
    for(int i=2;i<=1000000;i++){
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    }
    down[0]=1;
    for(int i=1;i<=1000000;i++){
        down[i]=down[i-1]*inv[i]%mod;
    }
}
ll getCom(ll x,ll y){//组合数(逃...
    return up[x]*down[y]%mod*down[x-y]%mod;
}
int ind = 0;
int main(){
    ios::sync_with_stdio(false);
    init();
    cin>>n>>m;
    for(int i=0;i<cnt;i++){
        if(m%prime[i]==0){
            pri[ind] = prime[i];
            while (m%prime[i]==0){
                m/=prime[i];
                num[ind]++;
            }
            ind++;
        }
    }
    if(m!=1){
        pri[ind]=m;
        num[ind]=1;
        ind++;
    }
    ll ans = 1;
    for(int i=0;i<ind;i++){
        ans*=getCom(n+num[i]-1,n-1);
        ans%=mod;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 24832
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DAnOrdinaryGame solver = new DAnOrdinaryGame();
        solver.solve(1, in, out);
        out.close();
    }

    static class DAnOrdinaryGame {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int l = s.length();
            if (l % 2 == 0 ^ s.charAt(0) == s.charAt(l - 1)) {
                out.println("Second");
            } else {
                out.println("First");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 25300
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int main(){
    string S;
    cin>>S;
    string s="CF";
    int cnt=0;
    REP(i,SZ(S)){
        if(s[cnt]==S[i])cnt++;
        if(cnt==2){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second


int par[100100];
int rannk[100100];
int cnt = 0;

void init(int n) {
    rep(i, n) {
        par[i] = i;
        rannk[i] = 0;
    }
}

int find(int x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;

    cnt ++;

    if(rannk[x] < rannk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if(rannk[x] == rannk[y]) rannk[x] ++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int M; cin >> M;
  init(N);
  rep(i, M) {
      int x, y, z; cin >> x >> y >> z;
      x --; y --;
      unite(x, y);
  }
  cout << N - cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int CMAX=100;

int main(){
    int c[3][3];
    bool ans=false;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&c[i][j]);
        }
    }
    //i:a_i,j:a_j,k:a_k
    for(int i=0;i<=CMAX;++i){
        for(int j=0;j<=CMAX;++j){
            for(int k=0;k<=CMAX;++k){
                bool flag=true;
                for(int l=0;l<3;++l){
                    int b=c[0][l]-i;
                    if(j+b==c[1][l] && k+b==c[2][l]){
                        continue;
                    }
                    flag &= false;
                }
                if(flag){
                    ans=true;
                    goto end;
                }
            }
        }
    }
end:
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;

    if(s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }


}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    int z=x/d;
    if(z<=k)
    {
        k-=z;
        x%=d;
    }
    else
    {
        x-=k*d;
        k=0;
    }

    if(k==0)
    {
        cout<<x;
    }
    else
    {
        if(k%2==0)
        {
            cout<<abs(x);
            return 0;
        }
        int xx=x-d;
        k--;
        cout<<abs(xx);
    }
    

}


Measured memory_bytes: 3556
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int R;
    read(R);
    cout << fixed << setprecision(3) << 2 * M_PI * R;
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 3784
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int A = s.nextInt();
		int V = s.nextInt();
		int B= s.nextInt();
		int W = s.nextInt();
		double T = s.nextInt();
		
		double D = Math.abs(A-B);
		double sokudosa = V-W;
		if(sokudosa<=0) {
		System.out.println("NO");	
		}
		else {
		   if(D/sokudosa >  T) {System.out.println("NO");}
		   else {System.out.println("YES");}
		}
	}

}


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

int main() {
  int N;
  cin>>N;
  int z=0;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    z+=r-l+1;
  }
  cout<<z<<endl;
   

}


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) {
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    ll count = 0;
    rep(i,n-1){
        if(s.at(i) != s.at(i+1)) count++;
    }

//    rep(i,n) cout << s.at(i) <<endl;
    cout << count +1<<endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

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

  int max = min(a, b);
  int min = 0;
  if (a + b <= n) {
    min = 0;
  } else {
    min = a + b - n;
  }

  cout << max << " " << min << endl;
}

Measured memory_bytes: 256
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;
#define      mxx                 LLONG_MAX
#define      mnn                 LLONG_MIN
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      MP                  make_pair
#define      flash               cout.flush()
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
constexpr ll MOD = 998244353;
constexpr ll mod = 1e9  + 7;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cerr<<a<<endl;
#define bug2(a,b)  cerr<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cerr<<a<<" "<<b<<" "<<c<<endl;
/*----*/
const ll N=2e5+5;
vector<ll> adj[N];
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll modpow(ll a,ll b,ll m){ll ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
ll nsum(ll num){return (num*(num+1))/2;}
void edge (ll u,ll v) {adj[u].PSB(v) ;adj[v].PSB(u);}
/*------------------START---------------------*/


/*-----*/
void solve(){
   ll n,a,b,c,d;
   string s;
   ll ans=mnn;
   cin>>a>>b>>c>>d;
   ans=max(ans,b*d);
   ans=max(ans,a*c);
   ans=max(ans,a*d);
   ans=max(ans,b*c);
   cout<<ans<<endl;




}
/*-----*/
int main(){
   InTheNameOfGod

   ll Test=1;
   //cin>>Test;
   while(Test--){
     solve();
    }
  loser;
}
///////   C O D I N G  I S  L I F E   ///////


Measured memory_bytes: 8344
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	int h,m,s,s1,ti[100001];
	char a,b;
	
	while(1){
	
		cin>>n;
		if(n==0) break;
		
		for(i=0;i<86400;i++) ti[i]=0;
		
		for(i=0;i<n*2;i++){
			cin>>h>>a>>m>>b>>s;
			if(i%2==0) ti[h*3600+m*60+s]++;
			else ti[h*3600+m*60+s]--;
		}
		
		for (i=0;i<86400;i++) {
			if (0<i) ti[i]+=ti[i-1];
		}
		
		int M = -1;
		for (i=0;i<86400;i++) {
			M=max(ti[i],M);
		}
		
		cout<<M<<endl;
	}	
	return 0;
}	
	
	


Measured memory_bytes: 3420
using System;
using System.Linq;

namespace AtCoder112
{
    class Program
    {
        static void Main(string[] args)
        {
            var hoge = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToList(); 
            int n = hoge[0];
            int t = hoge[1];
            int[,] fuge = new int[n,2];
            for(int i=0; i < n; i++)
            {
                var a = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToList();
                fuge[i, 0] = a[0];
                fuge[i, 1] = a[1];

            }

            int cost = 1001;
            int ans = 1001;
            for(int j = 0; j < n; j++)
            {
                if (fuge[j, 1] <= t)
                {

                    cost = fuge[j, 1];
                    if (fuge[j, 0] < ans)  ans = fuge[j, 0];
                                                          
                 
                }
            }

            if (cost != 1001) Console.WriteLine(ans);
            else Console.WriteLine("TLE");
            
            
            
        }
    }
}


Measured memory_bytes: 11220
L = []
for i in range(4):
    a = int(input())
    L.append(a)
    N = sorted(L) #小さい順に並べる
A = (N[len(N) - 1]) + (N[len(N) - 2]) + (N[len(N) - 3]) #リストNの後ろから1番目＋2番目＋3番目

l = []
for i in range(2):
    b = int(input())
    l.append(b)
    M = sorted(l)
B = (M[len(M) - 1])

print( A + B )


Measured memory_bytes: 5596
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;
  v(string) s(H);
  string a(W, '.');
  F0R(i, H) {
    cin >> s[i];
  }
  F0R(i, H) {
    if (s[i] == a) {
      s.erase(s.begin() + i);
      i--; H--;
    }
  }
  F0R(c, W) {
    bool del = true;
    F0R(r, H) {
      if (s[r][c] != '.') {
        del = false;
        break;
      }
    }
    if (del) {
      F0R(r, H) {
        s[r].erase(s[r].begin() + c);
      }
      c--; W--;
    }
  }

  F0R(r, H) {
    cout << s[r] << newl;
  }
}
#endif


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

int main() {
  int n,k;
  int diffA = 0;
  int diffB = 0;
  int kekka = 0;
  
  cin >> n >> k;
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++){
    cin  >> vec.at(i);
  }
  
  for(int i = 0; i < n; i++){
    diffA = vec.at(i);
    diffB = abs(k - vec.at(i));
    
    if(diffA <= diffB) kekka += diffA * 2;
      else kekka += diffB * 2;
  }
  
  cout << kekka;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

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

    ios_base::sync_with_stdio(false);

    long long a, b, c;
    cin >> a >> b >> c;
    long long ab = (c - a - b) * (c - a - b);
    if(c - a - b < 0){
        cout << "No\n";
        return 0;
    }
    if((4 * a * b) < ab){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  string W[N];
  for(int i=0;i<N;i++) cin>>W[i];
  for(int i=1; i<N;i++){
    for(int j=0;j<i;j++){
      if(W[j]==W[i]){
        cout<<"No"<<endl;
        return 0;
      }
    }
    if(W[i-1][W[i-1].length()-1] != W[i][0]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

int main(){
    int h,w;
    cin>>h>>w;
    while(h!=0||w!=0){
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                if(i%2==j%2)cout<<'#';
                else cout<<'.';
            }
            cout<<endl;
        }
        cout<<endl;
        cin>>h>>w;
    }
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    int outlet = 1;
    while(outlet < b){
        outlet--;
        outlet += a;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int n;
int cache[100000][4]={0};
int a[100000]={0},b[100000]={0},c[100000]={0};
int max_hap(int i,int ch)
{
	if(i>n-1)
	return 0;
	if(cache[i][ch]!=0)
	return cache[i][ch];
	if(ch==2)
	{
		int x=a[i]+max_hap(i+1,1);
		int y=c[i]+max_hap(i+1,3);
		cache[i][ch]=x>y?x:y;
		return cache[i][ch];
	}
		else if(ch==1)
	{
		int x=b[i]+max_hap(i+1,2);
		int y=c[i]+max_hap(i+1,3);
		cache[i][ch]=x>y?x:y;
		return cache[i][ch];
	}
		else if(ch==3)
	{
		int x=a[i]+max_hap(i+1,1);
		int y=b[i]+max_hap(i+1,2);
		cache[i][ch]=x>y?x:y;
		return cache[i][ch];
	}
	else if(ch==0)
	{int x=a[i]+max_hap(i+1,1);
		int y=b[i]+max_hap(i+1,2);
		int z=c[i]+max_hap(i+1,3);
		if(x>=y&&x>=z)
		cache[i][ch]=x;
		else if(y>=x&&y>=z)
		cache[i][ch]=y;
		else if(z>=x&&z>=y)
		cache[i][ch]=z;
		return cache[i][ch];
	}
}
int main()
{
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i]>>b[i]>>c[i];
int x= max_hap(0,0);
cout<<x;	
}

Measured memory_bytes: 7680
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll MOD = 1000000007;
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; }

ll com[2020][2020];

int main() {
    com[0][0]=1;
    for(int i=1; i < 2020; ++i){
        for(int j=0; j <= i; ++j){
            com[i][j] += com[i-1][j];
            if(j>0)com[i][j] += com[i-1][j-1];
            com[i][j] %= MOD;
        }
    }
    int N,K;
    cin >> N >> K;
    for(int i=1; i <= K; i++){ // iグループに分ける
        ll cnt = com[K-1][i-1] * com[N-K+1][i] % MOD;
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 30720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    string key = "keyence";
    int n = s.size();
    for (int i = 0; i <= n - 7; i++) {
        if (i == 0) {
            if (s == key) {
                cout << "YES" << endl;
                return 0;
            }
            continue;
        }
        for (int j = 0; j <= n - i; j++) {
            string t;
            for (int k = 0; k < n; k++) {
                if (j <= k && k <= j + i - 1) continue;
                t += s[k];
            }
            if (t == key) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    cin >> a;
    vector<int> countLeft(N, 0), countRight(N, 0);
    countLeft[0] = max(0LL, a[0]); countRight[N - 1] = max(0LL, a[N - 1]);
    for (int i = 1; i < N; i++) {
        if (a[i] > 0) countLeft[i] = countLeft[i - 1] + a[i];
        else countLeft[i] = countLeft[i - 1];
    }
    for (int i = N - 2; i >= 0; i--) {
        if (a[i] > 0) countRight[i] = countRight[i + 1] + a[i];
        else countRight[i] = countRight[i + 1];
    }
    vector<int> sum(N + 1, 0);
    int ans = 0;
    for (int i = 1; i <= N; i++) sum[i] = sum[i - 1] + a[i - 1];
    for (int i = 0; i + K - 1 < N; i++) {
        int temp = 0;
        if (i != 0) temp += countLeft[i - 1];
        if (i + K - 1 != N - 1) temp += countRight[i + K];
        temp += max(0LL, sum[i + K] - sum[i]);
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
package main

// 某DP, 再帰でやったらTLEになる原因がメモ化再帰しか浮かばないんだけどループでやるDPってやったことないので練習のため来ました

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

var n int
var k int
var h []int

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	n, k = nextInt(), nextInt()
	h = nextInts(n)
	dp := make([]int, n+10)
	INF := int(math.Pow(10, 9))
	for i := 0; i < len(dp); i++ {
		dp[i] = INF
	}
	dp[0] = 0
	for i := 1; i < n; i++ {
		// 現在のところから0を下回らない限り-1 ~ -kしたところとの差を集めて計算し最小値を更新していく
		ans := INF
		for j := 1; j <= k; j++ {
			if i >= j {
				ans = min(ans, dp[i-j]+abs(h[i], h[i-j]))
			} else {
				break
			}
		}
		dp[i] = ans
	}
	fmt.Fprintln(out, dp[n-1])
}

func abs(a, b int) int {
	if a < 0 {
		a *= -1
	}
	if b < 0 {
		b *= -1
	}
	ret := a - b
	if ret < 0 {
		return ret * -1
	} else {
		return ret
	}
}

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

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}


Measured memory_bytes: 2816
import math

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]


N, Q = map(int, input().split())
S = "0" + input() + "0"

memo = [0]*(N+1)
flags = [False]*(N+1)
for i in range(1, N+1):
    if S[i] == "A" and S[i+1] == "C":
        memo[i+1] = 1
        flags[i+1] = True
for i in range(2, N+1):
    memo[i] += memo[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    ans = math.floor(memo[r] - memo[l-1])
    if flags[l]:
        ans -= 1
    print(ans)


Measured memory_bytes: 10484
#include <stdio.h>

int main()
{

    int a;
    int b;
    int c;
    int d;
    int e;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    printf("%d\n", 15 - (a + b + c + d + e));

}

Measured memory_bytes: 2128
#include <iostream>
#include <math.h>

using namespace std;

bool isPrimal(const int x)
{
    if(x == 2)
      return true;
    
    if(x < 2 || x % 2 == 0)
      return false;
    
    int i = 3;
    const int xsqrt = int(sqrt(x));
      
    while (i <= xsqrt)
    {
        if(x % i == 0)
          return false;
        i += 2;  
    }
      
    return true;
    
    
}

int main()
{
    
    
    int N; cin >> N;
    int Ans = 0;
    
    for(int i = 0; i < N; ++i)
    {
        int n;
        cin >> n;
        
        if(isPrimal(n))
          ++Ans;
        
        
    }
    
    cout << Ans << endl;
    
    
    return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	string s;cin>>s;

	if(s =="ABC"){
		writeln("ARC");
	}else {
		writeln("ABC");
	}


}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main() {
  int r;
  cin >> r;
  const double p = 3.14159265358979323846;
  cout <<2*r*p<<endl;
}


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

int debug=0;

int N;
long long T[100+10];


long long calc_gcm(long long m, long long n){
    long long tmp;
    
    if(m < n){
        tmp=m;
        m= n;
        n= tmp;
    }

    if(debug){
        cout << "calc_gcm(" << m <<"," <<n <<")" << endl;
    }

    while (m%n !=0 ){
        tmp = n;
        n = m % n;
        m = tmp;
    }

    if(debug) cout << "return=" << n << endl;

    return n;
}

long long calc_lcm(long long m, long long n){
    long long tmp,ans;
    if(debug){
        cout << "calc_lcm(" << m <<"," <<n <<")" << endl;
    }

    if(m < n){
        tmp=m;
        m= n;
        n= tmp;
    }
    tmp = calc_gcm(m,n);
    
    ans = m/ tmp * n;

    if(debug) cout << "return=" << ans << endl;

    return ans;
}


int main(){
    cin >> N;
    for(int i=0;i<N;++i){
        cin >> T[i];
    }
    
    long long lcm,gcm;

    if(N==1){
        lcm=T[0];
    }else{
        gcm = calc_gcm(T[0],T[1]);
        lcm = calc_lcm(T[0],T[1]);

        if(debug){
            cout << "gcm=" << gcm << " ";
            cout << "lcm=" << lcm << endl;
        }
        for(int i =2;i<N;++i){
            gcm = calc_gcm(gcm,T[i]);
            lcm = calc_lcm(lcm,T[i]);

            if(debug){
                cout << i << ":" << "gcm=" << gcm << " ";
                cout << i << ":" << "lcm=" << lcm << endl;
            }
        }

    }
  
    cout << lcm << endl;
    
}

Measured memory_bytes: 256