akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]    


    token = lines[0].split(" ")
    n = int(token[0])
    
    a = [int(e) for e in lines[1].split(" ")]
    
    return (n, a)


def solve(n, a):


    current_max = -1
    result = "Yes"
    reduced_all = set()
    last_j = 0
    for i in range(n):

        if a[i] >= current_max:
            current_max = a[i]
        else:
            reduced_tmp = set()
            for j in range(last_j, i):
                if a[j] == current_max:
                    if j in reduced_all:
                        result = "No"
                        break
                    else:
                        reduced_tmp.add(j)

            if result == "No":
                break

            current_max = current_max - 1
            for j in reduced_tmp:
                reduced_all.add(j)
                a[j] = a[j] - 1
                if a[j] > a[i]:
                    result = "No"
                    break
                else:
                    last_j = max(j, last_j)


            if result == "No":
                break

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))


if __name__ == '__main__':

    main()


Measured memory_bytes: 15352
#include<iostream>

#define ll long long int
#define rep(i,n) for(int (i)=0;(i) < (n);(i)++)
#define INF 1000000000000000000

using namespace std;

int main(){
  int N;
  cin >> N;
  ll A[100010];
  ll ans = 1;

  rep(i,N){
      cin >> A[i];
  }

  rep(i,N){
      if(A[i] == 0){
          cout << 0 << endl;
          return 0;
        }
    }
  
  rep(i,N){
    if(A[i] <= INF/ans){
        ans *= A[i];
    }else{
        cout << -1 << endl;
        return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n;cin>>n;
    deque<int> dq;
    rep(i,n){
        int num;cin>>num;
        if(i%2) dq.push_back(num);
        else dq.push_front(num);
    }
    if(n%2)while(!dq.empty()){
        cout<<dq.front();
        dq.pop_front();
        cout<<(dq.empty()?"\n":" ");
    }
    else while(!dq.empty()){
        cout<<dq.back();
        dq.pop_back();
        cout<<(dq.empty()?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define trav(a, b) for(auto& a: b)
#define all(a) a.begin(), a.end()
#define gottagofast ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
using namespace std;
using ll = long long;
using ull = unsigned long long;

ll lcm(ll a, ll b) {
    ll g = __gcd(a, b);
    return a / g * b;
}

int main() {
    gottagofast;
    int n; cin >> n;
    ll ans = 1;
    while(n--) {
        ll x;
        cin >> x;
        ans = lcm(ans, x);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  ll k;
  cin >> n >> k;
  vector <ll> a (n), f (n);
  rep (i, n) cin >> a [i];
  rep (i, n) cin >> f [i];
  sort (ALL (a));
  sort (ALL (f), greater <void> ());
  ll l = -1, r = 1e12;
  while (l + 1 < r)
  {
    auto x = (l + r) / 2;
    ll delta = 0;
    rep (i, n)
    {
      delta += max <ll> (a [i] - x / f [i], 0);
    }
    if (delta <= k) r = x;
    else l = x;
  }
  cout << r << endl;
}


Measured memory_bytes: 3456
#include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

string s;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

	cin >> s;
	
	cout << (s[0]==s[2] ? "Yes" : "No") << endl;

}

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

int main() {
  int count=0,countb=0;
  int A,B;
  cin>>A>>B;
  if(A>B){
    rep(i,A){
      cout<<B;
    }
  }
  else{
    rep(i,B){
    cout<<A;
    }
  }
}


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

const lli INF = 1LL<<60;
const lli MAXM = 13;
const lli MAXW = 13;

lli M, W;
lli bm[MAXM], bw[MAXW];
lli dp[MAXM][1<<MAXW];

lli f(lli bm, lli bw) {
  return llabs(bm - bw) * (llabs(bm - bw) - 30LL) * (llabs(bm - bw) - 30LL);
}

int main() {
  while(cin >> M >> W && (M|W)) {
    for(lli i = 0; i < M; ++i) cin >> bm[i];
    for(lli i = 0; i < W; ++i) cin >> bw[i];
    fill(dp[0], dp[MAXM], -INF);
    dp[0][0] = 0;
    for(lli i = 0; i < M; ++i) {
      for(lli j = (1<<W)-1; j >= 0; --j) {
	dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
	for(lli k = 0; k < W; ++k) {
	  if(j >> k & 1) {
	    dp[i+1][j] = max(dp[i+1][j], dp[i][j-(1<<k)] + f(bm[i], bw[k]));
	  }
	}
      }
    }
    lli res = 0;
    for(lli j = (1<<W)-1; j >= 0; --j) {
      res = max(res, dp[M][j]);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1988
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int cnt0 = 0, cnt1 = 0;
    int n = S.length();
    rep(i, n) if(S[i] == '0') cnt0++; else cnt1++;
    
    cout << min(cnt0, cnt1) * 2 << endl;


    return 0;
}


Measured memory_bytes: 512
#pragma warning (disable:4996)
#include <stdio.h>
#include <ctype.h>

void inputstr(int *alpha){
	int num;
	char ch;
	while (scanf("%c", &ch) != EOF){
		ch = tolower(ch);
		num = ch - 'a';
		if (0<=num&&num<=26)++alpha[num];
	}
}
void output(int *alpha){
	unsigned short int i;
	for (i = 0; i < 26; i++){
		printf("%c : %d\n", 'a' + i, alpha[i]);
	}
}
int main(void){
	int alpha[26] = { 0 };
	inputstr(alpha);
	output(alpha);
	return 0;
}

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

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

  vector<int> X(N);
  for(auto& x: X){
    cin >> x;
  }

  int mean = 0;
  for(auto x: X){
    mean += x;
  }
  mean = round(1.0 * mean / N);
 

  int ans = 0;
  for(auto x: X){
    ans += (x - mean) * (x - mean);
  }

  

  cout << ans << endl;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  vector<string> str(3);
  str[0] = "Sunny";
  str[1] = "Cloudy";
  str[2] = "Rainy";
  map<string, ll> mp;
  REP(i,3) mp[str[i]] = i;

  string S;
  IN(S);
  OUT(str[(mp[S]+1)%3]);

  return 0;
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		long power = 1;
		
		for(int i = 0; i < n; i++) {
			power = power * (i+1) % (long)(1e9+7);
		}
		System.out.println(power);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 55;

int n;
vector<int> g[maxN];

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

    cin >> n;

    vector<int> sz(n + 1, 0);

    for(int i = 2; i <= n; i++) {
        int x;  cin >> x;
        sz[x]++;
    }

    for(int i = 1; i <= n; i++) {
        cout << sz[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 8740
n = gets.to_i
d, x = gets.split(" ").map(&:to_i)
as = []
n.times do
  as << gets.to_i
end

count = 0
n.times do |i|
  d.times.with_index(1) do |j|
    tmp = j * as[i] + 1
    count += 1 if tmp <= d
  end
end

puts count + x

Measured memory_bytes: 1916
#include<iostream>
using namespace std;
int n,k,l,r,ans;
string s;
int main(){
	cin>>n>>k>>s;
	s+='e';
	k+=(s[0]=='1');
	while(k--){while(r!=n&&s[r++]=='0');while(r!=n&&s[r]=='1')r++;}
	while(l!=n){
		ans=max(ans,r-l);
		while(l!=n&&s[l++]=='1');
		while(l!=n&&s[l]=='0')l++;
		while(r!=n&&s[r++]=='0');
		while(r!=n&&s[r]=='1')r++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
  string S;
  cin >> S;
  int N = S.size();
  for(int i = 0; i < N; i++){
    if(S[i] != S[N - i - 1]){ cout << "No"; return 0; }
  }

  for(int i = 0; i < (N - 1) / 2; i++){
    if(S[i] != S[(N- 1) / 2 - i - 1]){ cout << "No"; return 0; }
  }
  for(int i = -1 + (N + 3) / 2; i < N; i++){
    if(S[i] != S[N - i - 1]){ cout << "No"; return 0; }
  }

  cout << "Yes";

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;


int main(){
    bool flagA=false,flagB=false,flag=false;
    int N,countA=0,countB=0,count=0;
    cin>>N;
    string s;
    for(int i=0;i<N;i++,flagA=false,flagB=false){
        cin>>s;
        for(int i=0;i<s.size()-1;i++){
            if(s.substr(i,2)=="AB") count++;
        }
        if(s[0]=='B'){
            countB++; flagB=true;
        } 
        if(s[s.size()-1]=='A'){
            countA++;
            flagA=true;
        }
        if(flagA && !flagB) flag=true;
    }
    if(!flag) countB--;
    if(countB<0) countB++;
    cout<<count+min(countA,min(countB,N-1))<<endl;
}


Measured memory_bytes: 256
#include <iterator>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;
int main(int argc, char **argv) {

  vector<int> m;

  int ans = 0;
  for (int i = 0; i < 5; i++) {
    int a;
    cin >> a;
    if (a % 10 == 0) {
      ans += a;
    } else {
      m.push_back(a);
    }
  }
  sort(m.begin(), m.end(), [](int l, int r) {
                             auto lhs = (l/10 + 1) * 10 - l;
                             auto rhs = (r/10 + 1) * 10 - r;
                             return lhs < rhs;
                           });

  if (m.size() == 1) {
    ans += m.back();
  } else if (m.size()) {
    for (int i = 0; i < m.size() - 1; ++i)
      ans += ((m[i] / 10) + 1) * 10;

    ans += m.back();
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;
//フィボナッチ数列のx番目を求めるよ！
int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}
//aとｂの最大公約数を求めるよ！
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
//2のn乗を求めるよ！(二分累乗法)
int tow(ll n) {
	if (n == 0)return 1;
	ll x = tow( n / 2);
	x *= x;
	if (n % 2 == 1)x =x * 2;
	return x;
} 
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b,ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	ll int ans = modpow(2,n,mod) - 1;
	while (ans < 0)ans += mod;
	ans %= mod;
	ans -= c(n, a,mod);
	while (ans < 0)ans += mod;
	ans %= mod;
	ans -= c(n, b,mod);
	while (ans < 0)ans += mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
#include<math.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
int main()
{
	ll num,gen;
	scanf("%lld%lld",&num,&gen);
	ll mini=num;
	for(ll i=2;i<=100;i++)
	{
		double d=pow(num,1.0/double(i));
		ll t=floor(d);
		for(int j=t-1;j<=t+2;j++)
		{
			if(j<=1)continue;
			for(int k=0;k<=i;k++)
			{
				ll n=1;
				for(int l=0;l<k;l++)
				{
					if(double(n)*double(j)<5e18)n*=j;
					else n=5e18;
				}
				for(int l=k;l<i;l++)
				{
					if(double(n)*double(j+1)<5e18)n*=(j+1);
					else n=5e18;
				}
				if(n>=num)
				{
					mini=min(mini,gen*(i-1)+j*k+(j+1)*(i-k));
				}
			}
		}
	}
	printf("%lld\n",mini);
}

Measured memory_bytes: 256
def main():
    N = int(input())
    X = [int(i) for i in input().split()]
    
    sorted_X = sorted(X)
    median_1 = sorted_X[int(N/2)-1]
    median_2 = sorted_X[int(N/2)]
    
    for i in range(N):
        remove_num = X[i]
        if(remove_num > median_1):
            print(median_1)
        else:
            print(median_2)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 25224
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in xrange(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                peaks.append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            else:
                peaks.append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        else:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print(max(peaks))

N,L = map(int,raw_input().strip().split())
ices = [int(raw_input().strip()) for _ in xrange(N)]

orderN(N,L,ices)

Measured memory_bytes: 12556
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define watch(x) cout<<#x<<" : "<<x<<endl;
typedef long long ll;
using namespace std;

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

    ll a;
    cin>>a;
    printf("%lld\n",a+a*a+a*a*a);

    return 0;
}


Measured memory_bytes: 3720
fun main(args:Array<String>) {
  val (h, w) = readLine()!!.split(" ").map(String::toInt)
  val X = (1..h).map {
    readLine()!!.toList().map { it.toString() }
  }
  val sc = (0..h-1).map { y ->
    (0..w-1).map { x ->
      val st = X[y][x]
      if( st == "#" ) {
        val sst = mutableListOf<String>()
        // up
        if( y != 0 ) sst.add( X[y-1][x] ) 
        // down
        if( y != h-1) sst.add( X[y+1][x] )
        // left
        if( x != 0) sst.add( X[y][x-1] )
        // right
        if( x != w-1) sst.add( X[y][x+1] )
        sst.filter { it == "#" }.size >= 1
      } else {
        null
      }
    }
  }.flatten().mapNotNull { it }.all { it == true }
  when(sc) {
    true -> "Yes"
    else -> "No"
  }.let(::println)
}

Measured memory_bytes: 38512
n=int(input())
ba=[]
for i in range(n):
  c,d=map(int,input().split())
  ba.append([d,c])
ba.sort(key=lambda x:(x[0],-x[1]))
time=0
ans="Yes"
for i in range(n):
  time+=ba[i][1]
  if time<=ba[i][0]:
    continue
  else:
    """print("i",i)"""
    ans="No"
    break
print(ans)

Measured memory_bytes: 56988
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
//typedef pair<int,int> P;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> s[n];
    vector<int> ch1(n,0),ch2(n,0);
    
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        s[a].push_back(b);
        s[b].push_back(a);
    }
    for(int i=0;i<s[2].size();i++){
        //cout<<s[2][i]<<endl;
    }
    queue<int> que;
    que.push(0);
    int l=1;
    ch1[0]=1;
    while(que.size()){
        int x=que.front();
        que.pop();
        l++;
        //cout<<x<<"W"<<endl;
        for(int i=0;i<s[x].size();i++){
            if(ch1[s[x][i]]==0){
                que.push(s[x][i]);
                ch1[s[x][i]]=ch1[x]+1;
            }
        }
    }
    que.push(n-1);
    ch2[n-1]=1;
    while(que.size()){
        int x=que.front();
        que.pop();
        for(int i=0;i<s[x].size();i++){
            if(ch2[s[x][i]]==0){
                que.push(s[x][i]);
                ch2[s[x][i]]=ch2[x]+1;
            }
        }
    }
    int S=0,F=0;
    for(int i=0;i<n;i++){
        //cout<<ch1[i]<<ch2[i]<<endl;
        if(ch1[i]<=ch2[i])F++;
        else S++;
    }
    //cout<<S<<F<<"WWW"<<endl;
    if(F>S){
        cout<<"Fennec"<<endl;
    }
    else cout<<"Snuke"<<endl;
}


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

int main() {
    
    int n, m; cin >> n >> m;
    int time = 1900 * m + 100 * (n - m);
    int Ecnt = 1;
    while (m--) {
        Ecnt *= 2;
    }
    cout << time * Ecnt << endl;
    return 0;
}

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

void Main() {
    // input
    int N;
    cin >> N;
    

    // translate
    int ans = 100; // 適当なINF 2^100 > 10^12  
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        int count = 0;
        while (num % 2 == 0) {
            num /= 2;
            count++;
        }
        
        if (count < ans) {
            ans = count;
        }
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}
int main(void){
    ll n,m;
    string a,b;
    cin>>n>>m>>a>>b;
    
    
    ll t=gcd(n,m);
    if(n==m){
        cout<<(a==b?n:-1);
        return 0;
    }else if(t==1){
        cout<<(b[0]==a[0]?n*m:-1);
        return 0;
    }
    for(ll i=0;i<t;++i){
        //cout<<m/t*i<<" "<<n/t*i<<endl;
        if(m/t*i>=m||n/t*i>=n){
            //cout<<"no";
        }else if(b[m/t*i]!=a[n/t*i]){
            cout<<-1;
            return 0;
        }
    }
    cout<<n/t*m;
    
    return 0;
}


Measured memory_bytes: 3744
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int c = in.nextInt();
		int[] b = new int[m];
		int ret = 0;
		for (int i = 0; i < m; i++) {
			b[i] = in.nextInt();
		}
		for (int j = 0; j < n; j++) {
			int sum = 0;
			for (int i = 0; i < m; i++) {
				int a = in.nextInt();
				sum += a * b[i];
			}
			if (sum + c > 0) {
				ret++;
			}
		}
		System.out.println(ret);
	}

}


Measured memory_bytes: 23636
def energy_drink_collector(n, m, abli):

    ans = 0
    count = m
    abli.sort(key=lambda x: x[0])

    for i in abli:
        if i[1] <= count:
            ans += i[0]*i[1]
            count -= i[1]
        else:
            ans += count*i[0]
            count = 0
        if not count:
            break
    return ans

def main():
    n, m = map(int, input().split())
    abli = [list(map(int, input().split()))for i in range(n)]
    print(energy_drink_collector(n, m, abli))

if __name__ == '__main__':
    main()

Measured memory_bytes: 29028
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m,d;
    cin>>m>>d;
    ll ans=0;
    range(mm,1,m+1)range(dd,22,d+1){
        if(dd%10<2)continue;
        if(dd/10<2)continue;
        if(dd%10 * (dd/10) == mm){
            ans++;
        }
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),m=in();
    pq q;
    rep(i,n){
        q.push(in());
    }
    rep(i,m){
        int t=q.top();
        q.pop();
        q.push(t/2);
    }
    ll ans=0;
    rep(i,n){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
}



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

int main() {
  int a,b;
  cin >>a>>b;
  if (a==b){
    cout <<"Yes"<<endl;
  }
  else {
    cout <<"No"<<endl;
  }}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

void primeFactor(ll val, map<ll,ll> &primeList){
  if(val<1){
    return;
  }
  for(int i=2;i*i<val;i++){
    while(val%i==0){
      primeList[i]++;
      val/=i;
    }
  }
  if(val!=1){
    primeList[val]=1;
  }
  return;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll k;cin>>k;
  int ans=0;
  ll a=0;
  if(k==1||k==7){
    cout<<1<<endl;
    return 0;
  }else if(k%2==0||k%5==0){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=1;i<INT_MAX;i++){
    a=a*10+7;
    a%=k;
    if(a==0){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
n, k = map(int, input().split())

ans = 0
t = 0

for i in range(k, n + 1, k):
    ans += 1

ans **= 3

if k % 2 == 0:
    for j in range(int(k / 2), n + 1, k):
        t += 1
    
    ans += t ** 3

print(ans)

Measured memory_bytes: 3060
n,k = list(map(int, input().split()))
num = [0 for i in range(n)]
for i in range(k):
    s = input()
    a = list(map(int, input().split()))
    for j in a:
        num[j-1]+=1

ans = 0
for i in num:
    if(i==0): ans+=1
print(ans)



Measured memory_bytes: 67772
r, c = [int (x) for x in input().split(' ')]
a = [[0 for i in range(c)] for j in range(r)]
for s in range(0,r):
    a[s] = [int (x) for x in input().split(' ')]

for tr in range(0,r):
    total = 0
    for v in a[tr]:
        total += v
    a[tr].append(total)

total = [0 for i in range(c+1)]
for tr in range(0,r):
    for tc in range(0,c+1):
        total[tc] += a[tr][tc]
a.append(total)

for i in range(r+1):
    a[i] = [str(a[i][j]) for j in range(c+1)]
    print(' '.join(a[i]))

Measured memory_bytes: 8180
#include <bits/stdc++.h>
#include<math.h>
#define ll long long
#define fi first
#define se second
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,m,i,j;
char c;
cin>>n>>m;
ll a[n+1][m+1];
for(i=1;i<=n;i++)
{
    for(j=1;j<=m;j++)
    {
        cin>>c;
        if(c=='#')
        {
            a[i][j]=-1;
        }
        else
            a[i][j]=0;
    }
}
if(a[1][1]==-1 || a[n][m]==-1)
    cout<<"0";
else
{
    for(i=1;i<=n;i++)
    {
        if(a[i][1]==-1)
            break;
            else
              a[i][1]=1;
    }
     for(i=1;i<=m;i++)
    {
        if(a[1][i]==-1)
            break;
            else
              a[1][i]=1;
    }
    for(i=2;i<=n;i++)
    {
        for(j=2;j<=m;j++)
        {
            if(a[i][j]!=-1)
            {
                if(a[i-1][j]>0)
                {
                    a[i][j]=(a[i][j]%mod +a[i-1][j]%mod)%mod;
                }
                if(a[i][j-1]>0)
                {
                a[i][j]=(a[i][j]%mod +a[i][j-1]%mod)%mod;
                }
            }
        }
    }
  cout<<a[n][m];
}
}



Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

int N, M;
vector<vector<int> > g;
int used[100001];
vector<int> ans;
vector<int> ans2;

void dfs(int v)
{
    used[v] = 1;
    ans.push_back(v);
    for (int i = 0; i < g[v].size();i++)
    {
        if(used[g[v][i]] == 0)
        {
            return dfs(g[v][i]);
        }
    }
}

int main()
{
    cin >> N >> M;
    g.resize(N);
    for (int i = 0; i < M;i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0);
    used[0] = 0;
    dfs(0);

    for (int i = ans.size() - 1; i >= 0;i--)
    {
        if(ans[i] != 0)
        {
            ans2.push_back(ans[i]);
        }
        else
        {
            ans2.push_back(ans[i]);
            break;
        }
    }
    for (int i = 1; i < ans.size(); i++)
    {
        if (ans[i] != 0)
        {
            ans2.push_back(ans[i]);
        }
        else
        {
            break;
        }
    }

    cout << ans2.size() << endl;
    for (int i = 0; i < ans2.size() - 1; i++)
    {
        cout << ans2[i] + 1 << " ";
    }
    cout << ans2[ans2.size() - 1] + 1 << endl;

    return 0;
}


Measured memory_bytes: 7544
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007


int main(){
    int n,m;cin >> n >> m;
    vector<int>L(m),R(m);
    int cnt=0;
    for(int i=0;i<m;i++){
        cin >> L[i] >> R[i];
    }
    int max,min;
    max=*max_element(L.begin(),L.end());
    min=*min_element(R.begin(),R.end());
    for(int i=1;i<=n;i++){
        if(i>=max&&i<=min) cnt++;
        
    }
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
dic = {}
maxi = 0
for _ in range(n):
  k = input()
  dic[k] = 1 if k not in dic else dic[k] + 1
  if dic[k] > maxi: maxi = dic[k]
result = []
for i,j in dic.items():
  if j == maxi:
    result.append(i)
result.sort()
for r in result:
  print(r)

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

#define ll long long
#define ld long double
using namespace std;

int  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    cin >> n >> m;
    map<char,ll> ma;
    for (ll i = 1; i <= m*n; i++){
        char t;
        cin >> t;
        ma[t]++;
    }
    ll nn = n;
    ll mm = m;
    if (nn % 2 != 0){
        nn--;
    }
    if (mm % 2 != 0){
        mm--;
    }
    ll k = nn*mm;
    bool j = true;
    while (k){
        if (!j){
            cout << "No" << endl;
            return 0;
        }
        j = false;
        for (auto i = ma.begin(); i != ma.end(); i++){
            if (i->second >= 4){
                i->second-=4;
                k-=4;
                j = true;
                break;
            }
        }
    }
    if (n % 2 == 0 && m % 2 == 0) {
        cout << "Yes" << endl;
        return 0;
    } else if (n % 2 != 0 && m % 2 == 0){
        bool j = true;
        k = m;
        while (k){
            if (!j){
                cout << "No" << endl;
                return 0;
            }
            j = false;
            for (auto i = ma.begin(); i != ma.end(); i++){
                if (i->second >= 2){
                    i->second-=2;
                    k-=2;
                    j = true;
                    break;
                }
            }
        }
        cout << "Yes" << endl;
        return 0;
    }else if (n % 2 == 0 && m % 2 != 0){
        bool j = true;
        k = n;
        while (k){
            if (!j){
                cout << "No" << endl;
                return 0;
            }
            j = false;
            for (auto i = ma.begin(); i != ma.end(); i++){
                if (i->second >= 2){
                    i->second-=2;
                    k-=2;
                    j = true;
                    break;
                }
            }
        }
        cout << "Yes" << endl;
        return 0;
    } else if (n % 2 != 0 && m % 2 != 0){
        bool j = true;
        k = (n-1)+(m-1);
        while (k){
            if (!j){
                cout << "No" << endl;
                return 0;
            }
            j = false;
            for (auto i = ma.begin(); i != ma.end(); i++){
                if (i->second >= 2){
                    i->second-=2;
                    k-=2;
                    j = true;
                    break;
                }
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
	return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());

            if (k % 2 == 0)
            {
                Console.WriteLine((k / 2) * (k / 2));
            }
            else
            {
                Console.WriteLine((k / 2) * (k-(k/2)));
            }




        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    map<int,int> m;
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            map<int,int> ma=m;
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    ma[k]=0;
                }else{
                    ma[j]++;
                    a-=ma[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                m[y]=0;
            }else{
                m[j]++;
                ans-=m[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=15000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                r[i]=h;
            }else{
                r[i]=q[i];
            }
        }
        map<int,int> mx;
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    mx[r[i]]=0;
                }else{
                    mx[j]++;
                    ansm-=mx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3740
// In God We Trust


# include <bits/stdc++.h>
using namespace std;

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second

#define int long long 
int sumXOR(int arr[], int n) 
{
  int mod = 1000000007;
    int sum = 0; 
    for (int i = 0; i < 64; i++)  
    { 
        //  Count of zeros and ones 
        int zc = 0, oc = 0;  
          
        // Individual sum at each bit position 
        int idsum = 0;  
        for (int j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
          
        // calculating individual bit sum  
        idsum = oc * (zc * (((long long)1 << i) % mod) % mod) % mod ;  
  
        // final sum     
        sum += idsum % mod, sum %= mod;  
    } 
    return sum; 
} 

signed main()
{
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0 ; i < n; i++)
    cin >> a[i];
  cout << sumXOR(a, n) % (int)(1e9 + 7);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	int k, n; cin >> k >> n;
	
	vector<int> a(n), b(n+1);
	rep(i,n) cin >> a[i];
	sort(all(a));
	rep(i, n) b[i]= a[i];
	b[n]= a[0] + k;
	
	//cout << "test: " << a[n];
	
	//rep(i, n+1) cout << a[i];
	



	int max = 0;
	rep(i, n) chmax(max, b[i+1] - b[i]);
	
	int ans = k - max;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    string s;
    cin >> s;

    int r = 0;
    rep(i, s.size())
    {
        if (s[i] == '0') {
            r++;
        } else {
            r--;
        }
    }
    cout << s.size() - abs(r) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;

char a[10];
int main()
{
	scanf("%s",a);
	if((a[0] == a[1] && a[1] == a[2] )|| (a[1] == a[2] && a[2] == a[3]))
		puts("Yes\n");
	else	puts("No\n");
	return 0;
}

Measured memory_bytes: 256
n,x,y=map(int, raw_input().split())

tb=[[0]*(n+1) for i in xrange(n+1)]
tb[x][y]=1
for i in xrange(1, n+1):
    for j in xrange(i+1,n+1):
        if x==i and j==y:
            continue
        if i<x:
            # print i,j, x-i+1+abs(y-j)
            tb[i][j]=min(j-i, x-i+1+abs(y-j))
        elif i>=x and i<=y:
            tb[i][j]=min(j-i, i-x+1+abs(y-j))
        else:
            tb[i][j]=j-i

res=[0]*(n+1)

for i in xrange(1 ,n+1):
    for j in xrange(i+1, n+1):
        res[tb[i][j]]+=1

s=''
for i in xrange(1, n):
    s+=str(res[i])+'\n' 

# for i in tb:
#     print i
print s

Measured memory_bytes: 64284
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $wa = [];
  $sa = [];
  for($i=0; $i<$n; $i++){
    $x = $i + $a[$i];
    $y = $i - $a[$i];
    if(!isset($wa[$x])){
      $wa[$x]=0;
    }
    $wa[$x]++;
    if(!isset($sa[$y])){
      $sa[$y]=0;
    }
    $sa[$y]++;
  }

  $ans = 0;
  foreach($wa as $x => $wa_count){
    if(isset($sa[$x])){
      $sa_count = $sa[$x];
      $ans += $wa_count * $sa_count;
    }
  }
       
  echo $ans;

Measured memory_bytes: 47120
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Hina Arare
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    char s[2];
    scanf("%s", s);

    if (s[0] == 'Y') {
      puts("Four");
      return 0;
    }
  }

  puts("Three");
  return 0;
}


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

using namespace std;
int main()
{
	string s;
	cin >> s;
	int k,ans=1;
	cin >> k;
	for (int i = 0; i < k; i++) {
		if (s[i] != '1') {
			ans = (int)s[i] - 48;
			break;
		}
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
    static int n;
    static int q;

    static int Search(int[]s, int t, int n)
    {
        int left = 0;
        int right = n;

        while(left < right)
            {
                int mid = (left + right) / 2;

                if(s[mid] == t)
                    return 1;

                else if(t < s[mid])
                    right = mid;

                else 
                    left = mid + 1;
            }
        return 0;
    }

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

        n = In.nextInt();
        int []S = new int[n];

        for(int i = 0; i < n; i++)
            {
                S[i] = In.nextInt();
            }

        q = In.nextInt();
        int []T = new int[q];

        for(int i = 0; i < q; i++)
            {
                T[i] = In.nextInt();
            }

        int count = 0;
        for(int i = 0; i < q; i++)
            {
                count += Search(S,T[i],n);
            }

        System.out.println(count);
    }
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (h % 2 == 1 && w % 2 == 1) cout << (h * w + 1) / 2 << endl;
  else cout << h * w / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define inf 1000000007

int main(void) {
	// your code goes here
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=a+b;
	if (a+b<a-b&&a*b<a-b) c=a-b;
	if (a-b<a*b&&a+b<a*b) c=a*b;
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int N = 1e3+5;

int dp[N][N];
char s[N][N];

int main()
{
	int h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
		cin >> (s[i] + 1);
	dp[1][1] = 1;
	for (int i = 1; i <= h; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			if (s[i][j] == '.')	dp[i][j] += dp[i-1][j] + dp[i][j-1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[h][w];
	return 0;
}

Measured memory_bytes: 5120
def solve():
  S = int(input())

  if S == 10 ** 18:
    print('0 0 0 1000000000 1000000000 0')
  else:
    LIMIT = 10 ** 9
    a = S % LIMIT
    b = (S - a) // LIMIT + 1
    c = LIMIT - a
    print('0 0 1 1000000000 ' + str(b) + ' ' + str(c))

solve()

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

using namespace std;

typedef long long LL;
const int maxn = 1e5;
int n, a, b, m[maxn+3];

bool judge(LL x)
{

    LL sum = 0;
    for(int i=0; i<n; ++i)
    {
        LL t = (LL)m[i]-x*b;
        if(t>0)
        {
            sum += (int)ceil(t*1.0/(a-b));
            if(sum > x || sum < 0)
                return false;
        }
    }
    return true;
}
int main()
{
    while(~scanf("%d%d%d",&n,&a,&b))
    {
        int imax = 0;
        for(int i=0; i<n; ++i)
            scanf("%d",&m[i]), imax = max(imax, m[i]);
        LL l=0, r=imax;
        while(l<r)

        {

            LL mid = l+r>>1;

            if(judge(mid)) r=mid;

            else l=mid+1;

        }

        printf("%lld\n",r);

    }

    return 0;

}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {
    int a,b,k;

    cin>>a>>b>>k;

    int x=a;
    if(k>b-a+1){

        for(int i=0;i<b-a+1;i++){

        cout<<x<<endl;
        x++;
    }

    }
    else{
        for(int i=0;i<k;i++){

        cout<<x<<endl;
        x++;
    }
    }

    int begin=b-k+1;

    if(begin<=x){

        while(x<=b){
            cout<<x<<endl;
            x++;
        }

    }
    else{
        while(begin<=b){

            cout<<begin<<endl;
            begin++;
        }
        
    }



    

}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    ll n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    vector<ll> cnt;
    ll m=n;
    for(long long int i=2;i*i<=m && n>1;i++){
        if(n%i==0){
            ll tmp=0;
            while(n%i==0){
                tmp++;
                n/=i;
            }
            cnt.push_back(tmp);
        }
    }
  
    ll ans=0;
  	if(n!=1){
    	ans++;
    }
    n=cnt.size();
    rep(i,n){
        ll k=0;
        while(((k+2)*(k+1))/2 <= cnt[i]){
            k++;
        }
        ans+=k;
    }
    if(ans==0) ans++;

    cout<<ans<<endl;
    

    return 0;
}



Measured memory_bytes: 3560