akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void rdi(ll &x){
	ll f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
ll d[100005];
ll u[100005];
ll m;
int tmm;
int n;
vector<int> v[100005];
inline void dfs1(int x,int fa){
	d[x]=1;
	for(int y:v[x]){
		if(y!=fa){
			dfs1(y,x);
			d[x]=(d[x]*(1+d[y]))%m;
		}
	}
}

inline void dfs2(int x,int fa){
	for(int y:v[x]) if(y!=fa) u[y]=u[x];
	ll pre=1;
	for(int y:v[x]) if(y!=fa){
		u[y]=u[y]*pre%m;
		pre=pre*(d[y]+1)%m;
	}
	ll suf=1;
	reverse(v[x].begin(),v[x].end());
	for(int y:v[x]){
		if(y!=fa){
			u[y]=u[y]*suf%m;
			suf=suf*(d[y]+1)%m;
		}
	}
	for(int y:v[x]){
		if(y!=fa){
			u[y]=(u[y]+1)%m;
			dfs2(y,x);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	int i,j,x,y;
	for(i=1;i<n;++i){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
//	cerr<<"OK"<<endl;
	dfs1(1,0);
//	cerr<<"Ok"<<endl;
	u[1]=1;
	dfs2(1,0);
	for(i=1;i<=n;++i) cout<<d[i]*u[i]%m<<endl;
	return 0;
}

Measured memory_bytes: 10624
import java.io.*;
import java.util.*;

public class Main {

	int[] next;
	int[] head;
	int[] to;
	
	int[] color;
	
	int c1, c2;
	
	void submit() {
		int n = nextInt();
		int m = nextInt();
		
		head = new int[n];
		Arrays.fill(head, -1);
		next = new int[2 * m];
		to = new int[2 * m];
		
		for (int i = 0; i < m;i++) {
			int v = nextInt() - 1;
			int u = nextInt() - 1;
			to[2 * i] = u;
			next[2 * i] = head[v];
			head[v] = 2 * i;
			
			to[2 * i + 1] = v;
			next[2 * i + 1] = head[u];
			head[u] = 2 * i + 1;
		}
		
		color = new int[n];
		
		long ans = -m;
		
		for (int i = 0; i < n; i++) {
			if (color[i] == 0) {
				c1 = c2 = 0;
				if (dfs(i, 1)) {
					ans += (long)c1 * c2;
				} else {
					ans += (long)(c1 + c2) * (c1 + c2 - 1) / 2;
				}
			}
		}
		out.println(ans);
	}
	
	boolean dfs(int v, int col) {
		if (col == 1) {
			c1++;
		} else {
			c2++;
		}
		color[v] = col;
		boolean ret = true;
		for (int e = head[v]; e >= 0; e = next[e]) {
			int u = to[e];
			if (color[u] == 0) {
				ret &= dfs(u, 3 - col);
			} else if (color[u] == col) {
				ret = false;
			}
		}
		return ret;
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 48452
import numpy as np

N=int(input())
H=list(map(int,input().split()))

dp=np.zeros(N+1,dtype=int)

dp[0]=0
dp[1]=0
for i in range(1,N):
    if i==1:
        dp[i+1] = abs(H[1]-H[0])
    else:
        dp[i+1] = min( dp[i] + abs( H[i] - H[i-1] ), dp[i-1] + abs( H[i] - H[i-2] ) )

# print(dp)
print(dp[N])

Measured memory_bytes: 22824
#include <stdio.h>
int main(){
        double a,b,c,d,e,f,a2,b2,c2,d2,e2,f2,tmp1,tmp2,k,x,y;
        while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
        b2 = b * d;
        c2 = c * d;
        e2 = e * a;
        f2 = f * a;
        tmp1 = b2 - e2;
        tmp2 = c2 - f2;
        y = tmp2 / tmp1;
    a2 = a * e;
        c2 = c * e;
        d2 = d * b;
        f2 = f * b;
        tmp1 = a2 -d2;
        tmp2 = c2 - f2;
        x = tmp2 / tmp1;

        if(x<0.0004 && x>-0.0004)
                x=0.000;
        if(y<0.0004 && y>-0.0004)
                y=0.000;

        printf("%.3f %.3f\n",x,y);
        }
return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;

int main(){
    string s;
    std::cin >> s;
    std::cout << s.substr(0,s.size()-8) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll N;
	ll ans=0;
	cin>>N;
	vector<ll> A(N);
	vector<ll> B(N);
	vector<ll> C(N);
	for(int i=0;i<N;i++) cin>>A[i];
	for(int i=0;i<N;i++) cin>>B[i];
	for(int i=0;i<N-1;i++) cin>>C[i];
	for(int i=0;i<N;i++){
		ans+=B[i];
	}
	for(int i=1;i<N;i++){
		if(A[i]-1==A[i-1]){
			ans+=C[A[i-1]-1];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long N, long long K){

}

int main(){
    LL K,A,B;
    cin>>K>>A>>B;
    LL bsc = 1;
    if(B-A<=1){
        cout<<K+1<<endl;
    }
    else
    {
        LL res=0;
        if(A > 1){
            res += A-1;
            K -= A-1;
        }
        LL k = K/(2);
        LL r = K%(2)+res;
        debug(k); debug(r);
        cout<<1+r+k*(B-A)<<endl;

        // for(int i=0; i < K; i++){
        //     if(bsc >= A){
        //         bsc = 0;
        //     }
        //     else if( bsc ==0 ){
        //         bsc += B;
        //     }
        //     else{
        //         bsc++;
        //     }
        //     debug(bsc);
        // }
        // cout<<bsc<<endl;
    }
    
}


Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n, k; cin >> n >> k;
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    int t; cin >> t;
    if(t >= k) cnt++;
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    rep(i, N){
        int A;
        cin >> A;
        if(A%2==0){
            if(A%3!=0&&A%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;

}


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

const int N=1e5 +3;
char a[N];
unordered_map<string, int>mp;
vector<string>v;

int main(){

    int k;
    scanf("%s", a);
    scanf("%d", &k);
    string s(a);
    int sz=s.length();

    for(int i=1; i<=k; ++i){
        for(int j=0; j<sz-i+1; ++j){
            string sub=s.substr(j, i);
            ++mp[sub];
            --mp[sub];
            if(mp[sub]==0){
                mp[sub]=1;
                v.push_back(sub);
            }
        }
    }


    sort(v.begin(), v.end());
    sz=v.size();

    printf("%s", v[k-1].c_str());

    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> v;
	int p[a], q[b], r[c];
	for (int i = 0; i < a; i++){
		cin >> p[i];
	}
	for (int i = 0; i < b; i++){
		cin >> q[i];
	}
	for (int i = 0; i < c; i++){
		cin >> r[i];
		v.push_back(r[i]);
	}

	sort(p, p+a); sort(q, q+b); sort(r, r+c);
	reverse(p, p+a); reverse(q, q+b); reverse(r, r+c);

	for (int i = 0; i < x; i++){
		v.push_back(p[i]);
	}

	for (int i = 0; i < y; i++){
		v.push_back(q[i]);
	}

	sort(v.begin(), v.end(), greater<int>());

	long long res = 0;
	for (int i = 0; i < x+y; i++){
		res += v[i];
	}

	cout << res << endl;



}


Measured memory_bytes: 3572
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

b = raw_input()
b = b.replace('A', '1').replace('T', '2').replace('C', '3').replace('G', '4')
b = b.replace('1', 'T').replace('2', 'A').replace('3', 'G').replace('4', 'C')
print b

Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



template<class T> T gcd(T x, T y) {
	return (y ? gcd(y, x % y) : x);
}
template<class T> class segtree {
    int n = 1;
    vector<T> dat;
    T def = 0; //Default value

public:
    segtree(int _n) {
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
    }
    segtree(vector<T> a) {
        int _n = a.size();
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
        REP(i, 0, _n)dat[i + n - 1] = a[i];
        rREP(i, 0, n - 1)dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
    }


    T fun(T x, T y) { 
        if (x == 0 || y == 0)return max(x, y);
        return gcd(x, y); 
    }

    //assignment,chmin,chmax,etc...
    void update(int i, T a) {
        i += n - 1;
        dat[i] = a;
        while (i > 0) {
            --i /= 2;
            dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }


    T value(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a)return def;
        if (a <= l && r <= b)return dat[k];
        T s = value(a, b, 2 * k + 1, l, (l + r) / 2);
        T t = value(a, b, 2 * k + 2, (l + r) / 2, r);
        return fun(s, t);
    }
    T value(int a, int b) { return value(a, b, 0, 0, n); }

    T operator[](int k) { return dat[k + n - 1]; }
};

int main() {
	init();

	int N; cin >> N;

    segtree<int> seg(N);
    rep(i, N) {
        int a; cin >> a;
        seg.update(i, a);
    }

    int ans = seg.value(0, N);
    rep(i, N) {
        int a = seg.value(0, i);
        if (i == 0)a = 0;
        int b = seg.value(i + 1, N);
        if (i == N - 1)b = 0;
        chmax(ans, gcd(a, b));
    }
    cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        int digit = 0;
        
        while(N != 0){
            N = N/K;
            digit++;
        }
        
        System.out.println(digit);
    }
}


Measured memory_bytes: 35528
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


immutable INF = 10L^^18;

int N;
long[][] A;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      A = new long[][](N, N);
      foreach (u; 0 .. N) foreach (v; 0 .. N) {
        A[u][v] = readLong();
      }
      auto scores = new long[](1 << N);
      foreach (p; 0 .. 1 << N) {
        foreach (u; 0 .. N) foreach (v; u + 1 .. N) {
          if (((p >> u) & 1) && ((p >> v) & 1)) {
            scores[p] += A[u][v];
          }
        }
      }
      auto dp = scores.dup;
      foreach (p; 0 .. 1 << N) {
        for (int q = p; q; --q &= p) {
          chmax(dp[p], dp[p ^ q] + scores[q]);
        }
      }
      writeln(dp[$ - 1]);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 3324
#include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
int dx[] = {-1,0,1};
void saiki(int x,int y) {
  if(y >= h-1) memo[y][x]++;
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = x+dx[i], ny = y+1;
      if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
      if(nx <0|| nx >= w ||mp[ny][nx] == 1) continue;

      if(memo[ny][nx] > 0 && mp[ny][nx] == 0) memo[y][x] += memo[ny][nx];
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	memo[y][x] += memo[ny][nx];
      }
    }
    if(memo[y][x] == 0) mp[y][x] = 1;
  }
}
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
     
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
  
    for(int i=0;i<w;i++)
      if(mp[0][i] !=1) saiki(i,0);
     
    int cnt = 0;
    for(int i=0;i<w;i++)
      if(memo[0][i] > 0) cnt+=memo[0][i];
    cout <<cnt<<endl;
  }
  return 0;
}

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

typedef unsigned long long ull;
const int MAX_N = 100005;
ull a[MAX_N];

int main() {
  int n;
  ull k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int ai, bi;
    cin >> ai >> bi;
    a[ai] += bi;
  }
  for (int i = 0; i < MAX_N; i++) {
    if (k <= a[i]) {
      cout << i << endl;
      break;
    }
    k -= a[i];
  }
}

Measured memory_bytes: 1024
from sys import stdin
from collections import deque

def paint(n):
    if n == 1:
        return 0
    else:
        return 1

S = stdin.readline().rstrip()
data = deque([int(x) for x in S])

before = data.popleft()
cnt = 0

while data:
    if data[0] == before:
        cnt += 1
        before = paint(data.popleft())
    else:
        before = data.popleft()

print(cnt)

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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

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

    int X[20][20];
    rep(i,N) {
        rep(j,D) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            int value = 0;
            rep(k, D) {
                int tmp = abs(X[i][k] - X[j][k]);
                value += tmp * tmp;
            }

            for (int l = 0; l <= value; l++) {
                if (value == l * l) ans++;
            }
        }
    }
    cout << ans << endl;
} 

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

const long long maxn = 60;
const long long maxa = 60;
const long long inf = 1e18 + 7;

long long n;
long long ans;
int zarib[maxa];
long long a[maxn];
long long b[maxn];
long long cost[maxa][maxa];

void in();
void solve();
long long getmx();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(long long i = 0; i < n; i++)
        cin >> a[i];
    for(long long i = 0; i < n; i++)
        cin >> b[i];
}

void YEET(){
    for(long long i = 0; i < maxa; i++)
        for(long long j = 0; j < maxa; j++)
            cost[i][j] = inf;
    for(long long i = 0; i < maxa; i++){
        for(long long j = 0; j <= i; j++){
            if(i == j)
                cost[i][j] = 0;
            else
                for(long long k = 1; k <= i; k++)
                    cost[i][j] = min(cost[i][j], cost[i % k][j] + (1ll << k) * zarib[k]);
        }
    }
}


void solve(){
    for(int i = 0; i < maxa; i++)
        zarib[i] = 1;
    YEET();
    long long wow = getmx();
    while(wow != 0){
        ans += 1ll << wow;
        zarib[wow] = 0;
        wow = getmx();
        YEET();
    }
}

long long getmx(){
    long long wow = 0;
    for(long long i = 0; i < n; i++){
        if(cost[a[i]][b[i]] == inf){
            cout << -1;
            exit(0);
        }
        wow = max(wow, cost[a[i]][b[i]]);
    }
    long long ret = 0;
    while((wow >> ret) != 0)
        ret++;
    ret--;
    if(wow == 0)
        return 0;
    return ret;
}

void out(){
    cout << ans / 2;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;

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

    while(true) {
      int w = sc.nextInt();
      int h = sc.nextInt();

      if(w == 0 && h == 0) {
        break;
      }

      int map[][] = new int[h+2][w+2];
      int searched[][] = new int[h+2][w+2];

      for(int y = 0; y < h+2; y++) {
        for(int x = 0; x < w+2; x++) {
          map[y][x] = 1 <= y && y <= h && 1 <= x && x <= w ? sc.nextInt() : 0;
          searched[y][x] = 0;
        }
      }

      int count = 0;
      for(int y = 1; y <= h; y++) {
        for(int x = 1; x <= w; x++) {
          if(searched[y][x] == 0 && map[y][x] == 1) {
            Queue<Integer> queuey = new ArrayDeque<Integer>();
            Queue<Integer> queuex = new ArrayDeque<Integer>();

            searched[y][x] = 1;
            queuey.add(y);
            queuex.add(x);

            while(!queuey.isEmpty()) {
              int q = queuey.remove();
              int p = queuex.remove();

              if(searched[q-1][p-1] == 0) {
                searched[q-1][p-1] = 1;
                if(map[q-1][p-1] == 1) {
                  queuey.add(q-1);
                  queuex.add(p-1);
                }
              }

              if(searched[q-1][p] == 0) {
                searched[q-1][p] = 1;
                if(map[q-1][p] == 1) {
                  queuey.add(q-1);
                  queuex.add(p);
                }
              }

              if(searched[q-1][p+1] == 0) {
                searched[q-1][p+1] = 1;
                if(map[q-1][p+1] == 1) {
                  queuey.add(q-1);
                  queuex.add(p+1);
                }
              }

              if(searched[q][p-1] == 0) {
                searched[q][p-1] = 1;
                if(map[q][p-1] == 1) {
                  queuey.add(q);
                  queuex.add(p-1);
                }
              }

              if(searched[q][p+1] == 0) {
                searched[q][p+1] = 1;
                if(map[q][p+1] == 1) {
                  queuey.add(q);
                  queuex.add(p+1);
                }
              }

              if(searched[q+1][p-1] == 0) {
                searched[q+1][p-1] = 1;
                if(map[q+1][p-1] == 1) {
                  queuey.add(q+1);
                  queuex.add(p-1);
                }
              }

              if(searched[q+1][p] == 0) {
                searched[q+1][p] = 1;
                if(map[q+1][p] == 1) {
                  queuey.add(q+1);
                  queuex.add(p);
                }
              }

              if(searched[q+1][p+1] == 0) {
                searched[q+1][p+1] = 1;
                if(map[q+1][p+1] == 1) {
                  queuey.add(q+1);
                  queuex.add(p+1);
                }
              }
            }

            count++;
          }
        }
      }

      System.out.println(count);
    }
  }
}

Measured memory_bytes: 44768
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long A, B;
    cin >> A >> B;
    if(A <= B*2) cout << 0 << endl;
    else cout << A - B*2 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a:
    i += 1
    while np.any(d == x[i]):
        x[i] += 1
        if i != a:
            x[i + 1:] = 0
        if x[i] == 10:
            x[i - 1] += 1
            x[i:] = 0
            i -= 1

ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

Measured memory_bytes: 12392
#include <iostream>
#include <cstring>
#include <stack>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
    char c[10][10];
    for(int i=1;i<=2;i++)
    {
        for(int j=1;j<=4;j++)
        {
            scanf("%c",&c[i][j]);
        }
    }
    if(c[1][1]==c[2][3]&&c[1][2]==c[2][2]&&c[1][3]==c[2][1])
    {
        printf("YES\n");
    }
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 888
s = input()
a = [int(c) for c in s]
mark = ['+', '-']
sum = 0
ans = 0
for i in range(2**3):
    sum = int(a[0])
    for j in range(3):
        k = (i >> j)
        sum += int(a[j+1])*(-1)**k
    if sum == 7:
        ans = i
        break
# print(i)
# 下からn桁目のビットが1:-
# 下からn桁目のビットが0:+
b = []
m = []
formula = ''
for l in range(3):
    b.append(str(a[l+1]))
    c = (ans >> l & 1)
    m.append(mark[c])
    formula += (m[l] + b[l])
print(str(a[0]) + formula + '=7')

Measured memory_bytes: 62048
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;
struct UnionFind{
  vector<int> par;
  UnionFind(int n) : par(n, -1){}
  int root(int x){ return (par[x] < 0) ? x : par[x] = root(par[x]); }
  int size(int x){ return -par[root(x)]; }
  bool issame(int x, int y){ return root(x) == root(y); }
  void marge(int x, int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(x > y) swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }
};

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  REP(i, n) cin >> p[i], p[i]--;
  UnionFind uf(n);
  REP(i, m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    uf.marge(p[x], p[y]);
  }
  int ans = 0;
  REP(i, n){
    if(uf.issame(p[i], i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> a(6);
    int ans;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        if(a[i] == 0){
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 3504
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define mp make_pair
#define re return
#define first fi
#define second se
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi;
int sum,n,k=1;
int dish[30]={INF},words[29],score[30];
int plas[30];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>dish[i];
		if(dish[i]==dish[i-1]+1){
			plas[k]=dish[i-1];
			k++;
		}
	}
	for(int i=1;i<=n;i++){
		cin>>score[i];
		sum+=score[i];
	}
	for(int i=1;i<=n-1;i++)
		cin>>words[i];
	for(int i=1;i<=k;i++)
		sum+=words[plas[i]];
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
A, B, M = [int(a) for a in input().split()]
a = [int(ai) for ai in input().split()]
b = [int(bi) for bi in input().split()]
x = []
y = []
c = []
for _ in range(M):
    xi, yi, ci = [int(xyc) for xyc in input().split()]
    x.append(xi)
    y.append(yi)
    c.append(ci)

min_price = min(a) + min(b)
for i in range(M):
    price = a[x[i]-1] + b[y[i]-1] - c[i]
    min_price = min(min_price, price)

print(min_price)

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll X;
    cin >> X;

    ll ans = 0;
    ans = (X / 500) * 1000 + ((X % 500) / 5) * 5;
    _PR(ans);

    return 0;
}

/*



*/

Measured memory_bytes: 256
N = int(input())
S = {}
for i in range(N):
  s = "".join(sorted(input()))
  try:
    S[s]+=1
  except:
    S[s]=1
ans = 0

for i in S.keys():
  n = S[i]
  ans += n*(n-1)//2

print(ans)

Measured memory_bytes: 17896
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;



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

	cin >> N >> M >> K >> L >> R >> H;
	long double ans = 0;
	vector<int>v(H + 1);
	for (int i = 0; i < N; i++) {
		cin >> W;
		v[W]++;
	}
	int index = 0;
	int num = 0;
	int dush = 0;
	for (int i = 1; i <= H; i++) {
		if (dush >= i) {
			ans += (long double)1 / R;
		}
		else ans += (long double)1 / L;
		if (v[i]) {
			if (dush <= i)dush = i + R * K;
			else if (num < M)num++;
			else dush = i + R * K;
		}
		if (dush <= i && num) {
			num--;
			dush = i + R * K;
		}
		//cout << i << " " << ans << endl;
	}
	cout << setprecision(20) << ans << endl;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x,ans=0,cur=100;
	cin>>x;
	while(cur<x){
		cur+=cur/100;
		ans++;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = t.size();

  for (int start = 0; start <= s.size() - t.size(); start++){
    int diff = 0;

    for(int i = 0; i < t.size(); i++){
      if(t[i] != s[start + i]){
        diff++;
      }
    }
    ans = min(ans, diff);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int K;
int h[100010];

int main() {
	int cnt = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		if (h[i] >= K) {
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int p[M];
  string S[M];
  int done[N+1]={0}, wa[N+1]={0};
  int cr=0,pn=0;

  for(int i=0;i<M;i++){
    cin >> p[i] >> S[i];
    if(S[i]=="WA")wa[p[i]]+=1;
    if(S[i]=="AC"&&done[p[i]]==0){
      cr += 1;
      done[p[i]] = 1;
      pn += wa[p[i]];
    }
  }

  cout << cr << " " << pn << endl;
  return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t;
    int a[4]={0,0,0,0};
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s=="AC") a[0]++;
        else if(s=="WA") a[1]++;
        else if(s=="TLE") a[2]++;
        else a[3]++;
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
}

Measured memory_bytes: 3612
def can_travel(ts, xs, ys):
    t_prev, x_prev, y_prev = 0, 0, 0
    for t, x, y in zip(ts, xs, ys):
        t_diff = t - t_prev
        d = abs(x - x_prev) + abs(y - y_prev)

        if t_diff < d:
            return False

        if t_diff % 2 != d % 2:
            return False

    return True


if __name__ == '__main__':
    N = int(input())
    values = [list(map(int, input().split())) for _ in range(N)]
    ts, xs, ys = zip(*values)

    if can_travel(ts, xs, ys):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 36764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        System.out.println(s.equals(t.substring(0, t.length()-1)) ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 35616
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long 



bool comp1(pair<ll,ll>a,pair<ll,ll> b)
{
    if(a.first+a.second<b.first+b.second)
    {
        return(true);
    }
    else
    {
        return(false);
    }
}

bool comp2(pair<ll,ll> a,pair<ll,ll>b)
{
    if(a.first-a.second <b.first-b.second)
    {
        return(true);
    }
    else
    {
        return(false);
    }
}
int main()
{
    ll n,i;
    cin>>n;
    vector<pair<ll,ll> >p;
    ll x,y;
    for(i=0;i<n;i++){
        cin>>x>>y;
        p.push_back(make_pair(x,y));
    }
    sort(p.begin(),p.end(),comp1);
    ll ans=(p[n-1].first+p[n-1].second)-(p[0].first+p[0].second);
    sort(p.begin(),p.end(),comp2);
    ans=max(ans,(p[n-1].first-p[n-1].second)-(p[0].first-p[0].second));
    cout<<ans<<"\n";
}

Measured memory_bytes: 7404
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

using LL = long long;
const int N = 2e5 + 3;

int a[N];
bool mk[N * 5], mk1[N * 5];
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    for (int i = 0; i <  n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (mk[a[i]]) continue;
        if (mk1[a[i]]) {
            ans--;
            mk[a[i]] = true;
            continue;
        }
        ans++;
        mk1[a[i]] = true;
        for (int j = a[i] * 2; j < N * 5; j += a[i]) {
            mk[j] = true;
        }
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6244
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int C = sc.nextInt();
			double rad = (double)C / 180 * Math.PI;
			double S = a*b*Math.sin(rad)/2;
			double L = a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(rad));
			double H = S*2/a;
			System.out.println(S);
			System.out.println(L);
			System.out.println(H);
		}
	}
}


Measured memory_bytes: 26348
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<string> vstr;
void print() {cout<<'\n';}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<'\n';}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int a, b;
    cin >> a >> b;
    print((a-1) * (b-1));
}


Measured memory_bytes: 256
def maxtime(x):
  return (x + 9) // 10 * 10

def restime(x):
  return maxtime(x) - x

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

sumtime = maxtime(A)+maxtime(B)+maxtime(C)+maxtime(D)+maxtime(E)
maxrestime = max(restime(A),restime(B),restime(C),restime(D),restime(E))
print(sumtime - maxrestime)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n, W;
int w[105], v[105];
int dp[105][N];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n>>W;
    f(i, n) cin>>w[i]>>v[i];
    for(int i = w[0]; i <= W; i++) dp[0][i] = v[0];
    for(int i = 1; i < n; i++) {
        for(int j = 0; j <= W; j++) {
            if(w[i] > j) dp[i][j] = dp[i - 1][j];
            else {
                dp[i][j] = max(dp[i - 1][j], v[i] + dp[i - 1][j - w[i]]);
            }
        }
    }
    cout<<dp[n - 1][W];
    return 0;
}

Measured memory_bytes: 80128
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    string sub = s.substr(0, 4);
    cout << (sub == "YAKI" ? "Yes" : "No") << endl;
    return 0;
}


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

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

  ll N; cin >> N;
  vector<ll> L(N); for (ll i = 0; i < N; i++) cin >> L[i];

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      for (ll k = j + 1; k < N; k++) {
        ll a = L[i], b = L[j], c = L[k];
        if (a == b || b == c || c == a) continue;
        if (a + b > c && b + c > a && c + a > b) ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
int main(){
	int n,flag=0;
	int a[100001];
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int x=1;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(a[x]==2){
			flag=1;cnt+=1;
			break;
		}
		cnt+=1;	x=a[x];
	}
	if(flag==1) printf("%d",cnt);
	else printf("-1");
	return 0;
	}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;

    long long r = n % k;
    cout << min(r, k - r) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;


int N;
string S[1000000];
vector<pair<int,int>>inc,de;

int main(){
	cin>>N;
	for(int i=0;i<N;i++)cin>>S[i];
	int cnt=0;
	for(int i=0;i<N;i++){
		for(char c:S[i]){
			if(c=='(')cnt++;
			else cnt--;
		}
	}
	if(cnt!=0){
		puts("No");
		return 0;
	}
	for(int i=0;i<N;i++){
		int cc=0;
		int mn=0;
		for(char c:S[i]){
			if(c=='(')cc++;
			else cc--;
			mn=min(mn,cc);
		}
		if(cc>=0){
			inc.push_back({-mn,cc});
		}
		else{
			de.push_back({cc-mn,-cc});
		}
	}
	sort(inc.begin(),inc.end());
	sort(de.begin(),de.end());
	int t=0;
	for(auto p:inc){
		if(p.first>t){
			puts("No");
			return 0;
		}
		t+=p.second;
	}
	t=0;
	for(auto p:de){
		if(p.first>t){
			puts("No");
			return 0;
		}
		t+=p.second;
	}
	puts("Yes");
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<int> w(n);
    for(int i = 0; i < n; i++) cin >> w[i];

    V<int> v(n + 1);
    for(int i = 0; i < n; i++){
        v[i + 1] = v[i] + w[i];
    }


    int ans = IINF;
    for(int i = 1; i < n; i++){
        int a = v[i];
        int b = v[n] - v[i];
        ans = min(abs(a - b), ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
from math import cos, pi
a,b,h,m = map(int, input().split()) 

mangle = 2*pi * (m/60)
hangle = 2*pi * (h/12) + (1/6)*pi*(m/60)
dist = np.sqrt(a**2+b**2 - 2*a*b*cos(mangle- hangle))
print(dist)

Measured memory_bytes: 27064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,char> ic;
typedef pair<db,db> dd;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;

const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 998244353;

int a, b;
ii ar[maxn];

void solve() {
	scanf("%d",&a);
	printf("%.12lf\n",(double)((a+1)/2)/a);
}

int main() {

    //freopen("asd.in","r",stdin);
    //freopen("output17.txt","w",stdout);

	int n = 1;
	//scanf("%d",&n);
	while( n-- ) solve();

	return 0;
}

Measured memory_bytes: 256
X, Y = input().split()
alphabet = ['A', 'B', 'C', 'D', 'E', 'F']
x_i = 0
y_i = 0
for i in range(6):
    if alphabet[i] == X:
        x_i = i
    if alphabet[i] == Y:
        y_i = i
if x_i < y_i:
    print('<')
elif x_i > y_i:
    print('>')
else:
    print('=')


Measured memory_bytes: 9084
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
int f[2000000];
int main(){
	int k=read();
	int x=7, ans=1;
	if (x%k==0){
		puts("1");
		return 0;
	}
	x%=k;
	while (!f[x]){
		f[x]=1;
		x=(x*10+7)%k;
		ans++;
		if (!x){
			cout<<ans<<endl;
			return 0;
		}
	}
	puts("-1");
    return 0;
}

Measured memory_bytes: 7536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int n;
  cin >> n;
  ll ans=0;
  ans=(ll)(n-1)*(ll)n/2;
  cout << ans << endl;
   return 0;
}



Measured memory_bytes: 256
import numpy as np
n, m = map(int, input().split())
a = [[j for j in input()] for i in range(n)]
b = [[j for j in input()] for i in range(m)]
ans = 'No'
na = np.array(a)
nb = np.array(b)
for i in range(n-m+1):
    for j in range(n-m+1):
        s = na[i:m+i, range(j, m+j)]
        if (s == nb).all():
            ans = 'Yes'
            break
print(ans)

Measured memory_bytes: 21676
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}


Measured memory_bytes: 256
s=list(input())
if s[0]=='A':
    if 'C' in s[2:len(s)-1]:
        s.sort()
        t=''.join(s[2:len(s)-1])
        if t.islower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')



Measured memory_bytes: 38384