akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
#define fr(i,k,n) for(int i=k;i<n;i++)
#define fl(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
int n,m,x;
cin>>n>>m>>x;
int cost[n]={};
int book[n][m];
for(int i=0;i<n;i++)
{
	cin>>cost[i];
	for(int j=0;j<m;j++)
	cin>>book[i][j];
	//cout<<cost[i]<<" ";
}
//cout<<endl;
int mi=MOD;
for(int i=1;i<(1<<n);i++)
{
	int skill[m]={};
	int l=i;
	int p=0;
	int c=0;
	while(l)
	{
		if(l&1)
		{
			//cout<<cost[p]<<endl;
			c+=cost[p];
			for(int j=0;j<m;j++)
			{
				skill[j]+=book[p][j];
			}
		}
		p++;
		l>>=1;
	}
	//cout<<c<<endl;
	bool flag=0;
	for(int j=0;j<m;j++)
	{
		if(skill[j]<x)
		flag=1;
	}
	if(!flag)
	mi=min(mi,c);
}
if(mi==MOD)
cout<<-1<<endl;
else
cout<<mi<<endl;
}

return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



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

	if (N == 0) {
		cout << 0 << endl;
		return 0;
	}
	
	ll tmp = N;
	vll ans;
	while (tmp != 0) {
		if (abs(tmp) % 2 == 1) {
			--tmp;
			ans.push_back(1);
		}
		else ans.push_back(0);

		tmp /= -2;
	}

	reverse(all(ans));
	rep(i, ans.size()) cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

void main() {
    int n, m;
    int[][] a;

    scan(n, m);
    a = new int[][](n, m);
    iota(n).each!(i => a[i][] = readln.split.to!(int[]));
    iota(n).each!(i => a[i][] -= 1);

    int top = n, btm = 0;

    bool check(int k) {
        int[] cnt = new int[](m);
        bool[] ok = new bool[](m);
        ok[] = true;
        int oknum = m;

        while (oknum > 0) {
            cnt[] = 0;

            foreach (i ; 0 .. n) {
                foreach (j ; 0 .. m) {
                    if (ok[a[i][j]]) {
                        cnt[a[i][j]]++;
                        break;
                    }
                }
            }

            bool flag = true;

            foreach (j ; 0 .. m) {
                if (cnt[j] > k) {
                    ok[j] = false;
                    oknum--;
                    flag = false;
                }
            }

            if (flag) return true;
        }

        return false;
    }

    while (top - btm > 1) {
        int mid = (top + btm) / 2;
        (check(mid) ? top : btm) = mid;
    }

    writeln(top);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

double get_distance(int x1, int y1, int x2, int y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> xy(n);
    rep(i, n) cin >> xy[i].first >> xy[i].second;
    double sum = 0;
    int nb = 1;
    vector<int> k(n);
    rep(i, n) {
        k[i] = i;
        nb *= (i + 1);
    }
    do {
        rep(i, n - 1) {
            sum += get_distance(xy[k[i]].first, xy[k[i]].second, xy[k[i + 1]].first, xy[k[i + 1]].second);
        }
    }
    while(next_permutation(all(k)));
    printf("%.10f\n", sum / nb);
    return 0;
}

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

int main() {
    int n;
    int d,x;
    int a[110];
    cin >> n;
    cin >> d >> x;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int result =0;
    result += x;
    for(int i=0;i<n;i++){
        int count =0;
        for(int j=1;j<=d;j=(count*a[i])+1){
            count++;
        }
        result += count;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int max(int a,int b){
	return a>b?a:b;
}
vector<int>dp(3,0);
int func(){
	vector <int> c(3);
	for(int i=0;i<3;i++)cin>>c[i];
	vector <int> new_dp(3,0);
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(i!=j){
				new_dp[i]=max(new_dp[i],dp[j]+c[i]);
			}
		}
	}
	dp=new_dp;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)func();
	cout<<max(dp[0],max(dp[1],dp[2]));
	cin>>n;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    if (n < 1200)
        cout << "ABC" << endl;
    else if (n < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
}

Measured memory_bytes: 256
A, B, C = gets.chomp.split.map(&:to_i)
K = gets.to_i

is_yes = false
#0.upto(K){ |i|
0.upto(0){ |i|
  a = A * 2**i
  0.upto(K - i){ |j|
    b = B * 2**j
    0.upto(K - i - j){ |k|
      c = C * 2**k
      is_yes = true if a < b && b < c
      break if is_yes
    }
    break if is_yes
  }
  break if is_yes
}

if is_yes
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14408
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	if (s == "AAA" || s == "BBB")
	{
		println("No");
	}
	else
	{
		println("Yes");
	}
}


Measured memory_bytes: 256
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int n, k, x, y;
      
      
    scanf("%d%d%d%d", &n, &k, &x, &y);


    if( n > k ){

        printf("%d\n", x * k + y * ( n - k ) );

        }
   
    else printf("%d\n", x * n );
   

    return 0;
                                                          
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll h,w;
  cin>>h>>w;
  vvc t(h,vc(w));
  vll k(26);
  rep(i,h) rep(j,w) {
    cin>>t[i][j];
    k[t[i][j]-'a']++;
  }
  if(h%2==0&&w%2==0){
    rep(i,26){
      if(k[i]%4!=0){
        COUT("No");
        return 0;
      }
    }
    COUT("Yes");
  }
  else if(h%2==1&&w%2==1){
    ll tate=h-1;
    ll yoko=w-1;
    ll cu=0;
    rep(i,26){
      if(cu*4==tate*yoko) break;
      if(k[i]>=4){
        cu++;
        k[i]-=4;
        i--;
      }
    }
    if(4*cu<tate*yoko) {
     COUT("No");
     return 0;
    }
    cu=0;
    rep(i,26){
      if(cu*2==h+w-2){
        COUT("Yes");
        return 0;
      }
      if(k[i]>=2){
        cu++;
        k[i]-=2;
        i--;
      }
    }
    COUT("No");
  }
  else{
    if(w%2==1) swap(h,w);
    if(h%2==1){
      ll cu=0;
      rep(i,26){
        if(4*cu==w*(h-1)) break;
        if(k[i]>=4){
          cu++;
          k[i]-=4;
          i--;
        }
      }
      if(cu*4<w*(h-1)) {
        COUT("No");
        return 0;
      }
      cu=0;
      rep(i,26){
        if(cu*2==w){
          COUT("Yes");
          return 0;
        }
        if(k[i]>=2){
        cu++;
        k[i]-=2;
        i--;
        }
      }
      COUT("No");
    }
  }
}
        

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=500;
const ll inf=1e18;
const ll mod=1e9+7;

ll dp[MX][MX], sm[MX][MX], a[MX];

ll call(int l, int r)
{
    if(l==r)      return 0;
    if(~dp[l][r]) return dp[l][r];
    ll sum=inf;
    for(int i=l; i<r; i++)
    {
        sum=min(sum, call(l, i)+call(i+1, r)+sm[l][r]);
    }
    return dp[l][r]=sum;
}
int main()
{
    FasterIO;
    int n;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        sm[i][i]=a[i];
        for(int j=i+1; j<=n; j++) sm[i][j]=sm[i][j-1]+a[j];
    }

    mem(dp, -1);

    ll ans=call(1, n);

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


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

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

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

  int alice=0, bob=0;
  for (int i=0; i<a.size(); i++) {
    if (i%2==0) alice+=a[i];
    else bob+=a[i];
  }

  cout << alice-bob;
}

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

struct res
{
	string city;
	int score,id;
};
bool compare(res a, res b)
{
	if (a.city < b.city)return true;
	if (a.city == b.city)return a.score > b.score;
	return false;
}
int main()
{
	res a[104];
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i].city >> a[i].score;
		a[i].id = i + 1;
	}
	sort(a, a + n, compare);
	for (int i = 0; i < n; ++i)cout << a[i].id << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();

    char[] cS = S.toCharArray();
    char[] cT = T.toCharArray();

    int ans = 0;

    for(int i = 0; i < S.length(); i++) {
    	if(cS == cT) {
    		System.out.println(ans);
    		return;
    	}
      	if(cS[i] != cT[i]) {
    		ans++;
    	}
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 41880
use std::cmp;
use std::collections::BinaryHeap;

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    i: usize,
    cost: i64,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> std::cmp::Ordering {
        other.cost.cmp(&self.cost)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = scanner::Scanner::new(stdin.lock());
    let x: usize = sc.read();
    let y: usize = sc.read();
    let z: usize = sc.read();
    let n = x + y + z;
    let mut a: Vec<i64> = vec![];
    let mut b: Vec<i64> = vec![];
    let mut c: Vec<i64> = vec![];
    for _ in 0..n {
        a.push(sc.read());
        b.push(sc.read());
        c.push(sc.read());
    }

    let mut s = (0..n)
        .map(|i| (a[i] - b[i], a[i], b[i], c[i]))
        .collect::<Vec<_>>();
    s.sort();

    let mut heap = BinaryHeap::new();
    let mut b_sum = 0;
    let mut c_sum = 0;
    let mut max_bc = vec![(0, 0); n];
    for (i, &(_, _, b, c)) in s.iter().enumerate() {
        heap.push(State { i: i, cost: b - c });
        b_sum += b;
        if heap.len() == y + 1 {
            let min = heap.pop().unwrap();
            let (_, _, b, c) = s[min.i];
            b_sum -= b;
            c_sum += c;
        }
        max_bc[i] = (b_sum, c_sum);
    }

    let mut heap = BinaryHeap::new();
    let mut a_sum = 0;
    let mut c_sum = 0;
    let mut max_ac = vec![(0, 0); n];
    for (i, &(_, a, _, c)) in s.iter().enumerate().rev() {
        heap.push(State { i: i, cost: a - c });
        a_sum += a;
        if heap.len() == x + 1 {
            let min = heap.pop().unwrap();
            let (_, a, _, c) = s[min.i];
            a_sum -= a;
            c_sum += c;
        }
        max_ac[i] = (a_sum, c_sum);
    }

    let mut ans = 0;
    for i in (y - 1)..n {
        if i + 1 > n - x {
            break;
        }
        let (a, c1) = max_ac[i + 1];
        let (b, c2) = max_bc[i];
        ans = cmp::max(ans, a + b + c1 + c2);
    }
    println!("{}", ans);
}

pub mod scanner {
    use std::fmt::Debug;
    use std::io::Read;
    use std::str::{self, FromStr};

    pub struct Scanner<R: Read> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: Read> Scanner<R> {
        pub fn new(reader: R) -> Self {
            Scanner {
                reader: reader,
                buf: Vec::new(),
            }
        }

        pub fn read<T>(&mut self) -> T
        where
            T: FromStr,
            T::Err: Debug,
        {
            self.buf.clear();
            for c in self
                .reader
                .by_ref()
                .bytes()
                .map(|b| b.unwrap())
                .skip_while(|&b| b == b' ' || b == b'\n')
                .take_while(|&b| b != b' ' && b != b'\n')
            {
                self.buf.push(c);
            }

            unsafe { str::from_utf8_unchecked(&self.buf) }
                .parse()
                .expect("Parse error.")
        }
    }
}


Measured memory_bytes: 21660
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		if(n < 1000){
			System.out.println("ABC");
		} else {
			System.out.println("ABD");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

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

    int n , k;
    cin >> n >> k;

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


    int ans = 0;
    for (int i = 0 ;i <= n ;i++) {
        for (int j = i ;j < n ;j++) {
            int c = i + n - j - 1;
            if (c > k) continue;
            int s = 0;
            priority_queue<int> q;

            for (int k = 0 ;k < n ;k++) {
                if (k < i || k > j) {
                    s += a[k];
                    if (a[k] < 0)
                        q.push(-a[k]);
                }
            }

            int rem = k - c;
            while (rem > 0 && q.size()) {
                s += q.top();
                q.pop();
                rem--;
            }

            ans = max(ans , s);
        }
    }

    if (n <= k) {
        int s = 0;
        priority_queue<int> q;
        for (int i = 0 ;i < n ;i++) {
            s += a[i];
            if (a[i] < 0)
                q.push(-a[i]);
        }

        int rem = k - n;
        while (rem > 0 && q.size()) {
            s += q.top();
            q.pop();
            rem--;
        }

        ans = max(ans , s);
    }

    cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String[] array = scanner.nextLine().split(" ");
        int A = Integer.parseInt(array[0]);
        int B = Integer.parseInt(array[1]);
        int C = Integer.parseInt(array[2]);
        int X = Integer.parseInt(array[3]);
        int Y = Integer.parseInt(array[4]);
        int c2 = C * 2;

        int min =  A * X + B * Y;

        if (X > Y) {
            min = Math.min(min, c2 * Y + A * (X - Y));
            min = Math.min(min, c2 * X);
        } else if (Y > X) {
            min = Math.min(min, c2 * X + B * (Y - X));
            min = Math.min(min, c2 * Y);
        } else {
            min = Math.min(min, c2 * X);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

vector<ll> enumerate_num(ll x){
    vector<ll> res;
    for(ll i = 1; i * i <= x; i++){
        if (x % i == 0){
            res.push_back(i);
            if (i * i != x) res.push_back(x / i);
        }
    }
    sort(all(res));
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> res = enumerate_num(n);
    int ans = 10, sz = res.size();
    int left = 0, right = sz-1;
    while(left <= right){
        string s1 = to_string(res[left]);
        string s2 = to_string(res[right]);
        ans = min(ans, (int)max(s1.size(), s2.size()));
        left++; right--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>

#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
typedef long long ll;

using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    int k;
    cin >> k;
    rep(i,k){
        if(i % 2 == 0){
            if(a%2==1)  a--;
            b += a/2;
            a /= 2;
        }else{
            if(b%2 == 1)b--;
            a += b/2;
            b /=2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define dd double
#define ull unsigned long long
#define mes(x,y) memset(x,y,sizeof(x))
#define si(i) scanf("%d",&i)
#define ss(i) scanf("%s",(i))
#define sd(i) scanf("%lf",&i)
#define INF 0x3f3f3f3f
#define eps 1e-16
#define PI acos(-1)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int maxn=2e9+9;
const int mod=1e9+7;
ll GCD(ll a,ll b) {//最大公约数
    return b == 0 ? a : GCD(b, a % b);
}
int main() {
    //FAST_IO;
    ll n,i;
    while(cin>>n){
        double sum=0,j;
        for(i=0;i<n;i++){\
            cin>>j;
            sum+=(1/j);
        }
        sum=1/sum;
        printf("%.14lf\n",sum);
    }
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)                                                             \
  sort(x.begin(), x.end());                                                    \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y)                                                           \
  cerr << "(" << #x << ", " << #y << ") = "                                    \
       << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int a, b;
  cin >> a >> b;

  cout << a * b << endl;

  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
set <int> v[26];

int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    string s1,s2; cin>>s1>>s2;
    int l1=s1.length(), l2=s2.length();
    for(int i=0;i<l1;i++)
    {
        v[ s1[i] - 'a' ].insert(i);
    }
    ll c = 0, pos = 0;
    for(int i=0;i<l2;i++)
    {
        int j = s2[i] - 'a';
        if(v[j].empty()){ cout<<-1; return 0; } 
        auto it = v[j].lower_bound(pos);
        if( it == v[j].end() ){ c++; pos = 0; }
        pos = *v[j].lower_bound(pos);
        pos++;
    }
    cout<<(ll)c*l1 + pos;
	
	
	return 0;
}


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

using namespace std;

int main() {
	int N, M, answer;
	cin >> N >> M;
	answer = 0;
	answer += (N * (N - 1)) / 2;
	answer += (M * (M - 1)) / 2;
	cout << answer;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int N,x;
  cin>>N>>x;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());

  int sum=0;
  int ans=0;
  for(int i=0;i<N;i++){
    if(i==N-1){
      sum+=a.at(i);
      if(sum==x){
        ans++;
      }
    }else{
      sum+=a.at(i);
      if(sum<=x){
        ans++;
      }else{
        break;
      }
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
program atcoder_express2
  implicit none
  integer :: n, m, q, l, r, t(0:500,0:500), i, j
  t = 0
  read(*,*) n, m, q
  do i = 1, m
    read(*,*) l, r
    t(l,r) = t(l,r) + 1
  end do
  do i = 1, n
    do j = 1, n
      t(i,j) = t(i,j) + t(i,j-1)
    end do
  end do
  do j = 1, n
    do i = 1, n
      t(i,j) = t(i,j) + t(i-1,j)
    end do
  end do
  do i = 1, q
    read(*,*) l, r
    write(*,'(i0)') t(r,r)-t(r,l-1)-t(l-1,r)+t(l-1,l-1)
  end do
  stop
end program atcoder_express2

Measured memory_bytes: 1920
use proconio::{input, marker::Usize1};
use std::cell::RefCell;

fn main() {
    input! {
        n: usize, m: u64, q: usize,
        qs: [(Usize1, Usize1, u64, u64); q]
    }
    let sq = RefCell::new(Vec::new());
    let mut dfs = unsafe { std::mem::uninitialized() };
    let rec = &dfs as *const dyn Fn() -> u64;
    dfs = || unsafe {
        if sq.borrow().len() == n {
            let sq = sq.borrow();
            qs.iter()
                .map(|&(a, b, c, d)| if sq[b] - sq[a] == c { d } else { 0 })
                .sum()
        } else {
            let last = *sq.borrow().last().unwrap_or(&1);
            (last..=m)
                .map(|x| {
                    sq.borrow_mut().push(x);
                    let ret = (*rec)();
                    sq.borrow_mut().pop();
                    ret
                })
                .max()
                .unwrap()
        }
    };
    println!("{}", dfs());
}


Measured memory_bytes: 2156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();

        int t = 0;
        int x = 0;
        int y = 0;

        bool flag = true;

        for (int i = 0; i < n; ++i)
        {
            int t_ = cin.nextInt();
            int x_ = cin.nextInt();
            int y_ = cin.nextInt();

            int tZ = t_ - t;
            int xZ = x_ - x;
            int yZ = y_ - y;

            if (tZ < (Math.Abs(xZ) + Math.Abs(yZ))) { flag = false; break; }

            if (((Math.Abs(xZ) + Math.Abs(yZ)) - tZ) % 2 == 0)
            {
                t = t_;
                x = x_;
                y = y_;
                continue;
            }

            flag = false; break;
        }

        Console.WriteLine(flag ? "Yes" : "No");
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]!=t[i])ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long LL;

const int N = 100;

int n, res;
int a[N], b[N], c[N];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    for(int i = 1; i < n; i++) cin >> c[i];

    for(int i = 1; i <= n; i++)
    {
        res += b[a[i]];
        if(a[i] == a[i - 1] + 1) res += c[a[i] - 1];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#[macro_use]
pub mod basic_stdin {
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    use std::io::stdin;
    use std::io::Read;

    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}

}

#[macro_export]
macro_rules! test_function {
    (func = $func:expr, $($input:expr => $output:expr),* $(,)*) => {
        $(
            assert_eq!($func(std::io::Cursor::new($input)) , $output);
        )*
    };
}

#[macro_export]
macro_rules! input_macro {
    (string = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    (reader = $s:expr, $($r:tt)*) => {
        let reader = std::io::BufReader::new($s);
        let mut bytes = std::io::Read::bytes(reader);
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let stdin = std::io::stdin();
    let ret = solve(stdin.lock());

    println!("{}", ret);
}

fn solve<T: std::io::Read>(reader: T) -> String {
    input_macro! {
        reader = reader,
        a: u64,
        b: u64,
    }

    if a > 8 || b > 8 {
        return String::from(":(");
    }
    return String::from("Yay!");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll h, n, dp[10005];
pi spell[1005];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> h >> n;
	for (ll i = 0; i < n; i++){
		ll a, b;
		cin >> a >> b;
		spell[i] = mp(a, b);
	}
	for (ll i = 0; i < h; i++)dp[i] = inf;
	//~ dp[i] stores the minimum points needed to reach this state
	for (ll i= h-1; i >= 0; i--){//for each possible value
		for (ll j = 0; j < n; j++){//each spell
			dp[i] = min(dp[i], dp[min(i+spell[j].F, h)]+spell[j].S);
		}
	}
	cout << dp[0];
}


Measured memory_bytes: 384
#include <algorithm>

#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>

#include <vector>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const llint mod = 1e9 + 7;
const int MAXN = 321;

llint pot2[MAXN];
int dp[MAXN][MAXN][MAXN]; // rows, columns, rank

llint indep_vects(int dim, int k) {
  llint ans = 1;
  REP(i, k) {
    ans *= (pot2[dim] - pot2[i] + mod) % mod;
    ans %= mod;
  }
  return ans;
}

llint power_mod(llint b, llint e) {
  llint ans = 1;
  llint p2 = b;
  for (; e; e >>= 1) {
    if (e&1) ans = ans*p2 % mod;
    p2 = p2*p2 % mod;
  }
  return ans;
}

llint mod_inv(llint x) {
  return power_mod(x, mod-2);
}

llint k_subspaces(int dim, int k) {
  return (llint)dp[dim][dim][dim-k] * mod_inv( indep_vects(dim, dim-k) ) % mod;
}

int get_matrix_rank(int C[][MAXN], int n) {
  int rank = 0;

  REP(j, n) {
    int tmp_row = -1;
    FOR(i, rank, n) if (C[i][j] != 0) { tmp_row = i; break; }
    if (tmp_row == -1) {
      
    } else {
      REP(k, n) swap(C[rank][k], C[tmp_row][k]);
      assert(C[rank][j] == 1);

      REP(r2, n) if (r2 != rank)
        if (C[r2][j])
          REP(k, n)
            C[r2][k] ^= C[rank][k];
            
      ++rank;
    }
  }

  return rank;
}

int main(void) {
  pot2[0] = 1;
  for (int i = 1; i < MAXN; ++i) pot2[i] = (pot2[i-1] * 2) % mod;

  int n;
  static int C[MAXN][MAXN];
  scanf("%d", &n);
  REP(i, n) REP(j, n) scanf("%d", C[i]+j);

  //  TRACE(n);
  //  TRACE(pot2[0] _ pot2[10]);
  
  //  TRACE(power_mod(2, 0));
  //  TRACE(power_mod(2, 1));
  //  TRACE(power_mod(2, 2));
  //  TRACE(power_mod(2, 3));

  //  TRACE(indep_vects(n, 0));
  //  TRACE(indep_vects(n, 1));
  //  TRACE(indep_vects(n, 2));
  //  TRACE(indep_vects(n, 3));

  //  TRACE(mod_inv(5) _ 5 * mod_inv(5) % mod);

  memset(dp, 0, sizeof dp);
  REP(rows, MAXN-1) {
    dp[rows][0][0] = 1;

    REP(c, MAXN-1) REP(r, MAXN-1) {
      if (dp[rows][c][r] == 0) continue;

      dp[rows][c+1][r+1] += (pot2[rows] - pot2[r] + mod) % mod * (llint)dp[rows][c][r] % mod;
      dp[rows][c+1][r+1] %= mod;

      dp[rows][c+1][r] += pot2[r] * (llint)dp[rows][c][r] % mod;
      dp[rows][c+1][r] %= mod;
    }
  }

  int rankC = get_matrix_rank(C, n);
  //  TRACE(rankC);
  //  TRACE(dp[n][n][n]);

  //  TRACE(k_subspaces(n, 0));
  //  TRACE(k_subspaces(n, 1));
  //  TRACE(k_subspaces(n, 2));
  //  TRACE(k_subspaces(n, 3));

  int kerC = n - rankC;
  llint ans = 0;
  FOR(kerB, 0, kerC+1) {
    llint val = k_subspaces(kerC, kerB);
    val = val*indep_vects(n, n-kerB) % mod;
    val = val*power_mod(pot2[n], kerB) % mod;
    ans = (ans + val) % mod;

    //    TRACE(kerB _ val);
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 129792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int MOD = 1e9 + 7;

ll N,M,K,H,W;

int main(){
    string s, t, u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u) cout << a-1 << " " << b;
    else cout << a << " " << b-1;
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    cout << (a >= b ? "delicious" : b - a <= x ? "safe" : "dangerous") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N){
    if(N == 10 || N == 100 ||N == 1000 ||N == 10000 ||N == 100000){
        cout<<10<<endl; return;
    }
    ll ans = 0;
    while(N > 0){
        ans += N % 10;
        N /=10;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

	public static void main(String[] args)throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		int a ,b,c;
		String str = br.readLine();
		String strARY[] = str.split(" ");
		a= Integer.parseInt(strARY[0]);
		b = Integer.parseInt(strARY[1]);
		c = Integer.parseInt(strARY[2]);
		
		if(a < b && b < c){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int n, q;
    cin >> n >> q;

    vector< pair<int, P> > st;
    rep (i, n)
    {
        int s, t, x;
        cin >> s >> t >> x;
        st.emplace_back(s - x, P{1, x});
        st.emplace_back(t - x, P{-1, x});
    }
    sort(st.begin(), st.end());

    multiset<int> ms;
    int idx = 0;
    rep (i, q)
    {
        int d;
        cin >> d;
        while (idx < st.size() && d >= st[idx].first)
        {
            if (st[idx].second.first == 1)
            {
                ms.insert(st[idx].second.second);
            }
            else
            {
                ms.erase(ms.find(st[idx].second.second));
            }
            ++idx;
        }

        if (ms.empty()) cout << "-1\n";
        else cout << *ms.begin() << "\n";
    }

    return 0;
}



Measured memory_bytes: 15852
s = input()

a = int(s[:2])
b = int(s[2:])

af = False
bf = False
if 1 <= a <= 12:
    af = True
if 1 <= b <= 12:
    bf = True

if af and bf:
    print("AMBIGUOUS")
elif af and not bf:
    print("MMYY")
elif not af and bf:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	int s = (int)S.size();
	string ans = "No";
	for (int i = 0; i < s; i++) {
		if (S == T) ans = "Yes";
		string temp = S.substr(0, s - 1);
		char last = S[s - 1];
		S = last + temp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = n/(a+b);
    long d = n-(a+b)*c;
    System.out.println(c*a+Math.min(a,d));
    
    
  }
}


Measured memory_bytes: 23764
N=int(input())
a=[int(i) for i in input().split()]
D=dict()
for i in range(N):
    if a[i] in D:
        D[a[i]]+=1
    else:
        D[a[i]]=1
ans=0
for num in D:
    if num<=D[num]:
        ans+=D[num]-num
    else:
        ans+=D[num]
print(ans)


Measured memory_bytes: 18164
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int H, W, N;
    cin >> W >> H >> N;
    vector<set<int>> st(H);
    for(int i=0; i<N; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        st[y].insert(x);
    }
    for(int i=0; i<H; i++)
        st[i].insert(W);

    int ans = W;
    int x = 0;
    for(int y=0; y<H; y++){
        for(auto itr=st[y].begin(); itr!=st[y].end(); itr++){
            int xx = (*itr);
            if(xx <= x) continue;
            else{
                ans = min(ans, xx);
                break;
            }
        }
        if(y == H-1) break;
        x++;
        while(st[y+1].find(x)!=st[y+1].end()) x++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 28416
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
typedef long long Long;
typedef long double Double;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  Long n;
  cin >> n;

  int res = 0;
  for (int i = 2; i <= n / i; ++i) {
    if (n % i != 0) continue;
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      ++cnt;
    }
    int tmp = 1;
    while ((tmp + 2) * (tmp + 1) / 2 <= cnt) {
      ++tmp;
    }
    res += tmp;
  }
  res += (n != 1);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
int find(string a){
  	string s=a;
  	reverse(all(a));
  	return s==a;
}
void solve(){
	int a;
	cin>>a;
	string s=to_string(a);
	cout<<(find(s)?"Yes":"No")<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


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

typedef long long ll;
const int N = 110;

int n, k;
int a[N], num;

inline int read () {
	int s = 0, w = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		if(ch == '-') w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}
int main () {
	n = read(), k = read();
	for(int i = 1; i <= k; i ++ ) {
		int m = read();
		for(int j = 1; j <= m; j ++ ) {
			int o = read();
			if(!a[o]) {
				num ++;
				a[o] = 1;
			}
		}
	}
	printf("%d\n", n - num);
	return 0;
}

Measured memory_bytes: 3140
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

//計算量はsqrt(N)
template<typename T>
vector<T> Divisors(T n)
{
    vector<T> result;

    T boundary = sqrt(n);

    for (T i = 1; i <= boundary; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if(i != (n / i) && i * i != n)
                result.push_back(n/i);
        }
    }
    sort(result.begin(),result.end());
    return result;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    vector<ll> x(n+1);
    FOR(i,1,n+1)cin>>v[i];
    vector<ll> ans;
    FORr(i,0,n){
      if(v[i] != x[i]){
        ans.push_back(i);
        vector<ll> d = Divisors(i);
        FOR(j,0,d.size()){
          x[d[j]] = (x[d[j]] + 1)%2;
        }
      }
    }
    cout<<ans.size()<<endl;
    FOR(i,0,ans.size()){
      cout<<ans[i];
      if(i != ans.size()-1)cout<<" ";
      else cout<<endl;
    }
}


Measured memory_bytes: 5108