akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int n;
    cin >> n;
    if(n % 2 == 1)
    {
        cout << "0\n";
    }
    else
    {
        long long int ans = 0;
        for(long long int i = 5;i <= n;i *= 5)
        {
            ans += n / i / 2;
        }
        cout << ans;
    }
    
    return 0;
}

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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = 0;
		boolean ok = true;
		for(int i = 0; i < n; i++) {
			String in = sc.next();
			int count = sc.nextInt();
			if(in.equals("(")) l += count;
			else l -= count;
			if(l < 0) ok = false;
		}

		System.out.println((l == 0 && ok)?"YES":"NO");
		
		
		
		
		
		
		
		
	}
}

Measured memory_bytes: 24808
#include<stdio.h>
int main()
{
	int a,b,c,x,y,i,s;
	scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
	int k=x,min=a*x+b*y;
	if(x<y) k=y;
	for(i=1;i<=k;i++){
		if(x-i<0)
		    s=(y-i)*b+i*2*c;
		else if(y-i<0)
		    s=(x-i)*a+i*2*c;
		else
		    s=(x-i)*a+(y-i)*b+i*2*c;
		if(min>s)
			min=s;
	}
	printf("%d",min);
}

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

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

	if (A == 5 && B == 7 && C == 5) cout << "YES" << endl;
	else if (A == 7 && B == 5 && C == 5) cout << "YES" << endl;
	else if (A == 5 && B == 5 && C == 7) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
//おまじない
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n,m;
  cin>>n>>m;
  
  vector<long int> v(m);
  
  for(int i=0; i<n; i++){
    
    int f=0;
    cin>>f;
    
    for(int j=0; j<f; j++){
      int a=0;
      cin>>a;
      v.at(a-1)++;}
  }
  int s=0;
  for(int i=0;i<m;i++){
    if(v.at(i)==n){
      s++;}}
  
  cout<<s<<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 5;

int n;
int a[maxN * 3];
int64_t f[maxN * 3], g[maxN * 3];
map<pair<int, int>, int> pos;

int cnt[maxN * 3];
int64_t fwt[maxN * 3];

void upd(int idx, int64_t val) {
    for(; idx < 3 * maxN; idx += idx & -idx) {
        fwt[idx] += val;
        cnt[idx] += 1;
    }
}

pair<int64_t, int> sum(int idx) {
    int64_t total = 0;
    int bar = 0;
    for(; idx > 0; idx -= idx & -idx) {
        total += fwt[idx];
        bar += cnt[idx];
    }
    return {total, bar};
}

pair<int64_t, int> sum(int l, int r) {
    auto rr = sum(r);
    auto ll = sum(l - 1);

    return {rr.first - ll.first, rr.second - ll.second};
}

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

    cin >> n;

    int counter = 0;

    vector<pair<int, int> > vv;

    for(int i = 1; i <= 3 * n; i++) {
        cin >> a[i];
        vv.emplace_back(a[i], i);
    }

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

    for(auto p : vv)
        pos[p] = ++counter;

    int64_t pre = 0;

    for(int i = 1; i <= 2 * n; i++) {
        upd(pos[{a[i], i}], a[i]);
        pre += a[i];
        int64_t curSum = pre;

        if(i >= n) {
            int k = i - n;

            if(k) {
                int lo = 1, hi = 3 * maxN - 1;
                while(lo <= hi) {
                    int mid = (lo + hi) / 2;
                    auto curPair = sum(1, mid);
                    if(curPair.second > k) {
                        hi = mid - 1;
                    } else if(curPair.second < k) {
                        lo = mid + 1;
                    } else {
                        curSum -= curPair.first;
                        break;
                    }
                }
            }

            f[i] = curSum;
        }
    }

    for(int i = 0; i < 3 * maxN; i++)
        fwt[i] = cnt[i] = 0;

    int64_t suf = 0;
    for(int i = 3 * n; i > n; i--) {
        upd(pos[{a[i], i}], a[i]);
        suf += a[i];
        int64_t curSum = suf;

        if(i <= 3 * n - n + 1) {
            int k = 3 * n - n + 1 - i;
            if(k) {
                int lo = 1, hi = 3 * maxN - 1;
                while(lo <= hi) {
                    int mid = (lo + hi) / 2;
                    auto curPair = sum(mid, 3 * maxN - 1);
                    if(curPair.second > k) {
                        lo = mid + 1;
                    } else if(curPair.second < k) {
                        hi = mid - 1;
                    } else {
                        curSum -= curPair.first;
                        break;
                    }
                }
            }

            g[i] = curSum;
        }
    }

    int64_t ans = -1e18;
    for(int i = n; i <= n + n; i++) {
        ans = max(ans, f[i] - g[i + 1]);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 30520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()

struct Node{
  int location;
  int l, r;
};

struct Point{
  int id, x, y;
  bool operator < (const Point &p) const {
    return id < p.id;
  }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; };
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; };

int makeKDTree(int l, int r, int depth){
  if(!(l<r)) return NIL;
  int mid = (l+r)/2;
  int t = np++;

  if(depth%2 == 0) sort(P+l, P+r, lessX);
  else sort(P+l, P+r, lessY);

  T[t].location = mid;
  T[t].l = makeKDTree(l, mid, depth+1);
  T[t].r = makeKDTree(mid+1, r, depth+1);

  return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans){
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if(sx<=x && x<=tx && sy<=y && y<=ty){
    ans.push_back(P[T[v].location]);
  }

  if(depth%2 == 0){
    if(sx <= x && T[v].l != NIL){
      find(T[v].l, sx, tx, sy, ty, depth+1, ans);
    }
    if(x <= tx && T[v].r != NIL){
      find(T[v].r, sx, tx, sy, ty, depth+1, ans);
    }
  }
  else{
    if(sy <= y && T[v].l != NIL){
      find(T[v].l, sx, tx, sy, ty, depth+1, ans);
    }
    if(y <= ty && T[v].r != NIL){
      find(T[v].r, sx, tx, sy, ty, depth+1, ans);
    }
  }
}

int main(){
  scanf("%d", &N);
  rep(i, N){
    int x, y;
    scanf("%d %d", &x, &y);
    Point tmp = {i, x, y};
    P[i] = tmp;
    T[i].l = NIL;
    T[i].r = NIL;
  }

  np = 0;
  int root = makeKDTree(0, N, 0);

  int q;
  scanf("%d", &q);
  rep(i, q){
    int sx, tx, sy, ty;
    scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
    vector<Point> ans;
    find(root, sx, tx, sy, ty, 0, ans);
    sort(all(ans));
    rep(j, ans.size()) printf("%d\n", ans[j].id);
    printf("\n");
  }

  return 0;
}




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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 2e5 + 41;
int const INF = 1e9 + 41;

int n;
int a[MAX];
int b[MAX];
int d[MAX];
int d2[MAX];
int ans;

void solve() {
	bool z = true;
	fi(1, n) {
		if (a[i] != i) z = false;
	}
	ans = (z ? 0 : INF);
	fi(1, n) {
		b[a[i]] = i;
	}		
	fdi(n, 1) {
		d[i] = 1;
		if (i + 1 <= n) {
			if (b[i + 1] > b[i]) {
				d[i] = d[i + 1] + 1;
			}
		}
	}
	fi(1, n) {
		d2[i] = 1;
		if (i > 1) {
			if (b[i - 1] < b[i]) {
				d2[i] = d2[i - 1] + 1;
			}
		}
	}

	fi(1, n - 1) {
		int v1 = i;
		int v2 = (n - i - d[i + 1]);		
		ans = min(ans, v1 + v2);
	}
	fdi(n, 2) {
		int v1 = n - i + 1;
		int v2 = (i - 1 - d2[i - 1]);
		ans = min(ans, v1 + v2);
	}
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	fi(1, n) {
		scanf("%d", &a[i]);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long double n;cin>>n;
    n*=1.0;
    cout<<458.67252742410977361942*n/73.0<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


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

int main(){
    int n,l;
    cin>>n>>l;
    vector<string> vs(n);
    for (int i = 0; i < n; ++i) {
        cin>>vs[i];
    }
    sort(vs.begin(),vs.end());
    for(auto i:vs)cout<<i;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
s =["#"*(w+2)] + ["#"+input()+"#" for i in range(h)] + ["#"*(w+2)]
# print(s)
ans = 1
opt = [(0,1),(0,-1),(1,0),(-1,0)]
s2 = [[0]*(w+2) for i in range(h+2)]
s3 = [[0]*(w+2) for i in range(h+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == "." and s2[i][j] == 0:
            cnt = 0
            for k in opt[0:2]:
                tempy = i
                tempx = j
                while s[tempy+k[0]][tempx+k[1]] == ".":
                    cnt += 1
                    tempy += k[0]
                    tempx += k[1]
            for k in opt[0:2]:
                tempy = i
                tempx = j
                while s[tempy+k[0]][tempx+k[1]] == ".":
                    s2[tempy+k[0]][tempx+k[1]] += cnt
                    tempy += k[0]
                    tempx += k[1]
            s2[i][j] += cnt
        if s[i][j] == "." and s3[i][j] == 0:
            cnt = 0
            for k in opt[2:4]:
                tempy = i
                tempx = j
                while s[tempy+k[0]][tempx+k[1]] == ".":
                    cnt += 1
                    tempy += k[0]
                    tempx += k[1]
            for k in opt[2:4]:
                tempy = i
                tempx = j
                while s[tempy+k[0]][tempx+k[1]] == ".":
                    s3[tempy+k[0]][tempx+k[1]] += cnt
                    tempy += k[0]
                    tempx += k[1]
            s3[i][j] += cnt
        ans = max(ans,1+s2[i][j]+s3[i][j])
# print(s2)
print(ans)

Measured memory_bytes: 143304
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();        
        int N = r.i();
        int[] d = r.ii();
        Arrays.sort(d);
        println(d[N/2]-d[N/2-1]);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 36336
#include <iostream>
#include <sstream>

using namespace std;

int main () {
    string s;
    while (1) {
        cin >> s;
        int result = 0;
        if (s[0] == '0') break;
        for (int i = 0; i < s.size(); i++) {
            result += int(s[i]) - 48; //ascii 
            //printf("%d", result);
        }
        cout << result << endl;
       
    }
}


Measured memory_bytes: 3208
#include<cstdio>
int main(){
    double x1,y1,x2,y2,xq,yq;
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf\n",&x1,&y1,&x2,&y2,&xq,&yq)!=-1){
        double nxa=(x2-x1)*(xq-x1)+(y2-y1)*(yq-y1),aa=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
        printf("%lf %lf\n",x1-(xq-x1)+2*(nxa/aa)*(x2-x1),y1-(yq-y1)+2*(nxa/aa)*(y2-y1));
    }
}

Measured memory_bytes: 0
N = int(input())

blocks = list(map(int, input().split()))

route = [0] * N

for i in range(N):
    if i == 0:
        continue
    elif i == 1:
        route[1] = abs(blocks[1] - blocks[0]) 

    else:
        first = abs(blocks[i] - blocks[i-1]) + route[i-1]
        second = abs(blocks[i] - blocks[i-2]) + route[i-2]
        route[i] = min(first, second)

print(route[N-1])


Measured memory_bytes: 13908
import sys

stdin = sys.stdin
na = lambda: map(int, stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
def main():
  s = ns()
  t = ns()

  cnt = 0
  for ss, tt in zip(s, t):
    if ss == tt:
      cnt += 1

  print(cnt)

main()

Measured memory_bytes: 3060
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	LL a, b;
	while(cin >> a >> b) {
		if((a+b)%2 == 0) {
			cout << (a + b) / 2 << endl;
		} else {
			cout << "IMPOSSIBLE" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;

int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	lli n,x,y;
	cin>>n>>x>>y;
	vector<vector<lli>> adj(n);
	adj[x-1].push_back(y-1);
	adj[y-1].push_back(x-1);
	adj[0].push_back(1);
	adj[n-1].push_back(n-2);
	for(lli i=1;i<n-1;++i){
		adj[i].push_back(i+1);
		adj[i].push_back(i-1);
	}
	lli cnt[n]={0};
	for(lli i=0;i<n;++i){
		vector<lli> dist(n,LLONG_MAX);
		queue<lli> q;
		q.push(i);
		dist[i]=0;
		while(!q.empty()){
			lli node=q.front();
			q.pop();
			for(lli j=0;j<adj[node].size();++j){
				if(dist[node]+1<dist[adj[node][j]]){
					dist[adj[node][j]]=dist[node]+1;
					q.push(adj[node][j]);
				}
			}
		}
		for(lli d:dist){
			//cout<<d<<" ";
			cnt[d]++;
		}
		//cout<<endl;
	}
	for(lli i=1;i<n;++i)
		cout<<cnt[i]/2<<endl;
}


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

#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b);++i)
#define all(v) (v).begin(), (v).end()
#define rs resize
#define x first
#define y second

using namespace std;

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

ostream& operator<<(ostream &out, const pii &a) { return out << '(' << a.x << ", " << a.y << ')'; }
istream& operator>>(istream &in, pii &a) { return in >> a.x >> a.y; }

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

// lambda-expression: [] (args) -> retType { body }
const int maxn = 2e5 + 10;

vi g[maxn];
bool vis[maxn] = {}, col[maxn] = {};

bool bipartite(int v, bool c)
{
	vis[v] = true;
	col[v] = c;
	for (int w : g[v]) {
		if (vis[w]) {
			if (c == col[w])
				return false;
		} else if (!bipartite(w, !c)) {
			return false;
		}
	}
	return true;
}

void run()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}
	if (bipartite(1, true)) {
		ll L = 0, R = 0;
		rep(i,1,N+1) {
			if (col[i])
				L++;
			else
				R++;
		}
		ll cnt = L * R;
		cnt -= M;
		cout << cnt << endl;
	} else {
		ll cnt = 1LL * N * (N - 1) / 2;
		cnt -= M;
		cout << cnt << endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// cerr << boolalpha;
	(cout << fixed).precision(10);

	run();

	return 0;
}

Measured memory_bytes: 8704
//有参考，但是想明白了。。。。。希望下次做题可以多思考

#include <iostream>
#include <cmath>
using namespace std;

bool prime(int n){
    int m = sqrt(n);
    for(int i = 2; i <= m; i++){
        if(n % i == 0) return 0;
    }
    return 1;
}

int main()
{
    int n;
    cin >> n;
    int k = 11;
    while(n){
        if(prime(k) && k % 10 == 1){
            cout << k << ' ';
            n--;
        }
        k += 10;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		char[] S=sc.next().toCharArray();
		char[] T=sc.next().toCharArray();
		int ans=0;
		for(int i=0;i<S.length;++i) {
			if(S[i]==T[i])++ans;
		}
		pw.println(ans);
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21204
INFTY = float('inf')

n = int(input())
M = [[0 for i in range(n)] for i in range(n)]
p = []

for i in range(n):
    r, c = list(map(int, input().split(' ')))
    if i == 0: p.append(r)
    p.append(c)

for i in range(n-1):
    M[i][i+1] = p[i]*p[i+1]*p[i+2]

for gap in range(2,n): # gap = 1,.., n-1
    for i in range(n-gap):
        j = i+gap
        M[i][j] = INFTY
        for k in range(i, j):
            M[i][j] = min([M[i][j], M[i][k] + M[k+1][j] + p[i]*p[k+1]*p[j+1]])

print(M[0][n-1])



Measured memory_bytes: 5728
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n==1){
    	if(a!=b)
    		cout<<0<<endl;
    	else
    		cout<<1<<endl;
	}else if(a>b)
		cout<<0<<endl;
	else if(a==b)
		cout<<1<<endl;
	else{
		cout<<(b-a)*(n-2)+1<<endl;
	}
    return 0;
}

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

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int); 
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fastpow(ll, ll, ll);
ll slowpow(ll, ll, ll);
ll _gcd(ll, ll);
ll _lcm(ll, ll);
ll extgcd(ll, ll, ll&, ll&);
ll _inv(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

int main()
{
    string s = ss(100);
    int res = 0;
    for (int i = 0; i < s.size() / 2; ++i)
        if (s[i] != s[s.size() - 1 - i])
            ++res;
    pi(res);

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fastpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slowpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll _gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

ll _lcm(ll a, ll b)
{
    return a / _gcd(a, b) * b;
}

ll extgcd(ll a, ll b, ll& k, ll& l)
{
    if (b == 0)
    {
        k = 1; l = 0;
        return a;
    }    
    ll res = extgcd(b, a % b, l, k);
    l -= a / b * k;
    return res;
}

ll _inv(ll a, ll p)
{
    return fastpow(a, p - 2, p);
}

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

int main(){
  int x[5];
  int y[5];
  cin >> x[1] >> y[1] >> x[2] >> y[2];
  x[3]=x[2]-(y[2]-y[1]);
  y[3]=y[2]+(x[2]-x[1]);
  x[4]=x[1]-(y[2]-y[1]);
  y[4]=y[1]+(x[2]-x[1]);
  cout << x[3] << " " << y[3] << " " << x[4] << " " << y[4] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    ll n, y;
    cin >> n >> y;
    rep(i, n+1){
        rep(j, n+1){
            if(i + j > n) break;
            int k = n - i - j;
            if(10000*i + 5000*j + 1000*k == y){
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 3728
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 998244353
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint A,B,C;
    cin >> A >> B >> C;
    lint x,y,z;
    x=A*B,y=B*C,z=C*A;
    lint ans=min3(x*(C%2),y*(A%2),z*(B%2));
    cout << ans << endl;
}

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

int a[200005];

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

Measured memory_bytes: 1024
def is_palindromic_number(num):
    num_s = list(str(num))
    while len(num_s) > 1:
        if num_s.pop(0) != num_s.pop():
            return False
        
    return True

A,B = map(int, input().split())
print(sum(is_palindromic_number(num) for num in range(A,B+1)))

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FOR(i,a,b) for(i=a;i<=b;i++)

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll N;
ll X[200010],x[200010];


int main()
{
	cin >> N;
	for(ll i=1;i<=N;i++){
		cin >> X[i];
		x[i] = X[i];
	}
	sort(x, x+(N+1));

	for (ll i = 1; i <= N; i++) {
		if (X[i]<=x[N / 2]) {
			cout << x[N / 2 + 1] << endl;
		}
		else cout << x[N / 2] << endl;
	}

	
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, x;
    cin >> N >> x;
    if (x == 1 || x == 2 * N - 1)
    {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;

    if (N == 2)
    {
        rep(i, 0, 3)
        {
            cout << i + 1 << endl;
        }
        return;
    }

    vector<int> ans(2 * N - 1, -1);
    vector<bool> used(2 * N, false);
    if (x == 2)
    {
        ans[N - 2] = x + 1;
        ans[N - 1] = x;
        ans[N] = x - 1;
        ans[N + 1] = x + 2;
        used[x + 1] = used[x] = used[x - 1] = used[x + 2] = true;
    }
    else
    {
        ans[N - 2] = x - 1;
        ans[N - 1] = x;
        ans[N] = x + 1;
        ans[N + 1] = x - 2;
        used[x - 1] = used[x] = used[x + 1] = used[x - 2] = true;
    }

    int num = 1;
    rep(i, 0, 2 * N - 1)
    {
        if (ans[i] > 0) continue;
        while (used[num]) ++num;
        ans[i] = num;
        used[num] = true;
    }

    for (const int i : ans)
    {
        cout << i << endl;
    }
}


Measured memory_bytes: 2304
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
max = a.max
min = a.min
if max.abs >= min.abs
  maxid = a.index(max)+1
  puts 2*n-1
  for i in 1..n
    print maxid,"\s",i,"\n"
  end
  for i in 2..n
    print i-1,"\s",i,"\n"
  end
else
  puts 2*n-1
  minid = a.index(min)+1
  for i in 1..n
    print minid,"\s",i,"\n"
  end
  for i in 0..n-2
    print n-i,"\s",n-1-i,"\n"
  end
end

Measured memory_bytes: 3836
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    vvl v(m);  // v[i] : 電球iとつながっているスイッチの集合
    rep(i, m) {
        ll k;
        cin >> k;
        rep(j, k) {
            ll s;
            cin >> s;
            s--;
            v[i].pb(s);
        }
    }

    vl p(m);
    rep(i, m) {
        cin >> p[i];
    }

    ll ans = 0;
    rep(b, 1<<n) {  // bのjビット目が1のときスイッチjはon
        bool ok = true;
        rep(i, m) {
            ll cnt = 0;
            for(auto x : v[i]) {
                if(b & 1<<x) {
                    cnt++;
                }
            }
            if(cnt%2 != p[i]) {
                ok = false;
                break;
            }
        }
        if(ok) {
            ans++;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <stdio.h>
void bubblesort(int A[],int N);
int main(){
  int N,A[100],i,t,count;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  bubblesort(A,N);
  return 0;
}
void bubblesort(int A[],int N){
  int i,j,t,count=0;
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(A[j-1]>A[j]){
        t=A[j-1];
        A[j-1]=A[j];
        A[j]=t;
        count++;
      }
    }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[N-1],count);
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N,x;
  cin>>N>>x;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> m(N);
  int fans=1000000000000000000;
  for(int i=0;i<N;i++)m[i]=v[i];
  for(int i=0;i<N;i++){
    int ans=x*i;
    for(int j=0;j<N;j++){
      m[j]=min(m[j],v[(j+N-i)%N]);
      ans+=m[j];
    }
    fans=min(ans,fans);
  }
  cout<<fans<<endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[I() for _ in range(n)]
  sm=0
  ans=0

  for x in l:
    if x==0:
      ans+=sm//2
      sm=0
    else:
      sm+=x
  ans+=sm//2
  return ans

# main()
print(main())


Measured memory_bytes: 10940
import math


def divisors(n: int) -> list:
    s = int(math.sqrt(n))
    ret = []
    if s * s == n:
        ret.append(s)
    else:
        s += 1

    for i in range(1, s):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)

    return sorted(ret, reverse=True)


def partition(N: int, M: int) -> int:
    for gcd in divisors(M):
        if gcd * N > M:
            continue
        return gcd
    return -1


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = partition(N, M)
    print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 500000000
#define IOS ios_base::sync_with_stdio(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
bool check(int n,int p){return (1<<p)&n;}

int main()
{
    IOS;
    ll n;cin>>n;
    int ans=10;
    int sq=sqrt(n);
    for(int i=1;i<=sq;i++)
    {
        if(n%i==0)
        {
//            cout<<i<<" "<<n/i<<endl;
            int x=log10(i);
            int y=log10(n/i);
            int mx=max(x,y)+1;
            ans=min(ans,mx);
        }
    }
    cout<<ans<<endl;
}








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

using namespace std;

int N;
double dp[305][305][305];
int cnt[4];

double solve(int i, int j, int k){
    if(i < 0 || j < 0 || k < 0){
        return 0;
    }
    if(dp[i][j][k] != -1){
        return dp[i][j][k];
    }
    dp[i][j][k] = 1.0*N/(i+j+k) + (solve(i-1,j,k)*1.0*i + solve(i+1,j-1,k)*j + solve(i,j+1,k-1)*k)/(i+j+k);
    return dp[i][j][k];
}

int main(){
    cin >> N;
    for(int i = 0; i<=300; i++){
        for(int j = 0; j<=300; j++){
            for(int k = 0; k<=300; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int i = 1; i<=N; i++){
        int n;
        cin >> n;
        cnt[n]++;
    }
    printf("%.9f", solve(cnt[1], cnt[2], cnt[3]));
}


Measured memory_bytes: 219392
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  bool passed[n];
  fill(passed, passed + n, false);
  int j = 0, k = 0;
  for(int i = 0; i < n; i++){
    switch(s[i]){
      case 'a':
        if(j < a + b){
          passed[i] = true;
          ++j;
        }
        break;
      case 'b':
        if(j < a + b && k < b){
          passed[i] = true;
          ++j;
          ++k;
        }
        break;
    }
  }

  string buf;
  for(int i = 0; i < n; i++){
    if(passed[i]) buf += "Yes\n";
    else buf += "No\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 1340
#include <stdio.h>
#include <iostream>
#include <algorithm>

int main(int argc, char const *argv[])
{
  int A[50];
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &A[i]);
  }

  std::sort(A, A + n);

  double sum = A[0];
  for (size_t i = 1; i < n; i++)
  {
    sum = (sum + (double)A[i]) / 2.0;
  }

  printf("%lf", sum);

  return 0;
}


Measured memory_bytes: 256
num=int(input())
line=input().split(" ")
checklis=sorted(line)
if checklis[0]=="0":
    res=0
else:
    res=1
    i=0
    while res<=1000000000000000000 and i<num:
        res *= int(line[i])
        i+=1
        
    if res>1000000000000000000:
        res= -1
 
print(res)


Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

  cout << pow(2,M) * (1800*M + 100*N) << endl;
}

Measured memory_bytes: 256
import numpy as np

N, K = map(int, input().split())

cnt_win = 0

for n in range(1, N + 1):
    if n >= K:
        cnt_win += 1
    else:
        num_front = np.ceil(np.log2(K / n))
        cnt_win += 1 / np.power(2, num_front)

print(cnt_win / N)

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

int main() {
  int n,ans=10000000;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++) cin >> vec[i];
  for(int i=1; i<=100; i++) {
    int num=0;
    for(int j=0; j<n; j++) {
      num += (vec[j]-i)*(vec[j]-i);
    }
    ans = min(ans,num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*input
32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9
*/

#include <bits/stdc++.h> 
#define N 100010
#define int long long
using namespace std;

const int mod = (int)1e9 + 7;

int n;
int fact[N];

void precalc() {
	fact[0] = 1;
	for (int i = 1; i <= n + 5; i++) fact[i] = (fact[i - 1] * i) % mod;
}
int power(int x, int y) {
	x %= mod;
	int res = 1;
	while (y) {
		if (y & 1) res = (res * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return res;
}

int inverse(int x) {
	int res = power(x, mod - 2);
	assert((res * x) % mod == 1);
	return res;
}

int C(int _n, int _k) {
	if (_n < _k) return 0;
	return fact[_n]  * inverse(fact[_k] * fact[_n - _k] % mod) % mod;
}
int lst[N];
signed main() {
	scanf("%lld", &n);
	int d = 0;
	for (int i = 1; i <= n + 1; i++) {
		int x; scanf("%lld", &x);
		if (lst[x]) d = i - lst[x];
		lst[x] = i;
	}
	precalc();
	for (int k = 1; k <= n + 1; k++) printf("%lld\n", ((C(n + 1, k) - C(n - d, k - 1)) % mod + mod) % mod);	
}

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

int main() {
    int N;
    string S;
    cin >>N>>S;
    vector<int> R,G,B;
    rep(i,N){
        string a = S.substr(i,1);
        if (a =="R") R.push_back(i);
        if (a =="G") G.push_back(i);
        if (a =="B") B.push_back(i);
    }
    ll err=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(S[i]!=S[j]){
                if(2*j-i<=N-1){
                    if(S[i]!=S[2*j-i]&&S[j]!=S[2*j-i]) err++;
                }
            }
        }
    }
    cout << R.size()*G.size()*B.size()-err;
}

Measured memory_bytes: 3652
import sys
s = input()
south = s.count('S')
north = s.count('N')
east = s.count('E')
west = s.count('W')

f = lambda x, y : x == 0 and y != 0

if f(south, north) or f(north, south) or f(east, west) or f(west, east):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;

  lint sub = abs(A-B);
  cout << (sub <= (V-W)*T ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll A,B;
  cin>>A>>B;
  
  if(A>B){
    cout<<"safe"<<endl;
  }
  else{
    cout<<"unsafe"<<endl;
  }
}


Measured memory_bytes: 3624
import math
import fractions
import collections
import itertools
N=input()
if N[len(N)-1]=="3":
    print("bon")
elif (N[len(N)-1]=="0")or(N[len(N)-1]=="1")or(N[len(N)-1]=="6")or(N[len(N)-1]=="8"):
    print("pon")
else:
    print("hon")

Measured memory_bytes: 72684
#include <iostream>

using namespace std;

int main()
{

    string s, k;    cin >> s >> k;
    int num = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != k[i]){
            num++;
        }
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 3832
#include<iostream>
#include<cstring>
#define LcsMaxLen 1005
using namespace std;
char sf[LcsMaxLen];
char ss[LcsMaxLen];
int mark[LcsMaxLen][LcsMaxLen]={0};
int LcsLen( int sfi,int ssi ){
	if(sfi<0||ssi<0)
		return 0;
	if(mark[sfi][ssi])return mark[sfi][ssi];
	if(sf[sfi]==ss[ssi]){
		mark[sfi][ssi] = LcsLen(sfi-1,ssi-1)+1;
		return mark[sfi][ssi];
	}
	else {
		mark[sfi][ssi] = max(LcsLen(sfi,ssi-1),LcsLen(sfi-1,ssi));
		return mark[sfi][ssi];
	}
} 
int main(){
	int n,len;
	cin>>n;
	while(n--){
	cin>>sf>>ss;
	len = max(strlen(sf),strlen(ss));
	for(int i = 0;i<len;++i)
		for(int j = 0;j<len;++j)
			mark[i][j]=0;
	cout<<LcsLen(strlen(sf)-1,strlen(ss)-1)<<endl;
	} 
	return 0;
}


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

int n;
int a[100005];
int b[100005];
long long ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n+1;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        if(b[i]<=a[i]){
            ans+=b[i];
        }else{
            b[i]-=a[i];
            ans+=a[i];
            ans+=min(a[i+1],b[i]);
            a[i+1]-=min(a[i+1],b[i]);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;
 
using namespace std;
int dp[1005][1005];
 
int main() {
    int n; cin >> n;
    REP(k, n){
        REP(i, 1005) REP(j, 1005) dp[i][j] = 0;
        string a, b;
        cin >> a >> b;
        REP(i, a.length()){
            string q = a.substr(i, 1);
            REP(j, b.length()){
                string t = b.substr(j, 1);
                if(q == t){
                    if(i == 0 || j == 0)
                        dp[i][j] = 1;
                    else
                        dp[i][j] = (dp[i-1][j] > dp[i][j-1]) ? max(dp[i-1][j-1] + 1, dp[i-1][j]) : max(dp[i-1][j-1] + 1, dp[i][j-1]);
                }
                else if (i != 0 && j != 0)
                    dp[i][j] = (dp[i-1][j] > dp[i][j-1]) ? dp[i-1][j] : dp[i][j-1];
                else if (i != 0)
                    dp[i][j] = dp[i-1][j];
                else
                    dp[i][j] = dp[i][j-1];
            }
        }
        cout << dp[a.length()-1][b.length()-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 5156
from functools import reduce
from operator import and_, or_

N = int(input())
S, T, U, V = [[int(a) for a in input().split()] for _ in range(4)]
X = [[U[i] & V[j] if S[i] and T[j] else U[i] if T[j] else V[j] if S[i] else U[i] | V[j] for j in range(N)] for i in range(N)]

for _ in range(2):
    A1 = [-1] * N
    A2 = [[-1] * N for _ in range(N)]
    for i in range(N-1)[::-1]:
        for j in range(N):
            A2[i][j] = A2[i+1][j] & X[i+1][j]
    for i in range(N):
        if S[i]: a = ~U[i] | reduce(or_, X[i])
        for j in range(N):
            if S[i] and not T[j]:
                X[i][j] |= ~(A1[j] & A2[i][j] | a)
                a |= X[i][j]
            A1[j] &= X[i][j]
    
    if [reduce(or_ if S[i] else and_, x) for i, x in enumerate(X)] != U:
        print(-1)
        exit()
    
    X = [[X[j][i] for j in range(N)] for i in range(N)]
    S, T, U, V = T, S, V, U

for x in X:
    print(*x)

Measured memory_bytes: 142944
using System;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		string status = "Good";
      	string s1 = s.Substring(0,1);
      	string s2 = s.Substring(1,1);
      	string s3 = s.Substring(2,1);
      	string s4 = s.Substring(3,1);
      	if(s1 == s2){
          status = "Bad";
        }
      	if(s2 == s3){
          status = "Bad";
        }
      	if(s3 == s4){
          status = "Bad";
        }
		Console.WriteLine(status);
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  vector<Int> dp(k+1,0);
  for(Int i=1;i<=k;i++)
    for(Int x:a)
      dp[i]|=i>=x&&!dp[i-x];
    
  cout<<(dp[k]?"First":"Second")<<endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
X, Y = [int(x) for x in input().split()]

for i in range(X):
  x2 = i
  x4 = X - i
  if ((int(x2*2+x4*4) == Y) or (int(x2*4+x4*2) == Y)):
    print('Yes')
    sys.exit()

print('No')

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  if(n%2==0){
    for(int i=0;i<n;i++){
      cin >> a.at(i);
      if(i%2==0)
      b.at(n/2+i/2)=a.at(i);
      else
      b.at(n/2-i/2-1)=a.at(i);
    }
  }
  else{
    for(int i=0;i<n;i++){
      cin >> a.at(i);
      if(i%2==0)
      b.at(n/2-i/2)=a.at(i);
      else
      b.at(n/2+i/2+1)=a.at(i);
    }
  }
  for(int i=0;i<n;i++){
    cout << b.at(i) << ' ';
  }
  cout << endl;
}



Measured memory_bytes: 6424
#include<stdio.h>
#include<string.h>
#define N 100000000 
  
char c[14];
int x[N];
int n;
   
int a(void);
int b(char);
void insert(void);
int find(void);
   
int main(){
char str[7];
int i;
   
 scanf("%d",&n);
 for(i=0;i<n;i++){
   scanf("%s%s",str,c);
   if(str[0]=='i'){
     insert();
   }
   else if(str[0]=='f'){
     if(find())printf("yes\n");
     else printf("no\n");
   }
 } 
 return 0;
}
  
int a(void){
  int x=0,i,p=1;
  for(i=0;i<strlen(c);i++){
    x+=p*(b(c[i]));
    p*=5;
  }
  return x;
}
   
int b(char c){
   
  if(c=='A'){
    return 1;
  }
  else if(c=='C'){
    return 2;
  }
  else if(c=='G'){
    return 3;
  }
  else return 4;
   
}
  
void insert(){
  x[a()]=1;
}
int find(){
    int key =a();
       
    if(x[key]){
   return 1;
    }
    else return 0;
} 

Measured memory_bytes: 38628
N, K = map(int, input().split())
A = tuple(map(int, input().split()))

dp = [False] * (K + 1)
for i in range(1, K + 1):
    dp[i] = not all(dp[i - x] for x in A if i - x >= 0)
print('First' if dp[K] else 'Second')


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    ll n;
    cin>>n;
    ll ans=0;
    if(n%2==1){
        ans=0;
    }
    else{
        n/=2;
        while(n>1){
            n/=5;
            //cout<<n<<endl;
            ans+=n;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256