akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;

/**
 * @author Lin
 * @version 1.0
 * @date 2020/8/5 15:43
 */
public class Main
{

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext())
		{
			long n = scanner.nextLong();
			long m = scanner.nextLong();

			long gcd = gcd(Math.max(n, m), Math.min(m, n));
			long lcm = n * (m / gcd);
			System.out.println(gcd + " " + lcm);
		}
	}

	private static long gcd(long n, long m)
	{
		if (n%m == 0)
		{
			return m;
		}
		return gcd(m, n % m);
	}

	static class Reader {
		static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		static StringTokenizer tokenizer = new StringTokenizer("");
		static String nextLine() throws IOException
		{// 读取下一行字符串
			return reader.readLine();
		}
		static String next() throws IOException {// 读取下一个字符串
			while (!tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {// 读取下一个int型数值
			return Integer.parseInt(next());
		}
		static long nextLong() throws IOException {// 读取下一个int型数值
			return Long.parseLong(next());
		}
		static double nextDouble() throws IOException {// 读取下一个double型数值
			return Double.parseDouble(next());
		}
	}
}



Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    ll N; cin >> N;
    cout << N * (N - 1) / 2 << "\n";
}

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

const int INF=1<<30;
int dp[101][10001]={};

int main() {
	int n,W;cin>>n>>W;
	int v[100],w[100];
	for(int i=0;i<n;i++)cin>>v[i]>>w[i];
	int maxv=0;
	for(int i=0;i<n;i++)maxv=max(maxv,v[i]);
	for(int i=1;i<=100*n;i++)dp[0][i]=INF;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=n*maxv;j++)
		{
			if(j<v[i])
			{
				dp[i+1][j]=dp[i][j];
			}
			else
			{
				dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
			}
		}
	}
	int res=0;
	for(int i=0;i<=n*maxv;i++)if(dp[n][i]<=W)res=i;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 6992
#include <iostream>
using namespace std;
int main(){
    int n, b,f,r,v;
    int A[4][3][10] = {0};
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> b >> f >> r >> v;
        A[b - 1][f - 1][r - 1] += v;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << A[i][j][k];
            }
            cout << endl;
        }
        if(i == 3){
            break;
        }
        cout << "####################" << endl;
    }
    return 0;
}


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

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

    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)




const long long table_size = 200005;
long long fact[table_size], finv[table_size], inv[table_size];

void make_table(long long mod) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < table_size; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long nCr(long long n, long long r, long long mod){
    return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}

int main() {
    ll n, m;
    cin >> n >> m;
    
    vector<ll> cnt;
    ll t = m;
    for(ll i = 2; i <= ceil(sqrt(t)); i++){
        if(t % i == 0){
            ll c = 0;
            while(t % i == 0){
                c++;
                t /= i;
            }
            cnt.push_back(c);
        }
    }
    if(t != 1){
        cnt.push_back(1);
    }
    
    make_table(MOD);
    
    ll ans = 1;
    REP(i, cnt.size()){
        ans *= nCr(cnt[i] + n - 1, cnt[i], MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}



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

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> s(h);
  rep(i,h)cin>>s[i];
  int ans=0;
  
  rep(is,1<<h)rep(js,1<<w){
    int cnt=0;
    rep(i,h)rep(j,w){
    
      if(is>>i&1)continue;
      if(js>>j&1)continue;
      if(s[i][j]=='#')cnt++;
    }
    if(cnt==k)ans++;
  }
  
    
  cout<<ans<<endl;
  return 0;
}


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

int n, a[1<<18], x[1<<18], y[1<<18];

void update(int k, int p) {
    if (p == x[k] or p == y[k]) return;
    if (a[p] > a[x[k]]) y[k] = x[k], x[k] = p;
    else if (a[p] > a[y[k]]) y[k] = p;
}

int main() {
    cin >> n;
    for (int i=0; i<(1<<n); i++) cin >> a[i], x[i] = 1<<n, y[i] = 1<<n;

    x[0] = 0;

    int mx = 0;
    for (int i=1; i<(1<<n); i++) {
        update(i, i);
        for (int j=0; j<n; j++) if ((i>>j)&1) update(i, x[i^(1<<j)]), update(i, y[i^(1<<j)]);
        mx = max(mx, a[x[i]] + a[y[i]]);

        cout << mx << '\n';
    }
}

Measured memory_bytes: 6144
mystr = str(input())
mystrs = mystr.split(' ')
A = int(mystrs[0])
B = int(mystrs[1])
K = int(mystrs[2])
if K <= A:
  ret = "%d %d" % (A - K, B)
else:
  if K - A <= B:
    ret = "0 %d" % (B - (K - A))
  else:
    ret = "0 0"
print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  struct R {
    int h, w;
    bool operator<(const R& r) const {
      return make_pair(h * h + w * w, h) < make_pair(r.h * r.h + r.w * r.w, r.h);
    }
  };
  set<R> se;
  for (int h = 1; h <= 150; ++h) for (int w = h + 1; w <= 150; ++w) {
    se.emplace(R{h, w});
  }
  while (true) {
    int h, w; cin >> h >> w;
    if (!h) break;
    R r = *se.upper_bound({h, w});
    cout << r.h << ' ' << r.w << '\n';
  }
}


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

int main(void){
	string str, ope, p, str_rev;
	int q, a, b;
	cin >>str >>q;
	for(int i=0; i<q; i++){
		cin >>ope >>a >>b;
		if(ope=="replace"){
			cin >>p;
			str.replace(a, p.size(), p);
		}else if(ope=="reverse"){
			str_rev=str.substr(a, b-a+1);
			reverse(str_rev.begin(), str_rev.end());
			str.replace(a, str_rev.size(), str_rev);
		}else{
			cout <<str.substr(a, b-a+1) <<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1224
x = int(input())

if 400 <= x <= 599:
    print(8)
if 600 <= x <= 799:
    print(7)
if 800 <= x <= 999:
    print(6)
if 1000 <= x <= 1199:
    print(5)
if 1200 <= x <= 1399:
    print(4)
if 1400 <= x <= 1599:
    print(3)
if 1600 <= x <= 1799:
    print(2)
if 1800 <= x <= 1999:
    print(1)




Measured memory_bytes: 61636
main :: IO()
main = do
    str <- getLine
    putStrLn $ if (getsolve str) then "Yes" else "No"
    
getsolve :: String -> Bool
getsolve str
    | str!!0 == str!!1 && str!!1 == str!!2      = True
    | str!!2 == str!!3 && str!!1 == str!!2      = True
    | otherwise                                 = False

Measured memory_bytes: 380
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;


int main(){
    int N;
    cin >> N;
    if (N % 2 == 0){
        cout << N << endl;
    } else {
        cout << N * 2 << endl;
    }
}

Measured memory_bytes: 256
import sys
import collections
import copy
import math
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
S= input()
K =int(input())
count = 1
ans_list = []
ans = 0
if len(S) ==1:
    print(len(S)*K//2)
else:
    if S [0] != S[-1]:
        for i in range(len(S)-1):
            if S[i] == S[i+1]:
                count += 1
            else:
                if count ==1:
                    continue
                else:
                    ans_list.append(count)
                    count = 1
        if count !=1:
            ans_list.append(count)
        for j in range(len(ans_list)):
            if ans_list[j]%2 == 1:
                ans += (ans_list[j]-1)//2
            else:
                ans += (ans_list[j])//2
        print(ans*K)
    else:
        a = 0
        while S[a] == S[a+1] :
            a +=1
            if a == len(S)-1:
                break
        a += 1
        b = 0
        while S[-1-b] == S[-2-b]:
            b += 1
            if b == len(S)-1:
                break
        b += 1
        if a != len(S):
            S_alt = S[a:len(S)-b]
            for i in range(len(S_alt)-1):
                if S_alt[i] == S_alt[i+1]:
                    count += 1
                else:
                    if count ==1:
                        continue
                    else:
                        ans_list.append(count)
                        count = 1
            if count !=1:
                ans_list.append(count)
            for j in range(len(ans_list)):
                if ans_list[j]%2 == 1:
                    ans += (ans_list[j]-1)//2
                else:
                    ans += (ans_list[j])//2
            ans = (ans * K)
            ans += a//2 + b//2
            ans += (a+b)//2*(K-1)
            print(ans)
        else:
            ans += len(S)*K//2
            print(ans)


Measured memory_bytes: 38384
x = int(input())

# x = 149696127901
def calculate(x):

    if x <= 6:
        return 1

    a = x // 11
    mod = x % 11

    if mod == 0:
        return 2*a

    if mod >= 7:
        return 2*a + 2

    return 2*a + 1



res = calculate(x)

print(res)

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

int main() {

  int a, b, i, ans;
  char op;

  while(1){
    cin >> a >> op >> b;
    if(op=='?') break;
    else if(op=='+') ans = a + b;
    else if(op=='-') ans = a - b;
    else if(op=='*') ans = a * b;
    else ans = a / b;
    cout << ans << endl;
   }



}



Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
    int i, a;
    for(i = 1;i <= 10000;i++){
        scanf("%d", &a);
        if(a == 0){
            break;
        }
        else{
            printf("Case %d: %d\n", i, a);
        }
    }
    return 0;
}


Measured memory_bytes: 1988
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s = chomp(readline())
    n = length(s)
    s1 = s[1:div(n,2)]
    s2 = s[div(n,2)+2:end]
    if s == reverse(s) && s1 == reverse(s1) && s2 == reverse(s2)
        println("Yes")
    else
        println("No")
    end
end

main()

Measured memory_bytes: 110344
n=int(input())
a=list(map(int,input().split()))
ans=0
x=0
for i in range(1,n):
  if a[i]<=a[i-1]:
    x+=1
  else:
    ans=max(ans,x)
    x=0
else:
  ans=max(ans,x)
print(ans)

Measured memory_bytes: 14224
def max2(x,y):
    return x if x > y else y

def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

N = int(input())
data = [[] for _ in range(N)]
res = 0
for i in range(N):
    for _ in range(int(input())):
        data[i].append(tuple(map(int, input().split())))
for n in range(1 << N):
    flg = False
    for i in range(N):
        for x, y in data[i]:
            x -= 1
            if (n>>i)&1 == 1:
                if (n>>x)&1 != y:
                    flg = True
                    break
        if flg:
            break
        if i == N-1:
            res = max2(res, popcnt(n))
print(res)


Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

int main()
{
    string s[3];

    cin >> s[0] >> s[1] >> s[2];

    cout << s[0][0] << s[1][0] << s[2][0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int M[1111111];

int get(int l, int r)
{
	if(l==0) return M[r];
	else return M[r]-M[l-1];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='M') M[i]=1;
		if(i>0) M[i]+=M[i-1];
	}
	int q; cin>>q;
	for(int z=0;z<q;z++)
	{
		int k; cin>>k;
		ll d = 0;
		ll ans = 0;
		ll res = 0;
		for(int i=0;i<n;i++)
		{
			if(i-k>=0&&s[i-k]=='D')
			{
				res -= get(i-k+1,i-1);
				d--;
			}
			if(s[i]=='D') d++;
			if(s[i]=='M') res+=d;
			if(s[i]=='C') ans+=res;
		}
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 5404
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a124(3);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(a%4==0)  a124.at(2)++;
    else if(a%2==0) a124.at(1)++;
    else  a124.at(0)++;
  }

  bool flag=true;
  if(a124.at(0)-1>a124.at(2)) flag=false;
  if(a124.at(1)!=0 && a124.at(0)-1+1>a124.at(2))  flag=false;

  if(flag)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a 
    else :
        a_ = b
        b_ = a % b
        return gcd(a_,b_)

def lcm(a,b):
    return a*b//gcd(a,b)
E = lcm(max(C,D),min(C,D))
#A～BでCで割り切れるものの個数
if A % C == 0 :
    p = B//C - A//C + 1
else :
    p = B//C - A//C
#A~BでDで割り切れるものの個数
if A % D == 0 :
    q =B//D - A//D + 1
else:
    q = B//D - A//D 
#両方で割れるものの個数
if A % E == 0 :
    r = B//E - A//E + 1
else :
    r = B//E - A//E 

ans = B - A + 1 - (p + q - r)
print(ans)


Measured memory_bytes: 3064
c11,c12,c13 = map(int, input().split())
c21,c22,c23 = map(int, input().split())
c31,c32,c33 = map(int, input().split())

if c21-c11!=c22-c12 or c21-c11!=c23-c13 or c31-c11!=c32-c12 or c31-c11!=c33-c13:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in b:
    ans += i
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        ans += c[a[i] - 1]
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;

int main(void){
  int a,l,x;
  for(;scanf("%d%d%d",&a,&l,&x)>0;){
    double h=sqrt(l*l-a*a/4.0);
    double u=sqrt((l+x)*(l+x)-l*l)/2.0;
    printf("%.15f\n",a*h/2+l*u);
  }
}



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

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

  ll N; cin >> N;  
  vector<ll> A(N + 1); for (ll i = 0; i < N + 1; i++) cin >> A[i];
  if (N == 0) {
    if (A[0] == 1) {
      cout << 1 << '\n';
    } else {
      cout << -1 << '\n';
    }
    return 0;
  }

  if (A[0] != 0) {
    cout << -1 << '\n';
    return 0;
  }

  ll ans = 0;
  vector<ll> M(N + 10, 0), C(N + 10, 0);
  ll INF = 1e16;
  M[0] = 2;
  for (ll i = 1; i <= N; i++) {
    if (M[i - 1]>= INF) {
      M[i] = INF;
    } else {
      M[i] = 2 * (M[i - 1] - A[i]);
    }
    if (M[i] < 0) {
      cout << -1 << '\n';
      return 0;
    }
  }

  C[N] = A[N];
  ans = C[N];
  for (ll i = N - 1; i >= 1; i--) {
    C[i] = min(C[i + 1] + A[i], M[i - 1]);
    ans += C[i];
  }
  ans++;

  // cout << A[0]; for (int i = 1; i < A.size(); i++) { cout << ' ' << A[i]; } cout << '\n';
  // cout << C[0]; for (int i = 1; i < C.size(); i++) { cout << ' ' << C[i]; } cout << '\n';
  // cout << M[0]; for (int i = 1; i < M.size(); i++) { cout << ' ' << M[i]; } cout << '\n';
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 5572
#include <stdio.h>

int main(void){
  int N;
  int p[20] = {};
  int i, j, k;
  int max = 0;
  int price = 0;
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%d", &p[i]);
  }
  for(i = 0; i < N; i++){
    if(p[i] > max){
      max = p[i];
    }
  }
  for(i = 0; i < N; i++){
    if(p[i] == max){
      p[i] /= 2;
      break;
    }
  }
  for(i = 0; i < N; i++){
    price += p[i];
  }
  printf("%d\n", price);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx=0;
    for(auto p:mp) mx=max(mx,p.second);
    for(auto p:mp){
        if(p.second==mx) cout << p.first << endl;
    }
}

Measured memory_bytes: 25216
import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.max

fun main() {
    val reader = System.`in`.bufferedReader()
    val writer = PrintWriter(System.out, false)

    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun PrintWriter.solve() {
        var k = nextInt()
        var xmax = k/500
        var ymax = k/5

        var ans = 0
        for (x in 0..xmax){

            var (l,r) = listOf(0,ymax)
            while (l <= r){
                var y = l + (r-l)/2
                var calc = 1000*x + 5*y
                if (calc <= 2*k && 500*x + 5*y <=k ){
                    ans = max(ans,calc)
                    l = y+1
                }
                else r = y-1

            }
        }

        println(ans)

    }

    writer.solve()
    writer.flush()


}




Measured memory_bytes: 52960
void main()
{
    long n = rdElem;
    Coord[] c = n.rdCol!Coord;

    c.sort!((u, v) => u.x == v.x ? u.y > v.y : u.x > v.x);
    long[Coord] lists;
    long cost;
    foreach (i; 0 .. n-1)
    {
        foreach (j; i+1 .. n)
        {
            Coord d = c[i] - c[j];
            ++lists[d];
            cost = max(cost, lists[d]);
        }
    }

    writeln(n - cost);
}

struct Coord
{
    long x, y;

    this(long x, long y)
    {
        this.x = x, this.y = y;
    }

    Coord opBinary(string op)(Coord that)
    if (op == "+")
    {
        return Coord(this.x + that.x, this.y + that.y);
    }

    Coord opBinary(string op)(Coord that)
    if (op == "-")
    {
        return Coord(this.x - that.x, this.y - that.y);
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 380
n = int(input())
b = list(map(int, input().split()))
res = []
for _ in range(n):
    idx = 0
    for i in range(len(b)):
        if b[i] == i + 1:
            idx = i + 1
    if idx == 0:
        print(-1)
        exit()
    res.append(idx)
    b.pop(idx-1)
res = res[::-1]
for i in range(n): print(res[i])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

string s;
ll n;	

//----------------------------------------------------------------
signed main(){

	ll k,s;
	cin >> k >> s;
	ll cnt = 0;
	rep(i,k+1){
		rep(j,k+1){
			ll z = s-i-j;
			if(z >= 0&& z <= k)cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc141.contest.atcoder.jp/tasks/abc141_b

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using vi = vector<int>;

int main() {
	int n, k;
	cin >> n >> k;
	vi a(200000,0);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		a[x]++;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < 200000 - k; i++) {
		ans += a[i];
	}
	cout << ans << endl;

}

Measured memory_bytes: 1024
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline ll gl(){
	ll f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
ll S;
ll x[3],y[3];
void exgcd(int a,int b,int &x,int &y){
	if(!b){x=1;y=0;return;}
	exgcd(b,a%b,y,x);y-=a/b*x;
}
signed main(){
	S=gl();
	int A=1e9,B=ceil((double)S*1./A),C=1,D=1ll*A*B-S;
	printf("0 0 %lld %lld %lld %lld\n",C,B,A,D);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから
using P=pair<int,int>;
int color;
vector<bool>visited;
map<P,int>mp;

void dfs(int v,vector<vector<int>> &g,int c){
  visited[v]=true;
  for(auto e:g[v]){
    if(!visited[e]){
      c++;
      mp[P{min(v,e),max(v,e)}]=c%color;
      dfs(e,g,c%color);
    }
  }
}

void solve(){
  int n;
  cin>>n;
  vector<vector<int>>g(n);
  visited.resize(n);
  vector<int>a(n),b(n);
  rep(i,n-1){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    g[a[i]].pb(b[i]);
    g[b[i]].pb(a[i]);
  }
  color=0;
  int root=0;
  rep(i,n){
    if(chmax(color,(int)g[i].size()))root=i;
  }
  dfs(root,g,0);
  cout<<color<<"\n";
  rep(i,n-1)cout<<mp[P{a[i],b[i]}]+1<<"\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 14976
#include <iostream>

using namespace std;

int main(void){
  int num;
  cin >> num;
  int arr[num];
  for(int id=0; id<num; id++){
    int a;
    cin >> a;
    arr[id] = a;
  }
  for(int id=num-1; id>0; id--){
    cout << arr[id] << " ";
  }
  cout << arr[0] << endl;
  return 0;
}


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

int main()
{
    unsigned long long int x,y,z,sum;
    cin>>x>>y>>z;
    if(x%z==0){
        sum = (y/z)-(x/z)+1;
    }
    else sum = (y/z)-(x/z);
    cout<<sum<<endl;

    return 0;
}


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

typedef long long ll;

ll a, b;

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

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

int main() {
    while(scanf("%lld%lld", &a, &b) != EOF) {
        printf("%lld %lld\n", gcd(a, b), lcm(a, b));
    }
    return 0;
}


Measured memory_bytes: 3116
/*
THINGS TO DO
1) Check integer overflows
2) Check corner cases
3) Compile and run once on terminal
4) Code smart, not quick
*/

#ifndef ONLINE_JUDGE
	#define _GLIBCXX_DEBUG
	#include "debug.cpp"
#endif

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

int MAX = 21;

void update(vector<int> &segtree, int ind, int val){
	ind += segtree.size()/2;
	segtree[ind] = val;
	while(ind != 1){
		segtree[ind/2] = max(segtree[ind], segtree[ind/2]);
		ind /= 2;
	}
}

int query(vector<int> &segtree, int l, int r, int x, int y, int ind){
	if(r < x || l > y){
		return -1;
	}
	if(x >= l && y <= r){
		return segtree[ind];
	}

	int mid = (x+y)/2;
	int a = query(segtree, l, r, x, mid, 2*ind);
	int b = query(segtree, l, r, mid+1, y, 2*ind+1);
	return max(a, b);
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k, i;
	cin >> n >> k;
	int arr[n];
	for(i=0; i<n; i++)
		cin >> arr[i];

	vector<int> segtree(1<<MAX);

	int ans[n] = {0};
	ans[0] = 1;

	update(segtree, arr[0], 1);
	// print(segtree);
	int res = 1;
	for(i=1; i<n; i++){
		ans[i] = 1+query(segtree, max(0, arr[i]-k), arr[i]+k, 0, (1<<(MAX-1))-1, 1);
		if(ans[i] > segtree[arr[i]+segtree.size()/2]){
			update(segtree, arr[i], ans[i]);
		}
		// print(segtree);
		res = max(res, ans[i]);
	}

	// print(ans, n);
	cout << res << "\n";
}

//Read the stuff at the top

Measured memory_bytes: 13744
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;
vector<int> adj[100010];

void dfs(int i, vector<int> & vis){
	vis[i] = true;
	for(int ch: adj[i]){
		if(!vis[ch]){
			dfs(ch, vis);
		}
	}
}
int main(){
//freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	int m;
	cin >> m;
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int ans = 0;
	vector<int> vis(n+1,0);
	for(int i = 1; i <= n; i++){
		if(!vis[i]){
			dfs(i, vis);
			ans++;
		}
	}
	cout << ans-1 << endl;
}

Measured memory_bytes: 9608
#include <stdio.h>

int main() {

  int m, f, r;
  int x;
  while(1) {

    scanf("%d %d %d", &m , &f , &r);
    x = m + f;
    if(m == -1 && f ==-1 && r == -1) {
      break;
    }

    if(m == -1 || f == -1) {
      printf("F\n");
    } else if(x >= 80) {
      printf("A\n");
    } else if (x >= 65) {
      printf("B\n");
    } else if(x >= 50) {
      printf("C\n");
    } else if ( x >=30) {
      if(r >= 50) {
	printf("C\n");
      } else {
	printf("D\n");
      }
    } else if (x < 30) {
      printf("F\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2068
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
int main()
{
	ll H, N;
	ll A[100000];
	scanf("%lld %lld", &H, &N);
	
	for(int i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	
	ll sum = 0;
	for(int i = 0; i < N; i++){
		sum += A[i];
	}
	
	if(sum >= H){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

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

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

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
    {
        if((int)(i * 1.08) == N)
        {
            cout << i << "\n";
            return 0;
        }
    }

    cout << ":(\n";
    return 0;
}


Measured memory_bytes: 256
a = list(input())
l = len(a)
alphcnt = [0] * 26
for i in a:
    alphcnt[ord(i) - 97] += 1
ans = (l * (l + 1)) // 2 + 1
for i in alphcnt:
    ans -= (i * (i + 1)) // 2
print(ans)

Measured memory_bytes: 4840
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    out.println(lcm(in.nextLong(), in.nextLong()));

    out.close();
  }

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

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

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }

  public static int[][] lexSort(int[][] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[][] left = new int[mid][2];
    int[][] right = new int[a.length - mid][2];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return lexMerge(lexSort(left), lexSort(right));
  }

  public static int[][] lexMerge (int[][] l, int[][] r) {
    int[][] merged = new int[l.length + r.length][2];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i][0] < r[j][0] || l[i][0] == r[j][0] && l[i][1] <= r[j][1])
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }
}



Measured memory_bytes: 21076
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n,a,b,in=0,out=0;
	string s;
	cin>>n>>a>>b>>s;
	rep(i,s.size()){
		if(s[i]=='a'){
			if(in+out<(a+b)){
				cout<<"Yes"<<endl;
				in++;
			}else{
				cout<<"No"<<endl;
			}
		}else if(s[i]=='b'){
			if(in+out<(a+b) && out+1<=b){
				cout<<"Yes"<<endl;
				out++;
			}else{
				cout<<"No"<<endl;
			}
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
//AnkitCode99 (DP)....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;

using namespace std;

const ll sz=1e5+5;
ll n;
double cache[305][305][305];
bool state[305][305][305];

double dp(ll a,ll b,ll c)
{
    if(a<0 or b<0 or c<0)
        return 0;
    if(a==0 and b==0 and c==0)
        return 0;

    double &ans=cache[a][b][c];
    if(state[a][b][c])
        return ans;

    state[a][b][c]=1;
    ans=(n+a*dp(a-1,b,c)+b*dp(a+1,b-1,c)+c*dp(a,b+1,c-1))/(a+b+c);

    return ans;
}

int main()
{
    fast;
    

    clock_t startTime=clock();

    cin>>n;
    ll a=0,b=0,c=0;
    for(ll i=0;i<n;i++)
    {
        ll ele;
        cin>>ele;
        if(ele==1)
            a++;
        else if(ele==2)
            b++;
        else
            c++;
    }

    cout.precision(12);
    cout<<fixed<<dp(a,b,c);
    // a,b,c denotes the number of plates with a,b & c sushi's repectively
    // cout << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 246016
n=int(input())
a=list(map(int, input().split()))
tmp = 0

for i in range(n):
    if a[i] % 2 == 0 and (a[i] % 3 != 0 and a[i] % 5 != 0):
        print('DENIED')
        tmp = 1
        break

if tmp == 0:
    print('APPROVED')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[200000];
    cin >> N;
    REP(i, N) cin >> A[i];
    sort(A, A + N);
    reverse(A, A + N);

    ll ans = 0;
    REP(i, N - 1) ans += A[(i + 1) / 2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4388
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
const lnt INF = 0xffffffffffff;
lnt n,m,x,y,z,s;
lnt dl[200][200];
lnt ds[200][200];
lnt vis[1000];
lnt ans[200][1000];
char str[10];
int main()
{while(1){
	cin>>n>>m;
	if(!n&&!m) return 0;
	//for(int i=0;i<200;i++) {
	//	for(int j=0;j<1000;j++) {
	//		if(j<200){
	//			dl[i][j]=INF;
	//			ds[i][j]=INF;
	//		}
	//		ans[i][j]=INF;
	//	}
	//}
	fill(dl[0],dl[200],INF);
	fill(ds[0],ds[200],INF);
	fill(ans[0],ans[200],INF);
	for(int i=0;i<n;i++) dl[i][i]=ds[i][i]=0;
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld%s",&x,&y,&z,str);
		x--; y--;
		if(*str=='L') dl[x][y]=dl[y][x]=z;
		else ds[x][y]=ds[y][x]=z;
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dl[i][j]=min(dl[i][j],dl[i][k]+dl[k][j]);
				ds[i][j]=min(ds[i][j],ds[i][k]+ds[k][j]);
			}
		}
	}
	cin>>s;
	for(lnt i=0;i<s;i++){
		cin>>vis[i];
		vis[i]--;
	}
	ans[vis[0]][0]=0;
	for(int i=1;i<s;i++){
		if(i==1){
			for(int j=0;j<n;j++){
				ans[j][1]=ds[vis[0]][j]+dl[j][vis[1]];
			}
		}
		else{
			for(int j=0;j<n;j++){//vis[i-1]????????????j????????????k ?????? vis[i]
				for(int k=0;k<n;k++){
					if(j==k) ans[k][i]=min(ans[k][i],ans[j][i-1]+dl[vis[i-1]][vis[i]]);
					else ans[k][i]=min(ans[k][i],ans[j][i-1]+dl[vis[i-1]][j]+ds[j][k]+dl[k][vis[i]]);
				}
			}
		}
	}
	lnt res=INF;
	for(int i=0;i<n;i++) res=min(res,ans[i][s-1]);
	cout<<res<<endl;
}}

Measured memory_bytes: 3440
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(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)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int main()
{
	int a,b,c;cin>>a>>b>>c;
	if(a+b>=c)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 pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s1, s2, ans1, ans2;
    cin >> s1 >> s2;
    map<char, int> mp1;
    map<char, int, greater<char> > mp2;
    for (int i = 0; i < s1.size(); i++) ++mp1[s1[i]];
    for (int i = 0; i < s2.size(); i++) ++mp2[s2[i]];
    for (auto it = mp1.begin(); it != mp1.end(); it++){
        for (int j = 0; j < it->second; j++) ans1 += it->first;
    }
    for (auto it = mp2.begin(); it != mp2.end(); it++){
        for (int j = 0; j < it->second; j++) ans2 += it->first;
    }
    if (ans1 < ans2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<iostream>
using namespace std;
typedef long long LL;
int cs(LL n)
{
	int s=0;
	while(n>0){
		s+=n%10;
		n/=10;
	}
	return s;
}
int main(){
	LL n,temp,cnt=1;
	cin>>n;
	int ans=cs(n);
	temp=n;
	while(temp>=10)
	{
		temp/=10,cnt*=10;
	}
	ans=max(ans,cs(n/cnt*cnt - 1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
M,N = map(int,input().split())
K = int(input())
maze = []
for _ in range(M): 
  maze.append(list(input()))

J = [ [0]*(N+1) for _ in range(M+1) ] 
O = [ [0]*(N+1) for _ in range(M+1) ]
I = [ [0]*(N+1) for _ in range(M+1) ]

for i in range(M):
  for j in range(N):
    if maze[i][j] == "J":
      J[i+1][j+1] = 1
    elif maze[i][j] == "O":
      O[i+1][j+1] = 1
    else:
      I[i+1][j+1] = 1

for i in range(1,M+1):
  for j in range(1,N+1):
    J[i][j] += J[i-1][j]-J[i-1][j-1]+J[i][j-1]
    O[i][j] += O[i-1][j]-O[i-1][j-1]+O[i][j-1]
    I[i][j] += I[i-1][j]-I[i-1][j-1]+I[i][j-1]

for _ in range(K):
  x1,y1,x2,y2 = map(int,input().split())
  j = J[x2][y2]-J[x1-1][y2]-J[x2][y1-1]+J[x1-1][y1-1]
  o = O[x2][y2]-O[x1-1][y2]-O[x2][y1-1]+O[x1-1][y1-1]
  i = I[x2][y2]-I[x1-1][y2]-I[x2][y1-1]+I[x1-1][y1-1]
  print(j,o,i)



Measured memory_bytes: 131668
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x){
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer()
		: m_value(0)
	{ }
	modulus_integer(int x)
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const { return m_value; }
	self_type& operator=(const self_type& x){
		m_value = x.m_value;
		return *this;
	}
	self_type operator*(const self_type& x) const {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type& operator*=(const self_type& x){
		return (*this = *this * x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
namespace loquat {
template <typename T>
std::vector<int> eratosthenes(T& sieve){
	const int n = sieve.size();
	for(int i = 0; i < n; ++i){ sieve[i] = true; }
	if(n >= 1){ sieve[0] = false; }
	if(n >= 2){ sieve[1] = false; }
	std::vector<int> primes;
	for(int i = 2; i < n; ++i){
		if(!sieve[i]){ continue; }
		primes.push_back(i);
		for(int j = i + i; j < n; j += i){ sieve[j] = false; }
	}
	return primes;
}
std::vector<int> eratosthenes(size_t n){
	std::vector<bool> sieve(n);
	return eratosthenes(sieve);
}
}
using namespace std;
using mint = loquat::modulus_integer<1000000007>;
int main(){
	ios_base::sync_with_stdio(false);
	const auto primes = loquat::eratosthenes(1000);
	int n;
	cin >> n;
	const int m = primes.size();
	vector<int> counts(m);
	for(int i = 2; i <= n; ++i){
		for(int j = 0; j < m; ++j){
			const int p = primes[j];
			int x = i;
			while(x % p == 0){
				x /= p;
				++counts[j];
			}
		}
	}
	mint answer = 1;
	for(int i = 0; i < m; ++i){
		answer *= mint(counts[i] + 1);
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
nissuu = [0] * 26
key = ""
for k in range(26):
  nissuu = [0] * 26
  ans = 0  
  for i in range(D):
    t = (i+k) % 26 + 1
    for j in range(26):
        if j == t-1:
            nissuu[j] = 0
        else:
            nissuu[j] += 1
        ans -= c[j]*nissuu[j]
    ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(365):
    print((i+key) % 26 + 1)

Measured memory_bytes: 9488
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	Int a, b,c; cin >> a >>b;
	if (a - b > 0)cout << a - b;
	else cout << 0;
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define pll pair < ll, ll >
using namespace std;

ll cnt[maxn];
pll an[maxn];
ll total;

int main()
{
    ll n;

    cin >> n;

    ll a[n + 5], b[n + 5];

    for(ll i = 0; i < n; i++) cin >> a[i], b[i] = a[i], cnt[a[i]]++;

    sort(a, a + n);

    for(ll i = 0; i < n; i++){
        ll fi = cnt[a[i]];
        ll se = fi - 1;
        ll fis = (fi * (fi - 1)) / 2;
        ll ses = (se * (se - 1)) / 2;
        an[a[i]] = {fis, ses};
    }

    for(ll i = 1; i <= a[n - 1]; i++) total += an[i].first;

    for(ll i = 0; i < n; i++){
        cout << total - an[b[i]].first + an[b[i]].second << endl;
    }

    return 0;
}


Measured memory_bytes: 9472
N, M = map(int, input().split())
P = [False] * (N+1)
P[1] = True
C = [1] * (N+1)
for i in range(M):
    x, y = map(int, input().split())
    C[x] -= 1
    C[y] += 1
    if P[x]:
        P[y] = True
    if C[x] == 0:
        P[x] = False
print(P.count(True))


Measured memory_bytes: 4596