akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int cnt=0;
        for(int i=1;i<=n;i++){
            if(d(i)%2==1) cnt++;
        }
        out.println(cnt);
    }
    public static int d(int n){
        int cnt=0;
        while(n>0){
            cnt++;
            n/=10;
        }
        return cnt;
    }
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
// #define a first
// #define b second

vector < vi > v(100010);
stack <int > st;
int dp[100010];

void dfs(int u){
    dp[u] = true;
    for(auto i:v[u])
        if(!dp[i])
            dfs(i);
    st.push(u);
}

int f(int u){
    if(dp[u] != -1) return dp[u];

    int ans = 0;
    for(auto i:v[u]){
        ans = max(ans, 1 + f(i));
    }
    return dp[u] = ans;
}


int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);	
    
    int n, m, a, b;
    cin >> n >> m;
    memset(dp, 0, sizeof dp);
    forn(i, m){
        cin >> a >> b;
        v[a].pb(b);
    }
    rep(i, 1, n + 1){
        if(!dp[i])
            dfs(i);
    }
    memset(dp, -1, sizeof dp);
    int ans = -1;
    while(!st.empty()){
        if(dp[st.top()] == -1)
            ans = max(ans, f(st.top()));
        else ans = max(ans, dp[st.top()]);
        st.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032
x , n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))

ans = x
p.sort()  
cnt = 0

for i in range(100):
  if not (x - cnt) in p:
    print(x-cnt)
    exit()
  elif not (x + cnt) in p:
    print(x+cnt)
    exit()
  else:
    cnt += 1



Measured memory_bytes: 9192
/******************
*  Author: BD747  *
******************/
//Endagorion
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

const int maxn=100005,maxd=11;
int c[maxn][maxd];
int col[maxn];
vector<int> e[maxn];

int main(){

	int n,m,q;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		--a;--b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	cin>>q;
	for(int i=0;i<q;i++){
		int v,d;
		cin>>v>>d>>col[i+1];
		--v;
		c[v][d]=i+1;
	}
	for(int i=maxd-2;i>=0;i--){
		for(int v=0;v<n;v++){
			for(int u=0;u<e[v].size();u++){
				c[e[v][u]][i]=max(c[e[v][u]][i],c[v][i+1]);
			}
		}
	}
	
	for(int v=0;v<n;v++){
		int res=0;
		for(int d=0;d<maxd;d++){
			res=max(res,c[v][d]);
		}
		cout<<col[res]<<endl;
	}

	return 0;
}


Measured memory_bytes: 11128
#include <stdio.h>
#include <string.h>
 
int main() {
  long long a;
  long double b;
  scanf("%lld %Lf", &a,&b);
  long long bb = (long long)(b*100);
  long long ans = a*bb/100;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 2240
quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = [parse(Int,s) for s in split(readline())]

function main()
  M = 10^9 + 7
  n, a, b = in_a()
  power2_n = powermod(2, n, M)
  
  num_a, den_a, num_b, den_b = 1, 1, 1, 1
  num, den = 1, 1
  for i in 1:max(a, b)
    num = mod(num * (n-i+1), M)
    den = mod(den * i, M)
    if i == a
      num_a = num
      den_a = den
    end
    if i == b
      num_b = num
      den_b = den
    end
  end
  cmb_n_a = mod(num_a * invmod(den_a, M), M)
  cmb_n_b = mod(num_b * invmod(den_b, M), M)
  
  ans = mod(power2_n - 1 - cmb_n_a - cmb_n_b + 2M, M)
  println(ans)
end

isempty(ARGS) && main()


Measured memory_bytes: 169232
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main( void )
{
	int n, m, a;
	while ( cin >> n >> m >> a && n && m && a )
	{
		vector < vector <int> > lines( m );

		for ( int i = 0; i < m; i++ )
		{
			int h, p, q;
			cin >> h >> p >> q;

			vector <int> line(3);
			line[0] = h;
			line[1] = p;
			line[2] = q;

			lines[i] = line;
		}

		for ( int i = 0; i < m-1; i++ )
		{
			for ( int j = i+1; j < m; j++ )
			{
				if ( lines[i][0] < lines[j][0] )
				{
					swap( lines[i], lines[j] );
				}
				else if ( lines[i][0] == lines[j][0] )
				{
					if ( lines[i][1] > lines[j][1] )
						swap( lines[i], lines[j] );
				}
			}
		}

		int now = a;
		for ( int i = 0; i < m; i++ )
		{
			vector <int>& line = lines[i];
			if ( line[1] == now )
			{
				now = line[2];
			}
			else if ( line[2] == now )
			{
				now = line[1];
			}
		}

		cout << now << endl;

	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    long count_b = 0, count_a = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i]) {
            count_b += a[i] - b[i];
        } else {
            count_a += (b[i] - a[i]) / 2;
        }
    }
    cout << ((count_b > count_a) ? "No" : "Yes") << endl;
    return 0;
}


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

struct UnionFind {
  vector<int> parent;

  UnionFind(int N = 1) {
    init(N);
  }

  void init(int N = 1) {
    parent.assign(N, -1);
  }

  int root(int x) {
    if (parent.at(x) < 0) return x;
    else {
      parent.at(x) = root(parent.at(x));
      return parent.at(x);
    }
  }

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

  void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (parent.at(x) < parent.at(y)) swap(x, y);
    parent.at(x) += parent.at(y);
    parent.at(y) = x;
  }

  int size(int x) {
    return -parent.at(root(x));
  }
};

int main() {
  long long N, M; cin >> N >> M;
  vector<pair<int, int>> E(M);
  for (int i = 0; i < M; i++) {
    int A, B; cin >> A >> B;
    A--; B--;
    E.at(i) = make_pair(A, B);
  }
  reverse(E.begin(), E.end());
  UnionFind uf(N);
  vector<long long> ans;
  long long tmp = N * (N - 1) / 2; 
  for (int i = 0; i < M; i++) {
    ans.push_back(tmp);
    if (uf.issame(E.at(i).first, E.at(i).second)) continue;
    long long a = uf.size(E.at(i).first);
    long long b = uf.size(E.at(i).second);
    tmp -= a * b;
    uf.merge(E.at(i).first, E.at(i).second);
  }
  reverse(ans.begin(), ans.end());
  for (auto v : ans) cout << v << endl;
}


Measured memory_bytes: 3700
import bisect

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

ans = 0
A.sort()
C.sort()
for b in B:
    ans += bisect.bisect_left(A, b)*(N-bisect.bisect_right(C, b))
print(ans)

Measured memory_bytes: 23360
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a!=1){
		cout<<1<<endl;
	}
	if(b!=2){
		cout<<2<<endl;
	}
	if(c!=3){
		cout<<3<<endl;
	}
	if(d!=4){
		cout<<4<<endl;
	}
	if(e!=5){
		cout<<5<<endl;
	}

}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 2e5 + 1, mod = 1e9 + 7;

using namespace std;

int n;
int a[maxn];
int c2[maxn], c5[maxn];
int cnt[65][25];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        string ca;
        cin >> ca;
        int dc = 9, bf = 0;
        for (int j = 0; j < ca.size(); j++) {
            if (ca[j] == '.') {
                bf = 1; continue;
            }
            a[i] = 10 * a[i] + ca[j] - '0';
            if (bf) --dc;
        }
        for (; dc; --dc, a[i] *= 10);
        for (int x = a[i]; x % 2 == 0; x /= 2, ++c2[i]);
        for (int x = a[i]; x % 5 == 0; x /= 5, ++c5[i]);
        ++cnt[c2[i]][c5[i]];
    }
    int ans = 0;
    for (int i = 0; i < 65; i++)
        for (int j = 0; j < 25; j++) {
            if (!cnt[i][j]) continue;
            for (int l = max(0ll, 18 - i); l < 65; l++)
                for (int k = max(0ll, 18 - j); k < 25; k++) {
                    if (!cnt[l][k]) continue;
                    if (i == l && j == k) {
                        ans += cnt[i][j] * (cnt[i][j] - 1);
                        continue;
                    }
                    ans += cnt[i][j] * cnt[l][k];
                }
        }
    cout << ans / 2;
    return 0;
}


Measured memory_bytes: 8344
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        int [][]dp = new int[n][2];
        // 0 - '#', 1 -'.'
        dp[0][0] = s.charAt(0) == '#' ? 0 : 1;
        dp[0][1] = s.charAt(0) == '.' ? 0 : 1;
        for (int i = 1; i < n; ++i) {
            char current = s.charAt(i);
            if (current == '#') {
                dp[i][0] = Math.min(dp[i - 1][0], dp[i - 1][1]);
                dp[i][1] = 1 + dp[i - 1][1];
            } else {
                dp[i][0] = 1 + Math.min(dp[i - 1][0], dp[i - 1][1]);
                dp[i][1] = dp[i - 1][1];
            }
        }

        System.out.println(Math.min(dp[n - 1][0], dp[n - 1][1]));

    }
}


Measured memory_bytes: 34248
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;




struct MyString
{
	string str;

	MyString(){}
	MyString(string t) :str(t){}

	void in() { cin >> str; }

	/*bool operator< (const MyString& S) {
		if (this->str.size() != S.str.size()) return this->str.size() < S.str.size();
		return this->str < S.str;
	}

	bool operator> (const MyString& S) {
		if (this->str.size() != S.str.size()) return this->str.size() > S.str.size();
		return this->str > S.str;
	}*/
};




bool operator< (const MyString &s1, const MyString &s2) {
	if (s1.str.size() != s2.str.size()) return s1.str.size() < s2.str.size();
	return s1.str < s2.str;
}


int main() {
	MyString s;
	int n, t;
	map<MyString, int> m;

	cin >> n;
	for (int i = 0; i < n; i++) {
		s.in();
		cin >> t;
		m[s] += t;
	}

	for (map<MyString, int>::iterator it = m.begin(); it != m.end(); it++) {
		cout << it->first.str << " " << it->second << endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n; cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    sort(all(d));
    cout<<d[n/2]-d[n/2-1];
}

Measured memory_bytes: 3788
#include <stdio.h>

int main(void)
{
    int i, n, min, max, temp;
    long  sum;

    scanf("%d", &n);

    scanf("%d", &temp);
    min = temp;
    max = temp;
    sum = temp;

    for (i=1; i<n; i++) {
        scanf("%d", &temp);
        if (temp < min)
            min = temp;
        if (max < temp)
            max = temp;
        sum = sum + temp;
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;
}

Measured memory_bytes: 2724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;

		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();

			String[] tmp = line.split(" ");

			int numA = Integer.parseInt(tmp[0]);
			int numB = Integer.parseInt(tmp[1]);
			int numC = Integer.parseInt(tmp[2]);

			int cnt = 0;
			while (true) {

				if (cnt >= numC || numA > numB) {
					break;
				}

				numB -= numA;
				cnt++;
			}

			System.out.println(cnt);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 22868
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	ArrayList<ArrayList<Integer>> g = new ArrayList<>();
	boolean used[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		for(int i=0; i<N; i++) {
			g.add(new ArrayList<Integer>());
		}
		used = new boolean[N];
		for(int i=0; i<M; i++) {
			int x=sc.nextInt(); x--;
			int y=sc.nextInt(); y--;
			int z=sc.nextInt();
			g.get(x).add(y);
			g.get(y).add(x);
		}
		int cnt=0;
		for(int i=0; i<N; i++) {
			if(!used[i]) {
				dfs(i);
				cnt++;
			}
		}
		System.out.println(cnt);
		sc.close();
	}

	public void dfs(int r) {
		ArrayDeque<Integer> s = new ArrayDeque<Integer>();
		s.add(r);
		used[r]=true;
		while(!s.isEmpty()) {
			int u = s.pop();
			for(int i=0; i<g.get(u).size(); i++) {
				int v = g.get(u).get(i);
				if(used[v]) continue;
				s.push(v);
				used[v]=true;
			}
		}
	}
}


Measured memory_bytes: 107168
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0 || abs(X - Y) > (X + Y) / 3) {
        cout << 0 << endl;
        return 0;
    }
    fact();
    int K = (X + Y) / 3;
    cout << C(K, (K - abs(X - Y)) / 2) << endl;



    return 0;
}


Measured memory_bytes: 16640
package main

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

func main() {
	fsc := NewFastScanner()
	a, b, c := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	if a == b {
		fmt.Println(c)
	} else if a == c {
		fmt.Println(b)
	} else {
		fmt.Println(a)
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	int x, y, z, ans;
	scanf("%d %d %d", &x, &y, &z);
	ans = (x - z)/(y + z);
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    int n;
    string s;
	map<string,int> count;
    
	cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        count[s]++;
    }
    
    int maxv=0;
    map<string,int>::iterator it;
    
	for(it=count.begin(); it!=count.end(); it++){
        maxv = max(maxv, it->second);
    }
    
    for(it=count.begin(); it!=count.end(); it++){
       if(it->second==maxv){
          cout << it->first << endl;
       }
    }
    
	return 0;
}

Measured memory_bytes: 25216
# ???
n,a,b,c,d=map(int,input().split())
s=input()
ans="Yes"

if c<d:
    btod=s[b:d]
    atoc=s[a:c]
    if btod.count("##")>0:ans="No"
    if atoc.count("##")>0:ans="No"
else:
    btod=s[b-1-1:d+1]
    atoc=s[a:c]
    if atoc.count("##")>0:ans="No"
    else:
        if btod.count("...")==0:ans="No"
    
print(ans)


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>


int main()
{
  int cnt;
  int a,b,c,d,e,k;

  cnt = scanf("%d", &a);
  cnt = scanf("%d", &b);
  cnt = scanf("%d", &c);
  cnt = scanf("%d", &d);
  cnt = scanf("%d", &e);
  cnt = scanf("%d", &k);

  if ((e - a) <= k){
    printf ("Yay!");
  } else {
    printf (":(");
  }

  return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] dp = new int[n][3];
            int[][] a = new int[n][3];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 3; j++) {
                    a[i][j] = in.nextInt();
                }
            }
            dp[0][0] = a[0][0];
            dp[0][1] = a[0][1];
            dp[0][2] = a[0][2];

            for (int i = 1; i < n; i++) {
                dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
                dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
                dp[i][2] = Math.max(dp[i - 1][0], dp[i - 1][1]) + a[i][2];

            }

            out.println(Math.max(Math.max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]));
        }

    }
}



Measured memory_bytes: 102952
import sys
import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    n = int(stdin.readline().rstrip())
    #n,k = map(int, stdin.readline().rstrip().split())
    #p = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    letter = string.ascii_lowercase
    ans = str(num2alpha(n))
    ans = ans.lower()
    print(ans)


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

main()


Measured memory_bytes: 9772
#include"bits/stdc++.h"

using namespace std;

int main(){
  int ans=0;
  int R,G,B,N;cin>>R>>G>>B>>N;
  for(int i=0;i<=N;++i){
    for(int j=0;j<=N;++j){
      int rest=N-i*R-j*G;
      if(rest>=0&&rest%B==0)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
A,B = list(map(int,input().split()))
def problem_gksn(A, B):
  x_min = math.ceil(A / (0.08))
  x_max = math.floor((A+1)/0.08)
  y_min = math.ceil(B / (0.10))
  y_max = math.floor((B+1) / (0.10))
  if max(x_min, y_min) < min(x_max, y_max):
    return max(x_min, y_min)
  else:
    return -1
print(problem_gksn(A,B))

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 7)


class UnionFind:
    def __init__(self, size: int):
        self.parent = [-1 for _ in range(size)]
        self.size = [1 for _ in range(size)]

    def unite(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.parent[px] > self.parent[py]:
                self.parent[py] = px
                self.parent[px] -= 1
                self.size[px] += self.size[py]
                self.size[py] = 0
            else:
                self.parent[px] = py
                self.parent[py] -= 1
                self.size[py] += self.size[px]
                self.size[px] = 0
        return

    def find(self, x: int) -> int:
        if self.parent[x] < 0:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def is_same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)


def main():
    # input
    N, M = map(int, input().split())
    brs = [list(map(int, input().split())) for _ in range(M)]

    # solve
    # ref: http://drken1215.hatenablog.com/entry/2019/03/03/224600
    # ref: https://atcoder.jp/contests/abc120/submissions/4450601
    uf = UnionFind(N)
    ans = [N*(N-1)//2]
    for i in range(M-1, 0, -1):
        a, b = brs[i][0], brs[i][1]
        a, b = a-1, b-1
        p1 = uf.find(a)
        p2 = uf.find(b)
        if p1 != p2:
            ans.append(ans[-1] - uf.size[p1]*uf.size[p2])
        else:
            ans.append(ans[-1])
        uf.unite(p1, p2)
    return ans


print(*list(reversed(main())), sep="\n")


Measured memory_bytes: 62600
A, B = map(int, input().split())
G1 = [['#'] * 100 for i in range(50)]
G2 = [['.'] * 100 for i in range(50)]

A, B = A - 1, B - 1

h, w = 0, 0
for a in range(A):
    if w > 99:
        h += 2
        w = 0
    G1[h][w] = '.'
    w += 2

h, w = 1, 0
for b in range(B):
    if w > 99:
        h += 2
        w = 0
    G2[h][w] = '#'
    w += 2


print(100, 100)
for g in G1:
    print(''.join(g))
for g in G2:
    print(''.join(g))


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


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

    int r = 0, w = 0;

    for(int i = 0; i < n; i++){
        if(c[i] == 'W') w++;
        else r++;
    }

    int ans = 0;
    for(int i = 0; i < r; i++){
        if(c[i] == 'W') ans++;
    }

    cout << ans << endl;   

    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[2010],b[2010],c[2010],ans,x,sum;
const int MOD=1000000007;
int main()
{
	while(cin>>n>>k)
	{
		x=k-1;
		ans=sum=0;
		for(int i=0;i<n;i++)
			cin>>a[i];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(a[i]>a[j])
					sum++;
		for(int i=0;i<n;i++)
			for(int j=i+1;j<n;j++)
				if(a[i]>a[j])
					c[i]++;
		for(int i=0;i<n;i++)
			if(c[i])
			{
				ans+=c[i]*k;
				ans%=MOD;
			}
		k=k%MOD;
		x=(k)*x/2;
		x%=MOD;
		x=sum*x%MOD;
		ans+=x;
		ans%=MOD;
		for(int i=0;i<n;i++)
			a[i]=c[i]=0;
		cout<<ans<<'\n';
	}
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int n; cin >> n;
  int p[n]; rep(i,n) cin >> p[i];
  int result = 0;
  rep(i,n-2) {
    if (p[i]<p[i+1]&&p[i+1]<p[i+2]) result++;
    if (p[i]>p[i+1]&&p[i+1]>p[i+2]) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int in[110][110];
int pic[55][55];
int tmp[55][55];
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m),n){
		rep(i,n)rep(j,n)scanf("%d",&in[i][j]);
		rep(i,m)rep(j,m)scanf("%d",&pic[i][j]);
		pii out(inf,inf);
		int N=n-m+1,M=n-m+1;
		rep(e,4){
			rep(i,n-m+1)rep(j,n-m+1){
				pii t(inf,inf);
				rep(k,m)rep(l,m)
					if(pic[k][l]!=-1){
						if(in[i+k][j+l]!=pic[k][l])goto en;
						t=min(t,pii(i+k,j+l));
					}
				out=min(out,t);
				N=out.first;
				M=out.second;
				goto end;
				en:;
				if(i==N&&j==M)goto end;
			}
			end:;
			if(e==3)break;
			rep(i,m)rep(j,m)tmp[i][j]=pic[i][j];
			rep(i,m)rep(j,m)pic[i][j]=tmp[j][m-i-1];
		}
		if(out.first==inf)cout<<"NA"<<endl;
		else cout<<out.second+1<<" "<<out.first+1<<endl;
	}
}

Measured memory_bytes: 1272
import numpy as np


def main():
    a, b, x = map(int, input().split())

    if a * a * b / 2.0 <= x:
        theta = np.arctan(2 * (a * a * b - x) / a**3)
    else:
        theta = np.pi / 2.0 - np.arctan(2 * x / (a * b * b))

    print(np.degrees(theta))


if __name__ == '__main__':
    main()


Measured memory_bytes: 21108
res = {
    "AC": 0,
    "WA": 0,
    "TLE": 0,
    "RE": 0
}
N = int(input())
for i in range(0, N):
  s = input()
  res[s] += 1

def printf(tex: str, res):
  print(f"{tex} x {res[tex]}")

  
printf("AC", res)
printf("WA", res)
printf("TLE", res)
printf("RE", res)

Measured memory_bytes: 74860
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
#define pb push_back
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,A,lim,f[N],rt;
vector<int> E[N];
bool fl;

bool check2(vector<int> &v,int mid) {
	int l=0,r=sz(v)-1;
	while(l<r) {
		if(l==mid) { ++l;continue; }
		if(r==mid) { --r;continue; }
		if(v[l]+v[r]>lim) return 0;
		++l,--r;
	}
	return 1;
}

void dfs(int u,int fa) {
	vector<int> vec;
	for(auto v:E[u]) if(v^fa) dfs(v,u),vec.pb(f[v]);
	if(sz(vec)&1^1) vec.pb(0);
	sort(vec.begin(),vec.end());
	int l=0,r=sz(vec);
	while(l<r) {
		int mid=(l+r)>>1;
		if(check2(vec,mid)) r=mid;
		else l=mid+1;
	}
	if(l==sz(vec)) { fl=0;return; }
	f[u]=vec[l]+1;
}

bool check(int mid) {
	lim=mid;fl=1;dfs(rt,0);
	return fl&&f[rt]<=lim+1;
}

int main() {
	cin>>n;
	for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	for(int i=1;i<=n;i++)
		if(sz(E[i])&1) ++A,rt=i;
	int l=0,r=n;
	while(l<r) {
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<A/2<<' '<<l;
	check(2);
	return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Edge {
    ll to;
    ll from;
    ll cost;
};

Edge E[5005];
ll C[2505];
bool U[2505];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, P;
    cin >> N >> M >> P;
    REP(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        E[i].to = b - 1;
        E[i].from = a - 1;
        E[i].cost = -(c - P);
    }

    REP(i, N) {
        C[i] = INF;
    }
    C[0] = 0;
    memset(U, 0, sizeof(U));
    queue<ll> q;
    q.push(N - 1);
    U[N - 1] = true;
    while (!q.empty()) {
        ll t = q.front();
        q.pop();
        REP(i, M) {
            if (E[i].to != t)
                continue;
            ll n = E[i].from;
            if (U[n])
                continue;
            U[n] = true;
            q.push(n);
        }
    }

    REP(_, N + 5) {
        bool update = false;
        REP(i, M) {
            const auto &e = E[i];
            if (C[e.from] == INF)
                continue;
            ll cost = C[e.from] + e.cost;
            if (C[e.to] > cost) {
                update = true;
                C[e.to] = cost;
            }
        }
        if (!update)
            break;
    }

    REP(i, M) {
        const auto &e = E[i];
        if (!U[e.to])
            continue;
        if (C[e.from] == INF)
            continue;
        ll cost = C[e.from] + e.cost;
        if (C[e.to] > cost) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << std::max(0LL, -C[N - 1]) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    string S;cin >> S;
    int num = stoi(S);

    vint X(4);
    REPR(i,3){
        X.at(i) = num % 10;
        num /= 10;
    }
    string ans = "";

    for(int bit = 0;bit < (1 << 3); bit++){
        int res=X.at(0);
        ans = "";
        ans += S[0];

        for(int i = 0;i < 3;i++){
            if(bit & (1 << i)){
                res +=  X.at(i+1);
                ans += "+";
                ans += S[i+1];
            }else{
                res -= X.at(i+1);
                ans += "-";
                ans += S[i+1];
            }
        }
        if(res == 7){
            cout << ans << "=7" << endl;
            break;
        }

        
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {

	string a, ans = "No";
	cin >> a;
	if (a[0] == '9' || a[1] == '9'){
		ans = "Yes";
	}
	cout << ans << endl;
	
	system("pause");
	return 0;
}


Measured memory_bytes: 504
def main():
    n,m = list(map(int,input().strip().split()))
    a = list(map(int,input().strip().split()))

    total = sum(a)
    boarder = (1/(4*m)) * total
    chosen = 0

    for i in range(len(a)):
        if(a[i]>=boarder):
            chosen = chosen + 1

    if(chosen<m):
        print('No')
    else:
        print('Yes')

main()


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

const int INF = 1e9 + 7;

int N;
int a[310];
double dp[310][310][310];


double rec(int i, int j, int k){
	if(dp[i][j][k] >= 0) return dp[i][j][k];
	if(i==0 && j==0 && k==0) return 0.0;

	double res=0;
	if(i>0) res += rec(i-1, j, k)*i;
	if(j>0) res += rec(i+1, j-1, k)*j;
	if(k>0) res += rec(i, j+1, k-1)*k;
	res += N;
	res *= 1.0 / (i+j+k);

	return dp[i][j][k] = res;
}


int main() {
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a[i];
	}
	int one=0;
	int two=0;
	int three=0;
	for(int i=0; i<N; i++){
		if(a[i] == 1) one++;
		else if(a[i] == 2) two++;
		else three++;
	}
	memset(dp, -1, sizeof(dp));

	cout << fixed << setprecision(10) << rec(one, two, three) << endl;

}

Measured memory_bytes: 233088
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 505
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
char arr[MAX_INT][MAX_INT], arr1[MAX_INT][MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;


int main() {
	go;
    cin >> N >> M;
    fi(i, 0, N, 1) {
    	fi(j, 0, N, 1) {
    		cin >> arr[i][j];
    	}
    }
    fi(i, 0, M, 1) {
    	fi(j, 0, M, 1) {
    		cin >> arr1[i][j];
    	}
    }
   
	fi(k, 0, N, 1) {
		fi(l, 0, N, 1) {
			ll ok = 1;
			fi(i, k, k + M, 1) {
				fi(j, l, l + M, 1) {
					if(arr[i][j] != arr1[i - k][j - l]) {
						ok = 0;
						break;
					}	
				}
			}
			if(ok) {
				cout << "Yes\n";
				quit;
			}
		}
	}
	cout << "No\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3432
IsPrimes = [True] * 1000002
IsPrimes[0], IsPrimes[1] = False, False

for i in range(2, 1001):
    if IsPrimes[i]:
        for j in range(i*i, 1000001, i):
            IsPrimes[j]= False

cnt = [0] * 1000001

for i in range(1000001):
    if IsPrimes[i]:
        cnt[i] += 1

for i in range(1, 1000001):
    cnt[i] += cnt[i-1]

while True:
    try:
        n = int(raw_input())
        print cnt[n]

    except EOFError:
        break



Measured memory_bytes: 75976
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
const int MOD = 1e9 +7;

int main() {
  int H, W; cin >> H >> W;
  vector<string> grid(H); REP(i, H) cin >> grid[i];

  vector<vector<int>> yoko(H, vector<int>(W,0));
  vector<vector<int>> tate(H, vector<int>(W,0));

  //yoko
  REP(i, H) {
    int edge = 0;
    int cnt  = 0;
    REP(j, W){
      if(grid[i][j] == '#'){
        yoko[i][edge] = cnt;
        yoko[i][j] = -cnt;
        cnt = 0;
        edge = j + 1;
      }else if(j == W-1){
        yoko[i][edge] = ++cnt;
      }else{
        cnt++;
      }
    }

    FOR(j, 1, W){
      yoko[i][j] += yoko[i][j-1];
    }
  }

  //tate
  REP(j, W) {
    int edge = 0;
    int cnt  = 0;
    REP(i, H){
      if(grid[i][j] == '#'){
        tate[edge][j] = cnt;
        tate[i][j] = -cnt;
        cnt = 0;
        edge = i + 1;
      }else if(i == H-1){
        tate[edge][j] = ++cnt;
      }else{
        cnt++;
      }
    }

    FOR(i, 1, H){
      tate[i][j] += tate[i-1][j];
    }
  }

  ll ans = 0;
  REP(i, H) REP(j, W){
    if(grid[i][j] == '#') continue;
    ll tmp = tate[i][j] + yoko[i][j] -1;
    if(ans < tmp) ans = tmp;
  }
  cout << ans << endl;
}


Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

/*
int main () {
    string str;
    cin >> str;
    bool c = false;
    if (str.size() == 1) {
        cout << str << endl;
        return 0;
    }
    REP (i, 0, str.size()) {
        if (c) {
            str[i] = '9';
        }
        if (str[i] != '9') {
            c = true;
        }
    }
    if (c) {
        str[str.size() - 1] = '9';
    }
    int ans = 0;
    REP (i, 0, str.size()) {
        ans += str[i] - '0';
    }
    cout << ans - c << endl;
//    dump(str);
}
*/

int main() {
    string str;
    cin >> str;
    vector<vector<int>> dp(str.size() + 1, vector<int>(2, 0));
    REP (i, 0, str.size()) { 
        REP (j, 0, 2) {
            int m = (j ? str[i] - '0' :  9) + 1;
            if (i == 0 && j == 0) continue;
            REP (k, 0, m) {
                dp[i + 1][j && k == m - 1] = max(dp[i + 1][j && k == m - 1], dp[i][j] + k);
            }
        }
    }
    cout << max(dp[str.size()][0], dp[str.size()][1]) << endl;
/*
    REP (i, 0, str.size() + 1) {
        REP (j, 0, 2) {
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
*/
    return 0;
}


Measured memory_bytes: 256
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pll             pair<ll,ll>
#define vll              vector<int>
#define mll             map<ll,ll>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define md             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void hi()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void bye()
{
    #ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    #endif
}
ll ans=md,c=0,o=0,e=0,a[123456];
void printArray(ll arr[], ll size) 
{ 
    for(ll i = 0; i < size; i++) 
        cout<<arr[i]<<" "; 
    printf("\n"); 
    return; 
} 
void printSequencesRecur(ll arr[], ll n, ll k, ll index) 
{ 
   ll i; 
   if (k == 0) 
   {
       ans=min(ans,o);
       ans=min(ans,e);
       o=0,e=0;

    printArray(arr, index); 
   } 
   if (k > 0) 
   { 
      for(i = 1; i<=n; ++i) 
      { 
        arr[index] = a[i-1];
        c++;c%=2;
        if(c==0) o=max(o,arr[index]);
        else e=max(o,arr[index]); 
        printSequencesRecur(arr, n, k-1, index+1); 
      } 
   }
}
void printSequences(ll n, ll k) 
{ 
    ll *arr = new ll[k]; 
    printSequencesRecur(arr, n, k, 0); 
  
    delete(arr); // free dynamically allocated array 
    return; 
}  
void solve()
{
    ll n,s=0,x; cin>>n;
    mll m;
    for(int i=0;i<n;i++)
        cin>>x,m[x]++,s+=x;
    ll a,b;
    cin>>x;
    while(x--)
        cin>>a>>b,s-=m[a]*a,s+=m[a]*b,cout<<s<<"\n",m[b]+=m[a],m[a]=0;
}

int main()
{
    hi();
    ll test_cases=1; //cin>>test_cases;
    for(ll t=1;t<=test_cases;t++)
    {
        solve();
    }
    bye();
    return 0;
}

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

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

	if (s[5] == '0') {
		if (s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4') cout << "Heisei";
		else cout << "TBD";
	}
	else cout << "TBD";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define all(a) a.begin(), a.end()
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    string s; cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
    return;
}
int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

Measured memory_bytes: 3636
from collections import deque
N=int(input())
nums=["3","5","7"]
stack=deque(nums)
cnt=0
while stack:
    cand=stack.pop()
    if ('3' in cand) and ('5' in cand) and ('7' in cand):
        cnt+=1
    for c in nums:
        if int(cand+c)<=N:
            stack.append(cand+c)

print(cnt)

Measured memory_bytes: 40940
#include<bits/stdc++.h>
using namespace std;
#define pb			push_back
#define vi  		vector<int>
#define all(a)		(a).begin(),(a).end()
#define F 			first
#define S 			second
#define endl		"\n"
#define fast 		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int 		long long int
#define mod			1000000007

static int t[3][4001];
int32_t main(){


	int r;
	cin>>r;
	float ans=2*3.141592*r;
	printf("%.2f",ans);
	return 0;
}

Measured memory_bytes: 3684
import math
from functools import reduce
from collections import deque

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

s = input()

win = 0
lose = 0
for c in s:
    if c == "o":
        win += 1
    else:
        lose += 1

nokori = 15 - win - lose

print("YES" if win+nokori >= 8 else "NO")

Measured memory_bytes: 38384
#include<stdio.h>

int main(void)
{
    int n;
    int array[n];

    int a = 0;
    int b = 0;

    scanf("%d", &n);
    for(int i = 0;i<n;i++){
        scanf("%d", &array[i]);
    }
    for (int i=0; i<n; ++i) {
        for (int j=i+1; j<n; ++j) {
            if (array[i] < array[j]) {
                int tmp =  array[i];
                array[i] = array[j];
                array[j] = tmp;
                }
        }
    }

    for(int i = 0;i<n;i++){
        if(i%2==0){
            a += array[i];
        }
        else{
            b += array[i];
        }
    }

    printf("%d", a-b);
    return 0;
 

}




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

int main() {
	int A,B,m;
  cin >> A >> B;
  for(int i = A;i <= B;i++){
    if(i % 10001 % 10 == 0 && i % 10001 % 100 == i % 10001 /1000 * 10){
      m++;
    }
  }
  cout << m <<endl;
}

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

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

    vector<int> cnt(n, 1);
    vector<bool> flag(n);
    flag[0] = true;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (flag[a])
            flag[b] = true;
        if (cnt[a] == 1)
            flag[a] = false;

        cnt[a]--;
        cnt[b]++;
    }

    int ans = 0;
    rep(i, n) {
        if (cnt[i] >= 1 && flag[i])
            ++ans;
    }
    cout << ans << endl;

    return 0;
}

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

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

#define MOD 1000000007

int main(void) {
    ll N;
    ll count = 0;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll temp;
        cin >> temp;
        count += temp - 1;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,x) for(int i = 0; i<x; i++)

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b*c)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3588