akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#include<vector>

using namespace std;

const int MAXN = 200000 + 10;
const int MAXM = 200000 + 10;

int cnt[MAXN][2];
int Step[MAXN];
int Q[MAXN];
int s[MAXN];
int n, m;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;

	string buf;
	cin >> buf;
	memset(Step, 0, sizeof(Step));
	for (int i = 0; i < n; i++) {
		// cout << cnt[i][0] << cnt[i][1] << endl;
		s[i + 1] = (buf[i] == 'B');
	}
	vector<vector<int>> g(n + 1);
	int x, y;
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		cnt[x][s[y]]++;
		cnt[y][s[x]]++;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	int Tail = 0;
	for (int i = 1; i <= n; i++) {
		if (cnt[i][0] == 0 || cnt[i][1] == 0) {
			Q[Tail] = i;
			Step[i] = 1;
			Tail++;
		}
	}

	for (int Head = 0; Head < Tail; Head++) {
		int cur = Q[Head];
		for (int k : g[cur]) {
			cnt[k][s[cur]]--;
			if (cnt[k][s[cur]] == 0 && (!Step[k])) {
				Step[k] = 1;
				Q[Tail++] = k;
			}
		}
	}
	// cout << Tail << endl;
	cout << ((Tail == n) ? "No" : "Yes") << endl;
	return 0;
}


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

int main() {
  ll a;
  long double b;
  cin>>a>>b;
  b=(int)(b*100+0.5);
  ll ans=a*b;
  cout<<ans/100<<endl;
}

Measured memory_bytes: 3716
#include<iostream>

using namespace std;

int main()
{
	int a[101][101],b[101];
	int c;
	int n,m;
	
	cin>>n>>m;
	for( int i=0; i<n; i++ ) {
		for( int j=0; j<m; j++ ) {
			cin>>a[i][j];
		}
	}	
	for( int i=0; i<m; i++ ) {
		cin>>b[i];
	}
	for( int i=0; i<n; i++ ) {
		c=0;
		for( int j=0; j<m; j++ ) {
			c+=(a[i][j]*b[j]);
		}
		cout<<c<<endl;
	}
	
    return 0;
}

Measured memory_bytes: 1200
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    for i in range(6):
        tmp_dice = set_top(dice2, i)
        for _ in range(4):
            if dice1 == tmp_dice:
                return True
            tmp_dice = twist(tmp_dice)
    return False
        
dice1 = input().split()
dice2 = input().split()

print('Yes' if equal(dice1, dice2) else 'No')

Measured memory_bytes: 6744
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	ll k, a, b;
	cin >> k >> a >> b;
	if(a >= b-1){
		cout << 1 + k << endl;
	} else {
		ll ans = a, kai = k-(a-1);
		ans += (b-a)*(kai/2);
		ans += kai%2;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
    n = N // 2
    m2 = A[n - 1] + A[n]
    M2 = B[n - 1] + B[n]
    ans = M2 - m2 + 1
    print(ans)
else:
    n = N // 2
    m2 = A[n]
    M2 = B[n]
    ans = M2 - m2 + 1
    print(ans)

Measured memory_bytes: 25552
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			final int X = sc.nextInt();
			final int Y = sc.nextInt();
			final int Z = sc.nextInt();
			
			if(X == 0 && Y == 0 && Z == 0){
				break;
			}
			
			int[] numbers = new int[X];
			for(int i = 0; i < X; i++){
				numbers[i] = sc.nextInt();
			}
			
			int[] event = new int[Y + 1];
			int[] effect = new int[Y + 1];
			
			for(int i = 0; i < Z; i++){
				final int N = sc.nextInt();
				final int E = sc.nextInt();
				final int A = sc.nextInt();
				
				event[N] = E;
				effect[N] = A;
			}
			
			final int max = Y * 100;
			final double prob = 1.0 / X;
			double[][] DP = new double[Y + 1][max + 1];
			DP[0][0] = 1.0;
			
			for(int i = 0; i < Y; i++){
				//System.out.println(i + " " + DP_PROB[i] + " " + DP_MONEY[i]);
				for(int money = 0; money <= max; money++){
					if(DP[i][money] <= 0.0){
						continue;
					}
					
					for(int number : numbers){
						int next = Math.min(i + number, Y);
					
						int next_money = money;
						
						if(event[next] == 1){
							next = Math.min(next + effect[next], Y);
						}else if(event[next] == 2){
							next_money += effect[next];
						}else if(event[next] == 3){
							next_money -= effect[next];
							next_money = Math.max(next_money, 0);
						}
						
						DP[next][next_money] += DP[i][money] * prob;
					}
				}
			}
			
			double sum = 0;
			for(int i = 0; i <= max; i++){
				sum += DP[Y][i] * i;
			}
			
			System.out.println((long)(sum));
		}
		
	}

}

Measured memory_bytes: 59928
#include<iostream>
using namespace std;
int main(){
	int m,f,r;
	for(int a=0;a<50;a++){
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1){
	       break;
	    }
		if(m==-1||f==-1){cout<<"F"<<endl;}
		else if(m+f>=80){cout<<"A"<<endl;}
		else if(m+f>=65&&m+f<80){cout<<"B"<<endl;}
		else if(m+f>=50&&m+f<65||r>=50){cout<<"C"<<endl;}
		else if(m+f>=30&&m+f<50){cout<<"D"<<endl;}
		else if(m+f<30){cout<<"F"<<endl;}
		else if(m==-1||f==-1){cout<<"F"<<endl;}
	
	}
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,W; cin >> n >> W;
    array<int,10000000>dp = {0LL};
    rep(i,n){
        int w,v; cin >> w >> v;
        for(int j = W; j >= 0; j--){
            if(j + w <= W)cmax(dp[j + w],dp[j] + v);
        }
    }
    cout << *max_element(dp.begin(), dp.begin() + W+1) << endl;
}



Measured memory_bytes: 78336
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

const int MAX_V = 15;
int V;
int dp[1 << MAX_V][MAX_V];
vector<P> table[MAX_V];

int rec(int mask, int k, int start) {
    if (dp[mask][k] >= 0) return dp[mask][k];
    if (mask == (1 << V) - 1 && k == start) return dp[mask][k] = 0;

    int ret = INF;
    for (P next : table[k]) {
        if (mask & (1 << next.first)) continue;
        ret = min(ret, next.second + rec(mask | (1 << next.first), next.first, start));
    }
    return dp[mask][k] = ret;
}

signed main() {
    int E;
    cin >> V >> E;
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        table[s].push_back(P(t, d));
    }

    int ret = INF;
    for (int start = 0; start < V; start++) {
        memset(dp, -1, sizeof(dp));
        ret = min(ret, rec(0, start, start));
    }

    if (ret == INF) ret = -1;
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 6960
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long X, long long N, std::vector<long long> p) {
    set<long long> s;
    for (auto e : p)s.insert(e);

    int ans = 1 << 30;
    loop (k, -500, 500) {
        if (s.find(k) == s.end() && abs(X-k) < abs(X-ans)) {
            ans = k;
        }
    }
    cout << ans << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int a[5];
char b[5]={'A','B','C','D','E'};
int c,d;
while(cin>>c>>d,c||d){
a[0]=c+d;
loop(i,1,5){
cin>>c>>d;
a[i]=c+d;
}
int max=0;
int mai;
rep(i,5){
if(max<a[i]){
max=a[i];
mai=i;
}
}
cout<<b[mai]<<" "<<max<<endl;
}
}

Measured memory_bytes: 1164
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let(x,y,z) = read!(i64,i64,i64);
	println!("{} {} {}",z,x,y);
}

fn run() {
    solve();
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

    vector<double> x(n);
    vector<double> y(n);

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

    vector<int> t;
    for (int i = 0; i < n; ++i) {
        t.push_back(i);
    }

    double sum = 0.0;

    do {
        for (int i = 0; i < n-1; ++i) {
            sum += sqrt((x[t[i+1]] - x[t[i]]) * (x[t[i+1]] - x[t[i]]) + (y[t[i+1]] - y[t[i]]) * (y[t[i+1]] - y[t[i]]));
        }

    } while (next_permutation(t.begin(), t.end()));

    double n_1 = 1.0;
    for (int i = 1; i <= n; ++i) {
        n_1 *= i;
    }

    double ans = sum / n_1;

    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
S_list = list(input())
result = 0
level = S_list.pop(0)
for s in S_list:
    if level == s and s == "0":
        level = "1"
        result += 1
    elif level == s and s == "1":
        level = "0"
        result += 1
    else:
        level = s
print(result)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int n;
    string s;
    cin >> n >> s;

    int count=0;
    for (int i=0;i<=n-3;i++)
    {
        if ((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
        {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x;
    cin>>x;
    if(x < 1200){
        log("ABC");
    } else if(x < 2800){
        log("ARC");
    } else log("AGC");

    return 0;
}


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

using namespace std;

const int INF = 1000000000;

void Main() {
    int N, M;
    cin >> N >> M;
    vector<map<int, int>> graph(N, map<int, int>());
    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        --r;
        graph[l].emplace(r, d);
        graph[r].emplace(l, -d);
    }

    vector<int> dist(N, INF);
    for (int i = 0; i < N; ++i) {
        if (dist[i] < INF) {
            continue;
        }

        queue<int> q;
        q.push(i);
        dist[i] = 0;
        while (!q.empty()) {
            int curr = q.front();
            q.pop();
            for (auto e : graph[curr]) {
                if (dist[e.first] < INF) {
                    if (dist[e.first] != dist[curr] + e.second) {
                        cout << "No" << endl;
                        return;
                    }
                    continue;
                }
                dist[e.first] = dist[curr] + e.second;
                q.push(e.first);
            }
        }
    }
    cout << "Yes" << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> b(n-1, 0);
  for (ll i = 0; i < n-1; ++i) {
    cin >> b[i];
  }

  vector<ll> a(n, 1000000);
  for (ll i = 0; i < n-1; ++i) {
    a[i] = min(a[i], b[i]);
    a[i+1] = b[i];
  }

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    ans += a[i];
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll pre, suf;
int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    ll ans = 0;
    for (int i = k; i <= n + 1; ++i)
    {
        pre = i * (i - 1ll) / 2;
        suf = (n * 2 + 1ll - i) * i / 2;
        ans = (ans + suf - pre + 1) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
    int x, y;
    cin >> x >> y;
    if(y%2 == 1){
        cout << "No" << endl;
    }
    else if(x*4 < y){
        cout << "No" << endl;
    }
    else if(x*2 > y){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int find2(int n) {
    for (int i = 2; i < sqrt(n) + 1; i++) {
        if (n % i == 0) return i;
    }
    return -1;
}

int main() {
    int n, d;
    vector<int> v;
    cin >> n;
    int m = n;
    
    d = find2(n);
    
    while (d != -1) {
        while (n % d == 0) {
            n = n / d;
        }
        v.push_back(d);
        d = find2(n);
    }
    
    if (n != 1) {
        v.push_back(n);
    }
    
    for (int i = 0; i < v.size(); i++) {
        m = m / v[i] * (v[i] - 1);
    }
    cout << m << endl;
}

Measured memory_bytes: 3140
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int res;
    if (b/a < c) res = b/a;
    else res = c;

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


    return 0;
} 



Measured memory_bytes: 128
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 3e5+5;	
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    if(n>0)
    s << arr[n - 1] ;
    s<< "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];
int tree[4*N];
void update(int pos,int v,int l,int r,int tn){
	if(l==r && l==pos){
		tree[tn]=v;
		return ;
	}
	int mid=(l+r)/2;
	if(pos>=l&&pos<=mid)update(pos,v,l,mid,tn*2+1);
	else if(pos>mid && pos<=r)update(pos,v,mid+1,r,2*tn+2);
	tree[tn] = max(tree[tn*2+1],tree[tn*2+2]);
}
int qry(int l,int r,int ql,int qr,int tn){
	if(l>qr||r<ql)return INT_MIN;
	if(l>=ql && r<= qr)return tree[tn];
	int mid=(l+r)/2;
	return max(qry(l,mid,ql,qr,tn*2+1),qry(mid+1,r,ql,qr,2*tn+2));
}
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		int k;
		cin >> k;
		int ans=1;
		fn{
			int y;
			cin >> y;
			int l  = max(0ll,y-k);
			int r  = min(N,y+k);
			int x =qry(0,N,l,r,0);
			ans=max(ans,1+x);
			update(y,x+1,0,N,0);
		}
		cout << ans <<'\n';
	
	}
	return 0;
}

Measured memory_bytes: 11800
N=gets.chomp.to_i
A=gets.chomp.split.map(&:to_i)
S=A.select { |n| n % 2 == 0 }
S.each do |i|
  if i%3==0 || i%5==0
    next
  end
  puts 'DENIED'
  exit
end
puts 'APPROVED'

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    int w[N];
    for(int i=0;i<N;i++){
        cin >> w[i];
    }
    int ABS[N];
    for(int i=0;i<N;i++){
        int s1=0;
        int s2=0;
        for(int j=0;j<i;j++){
            s1 = s1 + w[j];
        }
        for(int k=i;k<N;k++){
            s2 = s2 + w[k];
        }
        ABS[i] = abs(s1-s2);
    }
    int min=ABS[0];
    for(int i=0;i<N;i++){
        if(ABS[i]<min){
            min = ABS[i];
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    string s, r;
    string s1, r1, s2, r2;
    cin >> s;
    r = s;
    r1 = s1 = s.substr(0, s.size() / 2);
    r2 = s2 = s.substr(s.size() / 2 + 1, s.size() / 2);
    reverse(r.begin(), r.end());
    reverse(r1.begin(), r1.end());
    reverse(r2.begin(), r2.end());
    if (s == r && s1 == r1 && s2 == r2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
H, N=map(int, input().split())
AB=[list(map(int, input().split())) for _ in range(N)]
dp=[0]+[float('inf') for _ in range(2*10**4)]
for a, b in AB:
  for i in range(a, H+a):
    dp[i]=min(dp[i-a]+b, dp[i])
    
print(min(dp[H:]))

Measured memory_bytes: 75112
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
      int a =sc.nextInt();
      int p =sc.nextInt();
      sc.close();
	  int ans = (a*3+p)/2;
	  System.out.println(ans);
	}

}

Measured memory_bytes: 21716
#include<iostream>
#include<map>
#include<string>
#include<vector>
using namespace std;
map<string,int>price;
map<string,vector<string> >rec;
int R(string o){
	int m=0,i;
	if(rec[o].size()){
		for(i=0;i<rec[o].size();i++)
			m+=R(rec[o][i]);
	}else
		m=price[o];
	if(price[o]&&price[o]<m)
		m=price[o];
	return m;
}
int main(){
	int n,m;
	string s,t;
	for(;cin>>n,n;){
		price.clear();
		rec.clear();
		for(;n--;){
			cin>>s;
			cin>>price[s];
		}
		cin>>n;
		for(;n--;){
			cin>>s>>m;
			int p=0;
			for(;m--;){
				cin>>t;
				p+=price[t];
			}
			if(p<price[s])
				price[s]=p;
		}
		cin>>s;
		cout<<price[s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    N = int(input())
    S = {}
    for _ in range(N):
        s = input()
        if s not in S:
            S[s] = 1
        else:
            S[s] += 1

    v_max = max(S.values())
    keys = [k for k, v in S.items() if v == v_max]
    keys.sort()

    for k in keys:
        print(k)


if __name__ == "__main__":
    main()

Measured memory_bytes: 32096
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979;

double toDegree(double rad) {
  return rad / (2 * PI) * 360.;
}

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double A = x / a;
  if (A >= a * b / 2) {
    double h = (a * b - A) * 2 / a;
    double ans = toDegree(atan2(h, a));
    printf("%.10f\n", ans);
  } else {
    double w = 2 * A  / b;
    double ans = toDegree(atan2(b, w));
    printf("%.10f\n", ans);
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		long X=nextLong();
//		for(long X=0;X<20000;X++){
//			boolean flg=true;
		for(int A=-1000;A<1000;A++){
//			if(flg==false)
//				break;
			for(int B=-1000;B<1000;B++){
				if(Math.pow(A, 5)-Math.pow(B, 5)==X){
//					System.out.println(X+":"+A+" "+B);
					System.out.println(A+" "+B);

					return;
//					flg=false;
				}
			}
		}
//		}

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 26040
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

int main() {

	ll N;
	cin >> N;
	
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			ll bunsi = N*i*j;
			ll bunbo = 4 * i*j - N*j - N*i;

			if (bunbo<=0) continue;

			if (bunsi%bunbo == 0) {
				ll c = bunsi / bunbo;

				if (4*i*j*c == (N*j*c + N*i*c + N*i*j)) {
					cout << i << " " << j << " " << c << endl;
					return 0;
				}
			}
		}
	}


	return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "sort"
)

func main() {
  i := make([]int, 3)
  fmt.Scan(&i[0], &i[1], &i[2])
  sort.Ints(i)
  if (i[0] == 5 && i[1] == 5 && i[2] == 7) {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
int main(){
  int r, c;
  cin>>r>>c;
  vector<vector<int>> vec(r+1, vector<int>(c+1, 0));
  for(int i = 1; i<=r; i++){
      for(int j = 1; j<=c; j++){
        char a;
        cin>>a;
        if(a=='#')vec[i][j]=1;
      }
  }
  
  vector<vector<int>> dp(r+1, vector<int>(c+1, 0));
  dp[1][1]=1;
  for(int i = 2; i<=r; i++){
    if(vec[i][1]==1) break;
    else dp[i][1] = 1;
  }
  for(int i = 2; i<=c; i++){
    if(vec[1][i]==1) break;
    else dp[1][i] = 1;
  }
  
  for(int i = 2; i<=r; i++){
     for(int j = 2; j<=c; j++){
       if(vec[i][j]!=1) dp[i][j] = (dp[i-1][j] + dp[i][j-1])%1000000007;
     }
  }
  cout<<dp[r][c]<<endl;  
  
}

Measured memory_bytes: 8192
n = gets.chomp.to_i
as = gets.chomp.split(' ').map(&:to_i)

cs = []
0.upto(10_000){|i| cs << 0}
as.each{|a| cs[a] += 1}
1.upto(cs.length - 1){|i| cs[i] += cs[i - 1]}
s = []
(as.length - 1).downto(0) do |i|
  s[cs[as[i]] - 1] = as[i]
  cs[as[i]] -= 1
end

puts s.join(' ')


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

int main(void){
    long double a,b,ans;
    cin>>a>>b;
    ans = a*b;
    cout<<(long long)ans;
    return 0;
}

Measured memory_bytes: 3732
/*  
     author : hursh29    
     g++ : 17.3.20 
*/        
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << "\n"
#define speedup            ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                998244353
#define pi                 pair<ll,ll>
#define vi                 vector <ll>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; 
const int N = 2e5+7; 
/*   
    time : 17 : 28      
    date : 20.12.2019
*/    

int solve(){ 
	int A,B,C ;
	cin >> A >> B  ;
	A += B ;  
	cout << 6-A ; 
    return 0 ; 
}
int main() { 
	speedup ;  
    int test  = 1 ; 
	//cin >> test  ; 
	while(test--)
    	solve() ; 
	 
	return 0;
} 


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

int main(){
    int a;
    string s;

    cin >> a;
    cin >> s;

    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}

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

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

    long long i,j,k,l,m,n,o,q;

   while(cin>>n>>m){
  j=0;
  for(i=0;i<n;i++){
    cin>>l>>k;
    l*=l;
    k*=k;
  double   p=sqrt(l+k);

  q=ceil(p);
    if(q<=m)j++;
  }
  cout<<j<<endl;
   }
    return 0;
}



Measured memory_bytes: 3768
#include <iostream>

int main(void)
{
    int n;
    std::cin >> n;

    int op = 0;
    for (int i = 0; i < n; ++i)
    {
        int a;
        std::cin >> a;

        int opa = 0;
        while ((a & 1) == 0)
        {
            a >>= 1;
            ++opa;
        }
        if (i == 0)
        {
            op = opa;
        }
        else
        {
            op = std::min<int>(op, opa);
        }
    }

    std::cout << op << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
ll A[MAX_N],cnt[MAX_N];

int main()
{
	ll N,Q;
	cin >> N;
	ll sum = 0;
	rep(i,N)
	{
		cin >> A[i];
		sum += A[i];
		cnt[A[i]]++;
	}
	cin >> Q;
	rep(i,Q)
	{
		ll b,c;
		cin >> b >> c;
		sum -= cnt[b] * b;
		sum += cnt[b] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 5148
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main() {
	ll D, N;
	cin >> D >> N;
	if (D == 0 && N<100) cout << N;
	else if (D == 0 && N == 100) cout << 101;
	else if (D == 1 && N<100) cout << 100 * N;
	else if (D == 1 && N==100) cout << 100 * 101;
	else if (N<100) cout << 10000 * N;
	else cout << 10000 * 101;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

using namespace std;

const int MOD = 1000000007;


map <string, int> m;
int main(){

    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll res = 0;
    for(int bit = 0; bit < (1 << s.size()-1); ++bit)
    {
        ll cnt = 0;
        ll tmp = 0;
        for(int i = 0; i < s.size(); ++i)
        {
            //+をここにいれる
            if(bit & (1 << i))
            {
                tmp *= 10;
                tmp += (s[i] - '0');
                cnt += tmp;
                tmp = 0;
            }
            else
            {
                tmp *= 10;
                tmp += (s[i] - '0');
            }
        }
        cnt += tmp;

        res += cnt;
    }

    cout << res << endl;

    return 0;     
}



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

int diff(int a, int b)
{
  return (a-b>0)?a-b:b-a;
}

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

int main()
{
  int n;
  cin >>n;
  
  int ht[100001];
  for (int i =0 ; i < n; i++) cin >> ht[i];
  //for (int i =0 ; i < n; i++) 
    //cout << ht[i] << "--";
  
  if (n ==1 ){ cout << "0\n"; return 0;}
  int min_cost[100001];
  min_cost[0] = 0;
  min_cost[1] = diff(ht[1],ht[0]);
  if (n == 2) {cout << min_cost[1]; return 0;}
  else
     for (int i=2 ;i < n; i++) {
       min_cost[i] = min(min_cost[i-1] + diff(ht[i],ht[i-1]),
                         min_cost[i-2] + diff(ht[i],ht[i-2]));
      // cout << "\ni = : "<< i << "  mincost = " << min_cost[i];
     }
  cout << min_cost[n-1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
//#define USING_LONG_LONG
#ifdef USING_LONG_LONG
    #define int long long
    const int INF=1001001001001001001ll;
#else
    const int INF=1001001001;
#endif
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREP(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define clr(a) memset((a),0,sizeof(a))
#define CLR(a) memset((a),-1,sizeof(a))
#define each(i,v) for(__typeof((v).begin()) i=(v).begin();i!=(v).end();i++)
#define minv(a,b) (a)=min((a),(b))
#define maxv(a,b) (a)=max((a),(b))
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<string>vs;
typedef pair<int,int>pii;
#define fi first
#define se second
 
int H,W;
int v[200];
int dp[110][110];
int solve(){
    v[0]^=1;v[W-1]^=1;
 
    clr(dp);
 
    for(int i=1;i<=W;i++){
        for(int j=0;j+i<=W;j++){
            if(i==1){
                dp[j][j+i-1]=v[j];
                continue;
            }
            maxv(dp[j][j+i-1],dp[j+1][j+i-1]+(v[j]^1));
            maxv(dp[j][j+i-1],dp[j][j+i-2]+(v[j+i-1]^1));
        }
    }
 
    return dp[0][W-1];
}
 
signed main(){
    cin>>H>>W;
 
    int ans=0;
    rep(i,H){
        rep(j,W)cin>>v[j];
        if(i)rep(j,W)v[j]^=1;
        ans+=solve();
    }
 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3100
n = int(input())
arr = list(map(int,input().split()))
ans = sum(arr)
maxn = 10**5
maxn+=10
freq = [0 for i in range(maxn)]
for i in arr:
    freq[i]+=1
q = int(input())
for i in range(q):
    prev,nx = list(map(int,input().split()))
    p = freq[prev]
    if p==0:
        print(ans)
    else:
        ans-=(p*prev)
        ans+=(p*nx)
        freq[prev] = 0
        freq[nx]+=p
        print(ans)

Measured memory_bytes: 20644
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = $">{ReadLine()}<".ToCharArray();
            var spos = new List<long>();
            for (var i = 0; i < S.Length; ++i)
            {
                if (S[i] == '>' && S[i + 1] == '<') 
                    spos.Add(i + 1);
            }
            var A = new long[S.Length + 1];
            S[0] = '<';
            S[S.Length - 1] = '>';
            foreach(var a in spos)
            {
                A[a] = 0;
                var i = a;
                while (true)
                {
                    if (S[(int)i - 1] == '<')
                        break;
                    A[i - 1] = Max(A[i - 1], A[i] + 1);
                    --i;
                }
                i = a;
                while(true)
                {
                    if (S[(int)i] == '>')
                        break;
                    A[i + 1] = Max(A[i + 1], A[i] + 1);
                    ++i;
                }
            }
            WriteLine(A.Sum() - A[0] - A[S.Length]);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 21984
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
  ll n,k,m;
  cin>>n>>k;
  n=min(n,n%k);
  while(n>=0)
  {
    m=min(n,abs(n-k));
    if(m==n)
      break;
    else
      n=m;
  }      
   cout<<n;
   return 0;  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e9+7;
const ll N = 302;
string s;
ll num[]={0,1,2,3,4,5,6,7,8,9};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	if(s.size()==1){
		cout<<num[s[0]-'0']<<endl;
		return 0;
	}
	ll ans=0;
	ll k=1;
	FOR(i,0,s.size()-1)k*=2;
	FOR(i,0,k){
		ll w=num[s[0]-'0'],p=i;
		FOR(j,1,s.size()){
			if(p%2==0){
				w=w*10+num[s[j]-'0'];
				if(j==s.size()-1)ans+=w;
			}else{
				ans+=w;
				w=num[s[j]-'0'];
				if(j==s.size()-1)ans+=w;
			}
			p/=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll X;
    cin >> X;
    cout << X / 500 * 1000 + X % 500/5 * 5 << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AKCity {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, m;
	    in >> n >> m;
	    out << (n-1) * (m-1) << endl;
	}
};


int main() {
	AKCity solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N,D1,D2,x=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> D1 >> D2;
    if(D1 == D2){
      x++;
    }else{
      x=0;
    }
    if(x==3){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define ft first
#define sd second
#define flag bool fl=true

#define mod 1000003
#define N 100001
#define MX 1000000001
#define MXX 1000000000000000001

#define pb push_back
#define For(i, a, b) for(int i=a;i<=b;i++)
#define T int t, qq=0; cin>>t; while(qq++<t)
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define scarr(array, size) for(int i=0;i<size;i++) cin>>array[i]

#define deg(rad) (rad*180.0)/pi
#define pi acos(-1)
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)


/*
//----------useful_functions----------

long long extended_euclid(ll a, ll b, ll &x, ll &y){//ax+by=c
    if(b==0)
    {
        x=1, y=0;
        return a;
    }

    ll x1, y1;
    ll d=extended_euclid(b, a%b, x1, y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
long long bigMod(ll a, ll b){//(a^b)%mod
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans%mod;
}
long long modInverse(ll a, ll b){//a*x=1 mod b
    ll x, y;
    ll gcd=extended_euclid(a, b, x, y);

    if(gcd==1) return ((x%b)+b)%b;
    else return 1;
}
long long nCr(ll n, ll r){//n<=1e6
    //declare globally-> ll fact[1000001];
    fact[1]=1;
    for(ll i=2;i<1000001;i++)
        fact[i]=(i*fact[i-1])%mod;

    return (fact[n]*modInverse(fact[r], mod)*modInverse(fact[n-r], mod))%mod;
}
long long josephus(ll n, ll k){//k'th person is killed out of n in the circle
    if(n==1) return 1;
    else return (josephus(n-1, k)+k-1)%n+1;
}
vector<int> sieve(ll n){//get primes up to n<=1e6 and the numbers can be handled up to 1e12
    bool fl[n+1];
    vector<int> primes;
    for(int i=0;i<=n;i++) fl[i]=false;

    for(int i=3;i*i<=n;i+=2)
        for(int j=i+i;j<=n;j+=i)
            fl[j]=true;

    primes.pb(2);
    for(int i=3;i<=n;i+=2) if(!fl[i]) primes.pb(i);
    return primes;
}

*/

int main()
{
    int n,ans=0;
    cin>>n;

    map<string, int> m;
    while(n--)
    {
        string s;
        cin>>s;

        auto it=m.find(s);
        if(it==m.end())
        {
            m.insert({s, 1});
            ans=max(ans, 1);
        }
        else
        {
            it->sd++;
            ans=max(ans, it->sd);
        }
    }

    for(auto it=m.begin();it!=m.end();it++)
        if(it->sd==ans) cout<<it->ft<<endl;


//        cout<<"Case "<<qq<<": ";
}


Measured memory_bytes: 19232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




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

    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) {
        int flg = 0;
        rep(l, n) {
            if (flg == 0 && s[l] - '0' == i) flg++;
            else if (flg == 1 && s[l] - '0' == j) flg++;
            else if (flg == 2 && s[l] - '0' == k) {
                // cout << i << j << k << endl;
                flg++;
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384