akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<vector<vector<int>>> data(4, vector<vector<int>>(3,vector<int>(10)));
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int b, f, r, v;
        cin >>  b >> f >> r >> v;
        data.at(b-1).at(f-1).at(r-1)+=v;
    }
    for(int i=0; i<data.size(); i++){
        for(int j=0; j<data.at(0).size(); j++){
            for(int k=0; k<data.at(0).at(0).size(); k++){
                cout << " " << data.at(i).at(j).at(k);
            }
            cout << endl;
        }
        if(i < data.size()-1){
            for(int l=0; l<20; l++) cout << "#";
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
 	long long N,K,M;
	cin>>N>>K;
	N=N%K;
	M=llabs(N-K);
	if(M>N){cout<<N;}
	else{cout<<M;}
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	int s = 0, t = 0;
	for (int i = 0; i < x.length(); i++)
	{
		if (x.substr(i, 1) == "T")
		{
			t++;
			if (s > 0)
			{
				t--;
				s--;
			}
		}
		else
		{
			s++;
		}
	}

	cout << s + t << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    static class Edge {
        int from, to;

        public Edge(int from, int to) {
            this.from = from;
            this.to = to;
        }
    }

    static void dfs(int at) {
        if (visited[at]) return;
        visited[at] = true;
        d[at] = timeStamp++;

        for (Edge e : graph.get(at)) {
            if (visited[e.to]) continue;
            dfs(e.to);
        }

        f[at] = timeStamp++;
    }

    static int N;
    static int timeStamp = 1;
    static List<List<Edge>> graph;
    static boolean[] visited;
    static int[] d;
    static int[] f;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        graph = new ArrayList<>();
        for (int i = 0; i < N; ++i) graph.add(new ArrayList<>());
        visited = new boolean[N];
        d = new int[N];
        f = new int[N];

        for (int i = 0; i < N; ++i) {
            int id = Integer.parseInt(sc.next());
            int degree = Integer.parseInt(sc.next());
            for (int j = 0; j < degree; ++j) {
                int v = Integer.parseInt(sc.next());
                graph.get(i).add(new Edge(i, v-1));
            }
        }

        for (int i = 0; i < N; ++i) {
            dfs(i);
        }

        for (int i = 0; i < N; ++i) {
            System.out.println((i+1) + " " + d[i] + " " + f[i]);
        }
    }
}


Measured memory_bytes: 28004
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

	n := readInt()

	ans := 0
	for i := 1; i <= n; i += 2 {
		if countDivisor(i) == 8 {
			ans++
		}
	}
	fmt.Println(ans)
}

func countDivisor(n int) int {
	count := 0
	for i := 1; i <= n; i++ {
		if n%i == 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
N=int(input())
A=[]
for i in range(N):
  x,y=map(int, input().split())
  A.append((x,y))

def c(P1, P2, P3):
    x1, y1 = P1; x2, y2 = P2; x3, y3 = P3
    a = 2*(x1 - x2); b = 2*(y1 - y2); p = x1**2 - x2**2 + y1**2 - y2**2
    c = 2*(x1 - x3); d = 2*(y1 - y3); q = x1**2 - x3**2 + y1**2 - y3**2
    det = a*d - b*c
    x = d*p - b*q; y = a*q - c*p
    if det < 0:
        x = -x; y = -y; det = -det
    if det!=0:
      x /= det; y /= det
    r = ((x - x1)**2 + (y - y1)**2)**0.5
    return x,y,r
  
ans=(200000)**2
for i in range(N-1):
  for j in range(i+1,N):
    f=0
    x1,y1=A[i][0],A[i][1]
    x2,y2=A[j][0],A[j][1]
    x,y=(x1+x2)/2,(y1+y2)/2
    r=((x1-x)**2+(y1-y)**2)**0.5
    for a,b in A:
      d=((a-x)**2+(b-y)**2)**0.5
      if d>r:
        f=1
        break
    if f==0:
      ans=min(ans,r)
f=0

if N>2:
  for i in range(N-2):
    for j in range(i+1,N-1):
      for k in range(j+1,N):
        f=0
        x,y,r=c(A[i],A[j],A[k])
        if r>0:
          for a,b in A:
            d=((a-x)**2+(b-y)**2)**0.5
            if d>r:
              f=1
              break
          if f==0:
            ans=min(ans,r)
print(ans)

Measured memory_bytes: 9712
#include <iostream>
using namespace std;
int main()
{
    long long int i, n, sum = 0, input = 0, max = 0, min = 0, temp;
    cin >> n >> min;
    sum = min;
    max = min;
    for(i = 1; i <= n - 1; i++)
    {
        cin >> input;
        sum = sum + input;
        if(input < min){
            min = input;
        }
        if(input > max){
            max = input;
        }
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b;
	for (int i = 0; i < 2; i++) {
		if (a > b) {
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}

	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    int v[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    int min=v[1];
    for(int i=1;i<=n;i++)
    {
       if(min>=v[i])
         min=v[i];
        if(min==v[i])
         c++;
    }
    cout<<c;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <complex.h>
#include <math.h>
#include <iostream>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace std;
#define int ll
// fendwick tree
//#include <ext / pb_ds / assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp>         //required
using namespace __gnu_pbds; //required
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<int> s;
ordered_set<int>::iterator itr;
// fendwick tree
/*
ll ans[200005];
void fun(ll a, ll b, ll c)
{
    //ll val = 1;

    while (a <= b)
    {
        ans[a] += c;
        ll p = -a;
        a += (a & p);
    }
}
ll find1(ll a)
{
    ll sum = 0;
    while (a != 0)
    {
        sum += ans[a];
        ll p = -a;
        a -= (a & p);
    }
    return sum;
}*/
int fastexpo(int a, int b, int m)
{
    int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % m;
        b = b / 2;
        a = (a * a) % m;
    }
    return ans;
}
int32_t main()
{
    int n;
    cin >> n;
    int p = n / 1000;
    cout << ((p + 1) * 1000 - n) % 1000 << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a,b)+max(max(a,b)-1,min(a,b));
}

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

int h,w;
bool s[100][100];
bool f[100][100]; //isSafe
int blackNum = 0;
int safeNum = 0;

void addSafe(int i, int j) {
    if (!f[i][j]) {
        f[i][j] = true;
        safeNum++;
    }
}

int main() {
    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            char c; cin >> c;
            if (c == '#') {
                s[i][j] = true;
                blackNum++;
                if (s[i - 1][j]) {
                    addSafe(i, j);
                    addSafe(i - 1, j);
                }
                if (s[i][j - 1]) {
                    addSafe(i, j);
                    addSafe(i, j - 1);
                }
            }
        }
    }
    cout << (blackNum == safeNum ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef  long long ll;
int N;
int d[105];
ll sum;
ll ans;
ll fun(int a);
int main(){
    scanf("%d",&N);
    sum=0;
    ans=0;
    for(int i=0;i<N;i++){scanf("%d",&d[i]);sum+=d[i];}

    for(int i=0;i<N;i++){
        ans+=fun(d[i]);
    }
    printf("%lld",ans);
    return 0;
}
ll fun(int a){

    sum-=a;
    return a*sum;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll mysqrt(ll x){
	ll l=1,r=2e9;
	while(l<r){
		ll mid=(l+r)>>1;
		if(mid*mid<x)l=mid+1;
		else r=mid;
	}
	return l;
}

int main(){
    ll s;
    cin>>s;

    ll x1=mysqrt(s);
    ll y2=x1;

    ll x2=x1*y2-s;

    ll y1=1;

    cout<<0<<' '<<0<<' '<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;

    return 0;
}


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

string S;

int ch(char c){
  if( c == 'L' ) return 0;
  if( c == 'U' ) return 1;
  if( c == 'D' ) return 1;
  if( c == 'R' ) return 2;
}

bool solve(int f){
  int d[4]={};
  int ft[2]; ft[0] = ft[1] = -1;
  for(int i=0;i<(int)S.size();i++){
    ft[f] = ch(S[i]);
    f = 1-f;
    if(i && S[i] == S[i-1]) return false;
    if( ft[0] == -1 || ft[1] == -1 ) continue;
    if( ft[0] > ft[1] ) return false;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> S;
    if( solve(0) || solve(1) ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

int main(){
    int K;
    cin >> K;
    int64_t ans = 0;
    for(int a=1; a<=K; a++) for(int b=1; b<=K; b++) for(int c=1; c<=K; c++) ans += gcd(a, gcd(b, c));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int a,b;cin>>a>>b;
    int c=max(a+b,a-b);
    cout<<max(c,a*b)<<endl;
}


Measured memory_bytes: 764
def main():
    while True:
        n = int(input())
        if n == 0:break
        a = []
        for i in range(n):
            a.append(int(input()))
        a.sort()
        sum = 0
        for i in range(1,n-1):sum+=a[i]
        print(sum//(n-2))


if __name__ == '__main__':
    main()




Measured memory_bytes: 5600
#include<iostream>

using namespace std;

/*
 * 稳定排序定义：
 * 1. 待排序的记录序列中可能存在两个或两个以上关键字相等的记录。
 * 2. 排序前的序列中Ri领先于Rj（即i<j）.若在排序后的序列中Ri仍然领先于Rj，则称所用的方法是稳定的。
 * 常见的稳定排序：
 *  插入排序，基数排序，归并排序，冒泡排序，计数排序
 * 常见的不稳定排序：
 *  快速排序，希尔排序，简单选择排序，堆排序
 *
 *  本题思路：
 *  利用稳定的冒泡排序的输出结果与选择排序的输出结果进行比较
 *  若相同则是稳定输出，若不同则是不稳定输出
 */

typedef struct{
    char suit;
    char value;
}Cart;

void bubbleSort(Cart a[], int n){ // 冒泡排序
    for (int i = 0; i < n-1; i++){
        for (int j = 0; j < n-i-1; j++){
            if (a[j].value > a[j+1].value){
                swap(a[j], a[j+1]);
            }
        }
    }
}

void selectionSort(Cart a[], int n){ // 选择排序
    for (int i = 0; i < n-1; i++){
        int pos = i;
        for (int j = i; j < n; j++){
            if (a[pos].value > a[j].value){
                pos = j;
            }
        }
        swap(a[pos], a[i]);
    }
}

void print(Cart a[], int n){ // 输出函数
    for (int i = 0; i < n; i++){
        if (i != n-1){
            cout<<a[i].suit<<a[i].value<<" ";
        }else{
            cout<<a[i].suit<<a[i].value<<endl;
        }
    }
}

bool isStable(Cart a[], Cart b[], int n){ // 判断选择排序结果是否与冒泡排序结果一致
    for (int i = 0; i < n; i++){
        if (a[i].suit != b[i].suit){
            return false;
        }
    }
    return true;
}

int main(){
    Cart a[100], b[100];
    int n;
    cin>>n;
    for (int i = 0; i < n; i++){
        cin>>a[i].suit>>a[i].value;

    }
    for(int i = 0; i < n; i++){
        b[i] = a[i];
    }
    bubbleSort(a, n);
    selectionSort(b, n);
    print(a, n);
    cout<<"Stable"<<endl;
    print(b, n);
    if (isStable(a, b, n)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    return 0;
}


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



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll a, b, h, m;
  cin >> a >> b >> h >> m;
  long double kakudo = abs(30*h + 0.5*m - 6*m);
  kakudo = min(kakudo, 360-kakudo);
  kakudo = (kakudo/360.0)*2*3.1415926535897932;
  long double ans = sqrt(a*a + b*b -2*a*b*cos(kakudo));
  cout << ans << "\n";
}

Measured memory_bytes: 4180
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

K = int(read())

x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print(nums.sum())


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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
pair<ll,ll> A[10000000] = {};
ll X[1000000] = {};
ll aiti[10000];
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 0,n = 0,sum = 0, max = INF;
str S;
int ans = 0;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                sum += n%10;
                n /= 10;
                i++;
        }
        return i;
}


int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        //Code Line
cin >> a >> b >> c;

cout << c / a * b << endl;
  //Code Line
        return 0;
}


Measured memory_bytes: 158208
import functools
import fractions
import copy

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

def gcd(x,y):
    if x<y:
        x,y = y,x
    if y==0:
        return x
    return gcd(x%y,y)

l = [a[0]]
for i in range(1,n):
    l.append(gcd(l[-1],a[i]))
l = [0]+l

a.reverse()
r = [a[0]]
for i in range(1,n):
    r.append(gcd(r[-1],a[i]))
r = [0]+r
r.reverse()

# print(l)
# print(r)

ans = 1
for i in range(n):
    ans = max(ans, gcd(l[i],r[i+1]))

print(ans)


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

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

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int 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 / 100;
//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)

bool contain(set<char> &s, int 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);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

struct Testimony {
    int from, to;
    bool is_honest;
};

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

    vector<Testimony> testimonies;

    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            Testimony testimony{(int)i, x, y == 1};
            testimonies.push_back(testimony);
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool b = [&]() {
            for (Testimony &testimony : testimonies) {
                int t_from = testimony.from;
                int t_to = testimony.to;
                bool test = testimony.is_honest;

                bool from_honesty = (i >> t_from) & 1;
                bool to_honesty = (i >> t_to) & 1;
                if (from_honesty) {
                    if (to_honesty == test) {
                        continue;
                    } else {
                        return false;
                    }
                } else {
                    continue;
                }
            }
            return true;
        }();

        if (b) {
            int now = __builtin_popcount(i);
            cmax(ans, now);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int[] uniq(int[] a) {
    int[] ret;
    foreach (x; a) {
        if (ret.length > 0 && ret[$-1] == x) continue;
        ret ~= x;
    }
    return ret;
}

int sign(int n) {
    if (n == 0) return 0;
    if (n > 0) return 1;
    return -1;
}

int calc(int[] a) {
    a = uniq(a);
    int ans = 0;

    int p = 0;
    int[] buf;
    while (p < a.length) {
        switch (buf.length) {
        case 0:
            ans++;
            buf ~= a[p++];
            break;

        case 1:
            buf ~= a[p++];
            break;

        default:
            if (sign(buf[$-1] - buf[$-2]) == sign(a[p] - buf[$-1])) {
                buf ~= a[p++];
            }
            else {
                buf = null;
            }
            break;
        }
    }
    return ans;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


Measured memory_bytes: 4916
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

const MOD: usize = 998244353;

#[fastout]
fn main() {
   input! {
      n: usize,
      s: usize,
      a: [usize; n]
   }

   let mut dp = vec![0usize; s + 1];
   dp[0] = 1;
   for i in 0..n {
      for j in (0..=s).rev() {
         dp[j] *= 2;
         if j >= a[i] {
            dp[j] += dp[j - a[i]];
         }
         dp[j] %= MOD;
      }
   }
   println!("{}", dp[s]);
}


Measured memory_bytes: 2216
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	string s,t;
    cin>>s;
    t=s;
    reverse(t.begin(),t.end());
    for(int i=0;i<s.size();i++){
        if(s[i]=='p'&&t[i]=='q');
        else if(s[i]=='q'&&t[i]=='p');
        else if(s[i]=='b'&&t[i]=='d');
        else if(s[i]=='d'&&t[i]=='b');
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
	return 0;
}

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

vector<int>tree[120];
int c[120], d[120],f[120];
int N,t=0;

void dfs_visit(int u){
  c[u]=1;
  t++;
  d[u]=t;
  for (auto p : tree[u]) {
    if(c[p]==0) dfs_visit(p);
  }
  c[u]=2;
  t++;
  f[u]=t;

}


void dfs(){

  for(int u=0;u<N;u++) c[u]=0;
  for(int u=0;u<N;u++){
    if(c[u]==0) dfs_visit(u);
  }

}

int main() {

  cin >>N;

  //vector<vector<int>> data(N, vector<int>(N));

  for(int j=0;j<N;j++){
  int u,k;
  cin>>u>>k;
    for(int i=0;i<k;i++){
      int v;
      cin>>v;
      tree[u-1].push_back(v-1);
    }
  }

	dfs();

  for(int i=0;i<N;i++) cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
}



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

typedef struct{
  char c;
  int d;
}O;





int n,i,j,a[100],minj,flag=0;
int main () {
  O ok[36],hoke[36],b;
  char z[2];
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%s",z);
    ok[i].c=z[0];
    ok[i].d=atoi(&z[1]);
    hoke[i].c=ok[i].c;
    hoke[i].d=ok[i].d;
    
  }


  //bubble//
  for(i=0;i<n;i++){
  
    for(j=n-1;j>=1+i;j--){
      if(ok[j].d<ok[j-1].d)
	{
	  b=ok[j];
	  ok[j]=ok[j-1];
	  ok[j-1]=b;

	}
    }
  }
 






  //selection//
  for (i=0;i<n;i++){
    minj = i;
    for (j=i;j<n;j++){
      if( hoke[j].d < hoke[minj].d){
	minj = j;
      }
    }
    if(hoke[i].d!=hoke[minj].d){
      b=hoke[i];
      hoke[i]=hoke[minj];
      hoke[minj]=b;
    }
  }
     

 
  for (i=0;i<n;i++){
    printf("%c%d",ok[i].c,ok[i].d);
    if (i<n-1)
      printf(" ");
  }
  printf("\nStable\n");
  for (i=0;i<n;i++){
    printf("%c%d",hoke[i].c,hoke[i].d);
    if (i<n-1)
      printf(" ");
  }
  for (i=0;i<n;i++){
    if(ok[i].c!=hoke[i].c)flag=1;
  }
  if(flag) printf("\nNot stable\n");
  else 
    printf("\nStable\n");
  return 0;
}



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

using namespace std;
typedef long long ll;




int main()
{
    
    
    int N,M;
    cin >> N >> M;
    vector<int> like(M,0);
    
    rep(i,N){
        int k;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            like[a-1] += 1;
        }
    }
    
    int ans = 0;
    
    rep(i,M){
        if(like[i] == N) ans += 1;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#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>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#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 INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
	int n,m;cin>>n>>m;
  	int ans=n*(n-1)/2+m*(m-1)/2;
  	cout<<ans<<endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e5+10;




//dp[i][j]: max value of first i items and we used j weight

void relax(ll& x,ll y) {
    x=max(x,y);
}

int n, w;

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

    
    cin>>n>>w;


    vector<ll> dp(maxn, 0);//max value using j weight so far
    
    for (int i=0; i<n; i++) {
	int wei; ll val;
	cin>>wei>>val;
	for (int j=w; j>=0; j--) {
	    if (j+wei<=w) {
		relax(dp[j+wei], val+dp[j]);
	    }
	}
	// for (int j=1; j<=w; j++) {
	//     dp[j]=max(dp[j],dp[j-1]);
	// }
    }

    //ll ans = *max_element(dp.begin(), dp.end());
    ll ans = dp[w];
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main(){
  int Q; std::cin >> Q;
  std::priority_queue<ll, std::vector<ll>, std::greater<ll>> que1;
  std::priority_queue<ll> que2;

  ll sum1 = 0, sum2 = 0;
  ll constant = 0;
  for(int i=0; i<Q; i++) {
    int c; std::cin >> c;
    if ( c == 1 ) {
      ll a, b; std::cin >> a >> b;
      constant += b;
      if ( que2.empty() || a <= que2.top() ) {
        que2.push(a);
        sum2 += a;
        if( que2.size() > que1.size()+1 ) {
          a = que2.top(); que2.pop();
          que1.push(a);
          sum2 -= a;
          sum1 += a;
        }
      }
      else {
        que1.push(a);
        sum1 += a;
        if( que1.size() > que2.size() ){
          a = que1.top(); que1.pop();
          que2.push(a);
          sum2 += a;
          sum1 -= a;
        }
      }
    }
    else {
      ll x = que2.top();
      std::cout << x << " ";
      std::cout << constant+(sum1-x*(ll)que1.size())+(x*(ll)que2.size()-sum2) << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
char map[505][505];
bool banx[505]= {false};
bool bany[505]= {false};
int n,m;
bool flag;
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)
		for(int r=1; r<=m; r++)
			cin>>map[i][r];
	flag=false;
	for(int i=1; i<=n; i++) {
		flag=false;
		for(int r=1; r<=m; r++)if(map[i][r]=='#')flag=true;
		if(!flag)banx[i]=true;
		}
	for(int i=1; i<=m; i++) {
		flag=false;
		for(int r=1; r<=n; r++)if(map[r][i]=='#')flag=true;
		if(!flag)bany[i]=true;
		}
	for(int i=1; i<=n; i++) {
		for(int r=1; r<=m; r++)
			if((!banx[i])&&(!bany[r]))cout<<map[i][r];
		if(!banx[i])cout<<endl;
		}
	}



Measured memory_bytes: 256
#include <stdio.h>

#define MAX 2000001

void CountingSort(int *, int *, int, int);

int main() {
  int A[MAX];
  int B[MAX];
  int n, i;

  scanf("%d", &n);

  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }

  CountingSort(A, B, n, 10000);

  for (i = 1; i <= n; i++) {
    if(i == 1)printf("%d", B[i]);
    else printf(" %d", B[i]);
  }
  printf("\n");
  
  return 0;
}

void CountingSort(int *A, int *B, int n, int k){
  int C[10001];
  int i, j;

  for (i = 0; i <= k; i++) {
    C[i] = 0;
  }

  for (j = 1; j <= n; j++) {
    C[A[j]]++;
  }

  for (i = 1; i <= k; i++) {
    C[i] = C[i] + C[i - 1];
  }

  for (j = n; j > 0; j--) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 17368
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X, N = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]

    if N == 0:
        print(X)
        return

    sa = 10000
    ans = []
    for i in range(-100, 102):
        if i in P:
            continue

        tmpans = sa
        sa = min(sa, abs(X - i))
        ans.append([sa, i])


    ans.sort()
    print(ans[0][1])



if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			int n = s.Length;
			for (int i = 0; i < n - 1; i++) {
				if (s[i] == s[i + 1]) {
					Console.WriteLine($"{i + 1} {i + 2}");
					return;
				}

				if (i < n - 2) {
					if (s[i] == s[i + 2]) {
						Console.WriteLine($"{i + 1} {i + 3}");
						return;
					}
				}
			}

			Console.WriteLine("-1 -1");
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13792
#include<iostream>
using namespace std;
#include<set>
#include<vector>
set<string> s;
#define int long long int
void function(int initial,int final,vector<int> &v)
{
	if(initial>final)
	{
		string str="";
		for(int x:v)
		{
			char y=char(x);
			str+=y;
		}
		s.insert(str);
	}
	else
	{
		int m=v[0];
		for(int j=1;j<v.size();j++)
		{
			m=max(m,v[j]);
		}
		for(int j=97;j<=m+1;j++)
		{
			v.push_back(j);
			function(initial+1,final,v);
			auto it=v.end();
			it--;
			v.erase(it);
		}
	}
}
int32_t main()
{
    int n;
    cin>>n;
    int j,arr[n];
    for(j=0;j<n;j++)
        cin>>arr[j];
    int sum=0;
    for(j=0;j<n;j++)
    {
		sum+=arr[j];
	}
	int val=arr[0];
	int ans=abs(val-(sum-val));
	for(j=1;j<n-1;j++)
	{
		val=val+arr[j];
		ans=min(ans,abs(val-(sum-val)));
	}
	cout<<ans<<endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t;

// <------------- Implement Functions Here ----------> //

bool comp(pll &a , pll &b) {
	if(a.s == b.s) return a.f > b.f;
	return a.s > b.s;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>k;
	vll a(k),way(n+1,1);
	for(ll i=0;i<k;i++) {
		cin>>a[i];
		way[a[i]] = 0;
	}

	for(ll i=2;i<=n;i++) {
		if(way[i]==0) continue;
		way[i] = ( way[i-1] + way[i-2] ) % MOD;
	}

	cout<<way[n];
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <algorithm>

#define st first
#define nd second

using namespace std;
using ll = long long;
using ld = long double;

const int MAXN = 1e5+5, inf = 1e9;
const ll INF = 1e18;

constexpr int mod = 1e9+7;
constexpr ll MOD = 1e9+7;

set<int> S;
map<int, int> M;

struct point
{
    ll t, x, y;
    bool operator < (const point &b) const
    {
        return t < b.t;
    }
};

point tab[MAXN];

ll dist(point a, point b)
{
    return (abs(a.x - b.x) + abs(a.y - b.y));
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    /////////////////////////////
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> tab[i].t >> tab[i].x >> tab[i].y;
    }

    sort(tab + 1, tab + n + 1);

    for (int i = 1; i <= n; i++)
    {
        int d = tab[i].t - (tab[i - 1].t + dist(tab[i], tab[i - 1]));
        if (d < 0|| d & 1)
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>
#include <ctype.h>
using namespace std;

int main(void)
{	
	char c;
	int count[26] = {0};
	while (cin >> c){
		c = tolower(c);
		if (c >= 'a' && c <= 'z') {
			count[c-'a']++;
		}
	}
	
	for (int i = 0; i < 26; i++) {
		cout << (char)('a' + i) << " : " << count[i] << endl;
	}
	
	return 0;
}

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

template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
    ~debug(){cerr<<endl;}
    template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
    template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
    template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
    template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
    template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}


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

    int n, k;
    cin >> n >> k;
    vector<int> cnt_rem(k);
    for(int i = 1; i <= n; i++) {
        cnt_rem[i%k]++;
    }
    ll ans = 0;
    for(int a = 1; a <= n; a++) {
        int need = (k - (a % k)) % k;
        if(2*need%k == 0) {
            ans += 1LL * cnt_rem[need] * cnt_rem[need];
        }
    }
    
    cout << ans << endl;
}













// Those who say they can, and those who say they can't - are both usually right.

// Read statement carefully
// Solve on paper first!
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  string S, T;
  cin >> S >> T;

  SORT(S);
  SORT(T);
  REVERSE(T);

  if (S < T) {
    COUT("Yes");
    return 0;
  }

  COUT("No");
  return 0;
}

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

const int N = 3e5L + 11;
using ll = long long;
int a[N];

int main() {
	ios :: sync_with_stdio(0);
	int n; cin >> n;
	multiset <int> l, r, sp;
	ll sl = 0, sr = 0;
	for(int i = 1; i <= 3 * n; i ++) {
		cin >> a[i];
		if(i <= n) l.insert(a[i]);
		else r.insert(-a[i]);
	}
	while(r.size() > n) {
		sp.insert(*r.begin());
		r.erase(r.begin());
	}
	for(int x : l) sl += x;
	for(int x : r) sr += x;

	ll ans = sl + sr;
	for(int i = n + 1; i <= 2 * n; i ++) {
		l.insert(a[i]);
		sl += a[i];
		sl -= *l.begin();
		l.erase(l.begin());

		if(r.count(-a[i])) {
			sr -= -a[i];
			r.erase(r.find(-a[i]));
			int x = *sp.rbegin();
			sp.erase(sp.find(x));
			sr += x;
			r.insert(x);
		} else {
			sp.erase(sp.find(-a[i]));
		}

		ans = max(ans, sl + sr);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}

void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}

int N, M, A, B;

void solve() {
	C_init(200000);
	cin >> N >> M >> A >> B;
	ll res = 0;
	rep(i, 0, N - A) {
		// debug(B + i - 1, i, N - i - 1, M - B - 1);
		ADD(res, C(B + i - 1, i) * C(N - i - 1 + M - B - 1, N - i - 1) % mod);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 6016
def r(x):
    return list(reversed(x))

def main():
    import sys
    S=sys.stdin.readline().strip()
    L=list(S)
    N=len(S)
    if L==r(L) and L[:(N-1)//2]==r(L[:(N-1)//2]) and L[(N+3)//2-1:]==r(L[(N+3)//2-1:]):
        return 'Yes'
    else:
        return 'No'
    
print(main())

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

using ull = unsigned long long;
using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll temp = gcd(a, b); return temp ? (a / temp * b) : 0; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

template <typename T>
vector<T> pows(int n) {
	vector<T> ret;
	T x = 1;
	while (ret.size() < n) {
		ret.push_back(x);
		x *= 10;
	}
	return ret;
}

template <class T>
bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T>
bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

inline tuple<ll, ll> rotate45(tuple<ll, ll> point) { ll x = get<0>(point), y = get<1>(point); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

template <typename T>
void out(T o) { cout << o << endl; }
template <typename T>
void out(vector<T> &out) { REP(i, (int)out.size()) { cout << out[i]; if (i == (int)out.size() - 1) cout << endl; else cout << " "; } }



int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	string s; cin >> s;
  bool ok = true;
  	if (s[0] != 'A') ok = false;
  	FOR(i, 1, 2) if (not ('a' <= s[i] and s[i] <= 'z')) ok = false;
  int cnt = 0;
    FOR(i, 2, s.size()) {
      if (not ('a' <= s[i] and s[i] <= 'z')) {
        if (s[i] == 'C') cnt++;
        else ok = false;
      }
    }
  if (not ('a' <= s[s.size()-1] and s[s.size()-1] <= 'z')) ok = false;
  
  if (cnt != 1) ok = false;
  
  if (ok) cout << "AC" << endl;
  else cout << "WA" << endl;

	return 0;
}


Measured memory_bytes: 256
#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 A, B, C;
  cin >> A >> B >> C;

  if ((A < C && C < B) || (A > C && C > B))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;

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

	cin >> n;
	vector<int> l(n);
	for (int i=0; i<n; i++)
	{
		cin >> l[i];
	}
	sort(l.begin(),l.end());

	ll ret=0;
	for (int i=0; i<n-2; i++)
	{
		for (int j=i+1;j<n-1;j++)
		{
			int c=l[i]+l[j];
			vector<int>::iterator it=lower_bound(l.begin(), l.end(), c);
			if (it==l.end())
			{
				ret+=(n-j-1);
			} else {
				int id = distance(l.begin(), it);
				ret+=(id-j-1);
			}
			
		}
	}

	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 256