akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m,s;cin >> n >>m >>s;if(s>=5010)s=5009;
    vvpl g(n*5010);
    rep(i,m){
        ll u,v,a,b;cin >> u >> v >>a >>b;u--;v--;
        rep(j,5010){
            if(j-a>=0){
                g[u*5010+j].pb({v*5010+j-a,b});
                g[v*5010+j].pb({u*5010+j-a,b});
            }
        }
    }
    rep(i,n){
        ll c,d;cin >> c >>d;
        rep(j,5010){
            if(j+c<5010)g[i*5010+j].pb({i*5010+j+c,d});
        }
    }
    vl d(n*5010,INF/10);
    pqueue(pl) que;
    que.push({0,s});
    d[s]=0;
    //ll cnt=0;
    while(!que.empty()){
        pl p=que.top();
        que.pop();
        ll v=p.se;
        if(d[v]<p.fi)continue;
        rep(i,g[v].size()){
            pl ed=g[v][i];
            if(d[ed.fi]>d[v]+ed.se){
                d[ed.fi]=d[v]+ed.se;
                que.push({d[ed.fi],ed.fi});
            }
        }
        //if(cnt<10){
            //rep(i,10)cout << d[i] <<" "<<d[i+5010] <<" "<< d[i+10020]<<endl;
            //cout <<endl;
        //}
        //cnt++;
    }
    rep(i,n-1){
        ll ans=INF;
        rep(j,5010){
            chmin(ans,d[(i+1)*5010+j]);
        }
        cout <<ans <<endl;
    }
}

Measured memory_bytes: 44364
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int s = S.size();
  int t = T.size();
  
  int dp[s+1][t+1];
  for(int i=0; i<s+1; i++){
    for(int j=0; j<t+1; j++){
      dp[i][j] = 0;
    }
  }
  
  for(int i=0; i<s; i++){
    for(int j=0; j<t; j++){
      if(S[i] == T[j]){
        dp[i+1][j+1] = dp[i][j] + 1;
      }
      else{
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }
  
  /*for(int i=0; i<s+1; i++){
    for(int j=0; j<t+1; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  
  int I = s;
  int J = t;
  stack<char> V;
  while(true){
    if(dp[I][J] == 0){
      break;
    }
    if(dp[I][J] == dp[I-1][J]){
      I--;
      continue;
    }
    if(dp[I][J] == dp[I][J-1]){
      J--;
      continue;
    }
    V.push(S[I-1]);
    I--;
    J--;
  }
  
  if(V.size() == 0){
    cout << "";
  }
  else{
    while(V.size()){
      cout << V.top();
      V.pop();
    }
  }
  cout << endl;
    
   
  
  
}




Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    // #ifndef ONLINE_JUDGE
	// 	freopen("test", "r", stdin);
	// #endif
    fastio;
    
    int N;
    cin >> N;
    vi arr(N, 0);

    int boss = 0;
    repA(i, 1, N-1){
        cin >> boss;
        arr[boss - 1]++;
    }

    rep(i, N){
        cout << arr[i] << "\n";
    }
    


    return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,d;
	scanf("%d%d",&m,&d);
	int sum=0;
	for(int i=1;i<=m;i++){
		for(int j=22;j<=d;j++){
			int d10=j/10;
			int d1=j%10;
			if(d1*d10==i && d1>=2 && d10>=2){
			    sum++;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i;
  int c;
  char prime[100000];
  int n;

  prime[0] = 0;
  prime[1] = 0;
  prime[2] = 1;

  for(i=3;i<100000;i+=2)prime[i] = 1;
  for(i=4;i<100000;i+=2)prime[i] = 0;

  c = 3;
  while(c<400){
    for(i=c+2;i<100000;i+=2){
      if(i%c==0)prime[i] = 0;
    }
    while(!prime[++c]);
  }

  while(scanf("%d",&n)!=EOF){
    c=0;
    while(!prime[n+(--c)]);
    printf("%d ",n+c);
    c=0;
    while(!prime[n+(++c)]);
    printf("%d\n",n+c);
  }

  return 0;
}

Measured memory_bytes: 0
i[100012], d[100012],s,w,n,a,x,y;
main()
{
  for(w=scanf("%d",&n);a<n;a++)
      scanf("%d%d",&x,&y),i[x]++,d[y]++;
  for(a=2;a<=n+1;a++)
    {
      w+=i[a];
      if(w>=a)s=a-1;
      w-=d[a];
    }
  printf("%d\n",s);
  exit(0);
}

Measured memory_bytes: 1144
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

int main() {
  int n, m, cnt = 0;
  scanf("%d%d", &n, &m);
  vector<int> len(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &len[i]);
    if (len[i] % 2) ++cnt;
  }
  if (n == 1) {
    printf("1\n1\n1\n");
    return 0;
  }
  if (m == 1) {
    printf("%d\n", len[0]);
    printf("%d\n%d %d\n", 2, len[0] - 1, 1);
    return 0;
  }
  if (cnt > 2) {
    puts("Impossible");
    return 0;
  }
  for (int i = 0; i < m; ++i) {
    if (len[i] % 2 && i != 0 && i != m - 1) {
      if (len[0] % 2 == 0) {
        swap(len[0], len[i]);
      } else {
        swap(len[m - 1], len[i]);
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    printf("%d%c", len[i], " \n"[i + 1 == m]);
  }
  vector<int> ret;
  if (len[0] - 1 > 0) ret.push_back(len[0] - 1);
  for (int i = 1; i < m - 1; ++i) ret.push_back(len[i]);
  ret.push_back(len[m - 1] + 1);
  printf("%d\n", (int)ret.size());
  for (int i = 0; i < ret.size(); ++i) {
    printf("%d%c", ret[i], " \n"[i + 1 == ret.size()]);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f(i,l,r) for(int i=l;i<=r;i++)
#define debug(x) cout<<#x<<'='<<(x)<<endl
using namespace std;
template<class T> bool maxs(T& a,T& b)
{
	if(a<b)
	{
		T t;
		t=a;
		a=b;
		b=t;
		return true;
	}
	return false;
}
template<class T> bool maxi(T& a,T b)
{
	if(a<b)
	{
		a=b;
		return true;
	}
	return false;
}
template<class T> bool mini(T& a,T b)
{
	if(a>b)
	{
		a=b;
		return true;
	}
	return false;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int h[n+1];
	f(i,1,n)
		cin>>h[i];
	ll dp[n+1]={INT_MAX};
	dp[1]=0;
	f(i,2,n)
	{
		dp[i]=INT_MAX;
		for(int j=i-1;j>=0&&j>=i-k;j--)
		{
			mini(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1408
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main(){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    string s1, s2;
    string ans;
    
    for(int i = 0; i < ty - sy; i++){
        s1.push_back('U');
        s2.push_back('D');
    }
    for(int i = 0; i < tx - sx; i++){
        s1.push_back('R');
        s2.push_back('L');
    }
    
    ans = s1 + s2;


    s1 = "";
    s2 = "";
    
    s1.push_back('L');
    s2.push_back('R');
    
    
    for(int i = 0; i < ty + 1 - sy; i++){
        s1.push_back('U');
        s2.push_back('D');
    }
    
    for(int i = 0; i < tx - sx + 1; i++){
        s1.push_back('R');
        s2.push_back('L');
    }
    s1.push_back('D');
    s2.push_back('U');
    
    ans += s1 + s2;
    cout << ans << endl;
        
}



Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl;
#define DPUT(x) printf("%.15lf\n",x);;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, bool>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

bool memo[2][20000] = {};

int main(void) {

	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;

	vector<int> table[2];

	int dis = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'F') {
			int total = 0;
			while (s[i] == 'F') {
				i++;
				total++;
			}
			i--;
			table[dis].push_back(total);
		}
		else {
			dis = !dis;
		}
	}
/*
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < table[i].size(); j++) {
			cout << table[i][j] << " ";
		}
		cout << endl;

	}
*/

	//x
	if (s[0] == 'F') {

		x -= table[0][0];

		memo[1][10000] = true;
		for (int i = 1; i < table[0].size(); i++) {
			for (int j = 0; j < 20000; j++) {
				if (memo[i % 2][j]) {
					memo[(i + 1) % 2][j + table[0][i]] = true;
					memo[(i + 1) % 2][j - table[0][i]] = true;
					memo[i % 2][j] = false;
				}
			}
		}

		if (memo[table[0].size() % 2][10000 + x]) {

		}
		else {
			cout << "No" << endl;
			return 0;
		}

	}
	else {


		memo[0][10000] = true;
		for (int i = 0; i < table[0].size(); i++) {
			for (int j = 0; j < 20000; j++) {
				if (memo[i % 2][j]) {
					memo[(i + 1) % 2][j + table[0][i]] = true;
					memo[(i + 1) % 2][j - table[0][i]] = true;
					memo[i % 2][j] = false;
				}
			}
		}

		if (memo[table[0].size() % 2][10000 + x]) {

		}
		else {
			cout << "No" << endl;
			return 0;
		}


	}

	fill(*memo,*memo+40000,0);

	//y
	memo[0][10000] = true;
	for (int i = 0; i < table[1].size(); i++) {
		for (int j = 0; j < 20000; j++) {
			if (memo[i % 2][j]) {
				memo[(i + 1) % 2][j + table[1][i]] = true;
				memo[(i + 1) % 2][j - table[1][i]] = true;
				memo[i % 2][j] = false;
			}
		}
	}

	if (memo[table[1].size() % 2][10000 + y]) {

	}
	else {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;

}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
const int MAX = 1000000+5;
int n,a[MAX],cnt = 0;
void Swap(int x,int y){
	int t = a[x];
	a[x] = a[y];
	a[y] = t;
}
void BubbleSort(){
	for(int i = 0;i < n;i++)
		for(int j = n-1;j >= i+1;j--){
			if(a[j] < a[j-1]){
				Swap(j,j-1);
				cnt++;
			}
		}
}
void Print(){
	for(int i = 0;i < n-1;i++)
		cout << a[i] << " ";
	cout << a[n-1] << endl;
	cout << cnt << endl;
}
int main(int argc, char const *argv[])
{
	cin >> n;
	for(int i = 0;i < n;i++)
		cin >> a[i];
	BubbleSort();
	Print();
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define pi pair<int,int>
#define mk make_pair
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define fr(i,a,n) for(int i=a;i>=n;i--)
#define ll long long
#define N 1000000
using namespace std;

vector<int> adj[100005];
vector<int> dp(100005,-1);

void addedge(int x,int y)
{
    adj[x].push_back(y);
}

int dfs(int ind)
{
    if(dp[ind]==-1)
    {
        int ans=0;
        for(auto i:adj[ind])
        {
           ans=max(ans,dfs(i)+1);
        }
       dp[ind]=ans;
    }
    return dp[ind];
}


int longestpath(int n)
{
    int answer=INT_MIN;
    fo(i,1,n+1)
    {
        answer=max(answer,dfs(i));
    }
    return answer;
}



int main()
{
    int n,m;
    cin>>n>>m;
    int x,y;
    f(i,m)
    {
        cin>>x>>y;
        addedge(x,y);
    }
    cout<<longestpath(n);
}


Measured memory_bytes: 11020
#include <iostream>
#include <string>

std::pair<int, int> stot(const std::string &str) {
	auto idx = str.find(':');
	return std::make_pair<int, int>(stoi(str.substr(0, idx)), stoi(str.substr(idx + 1)));
}

int main() {
	int n;
	std::cin >> n;
	for (auto i = 0; i < n; ++i) {
		std::string arg;
		std::cin >> arg;
		auto time = stot(arg);
		auto hour = time.first * 60 + time.second, minute = time.second * 12;
		auto dist = (hour - minute) * (hour - minute);
		if (dist < 3600 || dist > 435600) {
			std::cout << "alert\n";
		}
		else if (dist < 32400 || dist > 291600) {
			std::cout << "warning\n";
		}
		else {
			std::cout << "safe\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

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

void solve(int w, int h){
    int sy = 0, sx = 0, gy = 0, gx = 0;
    vector<vector<int>> ys(5), xs(5);
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            if(s[j] == 'S') sy = i, sx = j;
            else if(s[j] == 'G') gy = i, gx = j;
            else if(isdigit(s[j])){
                ys[s[j]-'1'].emplace_back(i);
                xs[s[j]-'1'].emplace_back(j);
            }
        }
    }
    vector<vector<int>> dp(5);
    for (int i = 0; i < 5; ++i) {
        dp[i].resize(ys[i].size());
    }
    int ans = INF<int>, cur = 0;
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < 5; ++j) {
            fill(dp[j].begin(),dp[j].end(), INF<int>);
        }
        int st = (i+1)%5;
        for (int j = 0; j < dp[st].size(); ++j) {
            dp[st][j] = abs(sy-ys[st][j])+abs(sx-xs[st][j]);
        }
        for (int _ = 0; _ < 3; ++_) {
            int stt = (st+1)%5;
            for (int j = 0; j < dp[st].size(); ++j) {
                for (int k = 0; k < dp[stt].size(); ++k) {
                    chmin(dp[stt][k], dp[st][j]+abs(ys[st][j]-ys[stt][k])+abs(xs[st][j]-xs[stt][k]));
                }
            }
            st = stt;
        }
        for (int j = 0; j < dp[st].size(); ++j) {
            int dist = dp[st][j]+abs(gy-ys[st][j])+abs(gx-xs[st][j]);
            if(ans > dist){
                ans = dist;
                cur = i;
            }
        }
    }
    if(ans == INF<int>)puts("NA");
    else printf("%d %d\n", cur+1, ans);
}

int main() {
    int w, h;
    while(cin >> w >> h, w){
        solve(w, h);
    }
    return 0;
}


Measured memory_bytes: 3336
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
   int n;cin>>n;
   string s, t;cin>>s>>t;
   int cnt = 0;
   rep(i,n){
       if(s.substr(i) == t.substr(0, n-i)){
           cnt=n-i;
           break;
       }
   }
   cout<<2*n-cnt<<endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

type node struct {
	to  []int
	val int
}

var used []bool

func dfs(i int, n []node) {
	used[i] = true
	for _, v := range n[i].to {
		if used[v] {
			continue
		}
		n[v].val += n[i].val
		dfs(v, n)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	N, Q := getInt(), getInt()
	n := make([]node, N)
	for i := 0; i < N-1; i++ {
		f, t := getInt()-1, getInt()-1
		n[f].to = append(n[f].to, t)
		n[t].to = append(n[t].to, f)
	}

	for i := 0; i < Q; i++ {
		p, x := getInt()-1, getInt()
		n[p].val += x
	}

	used = make([]bool, N)
	dfs(0, n)
	for _, v := range n {
		fmt.Print(v.val, " ")
	}
	out()
}


Measured memory_bytes: 68736
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
typedef long long ll;

ll a[100005];
ll all_sum[100005];
ll m_sum[100005];

int main()
{
	ll n, k;
	ll ans = 0;

	scanf("%lld %lld", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}

	for (int i = 1; i <= n; i++) {
		all_sum[i] = all_sum[i - 1] + a[i];
		m_sum[i] = m_sum[i - 1] + max(a[i], 0);
	}

	for (ll i = 1; i + k - 1 <= n; i++) {
		//black
		ans = max(ans, (m_sum[i - 1] - m_sum[0]) + (m_sum[n] - m_sum[i + k - 1]) + all_sum[i + k - 1] - all_sum[i - 1]);

		//white
		ans = max(ans, (m_sum[i - 1] - m_sum[0]) + (m_sum[n] - m_sum[i + k - 1]));

	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 2560
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	long long n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int maxn = 1e5 +100;
vector<int> G[maxn];
int sg[maxn];
void dfs(int x, int fa){
    sg[x] = 0;
    for(auto to : G[x]){
        if(to == fa) continue;
        dfs(to, x);
        sg[x] ^= (sg[to]+1);
    }
}

int main()
{
    int n, x, y;
    cin>>n;
    for(int i = 1; i < n; i++){
        scanf("%d %d", &x, &y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(1, 1);
    if(sg[1]) cout<<"Alice";
    else cout<<"Bob";
}


Measured memory_bytes: 12416
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int INF = INT_MAX;
struct LazySegmentTree {
private:
  int n;
  vector<int> node, lazy;
  vector<bool> lazyFlag;
public:
  LazySegmentTree(vector<int> v) {
    int sz = (int)v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1);
    lazy.resize(2*n-1, INF);
    lazyFlag.resize(2*n-1, false);
 
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
  }
  void lazyEvaluate(int k, int l, int r) {
    if(lazyFlag[k]) {
      node[k] = lazy[k];
      if(r - l > 1) {
        lazy[k*2+1] = lazy[k*2+2] = lazy[k];
        lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
      }
      lazyFlag[k] = false;
    }
  }
  void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    lazyEvaluate(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      lazyFlag[k] = true;
      lazyEvaluate(k, l, r);
    }
    else {
      update(a, b, x, 2*k+1, l, (l+r)/2);
      update(a, b, x, 2*k+2, (l+r)/2, r);
      node[k] = min(node[2*k+1], node[2*k+2]);
    }
  }
  int find(int a, int b, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    lazyEvaluate(k, l, r);
    if(b <= l || r <= a) return INF;
    if(a <= l && r <= b) return node[k];
    int vl = find(a, b, 2*k+1, l, (l+r)/2);
    int vr = find(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
};

int main(){
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> V;
  map<int,int> T;
  for(int i = 0; i < N; ++i){
    int s, t, x;
    cin >> s >> t >> x;
    V.push_back({x,s,t});
    ++T[s-x];
    ++T[t-x];
  }
  vector<int> D(Q);
  for(int i = 0; i < Q; ++i){
    cin >> D[i];
    ++T[D[i]];
  }
  int M = 0;
  for(auto &t : T) t.second = M++;
  sort(V.rbegin(), V.rend());
  vector<int> init(M,-1);
  LazySegmentTree sg(init);
  for(int i = 0; i < N; ++i){
    int x = V[i][0], s = V[i][1], t = V[i][2];
    int l = T[s-x], r = T[t-x];
    sg.update(l,r,x);
  }
  vector<int> ans(Q,-1);
  for(auto d : D){
    cout << sg.find(T[d],T[d]+1) << endl;
  }
}


Measured memory_bytes: 62380
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    string s;
    long long k;
    cin>>s>>k;
    for (int i=0; i<s.size(); i++)
    {
        if (s[i]!='1')
        {
            cout<<s[i]<<endl;
            break;
        }
        if (i==k-1) { cout<<1<<endl; break; }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		sc.close();
		int i=0;
		int ans = 0;
		while(!Arrays.equals(S, T)){
			if(T[i]!=S[i]){
				S[i]=T[i];
				ans++;
			}
			i++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 42184
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack> 
using namespace std;
inline int read(){
	int f=1,ans=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return f*ans;
}
const int MAXN=200011; 
stack<int> que;
char str[MAXN];
int len;
int main(){
	scanf("%s",str+1);
	len=strlen(str+1);
	for(int i=1;i<=len;i++){
		if(str[i]=='S') que.push(i);
		else{
			if(!que.empty()){
				if(str[que.top()]=='S') que.pop();
				else que.push(i);
			}
			else que.push(i);
		}
	}printf("%d\n",que.size());
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(){
  int N;
  long long A, B;
  scanf("%d %lld %lld", &N, &A, &B);
  
  long long h[N];
  for(int i = 0; i < N; i++){
    scanf("%lld", &h[i]);
  }
  
  long long ok = (1ll << 32);
  long long ng = 0ll;
  while(ok - ng > 1){
    long long mid = (ok + ng) / 2ll;
    
    int able;
    long long explode = 0ll;
    for(int i = 0; i < N; i++){
      if(h[i] - mid * B > 0ll){
        explode += (h[i] - mid * B - 1ll) / (A - B) + 1ll;
      }
    }
    if(mid >= explode) able = 1;
    else able = 0;
    
    if(able) ok = mid;
    else ng = mid;
  }
  
  printf("%lld", ok);
  
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MOD = 1000000007;


int main(){
    int N; cin >> N;
    int A[2][110];
    rep(i,2)rep(j,N) cin >> A[i][j];
    vector<int> S1(110),S2(110);
    rep(i,N){
        S1[i+1] = S1[i]+A[0][i];
    }
    rep(i,N){
        S2[i+1] = S2[i]+A[1][i];
    }

    int res = 0;
    rep(i,N){
        int tmp = S1[i+1] + (S2[N] - S2[i]);
        res = max(res, tmp);
    }
    cout << res << endl;
}

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

int main() {
  ll N, M;
  cin >> N >> M;
  vector<vector<ll>> G(N, vector<ll>(0));
  rep(i,M) {
    ll a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<ll> q;
  q.push(0);
  vector<ll> ans(N, -1);
  vector<bool> gone(N, false);
  gone[0] = true;
  while(!q.empty()) {
    ll x = q.front(); q.pop();
    if (!G[x].empty()) {
      for (auto g : G[x]) {
        if (gone[g]) continue;
        gone[g] = true;
        ans[g] = x+1;
        q.push(g);
      }
    }
  }
  bool can = true;
  for (ll i = 1; i < N; i++) {
    if (ans[i] == -1) {
      can = false;
      break;
    }
  }
  if (can) {
    cout << "Yes" << endl;
    for (ll i = 1; i < N; i++) {
      cout << ans[i] << endl;
    }
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 12876
n=int(input())
dict={}
cnt=1
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    cnt=max(cnt,dict[s])
  else:
    dict[s]=1
dict_sorted=sorted(dict.items())
for j in range(len(dict_sorted)):
  if dict_sorted[j][1]==cnt:
    print(dict_sorted[j][0])

Measured memory_bytes: 136832
#include <iostream>

 

using namespace std;

 

int main()
{
    int a,b,c;
    
    cin >> a >> b >> c;
   
   
    if (a<b&&b<c)
      cout << "Yes"<< endl;

    else
      cout << "No" << endl;
   
    return 0;
}


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

int sq[1000][1000];
char b[1000][1000];

int main() {
	int n;
	while (cin >> n , n) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> b[i][j];
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				sq[i][j] = (b[i][j] == '.') ? 1 : 0;
			}
		}

		int ans = 0;
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if (b[i][j] == '*') continue;
				int len = min({sq[i - 1][j - 1], sq[i - 1][j], sq[i][j - 1]});
				sq[i][j] = len + 1;
				ans = max(ans, sq[i][j]);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 7840
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

	ll a,b;
	cin>>a>>b;
	ll ans=-1;
	for(ll x=1;x<=5000;++x)
    {
        ll aa=x*0.08;
        ll bb=x*0.1;
        if(a==aa&&b==bb){ans=x;break;}
    }
    cout<<ans;

	return(0);
}


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

int n;

int main(void){
	scanf("%d",&n);
	set<string> se;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		se.insert(s);
	}
	printf("%d\n",(int)se.size());
	return 0;
}


Measured memory_bytes: 19380
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    long long a[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        a[i]-=i;
    }
    sort(a,a+n);
    long long b=a[n/2];
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-b);
    }
    printf("%lld\n",ans);
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef pair<int, int> pii;
typedef double Double;

inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

int N;
lint C[110][110];

int main() {
	cin >> N;
	for_(i,0,N) for_(j,0,N) cin >> C[i][j];
	lint ans = 0;
	for_(i,0,N) for_(j,i + 1, N) ans += min(C[i][j], C[j][i]);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(void) {
	int A, B, C, X, Y;
	long long int ans = 0;
	cin >> A >> B >> C >> X >> Y;
	if (A + B < 2 * C) {
		int t = min(X, Y);
		ans += (A + B) * t;
		X -= t;
		Y -= t;
	}
	else {
		int t = min(X, Y);
		ans += 2 * C * t;
		X -= t;
		Y -= t;
	}
	if (X > 0) {
		int t = min(A, 2 * C);
		ans += t * X;
	}
	if (Y > 0) {
		int t = min(B, 2 * C);
		ans += t * Y;
	}
	cout << ans << endl;
	//system("pause");
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int p = pow(K-1, N-1);
    cout << K*p << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
read = sys.stdin.read
from math import sqrt, ceil
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        sys.exit()

    divs = []
    for i1 in range(2, ceil(sqrt(m))+1):
        if m % i1 == 0:
            divs.append(i1)
            divs.append(int(m/i1))
    divs.sort()
    r = 1
    for div in divs:
        if n * div <= m:
            r = div
        else:
            break
    print(r)

if __name__ == '__main__':
    main()

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

int main(){
    int A,B,C,X,Y;
    int min_c=100000000000;
    cin>>A>>B>>C>>X>>Y;

        for(int i=0;i<=100000;++i){
            int sum=2*C*i+A*max(0,X-i)+B*max(0,Y-i);
            min_c=min(min_c,sum);
        }
     cout<<min_c;
    

}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


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

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

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

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

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

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;
const int M = 1000000007;


typedef long long int ll;
vector<ll> fac(3000001); //n!(mod M)
vector<ll> ifac(3000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算、a,b<=300000でないと使えない
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<10000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

typedef long long int ll;

int pow(int a,int b){
  if(b==0) return 1;
  else{
    return a*pow(a,b-1);

  }
}

typedef struct ListNode {
    int data;
    struct ListNode *next;
} ListNode;



int main(){
  long long int n;
  cin >> n;
  if(n >= 2){
    ll ans = ((mpow(10,n) - 2*mpow(9,n))%M + mpow(8,n))%M;
    if (ans >= 0){
      cout << ans << endl;
    }
    else{
      cout << ans +M << endl;
    }
  }else{
    cout << 0 << endl;
  }




}


Measured memory_bytes: 50096
#include <stdio.h>

int main(void)
{
    int i,a,x,n,m;
    int f[101][101],b[101],c[101];
    
    scanf("%d%d",&n,&m);
    
    for(i=0;i<n;i++){
        for(a=0;a<m;a++){
            scanf("%d",&f[i][a]);
        }
    }
    for(a=0;a<m;a++){
        scanf("%d",&b[a]);
    }
    for(i=0;i<n;i++){
        for(a=0;a<m;a++){
            c[i]+=f[i][a]*b[a];
        }
        printf("%d\n",c[i]);
    }
    return 0;
}


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

int main(void){

    int N, A, B;

    scanf("%d%d%d", &N, &A, &B);

    if(A * N < B){
        printf("%d\n", A * N);
    }else{
        printf("%d\n", B);
    }

    return 0;
}

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

int i,j;
char pat[10][10];

int main(){
	for(i=0;i<8;i++)scanf("%s",pat[i]);
	printf("90\n");
	for(i=0;i<8;i++){
		for(j=7;j>=0;j--){
			printf("%c",pat[j][i]);
		}
		printf("\n");
	}
	printf("180\n");
	for(i=7;i>=0;i--){
		for(j=7;j>=0;j--){
			printf("%c",pat[i][j]);
		}
		printf("\n");
	}
	printf("270\n");
	for(i=7;i>=0;i--){
		for(j=0;j<8;j++){
			printf("%c",pat[j][i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int
var StrReverse func(string) string

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
	StrReverse = strReverse
	GetIntAbs = getIntAbs
}

func main() {
	n := ReadInt()
  a := ReadIntSlice(n)
  b := ReadIntSlice(n)
  c := ReadIntSlice(n-1)
  manzoku := 0
  prev := -2
  for _, v := range a {
    v = v - 1
    manzoku += b[v]
    if v - 1 == prev {
      manzoku += c[prev]
    }
    prev = v
  }
  
  fmt.Println(manzoku)
}

func strReverse(s string) string {
	runes := []rune(s)
	l := len(runes)
	for i, j := 0, l-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func newReadString() func() string {
	sc.Buffer(make([]byte, 202400), 404800)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 640
#include<stdio.h>
int  main(void)
{
  char a[4]="ACGT",b;
  scanf("%s",&b);
  
  if(b==a[0])
   printf("T");
    if(b==a[1])
   printf("G");
   if(b==a[2])
   printf("C");
    if(b==a[3])
   printf("A");
  return 0;}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
long int N;
int main(){
    cin >> N;
    long int count =0;
    for(int i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0){
            count += i;
        }
    }
    printf("%ld\n",count);
}

Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
using namespace std;
#pragma warning (disable:4996)
const int maxn = 100005;
int a[maxn << 1], b[maxn << 1];
bool check(int n) {
	n--;
	while (n)
	{
		if (n & 1)
			n >>= 1;
		else
			return true;
	}
	return false;
}
int main() {
	int n;
	scanf("%d", &n);
	if (n == 1 || !check(n)) {
		printf("No\n");
		return 0;
	}
	a[1] = 1; b[1] = 2;
	int size;
	if(n&1){
		size = 1;
		for (int i = 2; i <= n; i += 2) {
			a[++size] = i; b[size] = i + 1;
			a[++size] = i + 1; b[size] = n + 1;
			a[++size] = n + 1; b[size] = n + i;
			a[++size] = n + i; b[size] = n + i + 1;
		}
	}
	else
	{
		size = 1;
		for (int i = 2; i + 1 <= n; i += 2) {
			a[++size] = i; b[size] = i + 1;
			a[++size] = i + 1; b[size] = n + 1;
			a[++size] = n + 1; b[size] = n + i;
			a[++size] = n + i; b[size] = n + i + 1;
		}
		a[++size] = n; b[size] = n - 1;
		a[++size] = n + n; b[size] = (n ^ (n - 1) ^ 1) + n;
	}
	printf("Yes\n");
	for (int i = 1; i <= size; i++) {
		printf("%d %d\n", a[i], b[i]);
	}
}

Measured memory_bytes: 4352
use std::cmp;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn find_min(x: &[u64]) -> u64 {
    let mut min: u64 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        min = cmp::min(*i, min);
    }
    return min;
}

#[allow(dead_code)]
fn find_max(x: &[u32]) -> u32 {
    let mut max: u32 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        max = cmp::max(*i, max);
    }
    return max;
}
fn main() {
    let n: u32 = read();
    let mut p: Vec<u32> = Vec::new();

    for _i in 0..n {
        let tmp: u32 = read();
        p.push(tmp);
    }

    let max: u32 = find_max(&p);

    let sum: u32 = p.clone().iter().fold(0, |sum, i| sum + i) - max / 2;

    println!("{}", sum);
}


Measured memory_bytes: 4352
use proconio::{fastout, input};

use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::cmp::Reverse;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        n: usize, m: usize, s: i64,
    }
    let mut g = vec![vec![]; n];
    for i in 0..m {
        input! { u: Usize1, v: Usize1, a: i64, b: i64 }
        g[u].push((v, a, b));
        g[v].push((u, a, b));
    }
    let mut h = vec![(0, 0); n];
    for i in 0..n {
        input! { c: i64, d: i64 }
        h[i] = (c, d);
    }
    let mut q = BinaryHeap::new();
    q.push(Reverse((0, min(s, 2500), 0)));
    let mut dp = vec![vec![std::i64::MAX; 2501]; n];
    dp[0][min(s, 2500) as usize] = 0;
    while let Some(Reverse((t, s, i))) = q.pop() {
        let (c, d) = h[i];
        if s + c < 2501 {
            let s0 = s as usize;
            let s1 = (s + c) as usize;
            if dp[i][s1] > dp[i][s0] + d {
                dp[i][s1] = dp[i][s0] + d;
                q.push(Reverse((dp[i][s1], s1 as i64, i)));
            }
        }
        for &(j, a, b) in g[i].iter() {
            if s - a >= 0 {
                let s0 = s as usize;
                let s1 = (s - a) as usize;
                if dp[j][s1] > dp[i][s0] + b {
                    dp[j][s1] = dp[i][s0] + b;
                    q.push(Reverse((dp[j][s1], s1 as i64, j)));
                }
            }
        }
    }
    for i in 1..n {
        let ans = dp[i].iter().fold(std::i64::MAX, |x, y| min(x, *y));
        println!("{}", ans);
    }
}


Measured memory_bytes: 4716
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

void Main() {
    // input
    int N, M;
    cin >> N >> M;

    vector<int> votes(N);
    for (int i = 0; i < N; i++) {
        cin >> votes[i];
    }

    // translate
    sort(votes.begin(), votes.end());
    reverse(votes.begin(), votes.end());

    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += votes[i];
    }

    for (int i = 0; i < M; i++) {
        if (votes[i] < sum * 1.0 / (4 * M)) {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;

    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#define MAX_N 100

int N;
char S[MAX_N];
char T[MAX_N];

char ans[MAX_N*2];

int main(int argc, char const *argv[])
{
	scanf("%d", &N);
	scanf("%s", S);
	scanf("%s", T);
	int len = 2*N;

	for (int i = 0; i < N; ++i)
	{
		if (S[i] == '\0')
		{
			break;
		}
		ans[2*i] = S[i];
		ans[2*i+1] = T[i];
	}

	for (int i = 0; i < len; ++i)
	{
		printf("%c", ans[i]);
	}
	printf("\n");

	return 0;
}

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

int main()
{
	int coin500, coin100, coin50;
	int x;

	cin >> coin500 >> coin100 >> coin50 >> x;

	int count_pattern = 0;
	for (int i500 = 0; i500 <= coin500; i500++)
	{
		for (int i100 = 0; i100 <= coin100; i100++)
		{
			for (int i50 = 0; i50 <= coin50; i50++)
			{
				if (i500 * 500 + i100 * 100 + i50 * 50 == x)
				{
					count_pattern++;
				}
			}
		}
	}

	cout << count_pattern << endl;
}

//int main()
//{
//	int n;
//	vector<int> list;
//
//	cin >> n;
//
//	for (int i = 0; i < n; i++)
//	{
//		int num;
//		cin >> num;
//		list.push_back(num);
//	}
//
//	int proc_count = 0;
//	while (true)
//	{
//		bool valid = true;
//		for (int i = 0; i < n; i++)
//		{
//			if (list[i] % 2 > 0)
//			{
//				valid = false;
//				break;
//			}
//			else
//			{
//				list[i] /= 2;
//			}
//		}
//
//		if (valid == true)
//		{
//			proc_count++;
//		}
//		else
//		{
//			break;
//		}
//	}
//
//	cout << proc_count << endl;
//}

//int main()
//{
//	string str;
//
//	cin >> str;
//
//	int count_one = 0;
//
//	if (str[0] == '1')
//	{
//		count_one++;
//	}
//	
//	if (str[1] == '1')
//	{
//		count_one++;
//	}
//
//	if (str[2] == '1')
//	{
//		count_one++;
//	}
//
//	cout << count_one << endl;
//}


//int main()
//{
//	int a, b;
//
//	cin >> a >> b;
//
//	int c = a * b;
//
//	if (c % 2 == 0)
//	{
//		cout << "Even" << endl;
//	}
//	else
//	{
//		cout << "Odd" << endl;
//	}
//}

Measured memory_bytes: 256