akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int H=sc.nextInt();
		int W=sc.nextInt();
		int K=sc.nextInt();
		char[][] c=new char[H][W];
		int ans=0;
		for (int i=0;i<H;++i) {
			c[i]=sc.next().toCharArray();
		}
		for (int s0=0;s0<1<<H;++s0) {
			for (int s1=0;s1<1<<W;++s1) {
				int cnt=0;
				boolean f0=false;
				for (int i=0;i<H;++i) {
					f0=(s0>>i)%2==1;
					for (int j=0;j<W;++j) {
						boolean f1=(s1>>j)%2==1;
						if (c[i][j]=='#'&&!f0&&!f1) {
							++cnt;
						}
					}
				}
				if (cnt==K) {
					++ans;
				}
			}
		}
		
		System.out.println(ans);
	}
	
	
	
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}



Measured memory_bytes: 32780
#include<stdio.h>
#include<stdbool.h>

void solve(int n);

int main(void){
  int n;
  while(scanf("%d",&n) && n)  solve(n);
  return 0;
}

void solve(int n){
  int bridge[20][20]={{0}};
  int count[20]={0},time[20]={0};
  bool flg[20];
  int i,j,k,t,rest,next,tmp;
  int sum=0,is1,is2;

  for(i=0;i<n-1;i++){
    scanf("%d%d%d",&is1,&is2,&t);
    is1--;
    is2--;
    bridge[is1][is2]=bridge[is2][is1]=t;
    sum+=2*t;
    count[is1]++;
    count[is2]++;
  }

  for(i=1;i<n;i++){
    time[i]=500000;
    flg[i]=false;
  }
  flg[0]=true;

  for(i=0,rest=n-1;rest>0;i=next,rest--){
    for(j=0;j<n;j++){
      if(bridge[i][j]==0) continue;
      tmp=bridge[i][j]+time[i];
      if(tmp<time[j]) time[j]=tmp;
    }

    for(j=0,next=-1;j<n;j++){
      if(flg[j]) continue;
      if(next==-1 || time[j]<time[next]) next=j;
    }
    flg[next]=true;
  }

  for(i=1;i<n;i++){
    if(count[i]==1){
      for(j=0;j<n && bridge[i][j]==0;j++);
      sum-=2*bridge[i][j];
      time[i]=0;
    }
  }

  for(tmp=time[0],i=0;i<n;i++) if(tmp<time[i]) tmp=time[i];
  sum-=tmp;
  printf("%d\n",sum);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	ll n,m;
	cin>>n>>m;
	int a[m];
	for(int i=0;i<m;i++)cin>>a[i];
	for(int i=0;i<m;i++)
	{
		if(n-a[i]<0)
		{
			cout<<"-1";return;
		}
		n-=a[i];
	}
	cout<<n;
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(){
	int h,w;
	cin>>h>>w;
	char a[h][w];
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
			cout<<a[i][j];
			if(j==w-1){
				cout<<endl;
				}
			}
		for(int j=0;j<w;j++){
			cout<<a[i][j];
			if(j==w-1){
				cout<<endl;
				}
			}
		}
	}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")\
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

typedef long long ll;

const ll mod = 1e9+7;
const int MAX = 2100000;
const int N = 21;

int mat[N][N];
int n;

ll DP[N][MAX];

ll add(ll a ,ll b){
    ll rta = a+b;
    return rta >= mod ? rta - mod : rta;
}

ll dp(int m, int i){
    if(i==n) return 1;
    if(DP[i][m]!=-1) return DP[i][m];
    ll rta = 0;
    for(int j = 0; j<n; ++j){
        if(mat[i][j] && ! (m&(1<<j)) ){
            //cout<<"holi"<<"\n";
            int d = dp(m | 1<<j, i+1);
            rta=add(rta, d);
        }
    }
    return DP[i][m] = rta;
}

int main(){

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

    memset(DP, -1, sizeof(DP));
    cout<<dp(0,0)<<"\n";


}



Measured memory_bytes: 344832
L, R = map(int, input().split())

ans = 2019
for a in range(L, min(L+2019, R)+1):
    for b in range(L, min(L+2019, R)+1):
        if a == b:
            continue
        ans = min(a*b%2019, ans)
        if ans == 0:
            print(0)
            exit()
print(ans)


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char n[4];
    for(int i=0;i<4;i++){
        cin >> n[i];
    }
    if((n[0]==n[1]&&n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3])){
        cout << "Yes" << endl;
    } else if(n[0]==n[1]&&n[1]==n[2]&&n[2]==n[3]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
/**
 * author: Dhakad_123
 * created: 22.04.2020
 **/

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

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

  int n , i; 
  cin >> n >> i;


  cout << (n - i) + 1 << "\n";
  return 0;

  


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}	
char c[214514];
signed main(){
	ic(n) ic(k)
	ic(r) ic(s) ic(p)
	sc(t)
	int ans=0;
	rep(0,i,n){
		if(t[i]=='r'){
			if(i<k){
				ans+=p;
				c[i]='p';
			}	
			else if(c[i-k]!='p'){
				ans+=p;
				c[i]='p';
			}
			else c[i]='x';
		}	
		if(t[i]=='p'){
			if(i<k){
				ans+=s;
				c[i]='s';
			}	
			else if(c[i-k]!='s'){
				ans+=s;
				c[i]='s';
			}
			else c[i]='x';
		}		
		if(t[i]=='s'){
			if(i<k){
				ans+=r;
				c[i]='r';
			}	
			else if(c[i-k]!='r'){
				ans+=r;
				c[i]='r';
			}
			else c[i]='x';
		}
	}
	c(ans)
}		

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int> > vv;
///-------------------------

const ll mod = 998244353;

int main()
{
    Phuong_; /// <3333
    int n,k;
    cin >> n >> k;
    vector<ll> dp(n+1,0);
    vector<ll> upd(n+1,0);
    dp[1] = 1;
    vector<pi> d(k);
    for(int i=0; i<k; ++i){
        cin >> d[i].first >> d[i].second;
    }
    ll sum=0;
    for(int i=1; i<=n; ++i){
        sum = (sum + upd[i]) % mod;
        dp[i] = (dp[i] + sum) % mod;
        for(int j=0; j<k; ++j){
            int head = i + d[j].first;
            int tail = i + d[j].second +1;
            if (head== tail && head <= n){
                upd[head] = (upd[head] + dp[i]) % mod;
            } else
            if (head < tail){
                if (head<=n)
                upd[head] = (upd[head] + dp[i]) % mod;
                if (tail > n) continue;
                upd[tail] = ( upd[tail] - dp[i] ) % mod;
                if (upd[tail] < 0) upd[tail] += mod;
            }
        }
    }
    cout << dp[n] ;
    return 0;
}


Measured memory_bytes: 6340
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt(), ans = 1;
        long[] a = new long[n + 1];
        for (int i = 1; i <= n; i++)
            a[i] = scanner.nextInt();
        Arrays.sort(a);
        Arrays.parallelPrefix(a, Long::sum);
        while (--n > 0 && a[n + 1] - a[n] <= a[n] * 2)
            ans++;
        System.out.println(ans);
    }
}

Measured memory_bytes: 53908
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;string s;cin>>n>>s;
	int tmp=0,mn=0,mx=0,sp=0,ep=0;
	for(int i=0;i<n;i++){
	if(s[i]=='('){sp++;tmp++;mn=min(mn,tmp);mx=max(mn,tmp);}
else if(s[i]==')'){ep++;tmp--;mn=min(mn,tmp);mx=max(mn,tmp);}
    }
	int n0=(sp-mn)-(n-sp);
string ans=string(-mn,'(')+s+string(n0,')');
cout<<ans<<endl;}





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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  if (A >= K) {
    cout << K << endl;
    return 0;
  }

  if (A + B >= K) {
    cout << A << endl;
    return 0;
  }

  ll zan = K - (A + B);
  cout << A - zan << endl;

  return 0;
}


Measured memory_bytes: 3608
N, M, Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]

def score(A):
    ans = 0
    for i in abcd:
        if A[i[1] -1] - A[i[0] -1] == i[2]:
            ans += i[3]
    return ans

def dfs(A, i):# 数列Aのi番目まで決まってる
    ans = 0
    if i == N:
        return score(A)
    
    lower = 1
    if i != 0:
        lower = A[i-1]
    for x in range(lower, M+1):
        A[i] = x
        ans = max(ans, dfs(A, i+1))
    
    return ans

print(dfs([None]*N, 0))

Measured memory_bytes: 9000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################

int main(){
  boost;
  
  ll a;
  cin>>a;
  cout<<a+a*a+a*a*a;
}


Measured memory_bytes: 3648
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld inf=pow(10,10);
const ld pi=acosl((ld)1);
//const ll mod = 1000000007;
const ll mod = 1000003;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
  ll A[3][3];
  rep(i,3)rep(j,3)cin>>A[i][j];
  ll n;cin>>n;
  rep(q,n){
    ll b;cin>>b;
    rep(i,3)rep(j,3)if(A[i][j]==b)A[i][j]=0;
  }
  rep(i,3){
    if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0){
      cout<<"Yes"<<endl;
      return;
    }
  }
  rep(i,3){
    if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0){
      cout<<"Yes"<<endl;
      return;
    }
  }
  if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0){
      cout<<"Yes"<<endl;
      return;
    }
  if(A[2][0]==0&&A[1][1]==0&&A[0][2]==0){
      cout<<"Yes"<<endl;
      return;
    }
  cout<<"No"<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;


int main(void) {
    int i;
    string s;

    cin >> s;

    for (i = 0; i < 3; i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
/**
 *    Author:  "Robin Singh" !!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0
#define rtn return 
#define nl "\n"      // avoid endl
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const ll INF = (1LL<<61);
const int inf = (1<<30);
//-------------------------------------------------------------------------------------------------------------
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//-------------------------------------------------------------------------------------------------------------

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int k;
    cin >> k;
    int e = k/2, o = k/2 + (k%2);
    cout << e*o;
    return 0;
}

Measured memory_bytes: 256
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    s = [input() for i in range(n)]
    print("AC x " + str(s.count("AC")))
    print("WA x " + str(s.count("WA")))
    print("TLE x " + str(s.count("TLE")))
    print("RE x " + str(s.count("RE")))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 17488
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){      
     lint n,m,e;
     cin>>n>>m>>e;
     lint c[n];
     lint a[n][m];
     rep(i,n){
         cin>>c[i];
         rep(j,m){
             cin>>a[i][j];
         }
     }
lint ans=INF;
    rep(i,(1<<n)){
        bool x[15];
        lint ski[15];
        fill(x,x+15,false);
        fill(ski,ski+15,0);
        rep(j,n){
            if(i&(1<<j))x[j]=true;
        }
        lint cost=0;
        rep(k,n){
            if(x[k]){
                cost+=c[k];
                rep(l,m){
                    ski[l]+=a[k][l];
                }
            }
        }
        rep(s,m){
            if(ski[s]<e)break;
            if(s==(m-1))ans=min(ans,cost);
        }
    }
        if(ans==INF)cout<<-1<<endl;
        else cout<<ans<<endl;
      }
      
    

  
          
  

Measured memory_bytes: 3680
N, x = map(int, input().split())
a = [int(x) for x in input().split()]

cnt = 0
for i in range(N - 1):
    if a[i] + a[i + 1] > x:
        c = a[i] + a[i + 1] - x
        a[i + 1] = max(a[i + 1] - c, 0)
        cnt += c
print(cnt)

Measured memory_bytes: 14052
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        boolean[][] bingo = new boolean[3][3];
        Map<Integer, int[]> map = new HashMap<>();

        for (int i = 0 ; i < 3 ; i++) {
            for (int j = 0 ; j < 3 ; j++) {
                int num = scanner.nextInt();
                int[] pos = new int[2];
                pos[0] = i;
                pos[1] = j;
                map.put(num, pos);
                bingo[i][j] = false;
            }
        }

        int N = scanner.nextInt();
        for (int i = 0 ; i < N ; i++) {
            int b = scanner.nextInt();
            if (map.containsKey(b)) {
                int[] pos = map.get(b);
                bingo[pos[0]][pos[1]] = true;
            }
        }

        for (int i = 0 ; i < 3 ; i++) {
            if (bingo[i][0] && bingo[i][1] && bingo[i][2]) {
                System.out.println("Yes");
                return;
            }
            if (bingo[0][i] && bingo[1][i] && bingo[2][i]) {
                System.out.println("Yes");
                return;
            }
        }
        
        if (bingo[0][0] && bingo[1][1] && bingo[2][2]) {
            System.out.println("Yes");
            return;
        }
        if (bingo[0][2] && bingo[1][1] && bingo[2][0]) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


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

typedef long long ll;

int keta( ll x ) {
  int a = 0;
  while ( x > 0 ){
    a++;
    x /= 10;
  }
  return a;
}

int main(){
  ll n;
  cin >> n;
  
  ll ans = 0;
  
  if ( keta (n) == 1 ){
    ans += n;
  } else if ( keta(n) == 2 ){
    ans += 9;
  } else if ( keta(n) == 3 ){
    ans += 9;
    ans += n - 99;
  } else if ( keta(n) == 4 ){
    ans += 9;
    ans += 900;
  } else if ( keta(n) == 5 ){
    ans += 9;
    ans += 900;
    ans += n - 9999;
  } else if ( keta(n) == 6 ){
    ans += 9; 
    ans += 900;
    ans += 90000;
  }
  
  cout << ans << endl;

}

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

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    int64_t N, K, cnt = 0;
    int mod = 1e9 + 7;
    cin >> N >> K;
    //処理
    for (int i = K; i <= N + 1; i++) {
        cnt += (N - i + 1) * i + 1;


    }
    //出力処理
    cout << cnt % mod << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

    vector<pair<int, int>> p(N);

    long double factor = (1 - 1 / N);
    long double ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> p[i].first >> p[i].second;
    }
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        a[i] = i;
    }   
    long long count = 0;
    do
    {
        for (int i = 0; i < N - 1; i++)
        {
            ans += sqrt((p[a[i]].first - p[a[i + 1]].first) * (p[a[i]].first - p[a[i + 1]].first) + (p[a[i]].second - p[a[i + 1]].second) * (p[a[i]].second - p[a[i + 1]].second));
        }
        count++;
    } while (next_permutation(a.begin(), a.end()));
    ans /= count;
    cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int MAX_N=10010;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//Ｏ(α(n)) < Ｏ(log n) 非常に高速

struct UnionFind{

int par[MAX_N];
int rank_[MAX_N];

//n要素で初期化
void init(int n){
  for(int t=0;t<n;t++){
    par[t]=t;
    rank_[t]=0;
  }
}

//木の根を求める。
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

//xとｙの集合を併合。
void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(rank_[x]<rank_[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank_[x]==rank_[y])rank_[x]++;
  }
}

//xとｙが同じ集合に属するかどうか。
bool same(int x, int y){
  return find(x)==find(y);
}

};

UnionFind UF;

signed main(){
  int n,q;
  queue<int>que;
  cin>>n>>q;

  UF.init(n);
  for(int t=0;t<q;t++){
    int com,x,y;
    cin>>com>>x>>y;
    if(com==0){
      UF.unite(x,y);
    }else{
      if(UF.same(x,y)){
        que.push(1);
      }else{
        que.push(0);
      }
    }
  }

  while(!que.empty()){
    cout<<que.front()<<"\n";
    que.pop();
  }

  return 0;
}



Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 1; i < (int)(n); i++)

using namespace std;

typedef unsigned long long ll;

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


int main(){
    int n;

    cin >> n;
    if(n%2==0) cout << n/2;
    else cout << n/2 +1;
  
    return 0;

}

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

typedef long long ll;

const int Maxn = 200005;

int L, N;
int A[Maxn];
ll oddL[Maxn], evenL[Maxn];
ll oddR[Maxn], evenR[Maxn];
ll res;

int Dist(int a, int b)
{
    if (a <= b) return b - a;
    else return b - a + L;
}

ll Solve(deque <int> D, bool beg)
{
    int cur = 0;
    ll res = 0;
    while (!D.empty()) {
        if (beg) { res += Dist(cur, D.front()); cur = D.front(); D.pop_front(); }
        else { res += Dist(D.back(), cur); cur = D.back(); D.pop_back(); }
        beg = !beg;
    }
    return res;
}

int main()
{
    scanf("%d %d", &L, &N);
    for (int i = 1; i <= N; i++)
        scanf("%d", &A[i]);
    A[N + 1] = L;
    for (int i = 1; i <= N + 1; i++) {
        oddL[i] = oddL[i - 1] + ll(A[i - 1]) + ll(A[i]);
        evenL[i] = evenL[i - 1] + ll(A[i]) + ll(A[i]);
    }
    for (int i = N + 1; i > 0; i--) {
        oddR[i] = oddR[i + 1] + ll(L - A[i]) + ll(L - A[i - 1]);
        evenR[i] = evenR[i + 1] + ll(L - A[i - 1]) + ll(L - A[i - 1]);
    }
    for (int i = 1; i <= N + 1; i++) {
        int mn = min(i - 1, N + 1 - i);
        // to left
        ll cand = 0;
        if (mn > 0) {
            cand += oddL[i - 1] - oddL[i - mn - 1] - 2ll * mn * A[i - mn - 1];
            cand += evenR[i + 1] - evenR[i + mn + 1] - 2ll * mn * (L - A[i + mn]);
        }
        if (i - 1 > N + 1 - i)
            cand += ll(2 * mn + 1) * A[i - mn - 1];
        else if (i - 1 < N + 1 - i)
            cand += ll(2 * mn) * (L - A[i + mn]);
        res = max(res, cand);
        cand = 0;
        if (mn > 0) {
            cand += evenL[i - 1] - evenL[i - mn - 1] - 2ll * mn * A[i - mn - 1];
            cand += oddR[i + 1] - oddR[i + mn + 1] - 2ll * mn * (L - A[i + mn]);
        }
        if (i - 1 > N + 1 - i)
            cand += ll(2 * mn) * A[i - mn - 1];
        else if (i - 1 < N + 1 - i)
            cand += ll(2 * mn + 1) * (L - A[i + mn]);
        res = max(res, cand);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 7296
use proconio::{input, fastout};

#[fastout]
fn main() {
  input!{
    N: i32
  }
  let mut ans:i32 = 0;
  for i in 1..(N+1) {
    let mut num:i32 = 0;
    for j in 1..(N+1) {
      if i%j == 0 {
          num += 1;
      }
    }
    if num == 8 && i%2 == 1 {
        ans += 1;
    }
  }
  println!("{}",ans);
}


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

using namespace std;

int par[10001];

int root(int x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = root(par[x]);
    }
}

bool same(int x, int y) {
    return root(x) == root(y);
}

void unit(int x, int y) {
    int root_x = root(x);
    int root_y = root(y);
    par[root_x] = root_y;
}

int main()
{

    for (int i = 0; i < 10000; i++) {
        par[i] = i;
    }
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            unit(x, y);
        }
        else {
            cout << (same(x, y) ? 1 : 0) << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 3140
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int cnt = 0;
    sc.close();
    for (int i = 0; i <= A; i++) {
      for (int j = 0; j <= B; j++) {
        for (int k = 0; k <= C; k++) {
          if (i * 500 + j * 100 + k * 50 == X) {
            cnt++;
          }
        }
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 23764
n = int(input())
w = list(map(int, input().split()))

a = [0]*2
i = 0
j = 1
while True:
    if (i + j) == n + 1:
        break
    elif a[0] <= a[1]:
        a[0] += w[i]
        i += 1
    else:
        a[1] += w[-j]
        j += 1

print(abs(a[0] - a[1]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    if (65 <= N && N <= 90) {
        cout << "1\n";
    } else if (97 <= N && N <= 122) {
        cout << "2\n";
    } else {
        cout << "0\n";
    }
    return 0;
}


Measured memory_bytes: 3084
import java.awt.Point;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	final int INF = 1 << 29;
	Scanner sc = new Scanner(System.in);
	int dx[] = { 0, 1, 0, -1 };
	int dy[] = { 1, 0, -1, 0 };

	void run() {
		while (true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			boolean wall[][] = new boolean[2 * h][w];
			if ((w | h) == 0)
				break;
			for (int i = 0; i < 2 * h - 1; i++) {
				for (int j = 0; j < (i % 2 == 0 ? w - 1 : w); j++) {
					wall[i][j] = sc.nextInt() == 1;
				}
			}
			Queue<Point> q = new LinkedList<Point>();
			int visited[][] = new int[h][w];
			for (int i = 0; i < h; i++) {
				Arrays.fill(visited[i], -1);
			}
			visited[0][0] = 1;
			q.add(new Point(0, 0));
			boolean goal = false;
			while (!q.isEmpty()) {
				Point p = q.poll();
				int x = p.x;
				int y = p.y;
				// System.out.println(x+" "+y);
				if (x == w - 1 && y == h - 1) {
					goal = true;
					break;
				}

				for (int i = 0; i < 4; i++) {
					int nx = x + dx[i];
					int ny = y + dy[i];
					if (nx < 0 || ny < 0 || nx >= w || ny >= h)
						continue;
					if (y == ny && wall[y * 2][(x + nx) / 2]) {
						continue;
					}
					if (x == nx && wall[y + ny][x]) {
						continue;
					}
					if (visited[ny][nx] != -1) {
						continue;
					}
					visited[ny][nx] = visited[y][x] + 1;
					q.add(new Point(nx, ny));
				}
			}
			if (goal) {
				System.out.println(visited[h - 1][w - 1]);
			} else {
				System.out.println(0);
			}
		}

	}

	public static void main(String[] args) {
		new Main().run();

	}
}

Measured memory_bytes: 68212
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
static const int N = 100;

int main(){
    int M[N][N];
    int n,u,k,v;
    cin >> n;
    for(int i = 0; i < n; i++)for(int j = 0; j < n; j++)M[i][j] = 0;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for(int j = 0; j < k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(j) cout << " ";
                cout << M[i][j];
            }
            cout << endl;
        }
        return 0;
}
           


Measured memory_bytes: 3132
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int R; cin >> R;
    cout << 2 * M_PI * R << endl;
    return 0;
}



Measured memory_bytes: 3788
a = int(input())
b = input().split()
teki = [int(i) for i in b]
c = input().split()
yuusya = [int(i) for i in c]

count = 0

if yuusya[0] >= teki[0]:
    yuusya[0] -= teki[0]
    count += teki[0]
    teki[0] = 0
else:
    count += yuusya[0]
    teki[0] -= yuusya[0]
    yuusya[0] = 0

for i in range(1, len(yuusya)):
    if yuusya[i - 1] > 0:
        if yuusya[i - 1] > teki[i]:
            count += teki[i]
            yuusya[i - 1] = 0
            teki[i] = 0
            continue
        else:
            count += yuusya[i-1]
            teki[i]-=yuusya[i-1]
    if yuusya[i] >= teki[i]:
        yuusya[i] -= teki[i]
        count += teki[i]
        teki[i] = 0
    else:
        count += yuusya[i]
        teki[i] -= yuusya[i]
        yuusya[i] = 0

if len(teki) > len(yuusya) and len(teki) > 2:
    if yuusya[i] >= teki[i+1]:
        yuusya[i] -= teki[i+1]
        count += teki[i+1]
    else:
        count += yuusya[i]
        teki[i] -= yuusya[i]
        yuusya[i] = 0

print(count)

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

void solve(long long N, string s){
	long long r = 0;
	for (int i=0; i<N; i++) {
		if (s[i] == 'R') r++;
	}
	if (r>N-r) cout << "Yes\n"; else cout << "No\n";
}

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


Measured memory_bytes: 256
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

void solve()
{
int a;
string s;
cin>>a>>s;
if(a>=3200)
cout<<s<<'\n';
else
cout<<"red"<<'\n';
}

int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;

void bubble_sort(int cards[36][2], int n){
    int temp[2]={};
    for(int i=0; i<n; i++){
        for(int j=n-1; j>i; j--){
            if(cards[j-1][1] > cards[j][1]){
                temp[0] = cards[j][0];
                temp[1] = cards[j][1];
                cards[j][0] = cards[j-1][0];
                cards[j][1] = cards[j-1][1];
                cards[j-1][0] = temp[0];
                cards[j-1][1] = temp[1];
            }
        }
    }
    for(int i=0; i<n; i++){
        cout << (char)cards[i][0]<<cards[i][1];
        if(i < n-1){
            cout << " ";
        }
    }
    cout << endl;
}

void selection_sort(int cards[36][2], int n){
    int temp[2]={};
    int min, min_index;
    for(int i=0; i<n; i++){
        min = cards[i][1];
        min_index = i;
        for(int j=i; j<n; j++){
            if(min > cards[j][1]){
                min = cards[j][1];
                min_index = j;
            }
        }
        if(min_index != i){
            temp[0] = cards[i][0];
            temp[1] = cards[i][1];
            cards[i][0] = cards[min_index][0];
            cards[i][1] = cards[min_index][1];
            cards[min_index][0] = temp[0];
            cards[min_index][1] = temp[1];
        }
    }
    for(int i=0; i<n; i++){
        cout << (char)cards[i][0]<<cards[i][1];
        if(i < n-1){
            cout << " ";
        }
    }
    cout << endl;
}

int diff(int list1[36][2], int list2[36][2], int l1, int l2){
    if(l1 != l2){
        return 1;
    }else{
        for(int i=0; i<l1; i++){
            if(list1[i][0] != list2[i][0]){
                return 1;
            }
        }
    }
    return 0;
}

int main()
{
    int N;
    string card;
    int bubble_cards[36][2], selection_cards[36][2];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> card;
        bubble_cards[i][0] = (int)card[0];
        bubble_cards[i][1] = (int)card[1]-'0';
        selection_cards[i][0] = (int)card[0];
        selection_cards[i][1] = (int)card[1]-'0';
    }
    bubble_sort(bubble_cards, N);
    cout << "Stable" <<endl;
    selection_sort(selection_cards, N);
    if(diff(bubble_cards, selection_cards, N, N)){
        cout << "Not stable" <<endl;
    }else{
        cout << "Stable" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3148
n = int(input())

d = {}
ans = 0
for i in range(n):
    list_s = sorted(list(input()))

    s = ""
    for j in list_s:
        s = s + j

    if s in d:
        ans = ans + d[s]
        d[s] += 1
    else:
        d[s] = 1

print(ans)

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

int main() {
    int n = 0, m = 0;
    int a[200000], b[200000];
    vector<vector<int>> graph(200001);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        graph[a[i]].push_back(b[i]);
        graph[b[i]].push_back(a[i]);
    }

    int dist[200001];
    for (int i = 1; i <= n; i++) dist[i] = -1;
    queue<int> q;

    dist[1] = 0;
    q.push(1);

    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        
        for (int node : graph[cur]) {
            if (dist[node] != -1) continue;
            dist[node] = cur; // 道しるべの更新
            q.push(node);
        }
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++) cout << dist[i] << endl;
}

Measured memory_bytes: 14028
N, M, X = map(int, input().split())
Cs = []
Ass = []
for _ in range(N):
    c, *a = list(map(int, input().split()))
    Cs.append(c)
    Ass.append(a)

INF = float('inf')
ans = INF
for i in range(2 ** N):
    score = [0] * M
    d = 1
    cost = 0
    for j in range(N):
        if i & d:
            cost += Cs[j]
            for k, s in enumerate(Ass[j]):
                score[k] += s
        d <<= 1
    for s in score:
        if s < X:
            break
    else:
        ans = ans if ans < cost else cost

print(-1 if ans == INF else ans)


Measured memory_bytes: 9224
def solve():
    n = int(input())
    h = list(map(int,input().split()))

    h[0] -= 1
    for i in range(1,n):
        if h[i-1]<h[i]:
            h[i] -= 1
        if h[i-1]>h[i]:
            return 'No'
    return 'Yes'

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 14396
#include<stdio.h>
int main()
{
	float a,b,c,d,e;
	scanf("%f%f%f%f%f",&a,&b,&c,&d,&e);
	printf("%d\n",(int)(a-((b/d>c/e)?b/d:c/e)));
	return 0;
}

Measured memory_bytes: 620
#include <map>
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
struct s{
	ll v, i, j;
};
class cmp{
	public : bool operator()(const s &a, const s &b){
		return a.v < b.v;
	}
};
int main(){
	int x, y, z, k;
	scanf("%d %d %d %d", &x, &y, &z, &k);
	ll a[x], b[y], c[z];
	for (int i = 0; i < x; i++) scanf("%lld", &a[i]);
	for (int i = 0; i < y; i++) scanf("%lld", &b[i]);
	for (int i = 0; i < z; i++) scanf("%lld", &c[i]);
	ll d[x * y], count = 0;
	for (int i = 0; i < x; i++){
		for (int j = 0; j < y; j++){
			d[count] = a[i] + b[j];
			count++;
		}
	}
	sort(d, d + x * y);
	reverse(d, d + x * y);
	sort(c, c + z);
	reverse(c, c + z);
	priority_queue<s, vector
, cmp> pq;
	for (int i = 0; i < x * y; i++){
		s aaa;
		aaa.i = i;
		aaa.j = 0;
		aaa.v = d[aaa.i] + c[aaa.j];
		pq.push(aaa);
	}
	while (k--){
		s cur = pq.top();
		pq.pop();
		printf("%lld\n", cur.v);
		s ns;
		if (cur.j == z - 1) continue;
		ns.i = cur.i;
		ns.j = cur.j + 1;
		ns.v = d[ns.i] + c[ns.j];
		pq.push(ns);
	}
}

Measured memory_bytes: 34792
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());

int main() {
	int h,w,tmp=0;

	string ans;
	cin>>h>>w;
	vi flag_x(h,0),flag_y(w,0);
	vs a(h);
	rep(i,h){
			cin>>a[i];
	}

	rep(i,h){
		tmp=0;
		rep(k,w) {
			if (a[i][k] == '.')
				tmp++;
		}
		if(tmp==w){
			flag_x[i]=1;
		}

	}
	rep(i,w){
		tmp=0;
		rep(k,h) {
			if (a[k][i] == '.')
				tmp++;
		}
		if(tmp==h){
			flag_y[i]=1;
		}
	}

	rep(i,h){
		rep(k,w) {
			if(flag_x[i]!=1 &&flag_y[k]!=1 ){
				cout<<a[i][k];
			}

		}
		if(flag_x[i]!=1)
			cout<<"\n";
	}


	return 0;


}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

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

  string s;
  cin >> s;
  int n = s.length();
  int b_sum = 0;
  int r_sum = 0;
  vector<FiniteField> current(2 * n + 1);
  current[0] = 1;
  for (int k = 0; k < 2 * n; k++) {
    if (k < n) {
      b_sum += s[k] - '0';
      r_sum += 2 - (s[k] - '0');
    }
    vector<FiniteField> next(2 * n + 1);
    for (int i = 0; i <= 2 * n; i++) {
      int b_used = i;
      int b_remain = b_sum - b_used;
      int r_used = k - i;
      int r_remain = r_sum - r_used;
      if (b_remain > 0) {
        next[i + 1] += current[i];
      }
      if (r_remain > 0) {
        next[i] += current[i];
      }
    }
    swap(current, next);
  }
  cout << current[b_sum] << endl;
}

Measured memory_bytes: 384
N = int(input())
S = input()
n = 0
for i in range(1000):
  ps_i = "%03d"%(i)
  s = S
  ps_i_ok = True
  for j in ps_i:
    if j in s: s = s[s.index(j)+1:]
    else:
      ps_i_ok = False
      break
  if ps_i_ok: n+=1
print(n)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int par[213456];//親
int depth[213456];//木の深さ
//n要素で初期化
void init(int n) {
	for (int i = 0; i <= n; i++) {
		par[i] = i;
		depth[i] = 0;
	}
}
//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y) { return; }
	if (depth[x] < depth[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (depth[x] == depth[y])depth[x]++;
	}
}
//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}
struct edge { int u, v, cost; };
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
edge es[345678];
int kruskal(int V, int E) { //頂点数と辺数
	sort(es, es + E, comp); //edge.costが小さい順にソート
	init(V); //Union-Findの初期化
	int res = 0;
	for (int i = 0; i < E; i++) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}
signed main() {
	int n; cin >> n;
	vector<vector<int>>aa(n, vector<int>(3));
	vector<vector<int>>bb(n, vector<int>(3));
	for (int h = 0; h < n; h++) {
		cin >> aa[h][0] >> aa[h][1]; aa[h][2] = h;
		bb[h][0] = aa[h][1]; bb[h][1] = aa[h][0]; bb[h][2] = h;
	}
	sort(aa.begin(), aa.end());
	int x = 0;
	for (int h = 1; h < n; h++) {
		es[x] = { aa[h - 1][2], aa[h][2], min(abs(aa[h - 1][0] - aa[h][0]),abs(aa[h - 1][1] - aa[h][1])) };
		x++;
	}
	sort(bb.begin(), bb.end());
	for (int h = 1; h < n; h++) {
		es[x] = { bb[h - 1][2], bb[h][2], min(abs(bb[h - 1][0] - bb[h][0]),abs(bb[h - 1][1] - bb[h][1])) };
		x++;
	}
	cout << kruskal(n, x) << endl;
	return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin>>n;
	vector<int>nums(n);
	int Xor=0;
	for(int i=0;i<n;++i)
	{
		cin>>nums[i];
		Xor^=nums[i];
	}
	for(int i=0;i<n;++i)
	{
		cout<<(Xor^nums[i])<<' ';
	}

}


Measured memory_bytes: 3864