akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int main(){
    int h,w,a,b;
    scanf("%d%d %d %d",&h,&w,&a,&b);
    for(int i=0;i<h-b;i++){
        for(int j=0;j<a;j++) putchar('1');
        for(int j=0;j<w-a;j++) putchar('0');
        putchar('\n');
    }
    for(int i=0;i<b;i++){
        for(int j=0;j<a;j++) putchar('0');
        for(int j=0;j<w-a;j++) putchar('1');
        putchar('\n');
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if (m1 != m2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

ll k;

void gen(ll prevdig, ll curr, ll digpos, ll digmax) {
    if (digpos == digmax) {
        k--;

        if (k == 0) {
            cout << curr;
            exit(0);
        }
        return;
    }

    if(prevdig - 1 >= 0) gen(prevdig - 1, curr * 10 + prevdig - 1, digpos + 1, digmax);
    gen(prevdig, curr * 10 + prevdig, digpos + 1, digmax);
    if(prevdig + 1 <= 9) gen(prevdig + 1, curr * 10 + prevdig + 1, digpos + 1, digmax);
}

void solver() {
    for (ll digs = 1; digs <= 20; digs++) {
        for (ll start = 1; start <= 9; start++) {
            gen(start, start, 1, digs);
        }
    }
}

void solve() {
    cin >> k;

    solver();
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        int n;
        cin>>n;
        vector <int> v;
        while (n)
        {
            int x=n%26;
            if(x==0)
            {
                v.pb(25);
                n--;
            }
            else
            {
                v.pb(x-1);
            }
            n/=26;
        }
        reverse(v.begin(),v.end());
        for(auto x: v)
        {
            cout<<(char)(x+'a');
        }
        
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


    int t = 1;
    //    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

int main(){
	int N,M;
	int k[30],A[30][30];
	std::cin >> N >> M;
	for (int i=0;i<N;i++){
		std::cin >> k[i];
		for(int j=0;j<k[i];j++){
			std::cin >> A[i][j];
		}
	}
	int out[30]={0};
	for(int i=0;i<N;i++){
		for(int j=0;j<k[i];j++){
			out[A[i][j]-1]++;
		}
	}
	int res = 0;

	for(int i=0;i<M;i++){
		//std::cout << "  " << out[i] << std::endl;
		if(out[i]==N){
			res += 1;
			//break;
		}
	}
	std::cout << res << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int n , m ;
  cin >> n >> m ;
  vector<int> h(n+1) ;
  for (int i = 1 ; i <= n ; ++i) {
    cin >> h[i] ;
  }
  vector<int> g[n+1] ;
  for (int i = 1 ; i <= m ; ++i) {
    int u , v ;
    cin >> u >> v ;
    g[u].push_back(h[v]) ;
    g[v].push_back(h[u]) ;
  }
  int cnt = 0 ;
  for (int i = 1 ; i <= n ; ++i) {
    if (g[i].size() == 0) {
      ++cnt ;
      continue ;
    }
    if (h[i] > *max_element(g[i].begin() , g[i].end())) {
      ++cnt ;
    }
  }
  cout << cnt ;
  return 0 ;
}


Measured memory_bytes: 8740
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int c[3][3];
	int t;
	rep(i, 9) {
		cin >> t;
		c[i / 3][i % 3] = t;
	}

	bool f = true;

	rep(i, 2) {
		int a = abs(c[i][0] - c[i + 1][0]);
		int b = abs(c[i][1] - c[i + 1][1]);
		int d = abs(c[i][2] - c[i + 1][2]);
		
		if (a == b && b == d) {
			//null
		}
		else {
			f = false;
		}
	}

	rep(i, 2) {
		int a = abs(c[0][i] - c[0][i + 1]);
		int b = abs(c[1][i] - c[1][i + 1]);
		int d = abs(c[2][i] - c[2][i + 1]);

		if (a == b && b == d) {
			//null
		}
		else {
			f = false;
		}
	}
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    string S;
    cin >> N >> M;
    cin >> S;
    int next[114514];
    vector<int> Ans;
    next[N]=N;
    RREP(i,N){
        if(S[i]=='0'){
            next[i]=i;
        }else{
            next[i]=next[i+1];
        }
    }
    int now=N;
    while(now>0){
        int goal = max(0ll,now-M);
        goal = next[goal];
        if(goal==now){
            cout << -1 << endl;
            return 0;
        }
        Ans.push_back(now-goal);
        now=goal;
    }
    REP(i,Ans.size()){
        cout << Ans[Ans.size()-1-i] << " ";
    }cout << endl;
    return 0;
}



Measured memory_bytes: 2296
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		if((a*b%2==0)){
			System.out.print("No");
		}else{
			System.out.print("Yes");
	    }
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll mod     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 1000 + 10;
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
void solve(){
  #ifndef ONLINE_JUDGE  
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    //cout<<fixed<<setprecision(20);
    ll n; 
    cin>>n; 
    ll a[n];
    for(ll i=0;i<n;i++){
      cin>>a[i];
    }
    ll ans=0,sum=0;
    for(ll i=0;i<n;i++){
      sum+=a[i];
    }
    for(ll i=0;i<n;i++){
      sum-=a[i];
      ans=ans%mod+(sum%mod*a[i]%mod)%mod; 
    }
    cout<<ans; 
    return 0;
}   

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

int Sum(const int* X, int size) {
  int sum = 0;
  for(int i = 0; i < size; i++) {
    sum += X[i];
  }
  return sum;
}

int Devide(int d, const int *X, int M) {
  if(X[M] != 0) 
    return (int)(d / X[M]);
  else
    return 0;
}

int main() {
  int N; //競技者の数
  int M; //優勝者の番号
  int P; //控除率(百分率)
  vector<int> X;
  int deduction;

  while(1) {
    cin >> N >> M >> P;
    if(N == 0 && M == 0 && P == 0)
      break;
      
    for(int i = 0; i < N; i++) {
      int x;
      cin >> x;
      X.push_back(x);
    }
    
    deduction = Sum(&X.front(), X.size()) * (100-P);
    cout << Devide(deduction, &X.front(), M-1) << endl;
    X.clear();
  }

}



Measured memory_bytes: 3096
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#define SIZE 10
using namespace std;

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

	int N;
	int i,j;
	double tmp;
	double ave;
	vector<double> given;

	cin >> N;

	for(i=0;i<N;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	sort(given.begin(),given.end());

	if(N==1){
		cout << given[0] << endl;
		return 0;
	}else{
		ave=(given[0]+given[1])/2;
		for(i=2;i<N;i++){
			ave=(ave+given[i])/2;
		}

		cout << ave << endl;
	}

	return 0;
}



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

int main() {
string s;
int sum=0;
while(1){
cin>>s;
if(s=="0"){
return 0;
}
for (int i = 0; i < s.length(); ++i) {
	sum+=s[i]-'0';
}
cout<<sum<<endl;
sum=0;
}
}

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

#define int long long

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
const int P = 1e9 + 7;
map<pair<int, int>, pair<int, int> > cnt;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
int Pow(int x, int t)
{
	int res = 1;
	for (; t; t >>= 1, x = x * x % P)
		if (t & 1) res = res * x % P;
	return res;
}

signed main()
{
	int n = read(), tot = P - 1;
	for (int i = 1; i <= n; ++i)
	{
		int a = read(), b = read();
		if (!a && !b) { ++tot; continue; }
		int g = gcd(a, b);
		a /= g; b /= g;
		if (b < 0) a = -a, b = -b;
		
		if (a > 0) ++cnt[{a, b}].first;
			else ++cnt[{b, -a}].second;
	}
	
	int ans = 1;
	for (auto i : cnt) 
		ans = ans * (Pow(2, i.second.first) + Pow(2, i.second.second) - 1) % P;
	printf("%lld\n", (ans + tot) % P);
	return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  if ((u == NIL) || (k == u->key)) return u;
  else if (k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while (x != NIL) {
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root = NIL;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20468
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    int bef = -1;
    int ans = 0;
    REP(i,N) {
        int a;
        cin >> a;
        if ( a == bef) {
            bef = -1;
            ans++;
            continue;
        }
        bef = a;

    }

    cout << ans << endl;

    return 0;
}


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

long long n, a[100004];

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	sort(a,a+n);
	cout << (a[n/2]==a[n/2-1] ? 0 : a[n/2]-a[n/2-1]) << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    int pt, px, py;
    pt = px = py = 0;
    int t, x, y;
    cin >> N;

    rep(i, N){
        cin >> t >> x >> y;
        int d = abs(x - px) + abs(y - py);
        if((t - pt) < d || d % 2 != (t - pt) % 2){
            cout << "No" << endl;
            return 0;
        }
        pt = t;
        px = x;
        py = y;

    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;


int main()
{
    int N; cin>>N;
    int seq[N]; REP(i,N) cin>>seq[i];

    int mini;
    int swap=0;
    REP(i,N)
    {
      mini = i;
      for(int j=i; j<N; j++)
      {
        if(seq[j] < seq[mini]) mini = j;
      }
      if( i == mini) continue;
      int tmp=seq[mini];
      seq[mini]=seq[i];
      seq[i]=tmp;
      swap++;
    }

    REP(i,N)
    {
      if(i) cout<<' ';
      cout<<seq[i];
    }
    cout<<endl;

    cout<<swap<<endl;
}

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

//#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((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 SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VI a(n - 1), b(n - 1);
    REP(i, n - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int k;
    cin >> k;
    VI v(k), p(k);
    REP(i, k) {
        cin >> v[i] >> p[i];
        v[i]--;
    }

    vector<vector<PII>> edge(n, vector<PII>());
    VI ans(n + 1, INT_MAX);

    REP(i, n - 1) {
        edge[a[i]].PB(MP(b[i], 1));
        edge[b[i]].PB(MP(a[i], 1));
    }
    priority_queue<PII> q;
    vector<bool> checked(n + 1, false);
    REP(i,k){
        q.push(MP(-p[i],v[i]));
        ans[v[i]]=p[i];
        checked[v[i]]=true;
    }

    while (!q.empty()) {
        int tnode = q.top().SND;
        int tcost = q.top().FST;
        q.pop();
        checked[tnode] = true;
        REP(i, edge[tnode].size()) {
            PII next = edge[tnode][i];
            if (checked[next.FST] == false) {
                if(ans[next.FST]>ans[tnode] + next.SND){
                    ans[next.FST] = ans[tnode] + next.SND;
                    q.push(MP(-ans[next.FST],next.FST));
                }
            }
        }
    }

    REP(i,n-1){
        if(abs(ans[a[i]]-ans[b[i]])!=1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    REP(i, n ) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll read() {
	ll x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
ll n, s[20], now, a[20], p[20], flag;
int main() {
	n=read();
	p[0]=1;
	for(int i=1;i<=15;i++) p[i]=p[i-1]*26;
	flag=n;
	while(flag>0) {
		now++;
		flag-=p[now];
	}
	s[0]=1;
	for(int i=1;i<=15;i++) s[i]=s[i-1]+p[i];
	for(int i=1;i<=now;i++) {
		cout<<(char)((n-s[now-i])/p[now-i]+'a');
		n-=p[now-i]*((n-s[now-i])/p[now-i]+1);
	}
}


Measured memory_bytes: 3636
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    rep(i,s.size()){
        cout<<'x';
    }
    cout<<endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class agcB {
public:
    void solve(istream& in, ostream& out) {
        int N, M, Q;
        in >> N >> M;
        vector<int> a(M), b(M);
        vector<vector<int>> g(N);
        for (int i = 0; i < M; ++i) {
            in >> a[i] >> b[i];
            g[a[i]-1].push_back(b[i]-1);
            g[b[i]-1].push_back(a[i]-1);
        }
        in >> Q;
        vector<int> v(Q), d(Q), c(Q);
        for (int i = 0; i < Q; ++i) {
            in >> v[i] >> d[i] >> c[i];
            --v[i];
        }
        
        vector<int> col(N, 0);
        vector<int> within(N, -1);
        for (int i = Q-1; i >= 0; --i) {
            if (within[v[i]] >= d[i]) {
                continue;
            }
            within[v[i]] = d[i];
            queue<pair<int,int>> q;
            q.emplace(v[i], d[i]);
            vector<int> vis(N, 0);
            vis[v[i]] = 1;
            while (!q.empty()) {
                int u = q.front().first, dist = q.front().second;
                q.pop();
                if (col[u] == 0) {
                    col[u] = c[i];
                }
                //cout << "paint " << u << " with " << c[i] << endl;
                if (dist > 0) {
                    for (int vv : g[u]) {
                        if (!vis[vv] && within[vv] < dist-1) {
                            q.emplace(vv, dist-1);
                            vis[vv] = 1;
                            within[vv] = dist-1;
                        }
                    }
                }
            }
        }
        for (int i = 0; i < N; ++i) {
            out << col[i] << "\n";
        }
    }
};


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

	agcB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 10616
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int MAXN = 3005;
ll MOD=1e9+7, dp[MAXN][MAXN];

int main(){FIN;
  ll ans=0,n; string s;
  cin >> n >> s;
  s = "<"+s;
  dp[n][1] = 1;
  for(int i = n-1; i >= 0; i--){
    ll tot = 0;
    if(s[i] == '<'){
      for(int j = n-i; j; j--){
        tot = (tot+dp[i+1][j]);
        if(tot>=MOD) tot-=MOD;
        dp[i][j] = tot;
      }
    }
    else{
      fore(j,1,n-i+1){
        tot = (tot+dp[i+1][j])%MOD;
        if(tot>=MOD) tot-=MOD;
        dp[i][j+1] = tot;
      }
    }
  }
  cout << dp[0][1] << "\n";
}

Measured memory_bytes: 70016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
  ll N;
  scanf("%llu\n",&N );
  std::vector<ll> v(N);
  for (size_t i = 0; i < N; i++) {
    scanf("%llu\n",&v[i] );
  }
  std::sort(v.begin(),v.end());

  ll upper=0;
  ll down=0;

  if(N%2==0){

    for (size_t i = 0; i < N/2; i++) {
      down +=v[i]*2;
    }
    down -= v[N/2-1];

    for (size_t i = N/2; i < N; i++) {
      upper +=v[i]*2;
    }
    upper -= v[N/2];

  }else{

    if(v[(N+1)/2]-v[(N+1)/2-1] < v[(N+1)/2-1]-v[(N+1)/2-2]){
      for (size_t i = 0; i < (N+1)/2-1; i++) {
        down +=v[i]*2;
      }

      for (size_t i = (N+1)/2-1; i < N; i++) {
        upper +=v[i]*2;
      }
      upper-= v[(N+1)/2-1];
      upper-= v[(N+1)/2];

    }else{
      for (size_t i = 0; i < (N+1)/2; i++) {
        down +=v[i]*2;
      }
      down -= v[(N+1)/2-1];
      down -= v[(N+1)/2-2];

      for (size_t i = (N+1)/2; i < N; i++) {
        upper +=v[i]*2;
      }
    }
  }

  printf("%llu\n",upper-down );
  return 0;
}


Measured memory_bytes: 1024
/*
    Author : Ritesh Singh
*/

#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define el '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;

int32_t main()
{
   IOS;
   int n,k; cin>>n>>k;
   int a[n];
   rep(i,0,n)
   	cin>>a[i];
   sort(a,a+n);
   int ans = 0;
   rep(i,0,k)
   	ans+=a[i];
   cout<<ans;
}

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

using namespace std;

#define MAX_P 11

struct Team {
	int tid;
	int penalty;
	int correct;
	int wrong[MAX_P];
	Team() {
		correct = 0;
		penalty = 0;
		for (int i = 0; i < MAX_P; i++) wrong[i] = 0;
	}
	bool operator<(const Team &o) const {
		return correct == o.correct ? 
					penalty == o.penalty ?
						tid < o.tid : penalty < o.penalty
				  : correct > o.correct;
	}
};

int main() {
	int T, P, R;
	while (cin >> T >> P >> R) {
		if (T == 0 && P == 0 && R == 0) break;
		Team team[T+1];
		for (int i = 1; i <= T; i++) team[i].tid = i;
		for (int i = 0; i < R; i++) {
			int tid, pid, time; string res;
			cin >> tid >> pid >> time >> res;
			if (res == "CORRECT") {
				team[tid].correct++;
				team[tid].penalty += time;
				team[tid].penalty += team[tid].wrong[pid] * 1200;
			} else {
				team[tid].wrong[pid]++;
			}
		}

		sort(team+1, team+T+1);

		for (int i = 1; i <= T; i++) {
			cout << team[i].tid << ' ' << team[i].correct << ' ' << team[i].penalty << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1216
class Integer
  @@mod = 1000000007
  @@inverse = {}
  @@factorial = {}
  def self.factorial
    @@factorial
  end
  def self.mod
    @@mod
  end
  def self.mod=(value)
    @@mod = value
  end
  # a + b
  def plus(other)
    (self + other) % @@mod
  end
  # a - b
  def minus(other)
    (self - other) % @@mod
  end
  # a * b
  def mult(other)
    (self * other) % @@mod
    # ((self % @@mod) * (other % @@mod)) % @@mod
  end
  # a / b
  def divi(other)
    (self * other.inverse) % @@mod
  end
  # a ** b
  def power(n)
    res = 1
    a = self
    while (n > 0) do
      res = res.mult(a) if n[0]==1
      a = a.mult(a)
      n = n >> 1
    end
    res
  end
  # nCk
  def combi(k)
    return 0 if self < k
    return 1 if k == 0 || k == self
    self.! .mult k.!.inverse .mult (self-k).!.inverse
  end
  # 逆元
  def inverse
    @@inverse[self] ||= self.power(@@mod - 2)
  end
  # 階乗
  def factorial
    # @@factorial[self] ||= (1..self).reduce(&:mult)
    @@factorial[self] ||= begin
      return 1 if self==1
      (self-1).factorial .mult self
    end
  end
  alias :! :factorial
end

# require 'benchmark'

# ABC 137-F
p = gets.to_i
Integer.mod = p
array = gets.split.map(&:to_i)
p.factorial
p_1C = {}
(0..(p-1)).each do |k|
  p_1C[k] = (p-1).combi(k)
end

# time = Benchmark.realtime do
  # 1 - (x-j)^(p-1) = 0 if x != j
  #                   1 if x == j
  ans = Array.new(p, 0)
  p.times do |j|
    next if array[j]==0

    ans[0] += 1
    j_times = 1
    (p-1).downto(0) do |k|
      ans[k] -= (p_1C[k] * j_times)
      j_times *= -j
      j_times %= p
    end
  end
  puts ans.map{|i| i % p}.join(' ')
# end
# puts time

Measured memory_bytes: 2812
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

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

	map<int32_t, int32_t> _map;
	for (int32_t i = 0; i < N; i++) {
		int32_t a;
		cin >> a;
		if (_map.find(a) == _map.end()) {
			_map[a] = 1;
		} else {
			_map[a]++;
		}
	}
	int32_t res = 0;
	for (auto iter = _map.begin(); iter != _map.end(); iter++) {
		if (iter->first < iter->second)
			res += iter->second - iter->first;
		else if (iter->first > iter->second)
			res += iter->second;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool isprime(int x){
    if( x==2 ){
        return true;
    }
    if( x<2 ){
        return false;
    }

    for(int i=2; i<=sqrt(x); ++i){
        if( x%i==0 ){
            return false;
        }
    }
    return true;
}


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

    int ans = 0;
    int x;
    for(int i=0; i<n; ++i){
        cin >> x;
        if( isprime(x) ){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3096
from collections import deque


# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs():
    # すべての点を -INF で初期化
    d = [[-float("inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]



    # スタート地点をキューに入れ、その点の距離を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # # 取り出してきた状態がゴールなら探索をやめる
        # if p[0] == gx and p[1] == gy:
        #     break
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == -float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    #return d[gx]
    a = 0
    for i in range(n):
        for j in range(m):
            a = max(d[i][j],a)
    return a

    #return max(d)


n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]
ans = 0
for sx in range(n):
    for sy in range(m):
        if maze[sx][sy] == '.':
            ans = max(ans, bfs())
        # for gx in range(n):
        #     for gy in range(m):
        #         if maze[sx][sy] == '.' and maze[gx][gy] == '.' and not (sx == gx and sy == gy):
        #             if bfs() != float('inf'):
        #                 ans = max(ans,bfs())
print(ans)

Measured memory_bytes: 47472
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a[5];
	REP(i, 5) {
		scanf("%d", &a[i]);
	}

	int min = 10;
	int idx = -1;
	REP(i, 5) {
		if (min > a[i] % 10 && a[i] %10!=0) {
			min = a[i] % 10;
			idx = i;
		}
	}
	int ans = 0;
	REP(i, 5) {
		if (idx != i&&a[i]%10!=0) {
			a[i] = a[i] / 10 * 10 + 10;
		}
		ans += a[i];
	}
	PRINTD(ans);
}

Measured memory_bytes: 128
n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
count = 0
(1..n-2).each do |i|
    if s[i] > s[i-1] && s[i] <= s[i+1]
        count += 1
    elsif s[i] <= s[i-1] && s[i] > s[i+1]
        count += 1
    end
end
puts count

Measured memory_bytes: 14272
//Space: O(k) Time: O(n)
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
using namespace std;
int main(){
int n,p,k;
cin>>n>>k;
deque<pair<int,int>> dp; 
while (n--){
    cin>>p;
    
    int Min=1E9;
    for(auto x: dp) Min=min(Min,x.second+abs(p-x.first));
    if(Min==1E9) Min=0;
    if (dp.size()==k) dp.pop_front();
    dp.push_back(make_pair(p,Min)); 
}
cout<<dp.back().second;
return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static void best(int num,int[][] arr){
		
		System.out.println(arr[num][1]);
	}
	
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		
		int h = s.nextInt();
		int w = s.nextInt();
		
		int[][] arr= new int[10][10];
		for (int i = 0; i < arr.length; i++) {
			for (int j = 0; j < arr.length; j++) 
				arr[i][j]=s.nextInt();
		}
		
		for (int k = 0; k < arr.length; k++) {
			for (int i = 0; i < arr.length; i++) {
				for (int j = 0; j < arr.length; j++) {
					if (arr[i][k] + arr[k][j] < arr[i][j])
                        arr[i][j] = arr[i][k] + arr[k][j];
				}
			}
		}
		int sum=0;
		int [][] wall = new int[h][w];
		for (int i = 0; i < wall.length; i++) {
			for (int j = 0; j < wall[0].length; j++) {
				wall[i][j] = s.nextInt();
				if(wall[i][j]!=-1){
					sum+= arr[wall[i][j]][1];
				}
			}
		}
		System.out.println(sum);	
	}
}


Measured memory_bytes: 47736
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string str, t;
  cin >> str >> t;
 
  for(int i = str.size()-1; i >= 0; i--){
  
    for(int j = 0; j < t.size(); j++){
      if(str[i-j] != t[t.size()-1-j] && str[i-j] != '?') {break;}
	if(j+1 == t.size()){
	 
	  str.replace(i-j, t.size(), t);
	  for(int k = 0; k < str.size(); k++) if(str[k]=='?') str[k] = 'a';
	  cout << str << endl;
	  return 0;
	}
      }
   
  }
  cout << "UNRESTORABLE" << endl;
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    if(B-K+1 <= A+K) {
        for(int i = A; i <= B; i++) {
            cout << i << "\n";
        }
    }
    else {
        for(int i = A; i <= A+K-1; i++) {
            cout << i << "\n";
        }
        for(int i = B-K+1; i <= B; i++) {
            cout << i << "\n";
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 2e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N];
vector < int > g[N];

bool win(int v, int p = -1) {
  bool ans = 0;
  for (auto to : g[v]) {
    if (to != p && a[to] < a[v]) ans |= !win(to, v);
  }
  return ans;
}
void solve() { 
  cin >> n;
  for (int i = 1;i <= n;i++) cin >> a[i];
  for (int i = 1, u, v;i < n;i++) {
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  for (int i = 1;i <= n;i++) {
    if (win(i)) cout << i << " ";
  }
  cout << endl;
}
  
int main() {
  #ifdef wws
   freopen("in", "r", stdin);
   // freopen("in", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 5120
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};
ll N=1e5+5;



int main(){
    IOS;
    make2(ll,a,b);
    make2(ll,c,d);
    ll cd=(c*d)/gcd(c,d);
    cout<<b-(b/c+b/d-b/cd)-a+1+((a-1)/c+(a-1)/d-(a-1)/cd)<<endl;


    return 0;
}


Measured memory_bytes: 3608
import sys

def main():
    input = sys.stdin.readline
    N, D = map(int, input().split())
    X = []
    for _ in range(N):
        A = tuple(map(int, input().split()))
        X.append(A)

    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            s = 0
            for d in range(D):
                s += (X[i][d] - X[j][d])**2

            t = int(s**(0.5))
            if s == t**2:
                ans += 1

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRVI(N, X) VI X(N); for (int ___I=0; ___I<n; ___I++) scanf("%d", &(X[___I]))  
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
    DRII(a,b);
    DRII(c,d);

    if ((c-1)/b+1<=(a-1)/d+1) {printf("Yes\n");}
    else {printf("No\n");}
}


Measured memory_bytes: 3764
#include<stdio.h>
#include<string.h>

int main(void){
  char A[11],B[11],C[11];
  int len_A,len_B;
  scanf("%s%s%s",A,B,C);
  len_A = strlen(A);
  len_B = strlen(B);
  if(A[len_A-1] == B[0] && B[len_B-1] == C[0]){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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 long long INF = 1e10;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(int argc, const char * argv[]) {
    
  
    //input
    int N; cin >> N;
    vector<ll> h(100010);
    vector<ll> dp(100010);
    
    //initialize
    rep(i,N) cin >> h[i];
    rep(i,100010) dp[i] = INF;
    dp[0] = 0;
    
    rep(i,N) {
        chmin( dp[i], dp[i - 1] + abs(h[i] - h[i - 1]) );
        if(i>1){
            chmin( dp[i], dp[i - 2] + abs(h[i] - h[i - 2]) );
        }
    }
    
    cout << dp[N - 1] << endl;
    
    
    
}


Measured memory_bytes: 1792
S = input()

max_length = 0
length = 0
for s in S:
    if s in ["A", "C", "G", "T"]:
        length += 1
    else:
        if length > max_length:
            max_length = length
        length = 0
if length > max_length:
        max_length = length
print(max_length)

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

typedef vector <int> vi; 

int mod(int x, int y)
{
	return x > y ? x - y : y - x; 
}

int main()
{
	int x, y, n, i, j; 

	cin >> n; 

	vi h(n), dp(n); 

	for(i=0; i<n; i++)
	{
		cin >> h[i]; 
	}

	dp[0] = 0;  
	dp[1] = mod(h[0], h[1]); 

	for(i=2; i<n; i++)
	{
		x = mod(h[i], h[i - 1]);
		y = mod(h[i], h[i - 2]); 

		dp[i] = min(dp[i - 1] + x, dp[i - 2] + y);  
	}

	cout << dp[n - 1] << endl; 

	return 0; 
}

Measured memory_bytes: 1024
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
    for k in l[i]:print("",*k)
    if i!=3:print("#"*20)

Measured memory_bytes: 7792
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include <map>
#define ll long long int
#define skip cin>>ws;
#define vll vector<ll> 
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define vs vector<string>
#define vvpll vector<vector<pair<ll, ll>>>
#define pb push_back
#define pob pop_back()
#define MOD (ll)(1e9 + 7)
#define test ll t; cin>>t; while(t--)

using namespace std;

void enter(vll &ar)
{
    ll n = ar.size();
    for(ll i=0;i<n;i++) cin>>ar[i];
}

void show(vll &a)
{
    ll n = a.size();
    for(ll i=0;i<n;i++) cout<<a[i]<<" ";
    cout<<"\n";
}

void SieveOfErat1sthenes(int n, vll &pri) 
{ 
    vb prime(n+1, true); 
   
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        { 
            pri.pb(p);
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll mo(ll a)
{
    return a%MOD;
}

const ll maxn = 405;
const ll INF = 1e18 + 5;
ll dp[maxn][maxn];

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

    ll n;
    cin>>n;

    vll a(n);
    enter(a);

    for(ll i=n-1;i>=0;i--)
    {
        for(ll j=i;j<n;j++)
        {
            if(i==j)
            {
                dp[i][j] = 0;
            }
            else
            {
                ll sum = 0;

                for(ll k = i; k<=j; k++) sum += a[k];

                dp[i][j] = INF;
                for(ll k=i;k<=j-1;k++)
                {
                    dp[i][j] =  min(dp[i][j], dp[i][k] + dp[k+1][j] + sum);
                }
            }
        }
    }

    cout<<dp[0][n-1]<<"\n";

    return 0;
}

Measured memory_bytes: 4892