akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    int a, b, c;
    int r; cin >> r;
    cout << 3 * r * r << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

#define MAX 10000
#define INFTY (1 << 20)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
vector<pair<int, int> > adj[MAX];

void solve(void) {
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];
    for(int i = 0; i < n; ++i) {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;
    
    while(!PQ.empty()) {
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        color[u] = BLACK;
        
        if(d[u] < f.first * (-1)) continue;
        
        for(int i = 0; i < adj[u].size(); ++i) {
            int v = adj[u][i].first;
            if(color[v] == BLACK) continue;
            if(d[v] > d[u] + adj[u][i].second) {
                d[v] = d[u] + adj[u][i].second;
                PQ.push(make_pair(d[v] * (-1),v));
                color[v] = GRAY;
            }
        }
    }
    
    for(int i = 0; i < n; ++i) {
        cout << i << ' ' << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main(void) {
    int k, u, v, c;
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> u >> k;
        for(int j = 0; j < k; ++j) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }
    
    solve();
    
    return 0;
}


Measured memory_bytes: 8000
#include<stdio.h>
#include<stdlib.h>
int L[4][3];
void initial(int value[]){
	memset(L,0,sizeof(L));
	L[1][1]=value[0],L[2][1]=value[1],L[1][2]=value[2];
	L[1][0]=value[3],L[0][1]=value[4],L[3][1]=value[5];}
void operate(char code){
	if(code=='S') 
		L[0][0]=L[1][1],L[1][1]=L[0][1],L[0][1]=L[3][1],L[3][1]=L[2][1],L[2][1]=L[0][0];
	else if(code=='N')
		L[0][0]=L[1][1],L[1][1]=L[2][1],L[2][1]=L[3][1],L[3][1]=L[0][1],L[0][1]=L[0][0];
	else if(code=='E')
		L[0][0]=L[1][1],L[1][1]=L[1][0],L[1][0]=L[3][1],L[3][1]=L[1][2],L[1][2]=L[0][0];
	else if(code=='W')
		L[0][0]=L[1][1],L[1][1]=L[1][2],L[1][2]=L[3][1],L[3][1]=L[1][0],L[1][0]=L[0][0];
	else return;
}
int main(){
	int value[10],len=0;
	char c;
	for(int i=0;i<6;++i)
		scanf("%d",value+i);
	initial(value);
	while((c=getchar())!=EOF)
		operate(c);
	printf("%d\n",L[1][1]);
	return 0;
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] = tolower(S[K-1]);
    res = S;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


bool binarySearch(int A[], int n, int key) {
    int left = 0;
    int right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (key == A[mid]) return true;
        else if (key < A[mid]) right = mid;
        else if (key > A[mid]) left = mid + 1;
    }
    return false;
}

int main() {
    int n, S[100005];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }

    int q;
    int cnt = 0;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if (binarySearch(S, n, t)) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int mn = 1001001001;
	if(x < y){
		swap(x, y);
		swap(a, b);
	}
	int cost = 0;
	// case 1
	cost = a * x + b * y;
	mn = min(mn, cost);
	// case 2
	cost = y * c * 2 + (x - y) * a;
	mn = min(mn, cost);
	// case 3
	cost = x * c * 2;
	mn = min(mn, cost);
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = input()

hsc = []
if s[0] == '0':
    hsc.append(0)
pre = s[0]
cnt = 0
for c in s:
    if c == pre:
        cnt += 1
    else:
        hsc.append(cnt)
        pre = c
        cnt = 1
hsc.append(cnt)

_max = sum(hsc[0:2*k+1])
tmp = _max
r = 2 * k + 1
for i in range(2, n, 2):
    l_sum = sum(hsc[i-2:i])
    r_sum = sum(hsc[r:r+2])
    r += 2
    tmp -= l_sum
    tmp += r_sum
    _max = max(_max, tmp)

print(_max)


Measured memory_bytes: 4596
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int a,b,n;
  int ai,bi;
  while(cin>>n,n){
	  a=b=0;
	  for(int i=0;i<n;i++)
	  {
		  cin>>ai>>bi;
		  if(ai>bi) a+=ai+bi;
		  else if(bi>ai) b+=ai+bi;
		  else{
			  a+=ai;
			  b+=bi;
		  }
	  }
	 cout<<a<<' '<<b<<endl;
  }
    return 0;
}


Measured memory_bytes: 5408
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1;i<=n; i++) {
			if (i % 3 == 0) {
				System.out.print(" " + i);
			} else if (i % 10 == 3) {
				System.out.print(" " + i);
			} else {
				for (int k = i;k>=10;) {
					k /= 10;
					if (k % 10 == 3) {
						System.out.print(" " + i);
						break;
					}

				}
			}
		}
		System.out.println();
	}
}



Measured memory_bytes: 28688
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        string s;cin>>s;
        if(s=="0")break;
        int count=0;
        for(int i=0;i<s.size();i++){
            count+=s[i]-'0';
        }
        cout<<count<<endl;
    }
}


Measured memory_bytes: 3232
n,mondaisuu=map(int,input().split())
s=input()
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1] + (1 if s[i]=="C" and s[i-1]=="A" else 0)
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(dp[r-1]-dp[l-1])

Measured memory_bytes: 7668
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)
t = list("ACGT")

ans = 0
cnt = 0
for i in range(N):
  if s[i] in t:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
else:
  ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 38256
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;

/* sample input

*/
int n;
string str;

int main()
{
	cin >> str;
	int len = str.length();

	int count = 0;
	int answer = INT_MAX;
	for (int i = 0; i < 26; i++){
		count = 0;
		int tmax = 0;
		for (int j = 0; j < len; j++){
			if (str[j] != char('a' + i)){
				count++;
				tmax = max(tmax, count);
			}
			else{
				count = 0;
			}
		}
		answer = min(tmax, answer);
	}

	cout << answer;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
        long max = 0;
        long min = Long.MAX_VALUE;
        for(int i=0;i<N;++i){
            long a = sc.nextLong();
            if(a>max) max = a;
            if(a<min) min = a;
        }
        System.out.println(max-min);
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int d;
     cin>>d;
     if(d==25)
     {
         cout<<"Christmas"<<endl;
     }
     else if(d==24)
     {
         cout<<"Christmas Eve"<<endl;
     }
     else if(d==23)
     {
         cout<<"Christmas Eve Eve"<<endl;
     }
     else if(d==22)
     {
         cout<<"Christmas Eve Eve Eve"<<endl;
     }
     return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;
  if (a > b) dump("Alice");
  else if (a < b) dump("Bob");
  else dump("Draw");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
int n,m,d[N];
struct mzls
{
	int a,b,id;
	bool operator<(const mzls &x1)const
	{
		return b<x1.b;
	}
}a1[N];
priority_queue<mzls>que;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a1[i].a),a1[i].id=i;
	for(int i=1;i<=n;i++)
		scanf("%d",&a1[i].b);
	for(int i=1;i<=n;i++)
	{
		if(a1[i].a>a1[i].b)
		{
			printf("-1");
			return 0;
		}
		if(a1[i].a!=a1[i].b)
			que.push(a1[i]);
	}
	long long ans=0;
	while(!que.empty())
	{
		mzls ml=que.top();
		que.pop();
		int d1=ml.id;
		int x1=d1-1,y1=d1+1;
		if(x1==0)
			x1=n;
		if(y1==n+1)
			y1=1;
		int x2=(ml.b-ml.a)/(a1[x1].b+a1[y1].b);
		if(!x2)
		{
			printf("-1");
			return 0;
		}
		ans+=x2;
		ml.b-=x2*(a1[x1].b+a1[y1].b);
		a1[ml.id].b-=x2*(a1[x1].b+a1[y1].b);
		if(ml.b!=ml.a)
			que.push(ml);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 9076
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		String s = sc.next();

		String ans = a >= 3200 ? s : "red";
		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int a; cin >> a;
    yn(a>=30);
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int odd[100005] = {0}, even[100005] = {0};
int main(){
	int N, x;
	scanf("%d",&N);
	for(int i = 0 ; i < N ; ++i){
		scanf("%d",&x);
		if(i%2)
			odd[x]++;
		else	
			even[x]++;
	}
	int omax = 0,emax = 0;
	int oind, eind;
	for(int i = 1 ; i <= 100000 ; ++i){
		if(odd[i] >= omax){
			omax = odd[i];
			oind = i;
		}
		if(even[i] >= emax){
			emax = even[i];
			eind = i;
		}
	}
	if(oind == eind){
		if(omax > emax){
			even[eind] = 0;
			emax = 0;
			for(int i = 1 ; i <= 100000 ; ++i){
				if(even[i] >= emax){
					emax = even[i];
					eind = i;
				}
			}
		}
		else if(omax < emax){
			odd[eind] = 0;
			omax = 0;
			for(int i = 1 ; i <= 100000 ; ++i){
				if(odd[i] >= omax){
					omax = odd[i];
					oind = i;
				}
			}
		}
		
		else{
			even[eind] = 0;
			odd[oind] = 0;
			int esed = 0,osed = 0;
			for(int i = 1 ; i <= 100000 ; ++i){
				if(odd[i] > osed)
					osed = odd[i];
				
			}
			for(int i = 1 ; i <= 100000 ; ++i){
				if(even[i] >= esed)
					esed = even[i];
				
			}
			if(esed > osed)
				emax = esed;
			else
				omax = osed;
		}
			
	} 
	//printf("%d %d %d %d\n",oind,omax,eind,emax);
	printf("%d\n",N - omax - emax);
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int x, ma=1;
    cin >> x;
    for(int i=2;i*i<=x;i++){
        int b = i;
        while(b*i<=x)b*=i;
        ma = max(ma, b);
    }
    cout << ma << endl;
    return 0;
}

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

const ll MAX_N = 114514;
ll N, a[MAX_N] = {0};

int main(){
    cin >> N;
    ll sum = 0;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
    }

    for(int i = 0; i < N; ++i){
        sum += abs(a[i] - a[i+1]);
    }
    sum += abs(a[N]);
    for(int i = 1; i <= N; ++i){
        ll k = a[i == N ? 0 : i+1];
        ll l = a[i == 0 ? N:i-1];
        cout << sum - abs(a[i]-k) - abs(a[i] - l) + abs(k-l)<< endl;
    }
}


Measured memory_bytes: 2048
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#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())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

LL a[100005];

int main() {
	LL n;
	scanf("%lld", &n);
	LL x = (n*(n + 1)) / 2;
	REP(i,n)scanf("%lld", &a[i]);
	LL sum = 0;
	REP(i, n)sum += a[i];
	if (sum % x) {
		printf("NO\n");
		return 0;
	 }
	LL k = sum / x;
	LL r = 0;
	REP(i, n) {
		LL d = - (a[(i + 1) % n] - a[i] - k);
		if (d % n || d < 0) {
			printf("NO\n");
			return 0;
		}
		r += d / n;
	}
	if (r != k)printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n,k,a[MAXN],minx,ans;
int main(){
	SF("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		SF("%d",&a[i]);
		if(i==1)
			minx=i;
	}
	k--;
	PF("%d",(n+k-2)/k);
} 

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;

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

	int b, B, h;
	cin >> b >> B >> h;
	int a = ((b+B)*h)/2;
	cout << a;
	return 0;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int A[400000];
ll d[61][200000];
int pos[200001];
int main() {
	ll N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i + N] = A[i];
	}
	for (int i = 2 * N - 1; i >= 0; i--) {
		if (i < N) d[0][i] = pos[A[i]] - i + 1;
		pos[A[i]] = i;
	}
	for (int i = 1; i <=  60; i++) {
		for (int j = 0; j < N; j++) {
			d[i][j] = min(INF, d[i - 1][j] + d[i - 1][(j + d[i - 1][j]) % N]);
		}
	}
	ll now = 0;
	for (int i = 60; i >= 0; i--) {
		if (now + d[i][now%N] <= N * K) now += d[i][now%N];
	}
	deque<int> q;
	set<int> S;
	for (ll i = now; i < N*K; i++) {
		if (S.count(A[i%N])) {
			while (q.back() != A[i%N]) {
				S.erase(q.back());
				q.pop_back();
			}
			S.erase(A[i%N]);
			q.pop_back();
		}
		else {
			S.insert(A[i%N]);
			q.push_back(A[i%N]);
		}
	}
	for (int i = 0; i < q.size(); i++) cout << q[i] << " ";
	cout << endl;
}

Measured memory_bytes: 109312
#include <iostream>

using namespace std;

#define MAX 2000000

int H, A[MAX+1];

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i + 1;}

void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    int largest;

    if(l <= H && A[l] > A[i]) largest = l;
    else largest  = i;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int main(){

    cin >> H;

    for(int i=1; i<=H; ++i) cin >> A[i];

    for(int i=H/2; i>=1; --i) maxHeapify(i);

    for(int i=1; i<= H; ++i){
        cout << " " << A[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 5044
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for(int i = 0;i < n;i++){
            a.add(sc.nextInt());
        }
        int Alice = 0;
        int Bob = 0;
        Collections.sort(a,Collections.reverseOrder());
        int index = 0;
        for(Integer it : a){
            if(index % 2 == 0){
                Alice += it;
            }
            else{
                Bob += it;
            }
            index++;
        }
        System.out.println(Math.abs(Alice - Bob));
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
    vector<int> ac(n+1,0), pn(n+1,0);

    for(int i=0; i<m; ++i){
        int p;
        string s;
        cin >> p >> s;
        if(s=="AC") ++ac[p];
        if(s=="WA" && ac[p]==0) ++pn[p];
    }

    int ans1=0, ans2=0;
    for(int i=1; i<=n; ++i){
        if(ac[i]>0){
            ++ans1;
            ans2 += pn[i];
        }
    }

	cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 1024
from collections import defaultdict
dic = defaultdict(int)
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    dic[a] += 1
    dic[b] += 1
if [value for value in dic.values() if value % 2 == 1]:
    print('NO')
else:
    print('YES')
    


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

int main()
{   
    int a;
    string s;

    cin>>a;
    cin>>s;
    if(a>=3200)
    {
        cout<<s;
    }
    else if(a<3200)
    {
        cout<<"red";
    }
    return 0;
}

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

const int INF = 1001001001;

int main() {
  int64_t N,ans;
  int64_t A,B;
  cin>>N>>A>>B;
  
  ans=(N/(A+B))*A;
  if(N%(A+B)>A){
    ans+=A;
  }
  else{
    ans+=N%(A+B);
  }
  cout<<ans<<endl;  
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

namespace Combination{
    const int MAX = 1000001;

    ll fac[MAX], finv[MAX], inv[MAX];

    void combination_init(){
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for( int i = 2; i < MAX; i++ ){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * ( MOD / i ) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll comb( int n, int k ){
        if ( n < k ) return 0;
        if ( n < 0 || k < 0 ) return 0;
        return fac[n] * ( finv[k] * finv[n - k] % MOD ) % MOD;
    }
}
using namespace Combination;

int main(){
    int x, y; cin >> x >> y;
    int m1 = 0, m2 = 0;

    combination_init();

    if( x == y && x % 3 == 0 && y % 3 == 0 ){
        m1 = x / 3;
        cout << comb( 2 * m1, m1 ) << endl;
    }else if( x > y ){
        while( x != 2 * y ){
            x--, y -= 2;
            m1++;

            if( y < 0 ){
                cout << 0 << endl;
                return 0;
            }
        }
        m2 = y;

        cout << comb( m1 + m2, m1 ) << endl;
    }else if( x < y ){
        while( 2 * x != y ){
            x -= 2, y--;
            m2++;

            if( x < 0 ){
                cout << 0 << endl;
                return 0;
            }
        }
        m1 = x;

        cout << comb( m1 + m2, m1 ) << endl;
    }else{
        cout << 0 << endl;
    }
}

/*


*/

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n/2]-d[n/2-1] << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

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

	if (r < 1200) {
		cout << "ABC" << endl;
	} else if (r < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int ans;
string str;


int main() {
	while ( ( cin >> str ) ) {
		ans = 0;
		for ( int i = 0; i < str.size(); i++ ) {
			if ( str[ i ] == 'M' ) {
				if ( ans % 1000 ) {
					ans += 800;
				}
				else {
					ans += 1000;
				}
			}
			else if ( str[ i ] == 'D' ) {
				if ( ans % 500 ) {
					ans += 300;
				}
				else {
					ans += 500;
				}
			}
			else if ( str[ i ] == 'C' ) {
				if ( ans % 100 ) {
					ans += 80;
				}
				else {
					ans += 100;
				}
			}
			else if ( str[ i ] == 'L' ) {
				if ( ans % 50 ) {
					ans += 30;
				}
				else {
					ans += 50;
				}
			}
			else if ( str[ i ] == 'X' ) {
				if ( ans % 10 ) {
					ans += 8;
				}
				else {
					ans += 10;
				}
			}
			else if ( str[ i ] == 'V' ) {
				if ( ans % 5 ) {
					ans += 3;
				}
				else {
					ans += 5;
				}
			}
			else {
				ans++;
			}
		}
		printf( "%d\n", ans );
	}
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    ll cnt = 0;
    for (int i = 1; i < N/2+5; i++) {
        if(i < (N-i) && N - i != i){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

using namespace std;

#define int long long

const int INF = 1e9;

string S;

main() {

    cin >> S;

    vector<vector<int>> dp(S.size(),vector<int>(2,-INF));

    dp[0][0] = 1;

    for (int i = 1; i < S.size(); i++) {
        dp[i][0] = dp[i-1][1] + 1;
        if (S[i] != S[i-1]) dp[i][0] = max(dp[i][0], dp[i-1][0] + 1);
        if (i > 1) dp[i][1] = dp[i-2][0] + 1;
        if (i > 2 && !(S[i] == S[i-2] && S[i-1] == S[i-3])) dp[i][1] = max(dp[i][1], dp[i-2][1] + 1);
        if (i == 1) dp[i][1] = max(dp[i][1],1LL);
    }

    cout << max(dp[S.size()-1][0],dp[S.size()-1][1]) << "\n";
    
}

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

int A[300][300];

// i -> j と i -> k -> j のどっちが短いかを判定
// 後者の方が短い場合は -1, 全ての場合について前者の方が短い場合は length += A[i][j] 
long long length( int N )
{
    long long length = 0;
    for( int i = 0; i < N; ++i ){
        for( int j = i+1; j < N; ++j ){
            bool allLong = true;
            for( int k = 0; k < N; ++ k ){
                if( i != k and j != k){
                    if( A[i][j] > A[i][k] + A[k][j] ) return -1;
                    if( A[i][j] == A[i][k] + A[k][j] ) allLong = false;
                }
            }
            if( allLong ) length += A[i][j];
        }
    }
    return length;
}



int main()
{
    int N;
    cin >> N;
    for( int i = 0; i < N; ++i ){
        for( int j = 0; j < N; ++j ) cin >> A[i][j];
    }

    
    cout << length( N ) << endl;

    return 0;
}

Measured memory_bytes: 640
s = input().strip()
n = len(s)

def is_kaibun(s):
    n = len(s)
    head = s[:(n - (n % 2)) // 2]
    tail = s[(n+(n%2)) // 2:]
    #print("head = {} tail = {}".format(head, tail[::-1]))
    return head == tail[::-1]

if is_kaibun(s) and is_kaibun(s[:(n-1)//2]) and is_kaibun(s[(n+3)//2-1:]):
    print("Yes")
else:
    print("No")


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

const int N = 1e5 + 5;

vector<int> g[N];
bool taken[N];

int matching, n;

static void match(int u, int pap = 0) {
	for (auto v: g[u]) if (v != pap)
		match(v, u);
	for (auto v: g[u])
		if (!taken[v] && !taken[u]) {
			taken[u] = taken[v] = 1;
			matching+= 1; } }

int main() {
#ifdef HOME
	freopen("agc14d.in", "r", stdin);
	freopen("agc14d.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	for (int a, b, i = 1; i < n; ++i) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a); }

	if (n % 2) {
		cout << "First\n";
		return 0; }

	match(1);

	cout << (matching == n / 2 ? "Second" : "First") << endl;

	return 0; }



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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N;
    cin >> N;
    string C;
    cin >> C;
    ll le = 0;
    ll ri = N - 1;
    ll ans = 0;
    while(1) {
        while(C[le] == 'R')
            le++;
        while(C[ri] == 'W')
            ri--;
        if(le >= ri)
            break;
        C[le] = 'R';
        C[ri] = 'W';
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>
int min(int a,int b){if(a<b) return a; return b;}
int main(){
    int n,ans=0;
    scanf("%d",&n);
    int b[n];
    for(int i=1;i<n;i++)
        scanf("%d",&b[i]);
    ans=b[1]+b[n-1];
    for(int i=2;i<n;i++)
        ans+=min(b[i],b[i-1]);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), k = sc.nextInt();
    int ans = 0;
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if (a == 1) {
        int l = i / (k-1) + (i % (k-1) != 0 ? 1 : 0);
        int r = (n-l*(k-1)-1) / (k-1) + ((n-l*(k-1)-1) % (k-1) != 0 ? 1 : 0);
        ans = l + r;
        r = (n-i-1) / (k-1) + ((n-i-1) % (k-1) != 0 ? 1 : 0);
        l = (n-r*(k-1)-1) / (k-1) + ((n-r*(k-1)-1) % (k-1) != 0 ? 1 : 0);
        if (l + r < ans) ans = l + r;
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  string S, T;
  string ans = "No";
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++) {
    if (S == T) {
      ans = "Yes";
      break;
    }
    S = S[S.size() - 1] + S.substr(0, S.size() - 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
const int N = 2e5+5; 
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt =1;
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		if(temp==cnt){
			cnt++;
		}
	}
	if(cnt==1) cout<<-1<<endl;
	else 
		cout<<n-cnt+1<<endl;
	return 0;
	
}

Measured memory_bytes: 384
n=int(input())
S=[input() for _ in range(n)]
#print(S)
#l=[[100 for i in range(26)]]*n
l=[100]*26
#print(l)
st="abcdefghijklmnopqrstuvwxyz"
for i in S:
    for j in range(26):
        #print(i.count(st[j]),st[j])
        if l[j]>i.count(st[j]):
            l[j]=i.count(st[j])
#print(l)
ans=""
for j in range(26):
    tmp=chr(97+j)*l[j]
    ans+=tmp
print(ans)

Measured memory_bytes: 9204
from collections import deque

s=deque(input())
q=int(input())
qq=[list(input().split()) for i in range(q)]

rl=1
fleft=deque()
fright=deque()

for i in qq:
  if i[0]=='1':
    rl*=-1
  else:
    if i[1]=='1':
      if rl==1:
        fleft.appendleft(i[2])
      else:
        fright.append(i[2])
    else:
      if rl==1:
        fright.append(i[2])
      else:
        fleft.appendleft(i[2])

fleft.reverse()

s.extendleft(fleft)
s.extend(fright)

if rl==-1:
  s.reverse()

print(''.join(s))

Measured memory_bytes: 36424
#include <iostream>

int main()
{
        int n, w;
        std::cin >> w >> n;
        
        int num[w], t, a, b;
        char c;

        for(t = 0; t < w ; ++t)
                num[t] = t + 1;

        while(n--)
        {
                std::cin >> a >> c >> b;
                t = num[a - 1];
                num[a - 1] = num[b - 1];
                num[b - 1] = t;
        }

        for(t = 0; t < w; ++t)
                std::cout << num[t] << std::endl;

        return 0;
}

Measured memory_bytes: 1160
# coding: utf-8
import sys
# import random
# import bisect
# import math
# import numpy as np
# from fractions import gcd
# import itertools

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def make_divisors(n):
    # divisors = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            # divisors.append(i)
            return i
            # if i != n // i:
            #     divisors.append(n//i)


def n_to_10(X, n):
    if int(X / n):
        return n_to_10(int(X / n), n) + str(X % n)
    return str(X % n)


def main():
    ip = IP()
    id = Idea()
    """この下から書いてね"""
    n = int(input())
    memo = (n*n-n)//2
    print(memo)


main()


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, m, ans = 0;
    cin >> n >> m;
    vll h(n);
    vvll r(n);

    cin >> h;
    REP(i,m){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        r[a].emplace_back(b);
        r[b].emplace_back(a);
    }
    REP(i,n){
        ll c=0;
        REP(j, r[i].size()){
            if(h[r[i][j]] >= h[i]) break;
            c++;
        }
        if(c == r[i].size()) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9860
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  
  for(int i=S.size()-2;i>=0;i--){
if(i%2==1){
vector<char>ans((i+1)/2);
  vector<char>ans2((i+1)/2);
  
  for(int j=0;j<(i+1)/2;j++){
ans.at(j)=S.at(j);
  }
  int p=0;
  for(int k=(i+1)/2;k<=i;k++){
    ans2.at(p)=S.at(k);
    p++;
  }
  int sum=0;

  for(int l=0;l<(i+1)/2;l++){
if(ans.at(l)==ans2.at(l)){
  sum++;
}
  }
  if(sum==(i+1)/2){
    cout<<i+1<<endl;
    break;
  }
}
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 102333
using namespace std;
int a[maxn];
int main() {
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		if((i & 1) && (a[i] & 1)) ++ans;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int a,n;
  while(cin>>a>>n){
    if(a==0&&n==0)break;
    map<int,int> mp;
    int order=0;
    mp[a]=order++;
    if(a==0){
       cout<<0<<' '<<0<<' '<<1<<endl;
    }else{
      while(1){
        string s=to_string(a);
        if(s.size()<n){
          int tmp=n-s.size();
          while(tmp--)s='0'+s;
        }
        sort(ALL(s));
        string mins=s;
        reverse(ALL(s));
        string maxs=s;
        int maxi=stoi(maxs),mini=stoi(mins),nw=maxi-mini;
        auto itr=mp.find(nw);
        if(itr==mp.end()){
          mp[nw]=order++;
        }else{
          cout<<itr->SC<<' '<<itr->FR<<' '<<order-itr->SC<<endl;
          break;
        }
        a=nw;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3268
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
n_set = set([])

for i in range(n):
    tmp = int(input())
    n_set.add(tmp)

ans = 1
for i in range(len(list(n_set))):
    ans = lcm(ans, list(n_set)[i])

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n;
    int a, b;
    while(cin >> n, n) {
        vector<int> x, y;
        x.pb(200); y.pb(200);
        rep(i,0,n-1) {
            cin >> a >> b;
            x.pb(x[a] + dx[b]);
            y.pb(y[a] + dy[b]);
        }
        int xmi = *min_element(x.begin(), x.end());
        int xma = *max_element(x.begin(), x.end());
        int ymi = *min_element(y.begin(), y.end());
        int yma = *max_element(y.begin(), y.end());
        printf("%lld %lld\n", xma - xmi + 1, yma - ymi + 1);
    }
    return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
    int n;
    cin >> n;
    vector <int> s(n);
    for(int i=0;i<n;++i) cin >> s[i];
    vector <int> a(n);
    for(int i=0;i<n;++i) a[s[i]-1]=i+1;
    for(int i=0;i<n;++i) cout << a[i] << endl;
}



Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
int a[2001][2001];
using namespace std;


int main() {
	lli h,w;
	cin>>h >>w;
	
	string str_h[h],str_w[w];
	rep0(i,h){
		cin>>str_h[i];
		str_h[i]+='#';
		rep0(j,w)str_w[j]+=str_h[i][j];
	}
	rep0(j,w)str_w[j]+='#';
	rep0(i,h){
		string::size_type pos=str_h[i].find('#');
		int temp=0;
		while(pos!=string::npos){
			for(int j=temp;j<(int)pos;j++){
				a[i][j]	=pos-temp;
			}
			a[i][pos]=0;
			temp=pos+1;
			pos=str_h[i].find('#',pos+1);
		}
	}
	
	rep0(i,w){
		string::size_type pos=str_w[i].find('#');
		int temp=0;
		while(pos!=string::npos){
			for(int j=temp;j<(int)pos;j++){
				a[j][i]+=pos-temp;
			}
			a[pos][i]+=0;
			temp=pos+1;
			pos=str_w[i].find('#',pos+1);
		}
	}
	lli max=0;
	rep0(i,h)rep0(j,w){
		if(a[i][j]>max)max=a[i][j];
	}
	if(max==0)cout << 0;
	else cout << max-1;
}


Measured memory_bytes: 24936
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        // Your code here!
        
        string S = Console.ReadLine();
        string[] divide = new string[]{"dream", "dreamer", "erase", "eraser"};
        
        Queue<int> q  = new Queue<int>();
        q.Enqueue(0);
        bool can = false;
        while(q.Count != 0)
        {
            int now = q.Dequeue();
            if(now == S.Length)
            {
                can = true;
                break;
            }
            for(int j = 0; j < divide.Length; j++)
            {
                string d = divide[j];
                int next = now + d.Length;
                if(S.Length - now < d.Length) 
                {
                    continue;
                }
                else if(S.Substring(now, d.Length) == d)
                {
                    q.Enqueue(next);
                }
            }
            
        }
        
        if(can) Console.WriteLine("YES");
        else Console.WriteLine("NO");
        
        
        
    }
}


Measured memory_bytes: 13408
import numpy as np
i4 = np.int32
i8 = np.int64


def find(x, parents):
    if parents[x] == x:
        return x
    else:
        return find(parents[x], parents)


def union (x, y, parents, depth):
    x = find(x, parents)
    y = find(y, parents)
    if x == y:
        return

    if depth[x] == depth[y]:
        depth[x] += 1
        parents[y] = x
    elif depth[x] > depth[y]:
        parents[y] = x
    else:
        parents[x] = y


def main(in_file):
    stdin = open(in_file)
    N, M = [int(x) for x in stdin.readline().split()]
    a = np.empty(M, i8)
    b = np.empty(M, i8)
    for i in range(M):
        a[i], b[i] = [int(x) - 1 for x in stdin.readline().split()]
    parents = np.arange(N)
    depth = np.zeros(N, i8)
    for i in range(M):
        union(a[i], b[i], parents, depth)
    num = np.zeros(N, i8)
    for i in range(N):
        p = find(i, parents)
        num[p] += 1
    ans = num.max()
    print(ans)


main('/dev/stdin')

Measured memory_bytes: 33104