akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int N = 2e5 + 10;
const int inf = 0x3f3f3f3f;

int n, E, Ex, X, Y;
int a[N], b[N], c[N], d[N];
int fir[N], nex[N << 1], arr[N << 1], dep[N], fa[N];
int firx[N], nexx[N << 1], arrx[N << 1], tim[N], tag[N];
queue<int> Q;

inline void Add_Edge(int x, int y) {
	nex[++E] = fir[x];
	fir[x] = E; arr[E] = y;
}

inline void Add_Edge2(int x, int y) {
	nexx[++Ex] = firx[x];
	firx[x] = Ex; arrx[Ex] = y;
}

void dfs(int x) {
	for (int i = fir[x]; i; i = nex[i]) {
		if (arr[i] == fa[x]) continue;
		fa[arr[i]] = x;
		dep[arr[i]] = dep[x] + 1;
		dfs(arr[i]);
	}
}

int dis(int x, int y) {
	if (fa[x] == y || fa[y] == x) return 1;
	if (fa[fa[x]] == y || fa[fa[y]] == x || fa[x] == fa[y]) return 2;
	else return 3;
}

void bfs() {
	tim[X] = 0;
	Q.push(X);
	while (!Q.empty()) {
		int x = Q.front(); Q.pop();
		for (int i = firx[x]; i; i = nexx[i]) {
			if (tim[arrx[i]] < inf) continue;
			if (tim[x] + 1 < dep[arrx[i]] && tim[x] + 1 < tim[arrx[i]]) {
				tim[arrx[i]] = tim[x] + 1;
				Q.push(arrx[i]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (tim[i] < inf) {
			if (tag[i]) {
				puts("-1");
				exit(0);
			}
			else ans = max(ans, dep[i] * 2);
		}
	}
	cout << ans << endl;
}

int main() {
	scanf("%d%d%d", &n, &X, &Y);
	for (int i = 1; i < n; ++i) {
		scanf("%d%d", &a[i], &b[i]);
	}
	for (int i = 1; i < n; ++i) {
		scanf("%d%d", &c[i], &d[i]);
	}
	for (int i = 1; i < n; ++i) {
		Add_Edge(c[i], d[i]);
		Add_Edge(d[i], c[i]);
	}
	dfs(Y);
	for (int i = 1; i < n; ++i) {
		Add_Edge2(a[i], b[i]);
		Add_Edge2(b[i], a[i]);
		if (dis(a[i], b[i]) == 3) tag[a[i]] = tag[b[i]] = 1;
	}
	memset(tim, 0x3f, sizeof tim);
	bfs();
	return 0;
}


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

int main(){
  int n,k;
  int count=0;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
    if(h[i]>=k){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>


int able(int p,int n, int k, int* w);
long long minimum(int n,int k,int* w);

int main(void){
    int n,k;
    scanf("%d %d",&n,&k);
    int* w = (int*)malloc(n*sizeof(int));
    for(int i=0;i<n;i++){
        scanf("%d",&(w[i]));
    }
    printf("%lld\n",minimum(n,k,w));
    return 0;
}

int able(int p,int n,int k,int* w){
    int truck=1;
    long weight=0;
    for(int i=0;i<n;i++){
        if(w[i]>p){
            return 0;
        }
        if(weight+w[i]>p){
            truck+=1;
            weight=0;
        }
        weight+=w[i];
    }
    if(truck>k){
        return 0;
    }
    else{
        return 1;
    }
}

long long minimum(int n,int k,int* w){
    long long min,max,mid;
    min=0;
    max=1000000010;
    while(min+1<max){
        mid=(min+max)/2;
        if(able(mid,n,k,w)){
            max=mid;
        }
        else{
            min=mid;
        }
    }
    for(long long i=min;i<=max;i++){
        if(able(i,n,k,w)){
            return i;
        }
    }
}



Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll X,t;
  cin>>X>>t;
  if(X>t) {

  cout<<X-t<<endl;
    return 0;
}
  cout<<0<<endl;
}


Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,min_priority_queue<ll>> a,pair<ll,min_priority_queue<ll>> b){
    return a.fi > b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------
    ll x;cin>>x;
    if(x==0)cout<<1<<endl;
    else cout<<0<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 3640
#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>
#define rep(i,a,n) for(int i =(a);i<(n);i++)
#define urep(i,a,n) for(int i = (a);i>(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int N, M;
int A[1000000];
int ans;
int main() {
	cin >> N >> M;
	if (N == 0) {
		if (M != 100)cout << M << endl;
		if (M == 100)cout << 100 + 1 << endl;
	}
	else if (N == 1) {
		if (M != 100)cout << 100 * M;
		if (M == 100)
			cout << 10000 + 100 << endl;
	}
	else if (N == 2) {
		if(M!=100)cout << 10000 * M << endl;
		if (M == 100)
			cout << 1000000 + 10000 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>

using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
  return 0;
}

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

int cnt = 0;

void bubbleSort(int A[], int N) {
	int flag = 1;
	while (flag){
		flag = 0;
		for (int j = N - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				cnt++;
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	int a[110];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	bubbleSort(a, N);
	for (int i = 0; i < N - 1; i++) {
		cout << a[i] << " ";
	}
	cout << a[N - 1] << endl;
	cout << cnt << endl;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x;
  cin >> n >> x;
  VLL l(n);
  ll d = 0;
  int cnt = 1;
  rep(i,n){
    cin >> l[i];
    d += l[i];
    if(d <= x) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,ans=0;
    cin>>n;
    vll l;
    rep(i,n){
        ll a;
        cin>>a;
        l.push_back(a);
    }
    sort(all(l));
    rep(i,l.size()){
        rep2(j,i+1,l.size()){
            ll s;
            s=lower_bound(l.begin()+j+1,l.end(),l[i]+l[j])-l.begin();
            s-=(j+1);
            ans+=s;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x,k;
		k=sc.nextInt();
		x=sc.nextInt();
		for(int i=x-k+1;i<=x+k-1;i++){
			System.out.print(i+" ");
		}
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

vector<int> g[100005];

pair<bool, int> dfs(int v, int from){
  if(from != -1){
    if(g[v].size()==1) return {true, 0};
    if(g[v].size()==2){
      for(auto to : g[v]) if(to!=from) return dfs(to, v);
    }
  }
  int np = 0;
  int ret = 0;
  for(auto to : g[v]) if(to != from){
    auto p = dfs(to, v);
    if(p.fi) np++;
    else ret += p.se;
  }
  ret += max(np-1, 0);
  return {false, ret};
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    g[a].pb(b);
    g[b].pb(a);
  }

  int st = -1;
  rep(i,n) if(g[i].size()>2) st = i;

  if(st == -1){
    // line
    cout << 1 << endl;
    return 0;
  }
  cout << dfs(st,-1).second << endl;

  // rep(i,n) dbg(i, dfs(i,-1));

  return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
bool check(string s){
    for(int i=0;i<s.length()-1;i++){
        if(s[i]!=s[i+1]){
            return false;
        }
    }
    return true;
}
int main () {
  int n;
  cin>>n;
  while(true){
    if(check(to_string(n)))break;
    n++;
  }
  cout<<n<<endl;
  return 0;
}

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

int main(){
    string str;
    getline(cin, str);
    for(int i=0; i<str.size(); i++){
        if(str[i]>='a'&&str[i]<='z'){
            str[i]+='A'-'a';
        }else if(str[i]>='A'&&str[i]<='Z'){
            str[i]+='a'-'A';
        }
    }
    cout << str << endl;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
const int INF = (1<<30);

int main()
{
  int n;
  while( cin >> n, n ) {
    int ma = 0, mi = INF, sum = 0, data;

    for(int i=0; i<n; i++) {
      cin >> data;
      sum += data;
      if( data > ma ) ma = data;
      if( data < mi ) mi = data;
    }
    
    sum = sum - ma - mi;
    cout << sum / (n-2) << endl;
  }

} 

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;

const ll inf =1LL << 62;
const ll mod=1000000007LL;

inline ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
inline ll ADD(const ll &a, const ll &b,const ll &mod) { return a+b<mod?a+b:a+b-mod;}
inline ll SUB(const ll &a, const ll &b,const ll &mod) { return a-b>=0?a-b:a-b+mod;}
inline ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
inline ll INV(ll a,ll mod){ll x,y;extgcd(a,mod,x,y);return (x%mod+mod)%mod;}
inline ll DIV(const ll &a, const ll &b,const ll &mod) {return MUL(a,INV(b,mod),mod);}
inline ll POW(ll a,ll n,ll mod){ll b=1LL;for(a%=mod;n;a=MUL(a,a,mod),n>>=1)if(n&1) b=MUL(b,a,mod); return b;}


ll dp[55][1<<18][2];

int main(void){
	int n;
	cin >> n;
	
	int ok=1,sum=0;
	rep(i,3){
		int in;
		cin >> in;
		sum+=in;
		ok|=bit(sum);
	}

	dp[0][1][0]=1LL;
	const int all=bit(sum+1)-1;

	rep(i,n)rep(s,2){
		if(s==1){
			dp[i+1][0][s]=ADD(dp[i+1][0][s],MUL(10LL,dp[i][0][s],mod),mod);
			continue;
		}

		rep(mask,1,all){
			rep(d,1,11){
				int nmask=((mask<<d))|1;
				if((nmask&ok)==ok)
					dp[i+1][0][1]=ADD(dp[i+1][0][1],dp[i][mask][s],mod);
				else
					dp[i+1][nmask&all][s]=ADD(dp[i+1][nmask&all][s],dp[i][mask][s],mod);
			}
		}
	}

	cout << dp[n][0][1] << endl;
	return 0;
}

Measured memory_bytes: 164096
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            int tmp = 0;
            int a = sc.nextInt();
            while(a % 2 == 0){
                tmp++;
                a /= 2;
            }
            ans = Math.min(ans,tmp);
        }
        System.out.println(ans);
    }
}
 

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll all = 0;
  rep(i, n) {
    all ^= a[i];
  }

  rep(i, n) {
    ll ans = all ^ a[i];
    cout << ans << " ";
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 4780
import numpy as np
n,m=map(int,input().split())
a=np.array([list(input())for i in range(n)])
b=np.array([list(input())for i in range(m)])
d=n-m+1
for i in range(d):
 for j in range(d):
  if (a[i:i+m,j:j+m]==b).all():print("Yes");exit()
print("No")

Measured memory_bytes: 27236
module Main where

import           Control.Monad       as CM (forM, forM_, replicateM)
import qualified Data.List           as DL (intersect)

quasiSolveB :: (Int, Int) -> IO Int
quasiSolveB (n, m) = do
  contents <-
    (\strings -> do
       oneLine <- strings
       let string2Ints = fmap read . tail . words :: String -> [Int]
       return $ string2Ints oneLine) <$>
    CM.replicateM n getLine
  return $ length $ foldl1 DL.intersect contents

main = do
  ans <- getLine >>= quasiSolveB . (\x -> (head x, last x)) . fmap read . words
  putStrLn $ show ans


Measured memory_bytes: 1148
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

vector<vector<int>> ansvec;
int a[501][501], x[100001],ballNum[100001];
bool can[100001];

vector<string> v;

int count(string s) {
	int cnt = 0;
	for (string st : v) {
		if (st == s) cnt++;
	}
	return cnt;
}

signed main() {
	int A, B;
	cin >> A >> B;
	if (A % 2 == 0 || B % 2 == 0) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#include <stack>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
ll R,C;

ll convert(ll x,ll y){
    ll res=-1;
    if(x==0) res=y;
    else if(y==C) res=C+x;
    else if(x==R) res=R+C+C-y;
    else if(y==0) res=2*C+R+R-x;

    return res;
}

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

  vector<pair<ll,int>> edges;
  for(int i=0;i<N;i++){
      ll a,b,c,d;
      cin>>a>>b>>c>>d;

      ll va=convert(a,b);
      ll vb=convert(c,d);
      if(va!=-1&&vb!=-1){
          edges.push_back(mkp(va,i+1));
          edges.push_back(mkp(vb,i+1));
      }
  }
  sort(edges.begin(),edges.end());

  stack<ll> st;
  map<ll,int> mp;
  for(int i=0;i<edges.size();i++){
      int now=edges[i].second;
      if(st.empty()) st.push(now);
      else if(st.top()==now) st.pop();
      else if(mp[now]==0){
          st.push(now);
          mp[now]=1;
      }else{
          cout<<"NO"<<endl;
          return 0;
      }
  }
  cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 10604
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){
  int N, M; cin >> N >> M;
  
  char S[N][M]; int check[N][M];
  int ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      cin >> S[i][j];
      if(S[i][j] == '.') ans++;
      check[i][j] = -1;
    }
  }

  check[0][0] = 1;
  queue <pair<int, int> > que;
  que.push(make_pair(0, 0));

  while (!que.empty()){
    pair<int, int> P = que.front(); que.pop();

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

    for (int i = 0; i < 4; i++){
      int nx = P.first + dx[i];
      int ny = P.second + dy[i];

      if (0 <= nx && nx < N && 0 <= ny && ny < M && S[nx][ny] == '.'){
        if (check[nx][ny] == -1){
          check[nx][ny] = check[P.first][P.second] + 1;
          que.push(make_pair(nx, ny));
        }
      }
    }
  }

  if (check[N - 1][M - 1] == -1){
    cout << -1 << endl;
  }else{
    cout << ans - check[N - 1][M - 1] << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	 public static void main(String[] args) {

	  Scanner s = new Scanner(System.in);

	  int x = s.nextInt();
	 
	  if(x>=400 && x<=599)
	  {
		  System.out.println("8");
	  }
	  else if(x>=600 && x<=799)
	  {
		  System.out.println("7");
	  }
	  else if(x>=800 && x<=999)
	  {
		  System.out.println("6");
	  }
	  else if(x>=1000 && x<=1199)
	  {
		  System.out.println("5");
	  }
	  else if(x>=1200 && x<=1399)
	  {
		  System.out.println("4");
	  }
	  else if(x>=1400 && x<=1599)
	  {
		  System.out.println("3");
	  }
	  else if(x>=1600 && x<=1799)
	  {
		  System.out.println("2");
	  }
	  else if(x>=1800 && x<=1999)
	  {
		  System.out.println("1");
	  }
	  
	 }
}

Measured memory_bytes: 35652
#include<bits/stdc++.h>
using namespace std;
const int N=2105;
int n,x,y,a[N];
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(n==1){printf("%d\n",abs(a[1]-y)); return 0;}
	int ans=max(abs(a[n]-y),abs(a[n-1]-a[n]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	int k,s,r=0;
	cin >> k >> s;
	int x,y,z;
	for (int y=0;y<=k;y++){
		for (int z=0;z<=k;z++){
			int x = s-y-z;
			if (x <= k && x >= 0){
				r++;
			}
		}
	}	
	
	cout << r;
	
	
	return 0;
}

Measured memory_bytes: 3600
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
input_line = input().split()

N = int(input_line[0])
M = int(input_line[1])
counter = 0 
if N > 1:
    counter += combinations_count(N,2) 
if M > 1:
    counter += combinations_count(M,2)
        
print(counter)

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if ((A != B || B != C || A != C) && !(A != B && B != C && A != C)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_variables, dead_code)]
//use permutohedron::LexicalPermutation as _;
//use proconio::input;
use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    proconio::input! {
        H:usize,W:usize,K:u32,
        S:[Chars;H]
    }
    let S: Vec<Vec<u32>> = S
        .iter()
        .map(|Si| Si.iter().map(|&c| (c as u8 - '0' as u8) as u32).collect())
        .collect();
    // Hの分割法を0から2^H-1まで総当たりで試す。
    // h_bar[i]==trueなら、i行目とi+1行目の間が結合していることを示す。
    // 逆にいうと、h_bar[i]==trueの行の数は、次の行の数に足す。
    // なお、H_bar[H-1]は常にfalseなので、次の行に足してしまうことは無い。
    // div がその時の分割数。
    let mut ans = H + W;
    let mut h_bar = vec![false; H];
    for h_devide in 0..(2i32.pow(H as u32 - 1)) {
        let mut div = h_devide.count_ones() as usize;
        for i in 0..H - 1 {
            h_bar[i] = (h_devide >> i) & 1 == 0;
        }
        //println!("h_devide {:?},{}", h_bar, div);
        // 以下、W方向について貪欲法。
        let mut white = vec![0; H];
        let mut w_len = 0;
        let mut w = 0;
        while w < W {
            //   println!("{}", w);
            let mut w_flag = true;
            for h in 0..H {
                // 各行を最大数がKになるまで結合していく。
                white[h] += S[h][w];
                if h_bar[h] {
                    white[h + 1] += white[h];
                    white[h] = 0;
                }
                if white[h] > K {
                    w_flag = false;
                    break;
                }
            }
            if !w_flag {
                // Kを超えてしまったら、分割を追加し、whiteを初期化して、同じ列をやり直す。
                // この時w_lenをリセット
                if w_len == 0 {
                    // ただし一行も追加できかった場合は打ち切り。
                    div = H + W;
                    break;
                }
                div += 1;
                white = vec![0; H];
                w_len = 0;
                continue;
            }
            // 無事に1列追加出来たら。
            w_len += 1;
            w += 1;
        }
        //println!("h分割{:?}, 計{}", h_bar, div);
        ans = std::cmp::min(ans, div);
    }

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


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

using namespace std;

const int64_t INF = 1LL << 60;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int, int>> P(N);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    P[i] = make_pair(x, i);
  }
  sort(P.begin(), P.end(), greater<pair<int, int>>());
  vector<vector<int64_t>> dp(N + 1, vector<int64_t>(N + 1, 0));
  int64_t res = 0;
  for (int l = 0; l < N; l++) {
    for (int r = 0; r < N; r++) {
      if (l + r == N) {
        res = max(res, dp[l][r]);
        break;
      }
      int64_t a = P[l + r].first;
      int b = P[l + r].second;
      chmax(dp[l + 1][r], dp[l][r] + abs(b - l) * a);
      chmax(dp[l][r + 1], dp[l][r] + abs(b - (N - 1 - r)) * a);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 34620
# A - Wanna go back home
ss=input()
n=ss.count('N')
w=ss.count('W')
s=ss.count('S')
e=ss.count('E')

ns=False
if n>0 and s>0:
    ns=True
elif n==0 and s>0:
    ns=False
elif n>0 and s==0:
    ns=False
elif n==0 and s==0:
    ns=True

we=False
if w>0 and e>0:
    we=True
elif w==0 and e>0:
    we=False
elif w>0 and e==0:
    we=False
elif w==0 and e==0:
    we=True

if ns==True and we==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int kisuu[] = {3,5,7,11,13};
    int kisuuu[] = {27};
    int kisuuuu[] = {105, 165, 195};
    int kisuuuuu[] = {135, 189};
    int listt[] = {105, 165, 195, 135, 189};
    int ans = 0;
    for(int i = 0; i < 5; i++){
        if(n >= listt[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


ll dp[2020];

int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;




        dp[0]=1;

        cin>>n;

        for(i=3; i<=n; i++)
        {
            for(j=3; j<=i; j++)
            {
                dp[i]=(dp[i]+dp[i-j])%Mod;

            }
        }

        cout<<dp[n]<<endl;











}



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

const int N = 100010;
const long long INF = 1e18;
typedef pair<long long, int> li;

int n, m, s, t;
vector < pair<int,int> > A[N], B[N];
long long dis[N][2];
long long res[N];

void dijkstra(int start) {
	int k = (start == s);
	for (int i = 1; i <= n; ++i) dis[i][k] = INF;
	dis[start][k] = 0;
	
	priority_queue < li, vector <li>, greater <li> > pq;
	pq.push(make_pair(0, start));

	while(!pq.empty()) {
		li top = pq.top(); pq.pop();
		int u = top.second;
		long long du = top.first;

		if (du != dis[u][k]) continue;

		for (auto &e : ((start == s) ? A[u] : B[u])) {
			int cost = e.first, v = e.second;
			if (dis[v][k] > du + cost) {
				pq.push(make_pair(dis[v][k] = du + cost, v));
			}
		}
	}
}

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

	cin >> n >> m >> s >> t;
	while(m--) {
		int u, v, x, y;
		cin >> u >> v >> x >> y;
		A[u].push_back(make_pair(x, v));
		A[v].push_back(make_pair(x, u));
		B[u].push_back(make_pair(y, v));
		B[v].push_back(make_pair(y, u));
	}

	dijkstra(s); // computed in yen
	dijkstra(t); // computed in snuuk

	res[n] = INF;
	for (int i = n; i >= 1; --i) {
		res[i - 1] = min(res[i], dis[i][1] + dis[i][0]);
	}

	for (int i = 0; i <= n - 1; ++i) {
		long long cur = res[i];
		printf("%lld\n", (long long)1e15 - cur);
	}
}

Measured memory_bytes: 16380
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
li = np.zeros(26)
li_one = np.ones(26)
c_sum = sum(c)
for lis in s:
  tmp_list = lis ** 2 / c**0.01
  idx_list = np.argsort(tmp_list)[:-6:-1]
  li += li_one
  max_idx = -1
  max_score = -10**10
  for i in idx_list:
    tmp = li
    li += li_one
    li[i] = 0
    sum_c_li = np.sum(c*li)
    score = lis[i] - sum_c_li
    if score > max_score:
      max_idx = i
      max_score = score
    li = tmp
  print(max_idx + 1)


  

Measured memory_bytes: 27544
//If You think you are Bad...I'm your Dad 
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n;
		int ans =1;
		fn{
			cin >> ar[i];
		}
		sort(ar,ar+n);
		fn{
			if(ans > 1e18L/ar[i])return cout<<"-1",0;
			ans*=ar[i];
			if(ans==0)break;
		}
		cout<<ans;
	
	
	}
	return 0;
}


Measured memory_bytes: 4432
N, M = map(int, input().split())

s = [0] * (N+1)

for i in range(M):
    ai = int(input())
    s[ai] = -1

s[0] = 1

if N == 1:
    print(1)
else:
    if s[1] == 0:
        s[1] = 1

    for i in range(2,N+1):
        if s[i] >= 0:
            s[i] += (max(0,s[i-1]) + max(0,s[i-2]))

    print(s[N] % 1000000007)

Measured memory_bytes: 462708
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
l = list()
for i in range(1,10):
    for j in range(1,10):
        l.append(i * j)
print('Yes' if n in l else 'No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    int m = n % 1000;
    if (m == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - m << endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int a[110][110]; int b[110][110];long long int c[110][110];
int main() {
	int n, m,l; int sum = 0;
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += (a[i][k]* b[k][j]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
		    if(j != l - 1){
			cout << c[i][j] << " ";
		    }
		    else{
		        cout << c[i][j] << endl;
		    }
		}
	}
}


Measured memory_bytes: 3272
#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() {
    int n;
    cin >> n;
    vector<int> v(n+1);
    int a;
    for(int i=0;i<n-1;i++){
        cin >> a;
        v[a]++;
    }
    for(int i=1;i<n+1;i++){
        cout << v[i] << endl;
    }
return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
  cout << -1 << endl;
  exit(0);
}

int main(){
    ll n;
    cin >> n;
    string s[n];
    ll t[n];
    string x;
    for(ll i=0; i < n; i++){
        cin >> s[i] >> t[i];
    }
    cin >> x;
    ll ans = 0;
    bool f = false;
    for(ll i=0; i < n; i++){
        if(f){
            ans += t[i];
        }
        if(x == s[i]){
            f = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;




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

	string S;
	cin >> S;
	int N = S.size();
	string res = "Yes";
	string T = S;
	reverse(T.begin(), T.end());
	if (S != T) res = "No";
	T = S.substr(0, (N - 1) / 2);
	reverse(T.begin(), T.end());
	if (S.substr(0, (N - 1) / 2) != T) res = "No";
	T = S.substr((N + 3) / 2 - 1);
	reverse(T.begin(), T.end());
	if (S.substr((N + 3) / 2 - 1) != T) res = "No";
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq as hq
N,M,S = list(map(int, input().split()))
#Edge
E = [[] for _ in range(N)]
  
for _ in range(M):
  # U <-> V, A coins, B mins
  u,v,a,b = list(map(int, input().split()))
  # 0-indexed
  E[u-1].append([v-1, a, b])
  E[v-1].append([u-1, a, b])

# City
C = []
for _ in range(N):
  # C coins, D mins
  C.append(list(map(int, input().split())))
  
# dp[p][i] 点Pにたどり着いた時、i円持っている時の最小時間
MAXYEN = 50 * N
dp = [[ 1e18 for i in range(MAXYEN + 5) ] for _ in range(N)]
S = min(MAXYEN, S)
dp[0][S] = 0

# 状態は点とお金と時間. time, pointindex, money
Q = []
hq.heapify(Q)
hq.heappush(Q, [0,0,S])

while len(Q) > 0:
  nowt, nowi, nowm = hq.heappop(Q)
  #print("Pop :", nowt, nowi, nowm)
  # Edgeをわたる。a yen払ってB時間かけて、Vに移動する。
  for e in E[nowi]:
    to_i, costm, costt = e
    #print("Edge:", to_i, costm, costt)
    if nowm - costm < 0:
      # unreachable 
      continue
    if dp[to_i][nowm-costm] > dp[nowi][nowm] + costt:
      dp[to_i][nowm-costm] = dp[nowi][nowm] + costt
      hq.heappush(Q, [dp[nowi][nowm] + costt, to_i, nowm-costm])
      
  # その場でお金を1回買う。移動せず、CYenGetして、D時間かける
  getm, costt = C[nowi]
  targetm = min(MAXYEN, nowm + getm)
  #print("Buy :", getm, targetm, costt)
  if dp[nowi][targetm] > dp[nowi][nowm] + costt:
    dp[nowi][targetm] = dp[nowi][nowm] + costt
    hq.heappush(Q, [dp[nowi][targetm], nowi, targetm])
  
for i in range(1,N):
  print(min(dp[i]))
  


Measured memory_bytes: 28788
#include <bits/stdc++.h>
using namespace std;
#define m 1000000007
#define N 200005
#define modinv(a) power(a,m-2)
#define gcd(a,b) __gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define popb pop_back
#define all(v) v.begin(),v.end()
#define nl "\n"
typedef long long ll;
ll power(ll a,ll b)
{
    ll res;
    if(b==0)return 1;
    if(b==1)return a%m;
    if(b&1)
    {
        res=power(a,b-1)%m;
        res=((a%m)*(res%m))%m;
    }
    else
    {
        res=power(a,b/2)%m;
        res=((res%m)*(res%m))%m;
    }
    return res;
}
void solve()
{
    ll n,c1=0,c2=0,c3=0,c4=0;
    cin>>n;
    string s;
    while(n--)
    {
        cin>>s;
        if(s=="AC")
        c1++;
        else if(s=="WA")
        c2++;
        else if(s=="TLE")
        c3++;
        else
        c4++;
    }
    cout<<"AC x "<<c1<<nl;
    cout<<"WA x "<<c2<<nl;
    cout<<"TLE x "<<c3<<nl;
    cout<<"RE x "<<c4<<nl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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

int main() {
    int n;
    bool check;
    cin >> n;
    int i = 1;
    while (i<=n) {
        int x = i;
        if (x%3 == 0) {
            cout << ' ' << i;
            check = false;
        }
        while (x>=3) {
            if (x%10 == 3 && check) {
                cout << ' ' << i;
                break;
            }
            x/=10;
        }
        check = true;
        ++i;
    }
    cout << endl;
    return 0;
}


/*137
137%10 = 7
137/10 = 13
13%10 = 3 */


Measured memory_bytes: 3084
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#define maxn 100009
using namespace std;
int H, W, n, a[maxn];
int ans[109][109];
int main(){
	cin >> H >> W;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	int x = 1, y = 1, d = 1;
	for(int i = 1; i <= n; i++){
		int tt = a[i];
		while(tt--){
			ans[x][y] = i;
			y += d;
			if(y > W){
				x++;
				y = W;
				d = -1;
			}
			else if(y < 1){
				x++;
				y = 1;
				d = 1;
			}
		}
	}
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			printf("%d", ans[i][j]);
			if(j == W) puts("");
			else printf(" ");
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include<stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,l,r) for(int i=l; i<(int)(r); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const ll MOD = 1000000007;

ll A[12];

int main(){
    int N,K; scanf("%d%d", &N, &K);
    rep(i,N){
        scanf("%d", A+i);
    }

    ll ans = MOD*MOD;
    rep(bit, (1 << N)) {
        if(__builtin_popcount(bit) < K) continue;
        ll tmp_a = 0, tmp_h = 0;

        rep(i, N) {
            if(bit&(1<<i)){
                if(A[i] <= tmp_h){
                    tmp_a += tmp_h-A[i]+1;
                    tmp_h++;
                }else{
                    tmp_h = A[i];
                }
            }else{
                tmp_h = max(tmp_h,A[i]);
            }
        }
        
        ans = min(ans, tmp_a);
    }
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1700
s = input()
count = 0
tmp = 0
for b in s:
    if b == 'A' or b == 'T' or b == 'G' or b == 'C':
        tmp += 1
    else:
        count = max(count, tmp)
        tmp = 0
        continue
count = max(count, tmp)
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    int l, q;
    cin >> l >> q;
    vector<vector<int>> dp(31, vector<int>(n+1));
    for(int i = 0; i < n; i++)
    {
        int now = x[i];
        dp[0][i+1] = lower_bound(x.begin(), x.end(), now + l + 1) - x.begin();
    }
    dp[0][n] = -1;
    for(int k = 0; k < 30; k++)
    {
        for(int i = 1; i <= n; i++)
        {
            if(dp[k][i] == -1) dp[k+1][i] = -1;
            else dp[k+1][i] = dp[k][dp[k][i]];
        }
    }
    while(q--)
    {
        int a, b;
        cin >> a >> b;
        int left = min(a, b);
        int right = max(a, b);
        int ans = 0;
        for(int k = 30; k >= 0; k--)
        {
            int next = dp[k][left];
            if(next >= 0 && next < right)
            {
                left = next;
                ans |= 1 << k;
            }
        }
        ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 13432
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+5;;
int n;
ll a[maxn],f[maxn];
bool judge(ll x,ll kk)
{
    for(int i=1;i<=n;i++)
    {
        if(a[i]*f[i]<=x)
        {
            continue;
        }
        else
        {
            ll t=x/f[i];
            kk-=(a[i]-t);
            if(kk<0)return false;
        }
    }
    return true;
}
int main()
{
    ll k;
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n,greater<int>());
    for(int i=1;i<=n;i++)
        scanf("%lld",&f[i]);
    sort(f+1,f+1+n);
    ll l=0,r=2e12;
    while(l<r)
    {
        ll mid=(l+r)/2;
        if(judge(mid,k))r=mid;
        else l=mid+1;
    }
    printf("%lld",r);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int A, B, K; cin >> A >> B >> K;
  	rep(i, K) {
      if (i%2==0) {
        B += A/2;
        A/=2;
      }
      else {
        A += B/2;
        B/=2;
      }  
    }
  cout << A << " " << B << endl;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n, m;
    cin >> n >> m;
    int res = 0;
    res = n * (n - 1) / 2 + m * (m - 1) / 2;
    c(res);
    return 0;
}


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

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

    vector<int> num;
    num.resize(3, 0);
    int K;
    for(int i = 0; i < 3; i++){
        cin >> num[i];
    }
    cin >> K;

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

    for(int i = 0; i < K; i++){
        num[2] *= 2;
    }

    int ans = num[0] + num[1] + num[2];
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target("avx")
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

ll dp[100001];

int main(void){
    cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl h(n);
	rep(i,n){
	    cin>>h[i];
	    dp[i] = inf;
	}
	dp[0] = 0;
	rep(i,n){
	    rep1(j,k+1){
	        if(i+j<n) dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
	    }
	}
	cout<<dp[n-1]<<endl;
}


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


int main(void)
{
	//変数の宣言
	int h,w,n;
	int a[10010];
	int i,j;
	int map[110][110];
	int mapx,mapy;
	int temp;
	
	//データの読み込み
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	mapx=0;
	mapy=0;
	
	for(i=0;i<n;i++){
		temp=a[i];
		while(temp>0){
			map[mapx][mapy]=i+1;
//			printf("map[%d][%d]=%d\n",mapx,mapy,i+1);
			temp--;
			if(mapx%2==0&&mapy==w-1){
				mapx++;
			}else if(mapx%2==0){
				mapy++;
			}else if(mapy==0){
				mapx++;
			}else{
				mapy--;
			}
		}
	}
				
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			printf("%d ",map[i][j]);
		}
		printf("\n");
	}
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 256
def hum(L,X):
    if L == 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= 1 + t[L-1]:
        return hum(L-1,X-1)
    elif X <= 2 + 2 * t[L-1]:
        return p[L-1] + hum(L-1,X-2-t[L-1]) + 1
    else:
        return 2 * p[L-1] + 1

n, x = map(int,input().split())
t = [1]
p = [1]
for i in range(n):
    t.append(t[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
print(hum(n,x))

Measured memory_bytes: 3064