akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
int n,m,r;
int now=1,prev=0;
ll dp[100001];
ll mod=1000000;

int main(void){
	scanf("%d%d%d",&n,&m,&r);
	r-=m*n;
	if(r<0){
		puts("0");
		return 0;
	}
	if(r==0){
		puts("1");
		return 0;
	}
	int nr=n+r-1,h=0;
	dp[0]=1;
	for(int i=2;i<=nr;i++){
		ll p=0;
		for(int j=0;j<=h;j++){
			dp[j]*=i;
			dp[j]+=p;
			p=0;
			if(dp[j]>=mod){
				if(j==h)h++;
				p=dp[j]/mod;
				dp[j]=dp[j]%mod;
			}
		}
	}
	for(int i=2;i<=r;i++){
		ll p=0;
		for(int j=h;j>=0;j--){
			dp[j]+=mod*p;
			p=dp[j]%i;
			dp[j]=dp[j]/i;
		}
	}
	for(int i=2;i<=nr-r;i++){
		ll p=0;
		for(int j=h;j>=0;j--){
			dp[j]+=mod*p;
			p=dp[j]%i;
			dp[j]=dp[j]/i;
		}
	}
	bool f=false;
	for(int i=h;i>=0;i--){
		if(f)printf("%06lld",dp[i]);
		if(!f && dp[i]>0){
			f=true;
			printf("%lld",dp[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    map<char, int> m;
    int acnt = 'z' - 'a' + 1;
    
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }
    
    rep(i, s.length()) {
        m[s[i]]++;
    }
    
    if (sz(m) == acnt) {
        rrep(i, s.length()) {
            bool f = false;
            m.clear();
            
            rep(ii, i) {
                m[s[ii]]++;
            }
            
            reps(ii, 1, 'z' - s[i] + 1) {
                char c = (char)(s[i] + ii);
                
                if (m.count(c) == 0) {
                    f = true;
                    s[i] = c;
                    
                    if (i != (s.length() - 1)) {
                        s = s.substr(0, i + 1);
                    }
                    
                    break;
                }
            }
            
            if (f) {
                break;
            }
        }
    }
    else {
        rep(i, acnt) {
            if (m.count(i + 'a') == 0) {
                s += (char)(i + 'a');
                break;
            }
        }
    }
    
    cout << s << endl;
    return 0;
}

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

using namespace std;

int main()
{
	string str1, str2;

	cin >> str1;
	cin >> str2;

	char ch = str1[0];
	str1[0] = str1[2];
	str1[2] = ch;

	if (str1 == str2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    ll X;
    cin >> X;
    vector<ll> A(8001);
    for (int i=0;i<=8000;i++) {
        A[i] = (i-4000);
        A[i] *= A[i];
        A[i] *= A[i];
        A[i] *= (i-4000);
    }

    for (int i=0;i<=8000;i++) {
        for (int j=i+1;j<=8000;j++) {
            if (A[j]-A[i] == X) {
                cout << j-4000 << " " << i-4000 << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

int main() {
  int a;
  cin >> a;
  if(a == 22){
    cout << "Christmas Eve Eve Eve";
  }
  if(a == 23){
    cout << "Christmas Eve Eve";
  }
  if(a == 24){
    cout << "Christmas Eve";
  }
  if(a == 25){
    cout << "Christmas";
  }
  return 0;
}

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

ll gcd(ll a, ll b) {
  return b?gcd(b,a%b):a;
}

ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}


int main(){
  int a,b;
  cin >> a >> b;

  cout << lcm(a,b) << endl;

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
dp=[[0 for _ in range(2)] for _ in range(n+1)]
dp[0][1] = - 10**9
for i in range(n):
  dp[i+1][0]=max(dp[i][0]+a[i],dp[i][1]-a[i])
  dp[i+1][1]=max(dp[i][0]-a[i],dp[i][1]+a[i])
print(dp[n][0])

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

int main()
{
    int n, k;
    std::cin >> n >> k;
    std::string s;
    std::cin >> s;

    long long ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            ans++;
        }
    }

    ans = std::min(n - (long long)1, ans + 2 * k);

    std::cout << ans << std::endl;
}


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

int N, M;
vector<int> fact;

int32_t main() {
  cin >> N >> M;
  for(int i = 1; i * i <= M; i++) {
    if(M % i == 0) {
      fact.push_back(i);
      fact.push_back(M / i);
    }
  }
  sort(fact.begin(), fact.end());
  int l = 0, r = fact.size() - 1, ans = 0;
  while(l <= r) {
    int mid = (l + r) >> 1;
    if(fact[mid] > M / N) {
      r = mid - 1;
    }else {
      l = mid + 1;
      ans = mid;
    }
  }
  cout << fact[ans] << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] input = new int[M];
		for (int i = 0; i < M; i++) {
			input[i] = sc.nextInt();
		}
		int[] dp = new int[N + 1];
		dp[0] = 1;
		int pointer = 0;
		if (pointer < M && input[pointer] == 1) {
			dp[1] = 0;
			pointer++;
		} else {
			dp[1] = 1;
		}
		for (int i = 2; i <= N; i++) {
			if (pointer < M && input[pointer] == i) {
				dp[i] = 0;
				pointer++;
			} else {
				dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
			}
		}
		System.out.print(dp[N]);
	}
}


Measured memory_bytes: 50708
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        m: usize,
        a: [i64; n],
        bcs: [(i64, i64); m],
    }
    let mut a = a;
    let mut bcs = bcs;
    a.sort();
    bcs.sort_by_key(|bc| bc.1);
    let mut cnt: usize = 0;
    for bc in bcs.into_iter().rev() {
        let mut pp = 0;
        while pp < bc.0 as usize {
            if cnt + pp < n {
                if a[cnt + pp] < bc.1 {
                    a[cnt + pp] = bc.1;
                } else {
                    let s = a.iter().fold(0, |sum, item| sum+item);
                    println!("{}", s);
                    return;
                }
                pp+=1;
            } else {
                break;
            }
        }
        cnt += pp;
    }
    let s = a.into_iter().fold(0, |sum, item| sum+item);
    println!("{}", s);
}

Measured memory_bytes: 12408
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0
    prev = 0
    for a in A:
        if prev and a:
            a -= 1
            ans += 1
        ans += a // 2
        prev = a % 2
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 7072
n = int(input())
A = list(map(int, input().split()))

min = 10**9
for a in A:
  s = bin(a)
  for k in range(len(s)):
    if s[-k]=='1':
      temp_min = k-1
      break
  if temp_min < min:
    min = temp_min
    
print("{}".format(min))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int n,q,a,b,c,i,x[100010];
string s;
int main(){
  for(cin>>n>>q>>s,i=1;i<n;++i){
    x[i+1]=x[i];
    if(s[i-1]=='A'&&s[i]=='C')x[i+1]++;
  }
  for(i=0;i<q;++i){
    int a,b;cin>>a>>b;
    int r=x[b]-x[a];
    cout<<r<<endl;
  }
}

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

int main() {
	int N;
	cin >> N;
	int dif = 0;
	for (int i = 1; i <= N; i++) {
		int p;
		cin >> p;
		if (i != p) dif++;
	}
	cout << (dif == 0 || dif == 2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b, c, d;
    std::cin>>a>>b>>c>>d;

    int ans;
    if(b <= c){
        ans = 0;
    }else if(a <= c){
        if(b <= d){
            ans = b - c;
        }else{
            ans = d - c;
        }
    }else{
        if(b <= d){
            ans = b - a;
        }else if(a <= d){
            ans = d - a;
        }else{
            ans = 0;
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M,P;
  cin>>N>>M>>P;
  vector<ll> a(M),b(M),c(M),dist(N,INFLL);
  REP(i,M){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;c[i]=-c[i]+P;
  }

  dist[0]=0;

  REP(loop,N-1){
    REP(i,M){
      if(dist[a[i]]!=INFLL){
        dist[b[i]] = min(dist[b[i]],dist[a[i]]+c[i]);
      }
    }
  }

  ll ans=-dist[N-1];

  vector<bool> negative(N,false);

  REP(loop,N){
    REP(i,M){
      if(dist[a[i]]==INFLL)continue;
      if(dist[b[i]]>dist[a[i]]+c[i]){
        dist[b[i]]=dist[a[i]]+c[i];
        negative[b[i]]=true;
      }

      if(negative[a[i]]){
        negative[b[i]]=true;
      }
    }
  }

  if(negative[N-1]){
    cout<<-1<<endl;
  }else{
    cout<<max(ans,0ll)<<endl;
  }
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; } 
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, pair<T*, int> a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
#define LOG
#endif

const int N = 1005;
int n;
int x[N], y[N];

bool read() {
	if (!(cin >> n))
		return false;
	forn(i, n)
		assert(cin >> x[i] >> y[i]);
	return true;
}

void solve() {
	li minx = x[0], miny = y[0];
	fore(i, 1, n) {
		minx += (x[i] - minx % x[i]) % x[i];
		miny += (y[i] - miny % y[i]) % y[i];
		assert(minx % x[i] == 0);
		li tx = minx / x[i];
		assert(miny % y[i] == 0);
		li ty = miny / y[i];
		minx += max(0ll, ty - tx) * x[i];
		miny += max(0ll, tx - ty) * y[i];
	}
	cout << minx + miny << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif
    
    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		ld stime = gett();
		solve();
		cerr << "Time: " << gett() - stime << endl;
		//break;
	}
	
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
typedef long long ll;
using namespace std;
#define mul(a, b) (((i64)(a) * (b) ) % MOD)
#define sum(a, b) (((a) + (b) ) % MOD)

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

	#define endl '\n'

	#ifdef LOCAL_DEBUG
		freopen("data.in", "r", stdin );
	#endif
	int n, s; cin >> n >> s;
	vector<int> x(n);
	vector<ll> p(n);
	for(int i = 0; i < n; i++)cin >> x[i] >> p[i];
	vector<int> order;
	for(int i = 0, b = 0, e = n -1; i < n; i++){
		if(x[e] < s){
			for(int j = b; j <= e; j++)
				order.push_back(j);
			break;
		}
		if(x[b] > s){
			for(int j = e; j >= b; j--)
				order.push_back(j);
			break;
		}

		if(p[b] >= p[e]){
			order.push_back(e);
			p[b] += p[e];
			e--;
		}
		else{
			order.push_back(b);
			p[e] += p[b];
			b++;

		}

	}
	reverse(order.begin(), order.end());
	ll ans = 0;
	int cur = s;
	for(auto i : order){
		//cout << i << endl;
		int ip = x[i];
		ans += abs(cur - ip);
		cur = ip;
	}
	cout << ans << endl;


}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int x,y,z,n,ansn;
int main(){
	cin>>x>>y>>z>>n;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++)
			if (i*x+j*y<=n&&(n-i*x-j*y)%z==0) ansn++;
	cout<<ansn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll X,K,D,ans=INF;
  cin>>X>>K>>D;
  
  if(abs(X)/D<K){
    ll cnt=abs(X)/D;
    if((K-cnt)%2==0) chmin(ans,abs(abs(X)/D*D-abs(X)));
    else chmin(ans,abs((abs(X)/D+1)*D-abs(X)));
  }
  else{
    chmin(ans,abs(X)-K*D);
  }
  
  co(ans);
  return 0;
}

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

#define MAX_N (3000)
#define SIZE_BUF (30)
#define NUM_MOD (1000000007)

int dpss[MAX_N][MAX_N], acc_dpss[MAX_N][MAX_N + 1];

int mod(int n, int k) {
  const int num = n % k;
  return num >= 0 ? num : num + k;
}

int main() {
  // read inputs
  int N;
  char cs[MAX_N + 1], buf[SIZE_BUF];
  scanf("%d", &N);
  fgets(cs, SIZE_BUF, stdin);
  scanf("%s", cs);

  // solve dp
  // initialize
  for (int j = 0; j < N; j++) {
    dpss[N - 1][j] = j == 0;
  }
  acc_dpss[N - 1][0] = 0;
  for (int j = 0; j < N; j++) {
    acc_dpss[N - 1][j + 1] = mod(acc_dpss[N - 1][j] + dpss[N - 1][j], NUM_MOD);
  }
  // update
  for (int i = N - 2; i >= 0; i--) {
    const int c = cs[i];
    // calculate dpss[i][j]
    for (int j = 0; j <= N - (i + 1); j++) {
      if (c == '<') {
        dpss[i][j] = mod(acc_dpss[i + 1][j] - acc_dpss[i + 1][0], NUM_MOD);
      } else {
        dpss[i][j] =
            mod(acc_dpss[i + 1][N - (i + 1)] - acc_dpss[i + 1][j], NUM_MOD);
      }
    }
    // calculate dpss[i][j + 1]
    acc_dpss[i][0] = 0;
    for (int j = 0; j < N; j++) {
      acc_dpss[i][j + 1] = mod(acc_dpss[i][j] + dpss[i][j], NUM_MOD);
    }
  }
//   for (int i = 0; i < N; i++) {
//     printf("i = %d:", i);
//     for (int j = 0; j <= N - (i + 1); j++) {
//       printf(" %d", dpss[i][j]);
//     }
//     printf("\n");
//   }
  // obtain answer
  int ans = 0;
  for (int j = 0; j < N; j++) {
    ans = mod(ans + dpss[0][j], NUM_MOD);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
 
  fastio
  lli n,k,i,d,m;
  cin>>n>>k;
  lli a[n+1];
  a[0]=1;
  for(i=1;i<=n;i++)
    cin>>a[i];
  for(i=k+1;i<=n;i++)
  {
   
    if(a[i]>a[i-k])
    {
      cout<<"Yes\n";
    }
    else
      cout<<"No\n";
    d=m;
  }
  return 0;
}

Measured memory_bytes: 5220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    if ((n+1)/2 >= k) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
typedef struct book{
    string title,auth,date;
} bk;

vector<string> split(string s,char ch){
    vector<string> ret;
    string tmp ="";
    rep(i,s.size()){
        if(s[i]==ch){
            ret.pb(tmp);
            tmp = "";
        }else tmp+=s[i];
    }
    if(tmp.size())ret.pb(tmp);
    return ret;
}

//  aaa???bbb???????????? -> 1
//  aaa???bbb???????????? -> -1
//  aaa??¨bbb????????? -> 0
int comp(string aaa,string bbb){
    if(aaa==bbb)return 0;
    vector<string> a = split(aaa,'/');
    vector<string> b = split(bbb,'/');
    
    if(stoi(a[0])>stoi(b[0]))return -1;
    if(stoi(a[0])<stoi(b[0]))return 1;
    
    if(stoi(a[1])>stoi(b[1]))return -1;
    if(stoi(a[1])<stoi(b[1]))return 1;
    
    if(stoi(a[2])>stoi(b[2]))return -1;
    else return 1;
    
}


bool is(bk data,string title,string auth,string from,string to){
    if(title!="*" && data.title.find(title)==string::npos)return false;

    if(auth!="*" && data.auth.find(auth)==string::npos)return false;

    if(from!="*" && comp(from,data.date)==-1)return false;

    if(to!="*" && comp(to,data.date)==1)return false;

    return true;
}

int main(){
    
    int n;
    cin>>n;
    vector<bk> data;
    
    rep(i,n){
        string a,b,c;
        cin>>a>>b>>c;
        data.pb(bk{a,b,c});
    }
    
    int q;
    cin>>q;
    rep(i,q){
        string title,auth,from,to;
        cin>>title>>auth>>from>>to;
        
        vector<string> t;
        rep(j,n){
            if(is(data[j],title,auth,from,to))t.pb(data[j].title);
        }
        
        rep(i,t.size())cout<<t[i]<<endl;
        if(i!=q-1)cout<<endl;
    }
}

Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int N;
struct edge{int to;double cost;};
vector<edge> G[100010];
double D[100010];
void dijkstra(int S){
  priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> que;
  rep(i,N+2) D[i]=1001001001001001;
  D[S]=0;
  que.push(mp(0,S));
  while(!que.empty()){
    PII P=que.top();
    que.pop();
    int X=P.second;
    if(D[X]<P.first) continue;
    rep(i,G[X].size()){
      edge E=G[X][i];
      if(D[E.to]>D[X]+E.cost){
        D[E.to]=D[X]+E.cost;
        que.push(mp(D[E.to],E.to));
      }
    }
  }
}

int main(){
  int X,Y,Z,W;
  cin>>X>>Y>>Z>>W;
  cin>>N;
  vector<double> A(N),B(N),C(N);
  rep(i,N) cin>>A[i]>>B[i]>>C[i];
  A.pb(X);
  A.pb(Z);
  B.pb(Y);
  B.pb(W);
  C.pb(0);
  C.pb(0);
  rep(i,N+2) rep(j,N+2){
    if(i==j) continue;
    double dis=sqrt((A[i]-A[j])*(A[i]-A[j])+(B[i]-B[j])*(B[i]-B[j]));
    double tmp=max(0.0,dis-C[i]-C[j]);
    edge E={(int)j,tmp};
    G[i].pb(E);
  }
  dijkstra(N);
  cout<<setprecision(10)<<D[N+1]<<endl;
}

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

using namespace std;

const int MAX_N = 8, INDEX = 1;

int n, m, ans = 0;

bool isEdge[MAX_N + INDEX][MAX_N + INDEX];

int per[MAX_N + INDEX];

bool isUsed[MAX_N + INDEX];

bool isGood() {
    for (int i = 1; i < n; i++) {
        if (!isEdge[per[i]][per[i + 1]]) {
            return false;
        }
    }

    return true;
}

void getPermutation(int deep) {
    if (deep == n) {
        if (isGood()) {
            ans++;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (!isUsed[i]) {
            per[deep + 1] = i;

            isUsed[i] = true;

            getPermutation(deep + 1);

            isUsed[i] = false;
        }
    }
}

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

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;

        cin >> a >> b;

        isEdge[a][b] = true;
        isEdge[b][a] = true;
    }

    per[1] = 1;

    isUsed[1] = true;

    getPermutation(1);

    cout << ans << endl;

    return 0;
}


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

int main() {
int n, y;
cin >> n >> y;
y /= 1000;

for(int i = 0; i <= n;i++){
  for(int j =0; j <= n-i; j++){
    if(10*i + 5*j + (n-i-j)*1 == y){
      cout << i << ' ' << j << ' ' << n-i-j << endl;
      return 0;
    }
  }
}

  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.Function

is_prime :: Int -> Bool
is_prime 1 = False
is_prime 2 = True
is_prime num = try 2
    where 
        root = ceiling $ sqrt $ fromIntegral num
        try :: Int -> Bool
        try x
            | x > root         = True
            | (mod num x) == 0 = False
            | otherwise        = try $ x + 1

loop :: Int -> Int -> IO Int
loop 0 count = pure count
loop times count = do
    n <- read <$> getLine
    newCount <- pure $ if is_prime n
        then count + 1
        else count
    loop (times - 1) newCount

main = do
    times <- read <$> getLine
    count <- loop times 0
    print count



Measured memory_bytes: 10380
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, K, S, L[50];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d", &N, &K);
	for(int i = 0; i < N; i++) scanf("%d", &L[i]);
	sort(L, L + N);
	for(int i = N - 1; i > N - 1 - K; i--) S += L[i];
	printf("%d\n", S);
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll w, h, x, y;
  cin>>w>>h>>x>>y;
  
  double area = ((double)w*h)/2;
  if(w==2*x && h==2*y) cout<<area<<" "<<1<<endl;
  else cout<<area<<" "<<0<<endl;
}

Measured memory_bytes: 3780
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main.py
# Date: 2020/06/08
# Filename: main.py 
# Author: acto_mini

def main():
    n = int(input())
    a = list(map(int, input().split()))
    result = 0
    loop = True

    while True:
        for i, v in enumerate(a):
            if v % 2 == 1:
                loop = False
                break
            else:
                a[i] = v / 2
        if not loop: break
        result += 1

    print(result)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
typedef pair<int,int> pii;
typedef long long ll;
int not_prime[maxn];
vector<int> prime;

int main() {
    for(int i = 2;i < maxn;++i) {
        if(!not_prime[i]) prime.emplace_back(i);
        for(auto u : prime) {
            if(u * i >= maxn) break;
            not_prime[u * i] = 1;
        }
    }
    ll a, b;
    scanf("%lld%lld",&a, &b);
    ll g = __gcd(a, b);
    int ans = 0;
    for(auto u : prime) if(g % u == 0){
        ++ans;
        while(g % u == 0) g /= u;
    }
    if(g != 1) ++ans;
    printf("%d\n",ans + 1);
    return 0;
}


Measured memory_bytes: 4860
function Main(input) {
  input = input.split("\n");
  N = parseInt(input[0].split(" ")[0]);
  A = new Array(N+1);
  A[0]=0;
  tmp = input[1].split(" ");
  var sum=0;
  skip=new Array(N);
  noskip=new Array(N);
  for(i=1;i<=N;i++){
    A[i]=parseInt(tmp[i-1]);
    sum+=Math.abs(A[i]-A[i-1]);
    if(i!=N){
      skip[i-1]=Math.abs(parseInt(tmp[i])-A[i-1]);
      noskip[i-1]=Math.abs(A[i]-A[i-1])+Math.abs(parseInt(tmp[i])-A[i]);
    }else{
      skip[i-1]=Math.abs(0-A[i-1]);
      noskip[i-1]=Math.abs(A[i]-A[i-1])+Math.abs(0-A[i]);
    }
  }
  sum+=Math.abs(A[N]);
  ans=new Array(N);
  for(i=0;i<N;i++){
    ans[i]=sum-noskip[i]+skip[i];
  }
  var ans2=ans.join("\n");

  console.log('%s', ans2);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35264
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, Q = map(int, rl().split())
    
    left = top = N
    row, col = [N] * (N + 1), [N] * (N + 1)
    
    ans = (N - 2) ** 2
    for _ in range(Q):
        com, x = map(int, rl().split())
        if com == 1:
            if x < left:
                for i in range(x, left):
                    col[i] = top
                left = x
            ans -= col[x] - 2
        else:
            if x < top:
                for i in range(x, top):
                    row[i] = left
                top = x
            ans -= row[x] - 2
    print(ans)


if __name__ == '__main__':
    solve()


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

long long pow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res*a;
        a = a*a;
        n >>= 1;
    }
    return res;
}

int main() {
  int n,p,o = 0,d = 0;
  ll ans = 1;
  cin >> n >> p;
  rep(i,n){
    int a;
    cin >> a;
    if(a%2 == 0) d++;
    else o++;
  }
  if(d != 0) ans *= pow(2,d);
  if(p == 0){
    if(o > 1) ans *= pow(2,o-1);
  }
  else{
    if(o == 0) ans *= 0;
    else ans *= pow(2,o-1);
  }
  cout << ans << endl;
}

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

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

    if (K % 2 == 0) {
        // こっちは簡単
        // K / 2に降りて、後は左の子を辿り続ける
        cout << K / 2 << " ";
        for (int i = 0; i < N - 1; ++i) {
            cout << K << " ";
        }
        cout << endl;
    } else {
        vector<int> ans(N, (K + 1) / 2);

        // N / 2だけ手前にずらす
        for (int i = 0; i < N / 2; ++i) {
            if (ans.back() == 1) {
                ans.pop_back();
            } else {
                --ans.back();
                while (ans.size() < N) {
                    ans.push_back(K);
                }
            }
        }

        for (int v : ans) {
            cout << v << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
x, n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))
for i in range(100):
  if not x-i in p:
    print(x-i)
    break
  elif not x+i in p:
    print(x+i)
    break

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  string s;
  cin>>s;
  s[3]='8';
  cout<<s;
return 0;
}

Measured memory_bytes: 3592
class Dice():
  def __init__ (self):
    # 1:ue 2:syomen 3:migi 4:hidari 5:oku 6:shita
    self.position = [0,0,0,0,0,0]
  
  def setNumber (self, num):
    for i,x in enumerate(num):
      self.position[i] = x
    #print(self.position)
      
  def roll(self, roll):
    for i in range(len(roll)):
      s = roll[i:i+1]
      p = self.position
      if s == 'E':
        self.setNumber([p[3], p[1], p[0], p[5], p[4], p[2]])
        #self.position = [p[4], p[2], p[1], p[6], p[5], p[3]]
      elif s == 'W':
        self.setNumber([p[2], p[1], p[5], p[0], p[4], p[3]])
        #self.position = [p[3], p[2], p[6], p[1], p[5], p[4]]
      elif s == 'S':
        self.setNumber([p[4], p[0], p[2], p[3], p[5], p[1]])
        #self.position = [p[5], p[1], p[3], p[4], p[6], p[2]]
      elif s == 'N':
        self.setNumber([p[1], p[5], p[2], p[3], p[0], p[4]])
        #self.position = [p[2], p[6], p[3], p[4], p[1], p[5]]

  def printTop(self):
    print(self.position[0])

d = Dice()

n = list(int(x) for x in input().split())
d.setNumber(n)

r = str(input())

d.roll(r)

d.printTop()


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;
 
typedef ostringstream OSS;
typedef istringstream ISS;
 
typedef vector<int> VI;
typedef vector< VI > VVI;
 
typedef long long LL;
 
typedef pair<int, int> PII;
typedef vector<PII> VPII;
 
#define X first
#define Y second
 
int main(void) {
	int N;
	cin >> N;
	VI xs(N);
	for (auto &x : xs) cin >> x;

	vector<vector<LL>> dp(N + 1, vector<LL>(21, 0));
	dp[1][xs[0]] = 1;

	for (int i = 1; i <= N - 2; i++) {
		for (int j = 0; j <= 20; j++) {
			if (!dp[i][j]) continue;

			VI ns({ j - xs[i], j + xs[i] });

			for (int k = 0; k < 2; k++) {
				if (ns[k] < 0 || 20 < ns[k]) continue;
				dp[i + 1][ns[k]] += dp[i][j];	
			}
		}
	}

	cout << dp[N - 1][xs[N - 1]] << endl;
}

Measured memory_bytes: 1232
import java.util.*;
 public class Main {
 	public static void main(String[] args){
 		Scanner sc = new Scanner(System.in);
 		// 整数の入力
 		int a = sc.nextInt();
 		int b = sc.nextInt();
 		// 出力
        if(a > 9 || b > 9)
          	System.out.println("-1");
        else
	 		System.out.println(a * b);
 	}
 }


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

int main() {
	int k, x; scanf("%d%d", &k, &x);
	
	printf("%s\n", (k * 500 >= x ? "Yes" : "No"));
	return 0;
}


Measured memory_bytes: 256
a = gets.gsub(/[a\n]/, '').chars
b = gets.gsub(/[b\n]/, '').chars
c = gets.gsub(/[c\n]/, '').chars
cards = { 'a' => a, 'b' => b, 'c' => c }
player = 'a'
while cards[player].length > 0
  player = cards[player].shift
end
puts ({ 'a' => 'A', 'b' => 'B', 'c' => 'C' })[player]


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
#define N 30
#define INF 100000

struct road{int to,cost,lim;};
struct situ{int v,now,from;double d;};
bool operator < (const situ &a,const situ &b){
	return a.d > b.d;
}

int main(){
	while(1){
		int n,m,s,g;
		vector<road> roads[N];
		cin >> n >> m;
		if(!n&&!m) break;
		cin >> s >> g;
		s--;g--;

		for(int i=0;i<m;i++){
			int x,y,d,c;
			scanf("%d%d%d%d",&x,&y,&d,&c);
			x--;y--;
			roads[x].push_back((road){y,d,c});
			roads[y].push_back((road){x,d,c});
		}

		priority_queue<situ> que;
		for(int i=0;i<roads[s].size();i++){
			int to = roads[s][i].to;
			int d = roads[s][i].cost;
			que.push((situ){1,to,s,(double)d});
		}
		bool used[N][N][31];
		memset(used,0,sizeof(used));

		bool isClear = false;
		while(que.size()){
			situ st = que.top(); que.pop();
			if(used[st.now][st.from][st.v]) continue;
			used[st.now][st.from][st.v] = true;
			if(st.now==g&&st.v==1){
				printf("%.5f\n",st.d);
				isClear = true;
				break;
			}
			for(int i=0;i<roads[st.now].size();i++){
				int to = roads[st.now][i].to;
				int d = roads[st.now][i].cost;
				if(to == st.from) continue;
				for(int j=-1;j<=1;j++){
					if(st.v+j<=roads[st.now][i].lim&&st.v+j>0){
						//if(!used[to][st.now][st.v+j])
							que.push((situ){st.v+j,to,st.now,st.d+(double)d/(st.v+j)});
					}
				}
			}
		}
		if(!isClear) cout << "unreachable" << endl;


	}
	return 0;

}

Measured memory_bytes: 20664
from collections import defaultdict
from itertools import accumulate

def main():
    N, C = map(int, input().split())
    programs = defaultdict(list)

    for _ in range(N):
        s,t,c = map(int, input().split())
        programs[c].append((s,t))

    imos = [0] * (10**5 + 1)
    for c, p in programs.items():
        p.sort()
        # チャンネルごとに連結処理を行う
        ps, pt = p[0]
        for s, t in p[1:]:
            if pt == s:
                pt = t
            else:
                imos[ps - 1] += 1
                imos[pt] -= 1
                ps, pt = s, t

        imos[ps - 1] += 1
        imos[pt] -= 1

    print(max(accumulate(imos)))

main()

Measured memory_bytes: 56920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		sc.nextLine();
		int[] n = new int[4];
		n[0] = 0;
		n[1] = 0;
		n[2] = 0;
		n[3] = 0;
		String StringLine = sc.nextLine();
		StringLine=StringLine.replace(" ", "");
		char[] array = StringLine.toCharArray();
		for (int i = 0; i < num; i++) {
			switch (array[i]) {
			case 'P':
				n[0]++;
				break;
			case 'W':
				n[1]++;
				break;
			case 'G':
				n[2]++;
				break;
			case 'Y':
				n[3]++;
				break;
			}
		}
		int rc = 0;
		for (int i = 0; i < 4; i++) {
			if (n[i] == 0) {
				rc++;
			}
		}

		switch (rc) {
		case 0:
			System.out.println("Four");
			break;
		case 1:
			System.out.println("Three");
			break;
		case 2:
			System.out.println("Two");
			break;
		case 3:
			System.out.println("One");
			break;
		}
	}

}


Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
map<long long int, int> mp;
long long int rem[100100];
int cnt;
int main(){
    int n,x;
    scanf("%d",&n);
    for(int i = 1; i <= n; i ++){
        scanf("%d",&x);
        if(!mp[x])
            rem[++cnt] = x;
        mp[x] ++;
    }
    long long int a = 0, ans = 0;
    sort(rem+1, rem+1+cnt);
    for(int i = cnt; i >= 1; i --){
        if(mp[rem[i]] > 1 && a){
            ans = rem[i] * a;
            break;
        }
        else if(mp[rem[i]] >= 4){
            ans = rem[i] * rem[i];
            break;
        }
        
        else if(mp[rem[i]] > 1){
            a = rem[i];
            continue;
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>

int32_t calc_gcd(int32_t a, int32_t b){
    if(b == 0) return a;
    return calc_gcd(b, a%b);
}

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

    int64_t N, X;
    std::cin >> N >> X;
    std::vector<int32_t> x(N+1);

    for(int32_t i = 0; i < N; i++){
        std::cin >> x[i];
    }
    x[N] = X;

    //xlogx
    std::sort(x.begin(), x.end());

    //x
    std::vector<int32_t> diffs(N);
    for(int32_t i = 0; i < N; i++){
        diffs[i] = x[i+1] - x[i];
    }

    //xlogx
    int32_t gcd = diffs[0];
    for(int32_t i = 0; i < N; i++){
        gcd = std::min(gcd, calc_gcd(gcd, diffs[i]));
    }

    std::cout << gcd << std::endl;
    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;


//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 3000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll r1, c1, r2, c2;std::cin >> r1 >> c1 >> r2 >> c2;
  init();
  ll ans = 0;
  for(int i=1;i<=r2+1;i++) ans = (ans + comb(c2+i, i))%P;
  for(int i=1;i<=r1;i++) ans = (ans - comb(c2+i, i)+P+P)%P;
  for(int i=1;i<=c1;i++) ans = (ans - comb(r2+i, i)+P+P)%P;
  for(int i=1;i<=r1;i++) ans = (ans + comb(c1-1+i, i))%P;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 70528
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b>>1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	ll M = 1e18;

	repn(i, N) {
		if (A[i] == 0) { cout << 0 << endl; return 0; }
	}

	ll ans = 1;
	repn(i, N) {
		if (ans > M / A[i]) { cout << -1 << endl; return 0; }
		ans *= A[i];
	}

	cout << ans << endl;
}


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

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

const long long INF = 1LL << 60;

int main ()
{
    int h,a;
    cin >> h >> a;
    if(h%a!=0)
    cout << h/a+1 << endl;
    else
    {
        cout << h/a << endl;
    }
    
}


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

int N,K;

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&K);
	if(N%K==0)puts("0");
	else puts("1");
	return 0;
}

Measured memory_bytes: 128
MOD = 10**9+7
factorial = [1]
inverse_factorial = [0]


def modpow(a, p):
    ans = 1
    while p:
        if p&1 == 1:
            ans = (ans*a)%MOD
        a = (a*a)%MOD
        p >>= 1
    return ans


def nCr(n, r):
    if r == 0 or r == n:
        return 1
    return (((factorial[n]*inverse_factorial[n-r])%MOD)*inverse_factorial[r])%MOD


def init_nCr(max_n):
    for i in range(1, max_n+1):
        f = (factorial[-1]*i)%MOD
        factorial.append(f)
        inv_f = modpow(f, MOD-2)
        inverse_factorial.append(inv_f)


def pow(b, p):
    ans = 1
    for _ in range(p):
        ans = (ans*b)%MOD
    return ans


def pow_list(b, p):
    ans = [1]
    for _ in range(p):
        ans.append((ans[-1]*b)%MOD)
    return ans


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    K = read_int()
    S = len(input().strip())
    init_nCr(K+S)
    T = pow(26, K+S)
    pow_25 = pow_list(25, K+S)
    for i in range(S):
        T = (T-(nCr(K+S, i)*pow_25[K+S-i])%MOD)%MOD
    return T


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 228832
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll x[50], y[50], xs[50], ys[50];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  for( int i=0; i<N; i++ ){
    cin >> x[i] >> y[i];
    xs[i] = x[i];
    ys[i] = y[i];
  }
  sort( xs, xs + N );
  sort( ys, ys + N );

  ll ret = 1LL << 62;
  for( int xi=0; xi<N; xi++ ){
    for( int xj=xi+1; xj<N; xj++ ){
      for( int yi=0; yi<N; yi++ ){
        for( int yj=yi+1; yj<N; yj++ ){
          ll xl = xs[xi];
          ll xr = xs[xj];
          ll yl = ys[yi];
          ll yr = ys[yj];
          ll s = ( xr - xl ) * ( yr - yl );
          if( s >= ret ) continue;
          int c = 0;
          for( int k=0; k<N; k++ ){
            if( xl <= x[k] && x[k] <= xr && yl <= y[k] && y[k] <= yr )
              c++;
          }
          if( c >= K ) ret = s;
        }
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    total = c
    for j in range(m):
        total += A[i][j] * B[j]
    if total > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064