akhauriyash/Code-Regression huggingface dataset:
from math import floor, ceil

def get_original_price(a, b):
  inclusive_min = max(12.5*a, 10*b)
  exclusive_max = min(12.5*(a+1), 10*(b+1))
  if inclusive_min >= exclusive_max: return -1
  if ceil(inclusive_min) == exclusive_max: return -1
  if floor(exclusive_max) >= ceil(inclusive_min): return int(ceil(inclusive_min))
  return -1

# 12.5a<=p<12.5(a+1)
# 10b<=p<10(b+1)
# also p must be integer, so the valid range
# must lie around at least one integer value

a, b = map(int, input().split())
print(get_original_price(a, b))

Measured memory_bytes: 3064
$MOD = 1000000007

def pow(a, b)
  ret = 1
  while b > 0
    if b % 2 != 0
      ret = (ret * a) % $MOD
    end
    a = (a * a) % $MOD
    b /= 2
  end
  return ret
end

n = gets.to_i
a = gets.chomp.split.map(&:to_i)

fact = 1
fact_inv_sum = Array.new(n+1, 0)
for i in 1..n
  fact = fact * i % $MOD
  fact_inv_sum[i] = pow(i, $MOD-2) + fact_inv_sum[i-1]
  fact_inv_sum[i] %= $MOD
end

ans = 0
for i in 0...n
  c = (fact_inv_sum[n-i] + fact_inv_sum[i+1] - 1 + $MOD) % $MOD;
  ans += c * a[i]
  ans %= $MOD
end

puts (fact * ans) % $MOD

Measured memory_bytes: 10252
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,K,S;
    cin >> N >> K >> S;
    int r = S/(N-K+1);
    int l = S-r*(N-K);
    
    
    REP(i,N){
        if(i<K){
            cout << S;
        }else{
            if(S<=1e8){
                cout << S+10;
            }else{
                cout << 1;
            }
        }
        if(i!=N-1){
            cout << " ";
        }
    }cout << endl;
    return 0;
}



Measured memory_bytes: 1280
#include <stdio.h>
#include <set>
#include <algorithm>
using namespace std;

int solve(int n) {
    int c = 0;
    set<int> vis;
    while (n >= 10 && vis.count(n) == 0) {
        vis.insert(n);
        int nx = 0, d = 10;
        while (d <= n) {
            nx = max(nx, (n%d)*(n/d));
            d *= 10;
        }
        n = nx;
        c++;
    }
    if (n < 10) return c;
    return -1;
}

int main() {
    int Q;
    scanf("%d", &Q);
    while (Q--) {
        int n;
        scanf("%d", &n);
        printf("%d\n", solve(n));
    }
    return 0;
}

Measured memory_bytes: 1032
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramC
    {
        static void Main(string[] args)
        {

            //入力
            int n = int.Parse(Console.ReadLine());
            string[] input = new string[n];


            for (int i = 0; i < n; i++)
                input[i] = Console.ReadLine();

            Array.Sort(input);
            long count = 1;

            for(int i = 1;i < n;i++)
            {
                if (input[i] != input[i - 1])
                    count++;
            }

            

            Console.WriteLine(count);
            
        }
    }

}


Measured memory_bytes: 38700
#include<bits/stdc++.h>
using namespace std;
int n;
#define ll long long int
const int modn=1e9+7;
int comp[22][22];
int main()
{ cin>>n;
  for(int i=0;i<n;i++)
  for(int j=0;j<n;j++)
  cin>>comp[i][j];
  
  vector<ll> dp(1<<n);
  dp[0]=1;
  for(int i=0;i<(1<<n);i++)
  { int m=__builtin_popcount(i);
   for(int w=0;w<n;w++)
    {if(comp[m][w]&&(i&(1<<w))==0)
      dp[i|1<<w]= (dp[i|1<<w]+dp[i])%modn;
	}
  }
  	
  cout<<(dp[(1<<n)-1])%modn;
  }
 


Measured memory_bytes: 19624
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int M = nint();
        List<Task> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(new Task(nint(), nint()));
        }
        
        Map<Integer, List<Task>> map = list.stream().collect(Collectors.groupingBy(e -> e.day));
        List<Integer> keys = new ArrayList<>(map.keySet());
        keys.sort((a, b) -> a-b);
        
        PriorityQueue<Task> q = new PriorityQueue<>((t1, t2) -> t2.reward - t1.reward);
        
        int ans = 0;
        for (int i = 1, keyIdx = 0; i <= M; i++) {
            if (keyIdx < keys.size()) {
                int key = keys.get(keyIdx);
                if (key <= i) {
                    keyIdx++;
                    map.get(key).forEach(t -> q.add(t));
                }
            }
            if (!q.isEmpty()) {
                Task polled = q.poll();
                ans += polled.reward;
            }
        }
        
        so.println(ans);
    }
    
    static class Task {
        int day;
        int reward;
        Task(int day, int reward) {
            this.day = day;
            this.reward = reward;
        }
        @Override
        public String toString() {
            return "[day = " + day + ", reward = " + reward + "]";
        }
    }

    private static int here(int i) {
        return (i+1)/2;
    }
    
    private static int there(int i) {
        return i/2;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


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

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

    int A=Y/1000-N;
    if(A>=0){
        for(int x=2*A/9;x<=A/4+1;x++){
            if(A-4*x>=0 && 9*x-2*A>=0 && N+A-5*x>=0){
                cout << (A-4*x) << ' ' << (9*x-2*A) << ' ' << (N+A-5*x) << endl;
                return 0;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <valarray>
#include <string>
#include <algorithm>
#include <set>
typedef unsigned long long ull;
typedef long long ll;

#define rep(i,n) for(ull i = 0;i<(n);i++)
#define rep1(i,n) for(ull i = 1;i<=(n);i++)
#define revrep(i,n) for(ull i = (n-1);i>=0;i--)
#define all(n) (n).begin(),(n).end()
#define show(x) cout << "debug " << #x << ":" << x << endl;
#define showmat(x) cout << endl << "debug " << #x << ";" << endl; \
	for(ull __i = 0;__i < x.size();__i++){ \
		for(ull __j = 0;__j<x[0].size();__j++){ \
			cout << x[__i][__j] << " "; \
		} \
		cout << endl; \
	} \
	cout << endl;

using namespace std;

ll M,N,D;
typedef valarray<ll> array_t;
int main(){
	while(cin >> M >> N >> D && M){
		valarray<array_t > mat(array_t(0LL,M*N+1), M*N);
		rep(i,M*N){
			cin >> mat[i][M*N];
			rep(j,M*N){
				int curx=i%M, cury=i/M, trgx=j%M, trgy=j/M;
				ll d = abs(curx-trgx)+abs(cury-trgy);
				if(d == 0 || d == D){
					mat[i][j] = 1;
				}
			}
		}


		//hakidashi
		rep(i,M*N){
			int nonzeroR = -1;
			for(ll p = i;p<M*N;p++){
				if(mat[p][i] != 0){
					nonzeroR = p;
					break;
				}
			}
			if(nonzeroR == -1){
				continue;
			}
			swap(mat[i],mat[nonzeroR]);
			for(ll j = 0;j<M*N;j++){
				if(j == i){
					continue;
				}
				if(mat[j][i] == 1){
					mat[j] += mat[i];
				}
				mat[j] %= 2;
			}
		}

		bool ans = true;
		rep(i,M*N){
			bool rowzero = true;
			rep(j,M*N){
				if(mat[i][j] != 0){
					rowzero = false;
					break;
				}
			}
			if(rowzero && mat[i][M*N] == 1){
				ans = false;
				break;
			}
		}
		if(ans){
			cout << 1 << endl;
		}else{
			cout << 0 << endl;
		}
	}
}

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

int main() {
  char c;
  cin>>c;
  if(c=='a'){
    cout<<"vowel"<<endl;
  }else if(c=='e'){
    cout<<"vowel"<<endl;
  }else if(c=='i'){
    cout<<"vowel"<<endl;
  }else if(c=='o'){
    cout<<"vowel"<<endl;
  }else if(c=='u'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }
  
}



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

int comp(const void *p1, const void *p2) {
	return *(const int *)p1 - *(const int*)p2;
}
int needs(int);

int N, K, a[5010];
int dp[5010][5010];

int main(void) {
	int i, left, right, center;
	
	scanf("%d%d", &N, &K);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		// 解に関係ない値は読み飛ばす
		if (a[i] >= K) {
			N--;
			i--;
		}
	}
	qsort(a, N, sizeof(int), comp);
	
	// 二分探索で解を探す
	left = 0; right = N - 1;
	while (left <= right) {
		center = (left + right) / 2;
		if (needs(center))
			right =  center - 1;
		else
			left = center + 1;
	}

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

int needs(int index) {
	int i, j;

	// 最初と飛ばすの行のみ初期化
	for (j = 0; j < K; j++) {
		dp[0][j] = 0;
		dp[index][j] = 0;	
	}
	if (index != 0) dp[0][a[0]] = 1;
	dp[0][0] = 1;

	for (i = 1; i < N; i++) {
		for (j = 0; j < K; j++) {
			dp[i][j] = dp[i - 1][j];
			if (i != index && j - a[i] >= 0)
				dp[i][j] |= dp[i - 1][j - a[i]];
		}
	}

	for (j = K - a[index]; j < K; j++) {
		if (dp[N - 1][j] == 1)
			return 1;
	}
	return 0;
}

Measured memory_bytes: 98044
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


C.sort()
C.reverse()
AB =[0]*(X*Y)

for i in range(X):
    for j in range(Y):
        AB[i*Y+j] =  A[i] + B[j]
        
AB.sort()
AB.reverse()
K2 = min(K,X*Y)
AB = AB[0:K2]
ABC = [0] * (K2*Z)
for i in range(K2):
    for j in range(Z):
        ABC[i*Z+j] = AB[i] + C[j]
        
ABC.sort()
ABC.reverse()
ABC = ABC[0:K]
for i in ABC:
    print(i)
        

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

int main(){
	char str0[11], str1[11], str2[11];

	for(int i = 0; i < 11; ++i){
		str0[i] = 0;
		str1[i] = 0;
		str2[i] = 0;
	}

	cin >> str0 >> str1 >> str2;

	int flag0, flag1;

	for(int i = 0; i < 11; ++i){
		if(str0[i] == 0){
			flag0 = i - 1;
			break;
		}
	}

	for(int i = 0; i < 11; ++i){
		if(str1[i] == 0){
			flag1 = i - 1;
			break;
		}
	}
	
	if(str0[flag0] == str1[0] && str1[flag1] == str2[0])
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}

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

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

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

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

int main(){
    int n; cin>>n;
    string s1, s2; cin>>s1>>s2;

    vector<int> domino(60);
    int i=0, j=0;
    while(i<n){
        if(s1[i] == s1[i+1]){
            domino[j]=2;
            i += 2;
        }
        else{
            domino[j]=1;
            i++;
        }
        j++;
    }
    
    ll ans=1;
    for(int i=0; i<j; i++){
        if(i == 0){
            if(domino[i] == 1){
                ans *= 3;
            }
            else{
                ans *= 6;
            }
        }
        else{
            if(domino[i-1] == 1){
                ans *= 2;
            }
            else if(domino[i] == 2){
                ans *= 3;
            }
        }
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	char str[21];
	int i, a;
	gets(str);
	for(i = 0; str[i]; i++);
	for(--i; i >= 0; i--){
		printf("%c", str[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    ll mi = min(4 * Q, min(2 * H, S));
    if (2 * mi < D) {
        print(mi * N);
    } else {
        print((N / 2) * D + (N % 2) * mi);
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n, m = map(int, input().split())
ans = []
i = 1
while i < m + 2 - i:
    ans.append([i, m + 2 - i])
    i += 1
i = m + 2
while i < 3 * m + 3 - i:
    ans.append([i, 3 * m + 3 - i])
    i += 1
for i in ans:
    print(*i)


Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#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 ffor for(;;)
#define ub upper_bound
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#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)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
vector< ll > divisor(ll n) {  //約数の列挙
  vector< ll > ret;
  for(ll 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);
}
int main(){
    int n;
    std::cin >> n;
    int ans=0;
    rrep(i,1,n+1){
        if(i%2==0)continue;
        std::vector<ll> di=divisor(i);
        if(di.size()==8)ans++;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
num = int(input())
mtlist = [int(x) for x in input().split()]
mtmax = 0
view = 0

for i in range(num):
  if mtlist[i] > mtmax:
    mtmax = mtlist[i]
    view = view +1
  elif mtlist[i] == mtmax:
    view = view +1
  else:
    continue
    
print(view)

Measured memory_bytes: 3060
S=list(input())

Dict={}
Dict["a"]=1
Dict["b"]=1
Dict["c"]=1
for i in range(len(S)):
    Dict[S[i]]+=1
if(("".join(S)=="aa")|("".join(S)=="bb")|("".join(S)=="cc")):
    print("NO")
    exit()

if(len(S)<3):
    print("YES")
    exit()

if((max(Dict.values())-min(Dict.values()))>1):
    print("NO")
else:
    print("YES")  

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n;
	cin>>n;
	for(int i=n;;i++){
		string s=to_string(i);
		int count=0;
		REP(j,s.size()-1){
			if(s[j]==s[j+1]){
				count++;
			}
		}
		if(count==s.size()-1){
			cout<<s<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 998244353;
                int arr[MAX];
            //Global Variables



                int main()
                {
                        int n;
                        scanf("%d",&n);

                        string s;
                        cin>>s;
                        int mx = 0 , val = 0;
                        for(int i = 0 ; i < n ; i++)
                        {
                            if(s[i] == 'I')
                            {
                                val++;
                            }else val--;
                            mx = max(mx , val);
                        }
                        printf("%d\n",mx);
                }


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

//#define HOST
#ifdef HOST
#include"data_structure.h"
#include"common_algorithm.h"
#endif



ll inf = 1e9+7;


template <typename T>
vector<vector<T> > input_graph(T array_num, T edge_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this input_graph function can only be in type \"int\" or \"long long int\"!\n");
    vector<vector<T> > a(array_num, vector<T>());
    for(T i = 0; i < edge_num; i++)
    {
        T d1, d2;
        cin >> d1 >> d2;
        a.at(d1-1).emplace_back(d2-1);
        a.at(d2-1).emplace_back(d1-1);
    }

    return a;
}

template <typename T>
vector<T> input_vector(T array_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this input_vector function can only be in type \"int\" or \"long long int\"!\n");
    vector<T> a(array_num, 0);
    for(T i = 0; i < array_num; i++)
    {
        cin >> a.at(i);
    }

    return a;
}


int main() {
    int n, k, d;
    cin >> n >> k >> d;
    if(n == k && k == d)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int ans = 0;
	if (N > K) {
		ans += K*X;
		ans += (N - K)*Y;
	}
	else {
		ans = N*X;
	}
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
if N == 1:
    print(1)
    exit()
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()


# 最初(N//2)**2にしていた、それぞれの場合の数ではなくなってしまう
print((2**(N // 2))%(10**9+7))

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,u,v;
int d[100004],dp[100004],f[100004],fr[100004];
vector<int>g[100004];
int main(){
	read(n),read(u),read(v);
	for (int i=0;i<n-1;i++){
		int x,y;read(x),read(y);
		g[x].push_back(y),g[y].push_back(x);
	}
	for (int i=0;i<100004;i++) d[i]=dp[i]=1e9;
	queue <int> que;
	d[u]=0;
	que.push(u);
	while(!que.empty()){
		int x=que.front();que.pop();
		for (int i=0;i<g[x].size();i++) if (d[g[x][i]]>d[x]+1){
			d[g[x][i]]=d[x]+1;
			f[g[x][i]]=x;
			que.push(g[x][i]);
		}
	}
	dp[v]=0;
	que.push(v);
	while(!que.empty()){
		int x=que.front();que.pop();
		for (int i=0;i<g[x].size();i++) if (dp[g[x][i]]>dp[x]+1){
			dp[g[x][i]]=dp[x]+1;
			fr[g[x][i]]=x;
			que.push(g[x][i]);
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++){
		if (d[i]==dp[i]){
			if (fr[i]==f[i]) continue;
			ans=max(ans,d[i]);
		}
		if (d[i]>dp[i]) continue;
		if (g[i].size()!=1){
			ans=max(ans,dp[i]);
		}else{
			ans=max(ans,dp[i]-1);
		}
	}
	write(ans);
}

Measured memory_bytes: 7424
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	const int MAX = (1 << 15);
	static bool is_prime[MAX + 1];
	fill(is_prime + 2, is_prime + (MAX + 1), true);
	for (int i = 2; i * i <= MAX; ++i)
		if (is_prime[i])
			for (int j = i * 2; j <= MAX; j += i)
				is_prime[j] = false;
	int n;
	while (scanf("%d", &n), n)
	{
		int res = 0;
		for (int i = 2; i <= n - i; ++i)
			if (is_prime[i] && is_prime[n - i])
				++res;
		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

bool check_even(std::string &s) {
	int len_ss = s.size() / 2;
	std::string s1 = s.substr(0, len_ss);
	std::string s2 = s.substr(len_ss, len_ss);
	if(s1 == s2) return true;
	else return false;
}

int main(void) {
	// in
	std::string s;
	std::cin >> s;

	// loop
	while(s.size() > 0) {
		s.erase(s.end() - 2, s.end());
		bool is_even = check_even(s);
		if(is_even) break;
	}

	// out
	std::cout << s.size() << std::endl;

	return 0;
}


Measured memory_bytes: 256
from math import floor

def parse():
  return map(int, input().split(" "))

def main():
  A, B, N = parse()
  
  x = B - 1 if B - 1 <= N else N
  print(floor((A * x) / B) - A * floor(x / B))
  exit(0)

  limit_N = 5000000
  N = limit_N if N > limit_N else N

  x = 0
  max_val = floor((A * x) / B) - A * floor(x / B)

  for x in range(1, N + 1):
    val = floor((A * x) / B) - A * floor(x / B)
    if max_val < val:
      max_val = val

  print(max_val)


if __name__ == "__main__":
  main()

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t)
{
    std::ostringstream os;
    os << t;
    return os.str();
}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a << endl;
    }
    return 0;
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll ans = 0;
    for ( int i = 1; i < N; i++ ) {
        ans += A[i-1] / 2;
        A[i-1] %= 2;
        ans += min(A[i-1],A[i]);
        A[i] -= min(A[i-1],A[i]);
    }
    ans += A[N-1] / 2;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let Y: u32 = read();

    for x in 0..n+1 {
        for y in 0..n+1-x {
            for z in 0..n+1-x-y {
                if x+y+z == n {
                    if 10000*x+5000*y+1000*z == Y {
                        println!("{} {} {}", x, y, z);
                        return;
                    }
                }
            }
        }
    }

    println!("-1 -1 -1");
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a;
	cin >> a;
	bool ns = false;
	for(ll i=1; i<=9; i++)
		for(ll j=1; j<=9; j++)
			if(i*j == a)
				ns = 1;
	if(ns)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

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

    if(D == 0)
        ans = N;
    else if(D == 1)
        ans = 100 * N;
    else if(D == 2)
        ans = 10000 * N;

    if(D == 0 && N == 100)
        ans += 1;
    if(D == 1 && N == 100)
        ans += 100;
    if(D == 2 && N == 100)
        ans += 10000;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        int cnt = 0;
        for ( int i = 0; i < 3; i++){
            String c = str.substring(i,i+1);
            if (c.equals("R")){
                cnt = cnt + 1;
            }
        }
        if ( str.equals("RSR")) {
                cnt = 1;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35508
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;
//union find
const int N = 100001;

int par[N];
int rnk[N];
int weight[N];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        weight[i] = 1;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]){
        weight[find(y)] += weight[find(x)];
        par[x] = y;
    }
    else{
        weight[find(x)] += weight[find(y)];
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}

set<int> G[100100];

/*----------------------------------------------------------------*/
signed main(){

	int n,m,k;
	cin >> n >> m >> k;

	init(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		unite(a-1,b-1);
		G[a-1].insert(b-1);
		G[b-1].insert(a-1);
	}

	int ans[100100] = {};
	rep(i,n){
		ans[i] = weight[find(i)] - G[i].size();
	}

	rep(i,k){
		int c,d;
		cin >> c >> d;
		c--;d--;
		if(same(c,d) && G[c].find(d) == G[c].end()){
			ans[c]--;
			ans[d]--;
		}
	}
	rep(i,n)cout << ans[i]-1 << " ";
	cout << endl;


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc157.contest.atcoder.jp/tasks/abc157_d

Measured memory_bytes: 20768
#include<bits/stdc++.h>
using namespace std;
int n,s[1000003],t[1000003],tmp,x;
long long prime[1100000],tot,d[1100003];
void find()
{
    for (long long i=2;i<=1100000;i++)
    {
        if (d[i]==0)
        {
            prime[++tot]=i;
            d[i]=i;
        }
        for (long long j=1;j<=tot&&prime[j]<=d[i];j++)
        {
            if (prime[j]*i<=1100000)d[prime[j]*i]=prime[j];else break;
        }
    }
}
int main()
{
    find();
    scanf("%d",&n);
    scanf("%d",&tmp);
    s[tmp]++;
    x=tmp;
    for (int i=2;i<=n;++i)
    {
        scanf("%d",&tmp);
        x=__gcd(tmp,x);
        s[tmp]++;
    }
    if(x!=1)
    {
        printf("not coprime\n");
        return 0;
    }
    for(int i=2;i<=1000000;++i)
    {
        if(s[i]==0)continue;
        if(s[i]>1)
        {
            printf("setwise coprime\n");
            return 0;
        }
        int lst=0,tmp=i;
        while(d[tmp]!=0)
        {
            if(d[tmp]==lst)
            {
                tmp/=d[tmp];
                continue;
            }
            t[d[tmp]]++;
            lst=d[tmp];
            if(t[d[tmp]]>1)
            {
                printf("setwise coprime\n");
                return 0;
            }
            tmp/=d[tmp];
        }
    }
    printf("pairwise coprime\n");
    return 0;
}


Measured memory_bytes: 20844
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    for(int i=0; i<N-1; i++){
        if(i<K){
            cout << S << ' ';
        }else if(S==1000000000){
            cout << S-1 << ' ';
        }else{
            cout << S+1 << ' ';
        }
    }
    if(K==N){
        cout << S << endl;
    }else if(S==1000000000){
        cout << S-1 << endl;
    }else{
        cout << S+1 << endl;
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int x, y;
  cin >> x >> y;
  if ((y - 2 * x) % 2 == 0 && y - 2 * x >= 0 && y % 2 == 0 &&
      2 * x - y / 2 >= 0) {
    cout << "Yes\n";
    return;
  }
  cout << "No\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static int N, W;
    static int[] w;
    static int[] v;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        W = Input.NextInt();
        w = new int[N];
        v = new int[N];
        foreach (var i in Enumerable.Range(0, N))
        {
            var wv = Input.LineInt();
            w[i] = wv[0];
            v[i] = wv[1];
        }

        dp = new Dictionary<NumberAndWeight, int>(); 
        Console.WriteLine(F(new NumberAndWeight(N, W)));
    }

    class NumberAndWeight
    {
        public NumberAndWeight(int n, int w)
        {
            Number = n;
            Weight = w;
        }

        public int Number;
        public int Weight;

        // override object.Equals
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }

            var o = (NumberAndWeight)obj;
            return this.Number == o.Number && this.Weight == o.Weight;
        }

        public override int GetHashCode()
        {
            return Number << 8 + Weight;
        }
    }

    static Dictionary<NumberAndWeight, int> dp;

    static int F(NumberAndWeight nw)
    {
        if (dp.ContainsKey(nw))
            return dp[nw];

        int newValue;
        if (nw.Number == 0)
        {
            newValue = 0;
        }
        else
        {
            newValue = F(new NumberAndWeight(nw.Number - 1, nw.Weight));
            var newWeight = nw.Weight - w[nw.Number - 1];
            if (newWeight >= 0)
            {
                var b = F(new NumberAndWeight(nw.Number - 1, newWeight)) + v[nw.Number - 1];
                newValue = Math.Max(b, newValue);
            }
        }
        return dp[nw] = newValue;
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 29788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
long modpow(long x,int n,long p){
	int i=0;long res=1;
	while(n>=(1<<i)){
		if(n&(1<<i)) (res*=x)%=p;
		i++;
		x=(x*x)%p;
	}return res;
}
int main(){
	int N;cin>>N;
	int cnt[N] = {}; int a;
	rep(i,0,N){
		cin>>a; cnt[a]++;
		cnt[abs(N - 2*i - 1)]--;
	}
	rep(i,0,N)if(cnt[i]){
		cout<<0<<endl;
		return 0;
	}
	cout<<modpow(2,N/2,mod)<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());
		int[] x = new int[n];

		for(int i = 0 ; i < n ; i++) {
			x[i] = Integer.parseInt(sc.next());

		}


		int ans = (1 << 31) - 1;
		for(int i = 1 ;  i <= 100 ;  i++ ) {

			int sum = 0;
			for(int j = 0 ;  j < n ;  j++ ) {
				int tmp = Math.abs(x[j] - i);
				sum += tmp * tmp;
			}
			ans = Math.min(ans, sum);

		}
		System.out.println(ans);
	}



}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a=1;
  cin >>N;
  vector<int>P(N,0),Q(N,0),S(N,0),X(N,0),Y(N,0);
  for(int i=1; i<=N; i++){
    a*=i;
    S[i-1]=a;
    X[i-1]=i;
  }
  Y=X;
  for(int i=0; i<2; i++){
    for(int j=0; j<N; j++){
      int x;
      cin >>x;
      if(i==0) P[j]=x;
      if(i==1) Q[j]=x;
    }
  }
  int pscore=1, qscore=1;
  for(int i=0; i<N; i++){
    sort(Y.begin(), Y.end());
    auto IT=lower_bound(Y.begin(), Y.end(), P[i]);
    int m=IT-Y.begin();
    for(int j=0; j<N; j++){
      if(Y[j]==P[i]) Y[j]=9;
    }
    pscore+=S[N-2-i]*m;
  }
  Y=X;
  for(int i=0; i<N; i++){
    sort(Y.begin(), Y.end());
    auto IT=lower_bound(Y.begin(), Y.end(), Q[i]);
    int m=IT-Y.begin();
    for(int j=0; j<N; j++){
      if(Y[j]==Q[i]) Y[j]=9;
    }
    qscore+=S[N-2-i]*m;
  }
//  cout<<"ps:"<<pscore<<" qs:"<<qscore<<endl;
  int ans=abs(pscore-qscore);
  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n;
ll cacu(ll n){
    return n*(n-1)/2;
}
int main(){
    cin>>n;
    vector<int> v(n,0);
    vector<int> a(n,0);
    rep(i,n) {
        int k;
        cin>>k;
        k--;
        v[k]++;
        a[i]=k;
    }

    ll sum=0;
    rep(i,n){
        sum+=cacu(v[i]);
    }
    //rep(i,10) cout<<v[i]<<" ";
    //cout<<endl;
    //cout<<sum<<endl;
    //cout<<endl;
    rep(i,n){
        ll ans = sum;
        ans -= cacu(v[a[i]]);
        ans += cacu(v[a[i]]-1);
        cout<< ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
 #define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= 1e19;
void solve(){
 int k,n;
 sl(k);sl(n);
 int arr[n];
 for(int i=0;i<n;i++){
	 sl(arr[i]);
 }
 sort(arr,arr+n);
 int ttl=0;
 for(int i=1;i<n;i++){
	 ttl=max(ttl,abs(arr[i]-arr[i-1]));
 }
 if(arr[0]==0){
	 ttl=max(ttl,abs(k-arr[n-1]));
 }
 else{
	 ttl=max(ttl,abs(k-arr[n-1]+arr[0]));
 }
 cout<<k-ttl<<endl;
 
}
 
signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


Measured memory_bytes: 1792
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
  u, v, c = map(int, input().split())
  e[u].append((v, c))
  e[v].append((u, c))

s = [1]
colour = [0] * (N + 1)
colour[1] = 1
bipartite = 1
while len(s):
  x = s.pop()
  for y, _ in e[x]:
    if colour[y]:
      if colour[y] == colour[x]: bipartite = 0
      continue
    colour[y] = colour[x] % 2 + 1
    s.append(y)
#print(colour, bipartite)
inf = 10 ** 10

def check(x):
  nums = [inf] * (N + 1)
  nums[1] = x
  s = [1]
  while len(s):
    x = s.pop()
    for y, c in e[x]:
      if nums[y] == inf:
        nums[y] = c - nums[x]
        s.append(y)
      elif nums[y] != c - nums[x]:
        return False
  if min(nums) > 0: return True
  else: return False

if bipartite:
  nums = [inf] * (N + 1)
  nums[1] = 1
  s = [1]
  while len(s):
    x = s.pop()
    for y, c in e[x]:
      if nums[y] == inf:
        nums[y] = c - nums[x]
        s.append(y)
  d = 0
  for x in range(2, N + 1):
    if nums[x] > 0: continue
    if colour[x] == 1: d = max(d, 1 - nums[x])
    if colour[x] == 2: d = inf
  if check(1 + d):
    ok = 1 + d
    ng = inf
    while ng - ok > 1:
      m = (ok + ng) // 2
      if check(m): ok = m
      else: ng = m
    print(ok - d)
  else: print(0)
else:
  nums = [inf] * (N + 1)
  nums[1] = 1
  s = [1]
  ps = []
  while len(s):
    x = s.pop()
    for y, c in e[x]:
      if nums[y] == inf:
        nums[y] = c - nums[x]
        s.append(y)
      elif colour[y] == colour[x]:
        ps.append((y, c - nums[x]))
  #print(ps, nums)
  
  y, c = ps[0]
  d = 0
  if colour[y] == 1: d = c - nums[y]
  if colour[y] == 2: d = nums[y] - c

  if d % 2 or (d < 0):
    print(0)
    exit(0)
  if check(1 + d // 2): print(1)
  else: print(0)


Measured memory_bytes: 121344
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;
 
#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)
 
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;
 
int main(){
  int N, K, T, U, V, L;
  cin >> N >> K >> T >> U >> V >> L;
  vector<int> D(N);
  REP(i, N) cin >> D[i];
 
 
  double res = 0;
  double pos = 0;
  int carrot = 0;
  int i = 0;
  while(i < N){
    // move to a next carrot
    res += (D[i] - pos) / U;
    pos = D[i++];
    carrot++;
 
    while(carrot > 0){
      // eat carrot
      // cout << pos << " " << res << endl;      
      carrot--;
      double next = min(pos + T * V, (double)L);;
 
      while(i < N && D[i] < next){
        carrot++;
        i++;
      }
 
      if(carrot > K){
        carrot = K + 1;
        res += (D[i-1] - pos) / V;
        pos =  D[i-1];
      }else{
        res += (next - pos) / V;
        pos = next;
      }
    }
    assert(carrot == 0);
  }
  cout << fixed << setprecision(20) << res + (L - pos) / U << endl;
   
  return 0;
}

Measured memory_bytes: 1272
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var l = next();
  return l*l*l/27;
}

Measured memory_bytes: 21192
n, m = map(int, raw_input().strip().split())

f = dict()

for i in xrange(m):
    s, c = map(int, raw_input().strip().split())
    try: f[s - 1].append(c)
    except: f[s - 1] = [c]

for key in f:
    f[key] = list(set(f[key]))
    if len(f[key]) > 1:
        print -1
        exit()

for i in xrange(1000):
    X = str(i)

    if len(X) != n:
        continue

    flag = 0
    for key in f:
        if key >= len(X):
            flag = 1
            break
        if X[key] != str(f[key][0]):
            flag = 1
            break

    if flag == 0 and len(X) == n:
        print X
        exit()

print -1
    


Measured memory_bytes: 28780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main(){int n,k,q; cin>>n>>k>>q; if(q<k){rep(i,n)cout<<"Yes"<<endl; return 0;}vector<int> p(n,0);rep(i,q){int a;cin>>a,a--,p[a]++;}rep(i,n)cout<<((p[i]<=q-k)?"No":"Yes")<<endl;}

Measured memory_bytes: 3764