akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>
#include<unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

struct val{
	int cost,u,t;
};
inline bool operator<(val a,val b){
	return a.cost>b.cost;
}
priority_queue<val>q;
int n,m;
vi col[111111];
unordered_map<int,vi>g[111111];
unordered_map<int,int>dp[111111];

int I_Love_Hashimoto_Kanna() {
  fastio;
  n=read();
  m=read();
  FOR(i,0,m){
  	int a=read()-1,b=read()-1,c=read();
  	col[a].push_back(c);
		col[b].push_back(c);
		g[a][c].push_back(b);
		g[b][c].push_back(a);
	}
	q.push({0,0,0});
	dp[0][0]=0;
	while(!q.empty()){
		int cost=q.top().cost;
		int u=q.top().u;
		int t=q.top().t;
		q.pop();
		if(dp[u][t]!=cost)continue;
		if(dp[u].find(0)==dp[u].end()||dp[u][0]>cost){
			dp[u][0]=cost;
			q.push({cost,u,0});
		}
		if(t==0){
			FOR(i,0,col[u].size()){
				int cc=col[u][i];
				if(dp[u].find(cc)==dp[u].end()||dp[u][cc]>cost+1){
					dp[u][cc]=cost+1;
					q.push({cost+1,u,cc});
				}
			}
			continue;
		}
		FOR(i,0,g[u][t].size()){
			int to=g[u][t][i];
			if(dp[to].find(t)==dp[to].end()||dp[to][t]>cost){
				dp[to][t]=cost;
				q.push({cost,to,t});
			}
		}
	}
	int ans=inf;
	for(unordered_map<int,int>::iterator itr=dp[n-1].begin();itr!=dp[n-1].end();itr++){
		ans=min(ans,itr->second);
	}
	if(ans==inf)Tone(-1)
	else Tone(ans) 
	
  
  return 0;
}


Measured memory_bytes: 81684
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin>>s;
	if(s=="SUN"){
		cout<<7<<"\n";
	}else if(s=="MON"){
		cout<<6<<"\n";

	}else if(s=="TUE"){
		cout<<5<<"\n";

	}else if(s=="WED"){
		cout<<4<<"\n";

	}else if(s=="THU"){
		cout<<3<<"\n";

	}else if(s=="FRI"){
		cout<<2<<"\n";

	}else if(s=="SAT"){
		cout<<1<<"\n";

	}
}

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

int main(){
  int N;
  cin >> N;
  N %= 10;
  if(N==3) cout << "bon" << endl;
  else if(N==0 || N==1 || N==6 || N==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}


Measured memory_bytes: 3632
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
  int n;
  cin >> n;
  if(n%1000 == 0)
    cout << 0;
  else
    cout << 1000 - (n%1000);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3648
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n:i32 = read();
    let mut sn :Vec<i64> = Vec::new();
    for _ in 0..n{
        sn.push(read::<i64>());
    }
    let sum:i64 = sn.iter().sum();
    let ans  = if sum % 10 == 0{
        let mut  sub = sn.iter().filter(|&&x| x % 10 != 0).collect::<Vec<&i64>>();
        sub.sort();
        match sub.len() {
            0 => 0,
            _ => sum - sub[0],
        }
    } else {
        sum
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as MA
import qualified Data.List as L
import Data.Vector as V

main = do
    as1<- fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine
    as2 <- fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine
    as3 <- fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine
    let as = fromList $ as1 L.++ as2 L.++ as3
    (n, _) <- MA.fromJust . BS.readInt <$> BS.getLine
    xs <- V.fromList . fmap (fst . MA.fromJust . BS.readInt) .BS.lines <$> BS.getContents
    let ixs = V.findIndices (\x -> V.elem x xs) as
    let ys = V.update_ (V.fromList $ L.replicate 9 False) ixs (V.fromList (L.replicate (V.length ixs) True))
    let row1 = ys ! 0 && ys ! 1 && ys ! 2
    let row2 = ys ! 3 && ys ! 4 && ys ! 5
    let row3 = ys ! 6 && ys ! 7 && ys ! 8
    let col1 = ys ! 0 && ys ! 3 && ys ! 6
    let col2 = ys ! 1 && ys ! 4 && ys ! 7
    let col3 = ys ! 2 && ys ! 5 && ys ! 8
    let dia1 = ys ! 0 && ys ! 4 && ys ! 8
    let dia2 = ys ! 2 && ys ! 4 && ys ! 6
    putStrLn $ if row1 || row2 || row3 || col1 || col2 || col3 || dia1 || dia2 then "Yes" else "No"


Measured memory_bytes: 508
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	x := readInt()

	m := make(map[int]int)
	for i := 0; i < 10001; i++ {
		t := int(math.Pow(float64(i), 5))
		m[t] = i
		m[-t] = -i
	}

	for b5, b := range m {
		a5 := x + b5
		if a, ok := m[a5]; ok {
			fmt.Println(a, b)
			return
		}
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 2520
n = int(input())
s = list(input())

res = 0
for i in range(1, n):
    s1 = set(s[:i])
    s2 = set(s[i: n])
    cnt = 0
    for i in s1:
        if i in s2:
            cnt += 1
    res = max(res, cnt)
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int cnt,i;
string s;
int main(){
	cin>>s;
	i=1;
	while(s.length()>2&&i<s.length()-1){
		int l=s.length();
		if(s[i-1]!=s[i+1]){
				s.erase(s.begin()+i);
				cnt++;
				i=1;
			}
		else i++;
	}
	if(cnt&1)cout<<"First";
	else cout<<"Second";
	return 0;
}

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

int main(){
  int i,count=0,ans=0;
  char  c[11];
  for(i=0;i<11;i++){
    cin >> c[i];
    if(c[i] == 'A' || c[i] == 'C' || c[i] == 'G' || c[i] == 'T' || c[i] == ' '){
      count++;
    }else{
      if(count > ans){
        ans = count;
        count = 0;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
N, = map(int, input().split())
R = 0
for _ in range(N-1):
    a, b = map(int, input().split())
    a, b= min(a,b), max(a,b)
    R += a*(N-b+1)
S = 0
for i in range(N):
    S += (i+1)*(N-i)
print(S-R)


Measured memory_bytes: 69704
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffor(i,a,b) for(ll i=a;i<=b;i++)
#define rfor(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9+7;
const ll N = 1e6+6;
const ll maxN = 1e7+7;
const ll MAX_SIZE = 2e5 + 5;

ll powerM(ll x,ll y, ll M = MOD) // default argument
{ll v=1; x=x%M; while(y>0){if(y&1)v=(v*x)%M;y = y>>1;x=(x*x)%M;} return v;}

ll power(ll x,ll y)
{ll v=1; x=x; while(y>0){if(y&1)v=(v*x);y = y>>1;x=(x*x);} return v;}

int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("input2.txt", "r", stdin);
    	freopen("output2.txt", "w", stdout);
	#endif
	FIO
	ll n; cin>>n;
	ll ar[n];
	FOR(i,n) cin>>ar[i];
	sort(ar,ar+n);
	ll ans=ar[n-1];
	ll m=n-1;
	ll i=n-2;
	while(m>2){
		ans += 2*(ar[i]);
		i--;
		m-=2;
		if(m == 1){
			break;
		}
		else if(m == 2){
			ans += ar[i]; break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#define INF 1000000000000000000
#define int long long
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef pair<int,pa> pp;

signed main(){
	vector<LL> se1,se2;
	vector<pp> ans;
	LL W,H,N;
	cin>>W>>H>>N;
	LL a,b,ha[4]={-INF,INF,-INF,INF};
	for(int i=0;i<N;i++){
		cin>>a>>b;
		ha[0]=max(ha[0],a+b);
		ha[1]=min(ha[1],a+b);
		ha[2]=max(ha[2],a-b);
		ha[3]=min(ha[3],a-b);
		se1.push_back(a);
		se2.push_back(b);
	}
	sort(se1.begin(),se1.end());
	sort(se2.begin(),se2.end());

	bool fla=false;
	int hog,hog2;
	LL sum=0,sum2=0;
	if(se1.size()%2){
		hog=se1.size()/2;
		for(int i=0;i<se1.size();i++){
			sum+=abs(se1[hog]-se1[i]);
		}
		fla=false;
	}
	else{
		hog2=se1.size()/2;
		hog=hog2-1;
		for(int i=0;i<se1.size();i++){
			sum+=abs(se1[hog]-se1[i]);
			sum2+=abs(se1[hog2]-se1[i]);
		}
		fla=true;
	}
	bool fla2=false;
	int hog3,hog4;
	LL sum3=0,sum4=0;
	if(se2.size()%2){
		hog3=se2.size()/2;
		for(int i=0;i<se2.size();i++){
			sum3+=abs(se2[hog3]-se2[i]);
		}
		fla2=false;
	}
	else{
		hog4=se2.size()/2;
		hog3=hog4-1;
		for(int i=0;i<se2.size();i++){
			sum3+=abs(se2[hog]-se2[i]);
			sum4+=abs(se2[hog2]-se2[i]);
		}
		fla2=true;
	}
	
	if(fla&&fla2) ans.push_back(pp((sum2+sum4)*2,pa(se1[hog2],se2[hog4])));
	if(fla) ans.push_back(pp((sum2+sum3)*2,pa(se1[hog2],se2[hog3])));
	if(fla2) ans.push_back(pp((sum+sum4)*2,pa(se1[hog],se2[hog4])));
	ans.push_back(pp((sum+sum3)*2,pa(se1[hog],se2[hog3])));

	LL tmp=-INF;
	for(auto it=ans.begin();it!=ans.end();it++){
		tmp=0;
		tmp=max(tmp,ha[0]-(it->second.first+it->second.second));
		tmp=max(tmp,-ha[1]+(it->second.first+it->second.second));
		tmp=max(tmp,ha[2]-(it->second.first-it->second.second));
		tmp=max(tmp,-ha[3]+(it->second.first-it->second.second));
		it->first-=tmp;
	}
	sort(ans.begin(),ans.end());
	cout<<ans[0].first<<endl<<ans[0].second.first<<" "<<ans[0].second.second<<endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>s(1,0);
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        s.push_back(t);
    }
    for(int i=1;i<=n;i++){
        int v=s[i];
        int j=i-1;
        while(j>0&&s[j]>v){
            s[j+1]=s[j];
            j--;
        }
        s[j+1]=v;
        for(int i=1;i<=n;i++){
            cout<<(i==1?"":" ")<<s[i];
        }
        cout<<endl;
    }
}


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


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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int k;
	while (cin >> k, k) {
		int n = 32, a[30];
		for (int i = 0; i < k; i++)cin >> a[i];
		for (int i = 0; n; i++) {
			int p;
			p = (n - 1) % 5;
			n -= p;
			cout << n << endl;
			p = a[i%k];
			n -= p
				; if (n < 0)n = 0; cout << n << endl;
		}
	}
}

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

int main()
{
  int N ;
  cin>>N ;
  int64_t sum=0 ; 
  vector<int>A(N+2,0) ;
  for(int i=1;i<N+1;i++){
    cin>>A.at(i) ;
    sum+=(A.at(i)>A.at(i-1)?A.at(i)-A.at(i-1):A.at(i-1)-A.at(i)) ;
  }
  sum+=(A.at(N)>0?A.at(N):-A.at(N)) ;
  
  /*観光地iを訪れるのをやめると仮定する*/
  for(int i=1;i<N+1;i++){
    int64_t plus=(A.at(i+1)>A.at(i-1)?A.at(i+1)-A.at(i-1):A.at(i-1)-A.at(i+1)) ;
    int64_t minus=(A.at(i)>A.at(i-1)?A.at(i)-A.at(i-1):A.at(i-1)-A.at(i)) ;
    minus+=(A.at(i+1)>A.at(i)?A.at(i+1)-A.at(i):A.at(i)-A.at(i+1)) ;
    cout<<sum+plus-minus<<endl ;
  }
  
  return 0 ;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define P pair<int,string>
int main(){
    int a,b;
    cin>>a>>b;
    int ans=1;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    b-=a;
    a--;
    while(b>0){
        b-=a;
        ans++;
    }
    cout<<ans<<endl;

}


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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if(a*n > b) cout << b << endl;
    else cout << a*n << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a*c <= b ? c : b / a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const int LLINF = 1e18 + 1;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    int ans = 0;
    for(int i = 0; i < N; i+=K-1) {
        ans++;
        if(i + K >= N) break;
    }

    cout << ans << endl;

    return 0;
}

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

using ll = int64_t;
const int MAX = 2e5;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    if (n%1000) cout << 1000 - n%1000;
    else cout << 0;
    


    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

set<string> st;
int n;
void dfs(string s = "", int num = 0) {
  if(SZ(s) == n) {
    st.insert(s);
    return;
  }
  rep(i, num) dfs(s+char('a'+i), num);
  dfs(s+char('a'+num), num+1);
}

int main()
{
  cin >> n;
  dfs();
  for(auto s : st) cout << s << endl;
}


Measured memory_bytes: 12564
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    var ans = 0L
    var cntA = 0
    var cur = 0
    while (cur < s.size - 1) {
        if (s[cur] == 'A') {
            cntA++
            cur++
            continue
        }

        if (cntA > 0 && s[cur] == 'B' && s[cur + 1] == 'C') {
            ans += cntA
            cur += 2
            continue
        }

        cntA = 0
        cur++
    }
    println(ans)
}


Measured memory_bytes: 34124
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<18;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	ll ans = 0;
	cin >> s;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		ll sum = 0;
		for(int j = i; j < n; j++) {
			sum = 10*sum + (s[j] - '0');
			ans += sum<<(n-1 - (j-i) - (i!=0) - (j+1!=n));
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
import collections
City = collections.namedtuple("City", ("number", "pref", "year"))

n, m = [int(i) for i in input().split()]
cities = []
for i in range(m):
    pref, year = input().split()
    city = City(i, int(pref), int(year))
    cities.append(city)
id_numbers = []
cities.sort(key=lambda x: x.year)
cities.sort(key=lambda x: x.pref)
prev_pref = None
for city in cities:
    if prev_pref is None or city.pref != prev_pref:
        rank = 1
    else:
        rank += 1
    id_numbers.append((city.number, city.pref, rank))
    prev_pref = city.pref
id_numbers.sort(key=lambda x: x[0])
for i in id_numbers:
    print("{:0>6}{:0>6}".format(i[1], i[2]))


Measured memory_bytes: 86104
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function that returns true if n 
// is prime else returns false 
bool isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) return false; 
	if (n <= 3) return true; 
	
	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n%2 == 0 || n%3 == 0) return false; 
	
	for (int i=5; i*i<=n; i=i+6) 
		if (n%i == 0 || n%(i+2) == 0) 
		return false; 
	
	return true; 
} 

// Function to return the smallest 
// prime number greater than N 
int nextPrime(int N) 
{ 

	// Base case 
	if (N <= 1) 
		return 2; 

	int prime = N; 
	bool found = false; 

	// Loop continuously until isPrime returns 
	// true for a number greater than n 
	while (!found) { 
		 

		if (isPrime(prime)) 
			found = true; 
			else
			prime++;
	} 

	return prime; 
} 

// Driver code 
int main() 
{ 
    int N;
    cin>>N;

	cout << nextPrime(N); 

	return 0; 
} 


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

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

int main(){
    int N;
    int t[102],v[102];
    cin >> N;

    t[0]=0;
    for(int i=1;i<=N;i++){
        cin >> t[i];
        if(i>1) t[i]=t[i]+t[i-1];
    }
    v[0]=v[N+1]=0;
    for(int i=1;i<=N;i++) cin >> v[i];

    double vmax[50000],vmaxR[50000];
    vmax[0]=0.0;
    for(int i=1;i<=N;i++){
        int cur_t=t[i-1]*2+1;
        for(int j=cur_t;j<=t[i]*2;j++){
            vmax[j]=min(v[i],vmax[j-1]+0.5);
        }
    }

    vmaxR[t[N]]=0;
    for(int i=N;i>=1;i--){
        int nt=t[i-1]*2;
        for(int j=t[i]*2-1;j>=nt;j--){
            vmaxR[j]=min(v[i],vmaxR[j+1]+0.5);
        }
    }

    for(int i=0;i<=t[N]*2;i++){
        vmax[i]=min(vmax[i],vmaxR[i]);
    }

    double x=0;
    for(int i=1;i<=t[N]*2;i++){
        x+=(vmax[i]+vmax[i-1])/4.0;
    }

    cout << fixed << setprecision(9) << x << endl;

    return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
void solve(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}

int main(){
    solve();
    return 0;
}



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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int n, a[110];

int main()
{
	gi(n);
	for (int i = n; i; --i) gi(a[i]);
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int len = a[1];
	int mn = len / 2 + 1;
	for (int i = len; i > len / 2; --i)
	{
		int cnt = 0;
		for (int j = 1; j <= n; ++j)
		{
			if (a[j] == i) ++cnt, a[j] = 0;
			if (cnt == 2) break;
		}
		if (cnt < 2)
		{
			puts("Impossible");
			return 0;
		}
	}
	if (!(len & 1))
	{
		mn = len / 2;
		int cnt = 0;
		for (int j = 1; j <= n; ++j)
		{
			if (a[j] == (len >> 1)) ++cnt, a[j] = 0;
			if (cnt == 1) break;
		}
		if (cnt < 1)
		{
			puts("Impossible");
			return 0;
		}
	}
	for (int i = 1; i <= n; ++i)
		if (a[i] && a[i] <= mn)
		{
			puts("Impossible");
			return 0;
		}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll Amax=0;
  rep(i,N){
    cin>>A.at(i);
    Amax=max(Amax,A.at(i));
  }
  vector<bool> dp(Amax+1);
  rep(i,Amax+1){
    dp.at(i)=true;
  }
  sort(A.begin(),A.end());
  rep(i,N){
    for(ll j=2;j<=Amax/A.at(i);j++){
      dp.at(j*A.at(i))=false;
    }
    if(i>=1&&A.at(i-1)==A.at(i))dp.at(A.at(i))=false;
    else if(i<N-1&&A.at(i)==A.at(i+1))dp.at(A.at(i))=false;
  }
  ll ans=0;
  rep(i,N){
    if(dp.at(A.at(i))==true)ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
    int n;cin>>n;

    multiset<LL> s; 

    REP(i,n){
        LL a;cin>>a;
        auto itr = s.lower_bound(a);
        if(itr == s.begin()){
            s.insert(a);
        }
        else{
            s.erase(--itr);
            s.insert(a);
        }
    }

    cout<<s.size()<<endl;

    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

ll n, x, ans;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> x;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;
    for (int i = 1; i < n; ++i) {
        if (a[i] + a[i - 1] > x) {
            int eat = min(a[i], a[i] + a[i - 1] - x);
            a[i] -= eat;
            ans += eat;
        }
    }
    if (a[0] + a[1] > x) {
        ans += a[0] + a[1] - x;
    }
    cout << ans;
}




Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int num, minn, maxn; long long sum = 0;
    int arr[10001];
    cin>>num;

    for(int i = 0; i<num; i++)
    {
        cin>>arr[i];
        minn = maxn = arr[0];

        sum = sum + arr[i];
    }

    for(int j = 1; j<num; j++)
    {
        if(arr[j] < minn)
            minn = arr[j];

        if(arr[j] > maxn)
            maxn = arr[j];

    }
    cout<<minn<<" "<<maxn<<" "<<sum<<endl;

    return 0;
}




Measured memory_bytes: 3128
using System;
using System.Linq;

namespace C_MaxValue
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] B = Console.ReadLine()
                                .Split(' ')
                                .Select(s => int.Parse(s))
                                .ToArray();
            int sumA = 0;
            for (int i = 1; i < N - 1; i++)
            {
                sumA += Math.Min(B[i - 1], B[i]);
            }
            sumA += B[0];
            sumA += B[N - 2];
            Console.WriteLine(sumA);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 110
typedef struct
{
    int x,y,z;
}Node;
Node e[N];
int a[N];
int main()
{
    int i,j,k,n,s,x,y,d,flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].z);
    s=0;
    for(i=0;i<=100;i++)
    for(j=0;j<=100;j++)
    {
        for(k=0;k<n;k++)
        {
           if(e[k].z==0)
                continue;
           d=e[k].z+abs(e[k].x-i)+abs(e[k].y-j);
           break;
        }
        flag=0;
        for(k=0;k<n;k++)
        if(e[k].z!=max(d-abs(e[k].x-i)-abs(e[k].y-j),0))
        {
            flag=1;
            break;
        }
        if(flag)
            continue;
        if(d>s)
        {
            s=d;
            x=i;
            y=j;
        }
    }
    printf("%d %d %d\n",x,y,s);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int z[150],x[150];
int main()
{
    memset(z,-1,sizeof(z));
    memset(x,-2,sizeof(x));
  int a,b,c,d;
    cin>>a>>b>>c>>d;
    int l=0;
    for(int i=a;i<b;i++)
    {
        z[i]=1;
    }
     for(int i=c;i<d;i++)
    {

        x[i]=1;
    }
    for(int i=0;i<=100;i++)
    {
        if(z[i]==x[i])l++;
    }
    printf("%d\n",l);
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <queue>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define fst first
#define snd second
#define SZ(x) ((int)x.size())
typedef long long ll;
#define dforn(i, n) for(int i = n - 1; i >= 0; i--)

const int MAXN = 200050;

int n, A[MAXN], ans, where[MAXN];

int main() {
    //~ freopen("input.in", "r", stdin);
    while( scanf("%d", &n) >= 1 ){
        forn(i, n){
            scanf("%d", &A[i]);
            --A[i];
            where[A[i]] = i;
        }
        int last = -1;
        int sz = 0;
        int mxsz = 1;
        forn(i, n){
            if(where[i] > last){
                sz++;
                mxsz = max(mxsz, sz);
            } else {
                sz = 1;
            }
            last = where[i];
        }
        printf("%d\n", n-mxsz);
    }
    return 0;
}


Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<int>v(N + 2);
	for (int i = 1; i <= N; i++)cin >> v[i];
	cin >> K;
	N += 2;
	vector<int>bef(N);
	bef[0] = M;
	for (int i = 1; i < N; i++) {
		bef[i] = min(bef[i - 1], abs(bef[i - 1] - v[i - 1]));
	}
	vector<int>fmin(N);
	fmin.back() = 1;
	for (int i = N - 2; i >= 0; i--) {
		fmin[i] = fmin[i + 1] + v[i];
		if (2 * fmin[i + 1] <= v[i])fmin[i] = fmin[i + 1];
	}
	for (int i = 0; i < K; i++) {
		cin >> M;
		if (bef[M] >= fmin[M+1])cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int c[10002];
int p[101][101];
int main(void){
   int h,w,n;
   cin>>h>>w>>n;
   for(int i=1;i<=n;i++){
       cin>>c[i];
   }
   int x=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i%2==0)p[i][j]=x;
            else p[i][w-j-1]=x;
            if(--c[x]==0)x++;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<p[i][j];
            if(j!=w-1)cout<<' ';
        }
        cout<<endl;
    }
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var ABCD = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (ABCD[0] + ABCD[1] > ABCD[2] + ABCD[3])
        {
            Console.WriteLine("Left");
        }
        else if (ABCD[0] + ABCD[1] == ABCD[2] + ABCD[3])
        {
            Console.WriteLine("Balanced");
        }
        else
        {
            Console.WriteLine("Right");
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

#define N 100000
int S[N],T[N],count=0,n,q,i,j,minj,temp,left,right,mid;

int binarySearch(int key){
  left = 0;
  right = n;
  while(left<right){
    mid = (left+right)/2;
    if(S[mid] == key){
      return 1;
    }else if(key < S[mid]){
      right = mid;
    }else{
      left = mid + 1;
    }
  }
  return 0;
}


int main(){

  scanf("%d",&n);
  i=0;
  while(i<n){
    scanf("%d",&S[i]);
    i++;
  }

  scanf("%d",&q);
  i=0;
  while(i<q){
    scanf("%d",&T[i]);
    if(binarySearch(T[i])==1){
      count++;
    }
    i++;
  }
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 3344
#include<stdio.h>

int main()
{
    char buffer[6];
    int i, j, n, rank, suit_int;
    char suit_char;
    int cards[4][13]={0};
    fgets(buffer, 4, stdin);
    sscanf(buffer, "%d", &n);
    for(i=0;i<n;i++)
    {
        fgets(buffer, 6, stdin);
        sscanf(buffer, "%c %d", &suit_char,&rank);
        switch(suit_char)
        {
            case 'S':
            suit_int = 0;
            break;
            case 'H':
            suit_int = 1;
            break;
            case 'C':
            suit_int = 2;
            break;
            case 'D':
            suit_int = 3;
            break;
            default:
            fprintf(stderr, "undefined");
            return(1);
        }
        cards[suit_int][rank-1] = 1;
    }
    for(i=0;i<4;i++)
    {
        suit_int = i;
        switch(suit_int)
        {
        case 0:
             suit_char = 'S';
             break;
        case 1:
             suit_char = 'H';
             break;
        case 2:
             suit_char = 'C';
             break;
        case 3:
             suit_char = 'D';
             break;
        default:
             fprintf(stderr, "undefined");
             return(1);
        }
        for(j=0;j<13;j++)
        {
            if(!cards[suit_int][j])
            {
                printf("%c %d\n", suit_char, j+1);
            }
        }
    }
    return(0);
}


Measured memory_bytes: 2036
#include<iostream>

using namespace std;
int main()
{
	long long n,m,a[55],b[55],c[55],d[55];
	cin >> n >> m;
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0; i<m; i++){
		cin >> c[i] >> d[i];
	}
	int ans;
	for(int i=0; i<n; i++){
		long long len = 2e9;
		for(int j=0; j<m; j++){
			if((abs(a[i] - c[j]) + abs(b[i] - d[j])) < len){
				len = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}


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


def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    # AB = sorted(list(zip(A,B)),key=lambda x: -x[0]/x[1])

    # dp[i][j] i番目までの技からいくつか選んで体力H以下にするときの最小MP

    dp = [[10**9]*(H+10**4+1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][0] = 0

    for i in range(N):
        for h in range(H+10**4+1):
            if h - A[i] >= 0:
                dp[i+1][h] = min(dp[i+1][h-A[i]]+B[i],dp[i][h])
            else:
                dp[i+1][h] = dp[i][h]
 

    answer = 10**9
    for i in range(H,H+10**4+1):
        answer = min(answer,dp[-1][i])
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 189724
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
#Ai<Biを満たすものを数える、このときsum(Ai)<sum(Bi)であれば、Ai>BiのもののうちAi-Biが最大のものを探し出して
#sum(Ai)+Ai-bi >= sum(Bi) になるか確かめる
smallA = []
equalA = []
largeA = []

for i,a in enumerate(A):
    if a < B[i]:
        smallA.append(B[i] - a)#差を入れる
    elif a == B[i]:
        equalA.append(a)
    else:
        largeA.append(a - B[i])#差を入れる

if smallA == []:
    print(0)
else:
    sumsmallA = sum(smallA)
    largeA.sort(reverse=True)#降順
    c = 0
    enable = True
    count = len(smallA)

    while True:
        if sumsmallA - c > 0:
            if len(largeA) > 0:
                c += largeA.pop(0)
                count+=1
            else:
                enable=False
                break
        else:
            break
    if enable==True:
        print(count)
    else:
        print(-1)

Measured memory_bytes: 19508
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define devugv(v)               for (auto& x: v) cerr << x << " "; cerr << '\n';
#define debugvp(v)              for (auto& x: v) cerr << x.fi << " - " << x.se << '\n';
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

typedef long long i64; 
typedef vector< int > vi;
typedef vector< i64 > vi64;
typedef pair< int, int > pi;
typedef vector< pair< int, int > > vpi;
typedef vector< vector < int > > vvi;

i64 epow(i64 a, i64 b) {
    i64 ret = 1;
    while (b) {
        if (b & 1) ret = (ret * a) % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}
int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in.txt", "r", stdin);
#endif

    int n; cin >> n;
    vector<int> diff(n);
    forn(i, n) cin >> diff[i];
    vector<int> cnt(2 * n + 1, 0);
    forn(i, n) cnt[diff[i]]++;
    bool ok = true;
    if (n % 2 != 0) {
        if (cnt[0] != 1) ok = false;
        else {
            fore(i, 2, n - 3, 2) {
                if (cnt[i] != 2) {
                    ok = false;
                    break;
                }
            }
        }
    } else {
        fore(i, 1, n - 3, 2) {
            if (cnt[i] != 2) {
                ok = false;
                break;
            }
        }
    }
    if (!ok) cout << 0 << '\n';
    else {
        i64 ans = epow(2, n / 2);
        cout << ans << '\n';
    }

#ifdef LOCAL_DEFINE
    cout << "time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 1408
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ANS = []
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            ans = 500*i + 100*j + 50*k
            if X == ans:
                 ANS.append(ans)
print(len(ANS))



Measured memory_bytes: 3060
import math

a, b = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(a)]

n = 0
for row in c:
    d = math.sqrt(abs(row[0]) ** 2 + abs(row[1]) ** 2)
    if d <= b:
        n += 1

print(n)

Measured memory_bytes: 45424
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll R, G, B, n; cin >> R >> G >> B >> n;
  ll ans = 0;
  rep(r, n+1) rep(g, n+1) {
    ll rest = n - (r * R + g * G);
    if (rest < 0) continue;
    if (rest % B) continue;
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,p;
    cin >> a >> p;
    cout << int((3 * a + p) / 2) << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
s = input()
if s[0] == s[1] == s[2] == s[3]:
    print('No')
elif s[0] == s[1] and s[2] == s[3]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060