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

int main(void){
    int d,n,i;
    cin >> d >> n;

    if(d == 0){
        if(n <= 99){
            cout << n << endl;
        }
        if(n == 100){
            cout << 101 << endl;
        }
    }

    if(d == 1){
        if(n <= 99){
            cout << n*100 << endl;
        }
        if(n == 100){
            cout << 101*100 << endl;
        }
    }

    if(d == 2){
        if(n <= 99){
            cout << n*10000 << endl;
        }
        if(n == 100){
            cout << 101*10000 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int check (int x, int n, int p[n]){
		int i;
		
		for (i = 0; i < n; i++){
				if(x == p[i]){
						return 1;
				}
		}
		return 0;
}
int main (){
	int x, n;
    int i;
	  
	if (scanf("%d", &x) == 1){};
	if (scanf("%d", &n) == 1){};
	  	
	if (n == 0){
	  	printf("%d", x);
	  	return 0;
	}
	  
	int p[n];
	for (i = 0; i < n; i++){
	  	if (scanf("%d", &p[i]) == 1){};
	}
	  
	for (i = 0; i < 100; i++){
	  	if (check(x - i, n, p) == 0){
  			printf("%d", x - i);
	  		return 0;
	  	}	
	    if (check(x + i, n, p) == 0){
	  		printf("%d", x + i);
	  		return 0;
	  	}	
	}
	return 0; 
}

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

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		int r = cin.nextInt();
		int g = cin.nextInt();
		int b = cin.nextInt();
		if ((r * 100 + g * 10 + b) % 4 == 0)
			cout.println("YES");
		else
			cout.println("NO");
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			return st.nextToken();
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

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

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define abdelrahman001 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define inFile(t) freopen((t),"r",stdin)
#define outFile(t) freopen((t),"w",stdout)
#define pb push_back
#define pf push_front
#define Pb pop_back
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define Pf pop_front
#define sz size
#define MP make_pair
#define Pc __builtin_popcount
#define pi 2*acos(0)
#define BiEdge(v,a,b) (v)[(a)].pb(b),(v)[(b)].pb((a))
#define mod 1000000007
#define point complex<ld>
#define X real()
#define Y imag()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define cross(a,b)(conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define rectangle pair<coordinate,coordinate>
#define line tuple<ll,ll,ll>
#define EPS 1e-7
#define polygon vector<point>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int const N = 2*1e5+5,M = 105;

using namespace std;
ll fact(ll n)
{
	ll ans = 1;
	for(int i = 2;i<=n;i++)
		ans = (ans*i)%mod;
	return ans;
}
int main()
{
	abdelrahman001
	ll n,m,sum = 1;
	cin >> n >> m;
	if(abs(n-m)>1)
		return cout << 0,0;
	cout << ((((sum+(n == m)) * fact(n))%mod)*fact(m))%mod;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
         
        public class Main { //クラス名はMain
            public static void main(String[] args) {
                //コード
              Scanner sc = new Scanner(System.in);
              int n1 = sc.nextInt();
              String wordw = sc.nextLine();
              int cut1 = n1 / 2;
              String word = sc.nextLine();
              String wordc1 = word.substring(0, cut1);
              String wordc2 = word.substring(cut1, n1);
              
              //処理打ち切り
              if (n1 <= 1) {
            System.out.println("No");
            return;
          } 
              //判定
              if (wordc1.equals(wordc2)) {
                	//等しいとき
                System.out.println("Yes");
           	}
          	else {
              		//等しくないとき
            		System.out.println("No");;
         		}
          }
        }

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

int main() {
    int n{}, m{};
    std::cin >> n >> m;
    std::vector<int> l(m);
    std::vector<int> r(m);
    for (int i = 0; i < m; i++) {
        std::cin >> l[i] >> r[i];
    }
    const auto minR = *std::min_element(r.begin(), r.end());
    const auto maxL = *std::max_element(l.begin(), l.end());
    std::cout << std::max(0, minR - maxL + 1);
    return 0;
}

Measured memory_bytes: 4020
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var count = 0;
            foreach (var c in consoleReader.String)
            {
                switch (c)
                {
                    case '+':
                        count++;
                        break;
                    case '-':
                        count--;
                        break;
                }
            }
            return count;
        }


        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 11092
h, w, d = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(h)]

inf = 1 << 30

pos = [(0, 0)] * (h * w + 1)
dist = [inf] * (h * w + 1)

for i in range(h):
    for j in range(w):
        pos[a[i][j]] = (i, j)

for i in range(1, h * w):
    if dist[i] == inf:
        dist[i] = 0
        j = i + d
        while j <= h * w:
            dist[j] = dist[j - d] + abs(pos[j][0] - pos[j - d][0]) + \
                abs(pos[j][1] - pos[j - d][1])
            j += d


q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(dist[r] - dist[l])


Measured memory_bytes: 22892
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int n;
ll x[51],y[51];
map<P,int> mp;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&x[i],&y[i]);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			//printf("%d %d %lld %lld\n",i,j,x[i]-x[j],y[i]-y[j]);
			mp[P(x[i]-x[j],y[i]-y[j])]++;
			ans=max(ans,mp[P(x[i]-x[j],y[i]-y[j])]);
			if(x[i]==x[j] && y[i]==y[j])continue;
			mp[P(x[j]-x[i],y[j]-y[i])]++;
			ans=max(ans,mp[P(x[j]-x[i],y[j]-y[i])]);
		}
	}
	printf("%d\n",n-ans);
	return 0;
}


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

int N, M;
int a[28], b[28];

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i];
  int array[N-1];
  int ans = 0;
  for (int i = 0; i < N-1; i++) array[i] = i + 2;
  do {
    int p, q;
    bool ikeru;
    for (int i = 0; i < N-1; i++) {
      if (i == 0) p = 1;
      q = array[i];
      ikeru = false;
      for (int j = 0; j < M; j++)
        if ((p == a[j] && q == b[j]) || (q == a[j] && p == b[j])) ikeru = true;
      if (!ikeru) break;
      p = q;
    }
    if (ikeru) ans++;    
  } while (next_permutation(array, array + N - 1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
lights=[list(map(lambda x: int(x)-1, input().split()))[1:] for i in range(M)]
p=list(map(int,input().split()))
ans=0

for i in range(1<<N):
  for m in range(M):
    on_sum=0
    for j in range(N):
      if i>>j &1 and j in lights[m]:
        on_sum+=1
    if on_sum%2!=p[m]:
      break
  else:
    ans+=1
print(ans)

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

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    int x;
    for (int i = 0; i < N; ++i) {
        cin >> x;
        ans += min(x, K - x) * 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long int mod=1e9;
	long long int n,i,l=1;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		l=l*i;
		l=l%(mod+7);
	}
	cout<<l<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 998244353  # type: int

def baai(n1, n2):
    return(n1**n2%MOD)

def solve(N: int, D: "List[int]"):
    cn=[0]*(N + 1)
    for i in range(N):
        cn[D[i]]+=1

    if D[0]!=0:
        print(0)
    else:
        answer=1
        bak=cn[0]
        kyo=1
        hen=1
        while True:
            cnt=cn[kyo]
            hen+=cnt
            if cnt==0:
                break
            answer=answer*baai(bak, cnt)%MOD
            bak=cnt
            kyo+=1
        if hen==N:
            print(answer%MOD)
        else:
            print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15220
#include<stdio.h>
int main()
{
    long long int n,i,j,k,l,count;
    while(scanf("%lld",&n)!=EOF){

    for(i=0,count=0;i<=9;i++)
     {for(j=0;j<10;j++)
      {for(k=0;k<10;k++)
         {for(l=0;l<10;l++)
           {
               if(i+j+k+l==n) count++;
           }}}}
           printf("%lld\n",count);}
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int dp[6002][3001];
int n,t;
pint a[3001];
int main(){
    cin>>n>>t;
    rep(i,n) cin>>a[i].first>>a[i].second;
    sort(a,a+n);
    rep(i,6001)rep(j,n){
        if(i<=t-1)dp[i+a[j].first][j+1]=max(dp[i+a[j].first][j+1],dp[i][j]+a[j].second);
        dp[i][j+1]=max(dp[i][j+1],dp[i][j]);
        dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
    int mx=0;
    rep(i,6001)rep(j,n+1)mx=max(mx,dp[i][j]);
    cout<<mx<<endl;
    return 0;
}

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

	if (c - a - b < 0) {
		cout << "No" << endl;
		return 0;
	}

	Int x = a*a + b*b + c*c - 2*a*b - 2*b*c - 2*c*a;
	cout << (x > 0 ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,3*n)cin>>a[i];
    sort(a,a+3*n);
    reverse(a,a+3*n);
    rrep(i,1,3*n){
        ans+=a[i];
        cnt++;
        i++;
        if(cnt==n)break;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 4352
a, b, c, x, y = gets.split.map &:to_i

min = 1000000000
min_ijk = [-1, -1, -1]
(0..2*[x, y].max).each do |k|
  i = [0, x-k/2].max
  j = [0, y-k/2].max
  min = [min, a*i+b*j+c*k].min
end

p min

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep(i, N) cin >> P[i];
    sort(P.begin(), P.end());
    ll ans = accumulate(P.begin(), P.end() - 1, 0LL);
    ans += P.back() / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L = [input() for i in range(2)]

if L[0][0] == L[1][2] and L[0][1] == L[1][1] and L[0][2] == L[1][0]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9672
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

  long n,m,l,*nm,*ml,r,*p;

  scanf("%ld %ld %ld\n",&n,&m,&l);

  nm=(long *)malloc(n*m*sizeof(long));
  ml=(long *)malloc(m*l*sizeof(long));

  p = nm;

  for(int i=0;i<n*m;i++){
          scanf("%ld ",p);
          p++;
  }
  p = ml;

  for(int i=0;i<m*l;i++){
          scanf("%ld ",p);
          p++;
  }

  for(int i=0;i<n;i++){
    r=0;
    for(int k=0;k<l;k++){
      for(int j=0;j<m;j++){
        r += nm[m*i+j] * ml[j*l+k];
      }
      printf("%ld",r);
      r=0;
      if(k<l-1)
      putchar(' ');
    }
  putchar('\n');
  }
}


Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>

using namespace std;
int main()
{
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	if(s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif

	int n,h;
	cin>>n>>h;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}

	int mxa=*max_element(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	int ans=0;
	for(int i=0;i<n and h>0;i++)
	{
		if(b[i]>=mxa)
		{
			h-=b[i];
			ans++;
			if(h<=0){cout<<ans;return 0;}
		}
	}

	ans+=(h+mxa-1)/mxa;
	cout<<ans;





	



	
}

Measured memory_bytes: 4820
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	}
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  for (int a, i = 0; i < n; ++i) {
    scanf("%d", &a);
    if (a%2) {
      printf("first");
      return;
    }
  }
  printf("second");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3872
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]
dp = [float("INF")]*(10)
dp[1] = 0
cnt = 1
while cnt < 10:
    cnt += 1
    for i in range(10):
        for j in range(10):
            dp[i] = min(dp[i],dp[j]+C[i][j])
ans = 0
for i in range(H):
    for j in range(W):
        a = A[i][j]
        if a != -1:
            ans += dp[a]
print(ans)



Measured memory_bytes: 68148
#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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;

int main()
{
  int n;
  cin>>n;
  ll a[n];
  for (int i = 0; i < n;i++){
    cin >> a[i];
  }
  ll cnt = 0;
  for (int i = 0; i < n;i++){
    for (int j= i; j < n;j++){
      for (int h = j; h < n;h++){
if(a[i] != a[j] && a[j]!=a[h] && a[h]!=a[i]){
  if (a[i] + a[j] > a[h] && a[j] + a[h] > a[i] && a[h] + a[i] > a[j] ){
        cnt++;
      }
}
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
long long ans,a,b;
int main(){
	scanf("%lld%lld",&a,&b);
	for(long long i=a;i<=b;i*=2) ans++;
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 325501;
const int MOD = 1e9 + 7;

int a, b;
string s, t;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b;
    if (a == b)
    {
        cout << 1;
        return 0;
    }
    int x = a, y = b;
    for (int i = 0; i < 65; i++)
    {
        s += x % 2 + '0';
        x /= 2;
    }
    for (int i = 0; i < 65; i++)
    {
        t += y % 2 + '0';
        y /= 2;
    }
    reverse(all(s));
    reverse(all(t));
    string p = "";
    for (int i = 0; i < 65; i++)
    {
        if (s[i] == t[i]) p += s[i];
        else
        {
            p += "1";
            break;
        }
    }
    int len = 65 - p.size();

    int deg = 0;
    for (int i = t.size() - len; i < t.size(); i++)
    {
        deg += (t[i] - '0' > 0 || deg > 0);
    }
    int z = 0;
    for (int i = 0; i < p.size(); i++)
    {
        z = 2LL * z + p[i] - '0';
    }
    for (int i = 0; i < len; i++) z *= 2LL;

    int g = 0;
    for (int i = s.size() - len; i < s.size(); i++)
        g = 2 * g + s[i] - '0';



    long long ans = (z - a) + (1LL << deg);
    ans += min((1LL << len) - g, (1LL << len) - (1LL << deg));
    cout << ans << "\n";
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func intAbs(x int) int {
	return int(math.Abs(float64(x)))
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	ans := intAbs(N-2) * intAbs(M-2)
	fmt.Println(ans)
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n,k; cin>>n>>k;
  auto h=make_v(n,(ll)0);
  rep(i,n) cin>>h[i];
  auto dp=make_v(n,INF);
  dp[0]=0;
  rep(i,n){
    rep(j,1,k+1){
      if(i+j<n) chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int local = a + b;
        int nowA = 0;
        int nowB = 0;

        String[] s = sc.next().split("");

        for (int i = 0; i < s.length; i++) {
            switch (s[i]) {
                case "a":
                    if (nowA + nowB < local) {
                        nowA++;
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                    break;
                case "b":
                    if (nowA + nowB < local && nowB < b) {
                        nowB++;
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                    break;
                case "c":
                    System.out.println("No");
                    break;
            }
        }
    }
}

Measured memory_bytes: 47488
#include <bits/stdc++.h>
using namespace std;
int n,m,q,i,x,y,z,ax,bx,r,a[100100],b[100100];
int main() {
  scanf("%d%d%d",&n,&m,&q);
  for (ax=i=1; i<=n; i++) {
    scanf("%d",&a[i]);
    if (a[i]<a[ax]) ax=i;
  }
  for (bx=i=1; i<=m; i++) {
    scanf("%d",&b[i]);
    if (b[i]<b[bx]) bx=i;
  }
  r=a[ax]+b[bx];
  while (q--) {
    scanf("%d%d%d",&x,&y,&z);
    r=min(r,a[x]+b[y]-z);
  }
  printf("%d\n",r);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int b[10000];

int main()
{
  int n;
  ll a[10000];

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    while(a[i] % 2 == 0){
      ans++;
      a[i] /= 2;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll x, a, b;
	cin >> x >> a >> b;
	if(abs(x-a) < abs(x-b)) puts("A");
	else puts("B");

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	map<string,int>a;
	int n;
	cin>>n;
	int mx=0;
	for(int i=1;i<=n;i++){
		string t;
		cin>>t;
		a[t]++;
		mx=max(mx,a[t]);
	}
	for(auto i:a){
		if(i.second==mx){
			cout<<i.first<<'\n';
		}
	}
	return 0;
} 
//力求AC，上帝求你啦~\(≧▽≦)/~

Measured memory_bytes: 25216
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt(); 
    int b = sc.nextInt(); 
    int c = sc.nextInt();
    int d = sc.nextInt();
	System.out.println(Math.min(a, b) + Math.min(c, d));
  }
}


Measured memory_bytes: 21972
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,p[100005],q[100005],b[100005];
ll k,a[100005],s;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%lld",a+i);
    scanf("%d%lld",&m,&k);
    for(int i=n;i>1;--i)p[i]=i,a[i]-=a[i-1];
    while(m--){
        int x;
        scanf("%d",&x);
        swap(p[x],p[x+1]);
    }
    for(int i=2;i<=n;++i){
        if(q[i]) continue;
        int _=1,o=p[i];
        b[0]=i;
        while(o!=i)b[_++]=o,o=p[o];
        o=b[k%_];
        for(int j=i;!q[j];j=p[j])q[j]=o,o=p[o];
    }
    q[1]=1;
    for(int i=1;i<=n;++i){
        s+=a[q[i]];
        printf("%lld\n",s);
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 3200
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll pcol = s[0]=='W' ? 1:0;
  ll cnt = 0;
  for (int i = 1; i < s.size(); ++i) {
    ll ccol = s[i]=='W' ? 1:0;
    if(pcol!=ccol){
      pcol = ccol;
      ++cnt;
    }
  }
  cout << cnt << endl;

  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	string s, t;
	cin >>s >>t;
	for (int i=N; i>=0; i--) {
		if (s.substr(N-i, i)==t.substr(0, i)) {
			cout <<N+N-i <<endl;
			break;
		}
	}
	return 0;
}



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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define F first
#define S second

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    cout << pow(n, 3) << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll a = a1 * t1 - b1 * t1, b = a2 * t2 - b2 * t2;
    b += a;
    if (b == 0) {
        cout << "infinity" << endl;
        return 0;
    }
    if (a < 0 && b < 0) {
        cout << 0 << endl;
    } else if (a > 0 && b > 0) {
        cout << 0 << endl;
    } else {
        if (abs(a) % abs(b) == 0) {
            cout << 2LL * (abs(a) / abs(b)) << endl;
        } else {
            cout << (2LL * (abs(a) / abs(b))) + 1LL << endl;
        }
    }
}

Measured memory_bytes: 256
import sys
from pprint import pprint

def solve(n, p):
    ans = 0
    min_p = p[0]
    for i in range(n):
        if min_p >= p[i]:
            ans += 1
        min_p = min(min_p, p[i])

    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    p = list(map(int,sys.stdin.readline().strip().split(" ")))
    
    solve(n, p)

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    long long int cnt[n] = {0};
    for(int i=0;i<n;++i){
        cin >> a[i];
        cnt[a[i]-1]++;
    }
    long int sum = 0;
    for(int i=0;i<n;++i){
        sum += ((cnt[i]*(cnt[i]-1))/2);
    }
   // cout << a[0] << " " << a[1] << endl;
    for(int i=0;i<n;++i){
        int temp = cnt[a[i]-1];
        cout << sum - temp + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
int prime[1000001];
int main(){
	prime[0]=prime[1]=-1;
	for(int i=2;i<=1000000;i++){
		if(prime[i]!=-1){
			prime[i]=1;
			for(int j=i+i;j<=1000000;j+=i)prime[j]=-1;
		}
	}
	int a;
	while(scanf("%d",&a),a){
		int ret=0;
		for(int i=1;i<=a/2;i++)if(prime[i]==1&&prime[a-i]==1)ret++;
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int[] IntArray = new int[3];
		
		for (int i = 0; i < 3; i++) {
			int a = stdIn.nextInt();
		    IntArray[i] = a;
		}
		
		Arrays.sort(IntArray);
		
		if (IntArray[0] + IntArray[1] == IntArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; ++i) {
    cin >> S[i];
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (S[i][j] != '.') continue;
      int cnt = 0;
      for (int k = -1; k <= 1; k++) {
        if ((i + k < 0) || (H <= i + k))  continue;
        if (0 < j) cnt += (S[i + k][j - 1] == '#');
        cnt += (S[i + k][j] == '#');
        if (j + 1 < W) cnt += (S[i + k][j + 1] == '#');
      } 
      S[i][j] = '0' + cnt;
    }
  }
  for (int i = 0; i < H; ++i) {
    cout << S[i] << endl;
  }
  return 0;
}


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

string S;


int main()
{
	cin >> S;
	string s[] = {"dream","dreamer","erase","eraser"};
	bool f = true; // 更新できたか？
	int end = S.size() -1;
	while(f){
		f = false;
		for(int i=0;i<4;++i){
			int size = s[i].size();
			if(end >= size-1 && S.substr(end-size+1,size)==s[i]){
				f = true;
				end -= size;
			}
		}
	}

	if(end==-1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

struct edge {int from, to, cost;};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

struct UnionFind {
    vector<int> par, rank; //根，木の高さ

    UnionFind(int n) : par(n), rank(n, 1) {
        iota(par.begin(), par.end(), 0);  // 初期では親は自分自身
    }
    void init(int n) {
        iota(par.begin(), par.end(), 0);
        rank.assign(n, 1);
    }

    int root(int x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]); //径路圧縮
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y); // 径路圧縮
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};


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

// クラスカル法．最小全域木問題. 辺の集合 O(E logV)
// 負の径路を含まない．
// 始点 s
int V, E; cin >> V >> E;
vector<edge> edges; // 辺の集合
rep(i, 0, E){
    edge add;
    cin >> add.from >> add.to >> add.cost;
    edges.push_back(add);
}

int res = 0; // MST の辺のコストの和
sort(ALL(edges), comp);
UnionFind UF(V); // MST を作る．連結判定が速い．

for (edge e: edges)
    if (!UF.issame(e.from, e.to)){
        UF.merge(e.from, e.to);
        res += e.cost;
    }

cout << res << endl;

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり




Measured memory_bytes: 4608
import math
X, Y = map(int, input().split())
MOD = 10 ** 9 + 7



if (2 * Y - X) % 3 != 0 or (2 * X - Y) % 3 != 0 or (2 * Y - X) // 3 < 0 or (2 * X - Y) // 3 < 0:
	print(0)
else:
	a = (2 * Y - X) // 3
	b = (2 * X - Y) // 3
	factorial = [1]
	inverse = [1]
	for i in range(1, a + b + 5):
		factorial.append(factorial[-1] * i % MOD)
		inverse.append(pow(factorial[-1], MOD - 2, MOD))
	print(factorial[a + b] * inverse[a] * inverse[b] % MOD)


Measured memory_bytes: 115052
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n;
    scanf("%d",&n);
    if(n/10==9 || n%10 == 9){printf("Yes\n");}else{printf("No\n");}
    return 0;
}

Measured memory_bytes: 128
#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 <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int n,ans=1;
	string s;
	cin >> n >> s;
	map<char, int>ma;
	rep(i, n) {
		if (!ma.count(s[i])) {
			ma[s[i]] = 1;
		}
		else {
			ma[s[i]]++;
		}
	}
	for (auto p : ma) {
		auto v = p.second;
		ans *= v+1;
		ans %= mod;
	}
	ans--;
	if (ans < 0)ans += mod;
	cout << ans << endl;
}


Measured memory_bytes: 3688
A, B, C, K = map(int, input().split())
cnt = K
ans = 0
if A <= K:
    cnt -= A
    ans += A
    if B <= cnt:
        cnt -= B
        if C <= cnt:
            ans += (-1) * cnt
        else:
            ans += (-1) * cnt
    else:
        ans += 0
else:
    ans += K
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


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


Measured memory_bytes: 3564
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int train = sc.nextInt();
            int trainfree = sc.nextInt();
            int bus = sc.nextInt();
            int busfree = sc.nextInt();
            int trainfee = 0;
            int busfee = 0;
            if(train > trainfree){
              trainfee = trainfree;
            } else {
              trainfee = train;
            }
            if(bus > busfree){
              busfee = busfree;
            } else {
              busfee = bus;
            }
            System.out.println(trainfee + busfee);
      }
}

Measured memory_bytes: 21716