akhauriyash/Code-Regression huggingface dataset:
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll maxi = 0;
		ll curr = 0;
		while (n--)
		{
			ll x, y;
			cin >> x >> y;
			if (x == y)
				curr++;
			else
				maxi = max(maxi, curr), curr = 0;

		}
		maxi = max(maxi, curr);
		// deba(maxi);
		if (maxi > 2)
			cout << "Yes";
		else
			cout << "No";
	}
	return 0;
}

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

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    ll n, d, a; cin >> n >> d >> a;
    vector<vector<ll> > lis(n, vector<ll>(2, 0));
    REP(i, 0, n){
        cin >> lis[i][0] >> lis[i][1];
    }
    sort(ALL(lis), [](auto &x, auto &y){return x[0] < y[0];});
    vector<ll> ruisekidown(n, 0), idx(n, 0);
    REP(i, 0, n){
        idx[i] = lis[i][0];
    }
    ll ans = 0;
    ll dam = 0;
    REP(i, 0, n){
        dam -= ruisekidown[i];
        if(dam >= lis[i][1]){
            continue;
        }
        ll c = (lis[i][1] - dam + (a-1))/a;
        ans += c;
        dam += c * a;
        auto it = upper_bound(ALL(idx), 2*d + lis[i][0]);
        int next = it-idx.begin();
        if(next == n){continue;}
        ruisekidown[next] += c * a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
x, y, z, K = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)


def check(P):
    cnt = 0
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if A[i]+B[j]+C[k] < P:
                    break
                cnt += 1
                if K <= cnt:
                    return True
    return False


L = 1
R = 10**14
while L != R-1:
    M = (L+R)//2
    if check(M):
        L = M
    else:
        R = M

ans = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if A[i]+B[j]+C[k] <= L:
                break
            ans.append(A[i]+B[j]+C[k])

ans.sort(reverse=True)
for i in range(K):
    if i < len(ans):
        print(ans[i])
    else:
        print(L)

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

namespace JKTX_AOJ2015
{
    public class Data
    {
        public int A { get; set; }
        public int B { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var dataList = new List<Data>();

            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                Data data = new Data();
                data.A = int.Parse(str[0]);
                data.B = int.Parse(str[1]);

                if (data.A == 0 && data.B == 0)
                {
                    break;
                }

                dataList.Add(data);
            }

            foreach (var item in dataList)
            {
                if (item.A < item.B)
                {
                    Console.WriteLine("{0} {1}", item.A, item.B);
                }
                else
                {
                    Console.WriteLine("{0} {1}", item.B, item.A);
                }
            }
        }
    }
}

Measured memory_bytes: 5900
#include <stdio.h>

void  SWAP(int *x, int *y) {
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

void quicksort(int *array, int *array2, int left, int right) {
    int l = left;
    int r = right;
    int pivot = array[(left + right) / 2];

    while (1) {
        while (array[l] < pivot) l++;
        while (array[r] > pivot) r--;
        if (l > r) break;
        SWAP(&array[l], &array[r]);
        SWAP(&array2[l], &array2[r]);
        l++, r--;
    };

    if (left < r)  quicksort(array, array2, left, r);
    if (l < right) quicksort(array, array2, l, right);
}

int main(void){
    int N, M;
    scanf("%d %d", &N, &M);
    int A[N];
    int B[N];

    for (int i = 0; i < N; i++){
        scanf("%d %d", &A[i], &B[i]);
    }

    quicksort(A, B, 0, N-1);

    long sum = 0;
    int num = 0;
    int tmp = 0;
    int i = 0;

    while(num < M){
        num += B[i];
        sum += (long)A[i] * B[i];
        tmp = i;
        i++;
    }
    sum -= (long)(num - M) * A[tmp];
    
    printf("%ld\n", sum);
    return 0; 
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void){
  long int l,r,i,j,min=2020;
  scanf("%ld %ld",&l,&r);

  if(r-l>=2019){
    min=0;
  }
  else{
    for(i=l;i<r;i++){
      for(j=i+1;j<=r;j++){
        if(((i*j)%2019)<min){
          min=(i*j)%2019;
        }
      }
    }
  }
  printf("%ld\n",min);
  return 0;
}


Measured memory_bytes: 128
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define repl(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const ll N=(ll)(1e6+1);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
ll inv(int x){return binpow(x, MOD - 2);}
ll divide(ll x, ll y){return mul(x, inv(y));}
ll fact[N];
void precalc(){fact[0] = 1;for(ll i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
ll C(ll n, ll k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================
//ll dp[1024][1024];
int main()
{

    string s;
    cin>>s;
    int ans=0;
    rep(i,0,3)
    {
        if (s[i]=='R')
        {
            ans++;
        }
    }
    if (ans==2)
    {
        if (s[0]=='R' && s[2]=='R')
        {
            ans--;
            cout<<ans;
        }
        else
        {
            cout<<ans;
        }
    }
    else
    {
        cout<<ans;
    }
}


Measured memory_bytes: 3608
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;

signed main() {
    int N,tmp;
    cin >> N;
    vector<int> ip(N,0);
    REP(i,N-1){
        cin >> tmp;
        ip[tmp-1] +=1;
    }
    REP(i,N){
        cout << ip[i] << endl;
    }
}


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


template <int mod>
struct ModInt {
  int val;
  int trim(int x) const { return x >= mod ? x - mod : x < 0 ? x + mod : x; }
  ModInt(int v = 0) : val(trim(v % mod)) {}
  ModInt(long long v) : val(trim(v % mod)) {}
  ModInt &operator=(int v) { return val = trim(v % mod), *this; }
  ModInt &operator=(const ModInt &oth) { return val = oth.val, *this; }
  ModInt operator+(const ModInt &oth) const { return trim(val + oth.val); }
  ModInt operator-(const ModInt &oth) const { return trim(val - oth.val); }
  ModInt operator*(const ModInt &oth) const { return 1LL * val * oth.val % mod; }
  ModInt operator/(const ModInt &oth) const {
    function<int(int, int, int, int)> modinv = [&](int a, int b, int x, int y) {
      if (b == 0) return trim(x);
      return modinv(b, a - a / b * b, y, x - a / b * y);
    };
    return *this * modinv(oth.val, mod, 1, 0);
  }
  bool operator==(const ModInt &oth) const { return val == oth.val; }
  ModInt operator-() const { return trim(mod - val); }
  template<typename T> ModInt pow(T pw) {
    bool sgn = false;
    if (pw < 0) pw = -pw, sgn = true;
    ModInt ans = 1;
    for (ModInt cur = val; pw; pw >>= 1, cur = cur * cur) {
      if (pw&1) ans = ans * cur;
    }
    return sgn ? ModInt{1} / ans : ans;
  }
};
using mint = ModInt<int(1e9 + 7)>;

mint dp[2][1<<17];
vector<int> g[1<<17];

void dfs(int u, int p) {
  dp[0][u] = dp[1][u] = 1;
  for (int v : g[u]) if (p != v) {
    dfs(v, u);
    dp[0][u] = dp[0][u] * (dp[0][v] + dp[1][v]);
    dp[1][u] = dp[1][u] * dp[0][v];
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, 0);
  cout << (dp[0][0] + dp[1][0]).val << '\n';
}


Measured memory_bytes: 14464
S = input()
Q = int(input())
cond = 1
pre = ''
epi = ''
for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == "1":
		cond *= -1
	else:
		if q[1] == "1":
			if cond == 1:
				pre += q[2]
			else:
				epi += q[2]
		else:
			if cond == 1:
				epi += q[2]
			else:
				pre += q[2]

if cond == 1:
	print(pre[::-1]+S+epi)
else:
	print(epi[::-1]+S[::-1]+pre)

Measured memory_bytes: 4468
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    if(n >= 400 && n <= 599) {
        printf("8\n");
    }
    else if( n >= 600 && n <= 799) {
        printf("7\n");
    }
    else if( n >= 800 && n <= 999) {
        printf("6\n");
    }
    else if( n >= 1000 && n <= 1199) {
        printf("5\n");
    }
    else if( n >= 1200 && n <= 1399) {
        printf("4\n");
    }
    else if( n >= 1400 && n <= 1599) {
        printf("3\n");
    }
    else if( n >= 1600 && n <= 1799) {
        printf("2\n");
    }
    else if( n >= 1800 && n <= 1999) {
        printf("1\n");
    }

    return 0;
}

Measured memory_bytes: 1644
#include<stdio.h>
using namespace std;

int main()
{
	int n,m,l[100000],r[100000];
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++) scanf("%d%d",&l[i],&r[i]);
	
	int lmax=0,rmin=100000;
	for(int i=0;i<m;i++){
		if(lmax<l[i]) lmax=l[i];
		if(rmin>r[i]) rmin=r[i];
	}
	
	printf("%d\n",(rmin-lmax+1<0)? 0:rmin-lmax+1);
	
	return 0;
}


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


int main(){
  int n,k,h,i,r=0;
  cin>>n>>k;
  for(i=0;i<n;i++){
    cin>>h;
    if(h>=k) r++;
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	static StringBuilder sb = new StringBuilder("");
	static Node root = null;	//根っこ
	
	//名ばかりメイン
	public static void main(String args[]) {
		run();
	}
	
	//実質メイン
	public static void run() {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		String ope;
		
		//入力
		for (int i = 0; i < num; i++) {
			ope = scanner.next();
			//命令分岐
			switch( Operate.getEnumName(ope) ){
			case in:
				insert( new Node( scanner.nextInt() ) );
				break;
			case print:
				print();
			}
		}
		
		output();//出力関数
		
		scanner.close();
	}
	
	//挿入処理
	public static void insert(Node node){
		Node parent = null;				// x の親
		Node child = root;
		while (child != null) {
			parent = child;				// 親を設定
			if (node.key < child.key) {
				child = child.left;		// 左の子へ移動
			} else {
				child = child.right;	// 右の子へ移動
			}
		}
		
		//親か子か
		if (parent == null) {
			root = node;
		} else if (node.key < parent.key) {
			parent.left = node;
		} else {
			parent.right = node;
		}
	}
	
	//先行巡回
	public static void preParse(Node node) {
		if (node == null) return;
		
		sb.append(" ").append(node.key);
		preParse(node.left);
		preParse(node.right);
	}
	//中間巡回
	public static void inParse(Node node) {
		if (node == null) return;
		
		inParse(node.left);
		sb.append(" ").append(node.key);
		inParse(node.right);
	}
	
	public static void print() {
		inParse(root);
		sb.append("\n");
		preParse(root);
		sb.append("\n");
	}
	
	//出力
	public static void output(){
		System.out.print(sb);
	}
	
	//enum宣言
	public static enum Operate{
		in("insert"),
		print("print");
		
		private final String name;
		
		Operate(String name){
			this.name = name;
		}
		
		String getName(){
			return this.name;
		}

		public static Operate getEnumName(String str){
			for(Operate v : values()){
				if(v.getName().equals(str)){
					return v;
				}
			}
			throw new IllegalArgumentException("undefined : " + str);
		}
	}

}
//クラス
class Node{
	public int key;
	public Node left;
	public Node right;
	
	public Node(int key) {
		this.key = key;
		left = right = null;
	}
	
}



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

int main() {
  ll l,r;
  cin >> l >> r;
  ll ans=2019;
  if(r-l+1>=2019)
  cout << 0 << endl;
  else{
    for(ll i=l;i<=r;i++){
      for(ll j=i+1;j<=r;j++){
        ans=min(i*j%2019,ans);
      }
    }
    cout << ans << endl;
  } 
}

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

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  unordered_set<string> us;

  string a, b, c;
  int ans = 0;
  vector<char> ch(3);
  for (char i = '0'; i <= '9'; ++i) {
    for (char j = '0'; j <= '9'; ++j) {
      for (char k = '0'; k <= '9'; ++k) {
        ch[0] = i;
        ch[1] = j;
        ch[2] = k;
        int m = 0;
        for (int l = 0; l < n; ++l) {
          if (s[l] == ch[m]) {
            m++;
            if (m == 3) {
              ans++;
              break;
            }
          }
        }
      }
    }
  }

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
#define rep(i,j,n) for(int i=(j);i<=((int)n);++i)
#define rev(i,n,j) for(int i=(n);i>=((int)j);--i)
typedef long long int ll;
#define int long long int
const ll INFL=0x3f3f3f3f3f3f3f3fLL;
const int INF=0x3f3f3f3f;
const int mod=1000000007;
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define readmat(a, n, m) int a[n + 5][m + 5] = {}; rep(i, 1, n) {rep(j, 1, m) cin >> a[i][j];}
#define printmat(a, n, m) rep (i, 1, n) {rep (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define printarr(a, n) rep(i, 1, n) cout << a[i] << " "; cout << endl;
typedef std::map< int,int> mii;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;
#define cerr cout
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);}
const int N = 1e6+5, M = N;
vector <int>g[N];

void solve()
{
    int n;
    cin>>n;
    ii a[n+5];
    for(int i = 1; i <=n; ++i) 
    {
        cin>>a[i].first>>a[i].second;
    }

    sort(a+1,a+n+1);
    int s[n+6];
    int d[n+6];
    for(int i = 1; i <=n; ++i) 
    {
        s[i]=a[i].first+a[i].second;
        d[i]=a[i].first-a[i].second;
    }

    int ans=-INF;
    int mn=s[1];
    for(int i = 1; i <=n; ++i) 
    {
        ans=max(ans,s[i]-mn);
        mn=min(mn,s[i]);
    }
    mn=d[1];
    for(int i = 1; i <=n; ++i) 
    {
        ans=max(ans,d[i]-mn);
        mn=min(mn,d[i]);
    }

    cout<<ans<<endl;
  

}



signed main()
{
  FAST;
#ifdef LOCAL
    freopen("C:\\Users\\hp\\Documents\\input.txt", "r", stdin);
    freopen("C:\\Users\\hp\\Documents\\output.txt", "w", stdout);
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
#endif

solve();

#ifdef LOCAL
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cout<<endl;
    cout << "\nElapsed Time: " << elapsed_time << "ms\n";
#endif

return 0;

}

// vector string set map first second continue break return upper_bound lower_bound length void sort
// stack queue pop size erase empty insert
// #Hala BBCF



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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int main() {
  int N, M, V[30] = {};

  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    int K;
    cin >> K;
    while(K--) {
      int x;
      cin >> x;
      --x;
      V[x]++;
    }
  }
  int ret = 0;
  for(int i = 0; i < M; i++) {
    ret += V[i] == N;
  }
  cout << ret << endl;

}





Measured memory_bytes: 256
import sys,bisect
input = sys.stdin.readline

n,m = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

b = [0]*(n+1)
for i in range(n-1,-1,-1):
    b[i] = a[i]+b[i+1]

ok = 0
ng = 200001

while ng-ok > 1:
    mid = (ok+ng)//2
    cnt = 0
    for e in a:
        k = bisect.bisect_left(a,mid-e)
        cnt += n-k
    if cnt >= m:
        ok = mid
    else:
        ng = mid

c = 0
res = 0

for e in a:
    k = bisect.bisect_left(a,ok+1-e)
    res += b[k] + e*(n-k)
    c += n-k

res += ok*(m-c)
print(res)



Measured memory_bytes: 55580
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

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

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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 nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  ll dx = tx - sx; ll dy = ty - sy;
  
  cout << string(dx,'R') << string(dy,'U') << string(dx,'L') << 
    string(dy,'D') << 'D' << string(dx+1,'R') <<
    string(dy+1,'U') << 'L' << 'U' << string(dx+1,'L') <<
    string(dy+1,'D') << 'R' << endl;
  
}
                                             

Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main()
{
	int a, n, m, result=0, cutp, cutr, cutl;
    string command;
    
    cin>>m;
    int* list=new int[m];
    for(int i=0; i<m; i++){
        cin >> n;
        list[i]=n;
    }
    
    cin>>a;
    for(int i=0; i<a; i++) {
        cutl=0;
        cutr=m-1;
        
        cin>>n;
        
        while(cutl<=cutr){
            cutp=(cutr+cutl)/2;
            
            //cout<<cutl<<":"<<cutp<<":"<<cutr<<" "<<n<<":"<<list[cutp]<<endl;
            if(list[cutp]>n){
                cutr=cutp-1;
            }else if(list[cutp]==n){
                result++;
                break;
            }else{
                cutl=cutp+1;
            }
        }
    }
    cout <<result<< endl;
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	long long int a,b,sum=0;
	cin>>a>>b;
	for(int i=1;i<b-a;i++){
		sum+=i;
	}
	
	cout<<sum-a<<endl;
    return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> H(N);
  for(int i=0;i<N;i++)  cin >> H.at(i);

  if(N<=K){
    cout << 0 << endl;
    return 0;
  }

  sort(H.begin(),H.end(),greater<int>());
  for(int i=0;i<K;i++){
    H.at(i)=0;
  }
  long long ans=0;
  for(int i=0;i<N;i++)  ans+=(long long)H.at(i);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
count = 0

soinsuu = prime_factorize(n)

soinsuu_set = set(soinsuu)
soinsuu_list = list(soinsuu_set)


for i in range(len(soinsuu_set)):
    z = soinsuu_list[i]
    while n % z == 0:
        n = n / z 
        z = z*soinsuu_list[i]
        count = count + 1
    
print(count)

Measured memory_bytes: 9288
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int n, m;
    cin>>n>>m;
    vector<vector<int>> s(m, vector<int> (2));
    for(int i=0; i<m; i++){
        for(int j=0; j<2; j++){
            cin>>s.at(i).at(j);
        }
    }
    
    int ans=0;
    for(int i=1; i<n+1; i++){
        set<int> a;
        int b=0;
        if(i==n&&n!=1) b=1;
        bool bad = false;
        for(int j=0; j<m; j++){
            if(n-s.at(j).at(0)+1==i){
                a.insert(s.at(j).at(1));
                b=s.at(j).at(1);
                if(i==n&&b==0&&n!=1) bad=true;
            }
        }
        if(i==n&&bad){
            ans=-1;
            break;
        }
        if(a.size()>1){
            ans=-1;
            break;
        }else{
            ans+=pow(10, i-1) * b;
        }
    }
    if(m==0&&n!=1){
        ans = pow(10, n-1) *1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int a , b , c , d ;
signed main() {
	cin >> a >> b >> c >> d ;
	while( true ) {
		c -= b ;
		if( c <= 0 ) {
			printf( "Yes\n" ) ;
			return 0 ;
		}
		a -= d ;
		if( a <= 0 ) {
			printf( "No\n" ) ;
			return 0 ;
		}
	}
	return 0 ;
}

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

int main(void){
  stack<int> car;
  int num,res[10000],cnt=0,cnt1=0;

  while( cin >> num ){

    if( num != 0 ) car.push(num);
    else{
      res[cnt] = car.top();
      car.pop();
      cnt++;
      cnt1++;
    }
  }

  cnt = 0;

  while(cnt1){

    cout << res[cnt] << endl; 
    cnt++;
    cnt1--;

  }

  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
int main()
{
    int s,h,m,s1;
    scanf("%d",&s);
    h=s/3600;
    m=(s-h*3600)/60;
    s1=s-h*3600-m*60;

    printf("%d:%d:%d\n",h,m,s1);

    return 0;
}


Measured memory_bytes: 2104
<?php
define("TOP",1);
define("FRONT",2);
define("RIGHT",3);
define("LEFT",4);
define("BEHIND",5);
define("BOTTOM",6);
class Dice{
    private $numbers;
    // before => after
    private $IDX_ROLL = [
        "E" => [TOP => RIGHT,RIGHT => BOTTOM,LEFT => TOP,BOTTOM => LEFT],
        "N" => [TOP => BEHIND,FRONT => TOP,BEHIND => BOTTOM,BOTTOM => FRONT],
        "S" => [TOP => FRONT,FRONT => BOTTOM,BEHIND => TOP,BOTTOM => BEHIND],
        "W" => [TOP => LEFT,RIGHT => TOP,LEFT => BOTTOM,BOTTOM => RIGHT],
        "C" => [FRONT => LEFT,RIGHT => FRONT,LEFT => BEHIND,BEHIND => RIGHT]    // spin:clockwise
    ];
    public function __construct($numbers){
        $this->numbers = $numbers;
    }
    public function roll($dir){
        $pos = $this->numbers;
        foreach($this->IDX_ROLL[$dir] as $before => $after){
            $this->numbers[$after] = $pos[$before];
        }
    }
    public function isEq($dice2){
        for($i = 1; $i <= 6; $i++){
            if($this->numbers[$i] !== $dice2[$i]) return false;
        }
        return true;
    }
    public function isEqual($dice2){
        for($i = 0; $i < 6; $i++){
            for($j = 0; $j <4; $j++){
                if($this->isEq($dice2)) return true;
                $this->roll("C");
            }
            if($i % 2) $this->roll("W");
            else $this->roll("N");
        }
        return false;
    }
}
//=====================================
$numbers = getStdin();
$dice2 = getStdin();
if(count(array_diff($numbers, $dice2)) !== 0){
    echo "No\n";
    exit();
}
$dice1 = new Dice($numbers);
if($dice1->isEqual($dice2)){
    echo "Yes\n";
} else {
    echo "No\n";
}

function getStdin(){
    $l = explode(" ",trim(fgets(STDIN)));
    return array_combine(range(1,6),$l);
}

Measured memory_bytes: 15492
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>


using namespace std;


using namespace std;

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

  cout<<A-(B-1)<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N, A[200000];
int main(void){
    cin >> N;
    REP(i,N) cin >> A[i];
    int m=A[0];
    ll res = 0;
    for(int i=1;i<N;i++){
        if(A[i] < m){
            res += m-A[i];
        }else{
            m = A[i];
        }
    }
    cout << res << endl;
    return 0;
}



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


bool is_prime(int n) {
    if (n < 2) return false;
    for (int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

int main() {
    int x; cin >> x; 
    for (int i = x; i >= x; ++i) {
        if (is_prime(i)) {cout << i << endl;
      break;}
    }
}

Measured memory_bytes: 256
num_mount = int(input())

dam = [int(s) for s in input().split(' ')]

even = [i for index, i in enumerate(dam) if index % 2 == 0]
odds = [i for index, i in enumerate(dam) if index % 2 == 1]

sum_even = sum(even)
sum_odds = sum(odds)

mount = [sum_even - sum_odds]

dam.append(dam[0])
for i in range(0, num_mount-1):
    mount.append(2 * dam[i] - mount[i])

mount_str = map(str, mount)
print(' '.join(mount_str))


Measured memory_bytes: 19912
n = int(input())
a = list(map(int, input().split()))

last = a[0]
direction = 0

ans = 1

for x in a[1:]:
    if direction == 0:
        if last < x:
            direction = 1
        elif last > x:
            direction = -1
        last = x
    elif direction == 1:
        if last > x:
            direction = 0
            ans += 1
        last = x
    elif direction == -1:
        if last < x:
            direction = 0
            ans += 1
        last = x

print(ans)

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

const int N = 510000;
int len;
char S[N];
int qu[N], deg[N], val[N];
vector <int> ve[N];

void add(int x, int y) {
	ve[x].push_back(y);
	deg[y]++;
}

int main() {
	scanf("%s", S + 1);
	int n = strlen(S + 1) + 1;
	for (int i = 1; i < n; i++) {
		if (S[i] == '<')
			add(i, i + 1);
		else
			add(i + 1, i);
	}
	for (int i = 1; i <= n; i++)
		if (!deg[i]) {
			qu[++len] = i;
		}
	for (int i = 1; i <= len; i++) {
		for (auto x: ve[qu[i]]) {
			val[x] = max(val[x], val[qu[i]] + 1);
			if (!(--deg[x]))
				qu[++len] = x;
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		ans += val[i];
	cout << ans << endl;
}


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

int main() {
  long long a,b,x,ans;
  cin >> a >> b >> x;
  if(a != 0){
    ans = b/x-(a-1)/x;
  }
  else{
    ans = b/x+1;
  }
  cout << ans << endl;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m, x;
	cin >> n >> m >> x;
	vi c(n);
	vector<vi> a(n, vector<int>(m));
	rep(i, n){
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}

	ll ans = INFLL;
	for(int bit = 0; bit < (1 << n); bit++){
		vi b;
		ll mny = 0;
		for(int i = 0; i < n; i++){
			if(bit & (1 << i)){
				b.push_back(i);
				mny += c[i];
			}
		}
		vi tmp(m, 0);
		for(auto t : b){
			rep(i, m){
				tmp[i] += a[t][i];
			}
		}
		bool ok = true;
		rep(i, m){
			if(tmp[i] < x) ok = false;
		}
		if(ok) ans = min(ans, mny);
	}

	if(ans == INFLL) ans = -1;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;

struct Rectangle {
    int start, height;
};

int main() {
    int h, w;
    cin >> h >> w;
//
//    int h = 1200;
//    int w = 1150;

    vector<vector<int>> area(h, vector<int>(w));;
    vector<vector<int>> histogram(h, vector<int>(w+1, 0));

    rep(y, h)rep(x, w) cin >> area[y][x];


    rep(y, h) {
        rep(x, w) {
            if (area[y][x] == 0) {
                if (y == 0) histogram[y][x] = 1;
                else histogram[y][x] = histogram[y - 1][x] + 1;
            } else {
                histogram[y][x] = 0;
            }
        }
    }
    ll ans = 0;
    rep(y, h) {
        stack<Rectangle> s;
        rep(x, w + 1) {
            Rectangle rectangle;
            rectangle.start = x;
            rectangle.height = histogram[y][x];
            if (s.empty()) s.push(rectangle);
            else {
                if (s.top().height < rectangle.height) {
                    s.push(rectangle);
                } else if (s.top().height > rectangle.height) {
                    int target = x;
                    while (!s.empty() && s.top().height >= rectangle.height) {
                        Rectangle pre = s.top();
                        s.pop();
                        ll size = pre.height * (x - pre.start);
                        cmax(ans, size);
                        target = pre.start;
                    }
                    rectangle.start = target;
                    s.push(rectangle);
                }
            }
        }
    }
    cout << ans << endl;

}





Measured memory_bytes: 18064
#include<iostream>
#include<vector>
struct ans{
  int y0,x0,y1,x1;
  ans(int a,int b,int c,int d){
    y0=a+1;
    x0=b+1;
    y1=c+1;
    x1=d+1;
  }
};
using namespace std;
int main(){
  int h,w;
  vector<ans> an;
  cin >> h >> w;
  int a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(int y=0;y<h;y++){
    for(int x=0;x<w-1;x++){
      if(a[y][x]%2!=0){
        an.push_back(ans(y,x,y,x+1));
        a[y][x]--;
        a[y][x+1]++;
      }
    }
  }
  for(int y=0;y<h-1;y++){
    if(a[y][w-1]%2!=0){
      an.push_back(ans(y,w-1,y+1,w-1));
      a[y][w-1]--;
      a[y+1][w-1]++;
    }
  }
  cout << an.size()<<endl;
  for(auto i=an.begin();i!=an.end();i++){
    cout << i->y0<<" "<<i->x0<<" "<<i->y1<<" "<<i->x1<<endl;
  }
}


Measured memory_bytes: 5104
from numba import njit
import numpy as np


@njit('i8(i8, i8, i8)', cache=True)
def mod_pow(x, a, MOD):
    # Numbaではmod付き累乗が使えなかった...
    ret = 1
    cur = x
    while a:
        if a & 1:
            ret = ret * cur % MOD
        cur = cur * cur % MOD
        a >>= 1
    return ret


@njit('UniTuple(i8[:], 2)(i8, i8)', cache=True)
def prepare(n, MOD):
    factorials = np.ones(n + 1, dtype=np.int64)
    for i in range(2, n + 1):
        factorials[i] = factorials[i - 1] * i % MOD
    finvs = np.ones(n + 1, dtype=np.int64)
    finvs[n] = mod_pow(factorials[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        finvs[i - 1] = finvs[i] * i % MOD
    return factorials, finvs


@njit('i8(i8, i8)', cache=True)
def solve(n, a):
    MOD = 10 ** 9 + 7
    facts, finvs = prepare(n, MOD)
    invs = [facts[i - 1] * finvs[i] % MOD for i in range(n + 1)]  # invs[0]: undefined
    r = n - a

    ans = 0
    # a個がいずれも自己ループを持たないパターン
    for l in range(a):
        tmp1 = facts[a] * finvs[l] % MOD * finvs[a - l] % MOD
        tmp2 = facts[n - l - 1] * (a - l) % MOD
        ans = (ans + (-1) ** (l & 1) * tmp1 * tmp2) % MOD

    # a個中k+1個目ではじめて自己ループを持つが、それまでのk個で全点灯できるパターン
    for k in range(1, a):
        for l in range(k):
            tmp1 = facts[k] * finvs[l] % MOD * finvs[k - l] % MOD
            tmp2 = facts[n - l - 1] * (k - l) % MOD * invs[r + k - l] % MOD
            ans = (ans + (-1) ** (l & 1) * tmp1 * tmp2) % MOD

    return ans


n, a = map(int, input().split())
print(solve(n, a))


Measured memory_bytes: 357024
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int A, B;
	cin >> A >> B;
	cout << (B+A+24)%24 << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
struct Istream {
	template <class T> 
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}
	template <class T>
	operator T() {
		static T x;
		*this>>x;
		return x;
	}
}is;
struct Ostream {
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}
	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}
}os;
const int MAXN=100000+11;
std::vector<int> G[MAXN];
int fa[MAXN];
int DFS(int pos) {
	int res=0;
	for(int u : G[pos]) if(u!=fa[pos]) {
		fa[u]=pos;
		res^=DFS(u)+1;
	}
	return res;
}
int main() {
	int n=is;
	for(int i=1;i<=n-1;++i) {
		int x=is,y=is;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	std::cout<<(DFS(1)?"Alice":"Bob")<<'\n';
	return 0;
}


Measured memory_bytes: 10752
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int n;
vector<vector<ll> >a(100010,vector<ll>(3));
vector<vector<ll> >dp(100010,vector<ll>(3));


int main(){
  cin>>n;
  for(int i=0;i<n;i++) for(int j=0;j<3;j++) cin>>a[i][j];

  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k) continue;
        chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }

  ll res=0;
  for(int i=0;i<3;i++) chmax(res,dp[n][i]);
  cout<<res<<endl;



}

Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int mp[2][26];

signed main()
{
	string S[2];
	cin >> S[0] >> S[1];
	int n = S[0].size();
	memset(mp, -1, sizeof(mp));
	rep(f, 2) rep(j, n) {
		if (mp[f][S[f][j] - 'a'] != -1) {
			if (mp[f][S[f][j] - 'a'] != S[!f][j] - 'a') {
				cout << "No" << endl;
				return 0;
			}
		}

		mp[f][S[f][j] - 'a'] = S[!f][j] - 'a';
	}

	cout << "Yes" << endl;
}


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

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))

int main()
{
    string s;
    cin >> s;
    
    if (s == "ABC") {
        s = "ARC";
    }
    else {
        s = "ABC";
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
int zet(int t)
{
    if (t < 0)
        t = -t;
    return t;
}
int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (zet(c - a) <= d || (zet(b - a) <= d && zet(c - b) <= d))
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;
char select(char a){
  if(a=='a'){
    return 'A';
  }
  else if(a=='b'){
    return 'B';
  }
  else if(a=='c'){
    return 'C';
  }
}
int main(){
  string a,b,c;
  getline(cin,a);
  getline(cin,b);
  getline(cin,c);
  char flag='A',turn='A';
  
  while(true){
    if(flag=='A'){
      if(a.empty()){
        turn='A';
        break;
      }
      flag=a.front();
      a.erase(a.begin());
      flag=select(flag);
    }
    if(flag=='B'){
      if(b.empty()){
        turn='B';
        break;
      }
      flag=b.front();
      b.erase(b.begin());
      flag=select(flag);
    }
    if(flag=='C'){
      if(c.empty()){
        turn='C';
        break;
      }
      flag=c.front();
      c.erase(c.begin());
      flag=select(flag);
    }
    
  }
  cout<<turn<<endl;
  
}






Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    vector<string> s(3);
    REP(i, 3) cin >> s[i];
    REP(i, 3) cout << s[i][i];
    cout << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
def nxtij(i, j):
    if i & 1 == 0:
        if j < w - 1:
            return i, j + 1
        elif i < h - 1:
            return i + 1, j
        else:
            return None
    else:
        if j > 0:
            return i, j - 1
        elif i < h - 1:
            return i + 1, j
        else:
            return None

def ijgen():
    p = 0, 0
    while p:
        yield p
        p = nxtij(*p)
    return
ans = []
for i, j in ijgen():
    if a[i][j] & 1:
        p = nxtij(i, j)
        if p:
            a[p[0]][p[1]] += 1
            ans.append((i+1, j+1, p[0]+1, p[1]+1))
print(len(ans))
for a in ans:
    print(*a)


Measured memory_bytes: 30484
def i():
	return int(input())
def s():
	return input()
def mp():
	return map(int,input().split())

a = input()
b = list(mp())
mx = b[0]
ans =0
for i in range(1,len(b)):
	if b[i]<mx:ans+=mx-b[i]
	else:mx = b[i]
print(ans)

Measured memory_bytes: 94248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef pair<int, int> P;
int main()
{
	int n, m;
	cin >> n >> m;
	int ans = 0;
	ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from copy import copy, deepcopy
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for CASES in range(int(input())):
'''
inf = 100000000000000000  # 1e17
mod = 998244353

'''
# example input


'''


def replace(pos, char):
    x = pos
    old_char = A[x]
    while x <= n:
        tr[x][old_char] -= 1
        x += x & (-x)
    x = pos
    while x <= n:
        tr[x][char] += 1
        x += x & (-x)
    A[pos] = char


def query(pos, char):
    x = pos
    sum = 0
    while x != 0:
        sum += tr[x][char]
        x -= x & (-x)
    return sum


n = int(input())
S = input().strip()
A = [27] * (n + 1)
'''
for i in range(len(S)):
    A.append(ord(S[i])-ord('a'))
'''
tr = [[0] * 30 for i in range(len(S) + 10)]
for i in range(len(S)):
    replace(i + 1, ord(S[i]) - ord('a'))
q = int(input())
for i in range(q):
    QUERY = list((input().split()))
    if int(QUERY[0]) == 1:
        replace(int(QUERY[1]), ord(QUERY[2]) - ord('a'))
    else:
        sum = 0
        for char in range(ord('a'), ord('z') + 1):
            num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a'))
            if num >= 1:
                sum += 1
        print(sum)


Measured memory_bytes: 204764
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    long long int n, m;
    cin >> n >> m;
    if(n == 1){
        if(m == 1){
            cout << 1;
        }else{
            cout << m - 2;
        }
    }
    else{
        if(m == 1){
            cout << n - 2;
        }else{
             cout << (m - 2) * (n - 2);
        }
    }
}

Measured memory_bytes: 256