akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 998244353;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        out.println(n * n);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

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

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

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

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21076
#include <stdio.h>

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	
	int f = a+b+c ;
	scanf("%d",&f);
	
	int z = 22;
	scanf("%d",&z);
	
	if( f >= z){
		printf("bust");
	}
	else{
		printf("win");
	}
		
	return 0;
	
}

Measured memory_bytes: 1692
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<P> v1;
bool used[100005];
int t[2];

int main(){
	int n;
	LL a,b,c;
	int i,j,k;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		v1.push_back(make_pair(a,i*2));
		v1.push_back(make_pair(b,i*2+1));
	}
	sort(v1.begin(),v1.end());
	a=0,b=0;
	for(i=0;i<n;i++){
		a+=v1[i].first;
		if(!used[v1[i].second/2])used[v1[i].second/2]=true,b++;
		t[v1[i].second%2]++;
	}
	if(t[0]>t[1])t[0]=t[1];
	if(b==n && t[0]>0){
		if(v1[n-1].second/2!=v1[n].second/2){
			a+=v1[n].first-v1[n-1].first;
		}else{
			b=a+v1[n].first-v1[n-2].first;
			c=a+v1[n+1].first-v1[n-1].first;
			a=b<c?b:c;
		}
	}
	cout<<a<<endl;
}


Measured memory_bytes: 2420
_ = [int(input()) for __ in range(6)]
N = _[0]
cities = _[1:]

sorted_cities = sorted(cities)
if N % sorted_cities[0] == 0:
    times = N / sorted_cities[0]
else:
    times = (N - N % sorted_cities[0]) / sorted_cities[0] + 1
print(int(times + 4))


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

int main(){
int n,k,q;
cin>>n>>k>>q;
int a[q];
int point[n];
REP(i,n){
  point[i]=k-q;
}
REP(i,q){
  cin>>a[i];
  point[a[i]-1]++;
  
}

REP(i,n){
  if (point[i]>0)
  {
    /* code */
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}


}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    
    int counter = 0;
    for(int i=0; i<n; i++){
        int temp;
        cin >> temp;
        if(temp >= k){
            counter++;
        }
    }

    cout << counter << "\n";
    return 0;
}


Measured memory_bytes: 256
implicit none
integer:: n,i
integer,allocatable:: a(:)
integer:: count(100)
 
read(*,*) n
allocate(a(n))
 
count=0
do i=1,n
read(*,*) a(i)
count(a(i))=1
end do
 
write(*,*) sum(count)
 
end

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    for(int i=0; i<n; i++){
        b.at(a.at(i)-1)=i+1;
    }
    for(int i=0; i<n; i++){
        cout << b.at(i) << " ";
        if(i==n-1){
            cout << endl;
        }
    }
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>

using namespace std;
//vacation
inline long long max(long long a,long long b){ return a>b?a:b; }
long long max_happ(vector< vector<int> > &gain_happ,int N,vector< vector<long long> > &maximize_happ){
    maximize_happ[0][0] = gain_happ[0][0];
    maximize_happ[0][1] = gain_happ[0][1];
    maximize_happ[0][2] = gain_happ[0][2];
    
    for(int i=1;i<N;i++){
            maximize_happ[i][0] = max(gain_happ[i][0]+maximize_happ[i-1][1],gain_happ[i][0]+maximize_happ[i-1][2]);
            maximize_happ[i][1] = max(gain_happ[i][1]+maximize_happ[i-1][0],gain_happ[i][1]+maximize_happ[i-1][2]);
            maximize_happ[i][2] = max(gain_happ[i][2]+maximize_happ[i-1][1],gain_happ[i][2]+maximize_happ[i-1][0]);
    }
    int temp1=max(maximize_happ[N-1][0],maximize_happ[N-1][1]);
    int temp2=max(maximize_happ[N-1][0],maximize_happ[N-1][2]);
    return temp1>temp2?temp1:temp2;
}

int main(){
    int N=0;cin>>N;
    vector< vector<int> > gain_happ(N);vector< vector<long long> > maximize_happ(N);
    for(int i=0;i<N;i++){
        gain_happ[i] = vector<int>(3);maximize_happ[i] = vector<long long>(3);
        scanf("%d %d %d",&gain_happ[i][0],&gain_happ[i][1],&gain_happ[i][2]);
    }

    printf("%d\n",max_happ(gain_happ,N,maximize_happ));

    return 0;
}

Measured memory_bytes: 11136
N, A, B = map(int, input().split())
S = input()
for s in S:
  if s == "a" and A > 0:
    print("Yes")
    A -= 1
  elif s == "a" and B > 0:
    print("Yes")
    B -= 1
  elif s == "b" and B > 0:
    print("Yes")
    B -= 1
  else:
    print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
int A, B;
int main() {
	cin >> A >> B;
	if (((A + B) % 3 == 0)||A%3==0||B%3==0)
		cout << "Possible" << endl;
	else {

		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;



int main()
{
	int L,R;
	cin>>L>>R;
	int ans = 2018;
	int l,r;
	l = L % 2019;
	r = l + (R - L);
	if( r >= 2019){
		ans = 0;
	}else{
		for(int i = l; i <= (r-1);i++){
			for(int j = i + 1;j <= r; j++){
				ans = min(ans,(i*j)%2019);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうなh
signed main(){
    int a,b,c;cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0)cout<<0<<endl;
    else cout<<min({a*b,b*c,c*a})<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    ll n, a, b, ans;
    cin >> n >> a >> b;
    ans = n / (a + b) * a;
    ans += min(n % (a + b), a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int w,s,o,c=0;
	scanf("%d%d",&w,&s);
	for(int x=0;x<=w;x++)
	{
			for(int y=0;y<=w;y++)
            {
            	int o=s-(x+y);
            	if((o>=0)&&(o<=w))
            	c++;
			}  
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    int p = 0;
    int q = 0;
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '0') {
        p++;
      } else {
        q++;
      }
    }
    ans = 2 * Math.min(p, q);
    System.out.println(ans);
  }
}

Measured memory_bytes: 24600
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    d = collections.defaultdict(set)
    kk = None
    for _ in range(n-1):
        a,b = LI()
        kk = [a,b]
        d[a].add(b)
        d[b].add(a)

    tt = True
    gf = collections.defaultdict(bool)
    while tt:
        tt = False
        for k,v in list(d.items()):
            if len(v) == 1:
                vt = list(v)[0]
                if len(d[vt]) == 1:
                    continue
                for vv in d[vt]:
                    if vv == k:
                        continue
                    if vt in d[vv]:
                        d[vv].remove(vt)
                d[vt] = set([k])
                tt = True
            elif len(v) == 0:
                return 'First'
    return 'Second'


print(main())


Measured memory_bytes: 55248
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 5;

ll arr [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n, K;
  cin >> n >> K;

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

  // include some substring, positives from the rest
  ll cur = 0;
  for (int i = 0; i < K; i++) {
    cur += arr[i];
  }
  for (int i = K; i < n; i++) {
    cur += max(0LL, arr[i]);
  }

  ll ans = cur;
  for (int i = K; i < n; i++) {
    cur -= max(0LL, arr[i]);
    cur += arr[i];

    cur -= arr[i - K];
    cur += max(0LL, arr[i - K]);

    ans = max(ans, cur);
  }

  // exclude some substring, positives from the rest
  cur = 0;
  for (int i = K; i < n; i++) {
    cur += max(0LL, arr[i]);
  }
  ans = max(ans, cur);

  for (int i = K; i < n; i++) {
    cur -= max(0LL, arr[i]);
    cur += max(0LL, arr[i - K]);
    ans = max(ans, cur);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
from math import ceil
n, a, b = map(int, input().split())

monster = []
for _ in range(n):
    monster.append(int(input()))

def check(monster, a, b, n):
    temp = []
    for i in range(len(monster)):
        if monster[i] > b * n:
            temp.append(monster[i] - b * n)
    ans = 0
    for t in temp:
        ans += ceil(t / (a - b))
    if ans <= n:
        return True
    return False


l = 0
r = 10 ** 9
ans = float('inf')
while l <= r:
    mid = (l + r) // 2
    if check(monster, a, b, mid):
        ans = min(ans, mid)
        r = mid - 1
    else:
        l = mid + 1
print(ans)

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

int main()
{
  string s;
  getline(cin, s);
  while (getline(cin, s)) {
    string::size_type b = 0, e;
    do {
      e = s.find("Hoshino", b);
      if (e != string::npos) {
	s[e+6] = 'a';
      }
      b = e + 1;
    } while (e != string::npos);
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

        int A = scanner.nextInt();
        int AB = A * (scanner.nextInt());
        int C = scanner.nextInt();
        int CD = C * (scanner.nextInt());

        if (AB > CD) {
            System.out.println(AB);
        } else {
            System.out.println(CD);
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		int m = sc.nextInt();
		int[] R = new int[m];
		
		for(int i=0;i<m;i++) R[i] = sc.nextInt();
		
		int mn = R[0];
		int ret = -1000000001;
		for(int i=1;i<m;i++){
			ret = Math.max(ret, R[i]-mn);
			mn = Math.min(mn, R[i]);
		}
		cout(ret);
	}
	
	
	
	public static boolean isPrime(int n){
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	}
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
	public static void cout(boolean n){
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	}
}

Measured memory_bytes: 100552
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function lineIn(){
		$buf = fgets(STDIN);
		return $this->killNewLine($buf);
	}
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();

		$h = $s[0];
		$w = $s[1];

		$kill_t = "";
		for($i = 0; $i < $w; $i++){
			$kill_t .= ".";
		}

		$g = array();
		for($i = 0; $i < $h; $i++){
			$g[] = $this->lineIn();
		}

		$buf = array();
		foreach($g as $k => $v){
			if($kill_t != $v){
				$buf[] = $v;
			}
		}
		unset($k);
		unset($v);

		$kill_tt = "";
		for($i = 0; $i < count($buf); $i++){
			$kill_tt .= ".";
		}

		$sub = "";
		$p_f = array();
		for($i = 0; $i < $w; $i++){
			for($j = 0; $j < count($buf); $j++){
				$sub .= $buf[$j][$i];
			}
			if($kill_tt == $sub){
				$p_f[] = true;
			}else{
				$p_f[] = false;
			}
			$sub = "";
		}

		for($i = 0; $i < count($buf); $i++){
			for($j = 0; $j < $w; $j++){
				if(!$p_f[$j]){
					echo $buf[$i][$j];
				}
			}
			echo "\n";
		}
	}
}
?>


Measured memory_bytes: 4856
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        String S = reader.next();
        int ans = 0;
        for (int i=0; i<6; i++) if (S.charAt(i) == '1') ans++;
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    string a, b;
    cin >> a >> b;

    cout << b+a; 
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    if(s.equals(s.toUpperCase())){
      System.out.println("A");
    }
    else{
      System.out.println("a");
    }
  }
}

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

/* Many Requirements */

int main(){
    // 入力スタンダード
    int n, m, q;
    cin >> n >> m >> q;

    vector<int> a;
    vector<int> b;
    vector<int> c;
    vector<int> d;

    a.push_back(0);
    b.push_back(0);
    c.push_back(0);
    d.push_back(0);

    for(int i=0; i<q; i++) {
        int ai,bi,ci,di;
        cin >> ai >> bi >> ci >> di;
        a.push_back(ai);
        b.push_back(bi);
        c.push_back(ci);
        d.push_back(di);
    }
    // ***************************************

    int A[n+1];
    for (int i=0; i<n+1; i++){
        A[i] =1;
    }

    long long sumd = 0;
    long long maxsum = 0;
    bool flag = true;

    while(flag){
         /*   ***********************
            cout << "(" ;
            for(int i=1; i<n+1; i++){
                cout << A[i] << ",";
            }
            cout << ") " << endl;
         */

        for(int i=1; i<q+1; i++){
             /* ********************
                cout << "  i=" << i;

                cout << " A[b[i]]=" << A[b[i]] << " A[a[i]]=" << A[a[i]]; 
                cout << " c[i]=" << c[i] << endl;
             */

            if(A[b[i]]-A[a[i]] == c[i]){
                sumd += d[i];
            }
        }

        if(maxsum < sumd){
            maxsum = sumd;
        }
       
        A[n] += 1;
        for(int j=n; j>0; j--){ 
            //　備忘：A_1 <= A_2 <= ... <= A_n の条件を忘れ苦労した
            if(A[j]>m){
                A[j-1] += 1;
                for(int k=j; k<n+1; k++){
                    A[k] = A[j-1];
                }
                if(A[0]==2){
                    flag = false;
                }
            }
        }
        
        sumd = 0;

    }    

    cout << maxsum << endl;

    return 0;
}

Measured memory_bytes: 3580
import bisect
s = input()
t = input()


# analysis on S
ch = [[] for _ in range(26)]
for i, c in enumerate(s):
    ascii = ord(c) - 97
    ch[ascii].append(i)

bi_left = bisect.bisect_left
bi_right = bisect.bisect_right
now = -1
ans = 0
for i, t in enumerate(t):
    ascii = ord(t) - 97
    if len(ch[ascii]) == 0:
        print("-1")
        exit()
    check = bi_right(ch[ascii], now)

    if check == len(ch[ascii]):
        now = ch[ascii][0]
        ans += 1
    else:
        now = ch[ascii][check]

print(ans*len(s)+now+1)


Measured memory_bytes: 7592
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
LL gcd(LL a, LL b){
	while(b){
		LL r=a%b;
		a=b;
		b=r;
	}
	return a;
}
struct Q{
	LL n,d;
	Q(){
		n=0;
		d=1;
	}
	Q(LL a, LL b){
		LL g=1;//gcd(abs(a),abs(b));
		a/=g;
		b/=g;
		if(b<0){
			n=-a;
			d=-b;
		}
		else
		{
			n=a;
			d=b;
		}
	}
	Q(LL a){
		n=a;
		d=1;
	}
	void normalize(){
		LL g=gcd(abs(n),abs(d));
		n/=g;
		d/=g;
	}
};
Q operator +(Q a, Q b){
	return Q(a.n*b.d+b.n*a.d,a.d*b.d);
}
Q operator -(Q a, Q b){
	return Q(a.n*b.d-b.n*a.d,a.d*b.d);
}
Q operator -(Q a){
	return Q(-a.n,a.d);
}
Q operator -(Q a,LL b){
	return a-Q(b,1);
}

Q operator *(Q a, Q b){
	return Q(a.n*b.n,a.d*b.d);
}
Q operator /(Q a, Q b){
	return Q(a.n*b.d,a.d*b.n);
}
Q operator /(Q a, LL b){
	return a*Q(1,b);
}
Q operator *(LL a, Q b){
	return Q(a,1)*b;
}
bool operator ==(Q a, Q b){
	return a.n==b.n&&a.d==b.d;
}
bool operator <(Q a, Q b){
	if(a==b){
		return false;
	}
	if((a.n>=0)!=(b.n>=0)){
		return a.n<b.n;
	}
	if(a.n<0){
		return -b<-a;
	}
	LL an=a.n,ad=a.d,bn=b.n,bd=b.d;
	do{
		LL aq=an/ad;
		LL bq=bn/bd;
		if(aq!=bq){
			return aq<bq;
		}
		an-=aq*ad;
		bn-=bq*bd;
		if(an==0||bn==0){
			return an<bn;
		}
		swap(an,bd);
		swap(bn,ad);
	} while(1);
}
bool operator <=(Q a, Q b){
	return !(b<a);
}
bool operator >(Q a, Q b){
	return b<a;
}
bool operator >=(Q a, Q b){
	return !(a<b);
}
LL w[51];
LL a[51];
LL p[51];
struct Less{
	bool operator()(int i,int j){
		return Q(w[i],a[i])<Q(w[j],a[j]);
	}
};
const int L=50*50*50;
LL dp[L+1];
const LL inf=1LL<<60;
int main() {
	LL N,X,D;
	cin >> N >> X >> D;
	for(int i=1;i<=N;i++){
		cin >> w[i];
		a[i]=1;
		if(i!=1){
			cin >> p[i];
		}
	}
	for(int i=N;i>1;i--){
		a[p[i]]+=a[i];
		w[p[i]]+=w[i];
	}
	for(int i=1;i<=L;i++){
		dp[i]=inf;
	}
	for(int i=1;i<=N;i++){
		int v=50;
		if(i>1){
			v=min(50,(int)D);
		}
		cerr << i << ", " << v << endl;
		int b=1;
		while(v>0){
			int c=min(v,b);
			for(int j=L;j>=c*a[i];j--){
				dp[j]=min(dp[j],dp[j-c*a[i]]+c*w[i]);
			}
			v-=b;
			b*=2;
		}
	}
	vector<int> od;
	for(int i=1;i<=N;i++){
		od.push_back(i);
	}
	sort(od.begin(),od.end(),Less());
	LL ret=0;
	for(int i=0;i<=L;i++){
		if(dp[i]<=X){
			LL s=i;
			LL r=X-dp[i];
			for(auto j:od){
				LL k=r/w[j];
				if(j>1){
					k=min(k,D-50);
				}
				if(k>0){
					s+=k*a[j];
					r-=k*w[j];
				}
			}
			ret=max(ret,s);
		}
	}

	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N,M,X;
  cin >> N >> M >> X;
  int C[N],A[N][M];
  for(int i=0;i<N;i++){
    cin >> C[i];
    for(int j=0;j<M;j++) cin >> A[i][j];
  }
  
  int NN = 1 << N;
  int MinT = 1000000000;
  
  for(int i=0;i<NN;i++){
    int B[M];
    int Total = 0;
    bool ok = true;
    for(int j=0;j<M;j++){
      B[j]=0;
      for(int k=0;k<N;k++){
        if(i & (1<<k)){
          B[j] += A[k][j];
          Total += C[k];
        }
      }
    }
    for(int j=0;j<M;j++) if(X>B[j]) ok = false;
    Total /= M;
    if(ok) MinT = min(Total,MinT);
  }
  if(MinT == 1000000000) cout << -1 << endl;
  else cout << MinT << endl;
  
}


Measured memory_bytes: 3600
N=input()
N=N[::-1]+"0"
ans=0
up=0
for i,n in enumerate(N):
  d=int(n)+up
  if d>5 or (d==5 and i<len(N)-1 and int(N[i+1])>=5):
    ans+=(10-d)
    up=1
  else:
    ans+=d
    up=0
print(ans)

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll int 
#define pi 3.1415926536
using namespace std;
const ll N=55;

void solve()
{ll n,k,m,h,x,y,z,w,mini,maxi=INT_MAX,prev,res;
 cin>>n>>m;
 vector<ll> v(n+1);
 for(ll i=0;i<n;i++)
 cin>>v[i+1];
 vector<ll> adj[n+1];
 for(ll i=0;i<m;i++)
 {
 	cin>>x>>y;
 	adj[x].pb(v[y]);
 	adj[y].pb(v[x]);
 }
 for(ll i=1;i<=n;i++)
 {
 	sort(adj[i].begin(),adj[i].end());
 }
 ll ans=0;
 for(ll i=1;i<=n;i++)
 {
 	if(adj[i].size()==0)
 	ans++;
 	else
 	{
 		x=adj[i].size();
 		if(v[i]>adj[i][x-1])
 		ans++;
	}
 }
 cout<<ans;
}
  
int main()
{
  fast
  //for(ll i=0;i<=9;i++)
  //cal(1,3234566667,i);
  //sort(v.begin(),v.end());
  //pre();
ll t=1;
//cin>>t;
//SieveOfEratosthenes();
//cout<<"ok";
while(t--)
{ //cout<<"ok";

solve();
 //cout<<ma<<endl;
}
return 0;}
/*
ll pr(ll a,ll b,ll c)
{
	if(b==0)
	return 1LL;
	ll ans=1;
	while(b>0)
	{
		if(b%2)
		ans=((ans%c)*(a%c))%c;
		a=((a%c)*(a%c))%c;
		b/=2;
		a%=c;
		ans%=c;
	}
	return ans;
}
vector<ll> fact(N+1);
void pre()
{
	fact[0]=1;
	for(ll i=1;i<=N;i++)
	fact[i]=fact[i-1]*i,fact[i]%=hell;
	
}
*/

Measured memory_bytes: 8780
A,B,C,X,Y=map(int,input().split())
if X>Y:
  answer=min(C*X*2,A*X+B*Y,C*Y*2+A*(X-Y))
elif X<Y:
  answer=min(C*Y*2,A*X+B*Y,C*X*2+B*(Y-X))
else:
  answer=min(C*X*2,A*X+B*Y)
print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,M;

int C;
ll ans=INF;
int cost[3][30];

void dfs(int d,int v1,int v2,ll total){
  if(d==3){
    if(total<ans){
      ans = total;
    }
  }else{
    if(d==0){
      REP(i,0,C){
        dfs(d + 1, i, 0, total + cost[d][i]);
      }
    }else if(d==1){
      REP(i,0,C){
        if(i!=v1){
          dfs(d + 1, v1, i, total + cost[d][i]);
        }
      }
    }else{
      REP(i,0,C){
        if(i!=v1&&i!=v2){
          dfs(d + 1, v1, v2, total + cost[d][i]);
        }
      }
    }
  }
}

int main()
{
  cin>>N;
  cin >> C;
  int D[C][C];
  REP(i,0,C){
    REP(j,0,C){
      cin >> D[i][j];
    }
  }
  map<int, int> d[3];

  REP(i, 0, 3)
  {
    REP(j,0,C){
      d[i][j]= 0;
    }
  }
  REP(i,0,N){
    REP(j,0,N){
      int c;
      
      cin >> c;
      c--;
      d[(i + j + 2) % 3][c]++;
    }
  }
  

  REP(i, 0, 3)
  {
    REP(j,0,C){
      cost[i][j] = 0;
    }
  }

 

  REP(i, 0, 3)
  {
    REP(j,0,C){
      REP(k,0,C){
        cost[i][j] += D[k][j] * d[i][k];
      }
    }
  }

  

  dfs(0, 0, 0, 0);
  cout << ans << endl;

  return 0;
}

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

const int MAX = 200000;

struct Node {
	int n;
	bool isExist; // その頂点をまだ消していないか否か
	vector<int> edge; // 繋がっている頂点
	pair<int, int> node; // 繋がっている'A'と'B'の個数
};

int main() {
	int N, M, a, b;
	string s;
	cin >> N >> M >> s;
	static Node node[MAX];
	for (int i = 0;i < N;++ i) {
		node[i].node = make_pair(0, 0);
		node[i].n = i;
		node[i].isExist = true;
	}
	for (int i = 0;i < M;++ i) {
		cin >> a >> b;
		-- a; -- b;
		node[a].edge.push_back(b);
		node[b].edge.push_back(a);
		s[a] == 'A' ? ++ node[b].node.first : ++ node[b].node.second;
		s[b] == 'A' ? ++ node[a].node.first : ++ node[a].node.second;
	}
	queue<int> que; // 削除する頂点
	for (int i = 0;i < N;++ i) {
		if (node[i].node.first == 0 || node[i].node.second == 0) que.push(i);
	}
	int tmp;
	int del = 0; // 削除した頂点の数
	while (!que.empty()) {
		tmp = que.front();
		que.pop();
		if (!node[tmp].isExist) continue; // 既に削除済み頂点なら無視(BFSなら必ず入れるコードですね)
		node[tmp].isExist = false;
		++ del;
		for (int i = 0, l = node[tmp].edge.size();i < l;++ i) {
			if (!node[node[tmp].edge[i]].isExist) continue;
			s[node[tmp].n] == 'A' ? -- node[node[tmp].edge[i]].node.first : -- node[node[tmp].edge[i]].node.second;
			if (node[node[tmp].edge[i]].node.first == 0 || node[node[tmp].edge[i]].node.second == 0) que.push(node[tmp].edge[i]); // 新しく削除する点
		}
	}
	if (del == N) cout << "No";
	else cout << "Yes";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

解説AC
'A'と'B'の両方に同時に繋がっていない辺を消していくことを繰り返すと解ける
ここで、消した頂点の周囲の頂点以外は繋がってるかの情報が更新されないことを考えると、BFSすれば解ける

*/

Measured memory_bytes: 13956
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

typedef long long LL;

#define BITTYPE LL
#define BITCNT  2
#define BITSIZE 512345
namespace _BIT{
    int i=0;
    BITTYPE t[2][BITSIZE];
    inline BITTYPE* get(){
        return t[i++];
    }
}

struct BIT{

    using T=BITTYPE;
    T *t;
    int n;
    
    BIT(int N):t(_BIT::get()),n(N+1){
        REP(i,n+1)t[i]=0;
    }
 
    void add(int r,T v){//add v for [1,r]
        for(;r;r-=r&-r)t[r]+=v;
    }
 
    void add(int l,int r,T v){//add v for [l,r]
        add(r,v);
        add(l-1,-v);
    }
 
    T get(int i){//get sum[i]
        T res=0;
        for(;i<=n;i+=i&-i)res+=t[i];
        return res;
    }
 
};
LL dp[1000001];

LL mod=1000000007;
LL N;
int main(){
        REP(i,1000001){
            dp[i]=0;
        }
	cin>>N;
	if(N==1){
	   cout<<1<<endl;
	   return 0;
	}
	if(N==2){
	   cout<<4<<endl;
	   return 0;
	}
	dp[0]=(N*N)%mod;
	dp[1]=(dp[0]+N*(N-1))%mod;
	LL sum=dp[1];
	sum%=mod;
	LL ans=sum;
	BIT b(N+10);
	b.add(1,N+5,N);	
	b.add(2,N+5,dp[0]);
	REP(i,N-1){
	    if(i==0)continue;
	    if(i==1)continue;
	    ans=b.get(i-1)+dp[i-1]+N*(N-i)+(i-1)*(N-1);
	    ans%=mod;
	    dp[i]=ans;
	    b.add(i+1,N+5,dp[i-1]);
	}
	/*REP(i,3){
	    cout<<dp[i]<<endl;
	}*/
	
        cout<<ans<<endl;
	return(0);
}

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> dp(n);

    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        //h.push_back(tmp); push_backは末尾に追加
        h[i] = tmp;
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    
    cout << dp[n - 1] << endl;

}



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

int h[10];
int main(){
    for(int i=0;i<10;i++)scanf("%d",&h[i]);
    sort(h,h+10);reverse(h,h+10);
    for(int i=0;i<3;i++)printf("%d\n",h[i]);
    return 0;
}

Measured memory_bytes: 1204
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        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_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)*}
    };

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n],
        es: [(usize1, usize1); n - 1]
    }
    let mut t = vec![vec![]; n];
    for &(a, b) in &es {
        t[a].push(b);
        t[b].push(a);
    }
    let mut mem = vec![0; n];
    println!("{}", if dfs(0, 0, &t, &v, &mut mem) && mem[0] == 0 {"YES"} else {"NO"});
}

fn dfs(v: usize, p: usize, t: &Vec<Vec<usize>>, num: &Vec<usize>, mem: &mut Vec<usize>) -> bool {
    if t[v].len() == 1 && v != p {
        mem[v] = num[v];
        return true;
    }
    let mut m = 0;
    let mut mt = 0;
    for &c in &t[v] {
        if c == p {
            continue;
        }
        if !dfs(c, v, t, num, mem) {
            return false;
        }
        m = max(m, mem[c]);
        mt += mem[c];
    }
    if mt < num[v] || 2 * num[v] < mt || min(mt - m, mt / 2) < mt - num[v] {
        return false;
    }
    mem[v] = 2 * num[v] - mt;
    if v == p && t[v].len() == 1 {
        mem[v] -= num[v];
    }
    true
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        B.at(A.at(i) - 1) = i + 1;
    }
    for(int i = 0; i < N; i++) {
        cout << B.at(i);
        if(i < (N - 1)) cout << " ";
        else cout << endl;
    }
    return 0;
}

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

int main(void) {
    //int N, ans=0;
    int A,B;
    cin >> A >> B;

    cout << A*B << endl;

    return 0;
}


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

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main(){
  ll X;
  cin >> X;
  ll ans = X;
  while(!(is_prime(ans))){
    ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  int N;cin>>N;
  bool can =false;
  for(int i=1;i<10;i++){
    if(N%i==0 && N/i<=9){
      can=true;
      break;
    }
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3584
bool DBG = false;
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using ld = long double;
//using i128 = __int128_t;
//using bint = boost::multiprecision::cpp_int;
//using d1024 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << (x) << (" ")
#define coutn(x) cout << (x) << ("\n")
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define dcouts(x) if(DBG) couts(x)
#define dcoutn(x) if(DBG) coutn(x);
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;



void solve(){
  int n;cin >> n;
  V<int> a(n,0);
  FOR(i,0,n-1){
    int b; cin >> b;
    a[b-1]++;
  }
  FOR(i,0,n) coutn(a[i]);
}




void solved(){
  //
}


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

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

int main(){
	int i;
	string S;
	cin >> S;
	vector<int> num(26, 0);
	for(i = 0; i < S.size(); i++){
		num[(int)(S[i] - 'a')]++;
	}
	for(i = 0; i < 26; i++){
		if(num[i] >= 2){
			printf("no\n");
			return 0;
		}
	}
	printf("yes\n");
	return 0;
}

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

typedef pair<int, int> pii;
int N;
vector<pii> X;
vector<int> arr;

int main() {
    scanf("%d", &N);
    X.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &X[i].first);
        X[i].first--;
        X[i].second = i;
    }

    sort(X.begin(), X.end());

    int lpos = 0, rpos = N*N - 1;
    arr = vector<int>(N*N, -1);

    for(int i = 0; i < N; i++) {
        arr[ X[i].first ] = X[i].second;
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < X[i].second; j++) {
            while(arr[lpos] != -1) lpos++;
            if(X[i].first < lpos) {
                printf("No");
                return 0;
            }
            arr[lpos] = X[i].second;
        }
    }
    for(int i = N - 1; i >= 0; i--) {
        for(int j = 0; j < N - 1 - X[i].second; j++) {
            while(arr[rpos] != -1) rpos--;
            if(rpos < X[i].first) {
                printf("No");
                return 0;
            }
            arr[rpos] = X[i].second;
        }
    }

    printf("Yes\n");
    for(int i = 0; i < N*N; i++) {
        printf("%d ", arr[i] + 1);
    }
}


Measured memory_bytes: 2176
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    //本文
    ll ans = 0;

    for(int i =1;i<N+1;i++){
      ll num = to_string(i).size();
      if(num%2==1){
        ans += 1;
      }
    }
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define p(a, b) make_pair(a, b)

const int use[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
int dp[10][10001];
bool f[10][10001];

bool order(int& a, int& b) { return use[a] != use[b] ? use[a] < use[b] : a > b; }

int main()
{
	int N, M, a;
	vector<int> A;

	cin >> N >> M;
	rep(i, M) {
		cin >> a;
		A.push_back(a);
	}

	sort(A.begin(), A.end(), order);

	/* マッチ本数同じで小さい数は不要なので削除 */
	vector<int>::iterator it = A.begin(); it++;
	int previous = use[A.front()];
	while (it != A.end()) {
		if (use[*it] == previous) it = A.erase(it);
		else { previous = use[*it]; it++; }
	}
	M = A.size();

	if (M == 1) {
		int num = N / use[A[0]];
		rep(i, num) cout << A[0];
		cout << endl;
		return 0;
	}

	sort(A.begin(), A.end());

	rep(i, M) {
		repc(j, 1, N) {
			if (i == 0) {
				if (j % use[A[i]] == 0) {
					dp[i][j] = j / use[A[i]];
					f[i][j] = true;
				}
				continue;
			}

			dp[i][j] = dp[i - 1][j];
			if (j % use[A[i]] == 0 && dp[i][j] <= j / use[A[i]]) {
				dp[i][j] = j / use[A[i]];
				f[i][j] = true;
			}
			if (j > use[A[i]] && dp[i][j - use[A[i]]] != 0 && dp[i][j] <= dp[i][j - use[A[i]]] + 1) {
				dp[i][j] = dp[i][j - use[A[i]]] + 1;
				f[i][j] = true;
			}
		}
	}

	int num = M - 1;

	while (N > 0) {
		if (!f[num][N]) num--;
		else {
			cout << A[num];
			N -= use[A[num]];
		}
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 512
s=input()
s1=int(s[:2])
s2=int(s[2:])

if (s1<=12) & (s1>=1):
  if (s2<=12) & (s2>=1):
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if (s2<=12) & (s2>=1):
    print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

long long int get_k(std::vector<long long int> v, long long int P) {
	long long int c = 1;
	long long int t = 0;
	for (std::vector<long long int>::iterator i = v.begin(); i != v.end(); ++i) {
		if (*i > P)
			return 1000000; // larger than max k
		t += *i;
		if (t > P) {
			c++;
			t = *i;
		}
	}
	return c;
}

long long int binary_search_P(std::vector<long long int> v, long long int l, long long int r, int k) {
	if (l == r)
		return l;
	long long int m = (l + r) / 2;

	if (get_k(v, m) <= k) 
		return binary_search_P(v, l, m, k);
	
	if (get_k(v, m) > k) 
		return binary_search_P(v, m + 1, r, k);
}



int main() {

	int n, k, P(0);
	std::cin >> n >> k;

	std::vector<long long int> v;
	v.resize(n);
	
	for (int i = 0; i < n; i++) {
		std::cin >> v[i];
	}

	long long int P_min = 1;
	long long int P_max = 100000 * 100000;


	P = binary_search_P(v, P_min, P_max, k);

	std::cout << P << std::endl;

	return 0;
}

Measured memory_bytes: 28600