akhauriyash/Code-Regression huggingface dataset:
from fractions import gcd
from functools import reduce

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

A, B, C, D = map(int, input().split())

tmp = B // C + B // D - A//C - A // D
if A%C == 0:
    tmp += 1
if A%D == 0:
    tmp += 1
lcm = lcm_base(C, D)
tmp -= (B//lcm - A//lcm)
if A%lcm == 0:
    tmp -= 1
print(B-A+1-tmp)


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

template <typename T>
void print(const T &v);

int main()
{
    ll n;
    cin >> n;
    ll ans = (n - 1) * n / 2;
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<size_t> p(N);
  for (auto& pi: p) {
    scanf("%zu", &pi);
    --pi;
  }

  int res = 0;
  for (size_t i = 0; i+1 < N; ++i) {
    if (p[i] == i) {
      ++res;
      std::swap(p[i], p[i+1]);
    }
  }

  if (p[N-1] == N-1) ++res;
  printf("%d\n", res);
}


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

#define f hell(t,a)
int n;
int hell(int t,int a[])
{
    int s1=0,s2=0;
    for(int i=0; i<t; i++)
        s1+=a[i];
    for(int i=t; i<n; i++)
        s2+=a[i];
    return abs(s1-s2);
}

int main()
{
    int m=0x7fffffff;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int t=1; t<=n; t++)
    {
        if(f==0)
        {
            cout<<"0"<<endl;
            return 0;
        }
        else if(f<m)
        {
            m=f;
        }
    }
        cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
//
// Created on 2020/07/11.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int l,r;
    int d;
    cin>>l>>r>>d;
    int ans = 0;
    for (int i = l; i <= r; ++i) {
        if(i % d == 0){
            ans ++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
using namespace std;
string a,b;
int num;
int main () {
	cin>>a>>b;
	a+=b;
	for (int i=0,len=a.size();i<len;++i) num=num*10+a[i]-'0';
	int kksk=sqrt(num);
	cout<<(kksk*kksk==num?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
signed main()
{
	int k;
	string s;
	cin >> k >> s;
	if(s.size() <= k)
	{
		cout << s << "\n";
	}
	else
	{
		for(int i = 0; i < k; ++i)
		{
			cout << s[i];
		}
		cout << "...\n";
	}
}


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

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int N, M;
    cin >> N >> M;

    vector<int> X(M);
    rep(i,M) cin >> X[i];

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

    sort(X.begin(), X.end());
    vector<pair<int, int>> diff(M - 1);
    rep(i,M-1) diff[i] = make_pair(abs(X[i] - X[i + 1]), M - i - 1);

    sort(diff.begin(), diff.end(), greater<pair<int, int>>());

    ll ans = 0;
    for (int i = N - 1; i < M; i++) ans += diff[i].first;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
st = input().split(' ');
s = st[0];
t = st[1];
ab = input().split(' ');
a = int(ab[0]);
b = int(ab[1]);
u = input().rstrip('\n');

if u == s :
	a = a-1;
else :
	b = b-1;

print(a,b);

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	
	if(scanf("%d %d %d %d", &a, &b, &c, &d) > 0)
	{
	int answer;
	if(c < b || a < d)
	{	
		int bigger, smaller;
		if(a < c)
		{
			bigger = c;
		}
		else
		{
			bigger = a;
		}
		if(b < d)
		{
			smaller = b;
		}
		else
		{
			smaller = d;
		}
		answer = smaller - bigger;
	}
	if(answer < 0)
	{
		answer = 0;
	}
	printf("%d", answer);
	}
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		sc.close();
		String ans[] = {"Yes", "No"};
		int an = 1;
		if(Math.abs(a - c) <= d) an = 0;
		else if(Math.abs(a - b) <= d && Math.abs(b - c) <= d)
			an = 0;
		
		System.out.println(ans[an]);
	}

}


Measured memory_bytes: 22996
#include <stdio.h>
#include <string.h>

int main()
{
	int sum = 0,max = 0;
	char c[11];
	gets(c);
	for(int i = 0;i < strlen(c);i++){
		if(c[i] == 'A' || c[i] == 'C' || c[i] == 'T' || c[i] == 'G') sum++;
		else{
			if(sum > max) max = sum;
			sum = 0;
		}
	}
	if(sum > max) max = sum;
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
N=int(input())
n=N
listm=[]
listn=[]
l=0
while n!=0:
  m=n%26
  listm.append(m)
  n=n//26
  l+=1

for i in range(l):
  try:
    if listm[i]<=0:
      listn.append(listm[i]+26)
      listm[i+1]-=1
    else:
      listn.append(listm[i])
  except IndexError:
    listn.append(listm[i])
    l=l-1
    exit

list_ans=[]
for i in range(N):
  try:
    ans=chr(listn[i]+96)
    list_ans.append(ans)
  except IndexError:
    break

ans=''
for i in range(l):
  ans=ans+list_ans[l-i-1]

print (ans)

Measured memory_bytes: 9216
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
input:
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print

output: in_order + pre_order
 1 12 17 20 25 30 88
 30 12 1 20 17 25 88

"""

import sys


class Node(object):
    def __init__(self, data):
        self.data = data
        self.left, self.right = None, None

    def insert(self, data):
        """
        insert data according to BST rules
        """
        if data < self.data:
            if not self.left:
                self.left = Node(data)
            else:
                self.left.insert(data)
        # insert duplicate value to right
        else:
            if not self.right:
                self.right = Node(data)
            else:
                self.right.insert(data)

        return self.data


def pre_order(node):
    if node is not None:
        print('', node.data, end='')
        pre_order(node.left)
        pre_order(node.right)
    return None


def in_order(node):
    if node is not None:
        in_order(node.left)
        print('', node.data, end='')
        in_order(node.right)
    return None


def action(command, content):
    if command.startswith('in'):
        tree_root.insert(int(content))
    # print tree walk
    else:
        in_order(tree_root)
        print('')
        pre_order(tree_root)
        print('')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    command_list = list(map(lambda x: x.split(), _input[1:]))
    # assert len(command_list) == array_length

    flag, tree_root = False, None
    for each in command_list:
        command, content = each[0], each[-1]
        if (not flag) and command.startswith('in'):
            tree_root = Node(data=int(content))
            flag = True
            continue
        action(command, content)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    auto dist = [&](int i, int j) {
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx * dx + dy * dy);
    };
    double sum = 0.0;
    rep(i, n) rep(j, i) {
        sum += dist(i, j);
    }
    int num = 2;
    rep1(i, n-1) num *= i;
    int fact = 1;
    rep1(i, n) fact *= i;
    double ans = sum * num / fact;
    printf("%.10f\n", ans);
    return 0;
}


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

#define ELEMENTS_MAX 100000
long long int N, counter_even[ELEMENTS_MAX], counter_odd[ELEMENTS_MAX];

class Map_t{
	public:
		int number,count;
		Map_t() : number(0), count(0) {}
};

int main(){
	for( int i=0; i<ELEMENTS_MAX; ++i ){ counter_even[i] = 0; counter_odd[i] = 0;}

	std::cin >> N;
	for( int v, i=0; i<N; ++i ){
		std::cin >> v;
		v = v - 1;
		if( i % 2 ){
			counter_even[v]++;
		} else{
			counter_odd[v]++;
		}
	}

	Map_t odd_index[2], even_index[2];
	const int FIRST = 0, SECOND = 1;
	for( int i=0; i<ELEMENTS_MAX; ++i ){
		if( counter_odd[i] > odd_index[SECOND].count ){
			odd_index[SECOND].number = i;
			odd_index[SECOND].count = counter_odd[i];
			if( odd_index[SECOND].count > odd_index[FIRST].count ){
				Map_t save;
				save = odd_index[FIRST];
				odd_index[FIRST] = odd_index[SECOND];
				odd_index[SECOND] = save;
			}
		}
		if( counter_even[i] > even_index[SECOND].count ){
			even_index[SECOND].number = i;
			even_index[SECOND].count = counter_even[i];
			if( even_index[SECOND].count > even_index[FIRST].count ){
				Map_t save;
				save = even_index[FIRST];
				even_index[FIRST] = even_index[SECOND];
				even_index[SECOND] = save;
			}
		}
	}

	int result = 0;
	if( ( even_index[FIRST].count + odd_index[FIRST].count ) == N ){
		if( even_index[FIRST].number == odd_index[FIRST].number ){
			result = N / 2;
		} else{
			result = 0;
		}
	} else if( even_index[FIRST].number == odd_index[FIRST].number ){
		result = N - std::max( even_index[FIRST].count + odd_index[SECOND].count, even_index[SECOND].count + odd_index[FIRST].count );
	} else{
		result = N - ( even_index[FIRST].count + odd_index[FIRST].count );
	}
	std::cout << result << std::endl;
}


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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define precise(x) cout<<fixed<<setprecision(12)<<x
#define test cout<<"#";

const ll inf = 1e18L + 2;

ll dp[3001][3001];
ll s[3001];

ll solve(vector<ll> &v, ll i , ll j)
{
	if(i==j)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	dp[i][j] = inf;
	for(ll k = i; k < j; k++)
	{
		dp[i][j] = min(dp[i][j], s[j]-s[i-1]+solve(v, i, k)+solve(v, k+1, j));
	}
	return dp[i][j];
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> v(n+1);
	for(ll x = 1; x<=n; x++)
	{	
		cin>>v[x];
		s[x]+=s[x-1]+v[x];
	}
	memset(dp, -1, sizeof(dp));
	cout<<solve(v, 1, n);
}

Measured memory_bytes: 70784
import java.util.Scanner;
public class Main {
	
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static int lower_bound(int vector[],int key){
		return 0;
	}
	public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
	public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int isPalindrome(char str[],int l,int h) 
{ 
    // Start from leftmost and rightmost 
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return 0; 
        } 
    } 
    return 1;
    // printf("%s is palindrome", str); 
} 
int main()
{
    int l;
    char *s = (char *)malloc(sizeof(char)*100);
    scanf("%s",s);
    l = strlen(s);
    if(isPalindrome(s,0,l-1)==1 && isPalindrome(s,0,((l-1)/2)-1)==1 && isPalindrome(s,((l+3)/2)-1,l-1)==1)
    {
        printf("Yes");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>

using namespace std;

struct Edge{int to, cost;};
const int NODE = 101;
const int MAX = 1e4+1;

vector<Edge> E[NODE];

int N,M;

void input(){
  for(int i = 0; i < NODE; i++) E[i].clear();

  for(int i = 0; i < M; i++){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    a--; b--;
    E[a].push_back((Edge){b,c});
    E[b].push_back((Edge){a,c});
  }
}

bool prim(int low, int high){

  bool used[N];
  for(int i = 0; i < N; i++) used[i] = false;

  used[0] = true;
  queue<int> Q;
  Q.push(0);

  int connect = 1;
  while(!Q.empty()){
    const int now = Q.front();
    Q.pop();
    
    for(int i = 0; i < E[now].size(); i++){
      Edge& e = E[now][i];
      if(!used[e.to] && low <= e.cost && e.cost <= high){
	used[e.to] = true;
	connect++;
	Q.push(e.to);
      }
    }
  }
  return connect==N;
}

void solve(){
  
  int ans = MAX;

  for(int i = 0; i < MAX; i++){
    int L = i,R = MAX;
    while(L < R){
      int C = (L+R)/2;
      if(prim(i,C)) R = C;
      else L = C+1;
    }
    if(R == MAX) continue;
    ans = min(ans,R-i);
  }
  if(ans >= MAX) printf("-1\n");
  else printf("%d\n",ans);
}

int main(){
  while(cin >> N >> M && N+M){
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1364
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli N,M,num=0,sum=0,flag=0;string S;
  cin >> S;
  N=S.size();
  M=2019;
  DV(dp,lli,2,M,0);//dp[i文字目まで見た][Mで割った余りがj]
  Vec(mot,int,10*M+10,0);
  rep(i,0,10*M+10)mot[i]=i%M;
  dp[1][mot[(S[0]-'0')]]++;
  sum+=dp[1][0];
  rep(i,1,N){
    rep(j,0,M)dp[flag][mot[(10*j+(S[i]-'0'))]]+=dp[flag^1][j];
    dp[flag][mot[(S[i]-'0')]]++;
    sum+=dp[flag][0];
    flag^=1;
    rep(j,0,M)dp[flag][j]=0;
  }
  Out(sum);
}


Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		String abacus[] = new String[]{
			"* = ****",
			"* =* ***",
			"* =** **",
			"* =*** *",
			"* =**** ",
			" *= ****",
			" *=* ***",
			" *=** **",
			" *=*** *",
			" *=**** ",
		};
		int flag = 0;
		while((string = reader.readLine()) != null){
			if(flag == 1) System.out.println();
			else flag++;
			
			while(string.length() < 5){
				string = "0" + string;
			}
			
			char ch[] = string.toCharArray();
			for(int i = 0; i < 8; i++){
				for(int j = 0; j < 5; j++){
					System.out.print(abacus[ch[j] - '0'].charAt(i));
				}
				System.out.println();
			}
		}
		reader.close();
	}
}

Measured memory_bytes: 35056
from collections import defaultdict
from itertools import combinations as comb



initial_dict = defaultdict(int)
n = int(input())
for i in range(n):
    initial = input()[0]
    if initial in 'MARCH':
        initial_dict[initial] += 1



ret = 0
for i, j, k in comb('MARCH', 3):
    ret += initial_dict[i] * initial_dict[j] * initial_dict[k]


print(ret)


Measured memory_bytes: 43496
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int main()
{
	int a , b , c;
	cin >> a >> b >> c;
	if(c >= a && c <= b){
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
} 




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int toInt(string s) {
	stringstream ss; ss << s;
	int res; ss >> res;
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	stack<int> S;
	string s;
	while ( cin >> s ) {
		if (s == "+" || s == "-" || s == "*") {
			int right = S.top(); S.pop();
			int left = S.top(); S.pop();
			if ( s == "+" ) {
				S.push(left + right);
			}
			else if ( s == "-" ) {
				S.push(left - right);
			}
			else if ( s == "*" ) {
				S.push(left * right);
			}
			else {
				assert(false);
			}
		}
		else {
			S.push( toInt(s) );
		}
	}
	cout << S.top() << endl;
}

Measured memory_bytes: 3216
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int A[N][N], n;

int prim(){
  int i, u, v, min, sum = 0;
  int d[N], p[N], color[N];

  for(i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    min = INFTY;
    u = -1;
    for(i = 0; i < n; i++){
      if(min > d[i] && color[i] != BLACK){
        u = i;
        min = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && A[u][v] != INFTY){
        if(d[v] > A[u][v]){
          d[v] = A[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }

  for(i = 0; i < n; i++){
    if(p[i] != -1) sum += A[i][p[i]];
  }

  return sum;
}

int main(){
  int i, j, s;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &s);
      A[i][j] = (s == -1) ? INFTY : s;
    }
  }

  printf("%d\n", prim());

  return 0;
}


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

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

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

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    vector<int> s(n+1);
    for (int i = 0; i < n; ++i) {
        s[i+1] = s[i]^v[i];
    }
    ll ans = 1;
    vector<ll> dp(1<<20, 0), dq(1<<20, 1), zeros(1<<20, 0);
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if(s[i] == 0) cnt++;
        else {
            (dq[s[i]] += dp[s[i]]*(cnt-zeros[s[i]])) %= MOD;
            (dp[s[i]] += dq[s[i]]) %= MOD;
            zeros[s[i]] = cnt;
        }
    }
    if(s.back() != 0) cout << dq[s.back()] << "\n";
    else {
        ans = pow_(2, cnt-1, MOD);
        ans = accumulate(dp.begin(),dp.end(), ans);
        cout << ans%MOD << "\n";
    }
    return 0;
}

Measured memory_bytes: 28800
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

double a[6];

void solve(){
	double aa=(a[2]*a[4]-a[1]*a[5])/(a[0]*a[4]-a[1]*a[3]);
	double bb=(a[0]*a[5]-a[2]*a[3])/(a[0]*a[4]-a[1]*a[3]);
	if(abs(aa)<EPS)aa=0;
	if(abs(bb)<EPS)bb=0;
	printf("%.3f %.3f\n",aa,bb);
}

int main(){
	while(cin>>a[0]){
		rep(i,5)cin>>a[i+1];
		solve();
	}
	
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> L) {
  long long max = *max_element(L.begin(), L.end());
  long long sum = accumulate(L.begin(), L.end(), 0);

  if (sum - max > max) {
    cout << YES << endl;
  } else {
    cout << NO << endl;
  }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> L(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &L[i]);
  }
  solve(N, std::move(L));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mo=1e9+7;
int n,k,a[2005],i,j,s1,s2,ans;
int main(){
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	for(i=1;i<n;++i)for(j=i+1;j<=n;++j)s1+=a[i]>a[j];
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)s2+=a[i]>a[j];
	ans=(1ll*k*(k-1)/2%mo*s2+1ll*k*s1)%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;

int a[100100];

int main(){
	cin>>n;
	a[0]=0;
	int sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=abs(a[i]-a[i-1]);
	}
	sum+=abs(a[n]);
	a[n+1]=0;
	
	for(int i=1;i<=n;i++){
		if((a[i]-a[i-1])*(a[i+1]-a[i])>=0){
			cout<<sum<<endl;
		}else{
			int s=sum-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1]);
			cout<<s<<endl;
		}
	}
	return 0;
}
	

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main(void){
  int l, k;
  
  cin >> l;
  cin >> k;

  long long int b[l + 1]; 
  long long int w[l + 1];
  
  b[1] = 1;
  w[1] = 0;

  if(k <= l){
    
    for(int i = 2 ; i <= k ; i++){
      b[i] = w[i - 1];
      w[i] = b[i - 1];
    }

    b[k] += 1;

    for(int i = k + 1; i <= l ; i++){
      b[i] = w[i - 1] + w[i - k];
      w[i] = b[i - 1];
    }

  }else{

    for(int i = 2 ; i <= l ; i++){
      b[i] = w[i - 1];
      w[i] = b[i - 1];
    }
    
  }
  
  long long int ans = 0;
  for(int i = 1 ; i <= l ; i++){
    ans += b[i]; 
  }

  cout << ans << endl;
  
}




Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=1e6+5;
int bit[N]={0};

void upd(int node,int x)
{
  for(;node<N;node+=(node&-node))
    bit[node]+=x;
}

int get(int node)
{
  if(node<1)
    return 0;
  int x=0;
  for(;node>0;node-=(node&(-node)))
    x+=bit[node];
  return x;
}
void solve()
{
    int n,q,x,y;
    cin>>n>>q;
    vector<array<int,2>> v[n+1];
    int ans[q+1];
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
    for(int i=1;i<=q;i++)
    {
      cin>>x>>y;
      v[y].push_back({x,i});
    }
    map<int,int> mp;
    for(int i=1;i<=n;i++)
    {
      if(mp.find(a[i])==mp.end())
      {
        upd(i,1);
      }
      else
      {
        upd(mp[a[i]],-1);
        upd(i,1);
      }
      mp[a[i]]=i;
      for(auto j:v[i])
      {
       ans[j[1]]=get(i)-get(j[0]-1);
      }
    }
    for(int i=1;i<=q;i++)
      cout<<ans[i]<<endl;
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 71648
mod=10**9+7
r1,c1,r2,c2=map(int,input().split())

FACT=[1]
for i in range(1,2*10**6+3):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**6+2,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0

for x in range(c1+1,c2+2):
    ANS=(ANS+Combi(r2+x,r2)-Combi(r1+x-1,r1-1))%mod

print(ANS)


Measured memory_bytes: 127104
let input = ''

process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
  input += chunk
})
process.stdin.on('end', function() {
  input = input.trim().split('\n')
  main()
})

function main() {
  dataset_num = input[0]
  if (dataset_num > 1000) {
    return
  }
  for(i=1; i<input.length; i++) {
    input_line = input[i].split(' ')
    input_line.sort(compareNumbers)
    // console.log(input_line)
    if(0 > input_line[0] || input_line[0] > 1000 ) {
        return
    }
    if(0 > input_line[1] || input_line[1] > 1000 ) {
        return
    }
    if(0 > input_line[2] || input_line[2] > 1000 ) {
        return
    }
    if (Math.pow(input_line[0],2) === Math.pow(input_line[1],2) + Math.pow(input_line[2],2)) {
      console.log('YES')
    } else {
      console.log('NO')
    }
    // console.log(Math.pow(input_line[0],2))
  }
}

function compareNumbers(a, b) {
  return b - a;
}


Measured memory_bytes: 18776
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>

//using lli = long long int;
int inf = 1000000007;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

int N;
int Q;
int x, y;

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

	//整列した場合との一致度
	int match = 0;
	for (int i = 0; i < N; i++)match += (a[i] == b[i] ? 1 : 0);
	//既に整列している
	if (match == N) { cout << 0 << endl; return 0; }
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> x >> y;
		x -= 1; y -= 1;
		//揃っていたものをSwapしてしまう場合
		if (b[x] == a[x])match -= 1;
		if (b[y] == a[y])match -= 1;
		int c = a[x];
		a[x] = a[y];
		a[y] = c;
		//もしSwapした時に揃った場合
		if (b[x] == a[x])match += 1;
		if (b[y] == a[y])match += 1;

		//揃った数 = 数列の長さなら全て整列したことになる
		if (match == N) { cout << (i + 1) << endl; return 0; }
	}

	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 5208
import std.stdio;
import std.conv;
import std.array;

void main()
{
    auto reader = readln.split;
    int A = reader[0].to!int;
    int B = reader[1].to!int;
    int C = reader[2].to!int;

    if ((A < C && C < B) || (A > C && C > B)) writeln("Yes");
    else writeln("No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  printf("ABC%03d\n",n);
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define VL vector<ll>
#define MA vector<VL >

const int P = 1e9+7;

using namespace std;

int n;
ll k;
MA I, X;

MA init(int szx, int szy){
	VL re(szx, 0);
	MA RE(szy, re);
	return RE;
}

MA mlp(MA A, MA B){
	int ay = A.size();
	int ax = A[0].size();
	int by = B.size();
	int bx = B[0].size();
	
	MA AB = init(bx, ay);
	if(ax != by) return AB;

	for(int i=0; i<ay; i++){
		for(int j=0; j<bx; j++){
			for(int k=0; k<ax; k++){
				AB[i][j] = (AB[i][j]+A[i][k]*B[k][j])%P;
			}
		}
	}

	return AB;
}

MA pow(ll z){
	if(z == 0) return I;
	MA U = pow(z/2);
	U = mlp(U, U);
	if(z&1) U = mlp(X, U);
	return U;
}

int main(){

	cin >> n >> k;
	
	I = init(n, n);
	X = init(n, n);

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin >> X[i][j];
			if(i==j) I[i][j] = 1;
		}
	}

	MA ANS = pow(k);
	ll ans = 0;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			ans = (ans+ANS[i][j])%P;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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


int main()
{
	int a, b;
	cin >> a >> b;
	int i = 1;
	while((int)(i * 0.08) <= a && (int)(i * 0.1) <= b)
	{
		double x = i * 0.08;
		double y = i * 0.1;
		if ((int)x == a && (int)y == b)
		{
			cout << i;
			return 0;
		}
		i++;
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    vector<int> a;
    for(int i=0;i<n;i++){
        int p;scanf("%d",&p);
        auto itr=lower_bound(a.begin(),a.end(),p);
        if(itr==a.begin())a.emplace(a.begin(),p);
        else itr--,*itr=p;
    }
    printf("%d\n",a.size());
    return 0;
}

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

using namespace std;

const int maxn = 3e5 + 7;
int n;
int a[maxn];
int main(){
	cin >> n;
	for(int i = 1; i <= 3 * n; ++i)cin >> a[i];
	sort(a + 1,a + 3 * n + 1);
	long long ans = 0;
	for(int i = 1,j = 3 * n,k = 3 * n - 1; i <= n; ++i,j -= 2,k -= 2)
		ans += a[k];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int main (void) {
  int n; cin >> n;
  int64_t sum = 0;
  vector<int> a(n); for (int& ai: a) cin >> ai;
  vector<int64_t> suffix(n);
  for (int64_t i = n - 1, sufsum = 0;i >= 0;i--) {
    sufsum = (sufsum + a[i]) % MOD;
    suffix[i] = sufsum;
  }
  for (int i = 0;i < n - 1;i++) {
    sum = (sum + (a[i] * suffix[i + 1]) % MOD) % MOD;
  }

  cout << sum << '\n';
}

Measured memory_bytes: 5640
#include<bits/stdc++.h>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define inf         1e9+5
#define mp          make_pair
#define ll          long long
#define pii         pair<int,int >
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define sf          scanf
#define pf          printf
/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
using namespace std;
//
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//
//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key
////

int main()
{
    char a,b,c;
    cin>>a>>b>>c;
    if(a=='7' ||b=='7'||c=='7') cout<<"Yes\n";
    else cout<<"No\n";
}


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

int main() {
  int N,K,d,ans=0,temp;
  cin >> N >> K;
  vector<bool> vec(N+1);
  vec.assign(N+1,1);

  for(int i=0;i<N;i++){
    cin >> d;
    for(int j=0;j<d;j++){
      cin >> temp;
      vec.at(temp) = 0;
    }
  }

  for(int i=1;i<=N;i++){
    if(vec.at(i)) ans++;
  }

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

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int X,Y;
  cin >> X >> Y;
  cout << X + Y / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7 ;

ll n, ans, dp[100][10];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	string a[3];
	fo(i, 2)
		cin >> a[i-1];
	dp[0][0] = 1;
	int m = 6;
	for(int i = 1; i <= n; ++i)
	{
		for(int fi = 0; fi < 3; ++fi)
			for(int se = 0; se < 3; ++se)
			{
				int mask = fi * 3 + se;
				if((fi == se) != (a[0][i - 1] == a[1][i - 1]))
					continue;
				if(i == 1)
				{
					(dp[i][mask] += dp[i - 1][0]) %= mod;
					continue;
				}
				for(int x = 0; x < 3; ++x)
				{
				    if((fi == x) != (a[0][i - 1] == a[0][i - 2]))
				    	continue;
					for(int y = 0; y < 3; ++y)
					{
						if((se == y) != (a[1][i - 1] == a[1][i - 2]))
							continue;
						int wmask = 3 * x + y;
						(dp[i][mask] += dp[i - 1][wmask]) %= mod;
					}
				}
			}
	}
	for(int x = 0; x < 3; ++x)	
		for(int y = 0; y < 3; ++y)
		{
			(ans += dp[n][x * 3 + y]) %= mod;
		}
	cout << ans;
	return 0;
}
               

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
string s="pphbhhphph";
int main()
{
	int n;cin>>n;
	cout<<s[n%10]<<"on"<<endl;
}


Measured memory_bytes: 3624
import numpy as np


N,K = map(int,input().split())
pn = list(map(int, input().split()))
sumn = list(map(lambda x:x*(x+1)/2/x ,pn))

ans = []
k_sum = sum(sumn[:K])
ans.append(k_sum)
for k in range(1,len(sumn)-K+1):
  k_sum -= sumn[k-1]
  k_sum += sumn[k+K-1]
  ans.append(k_sum)
print(max(ans))

Measured memory_bytes: 33840
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
class UnionFind {
  vector<int> p;
public:
  UnionFind (int n) : p(n, -1) {}
  int root(int x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    return true;
  }
};
int main(void)
{
  LL n,m;
  cin >> n >> m;
  vector<LL> v(n);
 
  UnionFind uf = UnionFind(n*2);
  REP(i,m) {
    int x,y;
    cin >> x >> y;
    --x; --y;
    uf.unite(x,y+n);
    uf.unite(x+n,y);
  }
  LL answer;
  if(uf.same(0,n)) answer = n*(n-1)/2-m;
  else {
    LL l,r;
    REP(i,n) uf.same(0,i) ? ++l : ++r;
    answer = l*r-m;
  }
 
  cout << answer << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	int n; cin >> n;
	vector <ll> vec;
	for (int i = 0; i < n; i++) {
		ll x; cin >> x;
		vec.push_back(x);
	}

	ll ans = 0;
	sort(vec.begin(), vec.end());
	for (auto it = vec.begin(); it != vec.end(); it++) {
		for (auto jt = vec.begin(); jt != it; jt++) {
			auto kt = upper_bound(vec.begin(), jt, *it - *jt);
			ans += (jt - kt);
		}
	}

	cout << ans << endl;
 }

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

using namespace std;
typedef long long ll;

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

  ll n;
  cin >> n;
  ll c = 1, sum = 0;
  while(n > 0){
    sum+=c;
    c*=2;
    n/=2;
  }
  cout << sum;

}


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

int main(){
	int arr[5];
  	cin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>arr[4];
  	for(int i=0;i<5;i++){
    	if(arr[i] == 0)	cout<<i+1;
    }
  return 0;
}

Measured memory_bytes: 3640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);
    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int N = 1e5 + 10;
struct Edge { int v, next;} edge[N * 4];
bool vis[N];
int n, m, cnt, head[N];
inline void add(int u, int v) {
    edge[++cnt].v = v; edge[cnt].next = head[u]; head[u] = cnt++;
    edge[++cnt].v = u; edge[cnt].next = head[v]; head[v] = cnt++;
}
void dfs(int u) {
    vis[u] = 1;
    for (int i = head[u]; i; i = edge[i].next) {
        int v = edge[i].v;
        if (!vis[v]) dfs(v);
    }
}

int main() {
    n = read(), m = read();
    for (int i = 0; i < m; i++) {
        int a = read(), b = read(); int c = read();
        add(a, b);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            ans++;
            dfs(i);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using large = long long;

int main() {
    int n;
    cin >> n;
    auto add = vector<large>(n + 1);
    auto sub = vector<large>(n + 1);
    for (auto i = 1LL; i <= n; i++) {
        large a;
        cin >> a;
        add[i] = a + i;
        sub[i] = a - i;
    }

    auto subcounter = map<large, large>();
    for (auto i = 1; i <= n; i++) {
        subcounter[sub[i]]++;
    }

    auto cnt = 0LL;
    for (auto i = 1; i <= n; i++) {
        subcounter[sub[i]]--;
        auto itr = subcounter.find(-add[i]);
        if (itr != subcounter.end()) {
            cnt += itr->second;
        }
    }

    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 17908
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 1e5 + 10; 
int rec[3*N];
void area(ll n, ll m, ll &ans)
{
    ll w = m>>1;
    for (int i = 1; i < n; i++)
    {
        ll x = m;
        ll y = m - w;
        ll z = i;
        ll mx = max(x*(n-i), max(y*z, z*w));
        ll mi = min(x*(n-i), min(y*z, z*w));
        ans = min(ans, mx - mi);
        
    }
}
void area2(ll n, ll m, ll &ans)
{
    for (int i = 1; i < n; i++)
    {
        ll h = i;
        ll w1 = (n - h)/2;
        ll w2 = n - h - w1;
        ll mx = max(h, max(w1, w2));
        ll mi = min(h, min(w1, w2));
        ans = min(ans, (mx-mi)*m);
    }
}
int main()  
{  
 //  freopen("in.txt", "r", stdin);
   ll n, m;
   while (cin >> n >> m)
   {
       ll t = n * m;
       if (t % 3 == 0)
       {
            puts("0");
            continue;
       }

       ll ans = 1LL<<60;
       area(n, m, ans);
       area(m, n, ans);
       area2(n, m, ans);
       area2(m, n, ans);
       cout<<ans<<endl;
   }
   return 0;  
}  

Measured memory_bytes: 256
# Aizu Problem 0196: Baseball Championship
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")



while True:
    n = int(input())
    if n == 0:
        break
    teams = []
    for i in range(n):
        rec = input().split()
        name = rec[0]
        rec = [int(_) for _ in rec[1:]]
        wins = rec.count(0)
        losses = rec.count(1)
        draws = rec.count(2)
        teams.append((i, name, wins, draws, losses))
    teams = sorted(teams, key=lambda x: (-x[2], x[4], x[0]))
    for team in teams:
        print(team[1])

Measured memory_bytes: 7696