akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <vector>

using namespace std;

const double EPS = 1e-7;
typedef complex<double> P;
typedef vector<P> G;

double cross(P a, P b) { return imag(conj(a)*b); }

// 多角形gの面積を求める
double polygonArea(G g){
	double res = 0.0;
	for(int i=0;i<g.size();i++)
		res += cross(g[i],g[(i+1)%g.size()]);
	return abs(0.5*res);
}

// 凸多角形gを，2点p, qを結ぶ線分で切断する
G convexCut(G g, P p, P q){
	G res;
	int n = g.size();
	for(int i=0;i<n;i++){
		P A(g[i]), B(g[(i+1)%n]);
		double p1 = cross(q-p,A-p);
		double p2 = cross(q-p,B-p);
		if(p1 > -EPS) res.push_back(A);
		if(p1*p2 < -EPS)
			res.push_back(A+cross(q-p,q-A)/cross(q-p,B-A)*(B-A));
	}
	return res;
}

int main(){
  int x[3], y[3];
  for(int test=1; ;test++){
    for(int i=0;i<3;i++) cin >> x[i] >> y[i];
    if(x[0] == 0) break;
    G g;
    g.push_back(P(0,0));
    g.push_back(P(10000,0));
    g.push_back(P(10000,10000));
    g.push_back(P(0,10000));
    for(int i=1;i<3;i++){
      P a = P(x[0], y[0]);
      P b = P(x[i], y[i]);
      P mid = 0.5*(a+b);
      P dir = mid + P(0,1)*(b-a);
      g = convexCut(g, mid, dir);
    }
    printf("%d %.10lf\n", test, 1e-8*polygonArea(g));
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int count=0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            count++;
            i++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    int D;
    while(cin>>D){
        int d=D;
        int ans=0;
        for(int i=600;i>0;i-=D){
            d-=D;
            ans+=pow(d,2)*D;
        }
        
        cout<<ans<<endl;
    }
    
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;

  int C;
  if (A > B) {
    C = A;
    A--;
  } else {
    C = B;
    B--;
  }

  if (A > B) {
    cout << C + A << endl;
  } else {
    cout << C + B << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[100001];
int a[101];
int main()
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<=k;i++)
		for(int j=1;j<=n;j++)
			if(i>=a[j]&&!dp[i-a[j]])dp[i]=1;
	if(dp[k]==1)cout<<"First";
	else cout<<"Second";
	return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
 
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
 
 
int main() {
  string S, T;
  cin >> S >> T;


  ll ans = 0;
  for (ll i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) ans++;
  }
  
  


  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  Vec(P,lli,0,0);
  cin >> K;
  map<int,int>dist;
  int k[]={1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,32,33,34,43,
 44,45,54,55,56,65,66,67,76,77,78,87,88,89,98,99};
  for(auto v:k){
    P.pb(v);
    dist[v]=1;
  }
  queue<lli>que;
  rep(i,9,36)que.push(P[i]);
  while(P.size()<3*K){
    auto v=que.front();que.pop();
    if(dist.find(v) == dist.end())continue;
    if(v%10!=0){
      P.pb(v*10+v%10-1);
      que.push(v*10+v%10-1);
      dist[v*10+v%10-1]=1;
    }
    P.pb(v*10+v%10);
    que.push(v*10+v%10);
    dist[v*10+v%10]=1;
    if(v%10!=9){
      P.pb(v*10+v%10+1);
      que.push(v*10+v%10+1);
      dist[v*10+v%10+1]=1;
    }
  }
  Sort(P);
  Out(P[K-1]);
}


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

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

    string s;
    cin >> s;

    int cnt = 0;
    for(char c : s){
        if(c=='x') cnt++;
    }

    if(cnt < 8) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

// Solution for https://atcoder.jp/contests/abc175/tasks/abc175_c

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var x, k, d int
	con.Scan(&x, &k, &d)
	if x < 0 {
		x = -x
	}
	y := x / d
	if y > k {
		y = k
	}
	x -= y * d
	k -= y
	if k == 0 {
		con.Println(x)
		return nil
	}
	if x == 0 {
		if k%2 == 0 {
			con.Println(0)
		} else {
			con.Println(d)
		}
		return nil
	}
	if k%2 == 0 {
		con.Println(x)
	} else {
		con.Println(d - x)
	}
	return nil
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t H, W, h, w;
    cin >> H >> W >> h >> w;

    if (H % h == 0 && W % w == 0) {
        cout << "No" << endl;
        return 0;
    }

    bool sw = false;
    if (H % h == 0) {
        std::swap(H, W);
        std::swap(h, w);
        sw = true;
    }

    vector<vector<int64_t>> a(H, vector<int64_t>(W));
    for (auto i : irange(0L, H / h)) {
        for (auto j : irange(0L, W)) {
            a[i * h][j] = H / h + 1;
            a[i * h + H % h][j] = -H / h - 2;
        }
    }
    for (auto j : irange(0L, W)) {
        a[H / h * h][j] = H / h + 1;
    }

    cout << "Yes" << endl;
    if (sw) {
        for (auto i : irange(0L, W)) {
            const auto* delim = "";
            for (auto j : irange(0L, H)) {
                cout << delim << a[j][i];
                delim = " ";
            }
            cout << "\n";
        }
    } else {
        for (auto i : irange(0L, H)) {
            const auto* delim = "";
            for (auto j : irange(0L, W)) {
                cout << delim << a[i][j];
                delim = " ";
            }
            cout << "\n";
        }
    }
}

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

int main(){
	long long int N, M, i;
	cin >> N >> M;
	int H[N+1], A[M+1], B[M+1];
	for(i=1; i<=N; i++){
		cin >> H[i];
	}
	for(i=1; i<=M; i++){
		cin >> A[i] >> B[i];
	}
	
	long long flg[N+1]={0};
	for(i=1; i<=M; i++){
		if(H[A[i]]>H[B[i]])		flg[B[i]]++;
		else if(H[A[i]]<H[B[i]])	flg[A[i]]++;
		else if(H[A[i]]==H[B[i]]){
			flg[A[i]]++;
			flg[B[i]]++;
		}
	}
	
	long long int ans=0;
	for(i=1; i<=N; i++){
		if(flg[i]==0)	ans++;
	}
	
	cout << endl << ans << endl;
	return 0;
}


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

signed main(){
  int A,B;
  cin>>A>>B;
  if(B%A==0){
    cout<<A+B<<endl;
  }else{
    cout<<B-A<<endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp1 = input[0].split(" ");
    tmp2 = input[1].split(" ");
    boxRowNum = tmp1[0];
    boxColNum = tmp1[1];
    paintRowNum = tmp2[0];
    paintColNum = tmp2[1];

    output = (boxRowNum - paintRowNum)*(boxColNum - paintColNum);

    console.log(output);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  long long a[n];
  int negs=0,zeros=0;
  long long s=0;
  REP(i,n){
    cin>>a[i];
    s += abs(a[i]);
    if(a[i]==0){
      zeros++;
    }else if(a[i]<0){
      negs++;
    }
  }
  
  long long ans;
  long long d;
  if(negs%2==1 && zeros==0){
    REP(i,n){
      if(i==0){
        d = abs(a[0]);
      }else{
        d = min(d,abs(a[i]));
      }
    }
    ans = s-2*d;
  }else{
    ans = s;
  }
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;

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

  string s;
  cin >> s;
  int n = s.size();

  int c1 = 0, c2 = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i]-'0' == i%2) c1++;
    else c2++;
  }
  cout << min(c1, c2) << endl;

  return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

int array[100000];

int main(void)
{
	int n;
    int k;
    int i, j;
    
    while (scanf("%d %d", &n, &k) * n != 0){
        int maxi;
        int sum;
        
        for (i = 0; i < n; i++) scanf("%d", array + i);
        sum = 0;
        for (i = 0; i < k; i++) sum += array[i];
        maxi = sum;
        for (i = k; i < n; i++){
            sum = sum - array[i - k] + array[i];
            if (maxi < sum) maxi = sum;
        }
        printf("%d\n", maxi);
    }
    
    return 0;
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 4e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
 
#define M 100010

map<ll,ll>mp;
ll a,b,c,d;
ll f(ll n){
	if(n<=1)return n*d;
	if(mp[n])return mp[n];
	ll ans=inf;
	if(n<=4e9)ans=min(ans,n*d);
	
	ans=min(ans,f(n/5)+(n%5)*d+c);
	if(n%5!=0)ans=min(ans,f(n/5+1)+(5-n%5)*d+c);
	
	ans=min(ans,f(n/3)+(n%3)*d+b);
	if(n%3!=0)ans=min(ans,f(n/3+1)+(3-n%3)*d+b);
	
	ans=min(ans,f(n/2)+(n%2)*d+a);
	if(n%2!=0)ans=min(ans,f(n/2+1)+(n%2)*d+a);
	return mp[n]=ans;
}

int main(){
	IOS;
	tihs;

	
	ll t;cin>>t;
	while(t--){
		ll n;cin>>n>>a>>b>>c>>d;
		cout<<f(n)<<"\n";
		mp.clear();
	}
	
	
	return 0;
}

Measured memory_bytes: 4364
import heapq
import math
N,H = map(int,input().split())

a_ls = [0]*N
b_ls =[0]*N
for i in range(N):
    a, b = map(int,input().split())
    a_ls[i] = a
    b_ls[i] = -b

a_max = max(a_ls)

heapq.heapify(b_ls)

total = 0
count = 0
for i in range(len(b_ls)):
    b_max = -heapq.heappop(b_ls)

    if a_max>=b_max:
        count += math.ceil((H-total)/a_max)
        total = H
        break
    total += b_max
    count +=1

    if total >=H:
        break

count += math.ceil(max(0,(H-total))/a_max)

print(count)

Measured memory_bytes: 77984
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int x, y; cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        for (int j = x - i; i + j <= x; j++) {
            if (i * 2 + j * 4 == y) {
                cout << "Yes\n";
                exit(0);
            }
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define per(i,x,y) for(in i=y;i>=(x);--i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main()
{
	IOS;
	in ans = 0;
	string s;
	cin >> s;
	rep(i,0,s.size()/2)
	{
		if(s[i] != s[s.size()-1-i]) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> t(N + 2);
	vector<int> v(N + 2);
	double res = 0;
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> t[i];
		t[i] *= 2;
	}
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		v[i] *= 2;
	}
	vector<double> u;
	vector<double> mxu;
	vector<double> vv;
	u.push_back(0);
	//mxu.push_back(0);

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < t[i] + 1; j++) {
			if (j == 0) {
				u[u.size() - 1] = min((double)u[u.size() - 1], (double)v[i]);
				//mxu[u.size() - 1] = max((double)mxu[mxu.size() - 1], (double)v[i]);
			}
			else {
				u.push_back(v[i]);
				//mxu.push_back(v[i]);
			}
		}
	}
	u[u.size() - 1] = 0;
	//mxu[u.size() - 1] = 10000;
	bool f = true;
	vv.resize((int)u.size(), 0);
	while (f) {
		f = false;
		for (int i = 1; i < (int)u.size() - 1; i++) {
			if (vv[i] < u[i]) {
				if (vv[i - 1] >= vv[i]) {
					if (vv[i + 1] >= vv[i]) {
						vv[i]++;
						f = true;
					}
				}
			}
		}
	}

	for (int i = 1; i < (int)u.size(); i++) {
		
		res += (vv[i] + vv[i - 1]) / 8.0;
	}
	cout << setprecision(30) <<  res << endl;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int X, Y;
    cin >> X >> Y;
    PRINT(X + Y / 2);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#define MAX_N (21)
#define NUM_MOD (1000000007)

using namespace std;

int dps[1 << MAX_N];

void init(int N) {
  for (int S = 0; S < (1 << N); S++) {
    dps[S] = -1;
  }
}

int calc_num_ways(int S, const vector<vector<int>> &adj_lists) {
  const int N = adj_lists.size();
  if (S == (1 << N) - 1) {
    return 1;
  }
  if (dps[S] < 0) {
    int i = 0;
    for (int k = 0; k < N; k++) {
      if (S & (1 << k)) {
        i++;
      }
    }
    int dp = 0;
    for (int j : adj_lists[i]) {
      if ((S & (1 << j)) == 0) {
        dp = (dp + calc_num_ways(S | (1 << j), adj_lists)) % NUM_MOD;
      }
    }
    dps[S] = dp;
  }
  return dps[S];
}

int main() {
  // read inputs
  int N, ass[MAX_N][MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%d", &ass[i][j]);
    }
  }

  // create graph
  vector<vector<int>> adj_lists(N, vector<int>());
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (ass[i][j]) {
        adj_lists[i].push_back(j);
      }
    }
  }

  // solve
  init(N);
  printf("%d\n", calc_num_ways(0, adj_lists));
}

Measured memory_bytes: 8576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
 {
        static void Main(string[] args)
        {
    		int a,b,c,d;
          	int ans;
//            string[] str = Console.ReadLine().Split(' ');

          	a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
          	c = int.Parse(Console.ReadLine()); 
            d = int.Parse(Console.ReadLine());

          	if(a>b){
              ans=b;
            }else{
              ans=a;
            }
          
          	if(c>d){
              ans=ans+d;
            }else{
              ans=ans+c;
            }
              
          	Console.Write("{0}",ans);
        }
 }

Measured memory_bytes: 13268
#include <stdio.h>

int d(int a);

int main(void){
    int x, y;
    scanf("%d %d",&x, &y);
    int X, Y;
    X = d(x);
    Y = d(y);

    if(X==Y){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

int d(int a){
    if(a%2==0){
        switch(a){
            case 2:
                return 3;
                break;
            case 4:
                return 2;
                break;
            case 6:
                return 2;
                break;
            default:
                return 1;
        }
    }
    else if(a<8){
        return 1;
    }
    else{
        return 2;
    }
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			
			int H = sc.nextInt();
			int W = sc.nextInt();
			
				if(H == W && H == 0)break;
				
				for(int i=0;i<H;i++) {
					for(int j=0;j<W;j++) {
						if(i % 2 == 0) {
							if(j % 2 == 0) {
								System.out.print("#");
							}else {
								System.out.print(".");
							}
						}else {
							if(j % 2 == 0) {
								System.out.print(".");
							}else {
								System.out.print("#");
							}
						}
					}
					System.out.println();
				}
				System.out.println();
		}
		sc.close();

	}

}


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

#define N 300

int d;
pair<int, int> idx[N*N];

int q;

int memo[N*N];

int func(int x)
{
	if( memo[x] > 0 ) {
		return memo[x];
	}
	if( x < d ) {
		return 0;
	}

	int y = x - d;
	int cost = abs( idx[x].first - idx[y].first ) + abs( idx[x].second - idx[y].second );
	int res = cost + func( y );
	return memo[ x ] = res;
}

int main()
{
	int h, w;
	int ans;
	int a;
	int l, r;

	cin >> h >> w >> d;

	for( int i = 0; i < h; i++ ) {
		for( int j = 0; j < w; j++ ) {
			cin >> a;
			a--;
			idx[ a ] = make_pair( j, i );
		}
	}

	cin >> q;
	for( int i = 0; i < q; i++ ) {
		cin >> l >> r;
		l--;
		r--;
		ans = func( r ) - func( l );
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 4992
import math

line1 = int(input())
line2 = str(input()).split(" ")
for index in range(len(line2)):
    line2[index] = int(line2[index])

newList = []
counter = dict()
newLength = 0
for element in line2:
    try:
        counter[element] += 1
    except:
        counter[element] = 1
    if (counter[element] == element):
        newLength += element

print(line1 - newLength)

Measured memory_bytes: 20596
using System;

namespace ITP1_2_C
{
    class ITP1_2_C
    {
        static void Main(string[] args)
        {
            string[] input = System.Console.ReadLine().Split(' ');
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            int c = Int32.Parse(input[2]);

            int min = Math.Min(a, Math.Min(b, c));
            int max = Math.Max(a, Math.Max(b, c));

            System.Console.WriteLine(String.Format("{0} {1} {2}", min, a + b + c - min - max, max));
        }
    }
}

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int rc[110];
    for(int i = 1; i <= n; i++) cin >> rc[i - 1] >> rc[i];
    int dp[110][110];
    for(int i = 0; i < 110; i++) for(int j = 0; j < 110; j++) dp[i][j] = INF;
    for(int i = 1; i <= n; i++) dp[i][i] = 0;
    for(int alpha = 2; alpha <= n; alpha++)
    {
        for(int l = 1; l <= n - alpha + 1; l++)
        {
            int r = l + alpha - 1;
            for(int k = l; k <= r; k++)
            {
                dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + rc[l - 1] * rc[k] * rc[r]);
            }
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}




Measured memory_bytes: 3220
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef unsigned  uint;
typedef unsigned long long int ull;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//const uint mod=998244353;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
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; }
ll dp[5000][5000],sum[5000][5000];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
vector<int> a(n+1,0),b(m+1,0);
for(int i=0;i<n;i++)cin>>a[i+1];
for(int i=0;i<m;i++)cin>>b[i+1];
dp[0][0]=1;
for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
        if(i!=0&&j!=0&&a[i]==b[j]){
            (dp[i+1][j+1]+=sum[i][j]+dp[i][j])%=mod;
        }
           (dp[i+1][j]+=dp[i][j])%=mod;
           (sum[i][j+1]+=(sum[i][j]+dp[i][j]))%mod;
    }
    (dp[i+1][m+1]+=dp[i][m+1])%=mod;
}
ll ans=0;
for(int i=0;i<=m+1;i++){
    ans+=dp[n+1][i];
    ans%=mod;
}
cout<<ans<<endl;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n;
	scanf("%d",&n);
	printf("%d\n",n + n*n + n*n*n);
	
	return 0;
};

Measured memory_bytes: 3812
use std::io::BufRead;

fn main() {
    let mut a = [[[0;10];3];4];
    let stdin = std::io::stdin();
    for line in stdin.lock().lines().skip(1) {
        let v: Vec<i64> = line.unwrap().split_whitespace().map(|n| n.parse().unwrap()).collect();
        let (b, f, r, v): (usize, usize, usize, i64) = (v[0] as usize, v[1] as usize, v[2] as usize, v[3]);
        a[b-1][f-1][r-1] += v;
    }
    
    for b in 0..4 {
        for f in 0..3 {
            for r in a[b][f].iter() {
                print!(" {}", r);
            }
            println!("");
        }
        if b != 3 {
            println!("{}", "#".repeat(20));
        }
    }
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, m, k;
int color[100009], ans[100009];
int fr[2][100009];
struct edge {
    int to;
    edge(int to) : to(to) {}
};
vector<edge> G[100009];

int dfs(int s, int c) {
    int num = 0;
    stack<int> st;
    st.push(s);
    color[s] = c;

    while (!st.empty()) {
        int u = st.top();
        st.pop();
        num++;
        for (auto &e : G[u]) {
            if (color[e.to] == -1) {
                color[e.to] = c;
                st.push(e.to);
            }
        }
    }
    return num;
}

int main() {
    cin >> n >> m >> k;
    int a, b, c, d;
    rep(i, m) {
        scanf("%d%d", &a, &b);
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        fr[0][i] = a;
        fr[1][i] = b;
    }
    int col = 0;
    fill(color, color + n, -1);
    vector<int> num;
    rep(i, n) {
        if (color[i] == -1) {
            num.push_back(dfs(i, col++));
        }
    }
    rep(i, n) { ans[i] = num[color[i]] - 1; }
    rep(i, m) { ans[fr[0][i]]--, ans[fr[1][i]]--; }

    rep(i, k) {
        scanf("%d%d", &c, &d);
        c--, d--;
        if (color[c] == color[d]) {
            ans[c]--, ans[d]--;
        }
    }
    rep(i, n) {
        if (i) printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");
    return 0;
}

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

ll a[200001];
map<ll, ll> mp;
int cnt[200001];


int main() {
#ifdef DEBUG
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        mp[a[i]]++;
    }

    ll orig = 0;
    for (auto& it : mp) {
        orig += it.second * (it.second - 1) / 2;
    }

    // cout << orig << '\n';

    for (int i = 0; i < n; i++) {
        if (!cnt[a[i]]) continue;

        ll ans = orig;
        ans -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
        ans += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 11904
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut cities: Vec<Vec<(usize, usize)>> = vec![Vec::new(); n];
    for i in 0..m {
        let p: usize = iterator.next().unwrap().parse().unwrap();
        let y: usize = iterator.next().unwrap().parse().unwrap();
        cities[p - 1].push((y, i));
    }

    let mut result: Vec<String> = vec![String::new(); m];

    for i in 0..n {
        cities[i].sort();
        for (j, city) in cities[i].iter().enumerate() {
            result[city.1] = format!("{:0>6}{:0>6}", i + 1, j + 1);
        }
    }

    return result.join("\n").trim().to_string();
}


Measured memory_bytes: 24828
#include<stdio.h>
#include<string.h>
using namespace std;
char s[131072];
int num[4],num2[4];
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	bool ok=false;
	for(int i=1;i<n;i++)
	{
		if(s[i]==s[i-1])
		{
			ok=true;
			break;
		}
	}
	if(!ok)
	{
		printf("1\n");
		return 0;
	}
	num2[1]=1;
	num2[2]=1;
	int now=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='a')
		{
			now++;
			if(now>=3)
			{
				now-=3;
			}
		}
		else
		{
			now--;
			if(now<0)
			{
				now+=3;
			}
		}
		num[now]+=num2[now];
		if(num[now]>=1000000007)
		{
			num[now]-=1000000007;
		}
		for(int j=0;j<3;j++)
		{
			if(j!=now)
			{
				num2[j]+=num2[now];
				if(num2[j]>=1000000007)
				{
					num2[j]-=1000000007;
				}
			}
		}
		num2[now]=0;
	}
	printf("%d\n",num[now]);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(3*a);
  rep(i,3*a)
    cin>>b[i];
  sort(all(b));
  reverse(all(b));
  int c=0;
  rep(i,a){
  c+=b[2*i+1];
  }
  out(c);
}


Measured memory_bytes: 5756
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;


void main() {
    auto S = readln.split.map!(to!int);
    auto K = S[1];
    auto A = readln.split.map!(to!int).filter!(a => a < K).array;
    A.sort();
    auto N = A.length.to!int;

    if (N == 0) {
        writeln(0);
        return;
    }
    
    if (N == 1) {
        writeln(A[0] >= K ? 1 : 0);
        return;
    }


    bool[5001] used;
    
    auto dp1 = new int[][](N);
    dp1[0] = [0, A[0]];
    foreach (i; 1..N) {
        memset(used.ptr, 0, used.sizeof);
        foreach (j; dp1[i-1]) {
            if (!used[j]) {
                dp1[i] ~= j;
                used[j] = true;
            }
            if (A[i] + j < K && !used[A[i]+j]) {
                dp1[i] ~= A[i] + j;
                used[A[i]+j] = true; 
            }
        }
        dp1[i].sort();
    }

    auto dp2 = new int[][](N);
    dp2[N-1] = [0, A[N-1]];
    foreach (i; iota(N-2, -1, -1)) {
        memset(used.ptr, 0, used.sizeof);
        foreach (j; dp2[i+1]) {
            if (!used[j]) {
                dp2[i] ~= j;
                used[j] = true;
            }
            if (A[i] + j < K && !used[A[i]+j]) {
                dp2[i] ~= A[i] + j;
                used[A[i]+j] = true;
            }
        }
        dp2[i].sort();
    }


    int ans = 0;
    
    foreach (i; 0..N) {
        bool required = false;
        int lb = K - A[i];
        
        if (i == 0) {
            if (dp2[1][$-1] >= lb) {
                required = true;
            }
        }
        
        else if (i == N-1) {
            if (dp1[N-2][$-1] >= lb) {
                required = true;
            }
        }

        else {
            int n = dp1[i-1].length.to!int;
            int m = dp2[i+1].length.to!int;
            int p1 = 0;
            int p2 = m-1;
            while (p1 < n && p2 >= 0) {
                int s = dp1[i-1][p1] + dp2[i+1][p2];
                if (s >= K) p2 -= 1;
                else if (s < lb) p1 += 1;
                else {required = true; break;}
            }
        }

        if (!required) ans += 1;
    }

    
    ans.writeln;
}


Measured memory_bytes: 224380
#include<stdio.h>
int main()
{
   int a,b;
   scanf("%d%d",&a,&b);

   if(a+b==15){
    printf("+\n");
   }
   else if(a*b==15){
    printf("*\n");
   }
   else{
    printf("x\n");
   }




    return 0;
}


Measured memory_bytes: 128
//itp1_4-b
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
 int a,b;
 char c;
 
 while(true){
  cin>>a>>c>>b;
  if(c=='?') break;
  else if(c=='+') cout<<a+b<<endl;
  else if(c=='-') cout<<a-b<<endl;
  else if(c=='*') cout<<a*b<<endl;
  else if(c=='/') cout<<a/b<<endl;
 }
 return 0;
}

Measured memory_bytes: 1160
/**
 *      ///----- My Info -----///
 *      Code by: Unk
 *      Codeforces User: Ernest0_0Abreu
 *      Country: Cuba
 *      E-mail: ernestoabreup@gmail.com
 *      CopyRight
**/
#include <bits/stdc++.h>
#ifdef Ernest0_0Abreu 
#include <debug/to_string.h>
#endif
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
    	///----- My Template -----///
///===================================================================================================================================
/// Debug
#define _end cout << "\n"
#ifndef Ernest0_0Abreu
#define db(x) ;
#define dbrange(x,begin,end) ;
#define dbname(x) ;
#define dbnamerange(x,begin,end) ;
#define dbmat(x,begin_n,end_n,begin_m,end_m) ;
#define dbST(x,end) ;
#define db_end ;
#endif
///Function
#define pi (acos(-1))
#define lg2(x) 31-__builtin_clz(x)
#define lgx(x,b) log(b)/log(x)
/// Macros
#define fst first
#define scd second
#define left (node<<1)
#define right ((node<<1)+1)
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/// Constant
const ll MAXN = 1e6+7;
const int MOD = 1e9+7;
const ull BASE = 311;
const ld EPS = 1e-9;
const int INF = ((1<<30)-1);
const ll INFLL = ((1ll<<62ll)-1ll);
const ll oo = 2e18;
/// Hash Prime Numbers: 2, 277, 293, 307, 331, 337, 1009, 2027;
/// Module Prime Numbers: 3,1000033, 998244353, 1000000007, 1000000009, 1000000021;
///===================================================================================================================================
#define int long long
		///----- My code -----///



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

	string s, t;
	cin >> s >> t;
	string k;
	for(int i = 0; i < sz(t)-1; ++i){
		k+=t[i];
	}
	if(k == s) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<utility>
#include<climits>
#include<set>
using namespace std;
#define ll long long


int main(){ 
	ios_base::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	    
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif


	int n;cin>>n;
	int v[n][2];

	for(int i=0;i<n;i++)
	{
		cin>>v[i][0]>>v[i][1];
	}
	int maxi=0;
	int flag=0;
	for(int i=0;i<n;i++)
	{
		if(v[i][0]==v[i][1])
		{
			flag++;
			
		}
		else
			flag=0;
		maxi=max(flag,maxi);
	}
	if(maxi>=3)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3652
/*
                    Author: Ankit Kaul
    **********************Code Belongs to Respective Author Only************************************
    */
    /*#pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
    #include <bits/stdc++.h>
    #define endl       '\n'
    #define PI          3.141592653589
    #define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define M           1000000007
    #define int         long long int
    #define inf         INT_MAX
    #define pb          emplace_back
    #define pf          emplace_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    using namespace std;
    int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
    int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
    bool isPrime(int n) 
    { 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
    } 
signed main()
{   jaldi
    int a[3][3],n,i;
    bool x[3][3];
    for(i=0;i<3;i++)
    {   for(int j=0;j<3;j++)
        {   cin>>a[i][j];
            x[i][j]=false;
        }
    }
    cin>>n;
    int b[n];
    for(i=0;i<n;i++)
    cin>>b[i];
    for(i=0;i<n;i++)
    {   for(int j=0;j<3;j++)
        {   for(int k=0;k<3;k++)
            {   if(a[j][k]==b[i])
                x[j][k]=true;
            }
        }
    }
    bool g=false;
    int count=0;
    for(i=0;i<3;i++)
    {   for(int j=0;j<3;j++)
        {   if(x[i][j]==true)
            count++;
        }
        if(count==3)
        g=true;
        count=0;
    }
    for(i=0;i<3;i++)
    {   for(int j=0;j<3;j++)
        {   if(x[j][i]==true)
            count++;
        }
        if(count==3)
        g=true;
        count=0;
    }
    for(i=0;i<3;i++)
    {   for(int j=0;j<3;j++)
        {   if(x[i][j]==true && i==j)
            count++;
        }
        if(count==3)
        g=true;
    }
    for(i=0;i<3;i++)
    {   for(int j=0;j<3;j++)
        {   if(x[i][j]==true && i+j==2)
            count++;
        }
        if(count==3)
        g=true;
    }
    if(g)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    vector<int> operate;
    operate.push_back(1);
    int num = 6;
    while(num <= n)
    {
        operate.push_back(num);
        num *= 6;
    }
    num = 9;
    while(num <= n)
    {
        operate.push_back(num);
        num *= 9;
    }
    //show(operate);
    vector<int> dp(n+1, MOD);
    dp[0] = 0;
    rep1(i, n){
        int tans = MOD;
        for(auto ope: operate){
            if (ope <= i){
                tans = min(tans, dp[i-ope]+1);
            }
        }
        dp[i] = tans;
    }

    //rep(i, n+1) cout << i << " " << dp[i] << endl;
    cout << dp[n] << endl;

}



Measured memory_bytes: 640
wordlist = ['dream', 'erase', 'dreamer', 'eraser']
S = input()
index = -1
ans = 'YES'
word = ''
for i in range(0, len(S)):
	word = S[-1-i] + word
	if word in wordlist:
		word = ''
	elif len(word) == 7:
		ans = 'NO'
		break
print(ans)

Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int h, w, n;
    cin >> h >> w >> n;
    int x = max(h, w);
    cout << (n + x - 1) / x << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


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

using namespace std;
#define lint long long
#define P pair<int, int>

int main() {
    int N, M;
    cin >> N >> M;
    
    if(N > 1 && M > 1){
        cout << (lint)(N - 2) * (M - 2) << endl;
    } else if(N == 1 && M == 1){
        cout << 1 << endl;
    } else {
        cout << N + M - 3 << endl;
    }
}

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

using namespace std;

int main(void) {
    int n, k, ans = 0;
    vector<int> p;
    cin >> n >> k;
    // cout << "for1" << endl;
    for(int i = 0; i < n; i++){
        // cout << "i = " << i << endl;
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
        // cout << "p[i] = " << p.at(i) << endl;
    }
    sort(p.begin(), p.end());
    // cout << "for2" << endl;
    for(int i = 0; i < k; i++){
        // cout << "i = " << i << endl;
        ans += p.at(i);
        // cout << "ans = " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  IN(N,M);
  vb C(N, false), D(N, false);
  REP(i,M){
    ll a, b;
    IN(a,b);
    a--; b--;
    if(a>b) swap(a,b);
    if(a==0) C[b] = true;
    if(b==N-1) D[a] = true;
  }

  REP(i,N){
    if(C[i]&&D[i]){
      OUT("POSSIBLE");
      return 0;
    }
  }

  OUT("IMPOSSIBLE");

  return 0;
}

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

int main()
{
  int N,K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  if (a.at(0) >= 0) {
    cout << a.at(K-1) << endl;
    return 0;
  }
  if (a.at(N-1) <= 0) {
    cout << -a.at(N -K) << endl;
    return 0;
  }
  vector<int> diff(N-K+1);
  for (int i = 0; i < N-K+1; i++) {
    diff.at(i)  = a.at(K+i - 1) - a.at(i);
    diff.at(i) += abs(a.at(i)) >  abs(a.at(K+i-1)) ?  abs(a.at(K+i-1)) : abs(a.at(i));
  }
  sort(diff.begin(), diff.end());

  cout << diff.at(0) << endl; 
}


Measured memory_bytes: 896