akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;
std::vector<int> X;

int calc(int p) {
  int sum = 0;
  for (const auto& x : X) {
    sum += (x-p)*(x-p);
  }
  return sum;
}

int main() {
  int N; std::cin >> N;
  X.resize(N);

  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int x; std::cin >> x;
    X[i] = x;
    sum += x;
  }

  double avg = (double)sum / N;
  int p1 = std::floor(avg);
  int p2 = std::ceil(avg);

  std::cout << std::min(calc(p1), calc(p2)) << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  
  int A,B,T;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  A=atoi(p);
  p=strtok(NULL," \n");
  B=atoi(p);
  p=strtok(NULL," \n");
  T=atoi(p);
  
  printf("%d\n",(T/A)*B);
  
 return 0; 
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 2e3+10;
const int MOD = 1e9+7;

ll N, K;
int A[MAX];


struct BIT {
    vector<ll> data;
    int N;

    BIT(int n) {
        N = n;
        data = vector<ll>(N+1);
    }

    void add(int i, ll x) {
        for (int k = i; k <= N; k += k&-k) data[k] += x;
    }

    ll sum(int i) {
        ll res = 0;
        for (int k = i; k > 0; k -= k&-k) res += data[k];
        return res;
    }
};

ll inversion(vi a) {
    BIT bit(N+10);

    ll res = 0;
    for (int i = 0; i < N; i++) {
        res += i-bit.sum(a[i]-1);
        res %= MOD;
        bit.add(a[i], 1);
    }

    return res;
}

vi compress() {
    vii c;
    REP (i, N) c.PB(MP(A[i], i));
    sort(ALL(c));
    vi res(N);
    REP (i, N) {
        res[c[i].second] = i+1;
    }
    return res;
}

ll count() {
    vi ccc(2020);
    REP (i, N) {
        ccc[A[i]]++;
    }
    ll res = 0;
    ll s = 0;
    REP (x, 2011) {
        s += ccc[x];
        res += ccc[x] * (N-s);
    }
    return res % MOD;
}

ll solve() {
    vi b = compress();
    ll res = inversion(b);
    ll c = count();
    res *= K;
    res %= MOD;
    res += c * (K * (K-1) / 2 % MOD);
    return res % MOD;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	int n;string s;
	cin>>n>>s;
	const ll md=1e9+7;
	ll r=1,p=0;
	for(int i=2;i<=n;++i)(r*=i)%=md;
	for(int i=0;i<s.size();++i){
		if((i%2==0 and s[i]=='B')or(i%2==1 and s[i]=='W'))++p;
		else (r*=p)%=md,--p;
	}
	if(p)r=0;
	cout<<r<<endl;
}

Measured memory_bytes: 888
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    int[] dp = new int[h + 1];
    Arrays.fill(dp, 2000000000);
    dp[h] = 0;
    for (int hitpoint = h; hitpoint >= 0; hitpoint--) {
      for (int i = 0; i < n; i++) {
        int damage = a[i];
        int magicPoint = b[i];
        int index = Math.max(hitpoint - damage, 0);
        dp[index] = Math.min(dp[index], dp[hitpoint] + magicPoint);
      }
    }
    System.out.println(dp[0]);
  }
}


Measured memory_bytes: 25828
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) { cin >> v.at(i); }

    sort(all(v));

    for(size_t i = 0; 1 < v.size(); i++) {
        {
            v.at(0) = (v.at(0) + v.at(1)) / 2;
            v.erase(v.begin() + 1);
            sort(all(v));
        }
    }
    rep(i, v.size()) { cout << v.at(i) << endl; }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=200010,maxm=400010;
int n,m,cnt,head[maxn];
struct edge{
    int to,next;
}edges[maxm];
bool c[maxn],sz[maxn];
char cc;
bool check(int p)
{
    bool hd;
    if(head[p]<0) return false;
    int j;
    for(j=head[p];sz[edges[j].to];j=edges[j].next);
    if(j>=0) hd=c[edges[j].to];
    for(;j>=0;j=edges[j].next) if(!sz[edges[j].to])
	{
        if(c[edges[j].to]^hd) return true;
    }
    return false;
}
void dfs(int p)
{
    sz[p]=true;
    for(int j=head[p];j>=0;j=edges[j].next)
	{
		if((!sz[edges[j].to])&&(!check(edges[j].to)))
		{
			dfs(edges[j].to);
		}
	}
}
void gi(int &x)
{
    for(cc=getchar();cc<48||cc>57;cc=getchar());
    for(x=0;cc<='9' && cc>='0';cc=getchar())
	{
		x=x*10+(cc&15);
	}
}
int main()
{
    cin>>n>>m;
	getchar();
    for(register int i=1;i<=n;i++) c[i]=(getchar()==65);
    int xx,yy;
	memset(head,-1,sizeof(head));
    for(register int i=1;i<=m;i++)
	{
        gi(xx);gi(yy);
        edges[cnt]=(edge){yy,head[xx]};
        head[xx]=cnt++;
        edges[cnt]=(edge){xx,head[yy]};
        head[yy]=cnt++;
    }
    bool flag;
    while(true)
	{
        flag=true;
	    for(int i=1;i<=n;i++)
		{
			if((!sz[i])&&(!check(i)))
			{
            	flag=false;dfs(i);
        	}
        }
		if(flag) break;
    }
    for(int i=1;i<=n;i++)
	{
		if(!sz[i])
		{
        	cout<<"Yes"<<endl;
			return 0;
    	}
    }
	cout<<"No"<<endl;
    return 0;
}

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

using namespace std;
using long64 = long long int;
using int_vec = vector<long64>;
long64 inversion = 0;


void merge(int_vec& v, int_vec& left, int_vec& right) {
    auto it = v.begin();
    auto l = left.begin();
    auto r = right.begin();
    auto n = left.size();
    while (l != left.end() && r != right.end()) {
        if (*l <= *r) {
            *it++ = *l++;
            --n;
        } else {
            *it++ = *r++;
            inversion += n;
        }
    }
    if (l != left.end()) {
        copy(l, left.end(), it);
    } else {
        copy(r, right.end(), it);
    }
    return;
}

void merge_sort(int_vec& v) {
    if (v.size() < 2) {
        return;
    }

    auto mid = v.begin() + distance(v.begin(), v.end()) / 2;
    auto left = int_vec(v.begin(), mid);
    auto right = int_vec(mid, v.end());
    merge_sort(left);
    merge_sort(right);
    merge(v, left, right);
    return;
}

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

    int_vec v;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    merge_sort(v);
    cout << inversion << endl;

    return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int MAX = 10000007;

int parent[200007];
int tam[200007];

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

void join(int a, int b){
	a = find(a);
	b = find(b);

	if(a != b){
		if(tam[a] > tam[b])
			swap(a, b);

		parent[a] = b;
		if(tam[a] == tam[b])
			tam[b]++;
	}
}

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

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

	FOR(i, n) parent[i] = i, tam[i] = 1;

	FOR(i, m){
		int a, b; cin >> a >> b;
		a--; b--;
		join(a, b);
	}

	vi cnt(n+1, 0);
	int ans = 0;
	FOR(i, n){
		int p = find(i);
		cnt[p]++;
		ans = max(ans, cnt[p]);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 5572
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

struct NODE {
  int id;
  int parent;
  int depth;
  vector<int> child;
  
  NODE() : id(), parent(-1), depth(0), child(0, 0) {}
};

static vector<NODE> TREE(100000);

static void inputNode(NODE& node, int id, int k) {
  node.id = id;

  int c;
  for (int i = 0; i < k; i++) {
    cin >> c;
    node.child.push_back(c);
  }
}

static const string ROOT = "root";
static const string INTERNAL_NODE = "internal node";
static const string LEAF = "leaf";

static const string& getNodeType(const NODE& node) {
  if (node.parent == -1) {
    return ROOT;
  } else if (node.child.size() != 0) {
    return INTERNAL_NODE;
  } else {
    return LEAF;
  }
}

static void setDepth(vector<NODE>& tree, NODE& node) {
  for (int i : node.child) {
    tree[i].depth = node.depth + 1;
    setDepth(tree, tree[i]);
  }
}

static void setup(vector<NODE>& tree, int num) {
  for (int i = 0; i < num; i++) {
    const NODE& node = tree[i];
    for (int j : node.child) {
      tree[j].parent = node.id;
      tree[j].depth = node.depth + 1;
      setDepth(tree, tree[j]);
    }
  }
}

static void printTree(const vector<NODE>& tree, int num) {
  int node, parent = -1, depth = 0;

  for (int i = 0; i < num; i++) {
    const string type = getNodeType(tree[i]);
    printf("node %d: parent = %d, depth = %d, %s, [", i, tree[i].parent, tree[i].depth, type.c_str());
    for (int j  = 0; j < tree[i].child.size(); j++) {
      if (j != 0) {
        printf(", "); 
      }
      printf("%d", tree[i].child[j]);
    }
    printf("]\n");
  }
}

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

  int id, k;
  for (int i = 0; i < n; i++) {
    cin >> id >> k;
    inputNode(TREE[id], id, k);
  }
  
  setup(TREE, n);
  printTree(TREE, n);

  return 0;
}



Measured memory_bytes: 7556
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i;
    string s;
    cin >> s;
    int count = 0;
    for (i = 0; i < 3;i++){
        if(s[i] == '1'){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int num[5];
int main(){
	for(int i=1;i<=3;i++){
		char x;
		scanf("%c",&x);
		num[x-'a']++;
	}
	for(int i=0;i<3;i++)
		if(!num[i]){
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional>
#include <iomanip>

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define MAX 20001
int p[MAX];
pair<int, int> d[MAX];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	for (int i = 1; i <= n; ++i) {
		d[i].first = i * n;
		d[i].second = n * n - i * n + n;
	}
	for (int i = 0; i < n; ++i) {
		d[p[i]].first += i+1;
	}
	for (int i = 1; i <= n; ++i) {
		if (i != 1) cout << " ";
		cout << d[i].first;
	}
	cout << endl;
	for (int i = 1; i <= n; ++i) {
		if (i != 1) cout << " ";
		cout << d[i].second;
	}
	cout << endl;
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  ll div = a+b;
  ll re = n/div;
  ll ans = a*re;
  n -= re*div;
  if(n-a>=0) ans += a;
  else ans += n;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  int n, w; // ?????????????????°??¨???
  while(cin>>n>>w,n||w) {
    int t[11]; CLR(t); // ?????????????????????????????????????????°
    int high = 0;
    int x = 0; // ?????¬?????????
    FOR(i,0,n) {
      int v; cin >> v;
      int st = 0;
      int j = 0;
      while(1) {
        if(st <= v && st + w > v) {
          t[j]++;
          high = max(high, t[j]);
          x = max(x, j);
          break;
        }
        st += w;
        j++;
      }
    }
    double ans = 0.01;
    FOR(i,0,x+1) {
      ans += double(x - i) * t[i] / double(x) / (double)high;
    }
    printf("%.10lf\n", ans);
  }
  return 0;
} 

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{
  int abcd;
  cin >> abcd;
  
  int A = (abcd / 1000) % 10;
  int B = (abcd / 100) % 10;
  int C = (abcd / 10) % 10;
  int D = abcd % 10;

  for (int i=0; i<2; i++) {
    for (int j=0; j<2; j++) {
      for (int k=0; k<2; k++) {
        int AB = (i==0 ? A+B : A-B);
        int ABC = (j==0 ? AB+C : AB-C);
        int ABCD = (k==0 ? ABC+D : ABC-D);

        if (ABCD == 7) {
          printf("%d%c%d%c%d%c%d=7\n", A, (i==0 ? '+' : '-'), B, (j==0 ? '+' : '-'), C, (k==0 ? '+' : '-'), D);
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, K;
  cin >> N >> K;
  ll cnt = 0;
  while(N != 0){
    cnt++;
    N /= K;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt(),B=sc.nextInt(),K=sc.nextInt();
		if(K>(B-A)/2){
			for(int i=A;i<B+1;i++){
				System.out.println(i);
			}
		}else{
			for(int i=A;i<A+K;i++){
				System.out.println(i);
			}
			for(int i=B-K+1;i<B+1;i++){
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 23764
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e18;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
const double pi=acos(-1);


int main(){
    TB
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=3e5+4;
const int mod=1e9+7;

ll n,pre[70][N],a,dizi[N],ans;

int main(){
//	fri("in.txt");
//	fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>dizi[i];
	}
	for(ll i=0;i<64;i++){
		pre[i][0]=0;
		for(ll j=1;j<=n+1;j++){
			pre[i][j]=(pre[i][j-1]%mod)+((dizi[j]&((ll)1<<i))!=0);
			pre[i][j]+=mod;
			pre[i][j]%=mod;
			//cout<<i<<" "<<j<<" "<<pre[i][j]<<endl;
		}
	}
	//cout<<pre[0][3]-pre[0][1]<<endl;
	for(ll i=0;i<64;i++){
		for(ll j=1;j<n;j++){
			if((dizi[j]&((ll)1<<i))!=0)ans+=(((n-(pre[i][n]-pre[i][j]+j))%mod)*(((ll)1<<i)%mod))%mod+mod;
			else ans+=(((pre[i][n+1]-pre[i][j]+mod)%mod)*((((ll)1<<i)+mod)%mod))%mod+mod;
			ans+=mod;
			ans%=mod;
		}
	}
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 153856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

class Main{

	public static void main(String[] args) {
		FastReader f = new FastReader();
		int n = ii(f);
		long[] arr = new long[n+1];
		for(int i=1; i<=n; ++i)
			arr[i] = il(f);
		long[][] dp = new long[n+1][n+1];
		for(int i=1; i<=n-1; ++i)
			dp[i][2] = Math.abs(arr[i] - arr[i+1]);
		for(int count=3; count<=n; ++count){
			for(int i=1; i<=n-count+1; ++i){
				dp[i][count] = max(arr[i] - dp[i+1][count-1], arr[i+count-1] - dp[i][count-1]);
			}
		}
		if(n == 1)
			printn(arr[1]);
		else
			printn(dp[1][n]);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static int ii(FastReader fr) {
		return fr.nextInt();
	}

	static long il(FastReader fr) {
		return fr.nextLong();
	}

	static double id(FastReader fr) {
		return fr.nextDouble();
	}

	static void printArray(Object[] arr) {
		for (Object x : arr)
			print(x, " ");
		printn("");
	}

	static void print(Object s, String sep) {
		System.out.print(s + sep);
	}

	static void printn(Object s) {
		System.out.println(s);
	}

	static long[] inputArrL(int n, FastReader fr) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = fr.nextLong();
		return arr;
	}

	static int[] inputArr(int n, FastReader fr) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = fr.nextInt();
		return arr;
	}

	static int max(int... args) {
		int max = Integer.MIN_VALUE;
		for (int x : args) {
			max = Math.max(x, max);
		}
		return max;
	}

	static int min(int... args) {
		int min = Integer.MAX_VALUE;
		for (int x : args) {
			min = Math.min(x, min);
		}
		return min;
	}

	static long max(long... args) {
		long max = Long.MIN_VALUE;
		for (long x : args) {
			max = Math.max(x, max);
		}
		return max;
	}

	static long min(long... args) {
		long min = Long.MAX_VALUE;
		for (long x : args) {
			min = Math.min(x, min);
		}
		return min;
	}

	static int lenDigit(int d) {
		if (d == 0)
			return 1;
		int l = 0;
		while (d != 0) {
			l++;
			d /= 10;
		}
		return l;
	}

	static int MOD = (int)1e9 + 7;

}



Measured memory_bytes: 168772
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	string s;
	cin >> s;
	if(s.substr(5,2) == "01") cout << "Heisei" << endl;
	else if(s.substr(5,2) == "02") cout << "Heisei" << endl;
	else if(s.substr(5,2) == "03") cout << "Heisei" << endl;
	else if(s.substr(5,2) == "04") cout << "Heisei" << endl;
	else cout << "TBD" << endl;

    //cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  const int N_max = 110;
  int d[N_max], e[N_max];

  for (int i=0; i < N_max; ++i) e[i] = 0;
  
// read
  for (int i=0; i < N; ++i) {
    cin >> d[i];
    e[d[i]] = 1;
  }
  //sort(d, d + N, greater<int>());
  int cnt = 0;
  for (int i=0; i < N_max; ++i) {
    if (e[i] > 0) ++cnt;
  }
    cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer t;
  for (t = nil->next; t != nil; t = t->next) {
    if (t->key == key) {
      return t;
    }
  }
  return nil;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  NodePointer a_del = t->next, b_del = t->prev;
  if (a_del == nil) {
    nil->prev = b_del;
    b_del->next = nil;
  } else if (b_del == nil) {
    nil->next = a_del;
    a_del->prev = nil;
  } else {
    a_del->prev = b_del;
    b_del->next = a_del;
  }
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if (t == nil) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  if (nil->prev == NULL) {
    nil->prev = x;
  }
  
  if (nil->next == NULL) {
    nil->next = x;
    x->prev = nil;
    x->next = nil;
  } else {
    nil->next->prev = x;
    x->next = nil->next;
    x->prev = nil;
    nil->next = x;
  }  
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
#include<iostream>
using namespace std;
 
int main(){
	long long a,b,c,d,ans;
    
  	cin>>a>>b>>c>>d;
  	
  	if(a*c>a*d)ans = a*c;
  	else ans=a*d;
  	if(a*d>ans)ans = a*d;
    if(b*c>ans)ans = b*c;
    if(b*d>ans)ans = b*d;
    cout<<ans;
  	
  	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <stdio.h>
int main(){
	int a,b;
	std::cin >> a;
	std::cin >> b;
	if(a!=b){
		if(a>b)
	std::cout << "a" <<" "<< ">" <<" "<< "b" << std::endl;
		else
	std::cout << "a" <<" "<< "<" <<" "<< "b" << std::endl;
	}
	else
	std::cout << "a" <<" "<< "==" <<" "<< "b" << std::endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-10;
string to_s(int n){
      string res="";
      while(n>0){
            res+=(char)(n%10+'0');
            n/=10;
      }
      reverse(ALL(res));
      return res;
}
bool ok(string s,string t){
      for(int i=0;i<=s.size()-t.size();i++){
            bool f=true;
            REP(j,t.size())if(s[i+j]!=t[j])f=false;
            if(f)return true;
      }
      return false;
}
int main(){
      string s="";
      int n;
      cin>>n;
      REP(i,n){
            int a;
            cin>>a;
            s+=(char)(a+'0');
      }
      int k=0;
      string t="0";
      if(!ok(s,t)){
            cout<<0<<endl;
            return 0;
      }
      while(1){
            t=to_s(k);
            if(!ok(s,t)){
                  cout<<k<<endl;
                  return 0;
            }
            k++;
      }
      cout<<s<<endl;
}

Measured memory_bytes: 1220
#include<iostream>

#include<set>

using namespace std; 

int main(){
  set<int> s;
  set<int>::iterator ite;
  int x;
  int cnt = 1;
  
  cin >> x;
  s.insert(x);
  
  while(-1){
    if (x%2 == 0){
        x = x/2;
    }else{
        x = 3*x+1;
    }
    ++cnt;
    ite =s.find(x);
    if (ite != s.end()) break;
    s.insert(x);
  }
  cout << cnt << endl; 
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a,b=[],[]
for i in range(n):a.append(list(map(int,input().split())))
for i in range(m):b.append(list(map(int,input().split())))
for i in range(n):
    x,y=a[i][0],a[i][1]
    c,ans=0,float("inf")
    for j in range(m):
        d=abs(b[j][0]-x)+abs(b[j][1]-y)
        if d<ans:c,ans=j+1,d
    print(c)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int concatDecimal(int a, int b)
{
    int base = (int)pow(10, floor(log10(b)) + 1);
    return a * base + b;
}
int isSquare(int i)
{
    int r = (int)floor(sqrt(i));
    return r * r == i;
}

int main()
{
    int a, b, concat;
    scanf("%d %d", &a, &b);

    concat = concatDecimal(a, b);
    if (isSquare(concat))
        puts("Yes");
    else
        puts("No");

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    string s; cin >> s;
    int cnt = 0;
    int l = s.length();

    char c[l];
    for(int i = 0; i < l; ++i){
        c[i] = s[i];
    }

    char rc[l];
    for(int i = 0; i < l; ++i){
        rc[i] = s[l-i-1];
    }

    for(int i = 0; i < l/2; ++i){
        if(c[i] != rc[i]) ++cnt;
    }

    cout << cnt << endl;

return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    string x;
    cin >> x;
    int s=0,t=0;
    int ans=x.size();
    for(int i = 0; i < x.size()-1; i++) {
        if(x[i]=='S') s++;
        else t++;

        if(x[i]=='T' && x[i+1]=='S'){
            if(t>s){
                ans -= s*2;
                s=0;t=0;
            }
            else{
                ans -= t*2;
                s -= t;
                t=0;
            }
        }
    }

    if(x[x.size()-1]=='S') s++;
    else t++;
    if(t>s){
        ans -= s*2;
        s=0;t=0;
    }
    else{
        ans -= t*2;
        s -= t;
        t=0;
    }    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3720
import itertools
import math

n = int(input())

#座標のリスト
xy_list = []
for i in range(n) :
    xy_list.append(list(map(int, input().split())))

#順列を生成
per_list = []
for j in itertools.permutations([x for x in range(n)]) :
    per_list.append(j)

#順列に従って距離を加算
d = 0
for k in per_list :
    for l in range(n - 1) :
        d += math.sqrt((xy_list[k[l + 1]][0] - xy_list[k[l]][0]) ** 2 + (xy_list[k[l + 1]][1] - xy_list[k[l]][1]) ** 2)
        
print(d/(len(per_list)))

Measured memory_bytes: 14032
#include <stdio.h>
#include <math.h>

int main(void)
{
	int N;
	
		scanf("%d", &N);
		int n = (int)sqrt((double)N);
		if ((n*n) == N) printf("%d", N);
		else{
			printf("%d", (n*n));
		}
	
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
N = int(input())
b_list = list(map(int, input().split()))
out_list = []

for i in range(N):
    ng_checker = 1
    for j in range(N - i):
        if b_list[(N - i) - (j + 1)] == (N - i) - j:
            out_list.insert(0, b_list.pop((N - i) - (j + 1)))
            ng_checker = 0
            break
    if ng_checker == 1:
        print(-1)
        break
if ng_checker != 1:
    for i in out_list:
        print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int H,W;
    
    cin >> H >> W;

    while(H || W)
    {
        for (int i = 0; i < H; i ++)
        {
            for (int j = 0; j < W; j++)
            {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }

    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <fstream>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
#define  point complex<ld>
#define Cp(a,b) ((conj(a)*b).imag())
#define Dp(a,b) ((conj(a)*b).real())
#define dist(a,b) (abs(line(a,b)))
#define angel(a) (atan2(a.Y,a.X)*360/pi)

#define X real()
#define Y imag()

#define line(a,b) (b-a)

#define endl "\n"

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N=1e5+5;
ll mod=1e9+9;
ll inf=1e18;
ld eps=1e-12;
ld pi=2*2*acos(0);
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}

int arr[305];
int co[4];
ld n;
bool vist[305][305][305];
ld dp[305][305][305];

ld solve(int co1,int co2,int co3)
{
    int total=co1+co2+co3;
    if(!total)
        return 0;

    if(vist[co1][co2][co3])
        return dp[co1][co2][co3];
    vist[co1][co2][co3]=1;

    ld co0=n-total,inf=1/(1-(co0/n));
    ld ans=1;

    if(co1)
        ans+=(ld)co1/n*solve(co1-1,co2,co3);

    if(co2)
        ans+=(ld)co2/n*solve(co1+1,co2-1,co3);
    if(co3)
        ans+=(ld)co3/n*solve(co1,co2+1,co3-1);

    return dp[co1][co2][co3]=ans*inf;

}

int main()
{
    FIO
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        co[arr[i]]++;
    }
    cout<<fixed<<setprecision(12)<<solve(co[1],co[2],co[3]);


    return 0;
}


Measured memory_bytes: 230308
#include <cstdio>

int main(int argc, char const *argv[]) {
  int A, B, C, D;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  int ab = A < B ? A : B;
  int cd = C < D ? C : D;
  printf("%d\n", ab + cd);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b;
  cin >> c >> d;
  int l  =a+b;
  int r = c+d;
  if(l>r)
    cout << "Left" << endl;
  else if(l==r)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}


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

int main() {
    long long a, b, k, takahashi, aoki;
    cin >> a >> b >> k;
    if(a >= k){
        takahashi = a - k;
        aoki = b;
    }else{
        takahashi = 0;
        aoki = b >= (k - a) ? a + b - k : 0;
    }

    cout << takahashi << " " << aoki << endl;
}

Measured memory_bytes: 256
// AOJ 2412: Village
// 2017.12.8 bal4u@uu

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

#define HASHSIZ 900007
typedef struct { long long t; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int insert(int x, int y)
{
	long long t = ((long long)x << 32) | y;
	HASH *p = hash + (int)(t % HASHSIZ);

	while (p->t) {
		if (p->t == t) return 0;
		if (++p == hashend) p = hash;
	}
	p->t = t;
	return 1;
}

int lookup(int x, int y)
{
	long long t = ((long long)x << 32) | y;
	HASH *p = hash + (int)(t % HASHSIZ);

if (x <= 0 || y <= 0) printf("x %d, y %d, t %lld\n", x, y, t);
	while (p->t) {
		if (p->t == t) return 1;
		if (++p == hashend) p = hash;
	}
	return 0;
}

#define BASE 1000010
int ans;
int mv[8][2] = {{-1,0},{0,-1},{1,0},{0,1},{-1,-1},{-1,1},{1,1},{1,-1}};
char buf[30], *p;

int getdbl()
{
	int minus = 0;
	int n = 0;

	if (*p == '-') minus = 1, p++;
	while (*p >= '0') n = (n<<3)+(n<<1) + (*p++ & 0xf);
	if (*p == '.') p++;
	while (*p >= '0') n = (n<<3)+(n<<1) + (*p++ & 0xf);
	p++;
	if (minus) n = -n;
	return n;
}

int main()
{
	int n, r, x0, y0, x, y, i;

	fgets(p=buf, 30, stdin);
	n = atoi(p); while (*p >= '0') p++; p++;
	r = getdbl();
	while (n--) {
		fgets(p=buf, 30, stdin);
#if 0
		x0 = getdbl(), y0 = getdbl();
		if (x0 < 0) x = (x0+1)/r-1; else x = x0/r;
		if (y0 < 0) y = (y0+1)/r-1; else y = y0/r;
#else
		x = BASE+getdbl()/r, y = BASE+getdbl()/r;
#endif
		if (insert(x, y)) {
			for (i = 0; ; i++) {
				if (i == 8) { ans++; break; }
				if (lookup(x+mv[i][0], y+mv[i][1])) break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8888
//解説みた
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  ll ans = 0;
  if(N % 2 == 0) {
    for(ll i = 10; i <= N; i*= 5) {
      ans += N/i;
    }
  }
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3676
while True :
    M, D = map(int, input().split())
    if M == 0 and D == 0 :
        break

    else :
        if M == 1 :
            days = D
        elif M == 2 :
            days = 31 + D
        elif M == 3 :
            days = 31+29+D
        elif M == 4 :
            days = 31+29+31+D
        elif M == 5 :
            days = 31+29+31+30+D
        elif M == 6 :
            days = 31+29+31+30+31+D
        elif M == 7 :
            days = 31+29+31+30+31+30+D
        elif M == 8 :
            days = 31+29+31+30+31+30+31+D
        elif M == 9 :
            days = 31+29+31+30+31+30+31+31+D
        elif M == 10 :
            days = 31+29+31+30+31+30+31+31+30+D
        elif M == 11 :
            days = 31+29+31+30+31+30+31+31+30+31+D
        elif M == 12 :
            days = 31+29+31+30+31+30+31+31+30+31+30+D
            
        youbi = days % 7
        if youbi == 0 :
            print("Wednesday")
        elif youbi == 1 :
            print("Thursday")
        elif youbi == 2 :
            print("Friday")
        elif youbi == 3 :
            print("Saturday")
        elif youbi == 4 :
            print("Sunday")
        elif youbi == 5 :
            print("Monday")
        elif youbi == 6 :
            print("Tuesday")


Measured memory_bytes: 5612
H,W = (int(i) for i in input().split())
A = []
for i in range(H):
    A.append(input())

numright = 0
numdown = 0
for i in range(H):
    now = A[i][0]
    for j in range(1,W):
        if now == "#" and A[i][j] == "#":
            numright += 1
        now = A[i][j]

for i in range(W):
    now = A[0][i]
    for j in range(1,H):
        if now == "#" and A[j][i] == "#":
            numdown += 1 
        now = A[j][i]

#print(numdown,numright)
if numdown == H - 1 and numright == W - 1:
    print("Possible")
else:
    print("Impossible")            

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    K = int(rl())
    A, B = map(int,rl().split())
    for i in range(A, B + 1):
        if i % K == 0:
            print("OK")
            exit()
    print("NG")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9200
/*
 * Author:  heyuhhh
 * Created Time:  2019/11/18 15:30:25
 */
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << '\n'; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
void pt() {std::cout << '\n'; }
template<typename T, typename...Args>
void pt(T a, Args...args) {std::cout << a << ' '; pt(args...); }
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 3005;

int n, t;
struct node {
    int a, b;   
    bool operator < (const node &A) const {
        return a < A.a;   
    }
}p[N];
int maxv[N];
int dp[N][N];

void run(){
    for(int i = 1; i <= n; i++) cin >> p[i].a >> p[i].b;
    sort(p + 1, p + n + 1);
    for(int i = n; i >= 1; i--) maxv[i] = max(maxv[i + 1], p[i].b);
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= t - 1; j++) {
            dp[i][j] = dp[i - 1][j];
            if(j >= p[i].a) dp[i][j] = max(dp[i][j], dp[i - 1][j - p[i].a] + p[i].b);
        }
        ans = max(ans, dp[i][t - 1] + maxv[i + 1]);
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    while(cin >> n >> t) run();
	return 0;
}

Measured memory_bytes: 35584
// inputに入力データ全体が入る
function Main(input) {

  var inp = input.split('\n');
  var N = inp[0];
  var tmp = inp[1].split(' ');
  var tmp2 = inp[2].split(' ');
  var A = new Array;
  A[0] = new Array;
  A[1] = new Array;

  // console.log(tmp2);


  for (var i = 0; i < 2; i++) {
    for (var j = 0; j < N; j++) {
      if (i === 0) {
        A[i][j] = parseInt(tmp[j]);
      } else if (i === 1) {
        A[i][j] = parseInt(tmp2[j]);
      }
    }
  }

  var maxVal = 0;
  for(var tmp = 0; tmp <= N - 1; tmp++) {
    var sum = 0;
    for (var l = 0; l <= N - 1 - tmp; l++) {
      sum += A[0][l];
    }
    for (var m = N - 1 - tmp; m <= N - 1; m++) {
      sum += A[1][m];
    }
    if (sum > maxVal) maxVal = sum;
  }
  console.log('%d', maxVal);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, W;
    cin >> n >> W;

    vl weight(n), value(n);
    rep(i, n) {
        cin >> weight[i] >> value[i];
    }

    vvl dp(n+1, vl(W+1));  // dp[i+1][j] : i番目までの品物で重さj以下のときの価値の総和の最大値
    rep(i, n) {
        rep(j, W+1) {
            chmax(dp[i+1][j], dp[i][j]);
            if(j >= weight[i]) {
                chmax(dp[i+1][j], dp[i][j - weight[i]] + value[i]);
            }
        }
    }

    out(dp[n][W]);
    re0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

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

    int x;
    cin >> x;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (v[i] + v[i - 1] > x) {
            int need = (v[i] + v[i - 1]) - x;
            ans += need;
            if (need <= v[i])
                v[i] -= need, need = 0;
            else v[i - 1] -= (need - v[i]), v[i] = 0;
        }
    }
    cout << ans << endl;
}

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

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

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;

  int n_odd = 0;
  int n_4 = 0;
  int n_2 = 0;

  rep(i, n) {
    int x; cin >> x;
    if (x % 4 == 0) n_4++;
    else if (x % 2 == 0) n_2++;
    else n_odd++;
  }

  if (n_2 >= 1) n_odd++;

  if (n_odd <= n_4 + 1) puts("Yes");
  else puts("No");

  return 0;
}


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 405;

int n;
int a[N], pre[N], memo[N][N];

int sum(int l, int r) {
	int ans = a[r];
	if (l) ans -= a[l - 1];
	return ans;
}

int dp(int l, int r) {
	if (l == r) return 0;
	int &ans = memo[l][r];
	if (ans != -1) return ans;
	ans = 1e18;
	for (int i = l; i < r; i++) {
		ans = min(ans, dp(l, i) + dp(i + 1, r) + sum(l, r));
	}
	return ans;
}

void solve() {
	int i, j, k, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i) a[i] += a[i - 1];
	}
	memset(memo, -1, sizeof(memo));
	cout << dp(0, n - 1);
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 1536
import numpy as np

K = int(input())
S = input()
S = list(S)
mojiretu=''
if len(S) <= K:
    for x in S:
        mojiretu += x
    print(str(mojiretu))

else:
    del S[K:len(S)]
    for x in S:
        mojiretu += x
    print(str(mojiretu)+'...')

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

int main(){
  int n; cin >> n;
  if(n==3){
    cout << 2 << " " << 5 << " " << 63 << endl;
    return 0;
  }
  if(n==4){
    cout << 2 << " " << 5 << " " << 63 << " " << 20 << endl;
    return 0;
  }
  if(n==5){
    cout << 2 << " " << 3 << " " << 4 << " " << 6 << " " << 15 << endl;
    return 0;
  }
  set<int> st;
  ll sum=0;
  rep1(i,30000){
    if(i%6==0||i%6==2||i%6==3||i%6==4){
      st.insert(i);
      sum+=i;
      sum%=6;
    }
    if(st.size()==n) break;
  }
  if(sum==2){
    st.erase(8);
    st.insert(30000);
  }
  if(sum==3){
    st.erase(9);
    st.insert(30000);
  }
  if(sum==5){
    st.erase(9);
    st.insert(29998);
  }
  for(auto v:st){
    cout << v << " ";
  }cout << endl;
}


Measured memory_bytes: 4568
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    int a[200][200];
    int b[200];
    int ans[200];
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>a[i][j];
        }
    }
    for(int j=0;j<M;j++){
        cin>>b[j];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            ans[i]=ans[i]+a[i][j]*b[j];
        }
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3184
n, k = map(int, input().split())
ns = list(map(int, input().split()))
mod = 10**9 + 7
dp = [[0] * (k+1) for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    b = 0
    cur = [0]
    for j in range(k+1):
        b += dp[i][j] % mod
        cur.append(b)
    for j in range(k+1):
        dp[i+1][j] = (cur[j+1] - cur[max(0, j-ns[i])]) % mod
print(dp[-1][-1]) 
    

Measured memory_bytes: 176136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int a, b;
    cin >> a >> b;
    if (abs(a - b) <= 1)
        cout << a + b << endl;
    else
        cout << max(a, b) * 2 - 1 << endl;
}


Measured memory_bytes: 256