akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private long f(int[] s, int i, int n) { 
		if (n == 0) {
			return 1;
		}
		if (s.length <= i) {
			return 0;
		}

		long result = 0;
		result += s[i] * f(s, i + 1, n - 1);
		result += f(s, i + 1, n);

		return result;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] s = new int[5];

		for (int i = 0; i < N; i++) {
			String S = sc.next();
			switch (S.charAt(0)) {
			case 'M':
				s[0]++;
				break;
			case 'A':
				s[1]++;
				break;
			case 'R':
				s[2]++;
				break;
			case 'C':
				s[3]++;
				break;
			case 'H':
				s[4]++;
				break;
			}
		}
		sc.close();

		long ans = f(s, 0, 3);

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 46928
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINTF(...)
#endif // DEBUG

static int g_compNum = 0;

void merge(int *array, int left, int mid, int right)
{
  DPRINTF("LEFT %d  MID %d  RIGHT %d\n", left, mid, right);

  // 0, 0, 1
  int n1 = mid - left + 1; // 1
  int n2 = right - (mid + 1) + 1; // 1

  int arrayL[n1 + 1], arrayR[n2 + 1];
  for (int i = 0; i < n1; i++)
    arrayL[i] = array[left + i];

  for (int i = 0; i < n2; i++)
    arrayR[i] = array[(mid + 1) + i];

  arrayL[n1] = INT_MAX;
  arrayR[n2] = INT_MAX;

  int i = 0, j = 0;
  for (int k = 0; k < (right - left + 1); k++)
  {
    DPRINTF("arrayL[%d] %d  arrayR[%d] %d\n", i, arrayL[i], j, arrayR[j]);

    if (arrayL[i] < arrayR[j])
    {
      array[left + k] = arrayL[i];
      i++;
    }
    else
    {
      array[left + k] = arrayR[j];
      j++;
    }
    g_compNum++;
  }

#if DEBUG
  for (int i = 0; i < (right - left + 1); i++)
  {
    if (i == 0) { DPRINTF("%d", array[i]); }
    else  printf(" %d", array[i]);
  }
  cout << endl;
#endif

}

void mergeSort(int *array, int left, int right)
{

  DPRINTF("LEFT %d  RIGHT %d\n", left, right);

  if (left >= right)
    return ;

  int mid = (left + right) / 2;
  mergeSort(array, left, mid);
  mergeSort(array, mid + 1, right);
  merge(array, left, mid, right);
}

int main()
{
  int arrayNum;
  cin >> arrayNum; cin.ignore();

  int array[arrayNum];
  for (int i = 0; i < arrayNum; i++)
    cin >> array[i];

#if DEBUG
  DPRINTF("ARRAY NUM %d\n", arrayNum);
  for (int i = 0; i < arrayNum; i++)
  {
    if (i == 0) { DPRINTF("%d", array[i]); }
    else printf(" %d", array[i]);
  }
  cout << endl;
#endif // DEBUG

  const int left = 0, right = arrayNum - 1;
  mergeSort(array, left, right);

  for (int i = 0; i < arrayNum; i++)
  {
    if (i == 0) printf("%d", array[i]);
    else  printf(" %d", array[i]);
  }
  cout << endl;

  cout << g_compNum << endl;

  return 0;
}



Measured memory_bytes: 7012
'use strict'

const Main = (input) => {
  const tmp = input.trim().split(' ')
  const D = parseInt(tmp[0])
  const N = parseInt(tmp[1])
  let result = 0
  switch (D) {
    case 0:
      if (N === 100) {
        result = 101
      } else {
        result = N
      }
      break;
    case 1:
      if (N === 100) {
        result = 10100
      } else {
        result = N * 100
      }
      break
    default:
      if (N === 100) {
        result = 1010000
      } else {
        result = N * 10000
      }
      break;
  }

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main() {
    int N, x;
    int A[N];  
    int res = 0;
    cin >> N >> x;
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A, A + N);
    for (int i=0; i < N-1; ++i){
        if (x >= A[i]){
            ++res;
            x = x - A[i];
            }
        }
    if(x == A[N-1]){
        ++res;
    }
    cout << res << endl;
    }
        
    
    
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define deba(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void solve(){
    ll n;
    cin>>n;
    vll v(n);
    fr(i,0,n)cin>>v[i];
    vll ans(n,INT_MAX);
    ans[1]=abs(v[1]-v[0]);ans[0]=0;
    for(int i=2;i<n;i++){
        ans[i]=ans[i-1]+abs(v[i]-v[i-1]);
        ans[i]=min(ans[i-2]+abs(v[i-2]-v[i]),ans[i]);
    }
    cout<<ans[n-1]<<endl;
    
    
}  
int main(){
    ll t=1;
//cin>>t;
while(t--){
     solve();
   //  cout<<endl;
}
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;
#define PI 3.14159265359



int main()
{
    int N;
    cin >> N;
    
    bool can = false;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i * j == N){
                can = true;
                break;
            }
        }
    }

    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
program walk_and_teleport
  implicit none
  integer :: n, i
  integer(8) :: a, b, x(100000), s
  x = 0_8
  read(*,*) n, a, b
  read(*,*) x(1:n)
  s = 0
  do i = 1, n-1
    s = s + min(a*(x(i+1)-x(i)),b)
  end do
  write(*,'(i0)') s
  stop
end program walk_and_teleport

Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
//#include<unordered_map>
//#include<unordered_set>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> P; 
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

Int dp[201][1000001];

void solve()
{
	int n, x;
	cin >> n >> x;
	vector<int> S(N);
	for (int i = 0; i < n; i++) cin >> S[i];
	sort(S.rbegin(), S.rend());

	dp[0][x] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 100000; j++) {
			dp[i + 1][j%S[i]] = (dp[i + 1][j%S[i]] + dp[i][j]) % MOD;
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * (n - i - 1)) % MOD;
		}
	}

	Int ans = 0;
	for (int j = 0; j <= 100000; j++) ans = (ans + (j*dp[n][j]%MOD)) % MOD;
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}


Measured memory_bytes: 160684
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=m/n;i>=1;i--){
		if(m%i==0){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A = list(map(int, input().split()))
c = 0
steps = [0] * N
for i in range(1,N):
    if A[i-1] + steps[i-1] > A[i]:
        d = A[i-1] + steps[i-1] - A[i]
        c += d
        steps[i] = d
print(c)

Measured memory_bytes: 94024
#include "bits/stdc++.h"
using namespace std;

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =3e3+5;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};

long double a[N][N],p[N],sum;


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

   rep(i,0,n)
	    cin>>p[i];
   

   a[0][0]=1;

   rep(i,0,n){
	 rep(j,0,i+1){
		a[i+1][j+1] += a[i][j]*p[i];
		a[i+1][j]   += a[i][j]*(1-p[i]);
	 }
   }
   
   int bg=(n+1)/2;
    
   rep(i,bg,n+1)
	    sum+=a[n][i];

   cout<<fixed<<setprecision(10)<<sum<<endl;

  // cout<<sum<<endl;

}



int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	   
}


Measured memory_bytes: 139392
local mod = 1000000007
local function badd(x, y) return (x + y) % mod end

local s = io.read()
local d = io.read("*n")
local dpmax, dpnormal = {}, {}
for i = 1, d do
  dpmax[i] = 0
  dpnormal[i] = 0
end
dpmax[d] = 1
local nxt_max, nxt_normal = {}, {}
for i = 1, #s do
  for j = 1, d do
    nxt_max[j] = 0
    nxt_normal[j] = 0
  end
  local v = s:sub(i, i):byte() - 48
  for src = 1, d do
    for add = 0, v do
      local dst = (add + src) % d
      if dst == 0 then dst = d end
      if add == v then
        nxt_max[dst] = badd(nxt_max[dst], dpmax[src])
      else
        nxt_normal[dst] = badd(nxt_normal[dst], dpmax[src])
      end
    end
    for add = 0, 9 do
      local dst = (add + src) % d
      if dst == 0 then dst = d end
      nxt_normal[dst] = badd(nxt_normal[dst], dpnormal[src])
    end
  end
  for j = 1, d do
    dpmax[j] = nxt_max[j]
    dpnormal[j] = nxt_normal[j]
  end
end
local ret = badd(dpmax[d], dpnormal[d])
ret = badd(ret, mod - 1)
print(ret)


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <stdlib.h>

using namespace std;

void solve()
{
	map<int, int> Map;
	set<int> Set1;
	set<int> Set2;
	int a, b;
	char c;
	string str;
	while(getline(cin, str))
	{
		if(str == "")
		{
			break;
		}
		string temp;
		for(int i = 0; i < str.size(); ++i)
		{
			if(str[i] == ',')
			{
				a = atoi(temp.c_str());
			}
			else
			{
				temp += str[i];
			}
		}
		b = atoi(temp.c_str());
		++Map[a];
		Set1.insert(a);
	}
	while(cin >> a >> c >> b)
	{
		++Map[a];
		Set2.insert(a);
	}
	map<int, int>::iterator it = Map.begin();
	while(it != Map.end())
	{
		if(Set1.find(it->first) != Set1.end() && Set2.find(it->first) != Set2.end())
		{
			cout << it->first << " " << it->second << endl;
		}
		++it;
	}
}

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

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

#define ll long long

int main() {

    ll a[3], i, j, k, m, n;

    for(i=0; i<3; i++)
        scanf("%lld", &a[i]);
    scanf("%lld", &k);

    while(k--) {
        if(a[0] > a[1])
            j = 0;
        else
            j = 1;
        if(a[2] > a[j])
            j = 2;

        a[j] *= 2;
    }

    printf("%lld\n", a[0] + a[1] + a[2]);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define S(n) scanf("%d",&n)
int n,s[100000],q,t,c,i,j;
main(){
  for(S(n);i<n;S(s[i++]));
  for(S(q);j++<q;std::cin>>t,std::binary_search(s,s+n,t)&&c++);
  printf("%d\n",c);
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
if((N-N/1000*1000)%111==0){
    cout<<"Yes"<<endl;
}
else if((N-N%10)/10%111==0){
    cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <queue>
#define inf 1000000000

using namespace std;

int n, m, c[3];
vector<int> G[55], g[55][3];
bool move[105][55];
int turns[55];

void canMove(int s)
{
	for(int i = 0; i <= 100; i++){
		for(int j = 1; j <= n; j++){
			move[i][j] = false;
		}
	}
	move[0][s] = true;
	
	for(int i = 0; i <= 99; i++){
		for(int j = 1; j <= n; j++){
			if(!move[i][j]) continue;
			for(int k = 0; k < G[j].size(); k++){
				move[i+1][G[j][k]] = true;
			}
		}
	}
}

int main(void)
{
	cin >> n >> m >> c[0] >> c[1] >> c[2];
	int u, v;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		G[u].push_back(v);
	}
	
	for(int i = 1; i <= n; i++){
		canMove(i);
		for(int j = 0; j < 3; j++){
			for(int k = 1; k <= n; k++){
				if(move[c[j]][k]) g[i][j].push_back(k);
			}
		}
	}
	
	for(int i = 1; i <= n; i++) turns[i] = inf;
	turns[n] = 0;
	
	int min_turn, max_turn;
	bool flag = true;
	while(flag){
		flag = false;
		for(int i = 1; i <= n; i++){
			max_turn = 0;
			for(int j = 0; j < 3; j++){
				min_turn = inf;
				for(int k = 0; k < g[i][j].size(); k++){
					min_turn = min(min_turn, turns[g[i][j][k]] + 1);
				}
				max_turn = max(max_turn, min_turn);
			}
			if(turns[i] > max_turn){
				flag = true;
				turns[i] = max_turn;
			}
		}
	}
	
	if(turns[1] >= inf) cout << "IMPOSSIBLE" << endl;
	else cout << turns[1] << endl;
	
	return 0;
}

Measured memory_bytes: 3232
#include "stdio.h"


int main()
{
	int S,W;
	do{
		scanf("%d%d",&S,&W);
	}while((S<1&&S>100)&&(W<1&&W>100));
	
	if(W>=S)
		printf("unsafe\n");
	else
		printf("safe\n");
	
	return 0;
}

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

using namespace std;

int h,w,d,q;
vector<pair<int,int>> p(90001,make_pair(0,0));
int sum[90001]={0};

int main(){
  cin >> h >> w >> d;
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
    int a;
     cin >> a;
     p[a].first=i;
     p[a].second=j;
   }
  }
  
  for(int i=d+1;i<=h*w;i++) sum[i]=sum[i-d]+abs(p[i].first-p[i-d].first)+abs(p[i].second-p[i-d].second);
  
  cin >> q;
  for(int i=0;i<q;i++){
   int l,r;
    cin >> l >> r;
    cout << sum[r]-sum[l] << endl;
  
  }

}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 3) {
        if (s[i] == t[i]) ans++;
    }

    cout << ans << endl;

}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, i, j;
    cin >> n >> k;
    vi a(n); cin >> a;
    vi sm(n);
    while(k--){
        fill(all(sm), 0);
        for(i=0;i<n;i++){
            j = max(i - a[i], 0);
            sm[j] += 1;
            j = i + a[i] + 1;
            if(j < n)
                sm[j] -= 1;
        }
        int cr = 0;
        bool stop = true;
        for(i=0;i<n;i++){
            cr += sm[i];
            a[i] = cr;
            if(a[i] != n) stop = false;
        }
        if(stop) break;
    }
    cout << a << "\n";
    return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,ans=0,k[1005],l[1005];
  cin>>a>>b>>c;
  for(int i=0;i<c;++i){
    cin>>k[i]>>l[i];
    if(i){
      ans+=abs(k[i]-k[i-1])+abs(l[i]-l[i-1]);
      if((k[i]>k[i-1]&&l[i]>l[i-1])||(k[i-1]>k[i]&&l[i-1]>l[i])) ans-=min(abs(k[i]-k[i-1]),abs(l[i]-l[i-1]));
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  vector<signed long long int> vect(n);
  for(int i=0;i<n;i++) cin>>vect[i];
  vector<vector<signed long long int>> dp(n,vector<signed long long int>(n));
  //dp[i][j]->max difference that the person can get when he is at range between i-to-j
  for(int i=0;i<n;i++) dp[i][i]=vect[i];
  for(int l=n-1;l>=0;l--){
    for(int r=l+1;r<n;r++){
      dp[l][r]=max(vect[l]-dp[l+1][r],vect[r]-dp[l][r-1]);
    }
  }
  cout<<dp[0][n-1];
  return 0;
}


Measured memory_bytes: 70784
// ABC152C3.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
//#include "pch.h"
#include <iostream>
#include <vector> //配列を使う
using namespace std;
int main()
{
	int ans = 0; // 答えを入れる変数
	int small = 2 * 100000 + 1;// 一番大きい値を準備
	int N;
	cin >> N;
	vector<int>P(N); // N個のデータを読み込む
	for (int i = 0; i < N; i++)
	{
		cin >> P.at(i);
		if (P.at(i)<small)
		{
			small = P.at(i); // これまでの最小値と比べて小さければ、入れ替える
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
s = list(input())
ans = 1
sw = 0
for i in range(len(s)):
    if i == 0 :
        if s[0] !="A":
            ans = 0
    elif 2 <= i <= len(s)-2 and s[i] == "C":
        sw += 1
    else:
        if not(97<= ord(s[i]) <= 122):
            ans = 0
if ans == 1 and sw == 1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
import sys as cghavcjhcbejwcbbsmbcjsdbcjdcadhbcjbdsjjcdjabjadbjsbcjdsbcsbcnsbcdnbcmbcmdabcdbjwhckfmknvskndleccdajbubcrjhebuoqbjhbjcdnaaayruegfubefruebhvy38bjhbvvbhcba
A,B,C = map(int,cghavcjhcbejwcbbsmbcjsdbcjdcadhbcjbdsjjcdjabjadbjsbcjdsbcsbcnsbcdnbcmbcmdabcdbjwhckfmknvskndleccdajbubcrjhebuoqbjhbjcdnaaayruegfubefruebhvy38bjhbvvbhcba.stdin.readline().split())

if A == B:
  print(C)
elif A == C:
  print(B)
else:
  print(A)

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

void max_self(long long& a , long long b){
	a = max(a , b);
}

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n , w;
	cin >> n >> w;
	vector<long long> dp(w + 1 , 0);
	for (int i = 0; i < n; i++){
		long long weight , val;
		cin >> weight >> val;
		for (int j = w - weight; j >= 0; --j){
			max_self(dp[j + weight] , dp[j] + val);
		}
	}
	long long ans = 0ll;
	for (auto x : dp){
		max_self(ans , x);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
import java.io.*;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(br.readLine());
        String[] st = br.readLine().split(" ");
        for (int i = n - 1; i >= 0; i--) {
            if (i < n - 1) {
                bw.append(" ");
            }
            bw.append(st[i]);
        }
        bw.newLine();
        bw.flush();
    }


}


Measured memory_bytes: 24544
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int r[4][13];

for(int i=0;i<=3;i++){
 for(int j=0;j<=12;j++){
  r[i][j]=0;
 }
}

for(int k=0;k<=n;k++){
string a;
int b;
cin >>a>>b;
if(a =="S"){
r[0][b]=1;
}else if(a =="H"){
r[1][b]=1;
}else if(a =="C"){
r[2][b]=1;
}else if(a =="D"){
r[3][b]=1;
}
}

for(int l=0;l<=3;l++){
 for(int m=1;m<=13;m++){
  if(r[l][m] == 0){
   if(l == 0){
    cout<<"S "<<m<<""<<endl;
   }else if(l == 1){
    cout<<"H "<<m<<""<<endl;
   }else if(l == 2){
    cout<<"C "<<m<<""<<endl;
   }else if(l == 3){
    cout<<"D "<<m<<""<<endl;
   }
  }
 }
}

}


Measured memory_bytes: 3124
import sys
N = int(sys.stdin.readline().rstrip())
T, A = map(int, sys.stdin.readline().rstrip().split())
H = list(map(int, sys.stdin.readline().rstrip().split()))
res = 10**10
ans = -1
for i, h in enumerate(H):
    if res > abs(A - (T - h * 0.006)):
        ans = i
        res = abs(A - (T - h * 0.006))
print(ans + 1)

Measured memory_bytes: 3064
#include <cstdio>

using namespace std;

char s[30001];
int a[30001][10];

int main() {
    int n, ans = 0, i, j, k;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < 10; i++) a[n][i] = -1;
    
    for (i = n - 1; i >= 0; i--) {
        for (j = 0; j < 10; j++) a[i][j] = a[i + 1][j];
        a[i][s[i] - '0'] = i;
    }
    
    for (i = 0; i < 10; i++) {
        for (j = 0; j < 10; j++) {
            for (k = 0; k < 10; k++) {
                int x = 0;
                
                if (a[x][i] == -1) continue;
                x = a[x][i] + 1;
                
                if (a[x][j] == -1) continue;
                x = a[x][j] + 1;
                
                if (a[x][k] == -1) continue;
                
                ans++;
            }
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[10],f,g,h,j,i,k;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<10;i++) d[i]=0;
		for(i=0;i<a;i++){
			scanf("%d",&s);
			d[s]++;
		}
		for(i=0;i<10;i++){
			for(j=1;j<=d[i];j++){
				printf("*");
			}
			if(d[i]==0) printf("-");
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2508
/*
    Created by vasu090 on 19 Apr, 2020
*/
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int a; cin >> a;
    cout << 3*a*a << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
int main() {
  cin >> n >> m;
  vector<lli> red(n+1, 0), cnt(n+1, 1);
  red[1] = 1;
  for (lli i=0; i<m; ++i) {
    lli x, y; cin >> x >> y;
    cnt[x]--;
    cnt[y]++;
    if (red[x] == 1) {
      red[y] = 1;
      if (cnt[x] == 0) red[x] = 0;
    }
  }
  lli ans = 0;
  for (lli x : red) {
    ans += x;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 1792
x=int(input())
l=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    l.append(x//i)
for i in l:
  for j in range(int(x**0.2)+100,0,-1):
    A=j
    B=j-i
    if A<B:
      break
    if A**5-B**5==x:
      print(A,B,sep=' ')
      exit()

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

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<vector<vector<int>>> da(26, vector<vector<int>>(26, vector<int>(0)));
	vector<int> li(n);
	rip(i, n, 0) {
		li[i] = s[i] - 'a';
	}
	rip(i, n - 1, 0) {
		da[li[i]][li[i + 1]].push_back(i);
	}
	int ans = 0;
	int no = 0;
	vector<unordered_map<int, int>> ma(2);
	rip(i, n - 1, 0) {
		int si = da[li[i]][li[i + 1]].size();
		for (int j = si - 1;j > -1;j--) {
			if (da[li[i]][li[i + 1]][j] <= i+1) {
				break;
			}
			if (ma[(i+1)%2].count(da[li[i]][li[i + 1]][j] - 1)) {
				if (ma[(i + 1) % 2][da[li[i]][li[i + 1]][j] - 1] != i + 1) {
					int gg = ma[(i + 1) % 2][da[li[i]][li[i + 1]][j] - 1];
					ma[i % 2][da[li[i]][li[i + 1]][j]] = gg;
					ans = max(ans, da[li[i]][li[i + 1]][j] - ma[i % 2][da[li[i]][li[i + 1]][j]] + 2);
				}
			}
			else {
				ma[i%2][da[li[i]][li[i + 1]][j]] = da[li[i]][li[i + 1]][j];
				ans = max(ans,2);
			}
		}
		ma[(i + 1) % 2].clear();
	}
	if(ans == 0) {
		set<int> se;
		rip(i, n, 0) {
			if (se.count(li[i])) {
				ans = 1;
				break;
			}
			else {
				se.insert(li[i]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <map>
#include <vector>
#define rep(i, n) for(int i=0 ; i<n; ++(i))
#define rep2(i, j, n) for(int i=j; i<n; ++i)
using namespace std;
typedef long long ll;
typedef unsigned long ul;


int main(){
    ll N;
    cin >> N;
    vector<ll> d(N);
    rep(i, N){
        cin >> d[i];
    }
    ll ans=0;
    rep(i, N) rep2(j, i, N){
        if(i!=j)ans += d[i] * d[j];
    }


    cout<<ans <<endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

bool f(int m, int d1, int d10) {
  if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) return true;
  return false;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      if (f(i, j % 10, j / 10)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 2e5 + 5;

int n, a[N];

int check(int val) {
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += abs(a[i] - (val + i + 1));
	return ans;
}
				
int32_t main() {
	fast_cin();  

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int l = -2e9, r = 2e9;
	while (r - l > 3) {
		int m1 = l + (r - l) / 3;
		int m2 = r - (r - l) / 3;
		if (check(m1) < check(m2)) {
			r = m2;
		} else {
			l = m1;
		}
	}
	int ans = 1e15;
	for (int i = l; i <= r; i++) {
		ans = min(ans, check(i));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
 
 
signed main()
{
	QUICK_CIN;
	//debug_input;
 
	int n;
	string s;
	string t[4];
 
	cin >> n >> s;
	s += s[0];
 
	t[0] = "SS";
	t[1] = "SW";
	t[2] = "WS";
	t[3] = "WW";
 
	map<char, string> rev;
	rev['W'] = "S";
	rev['S'] = "W";
 
	REPS(1,i,n+1) {
		REP(j, 4) {
			if (t[j][i] == 'S') {
				if (s[i] == 'o') {
					t[j] += t[j][i - 1];
				}
				else {
					t[j] += rev[t[j][i - 1]];
				}
			}
			else {
				if (s[i] == 'o') {
					t[j] += rev[t[j][i - 1]];
				}
				else {
					t[j] += t[j][i - 1];
				}
			}
		}
	}
 
	REP(i, 4) {
		if (t[i][0] == t[i][n] && t[i][1] == t[i][n+1]) {
			cout << t[i].substr(0, n) << endl;
			return 0;
		}
	}
 
	cout << -1 << endl;
 
	return 0;
}

Measured memory_bytes: 1104
n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(10**5+1)]
ans=0
for i in range(n):
    if a[i]>10**5:
        ans+=1
    else:
        l[a[i]]+=1
for i in range(10**5+1):
    if 0<l[i]<i:
        ans+=l[i]
    if i<l[i]:
        t=l[i]-i
        ans+=t
print(ans)        

Measured memory_bytes: 20760
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
L = [LIST() for i in range(N)]

L.sort()

ans = 0
i = 0
while M > 0:
    A, B = L[i]
    if B <= M:
        ans += A * B
        M -= B
    else:
        ans += M * A
        M = 0
    i += 1
print(ans)


Measured memory_bytes: 28600
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(3));
  for (int i = 0; i<n; ++i) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  vector<vector<int>> dp(n, vector<int>(3));
  for (int i = 0; i < 3; ++i) dp[0][i] = a[0][i];
  for (int i = 0; i < n - 1; ++i) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1][0];
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + a[i + 1][1];
    dp[i + 1][2] = max(dp[i][1], dp[i][0]) + a[i + 1][2];
  }
  int res = 0;
  for (int i = 0; i < 3; ++i) res = max(res, dp[n - 1][i]);
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 11264
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
ans = 0
for i in range(1,n+1):
    prob = 1
    base = i
    while base < k:
        base *= 2
        prob /= 2
    ans += prob
print(ans/n)


Measured memory_bytes: 10144
#include <stdio.h>

//メイン関数
int main(void){
  int a, b, c;
  int count = 0;
  scanf("%d %d %d", &a, &b, &c);
  for(int i = a; i <= b; i++){
    if(c%i == 0){
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}


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

int main()
{
	int N, K;
  	cin >> N >> K;
  	int arr[101] = {0};
  	for(int i=0; i<K; i++)
    {
    	int X;
      	cin >> X;
      	for(int j=0; j<X; j++)
        {
          int a;
          cin >> a;
          arr[a]++;
        }
    }
  	int ans = 0;
  	for(int i=1; i<=N; i++)
    { if(arr[i] == 0) ans++;}
  	cout << ans;
}

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

using namespace std;

typedef long long ll;


int main() {
    long long n, x;
    cin >> n >> x;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] + a[i - 1] > x) {
            long long eat = max(a[i] + a[i - 1] - x, 0ll);
            ans += eat;
            a[i] -= min(a[i], eat);

        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind ui(n + 1);
    vector<int> p;
    unordered_map<int, int> mp;
    REP(i, n){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
        mp[i + 1] = tmp;
    }
    REP(i, m){
        int x, y;
        cin >> x >> y;
        ui.unite(x, y);
    }
    int ans = 0;
    REP(i, n){
        if(ui.find(i + 1) == ui.find(mp[i + 1])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5148
import sys

if __name__ == '__main__':
    p,z,n,k = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))

    ans = 0
    if k > p:
        ans += p
        k -= p
    else:
        print(k)
        exit()
    if k > z:
        ans += 0
        k -= z
    else:
        print(ans)
        exit()
    ans -= k
    print(ans)

Measured memory_bytes: 9136
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1112"# => "Yes",
r#"2111"# => "Yes",
r#"2112"# => "No",
r#"1221"# => "No",
// r#"24"# => "No",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: chars,
    }

    if (n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]) { "Yes" } else { "No" }.to_string()
}

Measured memory_bytes: 4352
/*@authored by: Subham Pratap*/

/* ************************************************************************************************************************** */

#include <bits/stdc++.h>
using namespace std;
#define PKMKB ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define lli long long int
#define ull unsigned long long
#define INT_MAX 2147483647
#define all(a) begin(a),end(a)
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define MOD 1000000007

/* Look Bitch, Don’t mess with any of the code from here
   to the end of the function. None of us understand it,
   and any change seems to break the program in ways
   we don’t fuckin' understand. */

  int main()
  {
    PKMKB;
        lli n,d;
        cin >> n >> d;
        lli val = d+1;
        lli count=0;
        if(n==d*2 || n<d*2)
            cout << 1 <<endl;
        else {
                lli val = d*2+1;
                for(lli i=val;i<=100;i+=val)
                {
                    //cout << i << endl;
                    if(i<n)
                        count++;
                    else if(i==n)
                        {count++;
                        break;}
                    else
                        {
                            count++;
                            break;}}

                cout << count << endl;}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
    // INPUT
    ll num_a, num_b, limit;
    cin >> num_a >> num_b >> limit;
    vector<ll> a(num_a + 1, 0), b(num_b + 1, 0);
    ll tmp;
    for (ll i = 0; i < num_a; ++i) { cin >> tmp; a[i+1] = tmp + a[i]; }
    for (ll i = 0; i < num_b; ++i) { cin >> tmp; b[i+1] = tmp + b[i]; }

    // SOURCE
    ll ans = 0;
    ll j = num_b;
    for (ll i = 0; i < num_a + 1; ++i) {
        if (a[i] > limit) break;
        while (b[j] > limit - a[i]) {
            --j;
        }
        if (ans < i + j) ans = i + j;
    }

    // OUTPUT
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 6444
N, K = map(int, input().split())
X = list(map(int,input().split()))
a = []
for i in range(N-K+1):
    l = X[i]
    r = X[i+K-1]
    a.append(min(abs(r)+abs(r-l), abs(l)+abs(l-r)))
print(min(a))

Measured memory_bytes: 14392
#include <bits/stdc++.h>
#define endl '\n'
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ios_base::sync_with_stdio(false);cout.tie(NULL);
    string s;
    cin>>s;
    cout<<s[0];
    cin>>s;
    cout<<s[0];
    cin>>s;
    cout<<s[0]<<endl;
    return 0;
}


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

int main()
{
    ll N;
    cin >> N;
    int march[5] = {0};
    char s[12];
    map<char, int> ind;
    ind['M'] = 0, ind['A'] = 1, ind['R'] = 2, ind['C'] = 3, ind['H'] = 4;

    for(ll i = 0; i < N; ++i) {
        cin >> s;
        if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
            ++march[ind[ s[0] ]];
        }
    }

    ll ans = 0;
    for(int i = 0; i < 5; ++i) {
        for(int j = i + 1; j < 5; ++j) {
            ll tmp = 1;
            for(int k = 0; k < 5; ++k) {
                if(k != i && k != j) tmp *= march[k];
            }
            ans += tmp;
        }
    }

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

Measured memory_bytes: 256
#include<cstdio>
using namespace std;

int main(){
  int n,a[200000],b[200000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if((n%2==0&&i%2==1)||(n%2==1&&i%2==0))
      b[n/2-1-i/2+(n%2)]=a[i];
    else
      b[n/2+i/2+(n%2)]=a[i];
  }
  for(int i=0;i<n;i++)
    printf("%d ",b[i]);
  printf("\n");
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s[100100];

int main(void){
	int n,i;
	ll ans = 0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	for(i=0; i<n; ++i){
		ans += (ll)(upper_bound(s,s+n,s[i])-lower_bound(s,s+n,s[i]));
	}
	ans -= n;
	ans /= 2;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define MOD 1000000007

long long dp[105][10];

int main()
{
	int h,w,k;
	cin >> h >> w >> k;

	dp[0][1]=1;

	if(w==1)
	{
		cout << 1 << endl;
		return 0;
	}

	for(int i=1;i<=h;i++)	
	{
		for(int bit=0;bit<(1<<(w-1));bit++)
		{
			bool flag=false;
			bool no=false;
			for(int j=0;j<w;j++)
			{
				if(flag and (bit&(1<<j)))no=true;
				if(bit&(1<<j))flag=true;
				else flag=false;
			}
			if(no)continue;

//			cout << bitset<8>(bit) << endl;


			for(int j=1;j<=w;j++)
			{
				// | | | |
				// |-| | |
				// | |-| |
				// | | |-|

				
				if(bit & (1<<(j-2))) dp[i][j]+=dp[i-1][j-1];
				else if(bit & (1<<(j-1))) dp[i][j]+=dp[i-1][j+1];
				else dp[i][j]+=dp[i-1][j];

/*

				if(j==1)
					dp[i][j]=(dp[i-1][1]*(w-1)+dp[i-1][2]);
				else if(j==w)
					dp[i][j]=(dp[i-1][w]*(w-1)+dp[i-1][w-1]);
				else
					dp[i][j]=(dp[i-1][j-1]+dp[i-1][j+1]+dp[i-1][j]*(w-2));
*/
	
				dp[i][j]%=MOD;
			}
		}
	}

/*
	for(int i=0;i<=h;i++)
	{
		for(int j=0;j<=w;j++)
			cout << dp[i][j] << "\t";
		cout << "\n";
	}
*/


	cout << dp[h][k]%MOD << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    vector<int> num(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> num[i];
        if (num[i] == 0)
        {
            printf("%d\n", i + 1);
            return (0);
        }
    }

    return (0);
}

Measured memory_bytes: 3720
n = int(input())
n_str = str(n)
res = ''

for i in range(2, int(n//2) + 1):
    if res == '' and i > n**0.5//1:
        res = ' {}'.format(str(n_str))
        break

    while n % i == 0:
        res += ' {}'.format(str(i))
        n //= i

    if n == 1:
        break
print('{}:{}'.format(n_str, res))



Measured memory_bytes: 5636
#include <stdio.h>

#define Max 100
#define Min 1
#define AMAX 100

int main(){
  int i,j,n,A[AMAX],minj,tmp,cnt=0;

  scanf("%d",&n);

  if(n >= Min && n <= Max)
    for(i=0; i<n; i++)
      scanf("%d",&A[i]);

  for(i=0; i<n; i++){
    minj = i;
    for(j=i+1; j<n; j++)
      if(A[j] < A[minj]) 
	minj = j;
    if(minj != i){
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
      cnt++;
    }
  }

  for(i=0; i<n; i++)
    i == n-1 ? printf("%d\n",A[i]) : printf("%d ",A[i]);

  printf("%d\n",cnt);

  return 0;
}
    
  
    



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

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

    long long num;
    std::cin >> num;
    long long res = num - 1;
    auto sqr = static_cast<long long>(sqrtl(num));
    for (long long i = sqr + 1; i > 0; --i) {
        if (num % i == 0) {
            res = (num / i) + i - 2;
            break;
        }
    }
    std::cout << res << '\n';
    return 0;
}

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

int N;
#define N_MAX 100000
long long A[N_MAX];
long long B[N_MAX];

int main(){
  cin >> N;
  long long aSum = 0;
  long long bSum = 0;
  int cnt = 0;
  long long df = 0;
  vector<long long> C;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    aSum += A[i];
//    cout << A[i] << endl;
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
    if(B[i] > A[i]){
      cnt++;
      df -= B[i] - A[i];
    } else if (A[i] > B[i]){
      C.push_back(A[i] - B[i]);
    }
    bSum += B[i];
//    cout << B[i] << endl;
  }
//  cout << df << endl;
  sort(C.begin(),C.end(),greater<long long>());
  for(int i = 0; i < C.size(); i++){
    if(df >= 0) break;
    df += C[i];
    cnt++;
 //   cout << C[i] << endl;
  }
  if(aSum < bSum){
    cnt = -1;
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 2296
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll N;cin>>N;
    ll A[N];REP(i,N)A[i]=0;
    ll m;
    REP(i,N-1){
        cin>>m;
        if(i==0)A[i]=m;
        if(A[i]>m)A[i]=m;

        A[i+1]=m;
    }
    ll ans=0;
    REP(i,N){
        ans+=A[i];
    }
    cout<<ans<<"\n";
}




Measured memory_bytes: 256