akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(P);
P dequeue(void);


P Q[LEN+1];
int head, tail, n;

void initialize(){
  head = tail = 0;
}

int isEmpty(){
  return head == tail;
}

int isFull(){
  return head == ( tail + 1 ) % LEN;
}

void enqueue(P x){
  if(isFull()) return;
  Q[tail] = x;
  if(tail+1 == LEN) tail = 0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty()) return;
  x = Q[head];
  if(head+1 == LEN) head = 0;
  else head++;
  return x;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  initialize();
  tail=n;
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  while(!isEmpty()){
    u = dequeue();

    if(u.t-q>0){
      u.t-=q;
      enqueue(u);
      elaps+=q;
    }else if(u.t!=(-1)){
      elaps+=u.t;
      printf("%s %d\n", u.name,elaps);
      u.t=(-1);
    }
  }



  return 0;
}

Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> sx(n),sy(n);
    rep(i,n) cin>>sx[i]>>sy[i];
    vector<int> gx(m),gy(m);
    rep(i,m) cin>>gx[i]>>gy[i];
    
    rep(i,n){
        int len=1e9;
        int ans=-1;
        rep(j,m){
            int temp=abs(sx[i]-gx[j])+abs(sy[i]-gy[j]);
            //cout<<i<<" "<<j<<":"<<temp<<endl;
            if(len>temp){
                len=temp;
                ans=j;
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=305;
int binom[N][N];
int dp[N][N],sum[N][N];
int main()
{
	int n,k,m,i,j,l;
	scanf("%i %i %i",&n,&k,&m);
	for(i=0;i<=n+1;i++)
	{
		binom[i][0]=1;
		if(i>0) for(j=1;j<=n+1;j++) binom[i][j]=(binom[i-1][j-1]+binom[i-1][j])%m;
	}
	for(i=1;i<=n+1;i++)
	{
		for(j=k;j>=0;j--)
		{
			if(i==1) dp[i][j]=1;
			else
			{
				for(l=1;l<i;l++)
				{
					int pre=sum[l][k]-sum[l][j];
					if(pre<0) pre+=m;
					int comb=binom[i-2][l-1];
					dp[i][j]+=(ll)comb*pre%m*dp[i-l][j]%m;
					if(dp[i][j]>=m) dp[i][j]-=m;
				}
			}
		}
		for(j=1;j<=k;j++) sum[i][j]=(sum[i][j-1]+dp[i][j])%m;
	}
	printf("%i\n",dp[n+1][0]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
#define pb                emplace_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (ll)((x).size())
#define ff                first
#define ss                second
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define isBitset(S,i)     ((S>>i)&1)
#define print(x) 		  for(auto it:x) cout<<it<<" "; cout<<"\n"; 
#define MOD 1000000007
vector<ll>ar[200001];
ll vis[200001];
ll c;
void dfs(ll node)
{
	vis[node]=1;
//	cout<<c<<" ";
	c++;
	for(auto child:ar[node])
	{
		if(!vis[child])
			dfs(child);
	}
}
void solve()
{
	ll n,m;cin>>n>>m;
	ll ans=-1;
	for(ll i=0;i<=n;++i)
	{
		ar[i].clear();
		vis[i]=0;
	}
	for(ll i=0;i<m;++i)
	{
		ll x,y;
		cin>>x>>y;
		ar[x].pb(y);
		ar[y].pb(x);
	}
	for(ll i=1;i<=n;++i)
	{
		c=0;
		if(!vis[i])
			dfs(i);
		ans=max(ans,c);
	}
	cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);    
        solve();
    return 0;
}

Measured memory_bytes: 22396
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  long long int a,cnt = 0;
  for(int i = 0;i < n;i++){
    scanf("%lld",&a);
    if(a % 2 > 0){
      cnt++;
    }
  }
  if(cnt % 2 < 1){
    printf("YES\n");
    return 0;
  }
  printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

struct node{
  node():parent(NULL),minimum(0){}
  node(node* p):parent(p),minimum(0){}
  vector<node*> children;
  node* parent;
  int minimum;
};
vector<node> nodes;

int dfs(node* p){
  if(p->children.size()==0){
    //    cout<<p->minimum<<endl;
    return p->minimum/2+1;
  }
  vector<int> mins;
  for(node* q:p->children)
    mins.push_back(dfs(q));
  sort(mins.begin(),mins.end());
  return accumulate(mins.begin(),next(mins.begin(),mins.size()/2+1),0);
}

void solve(){
  string s; cin>>s;
  nodes.clear();
  nodes.reserve(5000);
  node* p=NULL;
  int num=0;
  for(char c:s){
    if(c=='['){
      nodes.push_back(node(p));
      node* child = &(*nodes.rbegin());
      if(p!=NULL)
	p->children.push_back(child);
      p=child;
    }else if(c==']'){
      p->minimum=num;
      p=p->parent;
      num=0;
    }else{
      num=num*10+(c-'0');
    }
  }
  cout<<dfs(&nodes[0])<<endl;
}

int main(){ _;
  int n;cin>>n;
  REP(i,n) solve();
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void f(set<ll> &s, ll &sl, ll &sr, ll x){
  sl = -1e18, sr = 1e18;
  auto sitr = s.lower_bound(x);
  if(sitr != s.end()) sr = *sitr;
  if(sitr != s.begin()){
    sitr--;
    sl = *sitr;
  }
}

ll ff(ll x, ll s, ll t){
  return min(abs(x-s), abs(x-t)) + abs(s-t);
}

ll fc(set<ll> &s, set<ll> &t, ll x){
  ll sl = -1e18, sr = 1e18, tl = -1e18, tr = 1e18;
  f(s, sl, sr, x);
  f(t, tl, tr, x);
  return min({ff(x, sl, tl), ff(x, sl, tr), ff(x, sr, tl), ff(x, sr, tr)});
}

int main(){
  int a, b, qe;
  cin >> a >> b >> qe;
  set<ll> s, t;
  rep(i, a){
    ll in;
    cin >> in;
    s.insert(in);
  }
  rep(i, b){
    ll in;
    cin >> in;
    t.insert(in);
  }
  rep(_q, qe){
    ll x;
    cin >> x;
    cout << fc(s, t, x) << endl;
  }
  return 0;
}

Measured memory_bytes: 12960
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

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

  void run() {
    int n = ni();
    int[] a = new int[n];
    for (int i = 0; i < n; ++i) {
      a[i] = ni();
    }

    int min = 1 << 28;
    for (int i = -100; i <= 100; ++i) {
      int sum = 0;
      for (int j = 0; j < n; ++j) {
        sum += (a[j] - i) * (a[j] - i);
      }
      min = Math.min(min, sum);
    }
    System.out.println(min);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 9812
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 100000 + 10;
const int mod = 1e9+7;
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    IOS
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
int n,m,i,j,dp[1005][5005],dp2[5005],used[1005],x,mx=1,num[1005],vis[1005];
vector<int> bi[1005];
pair<int,int> dfs3(int x)
{
	int i,j;
	for (i=0;i<bi[x].size();i++)
	{
		pair<int,int> nxt=dfs3(bi[x][i]);
		fill(dp2,dp2+5005,1e9+7);
		for (j=5000-nxt.second;j>=0;j--)
		{
			dp2[j+nxt.second]=min(dp2[j+nxt.second],dp[x][j]+nxt.first);
		}
		for (j=5000-nxt.first;j>=0;j--)
		{
			dp2[j+nxt.first]=min(dp2[j+nxt.first],dp[x][j]+nxt.second);
		}
		for (j=0;j<=5000;j++)
		{
			dp[x][j]=dp2[j];
		}
		j++;
		j--;
		j++;
		j--;
	}
	return pair<int,int>{num[x],dp[x][num[x]]}; 
} 
int main()
{
	cin>>n;
	for (i=2;i<=n;i++)
	{
		cin>>x;
		bi[x].push_back(i);
	}
	for (i=1;i<=n;i++) cin>>num[i]; 
	if (dfs3(1).second==1e9+7) cout<<"IM";
	cout<<"POSSIBLE";
	return 0;
}

Measured memory_bytes: 19456
n = int(input())
count = {}
s = 0
a = [int(c) for c in input().split()]
for val in a:
	s += val
	if (val not in count): count[val] = 1
	else: count[val] += 1

q = int(input())
for _ in range(q):
	b, c = [int(c) for c in input().split()]
	if (b in count):
		temp = count[b]
		count.pop(b)
		s = s + c*temp - b*temp 
		if (c not in count): count[c] = temp 
		else: count[c] += temp
	print(s)


Measured memory_bytes: 93664
#include<stdio.h>
#include<string.h>
#define N 2000000             
#define L 12                   
#define NIL (-1)
#define TRUE 1
#define FALSE 0

char H[N][L];

int getnum(char c){
  if(c=='A') return 1;
  else if(c=='C') return 2;
  else if(c=='G') return 3;
  else if(c=='T') return 4;
  else return 0;
}

long long getkey(char c[]){
  long long sum=0,i,j=1;
  for(i=0;i<strlen(c);i++){
    sum+=j*(getnum(c[i]));
    j*=5;
  }
  return sum;
}

int h1(int key){
  return key%N;
}
int h2(int key){
  return 1+(key%(N-1));                          
}

int search(char c[]){
  long long key,i,h;
  key=getkey(c);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%N;
    if(strcmp(H[h],c)==0) return TRUE;
    else if(H[h][0]=='0') return FALSE;
  }
  return FALSE;
}

void insert(char c[]){
  long long key,i,h;
  key=getkey(c);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%N;
    if(strcmp(H[h],c)==0) return;
    else if(H[h][0]=='0'){
      strcpy(H[h],c);
      return;
    }
  }
}

int main(){
  int i,j=0,n,h,a[N],sum=0;
  char c[L],order[10];
  for(i=0;i<N;i++) H[i][0]='0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",order,c);
    if(order[0]=='i'){
      insert(c);                       
    }
    else{
      sum++;
      if(search(c)==TRUE) a[j]=TRUE; 
      else a[j]=FALSE;
      j++;
      }
    }
  for(i=0;i<sum;i++){
    if(a[i]==TRUE) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}



Measured memory_bytes: 26912
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,a,q,b,c;
    cin>>n;
    map<int,int>mp;
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a;
        mp[a]++;
        sum+=a;
    }
    cin>>q;
    while(cin>>b>>c){
        sum+=(c-b)*mp[b];
        cout<<sum<<endl;
        mp[c]+=mp[b];
        mp[b]=0;
    }
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int> > vals(n);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i]; --a[i];
        vals[a[i]].push_back(b[i]);
    }
    for (int i = 0; i < n; ++i) sort(vals[i].begin(), vals[i].end());
    for (int i = 0; i < m; ++i) {
        printf("%06d", a[i] + 1);
        int id = lower_bound(vals[a[i]].begin(), vals[a[i]].end(), b[i]) - vals[a[i]].begin();
        printf("%06d\n", id + 1);
    }
}

Measured memory_bytes: 7808
def root(a, x)
  a[x] < 0 ? x : a[x] = root(a, a[x])
end

def unite(a, x, y)
  x, y = root(a, x), root(a, y)
  if x != y
    x, y = y, x if a[y] < a[x]
    a[x] += a[y]
    a[y] = x
  end
end

N, K, L = gets.split.map(&:to_i)
@p = Array.new(N + 1, -1)
K.times{unite(@p, *gets.split.map(&:to_i))}
@r = Array.new(N + 1, -1)
L.times{unite(@r, *gets.split.map(&:to_i))}
ks = (1 .. N).map{|i| [root(@p, i), root(@r, i)]}
res = ks.each_with_object(Hash.new(0)){|k, h| h[k] += 1}
puts ks.map{|k| res[k]}.join(' ')

Measured memory_bytes: 33532
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (998244353)

int main(void)
{
    char s[101];
    scanf("%s",s);

    for(int i=0;s[i]!='\0';i++)
    {
        if((i+1)%2==1) //奇数
        {
            if(s[i]=='L')
            {
                printf("No\n");
                return 0;
            }
        }else
        {
            if(s[i]=='R')
            {
                printf("No\n");
                return 0;                
            }
        }
        
    }

 
    printf("Yes\n");
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using int64 = int64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<int64> dp(w + 1, 0);
  while (n--) {
    int x, y;
    cin >> x >> y;
    for (int i = w; i >= x; i--) {
      dp[i] = max(dp[i], dp[i - x] + (int64)y);
    }
  }
  cout << dp[w];
  return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<typename T>
struct BIT{
    private:
        using Func = function<T(T, T)>;

        int n;
        vector<T> node;

        T init_v;
        Func func;

    public:

        BIT(int N, Func _func, T _init_v) {
            n = N + 1;
            init_v = _init_v;
            func = _func;

            node.resize(n, init_v);
            for(int i=1; i<n; i++) if((i+(i&-i)) < n) node[i+(i&-i)] = func(node[i+(i&-i)], node[i]);
        }

        BIT() {}

        void add(int pos, T v) {
            // 0-indexed
            pos++;
            while(pos < n){
                node[pos] = func(node[pos], v);
                pos += pos & -pos;
            }
        }

        T sum(int pos){
            // 0-indexed
            // [0,pos]の総和
            pos++;
            T res = init_v;
            while(pos > 0){
                res = func(res, node[pos]);
                pos = pos & (pos-1);
            }
            return res;
        }

        T sum(int l, int r){
            // 0-indexed
            // [l,r)の総和
            return sum(r-1) - sum(l-1);
        }
};
ll f(ll a, ll b){return a+b;}

void Main(){
    int N,Q; cin >> N >> Q;
    BIT<ll> bit(N,f,0);
    REP(i,N){
        ll a; cin >> a;
        bit.add(i,a);
    }

    REP(_,Q){
        int t; cin >> t;
        if(t == 0){
            ll p,x; cin >> p >> x;
            bit.add(p,x);
        }
        else{
            int l,r; cin >> l >> r;
            cout << bit.sum(l,r) << en;
        }
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 8248
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int X;
  cin >> X;
  
  for( int i = 1; i <= X; i++ ){
    if( i*(i+1)/2 >= X ){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,g;
	int x,y;
	while(scanf("%d %d",&a,&b) != EOF){
		if(a > b){
			x=a;y=b;
		}else{
			x=b;y=a;
		}
		while(a != b){
			if(a > b){
				a = a-b;
			}else{
				b = b-a;
			}
		}
		printf("%d %d\n",a,x*(y/a));
	}
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        // cout << " " << *t++;
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<string> l;
    string s, t;
    int k;
    cin >> s >> k;
    rep(j, 1, k + 1) rep(i, s.size() - j + 1) { l.insert(s.substr(i, j)); }
    auto a = l.begin();
    rep(i, k - 1) a++;
    cout << *a << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    x[i] = tmp;
  }
  if (n >= m) {
    cout << 0 << '\n';
    return 0;
  }
  sort(x.begin(), x.end());
  vector<int> dif(m - 1);
  for (int i = 0; i < m - 1; i++) {
    dif[i] = x[i + 1] - x[i];
  }
  sort(dif.begin(), dif.end());
  int ans = 0;
  for (int i = 0; i < m - n; i++) {
    ans += dif[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int n;
int dis[100005] = {0};
int memo[100005] = {0};
bool ch[100005] = {0};
vector<int> edge[100005];

void prians(bool answer) {
  if(answer)
    cout << "Fennec" << endl;
  else
    cout << "Snuke" << endl;
}
bool solve();

int main() {
  cin >> n;
  for(int i = 1; i <= n; ++i) dis[i] = 100000000;
  dis[1] = 0;
  for(int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  prians(solve());
  return 0;
}

bool solve() {
  queue<int> qu, qfs[2];
  int cnt[2] = {0};
  qu.push(1);
  while(!qu.empty()) {
    int now = qu.front();
    qu.pop();
    for(int i = 0; i < edge[now].size(); ++i) {
      int nextn = edge[now][i];
      if(dis[now] + 1 < dis[nextn]) {
        qu.push(nextn);
        memo[nextn] = now;
        dis[nextn] = dis[now] + 1;
      }
    }
  }
  int halfdist = (dis[n] - 1) / 2, from = n, to = memo[n];
  for(int i = 0; i < halfdist; ++i) {
    from = to;
    to = memo[from];
  }
  if(from > to) swap(from, to);
  qfs[0].push(1);
  qfs[1].push(n);
  ch[1] = ch[n] = 1;
  for(int i = 0; i < 2; ++i) {
    while(!qfs[i].empty()) {
      int now = qfs[i].front();
      qfs[i].pop();
      for(int j = 0; j < edge[now].size(); ++j) {
        int nextn = edge[now][j];
        if(min(now, nextn) == from && max(now, nextn) == to)
          continue;
        if(!ch[nextn]) {
          ch[nextn] = 1;
          qfs[i].push(nextn);
          ++cnt[i];
        }
      }
    }
  }
  return cnt[0] > cnt[1];
}

Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s, a = "", b = "";
    cin >> s;
    int q, qi, ai = 1, bi = 2, cnt1 = 0;
    cin >> q;
    while(q--) {
        cin >> qi;
        if(qi == 1) {
            swap(ai, bi);
            ++cnt1;
        } else {
            int abi; char c;
            cin >> abi >> c;
            if(abi == ai) {
                a.push_back(c);
            } else {
                b.push_back(c);
            }
        }
    }
    if(cnt1 % 2) {
        swap(a, b);
        reverse(s.begin(), s.end());
    }
    for(int i=a.size()-1;i>=0;--i) cout << a[i];
    cout << s;
    for(int i=0;i<b.size();++i) cout << b[i];
    cout << endl;
}


Measured memory_bytes: 1104
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define pai 3.1415926535


int main(void) {

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

	printf("%d\n", 180 * (N - 2));

	return 0;
}

Measured memory_bytes: 128
import sys

input = sys.stdin.readline


class UnionFind:
    """Union Find class.

    "Path compression" and "Union by rank" are used.

    References:
        <https://en.wikipedia.org/wiki/Disjoint-set_data_structure>
    """

    def __init__(self, N):
        self.N = N
        self.__make_set()

    def __make_set(self):
        self._parent = list(range(self.N + 1))
        self._rank = [0] * (self.N + 1)
        self._size = [1] * (self.N + 1)

    def find(self, x):
        if self._parent[x] != x:
            self._parent[x] = self.find(self._parent[x])
        return self._parent[x]

    def union(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)

        if x_root == y_root:
            return

        x_rank = self._rank[x_root]
        y_rank = self._rank[y_root]
        if x_rank > y_rank:
            self._parent[y_root] = x_root
            self._size[x_root] += self._size[y_root]
        elif x_rank < y_rank:
            self._parent[x_root] = y_root
            self._size[y_root] += self._size[x_root]
        else:
            self._parent[y_root] = x_root
            self._rank[x_root] += 1
            self._size[x_root] += self._size[y_root]

    def same_set(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self._size[self.find(x)]


def main():
    N, M = map(int, input().split())
    a = [None] * M
    b = [None] * M
    for i in range(M):
        a[i], b[i] = map(int, input().split())

    ans = 0
    for i in range(M):
        uf = UnionFind(N)
        for j in range(M):
            if j == i:
                continue
            uf.union(a[j], b[j])
        if not uf.same_set(a[i], b[i]):
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9272
#include<iostream>
using namespace std;
int main(){
int N;
int i;
int j;
cin>>N;
int judge;
bool flag=false;
int cake=N/4;
int donut=N/7;
for(i=0;i<=cake;i++){
for(j=0;j<=donut;j++){
  judge=7*j+4*i;
  if(judge==N){
  flag=true;
    break;
 }
}
}
  if(flag==true){
  cout<<"Yes";}
  else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
# from urllib.parse import urljoin

def testcase_ends():
    n, m = map(int, input().split())
    if (n, m) == (0, 0):
        return 1

    htmls = set(input() for i in range(n))
    files = set('/')
    for html in htmls:
        sp = html.split('/')
        for i in range(2, len(sp)):
            files.add('/'.join(sp[:i]) + '/')

        files.add(html)

    def find(url):
        has_ts = url.endswith('/')
        url = url.rstrip('/')
        sp = url.split('/')[1:]
        u = ['']
        for i, c in enumerate(sp, 1):
            if c == '..':
                if len(u) == 0: return None  # ???
                u.pop()
            elif c == '.':
                pass
            else:
                u.append(c)

            if ('/'.join(u) + '/') not in files:
                if i < len(sp):
                    return None
        else:
            u = '/'.join(u)

        if u.endswith('/') and (u+'index.html') in files:
            return u+'index.html'

        if (u+'/index.html') in files:
            return u+'/index.html'

        if u in files and not has_ts:
            return u

        return None

    for i in range(m):
        p1 = input()
        p2 = input()

        p1 = find(p1)
        p2 = find(p2)

        if p1 is None or p2 is None:
            print('not found')
        elif p1 == p2:
            print('yes')
        else:
            print('no')

def main():
    while not testcase_ends():
        pass

if __name__ == '__main__':
    main()



Measured memory_bytes: 5616
N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

AB = sorted([i for i in range(N)], key=lambda x: A[x] + B[x], reverse=True)
x, y = 0, 0
for (cnt, i) in enumerate(AB):
    if cnt % 2 == 0: 
        x += A[i]
    else:
        y += B[i]
print(x - y)


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

int main() {
    //A 
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    string ans = "APPROVED";
    rep(i,n){
        if (a[i]%2 == 1) continue;
        if (a[i]%3 != 0 && a[i]%5 != 0) ans = "DENIED";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void output(int array[],int array2[],int number){
    int num = 0;
    for(int j = 0;j<number;j++){
        num = num + array[j]*array2[j];               
    }
    cout<<num<<endl;
}

int main(){
    int m,f,r;
    cin>>m>>f>>r;
    while(m != -1 || f != -1 || r != -1){
        int score = m+f;
        if(m == -1 || f == -1){
            cout<<"F"<<endl; 
        }else{
            if(score >= 80){
                cout<<"A"<<endl;
            }else if(score >= 65){
                cout<<"B"<<endl;
            }else if(score >= 50){
                cout<<"C"<<endl;
            }else if(score >= 30){
                if(r >= 50)
                    cout<<"C"<<endl;
                else
                {
                    cout<<"D"<<endl;
                }
                
            }else{
               cout<<"F"<<endl; 
            }
        }
       cin>>m>>f>>r; 
    }
    return 0;
}


Measured memory_bytes: 3084
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}
func sortDesc(ar []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(ar)))
	return ar
}
func createTriangles(rods []int) (total int) {
	rods = sortDesc(rods)
	n := len(rods)
	for a := 0; a < n; a++ {
		rodA := rods[a]
		for b := a + 1; b < n; b++ {
			rodB := rods[b]
			for c := b + 1; c < n; c++ {
				rodC := rods[c]
				if rodA >= rodB+rodC || rodB >= rodC+rodA && rodC >= rodA+rodB {
					break
				}
				total++
			}
		}
	}
	return
}
func main() {
	n := nextInt()
	rods := nextInts(n)
	fmt.Println(createTriangles(rods))
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll A, B;
    cin >> A >> B;
    cout << A * B << endl;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys


def solve(N: int):
    S = str(N)
    keta = len(S)
    if S[1:].count("9") == keta-1:
        print(9*(keta-1)+int(S[0]))
        return
    
    if keta == 1:
        print(N)
        return

    print(int(S[0])-1+9*(keta-1))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout << '\n';
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

const int N=5e5+107;
vector<int> adj[N];
vector<int> h(N);

bool isvis(int yo){
  int itsheight=h[yo];
    //deb(itsheight);
  for(auto u:adj[yo]){
    if(h[u]>=itsheight){
      return 0;
    }
  }
  return 1;
}

void solve(){
  int n,m; cin>>n>>m;
  for(int i=1 ; i<=n ; i++){
    cin>>h[i];
  }
  for(int i=0,u,v ; i<m ; i++){
    cin>>u>>v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  int cnt=0;
  for(int i=1 ; i<=n ; i++){
    if(isvis(i)){
      cnt++;
    }
 //     deb(cnt);
  }
  cout<<(cnt);LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1; //cin >> _;
  for(int i = 1 ; i <= _ ; i++){
    //cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 22392
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<mint> dp(4, 0);
    dp[3] = 1;
    for (int i = 1; i <= n; ++i) {
        if (s[i - 1] == 'A')
            dp[0] += dp[3];
        else if (s[i - 1] == 'B')
            dp[1] += dp[0];
        else if (s[i - 1] == 'C')
            dp[2] += dp[1];
        else { // '?'
            mint dp3 = dp[3];
            mint dp2 = dp[2];
            mint dp1 = dp[1];
            mint dp0 = dp[0];
            dp[2]    = dp2 * 3 + dp1;
            dp[1]    = dp1 * 3 + dp0;
            dp[0]    = dp0 * 3 + dp3;
            dp[3] *= 3;
        }
    }
    cout << dp[2] << "\n";
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int j = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (j == 0 && s[i] == 'C' || j == 1 && s[i] == 'F') ++j;
  }
  cout << (j == 2 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  string S;
  cin >> S;
  if(S[0] != S[1]) if(S[1] != S[2]) if(S[2] != S[0]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
students = []
for _ in range(N):
    students.append([int(x) for x in stdin.readline().rstrip().split()])

checkpoints = []
for _ in range(M):
    checkpoints.append([int(x) for x in stdin.readline().rstrip().split()])

for i in students:
    tmp = 10**9 
    for ind,j in enumerate(checkpoints):
        dist = abs(i[0] - j[0]) + abs(i[1] - j[1])
        if dist < tmp:
            tmp = dist
            ans = ind+1
    print(ans)

Measured memory_bytes: 3064
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

__attribute__((constructor)) static void init()
{
    ios::sync_with_stdio(false);
    std::cin.tie(0);
}

int main()
{
    i64 x;
    cin >> x;

    i64 n = 100;
    int count = 0;
    while (n < x) {
        n *= 1.01;
        count++;
    }

    cout << count << "\n";
}


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

struct Position{
    double x;
    double y;
    Position(double x, double y) : x(x), y(y) {}
};

void Koch(Position p1, Position p2, vector<Position>& k, int n) {
    if (n == 0) return;
    Position s((2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3);
    Position t((2 * p2.x + p1.x) / 3, (2 * p2.y + p1.y) / 3);
    double u_x = (t.x - s.x) / 2 - sqrt(3) * (t.y - s.y) / 2 + s.x;
    double u_y = sqrt(3.0) * (t.x - s.x) / 2 + (t.y - s.y) / 2 + s.y;
    Position u(u_x, u_y);
    Koch(p1, s , k, n - 1);
    k.push_back(s);
    Koch(s , u , k, n - 1);
    k.push_back(u);
    Koch(u , t , k, n - 1);
    k.push_back(t);
    Koch(t , p2, k, n - 1);
}

int main(){
    int n;
    cin >> n;
    Position p1(0 , 0);
    Position p2(100, 0);
    vector<Position> k;
    k.push_back(p1);
    Koch(p1, p2, k, n);
    k.push_back(p2);
    for (const auto& e : k) {
        cout << e.x << " " << e.y << endl;
    }
    return 0;
}

Measured memory_bytes: 3312
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	ans := "Yes"
	if N == 1 {
		fmt.Println(ans)
		return
	}

	last := 0
	prev := nextInt()
	for i := 1; i < N; i++ {
		cur := nextInt()
		//fmt.Println(prev, cur)
		if prev == cur {
			continue
		} else if prev > cur {
			if prev-cur == 1 {
				last++
			} else {
				ans = "No"
				break
			}
		} else {
			last = 0
		}

		if last > 1 {
			ans = "No"
			break
		}
		prev = cur
	}
	fmt.Println(ans)

}


Measured memory_bytes: 3392
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;

int main(){
    int x,a;
    cin >> x >> a;
    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
}

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

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

    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    long sum = 0;

    for(int i=0; i<N; i++){
        sum+=A.at(i);
    }

    if(4 * M * A.at(M-1) < sum ) cout << "No" << endl;
    else cout << "Yes" << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

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

Node root;

Node treeMinimum(Node x){
	Node c = x;
	while (c->left != NIL){
		c = c->left;
	}
	return c;
}

Node treeMaximum(Node x){
	Node c = x;
	while (c->right != NIL){
		c = c->right;
	}
	return c;
}

Node treeSearch(Node u, int k){
	if (u == NIL) return NIL;
	if (u->key = k) return u;
	Node n = treeSearch(u->left, k);
	if (n != NIL) return n;
	Node m = treeSearch(u->right, k);
	if (m != NIL) return m;
	return NIL;
}

/*Node treeSuccessor(Node x){


}*/

void treeDelete(Node z){
	if (z->left != NIL) treeDelete(z->left);
	if (z->right != NIL) treeDelete(z->right);
	if (z != root) delete z;
	return;
}

void insert(int k){
	Node y = NIL;
	Node x = root;
	Node z = new 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;
	}

	return;


}

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


int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	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");
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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 int INF = 1001001001;
// long long max => LLONG_MAX

const ll mod = 1000000007;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n, m; cin >> n >> m;
    if(m > n) swap(n,m);
    ll ans = 1;
    if(n == m) {
        for(ll i = n; i >= 1; i--){
            ans *= i;
            ans %= mod;
            ans *= i;
            ans %= mod;
        }
        ans *= 2;
        ans %= mod;
    } else if(n == m+1){
        ans = n;
        for(ll i = n-1; i >= 1; i--){
            ans *= i;
            ans %= mod;
            ans *= i;
            ans %= mod;
        }
    } else ans = 0;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	for i, move := range s {
		if i%2 == 0 {
			switch string(move) {
			case "R", "U", "D":
				continue
			default:
				fmt.Println("No")
				return
			}
		} else {
			switch string(move) {
			case "L", "U", "D":
				continue
			default:
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 1780
using System;
using System.Collections.Generic;

namespace abc138_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var v = CIn.ReadIntArray(n);

      Array.Sort(v);

      var sum = (double)v[0] / Math.Pow(2, n - 1);

      for (var i = 1; i < n; i++)
      {
        sum += v[i] / Math.Pow(2, n - i);
      }

      Console.WriteLine(sum);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int H, W;
  cin >> H >> W;
  vector<string> field(H);
  REP(h,H){
    string s;
    cin >> s;
    field[h] = s;
  }
  vector<string> field2;
  //縦の圧縮
  REP(h,H){
    bool ok = false;
    REP(w,W){
      if(field[h][w] == '#'){
        ok = true;
        break;
      }
    }
    if(!ok) continue;
    field2.push_back(field[h]);
  }

  int H2 = field2.size();

  vector<string> field3(H2);
  REP(w,W){
    bool ok = false;
    REP(h,H2){
      if(field2[h][w] == '#'){
        ok = true;
        break;
      }
    }
    if(!ok) continue;
    REP(h,H2){
      field3[h].push_back(field2[h][w]);
    }
  }

  REP(h,field3.size()){
    cout << field3[h] << endl;
  }


  return 0;
}


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

int		main(void)
{
	int N, sum = 0;

	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++)
		cin >> vec[i];
	int i = 0;
	for (int j = 0; j < N; j++)
	{
		sum++;
		if (vec[i] == 2)
		{
			cout << sum << endl;
			return (0);
		}
		i = vec[i] - 1;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
int main(){
	string str;
	cin>>str;
	
	stack<int> s;
	s.push(str[0]);
	ll co = 0;
	for(int i = 1; i < str.size(); i++){
		if(s.empty()) {s.push(str[i]); continue;}
		if(str[i] != s.top()) { co += 2; s.pop(); }
		else s.push(str[i]);
	}
	cout<<co<<"\n";
	return 0;
}

Measured memory_bytes: 768
S = input()
lS = len(S)

if (S == S[::-1]):
    s1 = S[0:lS // 2]
    s2 = S[lS // 2 + 1:lS]
    if (s1 == s1[::-1]) and (s2 == s2[::-1]):
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int m = scn.nextInt();

        int[][] a = new int[n][m];
        int b[] = new int[m];
        int c[] = new int[n];
        Arrays.fill(c,0);

        for (int i = 0; i < n; i++) {
            for (int j=0; j < m; j++) {
                a[i][j] = scn.nextInt();
            }
        }
        for (int i = 0; i < m; i++) {
            b[i] = scn.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                c[i]= c[i]+a[i][j]*b[j];
            }
            System.out.println(c[i]);
        }



        scn.close();

    }


}


Measured memory_bytes: 40820