akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll A, B;
    in >> A >> B;
    ll ans = 0;

    // solution here
    int answers[3] = {1,1,1};
    answers[A-1] = 0;
    answers[B-1] = 0;
    REP(i, 3) {
        if (answers[i] > 0) {
            ans = i+1;
            break;
        }
    }
    out << ans << endl;
    debug(ans);
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
s = input()
n = len(s) + 1
a = [0 for i in range(n)]
for i in range(n - 1):
  if s[i] == '<':
    a[i + 1] = max(a[i + 1], a[i] + 1)
for i in reversed(range(n - 1)):
  if s[i] == '>':
    a[i] = max(a[i], a[i + 1] + 1)
ans = sum(a)
print(ans)


Measured memory_bytes: 24100
#include<stdio.h>
int main(void){
    int d,i,s=0;
    while(scanf("%d",&d)!=EOF){
        i=0;
        s=0;
        while(i<600){
            s+=d*i*i;
            i+=d;
        }
        /*if(d==600){
            s=d*600*600;
        }
        */
        printf("%d\n",s);
    }
return 0;
}

Measured memory_bytes: 596
n, m = [int(i) for i in input().split()]

a = [int(input()) for i in range(m)]

a.append(n + 1)
a.insert(0, -1)
b = [i-j-1 for i,j in zip(a[1:], a[:-1])]

mm = max(b) - 1

step = [0,1]

for i in range(mm):
	step.append(step[-1] + step[-2])

mul = 1
for i in b:
	mul *= step[i]
	
print(mul%1000000007)

Measured memory_bytes: 460020
package main
import "fmt"

var (k,x  int)
func main() {
	fmt.Scan(&k,&x)


	res := 0
	for i:=0;i <=k; i++ {
		if x-i <= 2*k && x-i >= 0 {
			for j := 0; j <= k; j++ {
				if x-i-j <= k && x-i-j >= 0 {
					res += 1
				}
			}
		}
	}
	fmt.Println(res)
}

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

int main() {
	// your code goes here
	int m,n;
	cin>>m>>n;
	
	char obstacleGrid[m][n];
	
	for(int i=0;i<m;i++){
	    for(int j=0;j<n;j++){
	        cin>>obstacleGrid[i][j];
	    }
	}
	
	long long dp[m][n];
	
	dp[m-1][n-1] = 1;
	
       for(int i=m-2;i>=0;i--)
        {
            if(obstacleGrid[i][n-1]!='#')
            {
                dp[i][n-1]=dp[i+1][n-1];
            }
            else
            {
                dp[i][n-1]=0;
            }
        }
        
        for(int i=n-2;i>=0;i--)
        {
           if(obstacleGrid[m-1][i]!='#')
            {
                dp[m-1][i]=dp[m-1][i+1];
            }
            else
            {
                dp[m-1][i]=0;
            } 
        }
        
        for(int i=m-2;i>=0;i--)
        {
            for(int j=n-2;j>=0;j--)
            {
                if(obstacleGrid[i][j]!='#')
                {
                    long long x = (dp[i+1][j])%mod;
                    long long  y = (dp[i][j+1])%mod;
                    
                    dp[i][j]=(x+y)%mod;
                }
                else
                {
                    dp[i][j]=0;
                }
            }
        }
        
	
	cout<<dp[0][0]<<endl;
	
	return 0;
}


Measured memory_bytes: 12368
// amigos y no más
// dile a la jardinera que traigo flores
 
// += O(logn) ; + = O(n)
 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define MOD 998244353LL
#define MOD1 1000000009LL
#define LIM 262150
#define FORN(i,j,n) for(int i=j; i<n;i++) 
#define FOR(i,n) FORN(i,0,n)
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef tree<int,int,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

double L;

bool checkPal(string s){
	for(int i=0; i<=s.size()/2;i++)
		if(s[i] != s[s.size()-1-i]) return false;
	
	return true;
}

int main() {
	fastio;
	cin>>L;
	cout<<fixed<<setprecision(6)<<(L/3.0)*(L/3.0)*(L/3.0)<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double x[10],y[10];
double sum=0;
int n;
bool used[10];
int ans[10];
void dfs(int u)
{
    if(u == n + 1)
    {
        for (int i = 1;i <= n-1;i ++){
        	sum+=sqrt((x[ans[i]]-x[ans[i+1]])*(x[ans[i]]-x[ans[i+1]])+(y[ans[i]]-y[ans[i+1]])*(y[ans[i]]-y[ans[i+1]]));
        }
        return ;    
    }
    for (int i = 1;i <= n;i ++)
        if(used[i] == 0)
        {
            ans[u] = i;
            used[i] = 1;
            dfs(u + 1);
            used[i] = 0;
        }
}
int main(){

	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
	}
	dfs(1);
	int s=1;
	for(int i=1;i<=n;i++){
		s*=i;
	}
	cout<<fixed<<setprecision(10)<<sum/s<<endl;;
}

Measured memory_bytes: 256
S = gets.chomp

def palindrom?(s)
  s == s.reverse
end

result = palindrom?(S) && palindrom?(S[0..((S.size - 1) / 2 - 1)]) && palindrom?(S[((S.size + 3) / 2 - 1)..-1])

if (result) then
  puts "Yes"
else
  puts "No"
end

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

int main(){
    int n;  cin >> n;
    vector<int>h(n);
    rep(i, n)   cin >> h[i];
    vector<int>dp(n);
    rep(i, n){
        if(!i)  continue;
        if(i == 1){
            dp[i] = abs(h[i] - h[i-1]);
        }else{
            dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
}


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

int main(){
  int N;
  cin>>N;
  
  vector<string> S(N);
  for(int i=0;i<N;i++){cin>>S.at(i);}
  
  sort(S.begin(),S.end());
  
  long long int ans;
  for(int i=0;i<S.size();i++){
    if(i==0){
      ans=1;
      continue;
    }
    if(S.at(i-1)!=S.at(i))ans++;
  }
  cout<<ans<<endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  int ans = 0; int tmp = 0;
  REP(i, S.size()) {
    if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
      tmp++;
    } else {
      if(ans < tmp) ans = tmp;
      tmp = 0;
    }
  } 
  if(ans < tmp) ans = tmp;
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

int main()
{
	fastIO;
	string s;
	cin >> s;
	map<string,int> m;
	m["SSS"] = 0;
	m["RSS"] = 1;
	m["SRS"] = 1;
	m["SSR"] = 1;
	m["RSR"] = 1;
	m["RRS"] = 2;
	m["SRR"] = 2;
	m["RRR"] = 3;

	cout << m[s] << endl;

	return 0;
}

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

int main() {
    int x,y;
    cin >> x >> y;
    int N[12] = {0,2,0,1,0,1,0,0,1,0,1,0};
    if(N[x-1] == N[y-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<string, int> Psi;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(int (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(int (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define FST first
#define SND second
signed main(){
    int N, M; cin >> N >> M;
    vector<P> A(N);
    REP(i, N){
        int x, y; cin >> x >> y;
        A[i] = P(x, y);
    }
    sort(ALL(A));
    lint res = 0;
    int i = 0;
    while(M and i<N){
        if(M>= A[i].second){
            M-=A[i].second;
            res += A[i].first * A[i].second;
        }
        else{
            res += M * A[i].first;
            M = 0;
        }
        i++;
    }
    cout << res << endl;
    return 0;
    
}

Measured memory_bytes: 1792
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf8"));

function main(input) {
  const s = input;

  let ans = "";
  for (let i = 0; i < s.length; i++) {
    if (i % 2 === 0) {
      ans += s[i];
    }
  }
  console.log(ans);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

bool ok(string &s, string &t){
  int now=0;
  for(int i=0;i<s.length();i++){
    if(s[i]==t[now]){
      now++;
      if(now==t.length()) return true;
    }
  }
  return false;
}

int main(){
  string s,t;
  cin >> s >> t;
  vector<string> tt(100,"");
  for(int i=1;i<100;i++){
    tt[i]=tt[i-1];
    for(int j=0;j<t.length();j++){
      tt[i]+=string(1,t[j]);
      tt[i]+=tt[i-1];
      if(tt[i].length()>s.length()){
        cout << i-1 << endl;
        return 0;
      }
    }
    // cout << tt[i] << endl;
    if(!ok(s,tt[i])){
      cout << i-1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3704
e1, e2, e3, e4 = map(int, input().split())
E = [e1, e2, e3, e4]

e = set(E)
e_list = list(e)

if len(e) == 2 :
    if E.count(e_list[0]) == 2 :
        print("yes")
    else :
        print("no")
else :
    print("no")



Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
	void run(){
      Scanner s = new Scanner(System.in);
      while(true){
        int x = s.nextInt();
        int y = s.nextInt();
        int p = s.nextInt();
        if (x == 0 && y == 0 & p == 0) break;
        int max = 0;
         for(int i = 1; i < p; i++) {
           for (int j = 1; j < p; j++){
              int checkNum = i * (100 + x) / 100 + j * (100 + x) / 100;
              if( checkNum ==  p){
                  int onceNum = (i * (100 + y) / 100) + (j * (100 + y) / 100);
                  max = Math.max(max, onceNum);
              }
           }
         }
         System.out.println(max);
       }
	}

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

Measured memory_bytes: 29248
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int i;
    int deg[n+5] = {};
    FOR0(i, n-1)
    {
        int temp;
        cin>>temp;
        temp--;
        deg[temp]++;
    }
    FOR0(i, n) cout<<deg[i]<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << ((H - h) * (W - w)) << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

  bool yoko[4][5];
  bool tate[5][4];
  REP(i,9) {
    char x;
    if (i%2==0)
      REP(j,4) {
        cin >> x;
        yoko[j][i/2] = (x=='1');
      }
    else
      REP(j,5) {
        cin >> x;
        tate[j][i/2] = (x=='1');
      }
  }
  int x=0,y=0;
  int dir = 0;
  char ss[4] = {'R','U','L','D'};
  x++;
  while(true) {
    cout << ss[dir];
    if (x==0&&y==0) break;
    if (dir == 0) {
      if (y>0&&tate[x][y-1]) {
        dir = 1;
        y--;
      } else if (x<4&&yoko[x][y]) {
        x++;
      } else if (y<4&&tate[x][y]) {
        dir = 3;
        y++;
      } else {
        dir = 2;
        x--;
      }
    } else if (dir == 1) {
      if (x>0&&yoko[x-1][y]) {
        dir = 2;
        x--;
      } else if (y>0&&tate[x][y-1]) {
        y--;
      } else if (x<4&&yoko[x][y]) {
        dir = 0;
        x++;
      } else {
        dir = 3;
        y++;
      }
    } else if (dir == 2) {
      if (y<4&&tate[x][y]) {
        dir = 3;
        y++;
      } else if (x>0&&yoko[x-1][y]) {
        x--;
      } else if (y>0&&tate[x][y-1]) {
        dir = 1;
        y--;
      } else {
        dir = 0;
        x++;
      }
    } else if (dir == 3) {
      if (x<4&&yoko[x][y]) {
        dir = 0;
        x++;
      } else if (y<4&&tate[x][y]) {
        y++;
      } else if (x>0&&yoko[x-1][y]) {
        dir = 2;
        x--;
      } else {
        dir = 1;
        y--;
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
double A, T;
double getDif(unsigned int x) {
    double temp =  T - x * 0.006;
    return (A > temp) ? A - temp : temp - A;
}

int main() {
    unsigned int N;
    unsigned int h;

    cin >> N >> T >> A;
    unsigned int i;
    unsigned int ans_ind = 1;
    cin >> h;
    double diff = getDif(h);


    for (i = 2;i <= N; i++) {
        cin >> h;
        double temp = getDif(h);
        if (temp < diff) {
            ans_ind = i;
            diff = temp;
        }        
    }
    cout << ans_ind << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

class AffineCipher
{
public:
	string decode (string, vector <int> );
	vector<int> make_alpha (void);
private:
	int gcd (int, int );
	bool decide_variable (int, int, string );
	bool check_code (string );
};

int AffineCipher::gcd (int a, int b)
{
	if (a > b){
		swap(a,b);
	} // end if
	while (b % a != 0){
		b = b % a;
		if (a > b){
			swap(a,b);
		} // end if
	} // end while

	return a;
}
bool AffineCipher::decide_variable (int a, int b, string str )
{
	set <char> code; 
	set <char> source;
	int i;

	for (i = 0; i < str.length(); ++i){
		if (isalpha(str[i]) ){
			source.insert (str[i]);
		} // end if
	} // end for
	set <char>::iterator it = source.begin();

	for (; it != source.end(); ++it){
		char c = (a*((*it) - 'a') + b) % 26 + 'a';
		if (code.count (c) ){
			return false;
		}else{
			code.insert (c);
		} // end if
	} // end for

	return true;
}
bool AffineCipher::check_code (string str)
{
	const string keyword[] = { "this", "that" };
	int i;

	for (i = 0; i < sizeof(keyword)/sizeof(keyword[0]); ++i){
		if (str.find(keyword[i]) != string::npos ){
			return true;
		} // end if
	} // end for

	return false;
}
string AffineCipher::decode (string str, vector <int> alpha)
{
	int len = str.length();
	int a, b;
	multimap <int, int> table;
 	int i;

	for (i = 0; i < alpha.size(); ++i){		
		a = alpha[i];
		for (b = 0; b < 26; ++b){
			if (!decide_variable (a, b, str ) ){
				continue;
			}else{
				table.insert (make_pair (a, b ) );
			} // end if
		} // end for
	} // end for

	string res = "";
	multimap <int, int>::iterator it = table.begin();
	for (; it != table.end(); ++it){
		a = (*it).first;
		b = (*it).second;
		res = "";
		for (i = 0; i < len; ++i){
			char c = 0;
			if (isalpha(str[i] ) ){
				c = (a*(str[i] - 'a') + b) % 26 + 'a';
			}else{
				c = str[i];
			} // end if
			res += c;
		} // end for
		if (!check_code (res) ){
			continue;
		}else{
			break;
		} // end if
	} // end for

	return res;
}
vector <int> AffineCipher::make_alpha (void)
{
	vector <int> alpha;
	int i;

	for (i = 1; i < 26; ++i){
		if (gcd(i, 26) == 1){
			alpha.push_back(i);
		} // end if
	} // end for

	return alpha;
}
	
int main()
{
	AffineCipher AC;
//	cut here before submit 
//	freopen("testcase.ac", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	
	vector <int> alpha = AC.make_alpha();
	int i;

	for (i = 0; i < n; ++i){
		string res = "";
		getline (cin, str );
		res = AC.decode (str, alpha );
		cout << res << endl;
	} // end for
		
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll ans[2001][2001];// [from][to]
ll ret[2001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N; cin >> N;
    ll x; cin >> x;
    vector<ll> a;
    rep(i,N){
        ll inp; cin >> inp;
        a.pb(inp);
    }

    rep(i,N)rep(j,N){
        if(j == 0) ans[i][j] = a[i];
        else ans[i][j] = min(ans[i][j-1], a[(i+j)%N]);
    }
    
    rep(i,N)rep(j,N){
        ret[j] += ans[i][j];
    }
    rep(i,N) ret[i] += (x*i);
    
    ll an = ret[0];
    rep(i,N){
        an = min(an, ret[i]);
    }
    cout << an << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 31616
import java.util.Scanner;

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

	int n=scanner.nextInt();
	Integer[] m=new Integer[n];
	int t=0;


	for(int j=0;j<n;j++) {
		int a=scanner.nextInt();
		m[j]=a;
	}

	for(int i=0;i<n;i++) {
		if((i+1)%2==1) {
			if(m[i]%2==1) {
				t=t+1;
			}
		}
	}

	System.out.println(t);


	 }
}

Measured memory_bytes: 35792
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2) {
		cout<<b-a<<endl;
	} else {
		cout<<a-b<<endl;
	}
}


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

int main(){
  string S;
  cin >> S;
  if("Sunny" == S){
    cout << "Cloudy" << endl;
  }
  if("Cloudy" == S){
    cout << "Rainy" << endl;
  }
  if("Rainy" == S){
    cout << "Sunny" << endl;
  }
}

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

double myround(double src, int n);

int main(void) {
	int A1, B1, E1, A2, B2, E2;
	double x, y;
	while(scanf("%d %d %d %d %d %d", &A1, &B1, &E1, &A2, &B2, &E2) == 6) {
		if(A1 == 0) {
			y = myround(1.0*E1/B1, -5);
			x = myround(1.0*(E2-B2*y)/A2, -5);
		} else if(B1 == 0) {
			x = myround(1.0*E1/A1, 5);
			y = myround(1.0*(E2-A2*x)/B2, -5);
		} else if(A2 == 0) {
			y = myround(1.0*E2/B2, -5);
			x = myround(1.0*(E1-B1*y)/A1, -5);
		} else if(B2 == 0) {
			x = myround(1.0*E2/A2, -5);
			y = myround(1.0*(E1-A1*x)/B1, -5);
		} else {
			x = myround(1.0*(E1*B2-B1*E2)/(A1*B2-B1*A2), -5);
			y = myround(1.0*(E2*A1-E1*A2)/(A1*B2-A2*B1), -5);
		}

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

double myround(double src, int n) {
    double dst;
    
    dst = src * pow(10, -n - 1);
    dst = (double)(int)(dst + 0.5);
    
    return dst * pow(10, n + 1);
}

Measured memory_bytes: 680
#include<stdio.h>

#define MAX 2000000

int H,A[MAX + 1];

void maxHeapify(int);

int main(){
  int i;

  scanf("%d",&H);
  for(i = 1;i <= H; i++){
    scanf("%d",&A[i]);
  }
  for(i = H/2; i >= 1; i--)
    maxHeapify(i);
  for( i = 1;i <= H; i++)
    printf(" %d",A[i]);
  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int l,r,tmp,large;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])large = l;
  else large = i;

  if(r <= H && A[r] > A[large])large = r;

  if(large != i){
    tmp = A[i];
    A[i] = A[large];
    A[large] = tmp;
    maxHeapify(large);
  }

}



Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read();
    vector<int> A(N), B(N);
    for (auto& a:A) {
        a = read();
    }
    for (int i = 0; i<N; i++) {
        B[0] += (i%2 == 0) ? A[i] : -A[i];
    }
    for (int j = 1; j<N; j++) {
        B[j] = 2 * A[j-1] - B[j-1];
    }
    if (B[0] == 2 * A[N-1] - B[N-1]) {
        for (int j = 0; j<N-1; j++) {
            printf("%d ", B[j]);
        }
        printf("%d\n", B[N-1]);
    }
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
	string S;

	cin >> S;

	int s = 0;
	bool flag = false;

	char str = S[s];

	for (int i = 1; i < (int)S.size(); ++i) {
		if (str != S[i]) {
			flag = true;
			break;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main()
{
	int i;
	char s[100001];
	cin >> s;

	int app[26] = {}; //zenbu0
	
	for (i=0; s[i] != '\0'; i++){
		app[s[i] - 'a'] = 1;
	}
	for (int i = 0; i < 26; ++i) {
		if (app[i]==0) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	cout << "None";
	return 0;
}


Measured memory_bytes: 384
from math import pi, acos, cos, sin

while 1:
    *S, = map(float, input().split())
    if all(e == -1 for e in S):
        break
    a, b, c, d = map(lambda x: pi * x / 180., S)
    x = 6378.1 * acos(sin(a)*sin(c) + cos(a)*cos(c)*cos(b-d))
    print(round(x))


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

int N, K;
vector<int> A;

bool check(int n){
	int con = 0;
	
	for(int i = 0; i < N; i++){
		if(A[i] < n) continue;
		
		con += (A[i])/ n;
	}

	
	return con <= K;
}

bool check2(int n){
	int con = 0;
	int z = 0;
	
	for(int i = 0; i < N; i++){
		if(A[i] < n) continue;
		
		con += (A[i])/ n;
		
		if(A[i] % n == 0) con--;
	}
	
	// if(z == N) return true;
	
	// return false;
	
	return con > K;
}

signed main(){
	cout<<fixed<<setprecision(10);
	

	
	cin>>N>>K;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	int l = 1, h = 1e10, m = 0;
	
	while(l + 1 < h){
		m = (l + h) / 2;
		
		if(!check(m)) {
			l = m;
		} else {
			h = m;
		}
	}
	
	// cout<<l<<endl;
	if(check2(l)) l++;
	
	cout<<l<<endl;
	
	return 0;
}

Measured memory_bytes: 4784
x = int(input())
if(x>=400 and x<600):
	print(8)
elif(x>=600 and x<800):
	print(7)
elif(x>=800 and x<1000):
	print(6)
elif(x>=1000 and x<1200):
	print(5)
elif(x>=1200 and x<1400):
	print(4)
elif(x>=1400 and x<1600):
	print(3)
elif(x>=1600 and x<1800):
	print(2)
else:
	print(1)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    double ans = 0.0;
    cin>>n;
    REP(i,n) {
        int a;
        cin>>a;
        ans += 1.0 / a;
    }
    ans = 1.0 / ans;
    //cout<<ans<<endl;
    printf("%9f\n", ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int ans = 180 * (N - 2);

        System.out.println(ans);

    }
}

Measured memory_bytes: 21972
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
int h,w,dp[59][59],ch[59][59],nx,ny,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
queue<pair<int,int>> que;
int main(void){
    while(1){
    cin>>w>>h;
    for(int i=0;i<59;i++){
        for(int j=0;j<59;j++){
            ch[i][j]=0;
        }
    }
    if(w==0&&h==0)return 0;
    for(int i=0;i<2*h-1;i++){
        if(i%2==0){
            for(int j=0;j<w*2-1;j++){
                if(j%2==0)dp[i][j]=0;
                else cin>>dp[i][j];
            }
        }
        else{
            for(int j=0;j<w*2-1;j++){
                if(j%2==0)cin>>dp[i][j];
                else dp[i][j]=1;
            }
        }
    }
    w=w*2-1;
    h=2*h-1;
    que.push({0,0});
    ch[0][0]=1;
    while(!que.empty()){
        auto q=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            nx=q.F+dx[i];
            ny=q.S+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&dp[nx][ny]==0){
                if(ch[nx][ny]==0){
                    ch[nx][ny]=1+ch[q.F][q.S];
                    que.push({nx,ny});
                }
            }
        }
    }
    
    if(ch[h-1][w-1]==0)cout<<0<<endl;
    else {
        cout<<(ch[h-1][w-1]+1)/2<<endl;
    }
    }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  string b;
 
  // 変数aで入力を受け取る
  cin >> a;
  cin >> b;
  int s = b.length();


  if (a<s){
    for (int i = 0; i < a; i++) {
		cout << b[i] ; // 0 1 2が出力される
	}
    cout << "..." ; 
 
  }
  else{
    cout << b ;
  }
}
  

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    //ll a, b,c,d;
    string S;
    cin >> S;
    //cin >> a>>b>>c>>d;
    ll answer = 0;

    rep(i,3) if (S[i] == '1') answer ++;

    cout << answer << endl;    

    return 0;
}


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

int main(){
  intl N;
  cin>>N;
  if(N%2==1){
    cout<<0<<endl;
  }
  else{
    intl ans=0;
    N=N/2;
    while(N>0){
      N=N/5;
      ans=ans+N;
    }
    cout<<ans;
  }
}
  

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

namespace CSharpTest
{
    class Program
    {
        static int Min(int x, int y) => x < y ? x : y;
        static int Max(int x, int y) => x > y ? x : y;

        static void Main(string[] args)
        {
            string[] nm = Console.ReadLine().Split();
            int n = int.Parse(nm[0]);
            int m = int.Parse(nm[1]);
            int[] keysFlags = new int[m];
            int[] keysPrice = new int[m];
            for (int i = 0; i < m; ++i)
            {
                string[] ab = Console.ReadLine().Split();
                keysPrice[i] = int.Parse(ab[0]);
                int flags = 0;
                foreach (string tmp in Console.ReadLine().Split())
                {
                    flags |= 1 << (int.Parse(tmp) - 1);
                }
                keysFlags[i] = flags;
            }

            int flagMax = 1 << n;
            const int PriceMax = 100000001;
            int[][] dp = new int[m][];
            for (int i = 0; i < dp.Length; ++i)
            {
                dp[i] = new int[flagMax];
                for (int j = 0; j < dp[i].Length; ++j)
                {
                    dp[i][j] = PriceMax;
                }
            }
            dp[0][0] = 0;
            dp[0][keysFlags[0]] = keysPrice[0];
            for (int i = 1; i < dp.Length; ++i)
            {
                for (int j = 0; j < dp[i].Length; ++j)
                {
                    dp[i][j] = dp[i - 1][j];
                }
                for (int j = 0; j < dp[i].Length; ++j)
                {
                    int newFlags = j | keysFlags[i];
                    dp[i][newFlags] = Min(dp[i][newFlags], Min(dp[i - 1][newFlags], dp[i - 1][j] + keysPrice[i]));
                }
            }

            int allPrice = dp[m - 1][flagMax - 1];
            Console.WriteLine(allPrice >= PriceMax ? -1 : allPrice);
        }
    }
}


Measured memory_bytes: 31072
#include <stdio.h>

int G[100][100];
int d[100], p[100];
enum status { true, false };
enum status is_visited[100];

void prim() {
  int i, j;
  int u, mincost;

  for(i = 0;i < 100;i++) {
    d[i] = 2001;
    is_visited[i] = false;
  }

  d[0] = 0;
  p[0] = -1;

  while(1) {
    mincost = 2001;
    for(i = 0;i < 100;i++) {
      if(is_visited[i] == false && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }

    if(mincost == 2001) break;

    is_visited[u] = true;

    for(i = 0;i < 100;i++) {
      if(G[u][i] != -1 && is_visited[i] == false) {
        if(G[u][i] < d[i]) {
          d[i] = G[u][i];
          p[i] = u;
        }
      }
    }
  }
}

int main() {
  int i, j, n;
  int sum = 0;

  for(i = 0;i < 100;i++)
    for(j = 0;j < 100;j++)
      G[i][j] = -1;

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

  prim();
  for(i = n - 1;i > 0;i--)
    sum += G[i][p[i]];

  printf("%d\n", sum);

  return 0;
}



Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;
 
 
public class Main{
	
    public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	
    	while(sc.hasNext()){
    		boolean inited = false;
    		boolean error = false;
    		int cur = 0;
    		int pos = 0;
    		
    		char[] input = sc.next().toCharArray();
    		
    		while(true){
    			//System.out.println(cur);
    			if(error){
    				if(input[pos] == '='){
    					break;
    				}else{
    					pos++;
    					continue;
    				}
    			}
    			
    			
    			if(input[pos] == '+'){
    				pos++;
    				
    				int sum = 0;
    				while('0' <= input[pos] && input[pos] <= '9'){
    					sum *= 10;
    					sum += input[pos] - '0';
    					pos++;
    				}
    				
    				if(sum < 0 || sum >= 10000){
    					error = true;
    				}else{
    					cur += sum;
    				}
    			}else if(input[pos] == '-'){	
    				pos++;
    				
    				int sum = 0;
    				while('0' <= input[pos] && input[pos] <= '9'){
  	  					sum *= 10;
    					sum += input[pos] - '0';
    					pos++;
        			}
    				
    				if(sum < 0 || sum >= 10000){
    					error = true;
    				}else{
    					cur -= sum;
    				}
    			}else if(input[pos] == '*'){
    				pos++;
    					
    				int sum = 0;
    				while('0' <= input[pos] && input[pos] <= '9'){
    					sum *= 10;
    					sum += input[pos] - '0';
    					pos++;
    				}
        			
    				if(sum < 0 || sum >= 10000){
    					error = true;
    				}else{
    					cur *= sum;
    				}
    			}else if(input[pos] == '='){
    				break;
    			}else{
    				int sum = 0;
    				while('0' <= input[pos] && input[pos] <= '9'){
    					sum *= 10;
    					sum += input[pos] - '0';
    					pos++;
    				}
        			
    				if(sum < 0 || sum >= 10000){
    					error = true;
    				}else{
    					cur = sum;
    				}
    			}
    			
    			if(cur < 0 || cur >= 10000){
					error = true;
				}
    		}
    		
    		if(error){
    			System.out.println("E");
    		}else{
    			System.out.println(cur);
    		}
    	}
    }
     
}

Measured memory_bytes: 25116
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int N = sc.nextInt();
		long K = sc.nextLong();
		int[] a = new int[N];
		int[] b = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		long lo = 0;
		long hi = 1L << 58;
		while (hi - lo > 1) {
			long mi = (hi + lo) / 2;
			if (f(a, b, mi) < K)
				lo = mi;
			else
				hi = mi;
		}
		out.println(hi);
	}
	long f(int[] a, int[]b, long x) {
		long res = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] <= x) 
				res += b[i];
		}
		return res;
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 44504
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  long int A, B, K;
  cin >> A >> B >> K;
  if (A > K){
    cout << A - K << " " << B << endl;
  }
  else if (B > K - A){
 	 cout << 0 << " " << B - K + A << endl;
    
  }
  else cout << 0 << " " << 0 << endl;
  return 0;
}

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

int main() {
    std::string s;
    std::cin >> s;
    if (s.size() == 2 && s[0] == s[1]) {
        std::cout << "1 2" << std::endl;
        return 0;
    }
    for (int i = 0; i + 2 < s.size(); i++) {
        if (s[i] != s[i + 1] && s[i + 1] != s[i + 2] && s[i + 2] != s[i]) continue;
        std::cout << i + 1 << " " << i + 3 << std::endl;
        return 0;
    }
    
    std::cout << "-1 -1" << std::endl;
    return 0;
}


Measured memory_bytes: 512
def MI(): return map(int, input().split())
H,W,K=MI()
Map=[input() for _ in range(H)]
#Map=[list(input()) for _ in range(H)]
#print(Map)
ans=0
for i in range(1<<H):
  for j in range(1<<W):
    cnt=0
    for h in range(H):
      for w in range(W):
        if 1&(i>>h):
          if 1&(j>>w):
            if Map[h][w]=='#':
              cnt+=1
    if cnt==K:
      ans+=1
print(ans)   

Measured memory_bytes: 9192
let () =
	let k, n = Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
	let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
	let brr = Array.init n @@ fun i -> 
    	if i = 0 then k - arr.(n-1) + arr.(i) else arr.(i) - arr.(i-1) in
    print_int ((Array.fold_left (+) 0 brr) - (Array.fold_left max 0 brr))

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

class G
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var rs = new int[h[1]].Select(_ => read()).ToArray();

		var map = rs.ToLookup(r => r[0], r => r[1]);
		var ins = new int[h[0] + 1];
		foreach (var r in rs) ins[r[1]]++;

		var q = new Queue<int>(Enumerable.Range(1, h[0]).Where(i => ins[i] == 0));
		var dp = new int[h[0] + 1];
		while (q.Any())
		{
			var p = q.Dequeue();
			foreach (var np in map[p])
				if (--ins[np] == 0)
				{
					dp[np] = dp[p] + 1;
					q.Enqueue(np);
				}
		}
		Console.WriteLine(dp.Max());
	}
}


Measured memory_bytes: 35340
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();

        int d = 0;
        int cnt = 0;
        if(d <= x) cnt++;
        for (int i = 0; i < n; i++) {
            d += scanner.nextInt();
            if(d <= x){
                cnt++;
            }
//            int l = scanner.nextInt();

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


Measured memory_bytes: 22868
using System;

public class dice
{
    private int[] data;
    public dice(string s = "1,5,6,4,2,3")
    {
        data = new int[6];
        string[] line = s.Split(',');
        for (int i = 0; i < 6; i++)
            data[i] = int.Parse(line[i]);

        // 0: ceilling 1: front 2: floor 3:right:4:back:5:left
    }
    public void roll(char c)
    {
        var w = new int[6];
        Array.Copy(data, w, 6);
        if (c == 'U' | c == 'N') { data[4] = w[0]; data[0] = w[1]; data[1] = w[2]; data[2] = w[4]; }
        else if (c == 'D' | c == 'S') { data[1] = w[0]; data[2] = w[1]; data[4] = w[2]; data[0] = w[4]; }
        else if (c == 'R' | c == 'E') { data[3] = w[0]; data[5] = w[2]; data[2] = w[3]; data[0] = w[5]; }
        else { data[5] = w[0]; data[3] = w[2]; data[0] = w[3]; data[2] = w[5]; }
    }
    public int peek(int n) => data[n];
}

public class hello
{
    public static void Main()
    {
        var b0 = "013542";
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var b = new int[6];
        for (int i = 0; i < 6; i++)
            b[b0[i] - '0'] = a[i];
        var d = new dice(string.Join(",", b));
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var ce = int.Parse(line[0]);
            var fr = int.Parse(line[1]);
            var ans = getAns(d, ce, fr);
            Console.WriteLine(ans);
        }

    }
    static int getAns (dice d, int ce, int fr)
    {
        if (d.peek(0) == ce && d.peek(1) == fr) return d.peek(3);
        var ok = false;
    again:;
        for (int i = 0; i < 4; i++)
        {
            d.roll('D');
            if (d.peek(0) == ce ) { ok = true; break; }
        }
        if (!ok) { d.roll('R');  goto again; }
        if (d.peek(1) == fr) return d.peek(3);
        else if (d.peek(3) == fr) return d.peek(4);
        else if (d.peek(4) == fr) return d.peek(5);
        else  return d.peek(1);
    }
}



Measured memory_bytes: 18008
#include <iostream>
using namespace std;
typedef pair<int, int> P;

int main() {
    int c;
    cin >> c;
    while (c--) {
        int x, y, w, h;
        cin >> x >> y >> w >> h;
        int n;
        cin >> n;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            if (x <= a && a <= x + w && y <= b && b <= y + h) {
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1e5+7;
typedef long long ll;

int n,m,ans,num;
int a[maxn];
int f[maxn];

vector<int>e[maxn];

void dfs(int x)
{
	int i,j,len=e[x].size();
	for(i=0;i<len;++i)
	{
		int t=e[x][i];
		if(f[t]==0)
		{
			f[t]=x;
			dfs(t);
		}
	}
}

void dfs2(int x)
{
	int i,j,len=e[x].size();
	for(i=0;i<len;++i)
	{
		int t=e[x][i];
		if(f[t]==x)
		{
			num++;
			dfs2(t);
		}
	}
}

int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<n;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].pb(y);
		e[y].pb(x);
	}
	
	f[1]=-1;
	dfs(1);
	/*
	for(i=1;i<=n;++i) printf("%d ",f[i]);
	printf("\n");
	*/
	k=0;
	int x=n;
	while(x!=1)
	{
		x=f[x];
		k++;
	}
	
	x=n;
	for(i=1;i<=(k-1)/2;++i) x=f[x];
	
	num=1;
	dfs2(x);
	
	if(num>=n-num)
	{
		printf("Snuke\n");
	}
	else printf("Fennec\n");
	
	return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef long long ll;
#define int ll

int N;
int a[10001];

bool solve() {
    int sum_plus = 0;
    int sum_minus = 0;
    int sum_minus2 = 0;
    rep(i, N) {
        if (a[i] > 0) {
            sum_plus += a[i];
        } else {
            sum_minus += (-a[i]);
            sum_minus2 += (-a[i]) / 2 * 2;
        }
    }
    if (sum_plus - sum_minus > 0) return false;
    if (sum_plus * 2 <= sum_minus2) return true;
    return false;
}

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> a[i];
    }
    rep(i, N) {
        int x;
        cin >> x;
        a[i] -= x;
    }
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.util.Scanner;

/**
 * Created on 2017/09/29 7:01.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int a = sc.nextInt();
            System.out.println(n * n - a);
        }
    }
}

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

lint s;

int main(){
	cin >> s;
	if(s == 1000000ll * 1000000ll * 1000000ll){
		printf("0 0 1000000000 0 0 1000000000");
		return 0;
	}
	int m = s % 1000000000;
	printf("0 %d ", m);
	printf("%lld 0 ", s / 1000000000);
	printf("%lld 1000000000", s / 1000000000 + 1);
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int main(void){
	int a,bignum=1,buf,m;
	scanf("%d",&a);
	for(int i=1;i<100;i++){
			for(int n=10,buf=i;n>0;n--){
				m=buf*=i;
				if(m>a){
					break;
				}
				else if(bignum<m){
					bignum=m;
				}
			}
		}
					printf("%d",bignum);
	return 0;
}

Measured memory_bytes: 128