akhauriyash/Code-Regression huggingface dataset:
use std::cmp::min;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let k: u64 = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let b: Vec<u64> = sc.vec(m);

    let mut a_sum = vec![0; n + 1];
    for i in 0..n {
        a_sum[i + 1] = a_sum[i] + a[i];
    }
    let mut b_sum = vec![0; m + 1];
    for i in 0..m {
        b_sum[i + 1] = b_sum[i] + b[i];
    }

    if k >= a_sum[n] + b_sum[m] {
        println!("{}", n + m);
        return;
    }

    let mut ng = n + m;
    let mut ok = 0;
    while ng - ok > 1 {
        let count = (ng + ok) / 2;

        let mut possible = false;
        for a_count in 0..=min(n, count) {
            let b_count = count - a_count;
            if b_count > m {
                continue;
            }

            let cost = a_sum[a_count] + b_sum[b_count];
            if cost <= k {
                possible = true;
                break;
            }
        }

        if possible {
            ok = count;
        } else {
            ng = count;
        }
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8408
import Control.Monad
import Data.List
import Data.Ord

main = do
 [n,k] <- map read . words <$> getLine
 ab <- map (map read . words) <$> replicateM n getLine
 print (bigArray k (sortBy (comparing head) ab))

bigArray k ([a,b]:ab)
 | k <= b = a
 | otherwise = bigArray (k-b) ab


Measured memory_bytes: 145788
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int v[N], c[N];

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> c[i];
  int ret = -INF;
  for (int mask = 0; mask < (1 << n); ++mask) {
    int x = 0, y = 0;
    for (int i = 0; i < n; ++i) {
      if ((mask >> i) & 1) {
        x += v[i];
        y += c[i];
      }
    }
    ret = max(ret, x - y);
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
char a[10],b[10];
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	bool pd=false;
	for (int i=0;i<3;i++)
	  if (a[i]!=b[2-i]) 
	  {
	  	pd=true;
	  	break;
	  }
	if (pd==false) printf("YES");
	else printf("NO");
	printf("\n");
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int N = s.size();
    for (int i = 0; i <= N; i++) {
        for (int j = i; j <= N; j++) {
            string word = s.substr(0, i) + s.substr(j);
            if (word == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	VI h(n); rep(i, n)cin >> h[i];

	int ans = 0;
	rep(i, n) {
		bool flag = true;
		rep(j, i)if (h[i] < h[j])flag = false;
		ans += flag;
	}
	Cout(ans);
}

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

#define ll long long
#define ar array

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

	long double d;
	cin >> d;
	d/=3;
	cout << fixed << setprecision(9);
	cout << d*d*d;
}

Measured memory_bytes: 256
import java.util.Scanner;


class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int T = scanner.nextInt();
		
		Card R=new Card();
		Card G=new Card();
		Card B=new Card();//各マークの手札


		int num[]=new int[9];


		for(int k=0;k<T;k++){

			//手札を９枚配る、各マークと数字を対応させ1枚のカードとして扱う
			for(int i =0;i<9;i++){
				num[i]= scanner.nextInt();
				
			}
			
			for(int p=0;p<9;p++){
				String st=scanner.next();
				
				switch(st){
				case "R":

					R.hand[num[p]-1]=R.hand[num[p]-1]+1;

					break;

				case"G":

					G.hand[num[p]-1]=G.hand[num[p]-1]+1;

					break;

				case"B":

					B.hand[num[p]-1]=B.hand[num[p]-1]+1;

					break;

				}

			}

		if( (B.Set()+R.Set()+G.Set()) ==3){
			System.out.println(1);
		}
		else{
			System.out.println(0);
		}
		}

		scanner.close();

	}

}


class Card{

	int hand [];
	int set=0;
	Card(){
		hand=new int[9];
	}

	//set数判定メソッド

	 public int Set(){
		set=0;

		for(int i=0;i<9;i++){
			if(hand[i]>=3){
				hand[i]=hand[i]-3;//同じカードが３枚あるなら１セット追加して捨て札にする
				set=set+1;
			}
			if(i <= 6){//3連続で同じ数字があるならい１セット追加して1枚ずつ捨て札にする
				
				while(true){
					if((((hand[i] == 0) ||((hand[i+1] ==0))||(hand[i+2]==0))))
					{
						break;}
				if( ((hand[i] >= 1) &&((hand[i+1]>=1))&&(hand[i+2]>=1))){
					hand[i]=hand[i]-1;
					hand[i+1]=hand[i+1]-1;
					hand[i+2]=hand[i+2]-1;
					set=set+1;
				}
				}

			}
			
		}
		
		for(int i=0; i < 9;i++){
		hand[i]=0;	
		}
		
	return set;
}



}









Measured memory_bytes: 29204
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define MAX 1<<18
struct RMQ{
  int n,q;
  int data[MAX];
  RMQ(){
    n=(1<<17);
    int tmp=1;
    while(tmp<n)tmp*=2;
    n=tmp;
    for(int i=0;i<n*2-1;i++)data[i]=INT_MAX;
  }
  void update(int k,int x){
    k+=n-1;
    data[k]=x;
    while(k>0){
      k=(k-1)/2;
      data[k]=min(data[k*2+1],data[k*2+2]);
    }
  }
  int find(int a,int b,int k=0,int l=0,int r=(1<<17)){
    if(r<=a || b<=l)return INT_MAX;
    if(a<=l && r<=b)return data[k];
    int v1=find(a,b,k*2+1,l,(l+r)/2);
    int v2=find(a,b,k*2+2,(l+r)/2,r);
    return min(v1,v2);
  }
};
int main(){
  RMQ a;
  int c,x,y,n,q;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&c,&x,&y);
    if(c)cout<<a.find(x,y+1)<<endl;
    else a.update(x,y);
  }
}


Measured memory_bytes: 4240
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] a = new boolean[n + 1];
        for (int i = 0; i < m; i++) {
            a[sc.nextInt()] = true;
        }
        long[] dp = new long[n + 1];
        dp[0] = 1;
        for (int i = 0; i < n + 1; i++) {
            if (i + 1 <= n && !a[i + 1]) {
                dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
            }
            if (i + 2 <= n && !a[i + 2]) {
                dp[i + 2] = (dp[i + 2] + dp[i]) % 1000000007;
            }
        }
        System.out.println(dp[n]);
    }
}

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

using namespace std;

int main(){
    int H, W;
    array<array<char, 100>, 100> a;
    array<int, 100> row, column;
    for(auto &num:row){
        num = 0;
    }
    for(auto &num:column){
        num = 0;
    }
    cin >> H >> W;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> a.at(i).at(j);
            if(a.at(i).at(j) == '#'){
                row.at(i)++;
                column.at(j)++;
            }
        }
    }
    for (int i = 0; i < H; ++i) {
        if(row.at(i) == 0){
            continue;
        }
        for (int j = 0; j < W; ++j) {
            if(column.at(j) == 0){
                continue;
            }
            cout << a.at(i).at(j);
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[233333];
	gets(a);
	int len=strlen(a),b=-1;
	while(len)
	{
		len--;
		b++;
		if(a[len]=='b')
		{
			if(a[b]!='d')
			{
				cout<<"No";
				return 0;
			}
		}
		if(a[len]=='d')
		{
			if(a[b]!='b')
			{
				cout<<"No";
				return 0;
			}
		}
		if(a[len]=='p')
		{
			if(a[b]!='q')
			{
				cout<<"No";
				return 0;
			}
		}
		if(a[len]=='q')
		{
			if(a[b]!='p')
			{
			    cout<<"No";
			    return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}


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

bool binary_search(vector<int>& a, int r) {
    int left = 0; int right = a.size() - 1;
    while (left <= right) {
        int middle = left + (right - left) / 2;
        if (a[middle] == r) return true;
        else if (a[middle] < r) left = middle + 1;
        else if (a[middle] > r) right = middle - 1;
    }
    return false;
}

int main() {
    int n; cin >> n;
    vector<int> S(n);
    for(int i = 0; i < n; i++) cin >> S[i];
    int q; cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; i++) cin >> T[i];
    int count = 0;
    for (int i = 0; i < q; i++) {
        if (binary_search(S, T[i])) count++;
        // cout << i << ": " << binary_search(S, T[i]) << endl;
    }
    cout << count << endl;

}


Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1e9+7
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct node{
  int x,y,z,l;
};

signed main(){
  while(1){
  int w,h,INF=1LL<<60;
  cin>>w>>h;
  if(w==0)break;
  char c[22][22];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
	 cin>>c[i][j];

  int sx,sy;
  int m[22][22];
  fill_n(*m,22*22,-1);
  int cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
	 if(c[i][j]=='*'){
	   m[i][j]=cnt++;
	 }
	 if(c[i][j]=='o'){
	   sx=i;
	   sy=j;
	 }
    }
  }

  int d[22][22][1<<10];
  fill_n(**d,22*22*(1<<10),INF);
  deque<node> que;
  que.push_back({sx,sy,0,0});
  int dx[4]={0,0,1,-1};
  int dy[4]={1,-1,0,0};

  while(que.size()){
    int x=que.front().x;
    int y=que.front().y;
    int z=que.front().z;
    int l=que.front().l;
    que.pop_front();
    if(x<0||h<=x||y<0||w<=y)continue;
    if(c[x][y]=='x')continue;
    if(d[x][y][z]!=INF)continue;
    if(c[x][y]=='*'&&(z>>m[x][y]&1)==0){
	 int nz=z+(1<<m[x][y]);
	 que.push_front({x,y,nz,l});
    }
    d[x][y][z]=l;
    for(int i=0;i<4;i++){
	 que.push_back({x+dx[i],y+dy[i],z,l+1});
    }
  }
  int mi=INF;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
	 mi=min(mi,d[i][j][(1<<cnt)-1]);
  if(mi==INF)cout<<-1<<endl;
  else cout<<mi<<endl;
  }
  return 0;
}



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

const int maxn = 103;

int main(){
	int n, m ,t[maxn], x[maxn], p[maxn];
	cin >> n;
	for(int i = 1; i<=n; i++){
		cin >> t[i];
	} 
	
	int sum = 0;
	for(int i = 1; i<=n ;i++){
		sum += t[i];
	}
	
	
	cin >> m;
	for(int i = 1; i<=m ;i++){
		cin >> p[i] >> x[i];
		int tmp = sum;
		tmp -= t[p[i]];
		tmp += x[i];
		cout << tmp << endl;
	}
	return 0;
}  

Measured memory_bytes: 3584
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n, k, res = 0;
    cin >> n >> k;
    res = n % k;
    string s = "";
    s = to_string(res);
    int x=0;
    x = n / k;
    do{
        res = x % k;
        s = to_string(res) + s;
        x /= k;
    }while(x >= k);
    s = to_string(x) + s;
    
    int y = 0;
    for (int i = 0; i < s.length(); ++i){
        if(s[i] == '0') ++y;
        else break;
    }
    cout << s.length() - y << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long floor_sum(long long N,long long M,long long A,long long B)
//Sum[floor((A*i+B)/M),{i,0,N-1}]
{
	long long ans=0;
	if(A>=M)
	{
		ans+=N*(N-1)/2*(A/M);
		A%=M;
	}
	if(B>=M)
	{
		ans+=N*(B/M);
		B%=M;
	}
	long long Ym=(A*N+B)/M,Xm=Ym*M-B;
	if(Ym==0)return ans;
	ans+=(N-(Xm+A-1)/A)*Ym;
	ans+=floor_sum(Ym,A,M,(A-Xm%A)%A);
	return ans;
}
main()
{
	int T;cin>>T;
	for(;T--;)
	{
		long N,M,A,B;
		cin>>N>>M>>A>>B;
		cout<<floor_sum(N,M,A,B)<<endl;
	}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	vvl vv(26);
	rep(i,s.size()){
		vv[s[i]-'a'].push_back(i);
	}
	ll cnt=0,cur=-1;
	bool ok=true;
	rep(i,t.size()){
		if(vv[t[i]-'a'].size()==0){
			ok=false;
			break;
		}
		auto itr=upper_bound(all(vv[t[i]-'a']),cur);
		if(itr==vv[t[i]-'a'].end()){
			cnt++;
			cur=(*vv[t[i]-'a'].begin());
		}
		else cur=*itr;
	}
	if(!ok)cout<<-1<<endl;
	else cout<<s.size()*cnt+cur+1<<endl;
}


Measured memory_bytes: 1736
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"700 600 780
" => r"1300",

r"10000 10000 10000
" => r"20000"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        abc: [i32; 3]
    }
    let mut ans: [i32; 3] = [abc[0], abc[1], abc[2]];
    ans.sort();

    (ans[0] + ans[1]).to_string()
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

int main(){
  int n,i;
  float x1,x2,x3,y1,y2,y3,a1,a2,b1,b2,c1,c2,x,y,r;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3);
    a1=(x2-x1)*2;
    b1=(y2-y1)*2;
    c1=x1*x1-x2*x2+y1*y1-y2*y2;
    a2=(x3-x1)*2;
    b2=(y3-y1)*2;
    c2=x1*x1-x3*x3+y1*y1-y3*y3;
    x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
    y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
    r=sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
    printf("%.3f %.3f %.3f\n",x,y,r);
  }
  return 0;
}

Measured memory_bytes: 0
#61b
# n 個の都市　,　m　本の道路
n,m = map(int,input().split())
a=[]
for _ in range(m):
    x,y = map(int,input().split())
    a.extend((x,y))
for i in range(1,n+1):
    print(a.count(i))


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int dp[15][1121];
int main() {
  int N = 1300;
  vector<int> prime(N, 1);
  REP(i,N) prime[i] = i;
  prime[0] = prime[1] = 0;
  for (int i=2; i<N; ++i)
    if (prime[i])
      for (int j=i*2; j<N; j+=i)
        prime[j] = 0;
  prime.erase(remove(ALL(prime), 0), prime.end());

  dp[0][0] = 1;
  REP(k, prime.size()) {
    for (int i=13; i>=0; --i) {
      for (int j=1120-prime[k]; j>=0; --j) {
        dp[i+1][j+prime[k]] += dp[i][j];
      }
    }
  }
  int n, k;
  while(cin>>n>>k,n||k) {
    cout << dp[k][n] << endl;
  }
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<int>a;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0')a.push_back(0);
    if(s.at(i)=='1')a.push_back(1);
    if(s.at(i)=='B'&&a.size()!=0)a.pop_back();
  }
  for(int i=0;i<a.size();i++)cout << a.at(i);
  cout << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nm = in.readLineAsIntArray();
        final int n = nm[0];
        final int m = nm[1];

        int[] coins = in.readLineAsIntArray();

        int[] dp = new int[n + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);

        for (int c : coins) {
            if(c<=n) {
                dp[c] = 1;
            }
        }

        for (int i = 1; i <= n; i++) {
            for (int c : coins) {
                if(i + c <=n) {
                    dp[i + c] = Math.min(dp[i + c], dp[i] + 1);
                }
            }
        }
        System.out.println(dp[n]);
    }


    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}


Measured memory_bytes: 25276
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000

int top=0;
int S[MAX];

void push(int x);
int pop();

int main(){
	int a,b;
	char str[MAX];
	while(scanf("%s",str)!=EOF){
		if(str[0]=='+'){
			a=pop();
			b=pop();
			push(b+a);
		}else if(str[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}else if(str[0]=='*'){
			a=pop();
			b=pop();
			push(b*a);
		}else{
			push(atoi(str));
		}
	}
  printf("%d\n",pop());
  return 0;
}

void push(int x){
	top++;
	S[top]=x;
}

int pop(){
	top--;
	return S[top+1];
}

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

int main(){
  int n,k;
  cin >> n >> k;
  
  string s;
  cin >> s;
  
  vector<int>nums;
  int now = 1;
  int count = 0;
  for(int i=0; i<n; i++){
    if(s[i]==('0'+now))  count++;
    else{
      nums.push_back(count);
      now = 1-now;
      count = 1;
    }
  }
    if(count != 0) nums.push_back(count);
    if(nums.size()%2==0)nums.push_back(0);
    
    int add = 2*k+1;
    
    vector<int>sum(nums.size()+1);
    for(int i=0; i<nums.size(); i++){
     sum[i+1]=sum[i]+nums[i];
    }
    
    int ans =0;
    
    for(int i=0; i<nums.size(); i+=2){
     int left = i;
      int right = min(i+add,(int)nums.size());
      int tmp = sum[right]-sum[left];
      ans = max(tmp,ans);
    }
  
    
    cout << ans << endl;
    
    return 0;
  
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

struct UnionFind
{
    int i;
    vector<int> par;
    vector<int> size;
    UnionFind(int n): par(n),size(n,1){
        for(i = 0;i < n;++i){
            par.at(i) = i;
        }
    }
    
    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x));
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }else{
            if(size.at(rx) < size.at(ry)){
                swap(rx,ry);
            }
            par.at(ry) = rx;
            size.at(rx) += size.at(ry);
            return;
        }
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int get_size(int x){
        return size.at(root(x));
    }
};

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    for(i = 0;i < m;++i){
        ll a,b;
        cin >> a >> b;
        --a;    --b;
        uf.unite(a,b);
    }
    ll ans = 0;
    for(i = 0;i < n;++i){
        ll tmp = uf.get_size(i);
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4836
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef vector<vector<int>> Graph;

ll damage(ll x) {

	if (x == 1) return 1;
	else {
		return damage(x / 2) * 2 + 1;

	}
}


int main() {
	//入力;
	ll H;
	cin >> H;

	cout << damage(H) << endl;

	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
    static node[] t;
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        t = new node[n];
        for(int i = 0; i<n; i++)
            t[i] = new node();
        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            final int id = Integer.parseInt(st.nextToken());
            final int left = Integer.parseInt(st.nextToken());
            final int right = Integer.parseInt(st.nextToken());
            if(left!=-1) t[left].parent = id;
            if(right!=-1) t[right].parent = id;
            t[id].left = left;
            t[id].right = right;
            if(left!=-1&&right!=-1){
                t[left].sibling = right;
                t[right].sibling = left;
            }
        }
        int root = 0;
        while(t[root].parent!=-1)
            root = t[root].parent;
        setdh(root, 0);
        final StringBuilder sb = new StringBuilder();
        for(int i = 0; i<n; i++){
            int degree = 0;
            if(t[i].left!=-1) degree++;
            if(t[i].right!=-1) degree++;
            sb.append("node "+i+": parent = "+t[i].parent+", sibling = "+t[i].sibling+", degree = "+degree+", depth = "+t[i].depth+", height = "+t[i].height+", ");
            if(t[i].parent==-1) sb.append("root\n");
            else if(degree==0) sb.append("leaf\n");
            else sb.append("internal node\n");
        }
        System.out.print(sb);
    }
    static int setdh(int id, int d){
        if(id==-1) return 0;
        t[id].depth = d;
        t[id].height = Math.max(setdh(t[id].left, d+1), setdh(t[id].right, d+1));
        return t[id].height+1;
    }
}

class node{
    int parent;
    int left;
    int right;
    int sibling;
    int depth;
    int height;
    node(){
        parent = -1;
        left = -1;
        right = -1;
        sibling = -1;
        depth = -1;
        height = -1;
    }
}

Measured memory_bytes: 24220
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-03-22 20:25:58
 * @LastEditTime: 2020-03-22 21:12:23
 * @FilePath: \VSCode\C++\Practice\AC abc159 D.cpp
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#pragma GCC optimize(3)
#pragma GCC optimize("02")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#define _inline __inline__ __attribute__((always_inline))
using namespace std;

class complex{
public:
    inline char gc(){
        static const signed IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline complex & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;

int a[200005],t[200005],ans[200005];
int n,temp=0ll;
signed main(){
    inc>>n;
    register int i;

    for(i=1;i<=n;++i) inc>>a[i],++t[a[i]];
    for(i=1;i<=200000;++i) temp+=t[i]*(t[i]-1)/2;
    for(i=1;i<=200000;++i) ans[i]=temp-t[i]+1;
    for(i=1;i<=n;++i) printf("%lld\n",ans[a[i]]);
    
    //system("pause");
    return 0;
}

Measured memory_bytes: 7168
using System;

namespace AtCoder2020Ned
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            var summerVacation = int.Parse(input[0]);
            var homeworks = new int[int.Parse(input[1])];
            var homeworkDurations = Console.ReadLine().Split();

            for (int i = 0; i < homeworks.Length; i++)
            {
                summerVacation -= int.Parse(homeworkDurations[i]);
            }

            if (summerVacation < 0)
            {
                summerVacation = -1;
            }

            Console.WriteLine(summerVacation);
        }
    }
}


Measured memory_bytes: 28320
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

bool isok(const char c) {
  if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
    return true;
  } else {
    return false;
  }
}

int main() {
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size();) {
    // cout << i << endl;
    int j = i;
    int flag = 0;
    while (isok(S[j]) && j < S.size()) {
      j++;
      // cout << "h" << endl;
      flag = 1;
    }
    ans = max(ans, j - i);
    if (flag == 1){
      i = j; 
    } else {
      i = j + 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#define lowbit(x) ((x)&(-x))
#define sc scanf
#define debug1(x) cout<<x<<" "
#define debug2(x) cout<<x<<"\n"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long ll;
const ll inf=1e18;
const int N=1e5+10;
ll mod=1e9+7;
using namespace std;
int gcd(int a,int  b){return b==0?a:gcd(b,a%b);}
int arr[N],brr[N];
ll quick_pow(ll a,ll b,ll m)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
		{
			ret*=a;
			ret%=m;
		}
		a*=a;
		a%=m;
		b>>=1;
	}
	return ret;
}
int main()
{
	int n;
	while(cin>>n)
	{
		memset(brr,0,sizeof(brr));
		for(int i=1;i<=n;i++)
		{
			cin>>arr[i];
			brr[arr[i]]++;
		}
		long long sum=0,i;
		if(n%2==0)i=1;
		else i=0; 
		for(;i<n;i+=2)
		{
			if(brr[i]>2||brr[0]>1)
			{
				break;
			}
			sum+=brr[i];
		}
		if((sum==n))
		{
			ll ans=quick_pow(2,n/2,mod);
			cout<<ans<<"\n";
		}	
		else
		cout<<0<<"\n";
	}	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
set<long long> factors(long long n){
    set<long long> res;
    for(long long i=2;i<=(long long)sqrt(n)+1;i++){
        if(n%i==0){
            if((n/i)!=i){
                res.insert(i);
                res.insert(n/i);
            }
            res.insert(i);
        }
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin>>n;
    if(n==2){
        cout<<1<<"\n";
        return 0;
    }
    set<long long> first = factors(n);
    first.insert(n);
    set<long long> second = factors(n-1);
    second.insert(n-1);
    long long ans=0;
    for(long long i:first){
        long long n1 = n;
        while(n1%i==0)n1/=i;
        if(n1%i==1)ans++;
    }
    ans+=second.size();
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long a[200010],ans[200010],sum,n,x,y;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i],sum+=a[i];
    x=a[0];
    y=sum-a[0];
    ans[0]=abs(x-y);
    for(int i=1;i<n-1;i++)
        x+=a[i],y-=a[i],ans[i]=abs(x-y);
    sort(ans,ans+n-1);
    cout<<ans[0]<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	string S; cin >> S;
	int N = S.size() + 1;
	vi L(N + 1), R(N + 1);	
	// L.at(0) = 0;
	int l = 0;
	rep(i, N - 1) {
		if (S.at(i) == '>') {
			l = 0;
			L.at(i + 1) = l;
		} else {
			l++;
			L.at(i + 1) = l;
		}
	}
	// R.at(N - 1) = 0;
	int r = 0;
	for (int i = N - 2; i >= 0; i--) {
		if (S.at(i) == '<') {
			r = 0;
			R.at(i) = r;
		} else {
			r++;
			R.at(i) = r;
		}
	}
	vi a(N); ll ans = 0;
	rep(i, N) {
		a.at(i) = max(L.at(i), R.at(i));
		ans += a.at(i);
	}
	dbv(a);
	cout << ans << endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int n;
int ans = 0;

void dps(long long int node, int x, int i, bool b3, bool b5, bool b7){
	if(i != 0) node += x * pow(10, i);

	if(node <= n){
		// cout << "pow : " << pow(10, i) << endl;
		// cout << "node : " << node << ", x : " << x << ", i : " << i << endl;

		if(b3 && b5 && b7) ans++;
	}
	else return;

	i++;
	dps(node, 3, i, true, b5, b7);
	dps(node, 5, i, b3, true, b7);
	dps(node, 7, i, b3, b5, true);
}

int main(){
	cin >> n;
	
	dps(3, 0, 0, true, false, false);
	dps(5, 0, 0, false, true, false);
	dps(7, 0, 0, false, false, true);

	cout << ans;
	return 0;
}

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

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            mainClass.Start();
        }

        public void Start()
        {
            var line = Console.ReadLine().Split(' ');
            int N = int.Parse(line[0]), Q = int.Parse(line[1]);
            var S = Console.ReadLine();
            var tmp = new int[N];
            tmp[0] = 0;

            for (int i = 1; i < N;i++){
                tmp[i] = tmp[i - 1];
                if(S[i-1] == 'A' && S[i] == 'C') {
                    tmp[i]++;
                }
            }
            List<int> res = new List<int>();

            for (int q = 0; q < Q; q++)
            {
                var nums = Console.ReadLine().Split(' ').Select(int.Parse).Select(x => x-1).ToList();
                res.Add(tmp[nums[1]] - tmp[nums[0]]);
            }

            res.ForEach(x =>
            {
                Console.WriteLine(x);
            });
        }

        List<List<int>> IntInit()
        {
            int maxindex = int.Parse(Console.ReadLine());

            List<List<int>> array = new List<List<int>>();

            for (int i = 0; i < maxindex; i++)
            {
                array.Add(new List<int>(
                Console.ReadLine().Split(' ').Select(int.Parse)));
            }

            return array;
        }
    }
}




Measured memory_bytes: 19616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define SZ(x) ((int)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const double pi=acos(-1);


 
int main() {
  long long a, b, c;
  cin >> a >> b >> c;

  if (c>a+b && 4*a*b<(a+b-c)*(a+b-c)) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val K = rd.readInt()
    if (K%2 == 0) {
        println(-1)
        return
    }

    var ans = -1
    var rn = 7%K
    for (n in 1..K) {
        if (rn%K == 0) {
            ans = n
            break
        }

        rn = 10*rn + 7
        rn %= K
    }

    println(ans)
}


//val rd = debug.Reader("abc", "174", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 34964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){
    cout<<"square1001"<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int a_n =1,b_n=1;
  bool hit=false;
  for(int i = 0; i < 100000000; i++){
    if((A*a_n % B) == C){
      hit = true;
      break;
    } else{
      a_n++;
    }
  }
  if(hit == true){
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
}

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,k;
	cin >> a >> b >> k;
	if(a >0 && k >0){
		if(k <= a){
			a -= k;
			k = 0;
		}
		else {
			k -= a;
			a =0;
		}
	}  
	// cout << a << " " <<  b << " " << k<< endl; 
	if(b > 0 && k > 0){
		if(k <= b){
			b -= k;
		}
		else {
			b =0;
		}
	}  
	cout << a << " " <<  b <<endl; 
	
	return 0;
}


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

using namespace std;
#define NIL -1
#define ll long long
#define MAX 100

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	string str;
	cin >> str;
	int cnt = 0;
	int cntb = 0;
	for(int i=0; i<n; i++) {
		if(str[i]=='c') cout << "No\n";
		else if(str[i]=='a') {
			if(a+b>cnt) cout << "Yes\n";
			else cout << "No\n";
			cnt++;
		}
		else {
			if(a+b>cnt && cntb<b) {
				cout << "Yes\n";
				cnt++;
			}
			else cout << "No\n";
			cntb++;
		}
	}
	return 0;
}


Measured memory_bytes: 3764
N = int(input())
w = [input() for _ in range(N)]

l = []
for i in range(N):
  if i == 0:
    l.append(w[i])
  elif not w[i] in l and w[i-1][-1] == w[i][0:1]:
    l.append(w[i])
  else:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  long long a, b, c, d, max = 0;

  cin >> a >> b >> c >> d;

  max = a;

  if (b >= max)
    max = b;
  if (c >= max)
    max = c;


  long long tmp = max;

  for (int i = 0; i < d; i++)
  {
    tmp = tmp * 2;
  }

  cout << tmp + a + b + c - max << endl;

}


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

int main() {
    int a,b,c;cin>>a>>b>>c;
    int sum=a+b+c;
    if(sum>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
  int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int x , y ; cin >> x >> y ;
  cout << ( a [ x ] == a [ y ] ? " Yes " : " No ") << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p = 1e9 + 7;
int qpow(int a, int n) {
  int res = 1;
  for (; n; n >>= 1, a = (ll)a * a % p) {
    if (n & 1) {
      res = (ll)res * a % p;
    }
  }
  return res;
}
struct dsu_t: vector<int> {
  dsu_t(int n) {
    resize(n);
    for (int i = 0; i < n; i++) {
      at(i) = i;
    }
  }
  int get_fa(int u) {
    if (u != at(u)) {
      at(u) = get_fa(at(u));
    }
    return at(u);
  }
  void merge(int u, int v) {
    at(get_fa(u)) = get_fa(v);
  }
};
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), go(n);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    go[--a[i]] |= 1 << --b[i];
    go[b[i]] |= 1 << a[i];
  }
  vector<int> pop_count(1 << n), all(1 << n), log2(1 << n);
  for (int i = 0; i < n; i++) {
    log2[1 << i] = i;
  }
  for (int mask = 1; mask < 1 << n; mask++) {
    int low = mask & -mask;
    pop_count[mask] = pop_count[mask ^ low] + 1;
    all[mask] = all[mask ^ low] + pop_count[go[log2[low]] & mask];
  }
  vector<int> edge(1 << n - 1);
  for (int mask = 0; mask < 1 << n - 1; mask++) {
    dsu_t dsu(n);
    for (int i = 0; i < n - 1; i++) {
      if (mask & (1 << i)) {
        dsu.merge(a[i], b[i]);
      }
    }
    vector<int> component, belong(n);
    for (int i = 0; i < n; i++) {
      if (dsu[i] == i) {
        belong[i] = component.size();
        component.push_back(0);
      }
    }
    for (int i = 0; i < n; i++) {
      belong[i] = belong[dsu.get_fa(i)];
      component[belong[i]] |= 1 << i;
    }
    for (int i = 0; i < component.size(); i++) {
      edge[mask] += all[component[i]] - (pop_count[component[i]] - 1);
    }
  }
  vector<int> fact(m + 1), ifac(m + 1);
  fact[0] = 1;
  for (int i = 1; i <= m; i++) {
    fact[i] = (ll)fact[i - 1] * i % p;
  }
  ifac[m] = qpow(fact[m], p - 2);
  for (int i = m; i > 0; i--) {
    ifac[i - 1] = (ll)ifac[i] * i % p;
  }
  vector<pair<int, int> > dp(1 << n - 1);
  vector<int> length(1 << n - 1);
  dp[0].first = 1;
  int full = (1 << n - 1) - 1;
  for (int mask = 0; mask < 1 << n - 1; mask++) {
    for (int i = 0; i < n - 1; i++) {
      if (!(mask & (1 << i))) {
        int k = edge[full ^ mask] - edge[full ^ mask ^ (1 << i)];
        int nxt = mask | (1 << i);
        length[nxt] = length[mask] + k + 1;
        int count = (ll)dp[mask].first * fact[length[nxt] - 1] % p * ifac[length[mask]] % p;
        int sum = (ll)dp[mask].second * fact[length[nxt]] % p * ifac[length[mask] + 1] % p;
        sum = (sum + (ll)count * (pop_count[mask] + 1)) % p;
        dp[nxt].first = (dp[nxt].first + count) % p;
        dp[nxt].second = (dp[nxt].second + sum) % p;
      }
    }
  }
  cout << dp[full].second << endl;
  return 0;
}


Measured memory_bytes: 20864