akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int sum[200010];
vector<vector<int>> v;

int main(void){
    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;
    sum[0]=0;
    for(int i=0; i<N; ++i){
        sum[i+1]=sum[i];
        if(S[i]=='o'){
            sum[i+1]=sum[max(0, i-C)]+1;
        }
    }
    if(sum[N]>K){
        return 0;
    }
    v.resize(K+1);
    int mx=N+C+100, now=K+1;
    for(int i=N; i>0; --i){
        if(S[i-1]=='o'){
            if(sum[i]==now){
                v[now].emplace_back(i);
            }
            else if(i+C<mx){
                --now;
                v[now].emplace_back(i);
                mx=i;
            }
        }
    }
    for(int i=1; i<=K; ++i){
        if(v[i].size()==1){
            cout << v[i][0] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 13444
N = int(input())
a = list(map(int, input().split()))
color = 0
num = 1
count = 0
for i in range(N):
    if a[i] == color:
        num += 1
    else:
        color = a[i]
        if num >= 2:
            count += num // 2
            num = 1
    if i == N - 1:
        if num >= 2:
            count += num // 2
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>

int main(){
    int N;
    int mul = 1;
    int a_i;
    int count = 0;
    std::cin >> N;
    for(int i=1;i<N+1;i++){
      std::cin >> a_i;
    while(a_i%2==0){
      count++;
      a_i=a_i/2;
    }
  }
    std::cout << count;
}


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

int main(){
    ll n,ans;
    cin >> n;
    ll seat[10][10];
    rep(i,10){
        rep(j,10){
            seat[i][j] = 0;
        }
    }
    for(int i = 1;i<=n;i++){
        ll min = i % 10;
        ll v = static_cast<ll>(log10(i));
        ll max = i / pow(10,v);
        seat[min][max]++;
    }
    rep(i,10){
        rep(j,10){
            ans += seat[i][j] * seat[j][i];
        }
    }

    cout << ans;
    return 0;
}


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

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;
const ll MOD = 1000000007;

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

  ll a = 1;
  ll b = 1;
  ll c = 1;
  rep(i, n){
    a *= 10;
    b *= 8;
    c *= 9;
    a %= MOD;
    b %= MOD;
    c %= MOD;
  }

  ll ans = a + b - 2*c;
  ans %= MOD;
  if(ans < 0) ans += MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);
#define forto(x,a,b) for(int x=a; x<=b; ++x)
#define fordo(x,a,b) for(int x=a; x>=b; --x)

using ll = long long;
using namespace std;
using ld = long double;
const int MAXSUM = 2500;
ll dp [MAXSUM+1];


int main()
{
#ifndef RICARDO
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    string a[3];
    cin >> a[0];
    cin >> a[1];
    cin >> a[2];
    int place = 0;
    while (true)
    {
        if (a[place].empty()) break;
        char t= a[place][0];
        a[place].erase(a[place].begin());
        place=t - 'a';
    }
    cout << char(place+'A');
    return 0;
}



Measured memory_bytes: 764
#include<iostream>
#define MAX 100005
using namespace std;

long long h[MAX];

bool terminatable(int n,long long a,long long b,long long c) {
	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		long long x = h[i];
		x -= b*c;
		if(x > 0){
			int dividable=1;
			if (x % (a - b) == 0) { dividable = 0; }
			cnt += x / (a - b) +dividable;
		}
	}
	return (cnt <= c);
}

int main() {
	int n;long long a, b;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	long long l, r, mid;
	l = 0; r = 1000000003;
	while (r - l > 1) {
		mid = (l + r) / 2;
		if (terminatable(n, a,b,mid)) {
			r = mid;
		}
		else { l = mid; }
	}
	cout << l + 1 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

void p1()
{
	cout<<"First\n";
	exit(0);
}

void p2()
{
	cout<<"Second\n";
	exit(0);
}

int a[100001];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int sum = 0;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
		sum+=(a[i]&1);
		sum%=2;
	}
	int n2 = n%2;
	if(n==1)
	{
		if(sum==n2) p2();
		else p1();
		return 0;
	}
	if(sum!=n2)
	{
		p1();
		return 0;
	}
	int turn = 1;
	while(1)
	{
		int cntodd = 0;
		int ex1 = 0;
		int sm = 0;
		int oddidx=0;
		for(int i = 0; i < n; i++)
		{
			if(a[i]&1) 
			{
				cntodd++;
				oddidx=i;
			}
			if(a[i]==1) ex1++;
			sm+=(a[i]&1);
			sm%=2;
		}
		if(sm!=n2&&!turn)
		{
			p2();
			return 0;
		}
		if(sm!=n2&&turn)
		{
			p1();
			return 0;
		}
		if(ex1>0||cntodd>1)
		{
			if(sm!=n2) 
			{
				if(turn) p1();
				else p2();
			}
			else 
			{
				if(!turn) p1();
				else p2();
			}
			return 0;
		}
		a[oddidx]--;
		int gcd = a[0];
		for(int i = 0; i < n; i++)
		{
			gcd=__gcd(a[i],gcd);
		}
		assert(gcd>1);
		for(int i = 0; i < n; i++)
		{
			a[i]/=gcd;
		}
		turn^=1;
	}
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define F first
#define S second


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-2*b);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()



bool is_parindrome(string T)
{
	string S = T;
	reverse(all(T));
	return S == T;
}

int problemC()
{
	string S;
	cin >> S;

	if (is_parindrome(S)) {
		cout << 0 << endl;
		return 0;
	}

	string T; // without x
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'x') continue;
		T.push_back(S[i]);
	}

	if (!is_parindrome(T)) {
		cout << -1 << endl;
		return 0;
	}

	vector<int> xlen;
	int count = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'x') {
			count++;
		}
		else {
			xlen.push_back(count);
			count = 0;
		}
	}
	xlen.push_back(count);

	int ans = 0;
	for (int i = 0; i < xlen.size() / 2; i++)
		ans += abs(xlen[i] - xlen[xlen.size() - 1 - i]);

	cout << ans << endl;

	return 0;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	problemC();

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	string s,t;
	cin>>s>>t;
	int dp[sz(s)+1][sz(t)+1];
	for(int i=0;i<=sz(s);i++)
		for(int j=0;j<=sz(t);j++)
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	int i=sz(s),j=sz(t);
	string ans;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans+=s[i-1];
			i--,j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	reverse(all(ans));
	cout<<ans;
}


Measured memory_bytes: 38824
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
struct edge {
    int to;
    int cap;
    int rev;
};

vector <edge> edges[100];
int level[100];
int iter[100];

void add_edge(int from, int to, int cap){
    edges[from].push_back((edge){to, cap, (int) edges[to].size()});
    edges[to].push_back((edge) {from, 0, (int) edges[from].size() - 1});
}

void bfs(int s){
    memset(level, -1, sizeof(level));
    queue <int> q;
    level[s] = 0;
    q.push(s);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i = 0; i < edges[v].size(); i++){
            edge &e = edges[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                q.push(e.to);
            }
        }
    }
}

int dfs(int v, int t, int f){
    if(v == t){
        return f;
    }

    for(int &i = iter[v]; i < edges[v].size(); i++){
        edge &e = edges[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                edges[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int dinic(int s, int t){
    int flow = 0;
    while(true){
        bfs(s);
        if(level[t] < 0){
            return flow;
        }
        memset(iter, 0, sizeof(iter));
        while(true){
            int f = dfs(s, t, INT_MAX);
            if(f <= 0){
                break;
            }
            flow += f;
        }
    }
    return 0;
}

int main(void){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int u;
        int v;
        int c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }
    cout << dinic(0, N - 1) << endl;
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
	int a,b;
	cin>>a>>b;
	int cnt=0;
	int now=1;
	while(now<b){
		now+=a-1;
		cnt++;
		if(now>=b){
			break;
		}
	}
	cout<<cnt<<endl;
}


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

int main(void) {
  long long N, A, B;
  cin >> N >> A >> B;
  long long ans = 0;
  ans += N / (A + B) * A;
  ans += min(N % (A + B), A);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Z=0;
	    int pri[]=new int[205];
	    pri[0]=300000;
	    pri[1]=200000;
	    pri[2]=100000;
	    for(int i=3;i<205;i++){
	        pri[i]=0;
	    }
	    int X = sc.nextInt();
		int Y = sc.nextInt();
	    for(int i=0;i<205;i++){
	        if(i+1==X)Z+=pri[i];
	    }
	    for(int j=0;j<205;j++){
	        if(j+1==Y)Z+=pri[j];
	    }
	    if(X==1&&Y==1){
	        Z+=400000;
	    }
	    System.out.println(Z);

	}

}


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

using namespace std;

int main() {
    string S;
    cin >> S;
    for (auto e : S) {
        if (e == 'A') cout << "T";
        if (e == 'T') cout << "A";
        if (e == 'C') cout << "G";
        if (e == 'G') cout << "C";
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int a,b;

scanf( "%d %d" , &a, &b );

 if(a < b) {
printf("a < b\n");
}
if(a > b) {
printf("a > b\n");
}
else if (a == b) {
printf("a == b\n");
} 
return 0;
}

Measured memory_bytes: 1756
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,n,c,d;
    cin>>n;
    ll b[n],ans[n],o=n-1;
    for (ll i=0; i<n; i++) {
        cin>>b[i];
    }
    for (ll i=n; i>0; i--) {
        a=0;
        c=b[i-1];
        for (ll j=i-1; j>=0; j--) {
            if (c==j+1) {
                ans[o]=c;
                o--;
                a++;
                break;
            }
            d=c;
            c=b[j-1];
            b[j-1]=d;
        }
        if (a==0) {
            break;
        }
    }
    if (a==0) {
        cout<<-1<<endl;
    }
    else{
        for (ll i=0; i<n; i++) {
            cout<<ans[i]<<endl;
        }
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int a[100100];
ll dp[110][100100];

int main(void){
	int n,k,i,j;
	fill(dp[0],dp[110],0ll);
	dp[0][0] = 1ll;
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<n; ++i){
		for(j=1; j<=k; ++j){
			add_mod(dp[i][j],dp[i][j-1]);
		}
		for(j=0; j<=k; ++j){
			dp[i+1][j] = ((dp[i][j]+(MOD-((j>a[i])?dp[i][j-a[i]-1]:0ll))))%MOD;
		}
	}
	cout << (dp[n][k]) << endl;
	return 0;
}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int stones[n];
    for (int i = 0; i < n; i++)
    {
        cin >> stones[i];
    }

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + k; j++)
        {
            if (j < n)
            {
                dp[j] = min(dp[j], dp[i] + abs(stones[i] - stones[j]));
            }
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 4000
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n;
    cin>>n;
    lvec a(n),b(2,0);
    rep(i,n){
        cin>>a[i];
        if(a[i]%2!=0) b[0]++;
        else if(a[i]%4==0) b[1]++;
    }
    if(b[1]+b[0]==n){
        if(b[1]-b[0]>=-1) cout<<"Yes";
        else cout<<"No";
    }else{
        if(b[1]-b[0]>=0) cout<<"Yes";
        else cout<<"No";
    }
}

Measured memory_bytes: 1024
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s,t;
	cin >> s;
	t = s;
	reverse(t.begin(),t.end());
	if(s == t) Yes();
	else No();
	return 0;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main() {

  int n;
  double h;

  int dist[6];


  cin >> n;

  for(int i=0;i<6;i++) dist[i]=0;

  for(int i=0;i<n;i++) {

    cin >> h;

    if(h<165.0) dist[0]++;

    else if(h<170.0) dist[1]++;

    else if(h<175.0) dist[2]++;

    else if(h<180.0) dist[3]++;

    else if(h<185.0) dist[4]++;

    else dist[5]++;

  }

  for(int i=0;i<6;i++) {

    cout << i+1 << ":";

    for(int j=0;j<dist[i];j++) cout << "*";

    cout << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include <iostream>

using namespace std;


int main()
{
    

    int K;
    int S;

    cin >> K >> S;

    int count=0;

    for(int x= 0;x<=K;x++){
        for(int y = 0;y<=K;y++){

            if (S-x-y <= K && S-x-y>=0){
                count++;
            }
        }
    }
    cout << count <<endl;
    return 0;
}

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

int main() {
	int P, Q, R;
	int a, b, c;
	cin >> P >> Q >> R;

	a = P + Q;
	b = P + R;
	c = Q + R;
	if(a <= min(b,c)) {
		cout << a << endl;
	} else if(b < min(a,c)) {
		cout << b << endl;
	} else {
		cout << c << endl;
	}
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int[] num = new int[5];
		for(int i=0; i<num.length; i++) {
			num[i] = in.nextInt();
		}

		for(int i=0; i<num.length; i++) {
			if(num[i] != i+1) {
				System.out.println(i+1);
				break;
			}
		}
	}

}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);}

void Main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = INF;
    REP(i, 100000+1) {
        int tmp = 0;
        tmp += i * 2 * c;
        tmp += a * max(x - i, 0);
        tmp += b * max(y - i, 0);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int a,b;
	std::cin >> a>>b;
	if((a*b)%2==0){
		std::cout << "Even" << std::endl;
	}else std::cout << "Odd" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll n,m;
ll fac(int x)
{
    ll ans=1;
    for(int i=2;i<=x;++i)
        ans=ans*i%mod;
    return ans;
}
int main()
{
    cin>>n>>m;
    if(n<m) swap(n,m);
    ll ans;
    if(n==m)
        ans=2LL*fac(n)%mod*fac(n)%mod;
    else if(n==m+1)
        ans=fac(n)*fac(m)%mod;
    else ans=0;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int low = max(a, c);
  int up = min(b, d)  ;
  cout << max(0, up-low) << endl;

  return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Constraint {
  int l, r, x;
};

template<typename T>
vector<vector<vector<T>>>
Make3DVector(int d1, int d2, int d3, T default_value) {
  return vector<vector<vector<T>>>(
      d1, vector<vector<T>>(d2, vector<T>(d3, default_value)));
}

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

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

  int n, m;
  cin >> n >> m;
  vector<vector<Constraint>> r_to_cs(n);
  for (int i = 0; i < m; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    l--;
    r--;
    r_to_cs[r].push_back(Constraint({l, r, x}));
  }

  auto dp = Make3DVector(n, n, n, FiniteField(0));
  dp[0][0][0] = 3;
  for (const auto& c : r_to_cs[0]) {
    if (c.x != 1) {
      dp[0][0][0] = 0;
    }
  }

  for (int i = 0; i < n - 1; i++) {
    for (int k1 = 0; k1 <= i; k1++) {
      for (int k2 = 0; k2 <= k1; k2++) {
        auto d = dp[i][k1][k2];
        if (d.Value() == 0) continue;
        dp[i + 1][k1][k2] += d;
        dp[i + 1][i + 1][k2] += d;
        dp[i + 1][i + 1][k1] += d;
      }
    }

    for (const auto& c : r_to_cs[i + 1]) {
      for (int k1 = 0; k1 <= i + 1; k1++) {
        for (int k2 = 0; k2 <= k1; k2++) {
          if (c.x == 1) {
            if (c.l < k1) {
              dp[i + 1][k1][k2] = 0;
            }
          } else if (c.x == 2) {
            if (c.l < k2 || c.l >= k1) {
              dp[i + 1][k1][k2] = 0;
            }
          } else if (c.x == 3) {
            if (c.l >= k2) {
              dp[i + 1][k1][k2] = 0;
            }
          }
        }
      }
    }
  }

  FiniteField ans = 0;
  for (int k1 = 0; k1 <= n - 1; k1++) {
    for (int k2 = 0; k2 <= k1; k2++) {
      ans += dp[n - 1][k1][k2];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 215424
#include<iostream>
#include<string>
#include<stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int red = 0, blue = 0;
	rep(i, n) {
		if (s.at(i) == 'R') red++;
		else blue++;
	}
	if (red > blue) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

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

count_A = Counter(As)
max_A = max(As)
min_A = min(As)

ans = False
if max_A % 2 == 0:
    if max_A // 2 == min_A and count_A[min_A] == 1:
        for A in range(min_A + 1, max_A + 1):
            if count_A[A] < 2:
                break
        else:
            ans = True
else:
    if max_A // 2 + 1 == min_A and count_A[min_A] == 2:
        for A in range(min_A + 1, max_A + 1):
            if count_A[A] < 2:
                break
        else:
            ans = True

if ans:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 65172
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());

    queue<ll> que;
    rep(i, n) {
        ll t = a[i];
        int b = 0;
        while(t == a[i]) {
            ++b;
            ++i;
        }
        if (b >= 4 && (int)que.size() == 0) {
            cout << t * t << endl;
            return 0;
        }
        if (b >= 2) que.push(t);
        --i;
        if ((int)que.size() >= 2) break;
    }

    if ((int)que.size() <= 1) {
        cout << 0 << endl;
        return 0;
    }
    
    ll edge1 = que.front();
    que.pop();
    ll edge2 = que.front();

    cout << edge1 * edge2 << endl;

    return 0;
}

Measured memory_bytes: 1024
def isOK(X, index, aim, mode):
    if mode==1:
        if X[index] < aim:
            return True
        else:
            return False
    else:
        if X[index] > aim:
            return True
        else:
            return False

def bs(X, aim, mode):
    left=-1
    right=len(X)

    while right-left>1:
        mid = left + int((right-left)/2)
        if mode == 1:
            if isOK(X, mid, aim, mode):
                left=mid
            else:
                right=mid
        else:
            if isOK(X, mid, aim, mode):
                right=mid
            else:
                left=mid
    if mode==1:
        return left
    else:
        return right

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for j in range(N):
    piva=bs(A, B[j], 1)
    pivc=bs(C, B[j], 2)
    ans+=(piva+1)*(len(C)-pivc)
print(str(ans))

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll m=-1, r=INF;
  rep(i, n) {
    cin >> a[i];
    chmax(m, a[i]);
  }
  sort(all(a));
  long double c = m / 2.0,d = INF;
  rep(i, n-1) {
    if (abs(c-a[i])<d){
      d=abs(c-a[i]);
      r = a[i];
    }
  }
  cout << m << " " << r << endl;

  return 0;
}

Measured memory_bytes: 1024
n = int(input())
l = sorted(list(map(int, input().split())))

ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1,n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i] and l[i]+l[j] > l[k] and l[j]+l[k] > l[i] and l[k]+l[i] > l[j]:
                ans += 1

print(ans)

Measured memory_bytes: 9196
/**
 *    Author:   Jay Sabale
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira;

    lli n; cin>>n;
    lli arr[n];
    map <lli, lli> mm;
    forz(i,n-1) 
    {
        cin>>arr[i];
        mm[arr[i]]++;
    }

    for(lli i=1; i<=n; i++)
    cout<<mm[i]<<endl;

    return 0;
}




















































Measured memory_bytes: 17680
#include <stdio.h>

int main()
{
  int month, date;
  int n;
  int i;
  int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  char *weeks[7] = {
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
  };
 
  while (1) {
    scanf("%d %d", &month, &date);

    if (month == 0)
      break;

    n = 0;

    for (i = 0; i < month - 1; i++)
      n += day[i];

    printf ("%s\n", weeks[(n + date - 1) % 7]);
  }

  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,x,m;
int l[11],r[11],s[11];

bool flag=false;
int ans[7];
int tmp[7];

void dfs(int v){
	if(v==n){
		bool ok=true;
		for(int i=0;i<m;i++){
			int val=0;
			for(int j=l[i];j<=r[i];j++){
				val+=tmp[j];
			}
			if(val!=s[i])ok=false;
		}

		if(!ok)return;
		int sum=0;
		flag=true;
		for(int i=0;i<n;i++){
			sum+=tmp[i]-ans[i];
		}
		if(sum>0){
			for(int i=0;i<n;i++){
				ans[i]=tmp[i];
			}
		}
	}else{
		for(int i=0;i<=x;i++){
			tmp[v]=i;
			dfs(v+1);
		}
	}
}

int main(void){
	scanf("%d%d%d",&n,&x,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&l[i],&r[i],&s[i]);
		l[i]--;
		r[i]--;
	}
	dfs(0);
	if(!flag){
		printf("-1\n");
	}else{
		for(int i=0;i<n;i++){
			printf("%d%c",ans[i],i+1==n?'\n':' ');
		}
	}
	return 0;
}


Measured memory_bytes: 3192
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n)           REPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
typedef unsigned long long ull;

int main(){
    int n;
    cin >> n;       // 10^4
    REP(i,n){
        int h, m; char c;
        cin >> h >> c >> m;   // hh:mm

        int th1 = 3600/12*h + 300/60*m;
        int th2 = 3600/60*m;
        int th_diff = abs(th1-th2);
        if(th_diff > 1800) th_diff = 3600-th_diff;
        //printf("th1 = %d, th2 = %d\n", th1, th2);
        if(th_diff < 300){
            cout << "alert" << endl;
        } else if(th_diff >= 900){
            cout << "safe" << endl;
        } else {
            cout << "warning" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
class Node
  attr_reader :id, :siblings
  attr_accessor :state, :parent

  def initialize(id)
    @id = id
    @siblings = []
    @distances = {}
    @state = :white
    @parent = nil
  end

  def add(sibling, distance)
    @siblings << sibling
    @distances[sibling.id] = distance
  end

  def distance_from(other)
    @distances[other.id]
  end
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  nodes = []

  n.times do |id|
    nodes[id] ||= Node.new(id)
    node = nodes[id]

    distances = gets.chomp.split.map(&:to_i)

    distances.each_with_index do |distance, sibling_id|
      next if distance == -1

      nodes[sibling_id] ||= Node.new(sibling_id)
      sibling = nodes[sibling_id]

      node.add(sibling, distance)
    end
  end

  distances = Array.new(n, Float::INFINITY)

  distances[0] = 0

  loop do
    current = nil
    min = Float::INFINITY

    nodes.each do |node|
      next if node.state == :black

      distance = distances[node.id]

      if distance < min
        min = distance
        current = node
      end
    end

    break unless current

    current.state = :black

    current.siblings.each do |sibling|
      next if sibling.state == :black

      distance_from_current = sibling.distance_from(current)

      if distance_from_current < distances[sibling.id]
        distances[sibling.id] = distance_from_current
        sibling.parent = current
        sibling.state = :gray
      end
    end
  end

  puts nodes.select(&:parent).inject(0) {|sum, node| sum + node.distance_from(node.parent) }
end

Measured memory_bytes: 9252
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;



int main(){

  int N; cin>>N;
  int A[1001];
  REP(i,N) cin>>A[i];
  int flag = 1;
  REP(i,N){
    if(A[i] % 2 == 0){
      if(A[i] % 3 != 0 and A[i] % 5 != 0) flag = 0;
      continue;
    }
  }

  auto ans = flag ? "APPROVED" : "DENIED" ;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
//for (int i = 0; i < N; i++){}
//for (int j = 0; j < M; j++){}

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

    int c[N], t[N];
    for (int i = 0; i < N; i++){
        cin >> c[i] >> t[i];
    }

    int res = 10000;
    for (int i = 0; i < N; i++){
        if(t[i] <= T){
            res = min(res, c[i]);
        }
    }
    if(res==10000){
        cout << "TLE" << endl;
    }else{
        cout << res << endl;
    }
}

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

int main() {
	int l,r,k=0;
	cin >> l >> r;
	int l2=l%2019,r2=r%2019;
	if(r-l>=2019)
	{
		k=0;
	}
	else if(r2<l2)
	{
		k=0;
	}
	else
	{
		k=2018;
		for(int i=l2;i<r2;i++)
		{
			for(int j=i+1;j<=r2;j++)
			{
				k=min(k,(i*j)%2019);
			}
		}
	}
  cout << k << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  long long n;
  cin>>n;
  vector<string> s(n);
  vector<vector<int> > a(n, vector<int>(26));
  r(i,n)cin>>s.at(i);

  r(i,n){
    sort(s.at(i).begin(),s.at(i).end());
  }
  sort(s.begin(),s.end());

  long long cnt=1,cnt2=0;
  int flag=-1;
  r(i,n-1){
    if(s.at(i)==s.at(i+1)){
      cnt++;
    }else{
      cnt2+=cnt*(cnt-1)/2;
      cnt=1;
    }
  }
  cnt2+=cnt*(cnt-1)/2;

  cout<<cnt2<<endl;

  return 0;
}


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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef pair<pair<int, int> , pair<int, int> > PPA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int H, W, K;
int dp[110][10];

signed main()
{
    cin >> H >> W >> K;
    if(W == 1){
        printf("1\n");
        return 0;
    }
    int bit = (1 << (W - 1));
    dp[0][0] = 1;
    for(int i = 1; i <= H; i++){
        for(int j = 0; j < bit; j++){
            bool flag = false;
            for(int k = 1; k < W - 1; k++){
                if((j & (1 << (k - 1))) && (j & (1 << k))){
                    flag = true;
                }
            }
            if(flag)continue;
            for(int k = 0; k < W; k++){
                if(j & (1 << k)){
                    dp[i][k + 1] += dp[i - 1][k];
                    dp[i][k + 1] %= mod;
                }
                else if(k > 0 && (j & (1 << (k - 1)))){
                    dp[i][k - 1] += dp[i - 1][k];
                    dp[i][k - 1] %= mod;
                }
                else {
                    dp[i][k] += dp[i - 1][k];
                    dp[i][k] %= mod;
                }
            }
            //printf("\n");
        }
    }
    cout << dp[H][K - 1] % mod << endl;

    return 0;
}
/*




*/



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL n,ans,a[301][301];
bool p[301][301];
int main(){
	cin>>n;
	for(LL i=1;i<=n;i++)
		for(LL j=1;j<=n;j++)cin>>a[i][j];
	for(LL k=1;k<=n;k++)
		for(LL i=1;i<=n;i++)
			for(LL j=1;j<=n;j++)
				if(k!=j&&k!=i&&i!=j){
					if(a[i][j]==a[i][k]+a[k][j])p[i][j]=1;
					if(a[i][j]>a[i][k]+a[k][j])puts("-1"),exit(0);
				}
	for(LL i=1;i<=n;i++)
		for(LL j=1;j<=n;j++)
			if(!p[i][j])ans+=a[i][j];
	printf("%lld\n",ans/2),exit(0);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#define N_ 101000
#define pli pair<long long, int>
using namespace std;
int n, m;
vector<int>E[N_], L[N_];
int Q[N_], head, tail, Mod = 1000000007;
struct SP {
	int st, Deg[N_];
	long long D[N_], R[N_];
	vector<int>G[N_];
	priority_queue<pli>PQ;
	void Put(int a, long long d) {
		if (D[a] <= d)return;
		D[a] = d;
		PQ.push({ -d,a });
	}
	void Dijk(int a) {
		st = a;
		int i;
		for (i = 1; i <= n; i++)D[i] = 1e18;
		Put(st, 0);
		while (!PQ.empty()) {
			auto tp = PQ.top();
			PQ.pop();
			int x = tp.second;
			if (D[x] != -tp.first)continue;
			for (i = 0; i < E[x].size();i++) {
				Put(E[x][i], D[x] + L[x][i]);
			}
		}
	}
	void Do() {
		head = tail = 0;
		int i, x;
		R[st] = 1;
		for (i = 1; i <= n; i++)if (!Deg[i])Q[++tail] = i;
		while (head < tail) {
			x = Q[++head];
			for (auto &t : G[x]) {
				Deg[t]--;
				R[t] = (R[t] + R[x]) % Mod;
				if (!Deg[t])Q[++tail] = t;
			}
		}
	}
}P1, P2;
int R[N_];
long long Pow2(long long a) {
	a %= Mod;
	return a*a%Mod;
}
int main() {
	int i, j, a, b, c, S, T;
	scanf("%d%d", &n, &m);
	scanf("%d%d", &S, &T);
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &a, &b, &c);
		E[a].push_back(b);
		E[b].push_back(a);
		L[a].push_back(c);
		L[b].push_back(c);
	}
	P1.Dijk(S);
	P2.Dijk(T);
	for (i = 1; i <= n; i++) {
		for (j = 0; j < E[i].size(); j++) {
			int x = E[i][j];
			if (P1.D[i] + P2.D[x] + L[i][j] == P1.D[T]) {
				P1.G[i].push_back(x);
				P2.G[x].push_back(i);
				P1.Deg[x]++, P2.Deg[i]++;
			}
		}
	}
	P1.Do();
	P2.Do();
	int res = Pow2(P1.R[T]);
	for (i = 1; i <= n; i++) {
		if (P1.D[i] + P2.D[i] == P1.D[T] && P1.D[i] * 2 == P1.D[T]) {
			res = (res - Pow2(P1.R[i] * P2.R[i]) + Mod) % Mod;
		}
	}
	for (i = 1; i <= n; i++) {
		for (auto &tp : P1.G[i]) {
			if (P1.D[i] * 2 < P1.D[T] && P1.D[tp] * 2 > P1.D[T]) {
				res = (res - Pow2(P1.R[i] * P2.R[tp]) + Mod) % Mod;
			}
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 29048
def candd(n):
  count = 0
  for i in range(25):
    for s in range(15):
      answer = 4*i + s*7
      if answer == n:
        count +=1
  if count >0:
    print('Yes')
  else:
    print('No')

a = int(input())
candd(a)


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

int main() {

    string Ta,Tb;
    int num,Pa=0,Pb=0;

    cin >> num;

    for(int i=0;i<num;i++){
        cin>>Ta >> Tb;

        if (Ta>Tb) Pa+=3;
        else if (Ta<Tb) Pb+=3;
        else
        {
            Pa++;
            Pb++;
        }
    }
    cout << Pa << " " << Pb << endl;
    return 0;
}

Measured memory_bytes: 3128
using System;
 
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            string[] arr = str.Split(' ');
            int x = Int32.Parse(arr[0]);
            int y = Int32.Parse(arr[1]);
            Console.WriteLine(x+y/2);
        }
    }
}

Measured memory_bytes: 13140
from collections import Counter
n = int(input())
d_array = [int(x) for x in input().split()]
d_counter = Counter(d_array)

max_d = max(d_array)
tmp = 0
cnt = 0
for i in range(max_d):
    tmp += d_counter[i]
    if tmp == n//2:
        cnt += 1
print(cnt)


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

using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pback pop_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vis vector<string>
#define vii vector<vector<int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi,greater<int>>
#define setbits(x) __buitin_popcountll(x)
#define zrobits(x) __buitln_ctzll(x)
#define mod 1000000007 //1e9+7
#define inf 1e18
#define ps(x,y) fixed<<setpresicion(y)<<x
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x; while(x--)
#define rg 1000005
#define deg(v) cout<<"Value is: "<<v<<endl
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(a,b) for(int i=a;i<b;i++)
#define frev(a,b) for(int i=(int)a;i>(int)b;--i)
//mt19937  ring(chrono: stready_clock::now().time_since_epoch().count)


void IO() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


string LCS(string a, string b) {

	if (b.length() > a.length()) swap(a, b);

	int n = a.length(), m = b.length();



	int dp[n + 1][m + 1];
	for (int row = 0; row <= n; row++) {
		for (int col = 0; col <= m; ++col) {
			dp[row][col] = 0;
		}
	}

	char firstRowChar = a[0];
	char firstColChar = b[0];

	for (int row = 1; row <= n; row++) {
		dp[row][1] = (firstColChar == a[row - 1]) ? 1 : 0;
	}

	for (int col = 1; col <= m; col++) {
		dp[1][col] = (firstRowChar == b[col - 1]) ? 1 : 0;
	}

	for (int row = 2; row <= n; row++) {

		for (int col = 1; col <= m; col++) {

			if (a[row - 1] == b[col - 1]) {
				dp[row][col] = dp[row - 1][col - 1] + 1;
			} else {
				dp[row][col] = max(dp[row - 1][col], dp[row][col - 1]);
			}
		}
	}

	// for (int row = 0; row <= n; row++) {
	// 	for (int col = 0; col <= m; col++) {

	// 		cout << dp[row][col] << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << "\n";
	string subseq;

	int row = n , col = m;

	while (row > 0 && col > 0) {

		//cout << row << " " << col << endl;
		if (dp[row][col] != max(dp[row - 1][col], dp[row][col - 1])) {
			subseq = b[col - 1] + subseq;
			row--; col--;
		} else {
			if (dp[row][col] == dp[row - 1][col]) row--;
			else col--;
		}
	}

	return subseq;


}
int32_t main() {

	FASTIO;
	//IO();

	string a, b; cin >> a >> b;

	cout << LCS(a, b) << endl;
	return 0;
}


Measured memory_bytes: 74044
#include <stdio.h>

int main() {
	int i, n, p[20], cont = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) scanf("%d", &p[i]);

	for (i = 1;i < n-1;i++)	{
		if (p[i - 1] > p[i] && p[i] > p[i + 1]) cont++;
		else if (p[i - 1] < p[i] && p[i] < p[i + 1]) cont++;
	}

	printf("%d\n", cont);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
 
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b&&!(a==1&&b==13)||a==13&&b==1) cout<<"Bob"<<endl;
    else if(a==b)cout<<"Draw"<<endl;
    else cout<<"Alice"<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

int main(void)
{
	double n, d;
	cin >> n >> d;

	cout << ceil(n / (2 * d + 1));

	return 0;
}



Measured memory_bytes: 384