akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
typedef pair<int, int> pii;
struct edge{int to, weight;};

#define MAX_V 100000
pii dfs(int prev, int v, const vector<edge> graph[MAX_V]){
    pii r(0, v);
    rep(i, graph[v].size()){
        struct edge e = graph[v][i];
        if(e.to == prev)continue;
        pii tmp = dfs(v, e.to, graph);
        tmp.first += e.weight;
        if( r.first < tmp.first) r =  tmp;
    }
    return r;
}

vector<edge> G[MAX_V];
void dijkstra(int s, vector<int> &d){
    priority_queue<pii, vector<pii>, greater<pii>> que;
    rep(i, d.size()) d[i] = inf;
    d[s] = 0;
    que.push(pii(0,s));
    while(que.size()){
        pii p = que.top();
//        cout << p.first <<  "," << p.second <<  endl;
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
//        cout << v <<  "," << p.first << "," << G[v].size() <<  endl;
        rep(i, G[v].size()){
            edge e = G[v][i];
//            cout << e.to <<  "," << v << "," <<  e.weight <<  endl;
            if(d[e.to] > d[v] + e.weight){
                d[e.to] = d[v] + e.weight;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin>>n;
    
    rep(i,n-1){
        int u,v;
        
        cin>>u>>v;
        u--,v--;
        G[u].pb(edge{v,1});
        G[v].pb(edge{u,1});
    }
    
    
    pii r=dfs(-1,0,G);
    pii t = dfs(-1,r.second,G);
    int A = r.second;
    int B = t.second;
    
    vector<int> d1(n),d2(n);
    
    dijkstra(A,d1);
    dijkstra(B,d2);
    
//    cout<<A<<" "<<B<<endl;
    rep(i,n){
//        cout<<d1[i]<<" "<<d2[i]<<endl;
        int dist=max(d1[i],d2[i]);
        cout<<2*(n-1)-dist<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 18344
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val (w,h,n) = readints()
    var ya = h
    var yb = 0
    var xa = w
    var xb = 0
    for(i in 0 until n){
        val (x,y,a) = readints()
        if(a == 1){
            xb = Math.max(xb,x)
        }
        else if(a == 2){
            xa = Math.min(xa,x)
        }
        else if(a == 3){
            yb = Math.max(yb,y)
        }
        else{
            ya = Math.min(ya,y)
        }
    }
    if(ya - yb < 0 || xa - xb < 0) println(0)
    else println(Math.max(0, (ya - yb) * (xa - xb)))
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

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

using namespace std;

using   ll=long long;
using   ld=long double;

#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define long long      int 
#define pb             push_back
#define mp             make_pair
#define ff             first
#define ss             second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define inf 		   LLONG_MAX
#define ones(x)		   __builtin_popcount(x)

void solve()
{
	string s;
	
	cin>>s;
	
	ll n = s.size();
	
	ll q;
	
	cin>>q;
	
	string agal,pacal;
	
	ll f;
	
	ll type;
	
	string c;
	
	ll cnt =0;
	
	ll lol = 0;
	
	while(q--)
	{
		cin>>type;
		
		if(type == 1)
		{
			cnt++;
			
			lol++;
		}
		else
		{
			if(lol%2)
			{
				swap(agal,pacal);
				
				reverse(ALL(agal));
				reverse(ALL(pacal));
			}
			
			lol=0;
			
			cin>>f>>c;
			
			if(f==1)
			{
				agal = c + agal;
			}
			else
			{
				pacal = pacal + c;
			}
		}
	}
	
	if(lol%2)
	{
		swap(agal,pacal);
				
		reverse(ALL(agal));
		reverse(ALL(pacal));
	}
	if(cnt%2)	reverse(ALL(s));
	
	cout<<agal<<s<<pacal;
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 1136
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    int ans=0;
    sort(v.begin(),v.end());
    for(int i=0;i<n-1;i++){
        ans+=v[i+1]-v[i];
    }
    cout<<ans<<endl;
    
    
    
    
return 0;
}


Measured memory_bytes: 256
n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
(*c,) = map(int, input().split())

ans = sum(c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1)
print(ans + sum(b[i - 1] for i in a))

Measured memory_bytes: 9032
package main

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

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	H := sc.readInt()
	W := sc.readInt()
	h := sc.readInt()
	w := sc.readInt()

	res := H*W - h*W - H*w + h*w
	fmt.Println(res)
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
  int X;
  cin >> X;
  
  for(int i=2;i <= 9;i++){
    if(200*i <= X && X <= 200*(i+1)-1){
      cout << 9 - (i-1) << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <set>
int main () {
    std::set<char> vowelSet = {'a', 'i', 'u', 'e', 'o'};

    char c;

    std::cin >> c;
    std::size_t n = vowelSet.count(c);

    if(n==1){
       std::cout << "vowel" << std::endl;
    }else{
       std::cout << "consonant" << std::endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
for a_i in a:
    if a_i <= b[n // 2 - 1]:
        c = b[n // 2]
    else:
        c = b[n // 2 - 1]
    print(c)


Measured memory_bytes: 26772
#include<bits/stdc++.h>
using namespace std;
int main()
{
         char s[12];
         scanf("%s", s);
         int i,l,c=0;
         l=strlen(s);
         if(l%2!=0)cout<<"No"<<endl;
         else
         {
                 for(i=0;i<l;i++)
                 {
                          if(i%2==0&&s[i]!='h')
                          {
                                   c=1;
                                   break;
                          }
                          else if(i%2!=0&&s[i]!='i')
                          {
                                   c=1;
                                   break;
                          }
                 }
                 if(c==0)cout<<"Yes"<<endl;
                 else cout<<"No"<<endl;
         }
         return 0;
}


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

int n;
string s;


int main() {
    ios::sync_with_stdio(false);
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) cout << 'x';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var A = new int[N];
        bool flag = false;
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextint;
            if (A[i] % 2 == 1)
            {
                flag = true;
            }
        }
        if (flag)
        {
            WriteLine("first");
        }
        else
        {
            WriteLine("second");
        }

    }


}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 17340
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,ai,ans=0;
    scanf("%d%d",&n,&k);
    while(n--)
    {
        scanf("%d",&ai);
        ans+=min(ai-0,k-ai)*2;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c;

    cin >> a >> b >> c;

    int n = c - (a - b);

    if (n > 0)
    {
    	cout << n;
    }   
    else {
    	cout << 0;
    }

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define MAX 2000000
#define INFTY (1<<30)
int H = 0;
int A[MAX+1];
int right(int i){
  return 2*i + 1;
}
int left(int i){
  return 2 * i;
}
void swap(int *a,int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}
void MaxHeapify(int i){
  int l,r,largest;
  l = left(i);
  r = right(i);
  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 extract(){
  int maxv;
  if(H < 1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  MaxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  if(key < A[i]) return;
  A[i] = key;
  while(i > 1&&A[i/2] < A[i]){
    swap(&A[i],&A[i/2]);
    i = i/2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
}
int main(){
  int i,key;
  char com[10];
  while(1){
    scanf("%s",com);
    if(com[0] == 'e'&&com[1] == 'n') break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5600
#include <bits/stdc++.h>
    #define rep(i, n) for (ll i = 0; i < (n); i++)
    #define all(x) (x).begin(), (x).end()
    using ll = long long;
    using namespace std;
    template <typename T> using vec = std::vector<T>;
     
    int main() {
        int N;
        cin >> N;
        
        unordered_map<int,int> mp;
        vec<ll> a2;
        vec<ll> a4;
        rep(i, N){
            int a;cin >> a;
            ++mp[a];
            if(mp[a] == 2) a2.push_back(a);
            if(mp[a] == 4) a4.push_back(a);
        }
        sort(a2.rbegin(),a2.rend());
        sort(a4.rbegin(),a4.rend());
        ll ans = 0;
        if(a2.size()>=2) ans = a2[0]*a2[1];
        if(a4.size()>=1) ans = max(ans,a4[0]*a4[0]);
        cout << ans << endl;
    }

Measured memory_bytes: 7192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  ll ans=0,l,r;
  rep(i,n){
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(void){
  int n;
  cin >> n;
  n *= 2;
  int l[2 * n];
  for(int i = 0; i < n; i++) cin >> l[i];
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      if(l[i] < l[j]) swap(l[i], l[j]);
    }
  }
  int sum = 0;
  for(int i = 1; i < n; i += 2){
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
    int ans=0;
    while(x>0&&y>0)
    {
        ans+=min(a+b,c*2);
        x--;
        y--;
    }
    while(x>0)
    {
        ans+=min(a,2*c);
        x--;
    }
    while(y>0)
    {
        ans+=min(b,2*c);
        y--;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
#define eps 1e-8
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const db PI = acos(-1.0);
int N,top;
db ans[105];
bool dcmp(db a,db b) {
    return fabs(b - a) <= eps;
}
struct Point {
    db x,y;int id;
    Point(db _x = 0.0,db _y = 0.0) {
	x = _x;y = _y;
    }
    friend Point operator + (const Point &a,const Point &b) {
	return Point(a.x + b.x,a.y + b.y);
    }
    friend Point operator - (const Point &a,const Point &b) {
	return Point(a.x - b.x,a.y - b.y);
    }
    friend Point operator * (const Point &a,const db &d) {
	return Point(a.x * d,a.y * d);
    }
    friend db operator * (const Point &a,const Point &b) {
	return a.x * b.y - a.y * b.x;
    }
    friend db dot(const Point &a,const Point &b) {
	return a.x * b.x + a.y * b.y;
    }
    db norm() {
	return sqrt(x * x + y * y);
    }
}P[105],sta[105];

bool cmp(Point a,Point b) {
    db d = (a - P[1]) * (b - P[1]);
    if(dcmp(d,0.0)) {return (a - P[1]).norm() < (b - P[1]).norm();}
    else return d > 0;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    int x,y;
    read(N);
    if(N == 1) {puts("1.0");return 0;}
    for(int i = 1 ; i <= N ; ++i) {read(x);read(y);P[i] = Point(x,y);P[i].id = i;}
    for(int i = 2 ; i <= N ; ++i) {
	if(P[i].x < P[1].x || (P[i].x == P[1].x && P[i].y < P[1].y)) swap(P[1],P[i]);
    }
    sort(P + 2,P + N + 1,cmp);
    sta[++top] = P[1];
    for(int i = 2 ; i <= N ; ++i) {
	while(top >= 2 && (P[i] - sta[top - 1]) * (sta[top] - sta[top - 1]) >= 0.0) --top;
	sta[++top] = P[i];
    }
    if(top == 2) {
	ans[sta[1].id] = 0.5;
	ans[sta[2].id] = 0.5;
    }
    else {
	Point a,b;
	sta[0] = sta[top];sta[top + 1] = sta[1];
	for(int i = 1 ; i <= top ; ++i) {
	    a = sta[i + 1] - sta[i];
	    b = sta[i - 1] - sta[i];
	    ans[sta[i].id] = (PI - acos( dot(a,b) / (a.norm() * b.norm()) ) ) / (2 * PI); 
 	}
    }
    for(int i = 1 ; i <= N ; ++i) {
	printf("%.10lf\n",ans[i]);
    }
    return 0;
}


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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N, K, R, S, P;
string T;
char H[200100];

int main()
{
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    ll ans = 0;
    rep(i, N)
    {
        char t = T[i];
        if (t == 'r')
        {
            if (i < K)
            {
                H[i] = 'p';
                ans += P;
            }
            else
            {
                if (H[i-K] != 'p')
                {
                    H[i] = 'p';
                    ans += P;
                }
                else
                {
                    H[i] = 'x';
                }
            }
        }
        else if (t == 's')
        {
            if (i < K)
            {
                H[i] = 'r';
                ans += R;
            }
            else
            {
                if (H[i-K] != 'r')
                {
                    H[i] = 'r';
                    ans += R;
                }
                else
                {
                    H[i] = 'x';
                }
            }
        }
        else
        {
            if (i < K)
            {
                H[i] = 's';
                ans += S;
            }
            else
            {
                if (H[i-K] != 's')
                {
                    H[i] = 's';
                    ans += S;
                }
                else
                {
                    H[i] = 'x';
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int h, w, a, b;
int ans[1010][1010];
int main(){
    cin >> h >> w >> a >> b;
    REP(i, b)REP(j, a)ans[i][j] = 1;
    for(int i = b;i < h;i++){
        for(int j = a;j < w;j++){
            ans[i][j] = 1;
        }
    }
    REP(i, h){
        REP(j, w){
            cout << ans[i][j];
        }
        cout << endl;
    }
}

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

static const int INF = 1e9+7;

int main(){
    int N;
    cin>>N;
    vector<int> dp(100000+10,INF);
    vector<int> A(N);
    for(int i=0; i<N; i++) cin>>A[i];

    dp[0] = 0;

    for(int i=1; i<N; i++){
        dp[i] = min(dp[i-1]+abs(A[i-1]-A[i]),dp[i]);
        if(i > 1) dp[i] = min(dp[i-2]+abs(A[i-2]-A[i]),dp[i]);
    }

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

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int f(int n, int x){
    return (n+x-1)/x;
}

signed main(void) {
    int n;
    vi a(5);
    cin >> n;
    rep(i,5)cin >> a[i];
    sort(all(a));
    cout << f(n, a[0])+4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define lli long long int
using namespace std ;


int main(int argc, char const *argv[])
{

	lli a,b,k ;
	cin>>a>>b>>k ;
	if(a >= k)
	{
		cout<<a-k<<" "<<b<<endl ; 
		return 0 ;
	}

	k-=a ;

	if(k > b)
	{
		cout<<"0 "<<"0"<<endl ;
		return 0 ;
	}

	cout<<"0 "<<b-k<<endl ; 

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i

A = 26
tmp = 12.times.map {|i| A ** i}
acc = 0
table = tmp.map {|i| acc += i}

idx = table.bsearch_index {n < _1}
n -= table[idx - 1]

result = ""
loop do
  result = (n % 26 + 97).chr + result
  n /= 26
  break if n.zero?
end
s = result.size
result = "a" * (idx - s)  + result if s < idx

puts result

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

int main()
{
    int S;
    cin >> S;
    int h,m,s;
    h = S/3600;
    m = S/60 - h*60;
    s = S - h*3600 - m*60;
    cout <<  h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    int j=1;
    for(int i=0; i<N; i++){
        if(a[i]==j) j++;
    }
    if(j==1) cout << -1 << endl;
    else cout << N-j+1 << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    }
}

Measured memory_bytes: 99796
n = gets.to_i
a = gets.split.map(&:to_i)

def yes
  puts 'Yes'
  exit
end
def no
  puts 'No'
  exit
end

yes if a.all?(&:zero?)

if n % 3 == 0
  b = a.group_by(&:itself)
  no unless b.each_value.map(&:size).all? {|x| x % (n/3) == 0 }
  case b.size
  when 3
    c = b.keys
    yes if c[0] == c[1] ^ c[2]
  when 2
    c = b.values.sort_by(&:size).map(&:first)
    yes if c[0] == 0
  end
end

puts 'No'


Measured memory_bytes: 15756
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B=0,C=0,D=0,F=0;
  cin >> A;
  A++;
  vector<lli>P(A);
  P[0]=2;
  P[1]=1;
  for(int i=2;i<A;i++){
    P[i]=P[i-1]+P[i-2];
  }
  Out(P[A-1]);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(br.readLine());
			String in2 = br.readLine();
			ArrayList<Integer> aList = new ArrayList<Integer>();
			int res = 0;

			for( String str:in2.split(" ") ){
				aList.add(Integer.parseInt(str));
			}

			Collections.sort(aList,Collections.reverseOrder());


			for(int i=0;i<n*2;i++){
				i = i+1;
				res = res + aList.get(i);
			}

			System.out.println(res);

		}  catch (IOException e) {
			e.printStackTrace();
		}

	}

}


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

int main(){

  string cards;
  string buf;
  int h,n;
  int i;

  while(1){
    cin >> cards;

    if(cards == "-"){
      break;
    }

    cin >> n;
    for(i = 0; i < n;i++){
      cin >> h;
      buf = cards.substr(0,h);
      cards += buf;
      cards.erase(cards.begin(),cards.begin()+h);
    }
    cout << cards << endl;
  }

return 0;



}

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

int main(){
  int n;
  cin >>n;
  double odd = 0;
  for(int i = 1; i<=n; i++){
    if(i%2 != 0) odd++;
  }
  double pro = odd/n;
  cout << fixed << setprecision(9) << pro << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
	int N;
	cin >> N;
	priority_queue<int>D;
	rep(i, N) {
		int d;
		cin >> d;
		D.emplace(d);
	}
	vector<int>CD(N);
	rep(i,N) {
		CD[i] = D.top();
		D.pop();
	}
	if (N%2!=0) {
		cout << 0 << endl;
	}
	else {
		int ans = CD[N / 2-1] - CD[N / 2];
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1144
// review
#include <iostream>
typedef long long ll;
using namespace std;

ll x, y;

void solve() {
  if (x > y) {
    swap(x, y);
  }
  if (y - x > 1) {
    cout << "Alice" << endl;
  } else {
    cout << "Brown" << endl;
  }
}

int main() {
  cin >> x >> y;
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	long long v[n+10];
	for(int i=0;i<n;i++)
	cin>>v[i];
	sort(v,v+n);
	multiset<long long> ssi;
	for(int i=0;i<n;i++)
	{
	    ssi.insert(v[i]);
	}
	int res=0;
	while(!ssi.empty())
	{
	    long long x=*ssi.rbegin();
	   
	   while (!ssi.empty()) {
		long long x = *ssi.rbegin();
		ssi.erase(prev(ssi.end()));
		long long now = 1;
		while (now <= x)
			now *= 2;
		auto it = ssi.find(now - x);
		if (it == ssi.end())
			continue;
		ssi.erase(it);
		++res;
	}
	}
	cout<<res<<'\n';
	return 0;
}


Measured memory_bytes: 11264
#include <iostream>

using namespace std;

int main(){
  long long N,a,min_=1e15;
  cin >> N;
  for(int i=0;i<6;i++){
    cin >> a;
    min_=min(a,min_);
  }
  cout << N/min_+4+((N%min_!=0)?1:0) << endl;
  return 0;
}

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

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

using namespace std;
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 int MOD = 1e9 + 7;

int C[2010][2010];

signed main(){
    C[0][0] = 1;
    FOR( i, 1, 2010 ){
        REP( j, i + 1 ){
            C[i][j] = C[i - 1][j];
            if( j - 1 >= 0 ) C[i][j] += C[i - 1][j - 1];
            C[i][j] %= MOD;
        }
    }

    int N, K; cin >> N >> K;
    REP( i, K ){
        cout << C[N - K + 1][i + 1] * C[K - 1][i] % MOD << endl;
    }

}



Measured memory_bytes: 30336
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int>> dp(n, vector<int> (n+1, 0));
    for (int i = 0; i < n; ++i) {
        dp[i][i] = 1;
    }
    for (int len = 3; len <= n; len += 3) {
        for (int i = 0; i+len <= n; ++i) {
            int k = i+len;
            if(s[i] == 'm' && s[k-1] == 'w'){
                for (int j = i+1; j < k-1; ++j) {
                    if(s[j] == 'e'){
                        dp[i][k] |= (dp[i+1][j] & dp[j+1][k-1]);
                    }
                }
            }
        }
    }
    puts(dp[0][n] ? "Cat" : "Rabbit");
    return 0;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

lint tos(lint n, lint X, lint D)
{
    return X * n + D * n * (n - 1) / 2;
}

int main()
{
    lint N, X, D;
    cin >> N >> X >> D;
    if (!D)
    {
        cout << (X != 0) * N + 1 << endl;
        return 0;
    }

    int g = (X != 0 ? __gcd(abs(X), abs(D)) : abs(D));
    X /= g, D /= g;
    int AD = abs(D);

    map<int, vector<plint>> Q;
    REP(i, N + 1) {
        lint lo = 9e18, hi = -9e18;
        vector<lint> c;
        c.emplace_back(tos(i, X, D));
        c.emplace_back(tos(i, X + D * (N - 1), -D));
        for (auto x : c) mmin(lo, x), mmax(hi, x);
        Q[i % AD].emplace_back(lo, hi);
    }
    lint ret = 0;
    for (auto &vec : Q) {
        sort(ALL(vec.second));
        lint h = vec.second[0].first - AD;
        for (auto x : vec.second) {
            mmax(h, x.first - AD);
            ret += max((x.second - h) / AD, 0LL);
            mmax(h, x.second);
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 22144
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int m = Integer.parseInt(sc.next());
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			int top = 0;
			int end = n;
			int pos = 0;
			while (top < end) {
				pos = (top + end) / 2;
				if (b[i] == a[pos]) {
					count++;
					break;
				} else if (b[i] > a[pos]) {
					top = pos;

				} else {
					end = pos;
				}
				if (pos == (top + end) / 2) {
					break;
				}
			}

		}

		System.out.println(count);

	}
}


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

#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;

using namespace std;

int main() {
  string S;
  cin >> S;
  int ans01 = 0;
  char c = '0';
  REP(i, S.size()) {
    if(S[i] != c) ans01++;
    c = (c == '0' ? '1' : '0');
  }
  c = '1';
  int ans10 = 0;
  REP(i, S.size()) {
    if(S[i] != c) ans10++;
    c = (c == '0' ? '1' : '0');
  }
  cout << min(ans01, ans10) << endl;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define crap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

string lcs(string s,string t){
    ll x = s.length();
    ll y = t.length();
    if( (x==1 && y==1) && s!=t ){
        return " ";
    }
    ll dp[x+1][y+1];
    for( int i=0; i<=x; i++ ){
        dp[i][0] = 0;
    }
    for( int i=0; i<=y; i++ ){
        dp[0][i] = 0;
    }
    for( int i=1; i<=x; i++ ){
        for( int j=1; j<=y; j++ ){
            if( s[i-1] == t[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    ll i = x,j = y; string st;
    while( i>0 && j>0){
        if( dp[i][j] == dp[i-1][j-1]){
            --i;
            --j;
        }
        else if( dp[i][j] == dp[i-1][j]){
            --i;
        }
        else if( dp[i][j] == dp[i][j-1]){
            --j;
        }
        else{
            st.insert(st.begin(),s[i-1]);
            --i;
            --j;
        }
    }
    return st;
}

int main() {
	crap;
	string s,t;
	cin >> s >> t;
	cout << lcs(s,t);

	return 0;
}

Measured memory_bytes: 73984
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

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


A, B = list(map(int, sys.stdin.readline().split()))

if A <= 0 <= B:
    print('Zero')
elif A < 0 and (min(B, 0) - A) % 2 == 0:
    print('Negative')
else:
    print('Positive')


Measured memory_bytes: 13808
#include<stdio.h>
int main(){
	while(1){
		int num,M,k,ans,S,c;
		long N[10000]={},N2[10000]={};
		scanf("%d %d",&num,&M);
		if(num==0&&M==0)break;
		for(int i=0;i<M;i++){
			scanf("%d %d",&S,&k);
			for(int j=0;j<k;j++){
				scanf("%d",&c);
				N[c-1]+=S;
				if(k==1){
					N2[c-1]+=S;
				}
			}
		}
		int MAX,MIN;
		MAX=N[0];
		MIN=N2[0];
		for(int i=1;i<num;i++){
			if(MAX<N[i]){
				MAX=N[i];
			}
			for(int j=0;j<num;j++){
				if(N[j]==MAX){
					N2[j]=N[j];
				}
			}
			if(MIN>N2[i]){
				MIN=N2[i];
			}
		}
		ans=MAX-MIN+1;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2848
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
map<int,int> mp ;
void factor(int x){
    for(int i = 2; i * i <= x; i++){
        bool ok = false ;
        int cnt = 0 ;
        while(x % i == 0){
            ok = true ;
            cnt++ ;
            x /= i ;
        }
        if ( ok ){
            if ( mp.count(i) ) {
                mp[i] = max(mp[i], cnt) ;
            }
            else mp[i] = cnt ;
        }
    }
    if ( x > 1 ) {
        if ( mp.count(x) ) {
            mp[x] = max(mp[x], 1LL) ;
        }
        else mp[x] = 1 ;
    }
}
int fast(int a, int b){
    if ( b == 0 ) return 1 ;
    if ( b == 1 ) return a ; 
    int y = fast(a, b / 2) % MOD ;
    int ans = y * y; 
    ans %= MOD ;
    if ( b & 1 ) ans *= a ; 
    return ans % MOD ;
}
int inverse(int x){
    return fast(x, MOD - 2) ;
}
signed main(){
    fastio
    debug() << imie((12 * inverse(12) % MOD)) ;
    // int ans = 36 * inverse(2) ;
    // ans %= MOD ;
    // ans *= inverse(3) ;
    // ans %= MOD ;
    // ans *= inverse(4) ;
    // ans %= MOD ;
    // debug() << imie(ans) ;
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
        factor(v[i]) ;
    }
    debug() << imie(mp) ;
    int ans = 1; 
    for(auto &p : mp){
        for(int i = 0; i < p.second; i++){
            ans *= p.first ;
            ans %= MOD ;
        }
    }
    int sum = 0 ;
    for(int i = 0; i < n; i++){
        int c = ans * inverse(v[i]) ;
        c %= MOD ;
        sum += c ;
        sum %= MOD ;
    }
    cout << sum << endl ;
    return 0; 
}

Measured memory_bytes: 4360
n,q=list(map(int,input().split()))
b=input()
k=[0]*n
ac=0
for i in range(n-1):
  ac += 1 if b[i:i+2] == 'AC' else 0
  k[i]=ac
for i in range(q):
  l,r = list(map(int,input().split()))
  print(k[r-2]-k[l-2])


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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  string s;
  cin >> s;
  
  int kind = 1;
  for(int i = 1; i < n; i++){
    if(s[i] != s[i - 1]) kind++;
  }
  
  cout << kind;
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, p;
    cin >> a >> p;
    p += a*3;
    cout << p/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    repeat(readLine()!!.toInt()){
        val (x, y, w, h) = readLine()!!.trim().split(' ').map(String::toInt)
        val square = Square(Point(x, y), w, h)
        println(Array(readLine()!!.trim().toInt()){
            val (cx, cy) = readLine()!!.trim().split(' ').map(String::toInt)
            Point(cx, cy)
        }.count{square.isInArea(it)})
    }
}
data class Point(val x:Int, val y:Int)
class Square(leftBottom:Point, width:Int, height:Int){
    private val mXrange = leftBottom.x .. (leftBottom.x + width)
    private val mYrange = leftBottom.y .. (leftBottom.y + height)
    fun isInArea(point:Point):Boolean = point.x in mXrange && point.y in mYrange
}


Measured memory_bytes: 33232
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim a, b As Char
        Dim arr(2) As String
        arr = Split(Console.ReadLine())
        a = arr(0) : b = arr(1)
        Dim x As New String(a, Integer.Parse(b))
        Dim y As New String(b, Integer.Parse(a))
        Console.WriteLine(if(Integer.Parse(a) < Integer.Parse(b), x, y))
    End Sub
End Class


Measured memory_bytes: 11488
fun main(args: Array<String>) {
    val int = readLine()!!.toInt()
    val pon = "pon"
    val hon = "hon"
    val bon = "bon"

    when (int % 10) {
        0-> println(pon)
        1-> println(pon)
        2-> println(hon)
        3-> println(bon)
        4-> println(hon)
        5-> println(hon)
        6-> println(pon)
        7-> println(hon)
        8-> println(pon)
        9-> println(hon)
    }
}

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

const int MAX = 2100000;

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

// テーブルを作る前処理
void COMinit(ll p) {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  rep(i, 2, MAX) {
    fac[i] = fac[i - 1] * i % p;
    inv[i] = p - inv[p % i] * (p / i) % p;
    finv[i] = finv[i - 1] * inv[i] % p;
  }
}

// 二項係数計算
ll cmb(ll n, ll k, ll p) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % p) % p;
}

int main() {
  ll p = 1000000007;
  COMinit(p);
  ll r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  ll a = 0;
  a = (cmb(r2 + c2 + 2, r2 + 1, p) + cmb(r1 + c1, r1, p) - cmb(r1 + c2 + 1, r1, p) - cmb(c1 + r2 + 1, c1, p)) % p;
  if (a < 0) a += p;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 52848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c=0,d,n,t,j,k,x,y,m,p,s,mx=0,mn;
    cin>>t;
    map<string,int>poll;
    vector<string>v;
    //string ar[t];
    for(p=0;p<t;p++)
    {
        string ss;
        cin>>ss;
        poll[ss]++;
    }
    map<string, int>::iterator it = poll.begin();
    for(it=poll.begin();it!=poll.end();it++)
    {
        c=max(c,it->second);
        //cout<<c<<endl;
    }
    int l=0;
    for(it=poll.begin();it!=poll.end();it++)
    {
        if(c==it->second)
        {
            v.push_back(it->first);
            l++;
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<l;i++)
    {
        cout<<v[i]<<endl;
    }
}


Measured memory_bytes: 27148
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct Node{ int parent,left,right;}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].left !=NIL) h1=setHeight(T[u].left)+1;
  if(T[u].right !=NIL) h2=setHeight(T[u].right)+1;
  return H[u] = (h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,i,root=0;
  scanf("%d",&n);

  for(i = 0;i<n;i++) T[i].parent = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l!=NIL) T[l].parent = v;
    if(r!=NIL) T[r].parent = v;
  }

  for(i = 0; i < n; i++) if(T[i].parent == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++) print(i);

  return 0;
}



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

int main() {
	int x, y, n;
	while(cin >> x >> y) {
		if(x == 0 && y == 0) {
			break;
		}
		if(x > y) {
			n = x;
			x = y;
			y = n;
		}
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#!/usr/bin/env python3

#from collections import defaultdict
#from heapq import heappush, heappop
#import numpy as np
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 2 ** 31 - 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7

debug_indent = 0


def debug(*x):
    global debug_indent
    x = list(x)
    indent = 0
    if x[0].startswith("enter") or x[0][0] == ">":
        indent = 1
    if x[0].startswith("leave") or x[0][0] == "<":
        debug_indent -= 1
    x[0] = "  " * debug_indent + x[0]
    print(*x, file=sys.stderr)
    debug_indent += indent


def set_depth(depth):
    global N, SEGTREE_SIZE, NONLEAF_SIZE
    N = depth
    SEGTREE_SIZE = 1 << N
    NONLEAF_SIZE = 1 << (N - 1)


def point_set(table, pos, value, binop):
    pos = pos + NONLEAF_SIZE
    table[pos] = value
    while pos > 1:
        pos >>= 1
        table[pos] = binop(
            table[pos * 2],
            table[pos * 2 + 1],
        )


def range_reduce(table, left, right, binop, unity):
    ret_left = unity
    ret_right = unity
    left += SEGTREE_SIZE // 2
    right += SEGTREE_SIZE // 2
    while left < right:
        if left & 1:
            ret_left = binop(ret_left, table[left])
            left += 1
        if right & 1:
            right -= 1
            ret_right = binop(table[right], ret_right)

        left //= 2
        right //= 2
    return binop(ret_left, ret_right)


def main():
    # parse input
    N, Q = map(int, input().split())
    depth = N.bit_length() + 1
    set_depth(depth)
    table = [INF] * SEGTREE_SIZE

    for _q in range(Q):
        q, x, y = map(int, input().split())
        if q == 0:
            # update
            point_set(table, x, y, min)
        else:
            # find
            print(range_reduce(table, x, y + 1, min, INF))


# tests
T1 = """
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2
"""


def test_T1():
    """
    >>> as_input(T1)
    >>> main()
    1
    2
    """
# add tests above


def _test():
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())

    def input():
        return bytes(f.readline(), "ascii")

    def read():
        return bytes(f.read(), "ascii")


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        print("testing")
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()



Measured memory_bytes: 9364