akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	y := make([]int, n)

	for i:=0; i<len(x); i++{
		fmt.Scan(&x[i])
	}
	for i:=0; i<len(y); i++{
		fmt.Scan(&y[i])
	}

	d1 := 0.0
	d2 := 0.0
	d3 := 0.0
	dinf := 0.0
	for i := 0; i < n; i++ {
		xi := float64(x[i])
		yi := float64(y[i])

		absi := math.Abs(xi - yi)
		d1 += absi
		d2 += math.Pow(absi, 2)
		d3 += math.Pow(absi, 3)
		dinf = math.Max(dinf, absi)
	}

	fmt.Println(d1)
	fmt.Println(math.Sqrt(d2))
	fmt.Println(math.Pow(d3, 1.0/3.0))
	fmt.Println(dinf)
}


Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define lb lower_bound
using namespace std;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k-1];

}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  
  int count=0;
  for (int i=0;i<N;i++){
    if (v[i]>=K)
      count++;
  }
  cout << count << endl;
}

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

int main(){
	vector<int>s(10);
	for(int a=0;a<10;a++)cin>>s[a];
	sort(s.begin(),s.end());
	cout<<s[9]<<endl;
	cout<<s[8]<<endl;
	cout<<s[7]<<endl;
	}

Measured memory_bytes: 3092
from fractions import gcd
A,B,C,D = map(int, input().split())
Cs = B//C - A//C
if A%C == 0:
    Cs += 1
Ds = B//D - A//D
if A%D == 0:
    Ds += 1
lcm = C*D//gcd(C,D)
CandDs = B//lcm - A//lcm
if A%lcm == 0:
    CandDs += 1
ans = (B - A + 1) - Cs - Ds + CandDs
print(ans)

Measured memory_bytes: 5344
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
vector<int> dp(70000,1e+9);

int main(){
  int n,m,c[30]={};
  cin >> n >> m;
  rep(i,m) cin >> c[i];
  dp[0] = 0;
  
  rep(i,50010){
    rep(j,m){
      dp[i+c[j]] = min(dp[i+c[j]], dp[i]+1);
    }
  }
  cout << dp[n] << endl;
}



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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int n,k;cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	sort(v.begin(),v.end());
	ll sum=0;
	for(int i=0;i<k;i++) sum+=v[i];
	cout<<sum;


}

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

int n,s,res;

void dfs(int decided, int i, int sum){
  if(decided == n){
    if (sum == s) res++;    
    return;
  }

  //0~9を選り好みしてn個決められなかったとき終了
  if(i > 9) return;

  //iを足さない
  dfs(decided,i+1,sum);

  //iを足す
  dfs(decided+1,i+1,sum+i);
}


int main(){
  while(true){
    res = 0;
    cin >> n >> s;
    if(n == 0 && s == 0) break;
    dfs(0,0,0);
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=2147483647;
const ll inf=1e16;
const ll ms=(100000) +5;

int ar[4][4];

int main()
{
    idfc;
    int i,j;
    for(i=1;i<=3;i++)for(j=1;j<=3;j++)cin>>ar[i][j];
    int n;
    cin>>n;
    int e;
    while(n--)
    {
        cin>>e;
        for(i=1;i<=3;i++){for(j=1;j<=3;j++){if(ar[i][j]==e)
                {
            ar[i][j]=-1;
                }}}


    }
    for(i=1;i<=3;i++)
    {
        if(ar[i][1]==-1&&ar[i][2]==-1&&ar[i][3]==-1)
        {
            cout<<"Yes";return 0;
        }
    }
    for(i=1;i<=3;i++)
    {
        if(ar[1][i]==-1&&ar[2][i]==-1&&ar[3][i]==-1)
        {
            cout<<"Yes";return 0;
        }
    }
    if(ar[1][1]==-1&&ar[2][2]==-1&&ar[3][3]==-1)
    {
        cout<<"Yes";
        return 0;
    }
    if(ar[1][3]==-1&&ar[2][2]==-1&&ar[3][1]==-1)
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

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

int main(){
  string s,t;
  int ans=1e9;cin>>s>>t;
  REP(i,s.size()-t.size()+1){
    int tmp=0;
    REP(j,t.size()){
      if(s.at(i+j)!=t.at(j)) tmp++;
    }
    ans=min(ans,tmp);
  }

  cout<<ans;
}

Measured memory_bytes: 3628
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	int n = s.size();
	int cnt = 0;
	int ans = 0;
	bool f = true;

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

			cnt = 0;
			f = true;

			for (int k = i; k < j+1; k++) {
				if (s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T') {
					cnt++;
				}
				else {
					f = false;
				}
			}

			if (f == true) {
				ans = max(ans, cnt);
			}
		}
	}

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


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

int main()
{
string s;
int x=0;
cin>>s;
for(int i = 2;i <= s.size()-1;i++){
        if(s[i] == s[i-1] &&s[i-1] == s[i-2]){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
const int INF = (int)1e9;


int main() {
#ifdef WIN32
	//freopen("input.txt", "rt", stdin);
#endif

	ll n, k; scanf("%lld%lld", &n, &k);
	if (n % k == 0) {
		puts("0"); return 0;
	}

	ll m = n % k;
	ll mmin = n, cur = n;
	for (int i = 0; i < 10000; i++) {
		mmin = min(mmin, abs(cur - k));
		cur = abs(cur - k);
	}
	
	printf("%lld\n", min({ mmin, n, abs(m - k), abs(k - m) }));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},k;
cin>>k;
cout<<n[k-1]<<endl;

return 0;

}


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

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define brep(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define xrep(i,n) for(ll i=1,i##_len=(n);i<=i##_len;i++)
#define Yes(n) cout<<((n)?YES:NO)<<'\n'
#define rYes(n) cout<<((n)?YES:NO)<<'\n';return
#define Sort(v) sort(all(v))
#define rSort(v) sort(all(v)); reverse(all(v))
#define Unique(v) (v).erase(unique(all(v)),(v).end())
#define eb emplace_back

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vvll = vector<vll>;
using vstr = vector<string>;

// --- functions which take 1 argument ---
static inline void ignore_ret(int x){x++;}
template<class T> inline int sgn(T x){return (x>0)-(x<0);}
template<class T> inline ll factorial(T n){if(n==0)return 1;ll r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline map<T,T> factorize(T n){map<T,T>r;for(T i=2;i*i<=n;i++){while(n%i==0){r[i]++;n/=i;}}if(n!=1)r[n]=1;return r;}

// --- functions which take 2 arguments ---
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T nPr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;for(T i=n-k+1;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}

// --- functions which take vector(s) as argument(s) ---
template<class T> inline void print(vector<T>v){cout<<"[ ";for(auto x:v)cout<<x<<' ';cout<<"]\n";}
template<class T> inline T min(vector<T>v){return *min_element(all(v));}
template<class T> inline T max(vector<T>v){return *max_element(all(v));}
template<class T> inline ll sum(vector<T>v){return reduce(all(v),0LL);}
template<class T> inline T gcd(vector<T>v){T r=v[0];for(T i=1;i<v.size();i++)r=gcd(r,v[i]);return r;}
template<class T> inline T lcm(vector<T>v){T r=v[0];for(T i=1;i<v.size();i++)r=lcm(r,v[i]);return r;}
template<class T> inline double abs(vector<T>v){return sqrt(reduce(all(v),0.0,[](int s,int v){return s+=v*v;}));}
template<class T> inline T vector_add(T u,T v){ll s=u.size();if(s>v.size())return {};T r;rep(i,s)r.eb(u[i]+v[i]);return r;}
template<class T> inline T vector_subtract(T u,T v){ll s=u.size();if(s>v.size())return {};T r;rep(i,s)r.eb(u[i]-v[i]);return r;}
template<class T> inline T dot_product(vector<T>u,vector<T>v){if(u.size()<v.size())return 0;T r=0;for(T i=0;i<u.size();i++)r+=u[i]*v[i];return r;}
template<class T> inline T cross_product(T u,T v){T r(3);r[0]=u[1]*v[2]-u[2]*v[1];r[1]=u[2]*v[0]-u[0]*v[2];r[2]=u[0]*v[1]-u[1]*v[0];return r;}

// --- Template ends here ---

void solve(ll A, ll B, ll N) {
  ll examining = min(B - 1, N);
  cout << ((A * examining) / B - A * (examining / B)) << endl;
}

int main() {
  ll A;
  ignore_ret(scanf("%lld",&A));
  ll B;
  ignore_ret(scanf("%lld",&B));
  ll N;
  ignore_ret(scanf("%lld",&N));
  solve(A, B, N);
  return 0;
}


Measured memory_bytes: 3696
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, d, sum, Q;
LL ans;
LL no;
bool b, bb[100001];
string s, t;
int main() {
	cin >> N>>M;
	LL num[5];
	char cc[5],c;


	for (int i = 0; i < M; i++) {
		cin >> num[i]>>cc[i];
	}
	for (int i = 0; i < N; i++) {
		s += 'a';
	}
	for (int i = 0; i < M; i++) {
		if (s[num[i] - 1] == 'a'|| s[num[i] - 1] == cc[i]) {
			s[num[i] - 1] = cc[i];
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	if (N == 1 && M == 0) {
		cout << 0 << endl;
		return 0;
	}
	if (s[0] == '0'&&N>1) {
		cout << -1 << endl;
		return 0;
	}

	if (s[0] == 'a') {
		s[0] = '1';
	}
	for (int i = 1; i < N; i++) {
		if (s[i] == 'a') {
			s[i] = '0';
		}
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0; i<n; i++)
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;

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

    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1) * (n-w+1) << '\n';
}


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

int main() {
  int a;
  cin >> a;
  int s1 = a / 100;
  int b = a - s1 * 100;
  int s2 = b / 10;
  int c = b - s2 * 10;
  int s3 = c;
  int ans = s1 + s2 + s3;
  cout << ans << endl;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int min;
    if (a > b) min = b;
    else min = a;
    if (min == 1) {
        cout << 1 << endl;
        return 0;
    }
    int c[100001] ;
    int cnt = 0;
    for (int i = min; i > 0; i--) {
        if (a % i == 0 && b % i == 0) cnt++;
        if (cnt == k) {
            cout << i << endl;
            return 0;
        }
    }

    // for (int i = 0; i < cnt; i++) cout << c[i] << endl;
    
    // cout << c[k-1] << endl;
    // return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5+5;
vector<int> t(4*N);
vector<int> dp(N); //dp[i] = max. beauty sum s.t. last flower has height i

int build(int v, int tl, int tr){
	if(tl == tr)
		{
			t[v] = dp[tl];
			return t[v];
		}
	int mid = (tl+tr)/2;
	int l = build(2*v, tl, mid);
	int r = build(v*2+1, mid+1, tr);
	t[v] = max(t[2*v], t[2*v+1]);
	return t[v];
}

int query(int v, int l, int r, int tl, int tr){
	int mid = (l+r)/2;
	if(tl > r or tr < l or l > r or tl > tr){
		return 0LL;
	}
	if(tl==l and tr==r){
		return t[v];
	}
	else
	{
		
		return max(query(2*v, l, mid, tl, min(mid, tr)), query(2*v+1, mid+1, r, max(mid+1, tl), tr));
	}
}

void update(int v, int tl, int tr, int pos, int newval){
	//cout<<v<<" "<<tl<<" "<<tr<<" "<<pos<<" "<<newval<<endl;
	if(tl==tr)
		t[v] = newval;
	else
	{
		int tm = (tl+tr)/2;
		if(pos <= tm)
			update(v*2, tl, tm, pos, newval);
		else
			update(v*2+1, tm+1, tr, pos, newval);
		t[v] = max(t[v*2] ,  t[v*2 + 1]);
	}
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	int h[n], b[n];
	build(1, 1, n);
	for(int i=0; i<n; ++i)cin>>h[i];
	for(int i=0; i<n; ++i)cin>>b[i];
	
	for(int flo=0; flo<n; ++flo)
	{
		int ht=h[flo];
		dp[ht] = max(query(1, 1, n, 1, h[flo]-1)+b[flo], dp[ht]);
		update(1, 1, n, ht, dp[ht]);
	}
	
		int ans=0;
		for(int i=1; i<=n; ++i){
			ans=max(ans, dp[i]);
		}
		cout<<ans;
	return 0;	
}

Measured memory_bytes: 14284
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m,n,m){
		int to[100]={0};
		for(int i=0;i<n;++i){
			for(int j=0,f;j<m;++j){
				cin>>f;
				if(f==1) to[j]++;
			}
		}
		vector<pair<int,int> > v;
		for(int i=0;i<m;++i) v.push_back(make_pair<int,int>(to[i],i+1));
		for(int i=0;i<m;++i){
			for(int j=m-1;j>i;--j){
				if(v[j].first>v[j-1].first){
					pair<int,int> tmp = v[j];
					v[j]=v[j-1];
					v[j-1]=tmp;
				}
			}
		}
		for(int i=0;i<m;++i)cout<<v[i].second<<((i==m-1)?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 900
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int A, B, tasu, hiku, kakeru, max;

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

	tasu = A + B;
	hiku = A - B;
	kakeru = A * B;

	if(tasu >= hiku){
		max = tasu;
	}else{
		max = hiku;
	}

	if(kakeru > max)
		max = kakeru;

	printf("%d",max);

	return EXIT_SUCCESS;
}


Measured memory_bytes: 128
N,M = map(int,input().split())
A = [input() for _ in [0]*N]
B = [input() for _ in [0]*M]
endFlg = False
for i in range(N-M+1):
    for j in range(N-M+1):
        breakFlg = False
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    breakFlg = True
                    break
            if breakFlg:break
        else:endFlg=True
        if endFlg: break
    if endFlg: break
if endFlg:print("Yes")
else:print("No")

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

bool check3(int n);

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 10 == 3 || check3(i)){
            cout << " " << i;
        }
    }
    cout << endl;
    return 0;
}

bool check3(int n){
    while(n > 0){
        if(n % 10 == 3) return true;
        n /= 10;
    }
    return false;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define INF 10000000000000

typedef long long ll;

int w[101];
ll v[101];
ll memo[101][100001];

ll knap(int n, int W)
{
	if(W < 0)
	return -INF;
	else if(!n)
	return 0;
	if(memo[n][W] != -1)
	return memo[n][W];
	ll ans = 0;
	ans = std::max(v[n] + knap(n-1, W-w[n]), knap(n-1, W));
	memo[n][W] = ans;
	return ans;	
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	int n,W;
	std::cin>>n>>W;
	for(int i=1;i<=n;i++)
	std::cin>>w[i]>>v[i];
	ll ans = knap(n, W);
	std::cout<<ans<<"\n";
	return 0;	
}

Measured memory_bytes: 79232
from collections import defaultdict
from heapq import heappop, heappush


class Graph():

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra():

    def __init__(self, graph, start):
        self.g = graph.graph

        self.dist = defaultdict(lambda: float("inf"))
        self.dist[start] = 0

        self.prev = defaultdict(lambda: None)

        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            dist_u, u = heappop(self.Q)

            if self.dist[u] < dist_u:
                continue

            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):

        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal

        while node is not None:
            path.append(node)
            node = self.prev[node]

        return path[::-1]

import sys
input=sys.stdin.readline
n,m,s,t=map(int,input().split())



en=Graph()
snu=Graph()

for i in range(m):
    u,v,a,b=map(int,input().split())
    en.add_edge(u,v,a)
    en.add_edge(v,u,a)
    snu.add_edge(u,v,b)
    snu.add_edge(v,u,b)

enen=Dijkstra(en,s)
snusnu=Dijkstra(snu,t)
ans=[enen.shortest_distance(n)+snusnu.shortest_distance(n)]

for i in range(n-1,0,-1):
    d1=enen.shortest_distance(i)
    d2=snusnu.shortest_distance(i)
    ans.append(min(ans[-1],d1+d2))


for i in range(1,n+1):
    print(10**15-ans[-i])


Measured memory_bytes: 118700
n, q = list(map(int, input().split()))
edge = []
for i in range(n-1):
    tempa, tempb = list(map(int, input().split()))
    edge.append((tempa-1, tempb-1))

node = [0] * n

for i in range(q):
    p, x = list(map(int, input().split()))
    node[p-1] += x

edge.sort()
for e in edge:
    node[e[1]] += node[e[0]]

for n in node:
    print(n)


Measured memory_bytes: 41760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a>=1 && a<=9 && b>=1 && b<=9) cout<<a*b;
    else cout<<"-1";   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll n,a[100010],c,v;
  cin >> n;
  c=0;
  v=0;
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  if(a[n-1]-a[0]>2){printf("No");
                    return 0;
                   }
  if(a[n-1]==a[0]){
    if(n==a[0]+1||n>=a[0]*2){printf("Yes");
                             return 0;
                            }
    printf("No");
    return 0;
  }
  if(a[0]==a[a[0]]){printf("No");
                    return 0;
                   }
  rep(i,n)if(a[i]==a[0])c++;
  rep(i,n)if(a[i]==a[n-1])v++;
  if(v/2+c>=a[n-1]){printf("Yes");
                    return 0;
                   }
  printf("No");
}

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

int n, l;
vector<string> s;

int main(void) {
	cin >> n >> l;
	s = vector<string>(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

using namespace std;

int N, Q;

struct Era {
	string name;
	int s, g;
};
bool operator < (const Era& e1, const Era& e2) {
	return e1.g < e2.g;
}

vector<Era> v;

void solve(int y) {
	int lb = 0, ub = N;
	while (ub - lb > 1) {
		int med = (ub + lb) / 2;
		if (v[med].s > y) ub = med;
		else lb = med;
	}
	
	if (lb == 0 && v[lb].s > y || v[lb].g < y) cout << "Unknown" << endl;
	else cout << v[lb].name << " " << y - v[lb].s + 1 << endl;
}

int main() {
	while (cin >> N >> Q, N) {
		v.clear();
		for (int i = 0; i < N; i++) {
			string name; int s, g;
			cin >> name >> s >> g;
			v.push_back((Era){name, g - s + 1, g});
		}
		sort(v.begin(), v.end());
		
		for (int i = 0; i < Q; i++) {
			int y; cin >> y;
			solve(y);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vi h(N); REP(i, N) cin >> h[i];
    vi dp(N, INF);
    dp[0] = 0;
    REP(i, N-1)
    {
        chmin<int>(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        if(i < N-1) chmin<int>(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
n,m,x=map(int,input().split())
A=[list(map(int,input().split()))for a in range(n)]
mi=[10**7]

for i in range(2**n):
  und=[0]*m
  money=0
  for j in range(n):
    if (i >> j)&1:
      money+=A[j][0]
      for u in range(m):
        und[u]+=A[j][u+1]
  if all(und[s]>=x for s in range(m)):    
    mi.append(money)
   
print(min(mi) if min(mi)!=10**7 else -1)



Measured memory_bytes: 9192
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int INF32 = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    map<ll, bool> was;
    for (ll x = 1; x <= sqrt(a); x++) 
        if (a % x == 0) {
            was[x] = true;
            was[a / x] = true;
        }
    set<ll> s;
    for (ll x = 1; x <= sqrt(b); x++) 
        if (b % x == 0) {
            if (was[x])
                s.insert(x);
            if (was[b / x])
                s.insert(b / x);
        }
    ll nok = 1;
    int ans = 0;
    for (auto x : s) {
        ll r = __gcd(nok, x);
        if (r == 1) {
            ans++;
            nok = (nok * x) / r;
        }    
    }
    cout << ans;
    return false;                                                       
}

Measured memory_bytes: 1024
n = int(input())

anslist = []
printlist = []

for i in range(n):
    query = list(map(int, input().split()))
    if query[0] == 0:
        anslist.append(query[1])
    elif query[0] == 1:
        printlist.append(anslist[query[1]])
    elif query[0] == 2:
        anslist.pop(-1)

for p in printlist:
    print(p)



Measured memory_bytes: 13364
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <math.h>
using namespace std;


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

	
	if(a >= 3200) cout << s << endl;
	else cout << "red" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  cout << fixed << setprecision(10);
  vector<double> x(n), y(n);
  REP(i, n) { cin >> x[i] >> y[i]; }
  vector<vector<double>> dist(n, vector<double>(n));
  REP(i,n) REP(j,n){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    dist[i][j] = sqrt(dx*dx+dy*dy);
  }

  vector<ll> ord(n);
  iota(ALL(ord),0);

  double ans = 0;
  do{
    REP(i,n-1){
      ans += dist[ord[i]][ord[i+1]];
    }
  }while(next_permutation(ALL(ord)));

  FOR(i,1,n+1){
    ans /= (double)i; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
INF = float("inf")
n, k = map(int, input().split())
a = list(map(int, input().split()))

def get_divisors(num):
    f_divs, l_divs = [], []
    for i in range(1, int(num**0.5)+1):
        if not num % i:
            f_divs.append(i)
            if i != num // i:
                l_divs.append(num // i)
    return f_divs + l_divs[::-1]

divs = get_divisors(sum(a))
ans = 1

def evl(d):
    rem = [x % d for x in a]
    rem.sort()
    s = sum(rem)
    c = 0
    for i, x in enumerate(rem):
        c += x
        if c == d*(n-i-1) - (s-c):
            return c <= k
    return False

for d in divs[::-1]:
    if evl(d):
        print(d)
        break


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    int mod = 0;
    rep(i, n){
        ll a;
        cin >> a;
        ans += (a+mod)/2;
        mod = (a+mod)%2;
        if(a == 0)mod = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import itertools

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline


N, M, Q = map(int, input().split())
abcd_ls = [list(map(int, input().split())) for _ in range(Q)]


def calc():
    score = 0
    for abcd in abcd_ls:
        a, b, c, d = abcd
        a -= 1
        b -= 1
        if c == A[b] - A[a]:
            score += d
    return score


def dfs(i, mx):
    if i == N:
        return calc()

    score = 0
    for x in range(mx, M+1):
        A[i] = x
        s = dfs(i+1, x)
        score = max(s, score)
    return score


A = [0] * N
ans = dfs(0, 1)
print(ans)


Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int cost[n];
  cost[0]=0;
  cost[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    cost[i]=min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]));
   }
    cout<<cost[n-1];
       return 0;
   }


Measured memory_bytes: 1024
# include <vector>
# include <stdio.h>
# include <string.h>
# include <iostream>
# include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int M = 5e5 + 10;
const int mod = 1e9 + 7;

int n, a[M], b[M];
vector <int> vec;
ll cnt[30];

int main() {
  std :: ios :: sync_with_stdio(false); 
  std :: cin.tie(0); 
  std :: cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++ i) cin >> a[i];
  for (int i = 1; i <= n; ++ i) cin >> b[i];
  
  for (int digits = 0; digits <= 28; ++ digits) {
    vec.clear(); 
    for (int i = 1; i <= n; ++ i) vec.push_back((b[i] & ((1 << (digits + 1)) - 1)));
    sort(vec.begin(), vec.end());
    for (int i = 1, A, pointa, pointb; i <= n; ++ i) {
      A = (a[i] & ((1 << (digits + 1)) - 1));
      // 2^d <= a[i] + b[i] < 2^(d+1)
      pointa = lower_bound(vec.begin(), vec.end(), (1 << digits) - A) - vec.begin();
      pointb = lower_bound(vec.begin(), vec.end(), (1 << (digits + 1)) - A) - vec.begin();
      cnt[digits] += pointb - pointa;
      // 2^(d+1) + 2^d <= a[i] + b[i] < 2^(d+2)
      pointa = lower_bound(vec.begin(), vec.end(), (1 << (digits + 1)) + (1 << digits) - A) - vec.begin();
      pointb = vec.end() - vec.begin();
      cnt[digits] += pointb - pointa;
    }
  }
  int ans = 0;
  for (int i = 0; i <= 29; ++ i)
    if(cnt[i] & 1) ans |= (1 << i);
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 2936
program a
  implicit none
  integer :: N,i,ale,ue,dif
  integer,allocatable :: W(:)
  read(*,*) N
  allocate(W(N))
  read(*,*) W
  ale=sum(W)
  dif=ale
  do i=1,N
     ue=sum(W(1:i))
     if(dif.gt.abs(ale-2*ue)) then
        dif=abs(ale-2*ue)
     endif
  enddo
  write(*,'(i0)') dif

  deallocate(W)
end program a




Measured memory_bytes: 768
#include<iostream>
#include<limits>
using namespace std;
int main()
{
    int n, t;
    cin >> n >> t;
    int m, p;
    int min = numeric_limits<int>::max();
    int ret = -1;
    for(int i = 0; i < n; i++)
    {
        cin >> m >> p;
        if( p > t )
        {
            // do nothing
        }
        else
        {
            if( min > m )
            {
                min = m;
                ret = m;
            }
        }
    }
    if(-1 == ret)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << ret << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> proof(n, vector<int>(n, - 1));
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        for (int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            x--;
            proof[i][x] = y;
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); i++){
        int z = 0;
        bool flag = true;
        vector<int> tmp(n);
        for (int j = 0; j < n; j++){
            if ((i >> j) & 1) z++, tmp[j] = 1;
            else tmp[j] = 0;
        }
        for (int j = 0; j < n; j++){
            if ((i >> j) & 1){
                for (int k = 0; k < n; k++){
                    if (proof[j][k] == - 1) continue;
                    if (tmp[k] != proof[j][k]) flag = false;
                    if (!flag) break;
                }
            }
        }
        if (flag) {
            ans = max(ans, z);
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

n=int(input())
c=input()
r=c.count("R")
w=c.count("W")
mi=min(r,w)
l_w=0
l_r=0
ans=float('inf')
if w==n:
  print(0)
  sys.exit()


for i in range(n):
  if c[i]=="W":
    l_w+=1
  else:
    l_r+=1

  r_r=r-l_r
  if l_w<=r_r:
    now=l_w+(r_r-l_w)
  else:
    now=r_r+(l_w-r_r)

  ans=min(ans,now)
print(ans)
  



Measured memory_bytes: 9320
#include<stdio.h>
int main(void)
{
	int x;

	scanf("%d",&x);

	if(x==1||x==8||x==15||x==22||x==29){
		printf("fri\n");
	}else if(x==7||x==14||x==21||x==28){
		printf("thu\n");
	}else if(x==6||x==13||x==20||x==27){
		printf("wed\n");
	}else if(x==5||x==12||x==19||x==26){
		printf("tue\n");
	}else if(x==4||x==11||x==18||x==25){
		printf("mon\n");
	}else if(x==3||x==10||x==17||x==24){
		printf("sun\n");
	}
	else if(x==2||x==9||x==16||x==23||x==30){
		printf("sat\n");
	}
	return 0;
}



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

int main(void) {
  string s;
  cin >> s;
  if (s.substr(0, 7) <= "2019/04/30") {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//
// AGC011A
//
//

#include <iostream>
#include <math.h>
#include<chrono>
#include <vector>
#include <cstring>   // memset
#include <algorithm>

using namespace std;

int N;

int main(){
	int N,C,K;
	cin >> N >> C >> K;;

	int T[N];
	for(int i=0; i<N; i++) cin >> T[i];

	sort(T,T+N);

	int pcnt = 0;
	int bcnt = 1;
	int sTime  = 0;
	for(int i=0; i<N; i++) {
		if (pcnt == 0) sTime = T[i];

		if (T[i] <= sTime + K && pcnt < C) {
				pcnt++;
		} else {
				bcnt++;
				pcnt = 1;
				sTime = T[i];
		}

	}

	cout << bcnt << endl;

  return 0;
}



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

long long small (long long a, long long b) {
  return a < b ? a : b;
}

long long abs(long long a) {
  return a < 0 ? -a : a;
}

long long sub (long long a, long long b, long long c) {
  long long min = a, max = a;
  min = b < min ? b : min;
  min = c < min ? c : min;
  max = max < b ? b : max;
  max = max < c ? c : max;
  return max - min;
}

int main () {
  long long i, j, h, w, a, b, c, min;
  cin >> h >> w;
  min = h * w;
  if(h >= 3) {
    a = (h / 3) * w;
    b = (h * 2 / 3 - h / 3) * w;
    c = (h - h * 2 / 3) * w;
    min = small(min, sub(a, b, c));
  }
  if(w >= 3) {
    a = (w / 3) * h;
    b = (w * 2 / 3 - w / 3) * h;
    c = (w - w * 2 / 3) * h;
    min = small(min, sub(a, b, c));
  }
  for(i = 1; i < w; ++i) {
    a = i * h;
    b = (w - i) * (h / 2);
    c = (w - i) * (h - h / 2);
    min = small(min, sub(a, b, c));
  }
  for(j = 1; j < h; ++j) {
    a = j * w;
    b = (h - j) * (w / 2);
    c = (h - j) * (w - w / 2);
    min = small(min, sub(a, b, c));
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <ctime>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef tuple<int, int, int> T;
typedef pair<int, int> P;
 
int n;
int a[200000];
int b[200000];
int cntA[200001];
int cntB[200001];
priority_queue<T> queA;	//(count(num, A+B), count(num, A), num)
priority_queue<T> queB; //(count(num, A+B), count(num, B), num)
bool eraseA[200001];
vector<P> pa;			//(numA, numB)
 
signed main() {
	int i;
	clock_t start_time = clock();
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	rep(i, n) {
		cntA[a[i]]++;
		cntB[b[i]]++;
	}
	
	for (i = 1; i <= n; i++) {
		if (cntA[i] > 0) {
			queA.push(T(cntA[i] + cntB[i], i, cntA[i]));
		}
		else {
			eraseA[i] = true;
		}
		if (cntB[i] > 0) {
			queB.push(T(cntA[i] + cntB[i], i, cntB[i]));
		}
	}
	
	while (!queA.empty()) {
		T tupA = queA.top(); queA.pop();
		T tupB = queB.top(); queB.pop();
		
		if (get<1>(tupA) == get<1>(tupB)) {
			if (queB.empty()) {
				cout << "No" << endl;
				return 0;
			}
			T tupB2 = queB.top(); queB.pop();
			
			//use(tupA, tupB2)
			pa.push_back(P(get<1>(tupA), get<1>(tupB2)));
			if (get<2>(tupA) - 1 > 0) {
				queA.push(T(get<0>(tupA) - 1, get<1>(tupA), get<2>(tupA) - 1));
			}
			else {
				eraseA[get<1>(tupA)] = true;
			}
			queB.push(T(get<0>(tupB) - 1, get<1>(tupB), get<2>(tupB)));
			
			if (get<2>(tupB2) - 1 > 0) {
				queB.push(T(get<0>(tupB2) - 1, get<1>(tupB2), get<2>(tupB2) - 1));
			}
			if (eraseA[get<1>(tupB2)] == false) {
				if ((double)(clock() - start_time) / CLOCKS_PER_SEC < 0.2) {
					vector<T> vec;
					while (!queA.empty()) {
						T now = queA.top(); queA.pop();
						if (get<1>(now) == get<1>(tupB2)) {
							vec.push_back(T(get<0>(now) - 1, get<1>(now), get<2>(now)));
							break;
						}
						else {
							vec.push_back(now);
						}
					}
					rep(i, vec.size()) {
						queA.push(vec[i]);
					}
				}
			}
		}
		else {
			//use(tupA, tupB)
			pa.push_back(P(get<1>(tupA), get<1>(tupB)));
			if (get<2>(tupA) - 1 > 0) {
				queA.push(T(get<0>(tupA) - 1, get<1>(tupA), get<2>(tupA) - 1));
			}
			else {
				eraseA[get<1>(tupA)] = true;
			}
			if (get<2>(tupB) - 1 > 0) {
				queB.push(T(get<0>(tupB) - 1, get<1>(tupB), get<2>(tupB) - 1));
			}
		}
	}
 
	sort(pa.begin(), pa.end());
	
	cout << "Yes" << endl;
	for (int i = 0; i < (int)pa.size(); i++) {
		cout << pa[i].second;
		if (i + 1 < pa.size()) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
int a[15],tail=0;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<=s.size()-1;i++)
	{
		if(s[i]=='0') a[++tail]=0;
		if(s[i]=='1') a[++tail]=1;
		if(s[i]=='B'&&tail!=0) a[tail--]=0;
	}
	for(int i=1;i<=tail;i++)
		cout<<a[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

dp = [[0] * 3 for _ in range(N + 1)]

for i in range(1, N + 1):
    dp[i][0] = max(dp[i][0], dp[i - 1][1] + abc[i - 1][1])
    dp[i][0] = max(dp[i][0], dp[i - 1][2] + abc[i - 1][2])
    dp[i][1] = max(dp[i][1], dp[i - 1][0] + abc[i - 1][0])
    dp[i][1] = max(dp[i][1], dp[i - 1][2] + abc[i - 1][2])
    dp[i][2] = max(dp[i][2], dp[i - 1][0] + abc[i - 1][0])
    dp[i][2] = max(dp[i][2], dp[i - 1][1] + abc[i - 1][1])

print(max(dp[N]))

Measured memory_bytes: 104556
N = int(input())
n = N

L = str()

alpha = [chr(i) for i in range(97,97+26)]

i = 0
while n > 0:
    i += 1
    n -= 26 ** i


N -= 26 * (26 ** (i - 1) - 1) // 25

while i > 0:
    code = (N - 1) // (26 ** (i - 1))
    L += alpha[code]
    N -= code * (26 ** (i -1))
    i -= 1

print(L)

Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    int one = 0;
    for (int i=0;i<s.length();i++){
        if(s[i] == '1'){
            one++;
        }
    }
    if(one * 2 < s.length()){
        cout << one * 2;
    }else{
        cout << (s.length() - one) * 2;
    }
}



Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static io;
public class CompetitiveProgramming
{
  public void Solve()
  {
    var n = Int1;
    var set = new HashSet<string>();
    for (int i = 0; i < n; ++i)
    {
      var s = Strs;
      if (s[0] == "insert")
      {
        set.Add(s[1]);
      }
      else
      {
        if (set.Contains(s[1])) Write("yes");
        else Write("no");
      }
    }
  }
}



class Program
{
  static void Main(string[] args)
  {
    var CompetitiveProgramming = new CompetitiveProgramming();
    CompetitiveProgramming.Solve();
  }
}
public static class io
{
  public static string Str => Console.ReadLine();
  public static string[] Strs => Str.Split(' ');
  public static long[] Longs => Strs.Select(long.Parse).ToArray();
  public static int[] Ints => Strs.Select(int.Parse).ToArray();
  public static char[] Chars => Str.ToArray();
  public static double[] Doubles => Strs.Select(double.Parse).ToArray();
  public static long Long1 => Longs[0];
  public static int Int1 => Ints[0];
  public static char Char1 => Chars[0];
  public static double Double1 => Doubles[0];
  public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; }
  public static void Write(string a) => Console.WriteLine(a);
  public static void Write(params object[] i) => Write(string.Join(" ", i));
  public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
  public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); }
  public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); }
}



Measured memory_bytes: 44392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

 class Main{

	public static void main(String[] args) throws IOException {
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		

		int n = Integer.parseInt(br.readLine());
		int[] in = new int[n];
		int max = Integer.MIN_VALUE;
		int mini = 0;
		int maxj=0;
		boolean con=false;
		
		for (int i = 0; i < n; i++)
			in[i] = Integer.parseInt(br.readLine());
		
		for (int i = 0; i < n - 1; i++) {
			if (in[i] > in[mini])continue;
			for (int j = i + 1; j < n; j++){
				if(i!=0&&con&&i<maxj){
					mini=i;
					max=in[maxj]-in[i];
					break;}
				else if(max+in[i]<in[j]){
					max=in[j]-in[i];
					mini=i;
					maxj=j;
					con=false;
				}
			}con=true;
		}
		System.out.println(max);
	}}

Measured memory_bytes: 37680
a=input()
b=int(a)
c=[b]
num=1
while True:
    if b%2==0:
        num+=1
        if c.count(b/2)==0:
            c.append(b/2)
            b=b/2
        else:
            print('%d'%num)
            break
    else:
        num+=1
        if c.count(3*b+1)==0:
            c.append(3*b+1)
            b=3*b+1
        else:
            print('%d'%num)
            break




Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	scanf("%d", &n);
	char s[102][11];
	int i;
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	int m;
	scanf("%d", &m);
	char t[102][11];
	for (i = 0; i < m; i++)
		scanf("%s", t[i]);
	int ans = 0;
	int k, j;
	for (i = 0; i < n; i++)
	{
		k = 0;
		for (j = 0; j < n; j++)
			if (strcmp(s[i], s[j]) == 0)
				k++;
		for (j = 0; j < m; j++)
			if (strcmp(s[i], t[j]) == 0)
				k--;
		if (ans < k)
			ans = k;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"YES\n"
#define no cout<<"NO\n"


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

	int a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v<=w)no;
	else{
		int d=abs(a-b),s=abs(v-w);
		if(s*t>=d)yes;
		else no;

	}

}


Measured memory_bytes: 3652
# print('input >>')

S = input()

N = len(S)

def is_kaibun(S):
    for i in range(len(S)):
        if S[i] != S[-i-1]:
            return False
    return True

if is_kaibun(S) and is_kaibun(S[:(N-1)//2]) and is_kaibun(S[(N+3)//2-1:N]):
    print('Yes')
else:
    print('No')

# print('-----output-----')



Measured memory_bytes: 2940
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	string S,T; cin >> S>>T;
	bool jg = 1;

	rep(i, S.size()) {
		if (T[i] != S[i])jg = 0;
	}
	if (jg)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double theta;
    if (a * b / 2 < s)
    {

        double h = (a * b - s) * 2 / a;
        theta = atan2(h, a) / 2 / acos(-1) * 360;
    }else{
        double h = 2 * s / b;
        theta = atan2(b, h) * 360 / (2 * acos(-1));
    }
    printf("%.10f\n",theta);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int n,i,j,u,k,tmp;
int list[100][100]={};
int time=0;
int timelist[100][2];

void search(int y){
	int ii,jj;
	time++;
	timelist[y][0]=time;
	for(jj=0;jj<n;jj++){
		list[jj][y]=0;
	}

	for(ii=0;ii<n;ii++){
		if(list[y][ii]==1){
			search(ii);
		}
	}
	time++;
	timelist[y][1]=time;
}

int main(void) {


	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&u);
		scanf("%d",&k);
		for(j=0;j<k;j++){
			scanf("%d",&tmp);
			list[u-1][tmp-1]=1;
		}
	}
	for(i=0;i<n;i++){
		if(timelist[i][0]==0){
			search(i);}}

	for(j=0;j<n;j++){
		printf("%d %d %d\n",j+1,timelist[j][0],timelist[j][1]);
	}

	return 0;
}

Measured memory_bytes: 636