akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if(a+b-1>n){cout<<-1<<endl;return 0;}
	vector<int> ans;
	int top=n,bottom=1,len1=a+1,len2=b;
	for(int i=0;;i++)
	{
		if(!--len1){cout<<-1<<endl;return 0;}
		int l1=min(len1,top-bottom+1);
		for(int j=top-l1+1;j<=top;j++)ans.push_back(j);
		top-=l1;
		if(top<bottom)break;
		if(!--len2){cout<<-1<<endl;return 0;}
		int l2=min(len2,top-bottom+1);
		for(int j=bottom+l2-1;j>=bottom;j--)ans.push_back(j);
		bottom+=l2;
		if(top<bottom)break;
	}
	for(int i:ans)cout<<i<<' ';
	cout<<endl;
	return 0;
}


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

using namespace std;

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

	bool flag = false;

	while (n != 0)
	{
		int t = n % 10;
		if (t == 7)
		{
			flag = true;
			break;
		}
		n /= 10;
	}
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  ll N,K;
  cin >> N >> K;
  vint A(N);
  REP(i,N){
    cin >> A[i];
    A[i]--;
  }
  int cnt_all = 0;
  int start = 0;
  int end;
  vint cnt(N);
  cnt[start]++;
  while(2 != cnt[start]){
    end = start;
    start = A[start];
    cnt[start]++;
    cnt_all++;
  }
  
  vint B;
  int pos = start;
  B.pb(pos);
  REP(i,cnt_all){
    pos = A[pos];
    B.pb(pos);
    if(end == pos){
      break;
    }
  }
  
  int cnt_sub = 0;
  pos = 0;
  while(start != pos){
    pos = A[pos];
    cnt_sub++;
  }
  int ans = 0;
  if(cnt_all > K){
    REP(i,K){
      ans = A[ans];
    }
  }else{
    K -= cnt_sub;
    int roops = K%(cnt_all-cnt_sub);
    ans = B[roops];
  }
  
  cout << ans+1 << endl;
}

Measured memory_bytes: 5788
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,v,p,a[N],b[N];

bool check(int x) {
	int tt=0;
	for(int i=1;i<=n;i++) if(i!=x) b[++tt]=a[i];
	reverse(b+1,b+tt+1);
	//for(int i=1;i<=tt;i++) cerr<<b[i]<<' ';
	int now=a[x]+m;ll tim=0;
	for(int i=p;i<=tt;i++) {
		if(b[i]>now) return 0;
		int tmp=min(now-b[i],m);
		tim+=tmp;
	}
	//cerr<<tim<<endl;
	return tim>=1ll*m*(v-p);
}

int main() {
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++) a[i]=gi();
	sort(a+1,a+n+1);
	int l=1,r=n+1;
	while(l<r) {
		int mid=(l+r)>>1;
		if(check(mid)) r=mid; else l=mid+1;
	}
	cout<<n-l+1;
	//cerr<<check(2);
	return 0;
}


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

#define ll long long int

int main() {
	// your code goes here
	ll n;
	cin>>n;
	vector<ll>v;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		v.push_back(x);
		//cout<<v[i]<<" ";
	}
	//cout<<n;
	vector<ll>dp;
	dp.push_back(0);
	dp.push_back(abs(v[0]-v[1]));
	for(ll i=2;i<n;i++){
		dp.push_back(min((dp[i-1]+abs(v[i]-v[i-1])),(dp[i-2]+abs(v[i]-v[i-2]))));
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 2548
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  int res=0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      res=max(res,abs(a[i]-a[j]));
    }
  }
  cout<<res<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
vector<ll> fact_inv, inv, Com;

ll POW(ll a, ll n){ return n ? POW(a*a%MOD, n/2) * (n%2?a:1)%MOD : 1;} 
 
void init_nCk(ll n, ll SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (ll i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}

ll nCk(ll k) {
    return Com[k];
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  init_nCk(n, 2e5);
  
  ll ca, cb;
  ca = nCk(a);
  cb = nCk(b);
  
  ll ret = POW(2,n);
  ret = (ret - ca - cb - 1) % MOD;
  if(ret < 0) ret += MOD;
  
  cout << ret << endl;
  return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

int main() {
	int K, A, B; cin >> K >> A >> B;
	ll ans = K+1;
	if (B - A > 2 && K >= A-1) {
		ll zan = (K - A + 1);
		ll t = A + zan / 2 * (B - A);
		if (zan & 1) {
			++t;
		}
		ans = max(ans, t);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long a,b,c,i,size;
	a=b=c=0;
	cin>>size;
	long* s=new long[size];
	for(i=0;i<size;i++)
	{
		cin>>s[i];
		if(s[i]%2==1)a++;
		else if(s[i]%4!=0)b++;
		else c++;
	}
	if(b==0){if(a<=c+1)cout<<"Yes";else cout<<"No";	}
	else if(a<=c)cout<<"Yes";
	else cout<<"No";
	delete [] s;
	return 0;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    c = [[0]*10 for i in range(10)]
    for i in range(1, N+1):
        S = str(i)
        c[int(S[0])][int(S[-1])] += 1

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += c[i][j]*c[j][i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40428
#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 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 pi=acosl((ld)1);
const ll mod = 1000000007;
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};

#define endN "\n"

bool solve(){
  string s;cin>>s;
  string t;cin>>t;
  for(int i=s.size()-1;i>=0;i--){
    if(i+t.size()-1<s.size()){
      bool isOK=true;
      rep(j,t.size()){
        if(s[i+j]=='?')continue;
        // cout<<t[j]<<" "<<s[i+j]<<endl;
        if(t[j]!=s[i+j])isOK=false;
      }
      // cout<<isOK<<endl;
      // cout<<endl;
      if(isOK){
        for(int j=0;j<i;j++){
          if(s[j]=='?')cout<<"a";
          else cout<<s[j];
        }
        cout<<t;
        for(int j=i+t.size();j<s.size();j++){
          if(s[j]=='?')cout<<"a";
          else cout<<s[j];
        }
        cout<<endl;
        return false;
      }
    }
  }
  cout<<"UNRESTORABLE"<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
 
  int i,n,m,p,k,x[101];
  int sum,s,re;
  while(1){
    scanf("%d%d%d",&n,&m,&p);
    if(n==0&&m==0&&p==0) break;
    sum=0; 
    for(i=1;i<=n;i++){
      scanf("%d",&x[i]);
      sum+=x[i];
      if(i==m) {
        k=x[i];
      }
    }
    re=(double)100*sum*(100-p)/100;
    if(k!=0)re/=k;
    else re=0;
    //    re=sum*(100-p)/100;
    printf("%d\n",re);
    // s=(double)p/(double)100;
    //re*=s;
    
 
    //  re = sum * p;
 
    // printf("%d\n",re/k);
    /*
   if(k>0){
     re/=k;
     printf("%d\n",(int)re);
    }
    else{
      printf("%d\n",0);
    }
    */
  }
 
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 5010;
int p[maxn], n, K, c[maxn];
bool vis[maxn];
LL add[maxn];
LL step[maxn];
LL work(int st){
    //cout<<"st = "<<st<<endl;
  	for (int i=1;i<=n;i++){
      vis[i] = false;
      add[i] = -1000000001;
      step[i] = 0;
    }
  	LL ans = c[st];
  	add[st] = 0;
    int k = K;
  	while (k){
      	int nx = p[st];
      	if (vis[nx]){
        	LL ADD = add[st] + c[nx] - add[nx];
          	LL times = step[st] + 1 - step[nx];
            if (ADD > 0){
                LL tt = (k - 1) / times;
            	LL tmp = add[st] + tt * ADD;
              	step[st] += tt * times;
                //cout<<"st = "<<st<<"\tnx = "<<nx<<"\tpre k = "<<k<<endl;
              	k -= tt * times;
              	if (tmp > ans) ans = tmp;
                for (int i=1;i<=n;i++) if (i!=st){
      				vis[i] = false;
      				add[i] = -1000000001;
      				step[i] = 0;
    			}
              	add[st] = tmp;
                //cout<<"st = "<<st<<"\tADD = "<<ADD<<"\ttimes = "<<times<<endl;
                //cout<<"add[st] = "<<add[st]<<endl;
                //cout<<"k = "<<k<<endl;
            }else break;
        }
      	else{
        	vis[nx] = true;
          	step[nx] = step[st] + 1;
          	add[nx] = add[st] + c[nx];
          	if (add[nx] > ans) ans = add[nx];
          	k--;
            st = nx;
            //cout<<"k = "<<k<<"--- st = "<<st<<"\tadd = "<<add[st]<<"\tans = "<<ans<<endl;
        }
    }
  	return ans;
}
int main(){
  	scanf("%d%d",&n,&K);
  	for (int i=1;i<=n;i++) scanf("%d",&p[i]);
  	for (int i=1;i<=n;i++) scanf("%d",&c[i]);
  	LL ans = c[1];
  	for (int i=1;i<=n;i++){
      	LL tmp = work(i);
      	if (tmp > ans) ans = tmp;
    }
  	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3916
#include <stdio.h>
int main()
{
    char c[5],a[]={'a','i','u','e','o'};
    int flg=1;
    scanf("%s",c);
    for(int i=0;i<5;i++){
        if(a[i]==c[0])
            flg=0;
    }
    if(flg==0)
        printf("vowel\n");
    else
        printf("consonant\n");
    return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N, *xl = map(int, read().split())
    XL = []

    for x, l in zip(*[iter(xl)]*2):
        XL.append((x-l, x+l))

    XL.sort(key=lambda x: x[1])

    ans = 0
    end = -10**9
    for s,e in XL:
        if s >= end:
            ans += 1
            end = e
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 26084
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( "\n" );
  var word = data[0];
  var q = parseInt( data[1] );
  var output = [];
  for( var i=0; i<q; i++ ) {
    var cmd = data[2+i].split( ' ' );
    var s = parseInt( cmd[1] );
    var e = parseInt( cmd[2] )+1;    
    if( "print" == cmd[0] ) {
      output.push( word.substring( s, e ) );
    } else if( "reverse" == cmd[0] ) {
      var br = word.substring( s, e );
      word = word.substring( 0, s )+br.split( '' ).reverse().join( '' )+word.substring( e );
    } else if( "replace" == cmd[0] ) {
      word = word.substring( 0, s )+cmd[3]+word.substring( e );
    }
  }
  console.log( output.join( '\n' ) );
});

Measured memory_bytes: 8532
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) if (i % d == 0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>

using namespace std;
typedef long long llint;
typedef long double ld;
#define inf 1e18

llint n,m;
string s;

bool check(int x,int y){
	x--;y--;
	while(x<y){
		if(s[x]==s[y]){
			x++;
			y--;
		}
		else{
			return false;
		}
	}
	return true;
}
void solve(){
	cin >> s;
	int n=s.size();
	bool a,b,c;
	a=check(1,n);
	b=check(1,(n-1)/2);
	c=check((n+3)/2,n);
	if(a&&b&&c)cout << "Yes";
	else cout << "No";
	cout << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
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 init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


int main(){
    init();
	ll N,L;cin>>N>>L;
	vector<ll>d(N);
	ll sum=0;
	for(int i=0;i<N;i++){
		d[i]=i+L;
		sum+=d[i];
		//cout<<d[i]<<" ";
	}
	//cout<<endl;
	ll ans=INF;
	for(int i=0;i<N;i++){
		if(abs(d[i])<abs(ans)){
			ans=d[i];
		}
	}
	cout<<sum-ans<<endl;	
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
        // int n=sc.nextInt();
        int n=3;
        int d[] = new int[n];
        for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
            sort(d);
        long ans=0;
        for(int i=1; i<n; i++) {
            ans += d[i]-d[i-1];
        }


        out.println(ans);
        out.flush();
    }
    
    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
        int id, d;
        P(int  id, int d) {
            this.id=id;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return d-p.d; //descend
        }
    }

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a >= 13) cout << b << endl;
	else if(a >= 6 && a <= 12) cout << b/2 << endl;
	else cout << 0 << endl;

}

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

int main(){
  int a,b,c,x,y,m;
  cin>>a>>b>>c>>x>>y;
  int ans=0;
  if(x>y){
    swap(x,y);
    swap(a,b);
  }
  if(a+b<=2*c){
    ans=a*x+b*y;
    cout<<ans<<endl;
    return 0;
  }
  ans+=2*c*x;
  if(b<=2*c){
    ans+=b*(y-x);
  }else{
    ans+=2*c*(y-x);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
const int maxn = 1e5 + 50;
const int mod = 1e9 + 7;
typedef long long ll;

ll qpow(ll a,ll b){
    ll ans = 1;
    while(b){
        if(b&1){
            ans = ans*a % mod;
        }
        a = a*a%mod;
        b >>= 1;
    }
    return ans;
}


int a[maxn];

int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    if(n&1){
        if(a[0]!=1){
            cout << 0 << endl;
            return 0;
        }
        else{
            for(int i=2;i<=n;i+=2){
                if(a[i]!=2){
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << qpow(2,n/2) << endl;
        }
    }
    else{
        for(int i=1;i<n;i+=2){
            if(a[i]!=2){
                cout << 0 << endl;
                return 0;
            }
        }
        cout << qpow(2,n/2) << endl;
    }
    return 0;
}


Measured memory_bytes: 768
N = int(input())
A = ""

if N % 2 == 0:
    A = "0" + A
else:
    A = "1" + A
    N -= 1

n = -2
while N != 0:
    if N == n:
        A = "1" + A
        break
    if N % ( n * 2 ) == 0:
        A = "0" + A
    else:
        A = "1" + A
        N -= n
    n *= -2

print(A)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 20;
int n;
int a[MAX];
vector<PII> t[MAX][MAX];
bool cz[MAX][MAX];
void licz(int po,int ko){
  cz[po][ko] = 1;
  if(po == ko){
    t[po][ko].PB({0ll,0ll});
    return;
  }
  vector<PII> res;
  for(int m = po; m < ko; m++){
    if(!cz[po][m])licz(po,m);
    if(!cz[m+1][ko])licz(m+1,ko);
    for(PII el:t[po][m])for(PII el2:t[m+1][ko]){
      res.PB({el.FI + el.SE + el2.FI + a[m], 
              el.SE + el2.FI + el2.SE + a[m]});
    }
  }
  sort(ALL(res));
  vector<PII> &pom = t[po][ko];
  for(PII el:res){
    if(!SZ(pom) || pom.back().SE > el.SE){
      pom.PB(el);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n){
    cin >> a[i];
  }
  licz(1,n-1);
  int wyn = 1e18;
  for(PII x:t[1][n-1]){
    mini(wyn,x.FI + x.SE);
  }
  cout << wyn + a[0] + a[n-1] << "\n";
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, m;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	multiset<double, greater<double>> st;
	for(int i = 0; i < n; i++){
		double val;
		cin >> val;
		st.insert(val);
	}
	while(m){
		double top = *st.begin();
		st.erase(st.begin());
		top /= 2;
		st.insert(top);
		m--;
	}
	long long sum = 0;
	for(double i : st) sum += (long long)i;
	cout << (long long)sum << "\n";
	return 0;
}

Measured memory_bytes: 4992
import numpy as np
n = int(input())
a = np.array([[int(i) for i in input().split(" ")] for j in range(n)])
arg = np.argsort(a[:,1])
sa = a[:,0][arg]
sb = a[:,1][arg]
tm = 0
flag = 0
for i in range(len(sa)):
    tm += sa[i]
    if tm > sb[i]:
        flag = 1
        break
if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 49992
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 205;
const int mod = 1e9 + 7; 
using namespace std;

int n, ans, pos; 
char s[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), scanf("%s", s + 1), scanf("%s", s + 1);
	if(s[1] == s[2]) ans = 6, pos = 3; 
	else ans = 3, pos = 2; 
	while(pos <= n)
	{
		if(pos < n && s[pos] == s[pos + 1])
		{
			if(s[pos - 1] == s[pos - 2]) ans = 1ll * ans * 3 % mod;
			else ans = 1ll * ans * 2 % mod;
			pos += 2; 
		}
		else
		{
			if(s[pos - 1] == s[pos - 2]) ans = ans;
			else ans = 1ll * ans * 2 % mod;
			pos++; 
		}
	}
	printf("%d\n", ans); 
	return 0; 
}


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

int main() {
  int N, Thou, Hund, Ten, One;
  cin >> N;
  Thou = N / 1000;
  Hund = (N - Thou * 1000) / 100;
  Ten = (N - Thou * 1000 - Hund * 100) / 10;
  One = N - Thou * 1000 - Hund * 100 - Ten * 10;
  
  if (Hund == Ten && (Thou == Hund || Ten == One)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int k,a,b; cin >> k >> a >> b;
    for( int i = a; i <= b; ++i )
    {
        if( i % k == 0 )
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 21
#define ll long long int
using namespace std;

int main(void)
{
	int a, b, c;
	vector <int> s;
	cin >> a >> b >> c;

	s.push_back(a);
	s.push_back(b);
	s.push_back(c);

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

	cout << s[0] + s[1] << endl;

	return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<iterator>

using ull = unsigned long long;

int main(){
	ull n;
	std::cin >> n;

	std::map<ull, ull> table;


	for( ull i{}; i < n; ++i )
	{
		ull t;
		std::cin >> t;

		table[t] += 1;
	}

	auto put = [&]()
	{
#ifdef DEBUG
		//std::cout << "ans : " << ans << "\n";
		for( const auto& p : table )
			std::cout << p.first << " : " << p.second << "\n"; 
#endif // DEBUG
	};
	put();

	const auto Amax = table.rbegin()->first;
	const auto const_tab = table;
	for( const auto&e : const_tab )
	{
		//if( e.second > 1 )
		//	continue;

		auto t = e.first;
		while( t < Amax )
		{
			t += e.first;
			if( table.count( t )==1 )
				table[t] += 1;
		}

	}

	//const auto ans
	//	= std::count_if(
	//		std::cbegin( table )
	//		, std::cend( table )
	//		, []( const auto& x )
	//		{
	//			return x.second == 0;
	//		}
	//);

	const auto ans = [&]() {
		ull ans_ = 0;
		for( const auto& p : table )
			ans_ +=
			p.second == 1 && const_tab.at( p.first ) == 1 ? 1 : 0;
		
		return ans_;
	}( );

	put();
	std::cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 28060
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    if(a + 2 >= b || k <= a){
        cout << 1 + k << endl;
        return 0;
    }
    ll ans = b;
    k -= a + 1;
    if(k % 2 == 0){
        ans += (b - a) * (k / 2);
    }
    else{
        ans += (b - a) * (k / 2);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// tested by Hightail: https://github.com/dj3500/hightail
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

const int N = 200200;
int r[N];
ll a[N], b[N];
vi adj[N];

void go (int v, int p) {
   ll suma = 0, sumb = 0;
   int ch = 0;
   for (int w : adj[v]) if (w != p) {
      ++ch;
      go(w, v);
      suma += a[w];
      sumb += b[w];
   }
   if (ch == 0) {
      a[v] = r[v];
      b[v] = min(r[v], r[p]);
   } else {
      a[v] = max(0LL, 2 * r[v] - sumb);
      b[v] = min(1LL * min(r[v], r[p]), 2 * r[v] - suma);
   }
   if (a[v] > b[v]) throw 0;
}

int main () {
   wez(n)
   FORI(i,n) scanf("%d", r+i);
   if (n == 2) {
      if (r[1] == r[2]) printf("YES");
      else printf("NO");
      return 0;
   }
   FOR(u,n-1) {
      wez2(_a,_b);
      adj[_a].pb(_b);
      adj[_b].pb(_a);
   }
   int root = -1;
   FORI(i,n) if (SZ(adj[i]) > 1) root = i;
   r[0] = 0;
   //adj[0] = {root};
   //adj[root].pb(0);
   try {
      go(root, 0);
   } catch (int _) {
      printf("NO");
      return 0;
   }
   printf("YES");
}

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

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;

int a,b,c;
int arr[101][101][101];
int main()
{
 /*cin>>a>>b>c;
for(int i=0;i<a;i++){
    int x,y,z;cin>>x>>y>>z;
    arr[x][y][z]++;
}
  for(int i = 1 ; i<=100 ; ++i)
        for(int j = 1 ; j<=100 ; ++j)
            for(int a = 0 ; a<=m ; ++a)
            {
               arr[i][j][a] += arr[i-1][j][a] + arr[i][j-1][a];
                arr[i][j][a] -= arr[i-1][j-1][a];
            }*/
string s;cin>>s;
for(int i=0;i<s.size();i++){
    if(s[i]=='9'){
        s[i]='1';}else{
        s[i]='9';
        }
}cout<<s;
}
/*
2
2
2 3
2
2 4
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

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

    if(A == B and B == C and A % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    ll cnt = 0;
    while(A % 2 == 0 and B % 2 == 0 and C % 2 == 0) {
        ll a = A, b = B, c = C;
        A = (b + c) / 2;
        B = (a + c) / 2;
        C = (a + b) / 2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
for i in range(3,n+1):
    if i % 3 == 0:
        print(" "+str(i),end="")
    else:
        x = i
        while x >= 3:
            if x%10==3:
                print(" "+str(i),end="")
                break
            x //= 10
    
print()


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string w;
  cin >> w;
  vector<int> count(26, 0);
  int l = w.length();
  REP(i, l) { ++count.at(w.at(i) - 'a'); }

  REP(i, 26) {
    if (count.at(i) == 0) {
      continue;
    }

    if (count.at(i) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque
import math
n,k=map(int,input().split())
l=deque()
i=0
while math.ceil(k/(2**i))!=math.ceil(k/(2**(i+1))):
  l.appendleft(math.ceil(k/(2**i)))
  i+=1
l=list(l)
count=len(l)
ans=0
for i in range(1,n+1):
  if i in l:
    count-=1
  ans+=1/(2**count)
print(ans/n)

Measured memory_bytes: 3316
#include <stdio.h>

int main ()
{
    long int r=1;

    long int h;
    scanf("%ld",&h);
    while(1)
    {
        r=r*2;
        if(r>h) break;
    }

    r=r/2;

    printf("%ld",r*2-1);

    return 0;

}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Dish struct {
	A, B int
}

func main() {
	N, T := ReadInt(), ReadInt()
	dishes := make([]Dish, N)
	for i := 0; i < N; i++ {
		dishes[i].A, dishes[i].B = ReadInt(), ReadInt()
	}
	sort.Slice(dishes, func(i, j int) bool {
		return dishes[i].A < dishes[j].A
	})
	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, T)
	}
	ans := -1
	for i := 0; i < N; i++ {
		for j := 0; j < T; j++ {
			dp[i+1][j] = Max(dp[i+1][j], dp[i][j])
			nj := j + dishes[i].A
			if nj < T {
				dp[i+1][nj] = Max(dp[i+1][nj], dp[i][j]+dishes[i].B)
			}
		}
		ans = Max(ans, dp[i][T-1]+dishes[i].B)
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 76992
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()

if n==1 and m==1:
    print(1)
elif n==1 and m!=1:
    print(m-2)
elif n!=1 and m==1:
    print(n-2)
else:
    print((n-2)*(m-2))

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int  a,b;
  cin >>a>>b;
  
  cout << (3*a+b)/2 << endl;
  
  
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


// 最小全域有向木 O(EV)
// 0-index
// 例外判定のために Edge[0] => {-1,-1,-1} が必須なため　辺のindexは 1-index
const int MAXV = 10010;
const int MAXE = 10010;
const int MAXW = 2147483647;
struct Edge {
    int u, v, c;
    Edge(int x = 0, int y = 0, int z = 0) : u(x), v(y), c(z) {}
};
int V, E, root;
Edge edges[MAXE];
inline void addEdge(int u, int v, int c){ edges[++E] = Edge(u, v, c);}
bool con[MAXV];
int mnInW[MAXV], prv[MAXV], cyc[MAXV], vis[MAXV];
inline int DMST() {
    fill(con, con + V, 0);
    int r1 = 0, r2 = 0;
    while (true) {
        fill(mnInW, mnInW + V, MAXW);
        fill(prv, prv + V, -1);
        for (int i = 1; i <= E; i++) {
            int u = edges[i].u, v = edges[i].v, c = edges[i].c;
            if (u != v && v != root && c < mnInW[v]){mnInW[v] = c; prv[v] = u;}
        }
        fill(vis, vis + V, -1);
        fill(cyc, cyc + V, -1);
        r1 = 0;
        bool jf = false;
        for (int i = 0; i < V; i++) {
            if (con[i]) continue;
            if (prv[i] == -1 && i != root) {
                return -1;
            }
            if (prv[i] >= 0) r1 += mnInW[i];
            int s;
            for (s = i; s != -1 && vis[s] == -1; s = prv[s]) vis[s] = i;
            if (s >= 0 && vis[s] == i) {
                // get a cycle
                jf = true; int v = s;
                do { cyc[v] = s; con[v] = true; r2 += mnInW[v]; v = prv[v];
                } while (v != s);
                con[s] = false;
            }
        }
        if (!jf) break;
        for (int i = 1; i <= E; i++) {
            int &u = edges[i].u;
            int &v = edges[i].v;
            if (cyc[v] >= 0) edges[i].c -= mnInW[edges[i].v];
            if (cyc[u] >= 0) edges[i].u = cyc[edges[i].u];
            if (cyc[v] >= 0) edges[i].v = cyc[edges[i].v];
            if (u == v) edges[i--] = edges[E--];
        }
    }
    return r1 + r2;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int e;
    cin >> V >> e >> root;
    for(int i = 0; i < e;i++) {
        int a, b, c;
        cin >> a >> b >> c;
        addEdge(a, b, c);
    }
    cout << DMST() << endl;
    
    return 0;
}



Measured memory_bytes: 3348
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc175/tasks/abc175_a
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    ll ans = 0;
    ll temp = 0;
    for(int i = 0;i<s.length();i++){
        if(s[i] == 'R'){
            temp++;
        }
        else{
            ans = max(ans, temp);
            temp = 0;
        }
    }
    ans = max(ans,temp);
    cout << ans;

    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a&&c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

	vector<ll> x(N);
	rep(i, N) cin >> x[i];

	auto start = lower_bound(all(x), 0);

	if (start == x.begin())
	{
		cout << x[K - 1] << endl;
	}
	else if (start == x.end())
	{
		cout << abs(x[N - K]) << endl;
	}
	else
	{
		vector<ll> xl = vector<ll>(x.begin(), start);
		if (xl.back() != 0) xl.push_back(0);
		reverse(all(xl));

		vector<ll> xr;
		if (*start != 0) xr.push_back(0);
		xr.insert(xr.end(), start, x.end());

		ll ans = 100000000000000000;

		reple(i, 0, K)
		{
			if (i < xl.size() && (K - i) < xr.size())
			{
				ll l = abs(xl[i]);
				ll r = abs(xr[K - i]);
				chmin(ans, l + r + min(l, r));
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2048
while True:
    A,B,C = map(int,input().split())
#    A,B,C = map(int,f.readline().split())
 #   print(A,B,C,end="")
    if A==-1 and B==-1 and C==-1:
        break
    elif A==-1 or B==-1:
        print("F")
        continue
    if A==-1:
        A=0
    if B==-1:
        B=0
        
    if A+B >= 80:
        print("A")
    elif A+B >=65 and A+B < 80:
        print("B")
    elif A+B >=50 and A+B < 65:
        print("C")
    elif A+B >=30 and A+B < 50:
        if C >= 50:
            print("C")
        else:
            print("D")
    elif A+B < 30:
        print("F")


Measured memory_bytes: 5596
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(){
    int a,b,c;
    scanf("%d %d %d\n",&a,&b,&c);
    
    int min=INT_MAX,max=INT_MIN;
    if(a>b){
        max=a;
        min=b;
    }else{
        max=b;
        min=a;
    }
    if(max<c)max=c;
    else if(min>c)min=c;
    
    printf("%d %d\n",min,max);
    
    return 0;
}


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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,K;
    cin>>N>>K;
    vector<int> l(N);
    REP(i,N) cin>>l[i];
    sort(ALL(l),greater<int>());
    int ans = 0;
    REP(i,K) ans += l[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int ll;
int main() {
	int l, k;
	ll dp[101];
	cin >> l >> k;
	for(int i = 0; i <= 100; i++) dp[i] = 0;
	dp[0] = 0; dp[1] = 1; dp[k] = 1;
	for(int i = 2; i <= l; i++){
		if(i - (k + 1) >= 0) dp[i] += dp[i - 2] + dp[i - (k + 1)];
		else dp[i] += dp[i - 2];
	}
	ll ans = 0;
	for(int i = 1; i <= l; i++){
		ans += dp[i];
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 1005;

char s[N], t[N];

int solve() {
  scanf("%s", s);
  scanf("%s", t);

  int n = strlen(s), m = strlen(t);
  int ans = N;

  for (int i = 0; i < n; ++i) {
    if (i + m > n) break;
    int cnt = 0;
    for (int j = i; j < i + m; ++j) {
      if (s[j] != t[j-i]) ++cnt;
    }
    ans = min(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define endl '\n'
#define pb push_back
#define int long long
#define vi vector<int>
#define mii map<int, int>
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a) for(auto x: a) cout<<x<<" "; cout<<endl;
#define pxy(a,n,m) rep(i,0,n) {rep(j,0,m) cout<<a[i][j]<<" "; cout<<endl;}

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

const long long MOD=LLONG_MAX;
int r,c;
int dp[3005][3005][4];
int a[3005][3005];
int dpfun(int i, int j, int k){
	if(i==r or j==c) return 0;
	if(dp[i][j][k]!=-1) return dp[i][j][k];
	if(k==3) return dpfun(i+1,j,0);
	return dp[i][j][k]=max({dpfun(i+1,j,0)+a[i][j],dpfun(i,j+1,k+1)+a[i][j],dpfun(i,j+1,k)});
}
void solve()
{
	int k;
	cin>>r>>c>>k;
	fill(a,0);
	fill(dp,-1);
	rep(i,0,k){
		int x,y,z;
		cin>>x>>y>>z;
		a[x-1][y-1]=z;		
	}
	cout<<dpfun(0,0,0);
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1; 
	//cin>>t;
	while(t--) solve();
}

Measured memory_bytes: 356816
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int main(){
   string s,t; cin>>s>>t;
  
   int sum=0;
   
  REP(i,3)if(s[i]==t[i])sum++;
   cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char a, b, ans;
    cin >> a >> b;
    if (a == 'H') {
        if (b == 'H') ans = 'H';
        else ans = 'D';
    } else {
        if (b == 'H') ans = 'D';
        else ans = 'H';
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef pair<int, int> pii;

int d(int x,int n)
{
	int ans = 0;
	while (x%n == 0)
	{
		ans++; x /= n;
	}
	return ans;
}

int main()
{
	int n;
	while (cin >> n&&n)
	{
		int p2=0, p5=0;
		for (int i = 1; i <= n; i++)
		{
			p2 += d(i, 2);
			p5 += d(i, 5);
		}
		cout << min(p5, p2) << endl;

	}

}

Measured memory_bytes: 1160