akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

const int N = 200010;
const int moder = (int) 1e9 + 7;

int c[N];
int pre[N], sit[N];
int dp[N];

int main() {
    memset(sit, -1, sizeof(sit));
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &c[i]);
        pre[i] = sit[c[i]];
        sit[c[i]] = i;
    }
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        dp[i + 1] = dp[i];
        if (pre[i] == -1 || pre[i] == i - 1) {
            continue;
        }
        dp[i + 1] += dp[pre[i] + 1];
        dp[i + 1] -= dp[i + 1] >= moder ? moder : 0;
    }
    printf("%d\n", dp[n]);
    return 0;
}

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


int main() {
  int n,l;
  cin >> n >> l;
  if(l>=0){
    int ans=0;
    for(int i=1;i!=n;i++){
      ans+=l+i;
    }
    cout << ans <<endl;
  }
  else{
    if(n+l-1<=0){
      int ans=0;
      for(int i=0;i!=n-1;i++){
        ans+=i+l;
      }
      cout << ans << endl;
    }
    else{
      int ans=0;
      for(int i=0;i!=n;i++){
        ans+=i+l;
      }
      cout << ans << endl;
    }
  }
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n,m,ans=0,c=1;
    cin>>n>>m;
    n--; m--;
    cout<<(m+n-1)/n el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll dp[61000];

int main() {
    int n, m; cin >> n >> m;
    vector<int> c(m); rep(i, m) cin >> c[i];
    rep(i, 61000) dp[i] = INF;
    dp[0] = 0;
    rep(i, m) {
        rep(j, n+1) {
            chmin(dp[j + c[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
}


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

using namespace std;

int main(void)
{
	int n,ans=0;

	cin>>n;

	int v[n],c[n];

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

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

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

		if(v[i]-c[i]>ans) ans=v[i]-c[i];

			for(int j=0;j<=i;j++){
				if(v[j]>c[j]){
					x+=v[j];
					y+=c[j];
				}
			if(x-y>ans) ans=x-y;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] a = new int[100];
		int b = 1;
		int x = 0;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			a[i] = scan.nextInt();
		}
		
		while(b==1){
			b = 0;
			for(int i=n-1; i>=1; i--){
				if(a[i] < a[i-1]){
					int kari = a[i];
					a[i] = a[i-1];
					a[i-1] = kari;
					b = 1;
					x++;
				}
			}
		}
		
		for(int i=0; i<n; i++){
			System.out.print(a[i]);
			if(i!=n-1){
				System.out.print(" ");
			}
			else{
				System.out.print("\n");
			}
		}
		
		System.out.println(x);
	}
}


Measured memory_bytes: 26476
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    a=input()
    N=1
    print(chr(ord(a)+N) if ord(a)+N<=122 else chr(ord(a)+N-26))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  cout << (s<t?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

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

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << endl;
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << endl;
	}
}

void executeCode() {
	ll n;
	cin >> n;
	string str;
	while(n) {
		if(n % 26 == 0) {
			str += 'z';
			n /= 26;
			n--;
		}else {
			str += ((n % 26) - 1 + 'a');
			n /= 26;
		}
	}
	reverse(str.begin(), str.end());
	cout << str << endl;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

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

#define MAXN 100*1000 + 5

int dsu[MAXN], sz[MAXN], ans[MAXN];

set<int> good[MAXN], bad[MAXN];

int find(int i) { return i == dsu[i] ? i : dsu[i] = find(dsu[i]); }

void unite(int i, int j) {
	i = find(i), j = find(j);
	if(i == j) return;
	else if(sz[i] < sz[j]) {
		sz[j] += sz[i];
		dsu[i] = j;
	} else {
		sz[i] += sz[j];
		dsu[j] = i;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	memset(ans, 0, sizeof ans);
	fill(sz, sz + MAXN, 1);
	iota(dsu, dsu + MAXN, 0);
	
	int n, m, k;
	cin >> n >> m >> k;
	vector<pair<int, int>> edges;
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		good[u].insert(v);
		good[v].insert(u);
		edges.emplace_back(u, v);
	}
	
	for(int i = 0; i < k; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		bad[u].insert(v);
		bad[v].insert(u);
	}
	
	for(auto e : edges) {
		unite(e.first, e.second);
	}
	
	for(int i = 0; i < n; i++) {
		ans[i] = sz[find(i)];
		ans[i] -= (int) good[i].size();
		for(int x : bad[i]) {
			if(find(x) == find(i) && good[i].count(x) == 0) {
				ans[i]--;
			}
		}
	}
	
	for(int i = 0; i < n; i++) {
		cout << ans[i]-1 << " \n"[i==n-1];
	}
}


Measured memory_bytes: 30964
#include<iostream>
#include<map>
#include<vector>
#include<string>

int p, q;
std::map<int, int> m;
std::vector<int> v;

int main()
{
	while( std::cin >> p >> q )
	{
		m.clear();
		v.clear();
		
		int cnt = 0;
		int s = -1;
		while( true )
		{
			if( cnt )
				v.push_back( p / q );

			p %= q;
			
			if( !p )
				break;

			if( m.count( p ) )
			{
				s = m.find( p )->second;

				break;
			}

			m.insert( std::make_pair( p, cnt++ ) );

			p *= 10;
		}

		for( int i = 0; i != v.size(); ++i )
			std::cout << v[i];

		std::cout << std::endl;

		if( s != -1 )
			std::cout << std::string( s, ' ' ) << std::string( v.size() - s, '^' ) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
using namespace std;
int main(){
    int h[3],m[3],s[3];
    for(int i = 0; i < 3;i++){
        int ah,am,as;
        int bh,bm,bs;
        cin >> ah >> am >> as >> bh >> bm >> bs;
        h[i] = bh - ah;
        m[i] = bm - am;
        s[i] = bs - as;
        if(s[i] < 0){
            m[i]--;
            s[i] += 60;
        }
        if(m[i] < 0){
            h[i]--;
            m[i] += 60;
        }
        if(s[i] > 60){
            int cm = s[i] /60;
            s[i] = s[i] % 60;
            m[i] += cm;
        }
        if(m[i] > 60){
            int ch = m[i] /60;
            m[i] = m[i] % 60;
            h[i] += ch;
        }
    }
    for( int i = 0;i < 3;i++){
        cout << h[i] << " " << m[i] << " " << s[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#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;

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; }




void Main(){
    int n;
    cin >> n;
    VI xv(n);
    VI yv(n);
    REP(i, n) cin >> xv[i] >> yv[i];
    VI a(n);
    VI b(n);
    REP(i, n) a[i] = xv[i] + yv[i];
    REP(i, n) b[i] = xv[i] - yv[i];
    sort(ALL(a));
    sort(ALL(b));
    int a1 = a[n-1] - a[0];
    int b1 = b[n-1] - b[0];
    int ans = max(a1, b1);
    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: 6340
#include <bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define en "\n"
#define eps 1e-9
#define VECT(v)  vector<int>v
#define SCAN(v)  int temp; for(int i=0; i<n; i++) {cin>>temp; v.push_back(temp);}
#define PRINT(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << en;
#define SORT(v)  sort(v.begin(), v.end());
#define CASEP(v) cout<<"Case "<<c<<": "<<v<<"\n"
#define DEBUG(v) cout << v << " "; cout << en;

int main(void)
{
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	fast_io
	
	double d, t, s;
	cin >> d >> t >> s;

	double ans = d/s;
	
	if(ans <= t)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

Measured memory_bytes: 3676
#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;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    ld density=0;
    int answater=0;
    int anssugar=0;
    for(int i=0;i<=30;i++){         // 100a water
        for(int j=0;j<=15;j++){     // 100b water
            for(int k=0;k<=1500;k++){       //c sugar
                for(int l=0;l<=750;l++){    //d sugar
                    int water=100*i*a+100*j*b;
                    int sugar=k*c+l*d;
                    if(sugar<=(i*a+j*b)*e && water+sugar<=f && water+sugar>0){

                        if(100.00000*sugar/(water+sugar)>=density){

                            answater=water+sugar;
                            anssugar=sugar;
                            density=100.0000000*sugar/(water+sugar);
                        }
                    }
                }
            }
        }
    }
    cout<<answater<<' '<<anssugar<<endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int H, W;
    cin >> H >> W;
    vector<string> S(H+2);
    for(int i=1; i<=H; i++) {
        cin >> S[i];
        S[i].insert(0, "#");
        S[i].push_back('#');
    }
    S[0] = string(W+2, '#');
    S[H+1] = string(W+2, '#');

    vector< vector<int> > yoko(H+2, vector<int>(W+2));
    for(int i=1; i<=H; i++) {
        int s = 0;
        int c = 0;
        for(int n=0; n<=W+1; n++) {
            if(S[i][n] == '#') {
                for(int j=s; j<n; j++) {
                    yoko[i][j] =c;
                }
                s = n+1;
                c = 0;
            } else {
                ++c;
            }
        }
    }

    vector< vector<int> > tate(H+2, vector<int>(W+2));
    for(int i=1; i<=W; i++) {
        int s = 0;
        int c = 0;
        for(int n=0; n<=H+1; n++) {
            if(S[n][i] == '#') {
                for(int j=s; j<n; j++) {
                    tate[j][i] =c;
                }
                s = n+1;
                c = 0;
            } else {
                ++c;
            }
        }
    }

    int ans = 0;
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            ans = max(ans, yoko[i][j] + tate[i][j]);
        }
    }

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


Measured memory_bytes: 35840
# スペース区切りの整数の入力
a,b=gets.chomp.split(" ").map(&:to_s);
c = "#{a}#{b}"
c = c.to_i
for i in 1..c/2 do
  if c==i*i then
    print "Yes"
    exit
  end
end
print "No"

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  private void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      int[] mHeap = new int[heapSize+1];
      mHeap[0] = heapSize;
      for(int i=1; i<=heapSize; i++)
        mHeap[i] = Integer.parseInt( keys[i-1] );

      buildMaxHeap(mHeap);

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<mHeap.length; i++) 
        buf.append(" ").append(mHeap[i]);

      System.out.println(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
  private void buildMaxHeap(int[] heap) {
    for(int i= heap[0]/2; i>0; i--)
      maxHeapify(heap, i);
  }
  private void maxHeapify(int[] heap, int node) {
    int t,left,right,largest;
    t = left = right = largest = 0;
    left  = nodeLeft(node);
    right = nodeRight(node);

    if( (left <= heap[0]) && (heap[left] > heap[node]) )
      largest = left;
    else
      largest = node;
    if( (right <= heap[0]) && (heap[right] > heap[largest]) )
      largest = right;

    if( largest != node ) {
      t = heap[node]; heap[node] = heap[largest]; heap[largest] = t;

      maxHeapify(heap, largest);
    }
  }
  private int nodeLeft(int node) {
    return node*2;
  }
  private int nodeRight(int node) {
    return node*2+1;
  }
}


Measured memory_bytes: 75344
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stdio.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
ll n, a1goukei = 0, a3goukei = 0, a2goukei = 0;
priority_queue<int, vector<int>, greater<int>> a1, a1c;
vector <ll>  a2;
ll  a1wa[100000], a3wa[100000], ruisekiwa1[100001], ruisekiwa2[100001];
ll a1max = -993193111451419810, wa1 = 0, wa3 = 0;
priority_queue<ll>a3, a3c;//小さいものを取り出す
int main() {
	cin >> n;//ボボボボボッボッボッボッボッボッボボオエエエエエ
	REP(i, n) {
		ll gomi; cin >> gomi;//代入な
		a1.push(gomi);
		a1wa[i] = gomi;
		wa1 += gomi;//左側すべての和を計算するぞい
	}
	REP(i, n) {
		ll gomi; cin >> gomi;
		a2.push_back(gomi);//代入な
	}
	REP(k, n) {
		ll gomi; cin >> gomi;
		a3.push(gomi);
		a3wa[k] = gomi; wa3 += gomi;//同じだよ
	}			
	ruisekiwa1[0] = wa1;
	REP(i, n) {//累積和でガンガン押します
		a1.push(a2[i]);//a1の方なので、最初から最後に向けて累積和
		ll top1 = a1.top(); a1.pop();//なるべく小さくするぞい
		ruisekiwa1[i + 1] = ruisekiwa1[i] + a2[i] - top1;
	}			
	ruisekiwa2[n] = wa3;
	for (ll i = n - 1; i >= 0; i--)
	{
			a3.push(a2[i]);//今度は逆に累積和
			ll top3 = a3.top();	a3.pop();
			ruisekiwa2[i] = ruisekiwa2[i + 1] - top3 + a2[i];
	}
	for (ll i = 0; i <= n; i++)
	{
		a1max = max(a1max, ruisekiwa1[i] - ruisekiwa2[i]);//最大値をとるよ
	}
	cout << a1max << endl;//はいWA
	return 0;
}

Measured memory_bytes: 5492
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <array>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
const int  INF=10e7;

typedef  pair<int,int> P;


int main(){
     int n,k,x,y;
     cin>>n>>k>>x>>y;
     int ans=0;
     ans=min(n,k)*x+max(n-k,0)*y;
     cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<list>
using namespace std;
int main(void){
  int n;
  cin>>n;
  list<string> List;
  for(int i=0;i<n;i++){
    string name;
    cin>>name;
    List.push_front(name);
  }
  List.sort();
  List.unique();
  int ans=List.size();
  cout<<ans;
  return 0;
}

Measured memory_bytes: 16012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, m; cin >> n >> m; 
    vector<vector<int>> G(n);
    rep(i,m){
        int a, b; cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> vec;
    rep(i,n) vec.push_back(i);
    int ans = 0;
    do{
        bool add = false;
        if(vec[0] != 0)continue;
        for(int i = 0; i < n-1; ++i){
            bool isOK = false;
            for(auto e : G[vec[i]]){
                if(e == vec[i+1]) isOK = true;
            }
            if(!isOK) break;
            if(i==n-2) add = true;
        }
        if(add) ans++;
    }while(next_permutation(ALL(vec)));
    cout << ans << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

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

print(min(N % K, K - (N % K)))


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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

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


int main(){
int N,K; cin>>N>>K;
vi vec(N);
REP(i,N){
    cin>>vec.at(i);
}
sort(vec.begin(),vec.end());
int ans=0;
REP(i,K){
    ans+=vec.at(i);
}
cout<<ans<<endl;
}
  


Measured memory_bytes: 3624
import math
import heapq

def minus(number):
    return (-1) * number

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(minus, A))
heapq.heapify(A)


for x in range(M):
    t = math.floor(heapq.heappop(A) * (-1) / 2)
    heapq.heappush(A, t*(-1))

A = list(map(minus, A))
print(sum(A))



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

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

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

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


signed main(){
    int A, B, C;
    cin >> A >> B >> C;
    PRINT(min(B / A, C));
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  int n = rint();
  int m = rint();
  int dp[n+1];
  dp[0] = 0;
  dotimes(i, n)
    dp[i+1] = 1LL << 61;
  dotimes(i, m) {
    int c = rint();
    for (int j = c; j <= n; j++)
      mins(dp[j], dp[j-c] + 1);
  }
  wint(dp[n]);
  return 0;
}



Measured memory_bytes: 3132
#include <stdio.h>
int main(void){
int a,b,c,d,e,k;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&k);
  if(b-a>k){printf(":(");return 0;}
  if(c-a>k){printf(":(");return 0;}
  if(d-a>k){printf(":(");return 0;}
  if(e-a>k){printf(":(");return 0;}
  if(c-b>k){printf(":(");return 0;}
  if(d-b>k){printf(":(");return 0;}
  if(e-b>k){printf(":(");return 0;}
  if(d-c>k){printf(":(");return 0;}
  if(e-c>k){printf(":(");return 0;}
  if(e-d>k){printf(":(");return 0;}
printf("Yay!");
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int S;
	int h,m,s;
    int s1;
	
	
	
	
	scanf("%d", &S);
	while(1){
	if(0<=S && 86400>S){
		h=S/3600;
		s1=S-h*3600;
		m=s1/60;
		s=s1-m*60;
		break;
	}else{
		scanf("%d", &S);
	    continue;
	}
	}
	printf("%d:%d:%d\n", h , m , s);
		
	return 0;
}

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

int main(){
    string S;
    string ans;
    cin >> S;
    const int n = 4;

    for(int bit = 0; bit < (1 << (n-1)); bit++){
        int a = S[0] - '0';
        ans = S[0];
        int sum = a;
        for(int j = 0; j < n-1; j++){
            if(bit & (1<<j)){
                sum += (S[j+1] - '0');
                ans.append("+");
            }else{
                sum -= (S[j+1] - '0');
                ans.append("-");
            }
            ans.append(1,S[j+1]);
        }
        if(sum == 7){
            ans.append("=7");
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

struct Coordinate {
	int x, y;
	Coordinate operator-(const Coordinate that) const { return Coordinate{ x - that.x, y - that.y }; }
	Coordinate operator+(const Coordinate that) const { return Coordinate{ x + that.x, y + that.y }; }
	Coordinate rotate() const { return Coordinate{ y, -x }; }
};
int main() {
	Coordinate c1, c2; std::cin >> c1.x >> c1.y >> c2.x >> c2.y;
	auto c3 = (c1 - c2).rotate() + c2;
	auto c4 = c3 + c1 - c2;
	std::cout << c3.x << ' ' << c3.y << ' ' << c4.x << ' ' << c4.y << std::endl;
}


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;
typedef pair<int, int> P;
#define rrep(i,n) for(int i = 1;i < (n);++i)
constexpr int mod = 1000000007;

int modPow(long long a, long long n, long long p) {
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	rrep(i, p + 1) {
		a = (a * (n - i + 1)) % mod;
		b = (b * i) % mod;
	}
	return a * (modPow(b, mod - 2, mod)) % mod;
}

int main() {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	if (!(2 * y - x >= 0 && 2 * x - y >= 0)) {
		cout << 0 << endl;
		return 0;
	}
	int a = (2 * y - x) / 3;
	int b = (2 * x - y) / 3;
	int ans = comb(a + b, a);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    statements = []
    for _ in range(N):
        a = II()
        statement = []
        for _ in range(a):
            hatugen = LI()
            statement.append(hatugen)
        statements.append(statement)

    ans = 0
    for i in range(2**N):
        flag = True
        i_str = format(i, f"0{N}b")
        for n in range(N):
            if i_str[n] == '0':
                continue

            for statement in statements[n]:
                target = statement[0]
                seisitu = statement[1]

                if i_str[target - 1] != str(seisitu):
                    flag = False

        if flag:
            tmp = 0
            for n in range(N):
                tmp += int(i_str[n])

            ans = max(ans, tmp)

    print(ans)


main()


Measured memory_bytes: 74608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(){
    int i=0, a=9;
    for(;a;scanf("%d", &a))i++;
    printf("%d\n", i);   
}

Measured memory_bytes: 1732
#include<stdio.h>
int main(void)
{
  int n,i;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=n-1;i>0;i--)
    printf("%d ",a[i]);
  printf("%d",a[0]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 20
int n;
int ans;
int a[N];
int x[N][N];
int y[N][N];
bool ok[N];
void judge()
{
	bool yes=1;
	for(int i=1;i<=n;i++)
	{
		if(ok[i])
		{
			for(int j=1;j<=a[i];j++)
			{
				if(y[i][j]!=ok[x[i][j]]) yes=0;
			}
		}
	}
	if(yes)
	{
		int sum=0;
		for(int i=1;i<=n;i++) if(ok[i]) sum++;
		if(sum>ans) ans=sum;
	}
}
void dfs(int dep)
{
	if(dep==n+1)
	{
		judge();
		return ;
	}
	ok[dep]=0;dfs(dep+1);
	ok[dep]=1;dfs(dep+1);
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		for(int j=1;j<=a[i];j++)
		{
			x[i][j]=read(),y[i][j]=read();
		}
	}
	dfs(1);
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
#define DICIMAL(x) fixed<<setprecision(x)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    INIT;

    int N[3]; REP(i,3) cin>>N[i];
    sort(N, N+3);
    int res = N[2]*10+N[1]+N[0];

    cout<<res<<endl;
    return 0;
}


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

int n,T,minv=2e9+7,ans;

signed main()
{
	cin>>n>>T;
	for (int i=1;i<=n;i++)
	{
		int t,c;
		cin>>c>>t;
		if (t<=T)  minv=min(minv,c);
	}
	if (minv!=2e9+7)  cout<<minv<<endl;
	else cout<<"TLE"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    int N , K;
    cin >> N >> K;
    vector <int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    cout << (N - 1 + K - 2) / (K - 1) << endl;
    
}


Measured memory_bytes: 640
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define INF2 4611686018427387904
//#define MOD 1000000007
#define MOD 998244353
#define MAX_SIZE 1000000000

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; for (const auto& j: v) { if (!first) { os << " "; } first = false; os <<j; } os << "\n"; return os; }
template<typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& elem : v) { is >> elem; } return is; }

struct v {
    int y;
    int a;
    int b;
};

void solve() {
    int n, m, s;
    cin >> n >> m >> s;

    vector<vector<v> > g(n);

    for (int i=0; i<m; i++) {
        int x, y;
        v q;
        cin >> x >> y >> q.a >> q.b;
        x--;
        y--;
        q.y = y;
        g[x].push_back(q);
        q.y = x;
        g[y].push_back(q);
    }

    vi c(n);
    vi d(n);
    for (int i=0; i<n; i++) {
        cin >> c[i] >> d[i];
    }

    int ma = 2500;
    s = min(ma, s);

    priority_queue<pair<ll, ll> > b;
    b.push({0, s * n});

    vector<vll> ans(n, vll(ma+1, INF2));
    ans[0][s] = 0;

    while (b.size() > 0) {
        ll time = -b.top().first;
        int i = b.top().second % n;
        int left = b.top().second / n;
        b.pop();

        if (time > ans[i][left]) {
            continue;
        }

        //cout << time << ' ' << i << ' ' << left << endl;

        for (v& q : g[i]) {
            if (q.a <= left) {
                ll time2 = time + q.b;
                int left2 = left - q.a;
                if (ans[q.y][left2] > time2) {
                    ans[q.y][left2] = time2;
                    b.push({-time2, left2 * n + q.y});
                }
            }
        }

        if (left < ma) {
            ll time2 = time + d[i];
            int left2 = min(ma, left + c[i]);
            if (ans[i][left2] > time2) {
                ans[i][left2] = time2;
                b.push({-time2, left2 * n + i});
            }
        }
    }

    for (int i=1; i<n; i++) {
        ll mi = INF2;
        for (int j=0; j<=ma; j++) {
            mi = min(mi, ans[i][j]);
        }
        cout << mi << "\n";
    }
}


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

    if (0) {
        int tests;
        cin >> tests;
        for (int t = 1; t <= tests; t++) {
            //cout << "Case #" << t << ": ";
            solve();
            cout << "\n";
        }
    } else {
        solve();
        //cout << endl;
    }

    return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    int ans=0;
    
    rrep(i,1,n+1){
        string s=to_string(i);
        if(s[0]==s[s.size()-1])ans++;
        string ss;
        ss.pb(s[s.size()-1]);
        ss.pb(s[0]);
        if(ss[0]=='0')continue;
        if(stoi(ss)<=n){
            ans++;
        //    std::cout << s<<' '<<ss << std::endl;
        }
        else continue;
       // std::cout << ss << std::endl;
        string s1,s2;
        s1=ss;s2=ss;
        for(int j=1;;j++){
            s1.insert(1,"0");
           // std::cout << s1 << std::endl;
            if(stoi(s1)>n)break;
            s2.insert(1,"9");
            ans+=min((n-stoi(s1))/10+1,int(pow(10,j)));
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int a;string s;
  in(a,s);
  out(a>=3200?s:"red");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)


using namespace std;

int main() {

	unsigned long long int p, res;
	int n, tmp;
	cin >> n;

	vector<int>st(n, 0);

	rep(i, 0, n) {
		cin >> tmp;
		st[tmp] += 1;
	}

	unsigned long long int md = (int)pow(10, 9) + 7;


	if (n == 1) {
		cout << "1" << endl;
		return 0;
	}
	else if (n % 2 == 1) {
		if (st[0] != 1) {
			cout << "0" << endl;
			return 0;
		}

		rep(i, 1, n) {

			if (st[i] > 2 || st[i]==1) {
				cout << "0" << endl;
				return 0;
			}

		}

		if (n == 3) {
			res = 2;
		}
		else {
			p = n / 2;
			res = 2;

			for (int k = 0; k < p-1; k++) {
				res *= 2;
				res = res % md;
			}
			
		}
		



	}
	else {		
		rep(i, 1, n) {
			if (st[i] > 2 || st[i] == 1) {
				cout << "0" << endl;
				return 0;
			}
		}

		if (n == 2) {
			res = 2;
		}
		else {
			p = n / 2;
			res = 2;

			for (int k = 0; k < p - 1; k++) {
				res *= 2;
				res = res % md;
			}

		}
		

	}

	
	cout << res << endl;

	return 0;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))

void run(void){
  int n;
  scanf("%d",&n);
  int dp[6]={0};
  int now=0;
  while(n--){
    int next=now^3;
    int i,j;
    for(i=0;i<3;i++){
      int a;
      scanf("%d",&a);
      for(j=0;j<3;j++){
	if(i==j) continue;
	dp[next+i]=MAX(dp[next+i],dp[now+j]+a);
      }
    }
    now=next;
  }
  printf("%d\n",MAX(dp[now],MAX(dp[now+1],dp[now+2])));
}

int main(void){
  run();
  return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100007, MOD = 1000000007;
int n, k, a[N];

struct mint {
    int val;
 
    mint(int v = 0) {
        val = v % MOD;
        if(val < 0) val += MOD;
    }
 
    static int mod_inv(int a, int m = MOD) {
        int g = m, r = a, x = 0, y = 1;
 
        while (r != 0) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }
 
        return x < 0 ? x + m : x;
    }
 
    explicit operator int() const {
        return val;
    }
 
    mint& operator+=(const mint &other) {
        val += other.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
 
    mint& operator-=(const mint &other) {
        val -= other.val;
        if (val < 0) val += MOD;
        return *this;
    }
 
    static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
        return x % m;
    }
 
    mint& operator*=(const mint &other) {
        val = fast_mod((uint64_t) val * other.val);
        return *this;
    }
 
    mint& operator/=(const mint &other) {
        return *this *= other.inv();
    }
 
    friend mint operator+(const mint &a, const mint &b) { return mint(a) += b; }
    friend mint operator-(const mint &a, const mint &b) { return mint(a) -= b; }
    friend mint operator*(const mint &a, const mint &b) { return mint(a) *= b; }
    friend mint operator/(const mint &a, const mint &b) { return mint(a) /= b; }
 
    mint& operator++() {
        val = val == MOD - 1 ? 0 : val + 1;
        return *this;
    }
 
    mint& operator--() {
        val = val == 0 ? MOD - 1 : val - 1;
        return *this;
    }
 
    mint operator++(int32_t) { mint before = *this; ++*this; return before; }
    mint operator--(int32_t) { mint before = *this; --*this; return before; }
 
    mint operator-() const {
        return val == 0 ? 0 : MOD - val;
    }
 
    bool operator==(const mint &other) const { return val == other.val; }
    bool operator!=(const mint &other) const { return val != other.val; }
 
    mint inv() const {
        return mod_inv(val);
    }
 
    mint pow(int p) const {
        assert(p >= 0);
        mint a = *this, result = 1;
 
        while (p > 0) {
            if (p & 1)
                result *= a;
 
            a *= a;
            p >>= 1;
        }
 
        return result;
    }
 
    friend ostream& operator<<(ostream &stream, const mint &m) {
        return stream << m.val;
    }
};


mint _f[N];
int sz = 1;
mint fact(int i) {
    while(sz <= i) {
        _f[sz] = _f[sz-1]*sz;
        sz++;
    }
    return _f[i];
}

mint comb(int n, int k) {
    if(k > n) return 0;
    mint a = fact(n);
    mint b = fact(k)*fact(n-k);
    return a/b;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    _f[0] = 1;
    sort(a, a+n);

    mint ans = 0;
    for(int i = 0; i < n; ++i) {
        mint mn = comb(n-i-1, k-1);
        mint mx = comb(i, k-1);

        ans += (mx-mn)*a[i];
    }

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


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

signed main()
{
  int N;
  cin >> N;
  int X1 = (int)ceil(N/1.08);
  int X2 = (int)floor(N/1.08);
  if      ((int)(X1 * 1.08) == N) cout << X1 << endl;
  else if ((int)(X2 * 1.08) == N) cout << X2 << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans,k,n;

void give_ans(priority_queue <ll, vector<ll>, greater<ll>> gq)
{
	ll maxx=0;
	priority_queue <ll, vector<ll>, greater<ll>> g= gq;
	ll st = g.top();
	g.pop();
	while(!g.empty()){
		
		ll diff= g.top();
		diff -= st;
		maxx= max(maxx,diff);
		st = g.top();
		g.pop();
	}
	ans = n - maxx;
}
int main()
{
	ll x;
	cin>>n>>k;
	priority_queue <ll, vector<ll>, greater<ll>> ww;
	
	for(int i=1;i<=k;i++)
	{
		cin>>x;
		x = x%n;
		ww.push(x);
	}
	ww.push(ww.top()+n);
	//showpq(ww);
	give_ans(ww);
	cout<<ans;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;
#define int long long
#define test int t; cin >> t; while (t--)
#define deb(x) cerr << #x << " " << x << endl;
#define debb(x, y) cerr << #x << " = " << x << "," << #y << " = " << y << endl <<endl;
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const int maxn = 2e6 + 10;
const long double Pie = acos(-1);
 
signed main() {
    int n;
	cin >> n;
	
	if (n >= 30)	cout << "Yes";
	else            cout << "No";
	cout << "\n";
    return 0;
}


Measured memory_bytes: 3628
x=[]
y=[]
n=list(map(int,input().split()))

for i in range(n[0]):
	x.append(list(map(int,input().split())))
for i in range(n[1]):
	y.append(list(map(int,input().split())))
	
for i in range(n[0]):
	a=[]
	for j in range(n[2]):
		b=0
		for k in range(n[1]):
			f=x[i][k]*y[k][j]
			b+=f
		a.append(b)
	print(' '.join(list(map(str,a))))
	
			
			
			
		
			


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll n;
    cin >> n;
    FORd(i, sqrt(n), 1)
    {
        if(n % i == 0)
        {
            cout << (i + n / i) - 2;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int nur (int a){
    int ans = 0;
    while (a) {
        ans += a % 10;
        a /= 10;
    }
    return ans;
}
int main (){
    int a;
    cin >> a;
    int ans = 1e9;
    for (int i = 1; i <= a / 2; i++){
        ans = min (nur (i) + nur (a - i), ans);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <map>
using namespace std;
int main(){
    int n,m,now=0,temp;
    long long int ans=0;
    map<int,int>ma;
    scanf("%d%d",&n,&m);
    while(n--){
        ma[now]++;
        scanf("%d",&temp);
        now+=temp;
        now%=m;
        ans+=ma[now];
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 3200