akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int n,k;cin>>n>>k;
	vector<bool>vst(n+1,false);
	f(i,k)	
	{
		int d;cin>>d;
		f(j,d)
		{
			int a;
			cin>>a;
			vst[a]=true;
		}
	}
	int ans=0;
	ff(i,n)
	{
		if(!vst[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define N 100005
#define LL long long
using namespace std;
int n,m,f[N],sz[N],w[N],cir[N],A,B,C;
int find(int x){ while(f[x]) x=f[x]; return x;}
int path(int x){ int s=0; while(f[x]) s^=w[x],x=f[x]; return s;}
int main()
{
	int i,x,y,p,q;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++) sz[i]=1;
	while(m--){
		scanf("%d %d",&x,&y);
		p=find(x),q=find(y);
		if(sz[p]<sz[q]) swap(p,q);
		if(p!=q)
			w[q]=path(x)^path(y)^1,f[q]=p,cir[p]|=cir[q],sz[p]+=sz[q];
		else{
			if(path(x)^path(y)) continue;
			else cir[p]=1;
		  }
	  }
	for(i=1;i<=n;i++)
		if(find(i)==i){
			if(sz[i]==1) C++;
			else if(cir[i]) A++;
			else B++;
		  }
	LL ans=1LL*C*C+2LL*C*(n-C)+2LL*A*B+1LL*A*A+2LL*B*B;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int a,b; cin>>a>>b;
  rep(i,max(a,b))cout<<min(a,b);
  cout<<endl;
}

Measured memory_bytes: 3556
package main

import "fmt"

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

func main() {
	var n int
	fmt.Scan(&n)

	a := make([][]int, 3)
	for i := 0; i <= 2; i++ {
		a[i] = make([]int, n+5)
	}

	for i := 1; i <= 2; i++ {
		for j := 1; j <= n; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	dp := make([][]int, 3)
	for i := 0; i <= 2; i++ {
		dp[i] = make([]int, n+5)
	}

	for i := 1; i <= 2; i++ {
		for j := 1; j <= n; j++ {
			if i == 1 {
				dp[i][j] = dp[i][j-1] + a[i][j]
				continue
			}
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + a[i][j]
		}
	}

	fmt.Println(dp[2][n])
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

const ll mod = 1e9+7;

ll f(ll x) {
  ll res = 1;
  REP(i,x+1) {
    res *= i;
    res %= mod;
  }
  return res;
}

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

  ll n, m;
  cin >> n >> m;
  if(abs(n-m) > 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = f(n) * f(m) % mod;
  if(n == m) ans *= 2;
  ans %= mod;
  cout << ans << endl;
}

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

int main(){
string s;
char ary[4];
bool f=0;
for(int i=0; i<4; i++){
cin >> ary[i];
}
int cnt=0;
for(int i=0; i<4; i++){//全ての要素が等しいか 
if(ary[0]==ary[i]) cnt++; //全ての要素が等しい時4になる
}
  if(ary[0]==ary[1] && ary[2]==ary[3]) f=1;  //aabb
else if(ary[0]==ary[2] && ary[1]==ary[3])f=1; //abab
  else if(ary[0]=ary[3] && ary[1]==ary[2]) f=1; //abba

  if(cnt==4) cout <<"No" <<endl;
else if(f)cout <<"Yes" <<endl;
else cout <<"No" <<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr uint64_t INF = 1e18;

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

  int32_t X, Y;
  cin >> X >> Y;
  if ( Y - 2*X < 0 || (Y- 2*X) % 2 != 0) {
    cout << "No" << endl;
  } else if (X < (Y - 2 * X) / 2 ){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 3648
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

S = sum(A)
cnt = 0
for a in A:
    cnt += a * 4 * M >= S
if cnt >= M:
    print('Yes')
else:
    print('No')


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

using namespace std;

//#define FILE_IO

int N, M;
int v[100005];
int f[100005];

class normalizator
{
private:
    vector <int> ord;
    map <int, int> mp;

public:
    void add(int x)
    {
        if(mp.count(x)) return;
        mp[x];
        ord.push_back(x);
    }

    int getSmall(int x)
    {
        if(!mp.count(x))    return -1;
        return mp[x];
    }

    int getBig(int x)
    {
        return ord[x - 1];
    }

    void normalize()
    {
        sort(ord.begin(), ord.end());
        int cnt = 0;
        for(auto x: ord)
            mp[x] = ++cnt;
    }
}nrm;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);

    int mn = 1 << 30;
    int pf = 0;
    for(int i = 1; i <= N; i++)
    {
        scanf("%d", &v[i]);
        mn = min(mn, v[i]);
        pf = max(pf, v[i] - mn);
        nrm.add(v[i]);
    }

    nrm.normalize();

    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        f[ nrm.getSmall(v[i]) ]++;
        int id = nrm.getSmall(v[i] - pf);
        if(id == -1)    continue;
        ans += f[id];
        f[id] = 0;
    }

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

    return 0;
}


Measured memory_bytes: 6136
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    while (1) {
        if (a / 100 == a / 10 % 10 && a / 10 % 10 == a % 10) break;
        a++;
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e10
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using lli = long long int;
template<typename T> bool chmax(T &a, T &b){ if(a<b) { a=b; return 1; }}
template<typename T> bool chmin(T &a, T &b){ if(b<a) { a=b; return 1; }}
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T arrdebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    lli n, m, buf;
    vector<lli> x;
    cin >> n >> m;
    rep(i, m){
        cin >> buf;
        x.push_back(buf);
    }

    vsort(x);

    if(x.size() == 1){
        cout << 0 << endl;
        return 0;
    }

    vector<lli> xdiff;
    rep(i, x.size()-1){
        xdiff.push_back(x[i+1]-x[i]);
    }

    vsort(xdiff);

    lli sum=0;
    lli len = xdiff.size()-(n-1);
    if(len < 0){
        cout << 0 << endl;
        return 0;
    }

    rep(i, len){
        sum += xdiff[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1E9 + 9;
const int INF = 1<<29; 

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= b){
        rep(i, a) cout << b;
    }else{
        rep(i, b) cout << a;
    }
}

Measured memory_bytes: 256
/* 
* ID: juryc
* PROG: Ibis vs monster
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int h; cin>>h; int n; cin>>n;
vector<int> a(n),b(n);
for(int i=0;i<n;i++) cin>>a[i]>>b[i]; 
vector<int> dp(h+1,0x3f3f3f3f); 
dp[0]=0;
for(int i=1;i<=h;i++){
for(int j=0;j<n;j++){
if(a[j]>i){dp[i]=min(dp[i],b[j]); }
else dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
}
}
cout<<dp[h]<<"\n";
return 0;
} 

Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
  int m,l,n;
  scanf("%d%d%d",&n,&m,&l);
  int i,j,k;
  long int list,list1[n][m],list2[m][l];

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%ld",&list1[i][j]);
    }
  }
  for(j=0;j<m;j++){
    for(k=0;k<l;k++){
      scanf("%ld",&list2[j][k]);
    }
  }
  for(i=0;i<n;i++){
    for(k=0;k<l;k++){
      list=0;
      for(j=0;j<m;j++){
        list+=list1[i][j]*list2[j][k];
      }
      printf("%ld",list);
      (k!=l-1)?printf(" "):printf("");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator
 
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
 
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
 
int32_t main()
{
    fast;
    string s;cin>>s;
    int cnt=count(all(s),'7');
    if(cnt)
        cout<<"Yes";
    else
        cout<<"No";
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  string T;
  for (int i = 0; i < N / 2; ++i) T += S[i];
  T += T;
  
  if (S == T) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
K,N= list(map(int, input().split()))
A= list(map(int, input().split()))
max = 0
for i in range(1,N):
    if max < A[i]-A[i-1]:
        max = A[i]-A[i-1]
if max < K - A[N-1] + A[0]:
    max = K - A[N-1] + A[0]

print(K-max)

Measured memory_bytes: 25840
#include<cstdio>
using namespace std;
int i,j,n,tot,ans;
int a[105][3],b[105][3],last[105],des[10005],prev[10005],vis[105],mat[105];
bool dfs(int x)
{
	for (int j=last[x];j;j=prev[j])
		if (vis[des[j]]!=i)
		{
			vis[des[j]]=i;
			if ((!mat[des[j]])||(dfs(mat[des[j]])))
			{
				mat[des[j]]=x;
				return true;
			}
		}
	return false;
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d%d",&a[i][1],&a[i][2]);
	for (i=1;i<=n;i++)
		scanf("%d%d",&b[i][1],&b[i][2]);
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if ((a[i][1]<b[j][1])&&(a[i][2]<b[j][2]))
			{
				des[++tot]=j;
				prev[tot]=last[i];
				last[i]=tot;
			}
	for (i=1;i<=n;i++)
		if (dfs(i))
			ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {   
    int n, a, b;
    cin >> n >> a >> b;
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < n; i++ ) {
        int p;
        cin >> p;
        if (p <= a) {
            c1++;
        } else if (p <= b) {
            c2++;
        } else {
            c3++;
        }
    }
    cout << min(c1, min(c2, c3)) << endl;
}




Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s;
	cin>>s;
	ll i,j,k,l,n=s.length();
	string a,b;
	a=s;
	b=s;
	reverse(all(b));
	if(a!=b){
		cout<<"No";return 0;
	}
	a="";
	for(i=0;i<(n-1)/2;i++){
		a+=s[i];
	}
	//cout<<a<<endl;
	b=a;
	reverse(all(b));
	if(a!=b){
		cout<<"No";return 0;
	}

	a="";
	for(i=(n+3)/2-1;i<n;i++){
		a+=s[i];
	}
	//cout<<a<<endl;
	b=a;
	reverse(all(b));
	if(a!=b){
		cout<<"@No";return 0;
	}
	cout<<"Yes";	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

const int maxn = 102;
const int maxm = 100002;
const int mo = 1e9 + 7;

int n, m, a[maxn], sum[maxn];
long long f[maxn][maxm];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum[i] = sum[i-1] + a[i];
	}

	if (sum[n] < m) {
		cout << 0 << endl;
		return 0;
	}

	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		f[i][0] = 1;
		for (int j = 1; j <= sum[i] && j <= m; ++j) {
			f[i][j] = f[i][j-1] + f[i-1][j];
			
			if (j > a[i])
				f[i][j] -= f[i-1][j-1-a[i]];

			f[i][j] %= mo;
			if (f[i][j] < 0)
				f[i][j] += mo;
		}
	}
		
			// for (int k = 0; k <= a[i] && k <= j; ++k) {
			// 	f[i][j] += f[i-1][j-k];
			// 	if (f[i][j] >= mo)
			// 		f[i][j] -= mo;
			// }

	cout << f[n][m] << endl;

	return 0;
}

Measured memory_bytes: 78336
#include <iostream>

using namespace std;
static const int MAX = 100;
static const int INF = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; ++i) {
        d[i] = INF;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (true) {
        minv = INF;
        u = -1;
        for (int i = 0; i < n; ++i) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }

        if (u == -1)
            break;

        color[u] = BLACK;
        for (int v = 0; v < n; ++v) {
            if (color[v] != BLACK && M[u][v] != INF) {
                if (d[v] > M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        if (p[i] != -1)
            sum += M[i][p[i]];
    }

    return sum;
}

int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int e;
            cin >> e;
            M[i][j] = e == -1 ? INF : e;
        }
    }

    cout << prim() << endl;

    return 0;
}

Measured memory_bytes: 3072
import heapq

h,w = (int(x) for x in input().split())
seq = []
white = 0
for i in range(h):
    seq.append(input())
    white += seq[-1].count('.')

MOVES = ((-1, 0), (1, 0), (0, 1), (0, -1))
visited = set()

final = (w-1, h-1)
stack = []
heapq.heappush(stack, ((0,0), 1))
ans = -1
while stack:
    state, cost = heapq.heappop(stack)
    if state == final:
        ans = white - cost
        break
    
    if state not in visited:
        x,y = state
        visited.add(state)
        for dx,dy in MOVES:
            xnew = x + dx
            ynew = y + dy
            
            if xnew >= 0 and ynew >=0 and xnew < w and ynew < h and seq[ynew][xnew] == '.':
                heapq.heappush(stack, ((xnew, ynew),cost+1))

print(ans)

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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
int N, X, T;
  cin >> N >> X >> T;

  int a = ceil((double)N / (double)X);
  cout << a * T << endl;

  return 0;
}


Measured memory_bytes: 3632
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if a[i] > x:
        ans += a[i]-x
        a[i] = x
    if a[i]+a[i+1] > x:
        ans += a[i+1] + a[i] -x
        a[i+1] = x - a[i]
# print(a)
print(ans)

Measured memory_bytes: 19916
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (t, x) = listOfFloat()
    println(t/x)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfFloat()= listOfString().map { it.toFloat() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37872
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long

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

  int c=0;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    c = c^a;
  }

  if(c==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    show(x, y, z);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    string w;
    cin >> w;
    bool ok = true;
    for (char c='a';c<='z';c++){
        if (count(w.begin(),w.end(),c)%2 != 0) ok = false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SHOW(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
int main()
{
    ll t;
    std::cin >> t;
    ll min = t;
    for (ll max = 1; max <= t; max *= 3LL) {
        ll need = 1 + max;
        ll tim  = 2;
        for (ll t = 3; t < max; t *= 3) { need += t * 2LL, tim += 2; }
        if (need > t) { continue; }
        ll res = t - need;
        for (ll seg = max; seg >= 1; seg /= 3) {
            tim += res / seg;
            res %= seg;
        }
        min = std::min(min, tim);
    }
    std::cout << min << std::endl;
    return 0;
}



Measured memory_bytes: 3124
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    //const k = parseInt(arg.slice(5, 6));
    //const k = parseInt(arg.pop());
    //const antennas = arg.slice(0,5).map(n=>parseInt(n));//arg.map(n=>parseInt(n));
    
    const k = parseInt(arg.slice(5, 6));
    const antennas = arg.slice(0, 5).map(n=>parseInt(n));
    
    for(let i=0; i<antennas.length; i++) {
        for(let j=i+1; j<antennas.length; j++) {
            if(antennas[j] - antennas[i] > k) {
                console.log(":(");
                return;
            }   
        }
    }
    
    console.log("Yay!");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int[] l = new int[n];
    for(int i=0;i<n;i++)l[i]=sc.nextInt();
    int min = (int)Math.pow(10,9);
    for(int i=0;i<=Math.pow(4,n)-1;i++){
      int sumA = 0;
      int cntA = 0;
      int sumB = 0;
      int cntB = 0;
      int sumC = 0;
      int cntC = 0;
      StringBuilder sb = new StringBuilder();
      String s = Integer.toString(i,4);
      for(int j=1;j<=n-s.length();j++)sb.append("0");
      sb.append(s);
      for(int j=0;j<sb.length();j++){
        if(sb.charAt(j)=='1'){
          sumA+=l[j];
          cntA++;
        }else if(sb.charAt(j)=='2'){
          sumB+=l[j];
          cntB++;
        }else if(sb.charAt(j)=='3'){
          sumC+=l[j];
          cntC++;
        }
      }
      if(sumA>0&&sumB>0&&sumC>0){
        int mp = (cntA-1)*10+(cntB-1)*10+(cntC-1)*10+Math.abs(a-sumA)+Math.abs(b-sumB)+Math.abs(c-sumC);
        min = Math.min(min,mp);
      }
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 38688
using System.Linq;
public class Hello{
    public static void Main(){
        
        var line = System.Console.ReadLine();
        int n = line.Length;
        string result = "";
        
        var linerev = new string(line.Reverse().ToArray());
        if(line == linerev)
        {
            string cut = line.Substring(0,(n - 1)/2);
            var cutrev = new string(cut.Reverse().ToArray());
            
            if(cut == cutrev)
            {
                result = "Yes";
            }
            else
            {
                result = "No";
            }
        }
        else
        {
            result = "No";
        }
        
        System.Console.WriteLine(result);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

bool dfs(Graph& g, Array& used, ll v,ll pre) {
	used[v] = true;
	for (auto e : g[v]) {
		if (e.to != pre) {
			if (used[e.to]) {
				return false;
			}
			else {
				if (!dfs(g, used, e.to, v)) {
					return false;
				}
			}
		}
	}
	return true;
}

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

	ll n, m;
	cin >> n >> m;
	Matrix map(n, Array(n, false));
	
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		map[a][b] = true;
		map[b][a] = true;
	}

	Array order(n-1,0);
	REP(i, n - 1) order[i] = i + 1;

	ll ans = 0;
	do {
		bool flag = true;
		ll u = 0;
		REP(i, n - 1) {
			ll v = order[i];
			if (map[u][v] ==false) {
				flag = false;
				break;
			}
			u = v;
		}
		if (flag)ans++;
	
	} while (next_permutation(all(order)));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int judge(int a, int b, int c);

int main()
{
	int a, b, c;
	int N;
	int i = 0;
	int m;
	
	scanf("%d", &N);
	
	while (i < N){
		scanf("%d %d %d", &a, &b, &c);
		if (b > a && b > c){
			m = a;
			a = b;
			b = m;
		}
		else if (c > a && c > b){
			m = a;
			a = c;
			c = m;
		}
		
		if (judge(a, b, c) == 1){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		i++;
	}
	
	return (0);
}

int judge(int a, int b, int c)
{
	if ((a * a) == (b * b) + (c * c)){
		return (1);
	}
	return (0);
}

Measured memory_bytes: 580
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N, K = ri_()
A = ri_()
d = [0] * N
d[0] = 1
cnt = 1
loop = 0
now = 0
while True:
    now = A[now] - 1
    if d[now]:
        loop = cnt - d[now] + 1
        break
    else:
        cnt += 1
        d[now] = cnt
ans = 0
for i in range(N):
    if d[i] == min(d[now] + (K - cnt) % loop, K + 1):
        ans = i + 1
print(ans)

Measured memory_bytes: 95020
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 + (y1 - y2)
y3 = y2 - (x1 - x2)
x4 = x1 + (y1 - y2)
y4 = y1 - (x1 - x2)
print(x3,y3,x4,y4)

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

int main(void){
    int N,K; cin >> N >> K;
    vector<int> A(N), cnt(N+1);
    for(int i=0; i<N; i++) cin >> A[i];

    for(int i=0; i<N; i++) cnt[A[i]]++;

    sort(cnt.begin(), cnt.end(), greater<int>());

    int unchange=0;
    for(int i=0; i<K; i++) unchange+=cnt[i];

    cout << N-unchange << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long A, B, C;
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << endl;
	else cout << min({ A * B, B * C, C * A }) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    
    vector<int> x(4, 0);
    vector<int> y(4, 0);
    
    for(int i=0; i<2; i++){
        cin >> x[i];
        cin >> y[i];
    }
    
    cout << x[1]-(y[1]-y[0]) << " ";
    cout << y[1]+(x[1]-x[0]) << " ";
    cout << x[0]-(y[1]-y[0]) << " ";
    cout << y[0]+(x[1]-x[0]) << endl;
    
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	n %= 10;
	if (n == 3) cout << "bon";
	else if (n == 0 or n == 1 or n == 6 or n == 8) cout << "pon";
	else cout << "hon";
	return 0;
}

Measured memory_bytes: 3632
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))
C=[0]+list(map(int,input().split()))

X=0
for i in range(1,N+1):
    X+=B[i]

    if A[i-1]+1==A[i]:
        X+=C[A[i-1]]
print(X)

Measured memory_bytes: 62016
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int dp[1000000];

void dfs(vector<int>adj[],int vis[],int node){
    if(vis[node]) return;
    vis[node] = 1;
    for(int i=0;i<adj[node].size();i++){
        int x = adj[node][i];
        if(!vis[x]) dfs(adj,vis,x);
        dp[node] = max(dp[node],dp[x]+1); 

    }

}
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>adj[n+1];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    memset(dp,0,sizeof(dp));
    int vis[n+1];
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++){
        if(!vis[i]) dfs(adj,vis,i);
    }
    int mx=0;
    for(int i=1;i<=n;i++) mx = max(dp[i],mx);
    cout<<mx<<endl;
    
}

Measured memory_bytes: 16540
package main

import "fmt"

type Point struct {
	x int
	y int
}

const max = 1000000001

func abs(a int, b int) (c int) {
	c = a - b
	if c < 0 {
		return -c
	} else {
		return c
	}
}

func man(p Point, q Point) int {
	return abs(p.x, q.x) + abs(p.y, q.y)
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	s := make([]Point, n)
	for i:=0; i<n; i++ {
		fmt.Scan(&s[i].x, &s[i].y)
	}
	c := make([]Point, m)
	for i:=0; i<m; i++ {
		fmt.Scan(&c[i].x, &c[i].y)
	}
	for _, p := range s {
		min_p := 1
		min := max
		for i, q := range c {
			t := man(p, q)
			if min > t {
				min_p = i
				min = t
			}
		}
		fmt.Println(min_p+1)
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 15;
const int M = 1005;

int n, m, k;
char a[N][M];
int cur[N], temp[N];

int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> a[i][j];
	int ans = 1e9;
	for(int mask = 0; mask < (1 << (n - 1)); mask++)
	{
		int cuts = __builtin_popcount(mask);
		memset(cur, 0, sizeof(cur));
		int flag = 1;
		for(int j = 0; j < m && flag; j++)
		{
			int idx = 0;
			memset(temp, 0, sizeof(temp));
			for(int i = 0; i < n; i++)
			{
				temp[idx] += (a[i][j] - '0');
				if(mask >> i & 1)
					idx++;
			}
			for(int j = 0; j < n; j++)
			{
				if(temp[j] > k)
				{
					flag = 0;
					break;
				}
			}
			bool mark = 0;
			for(int j = 0; j < n; j++)
			{
				if(cur[j] + temp[j] > k)
					mark = 1;
			}
			cuts += mark;
			if(mark)
			{
				for(int j = 0; j < n; j++)
					cur[j] = temp[j];
			}
			else
			{
				for(int j = 0; j < n; j++)
					cur[j] += temp[j];
			}
		}
		if(flag)
			ans = min(ans, cuts);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
package main


import (
    "fmt"
)

func main() {
  var N int
  var S string

  var res string = "Three"

  fmt.Scan(&N)

  for i := 0; i < N; i++ {
    fmt.Scan( &S )

    if S == "Y" {
      res = "Four"
    }
  }

    fmt.Println(res)

}


Measured memory_bytes: 512
import math

N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N - 1)]

for i in range(N):
    t = 0

    for c, s, f in CSF[i:]:
        # 待ち時間
        if t < s:
            t = s
        else:
            t = math.ceil((t - s) / f) * f + s

        # i -> i+1に移動
        t += c

    print(t)


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
deque<int> fr,se;
void solve(int num,long long v){
	if(v==0) return;
	if(v&1){
		solve(num+1,v>>1);
		fr.push_front(num),se.push_front(num);
	}else{
		solve(num+1,v-1);
		fr.push_back(num),se.push_front(num);
	}
}
long long N;
int main(){
    cin>>N;
    solve(1,N);
    printf("%d\n",fr.size()+se.size());
    while(!fr.empty()) printf("%d ",fr.front()),fr.pop_front();
    while(!se.empty()) printf("%d ",se.front()),se.pop_front();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s[2];
    cin >> s[0] >> s[1] ;
    if(s[0]<s[1]){
        cout << "<" << endl;
    }else if(s[0]>s[1]){
        cout << ">" << endl;
    }else{
        cout << "=" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int n,m,q;
vi a,b,c,d;
int ans = 0;
void solve(vi v){
	if(v.size()==n){
		int sum = 0;
		for(int i = 0; i < q; i++){
			if(v[b[i]] - v[a[i]] == c[i]){
				sum+=d[i];
			}
		}	
		ans = max(ans,sum);
	}
	else{
		int st = 1;
		if(v.size()) st = v.back();
		for(int i = st; i <= m; i++){
			v.push_back(i);
			solve(v);
			v.pop_back();
		}
	}
}
int main(){
	cin>>n>>m>>q;	
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	for(int i  = 0; i < q; i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;
		b[i]--;
	}
	solve(vi());
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main()
{
    long long sum,n,m;
    while(scanf("%lld%lld",&n,&m)!=EOF)
    {
        if(n*2>=m)
            printf("%lld\n",m/2);
        else
            printf("%lld\n",n+(m-n*2)/4);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> a, std::vector<long long> b){
  vector<vector<ll>> mp(N);
  REP(N-1){
    mp[a[i]].push_back((b[i]));
    mp[b[i]].push_back((a[i]));
  }
  map<pll,ll> ans;
  ll K=0;
  queue<pll> q;
  q.push(pll(0,-1));
  ans[pll(0,-1)]=-1;
  while(!q.empty()){
    ll color=1;
    pll tmp=q.front();q.pop();
    if(color==ans[tmp]){
      ++color;
    }
    for (auto &&j : mp[tmp.first])
    {
      if(j==tmp.second)
        continue;
      q.push(pll(j,tmp.first));
      ans[pll(j,tmp.first)]=ans[pll(tmp.first,j)]=color;
      K=max(K,color);
      ++color;
      if(color==ans[tmp]){
        ++color;
      }
    }
  }
  cout<<K<<endl;
  REP(N-1){
    cout<<ans[pll(a[i],b[i])]<<endl;
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        --a[i];
        --b[i];
    }
    solve(N, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 20608
#include <stdio.h>

int main()
{
	int a, h;
	scanf("%d %d", &h, &a);
	int b = h / a;
	if(h % a == 0){
		printf("%d\n", b);
	}else{
		printf("%d\n", b + 1);
	}
	return 0;
}

Measured memory_bytes: 128
//2019年12月8日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElms(&a[0], a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


string maze[105];
int dp[105][105];
int main(){
	int h,w;
	cin >> h >> w;
	rep(i,h) cin >> maze[i];
	rep1(i,h-1){
		if(maze[i][0] =='#' && maze[i-1][0] =='.'){
			dp[i][0] = dp[i-1][0]+1;
		}
		else{dp[i][0] = dp[i-1][0];}
	}
	rep1(i,w-1){
		if(maze[0][i] =='#' && maze[0][i-1] =='.'){
			dp[0][i] = dp[0][i-1]+1;
		}
		else{dp[0][i] = dp[0][i-1];}
	}

	rep1(i,h-1)rep1(j,w-1){
		int tmp = 0;
		if(maze[i][j]=='#' &&maze[i][j-1] =='.'){
			tmp = dp[i][j-1]+1;
		}
		else{tmp = dp[i][j-1];}
		// prints(tmp);
		if(maze[i][j] =='#' && maze[i-1][j] =='.'){
			tmp = min(tmp,dp[i-1][j]+1);
		}
		else{tmp = min(tmp,dp[i-1][j]);}
		dp[i][j] = tmp;
	}

	// if(maze[0][0] == '.' && maze[h-1][w-1] == '.'){
	// 	dp[h-1][w-1]=max(dp[h-1][w-1]-1,0);
	// }

	if(maze[0][0] == '#'){
		dp[h-1][w-1]++;
	}

	// rep(i,h){
	// 	printElems(&dp[i][0], &dp[i][w]);
	// }

	prints(dp[h-1][w-1]);

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
     
    int main(){
      int n,a[2][100],i,sum=0,max=0,j;
      scanf("%d",&n);
      for(i=0;i<n;i++)
        scanf("%d",&a[0][i]);
      for(i=0;i<n;i++)
        scanf("%d",&a[1][i]);
      for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<n;j++){
          if(j<=i)
            sum+=a[0][j];
          if(j>=i)
            sum+=a[1][j];
        }
        if(max<sum) max=sum;
      }
      printf("%d\n",max);
    }

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
vector<long long> kouho;
void dfs(long long now,bool a,bool b,bool c){
	if(now>=1e9+7){
		return;
	}
	if(a&&b&&c){
		kouho.push_back(now);
	}
	dfs(now*10+3,a|1,b,c);
	dfs(now*10+5,a,b|1,c);
	dfs(now*10+7,a,b,c|1);
}
int main(){
	long long n;
	cin>>n;
	dfs(3,1,0,0);
	dfs(5,0,1,0);
	dfs(7,0,0,1);
	int ans=0;
	for(int i=0;i<kouho.size();i++){
		if(kouho[i]<=n){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	long long a,b,m,minA= 1000000,minB = 1000000,ans;
	cin >> a >> b >> m;

	vector<long long> A(a), B(b);
	vector<vector<long long>> M(m, vector<long long>(3));

	for (long long i = 0; i < a; i++)
		cin >> A[i];
	for (long long i = 0; i < b; i++)
		cin >> B[i];

	for (long long i = 0; i < m; i++)
		for (long long j = 0; j < 3; j++)
			cin >> M[i][j];

	for (long long i = 0; i < m; i++)
		for(long long j =0;j<2;j++)
			M[i][j]--;

	for (long long i = 0; i < A.size(); i++)
		if (minA > A[i])
			minA = A[i];

	for (long long i = 0; i < B.size(); i++)
		if (minB > B[i])
			minB = B[i];

	ans = minA + minB;
	
	for (long long i = 0; i < M.size(); i++)
	{
		if (A[M[i][0]] + B[M[i][1]] - M[i][2] < ans)
			ans = A[M[i][0]] + B[M[i][1]] - M[i][2];
	}
	

	cout << ans<< endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define N 103
#define MAXW 100005
using namespace std;

int n, W, w[N], v[N];
long long f[N][MAXW];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> W;
    for (int i = 1; i <= n; ++i)
        scanf("%d%d", w + i, v + i);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= W; ++j) {
            f[i][j] = f[i - 1][j];
            if (j >= w[i])
                f[i][j] = max(f[i][j], f[i - 1][j - w[i]] + v[i]);
        }
    cout << f[n][W] << endl;
    return 0;
}


Measured memory_bytes: 79360