akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF 2000000000
#define INFLL 9000000000000000000
using namespace std;
int main(void)
{
	int n, k, ans=0;

	cin>>n>>k;

	vector<int> x(n);

	rep(i, n) cin>>x[i];

	rep(i, n){
		ans+=(x[i]<abs(x[i]-k))?(2*x[i]):(2*abs(x[i]-k));
	}
	cout<<ans<<endl;
}



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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, x ,y;
	cin >> a >> b >> c >> x >> y;
	a = min(2*c,a);
	b = min(2*c,b);
	c = min(2*c,a+b);
	int ans = min(x,y)*c;
	if(x>y){
		ans += a * (x-y);
	}
	else{
		ans += b * (y-x);
	}
	cout << ans << endl;
}

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

int n, m;
vector<int> g[100055];

int dp[100055];

void dfs(int v) {
	dp[v] = 0;
	
	for (auto u : g[v]) {
		if (dp[u] == -1) {
			dfs(u);
		}
		
		dp[v] = max(dp[v], dp[u] + 1);
	}
}
int main() {
	cin >> n >> m;
	
	while (m--) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;
		
		g[x].push_back(y);
	}
	
	memset(dp, -1, sizeof(dp));
	
	for (int i = 0; i < n; i++) if (dp[i] == -1) {
		dfs(i);
	}
	
	int res = *max_element(dp, dp + n);
	
	cout << res;
}


Measured memory_bytes: 8192
n = int(input())
h = list(map(int,input().split()))
c_list = []
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        c_list.append(count)
        count = 0
c_list.append(count)
print(max(c_list))

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

int main() {
  int N;
  cin >> N;
  vector<long> a(N);
  vector<long> s(N);
  
    for(int i=0;i<N;i++){
       cin>>a[i];
      if(i==0) s[0] = a[0];
       else s[i] =s[i-1]+a[i];
     }
  //cout<<s[0]<<endl;
  //cout<<s[N-1]<<endl;
  long m=99999999999999999;
    for(int i=0;i<N-1;i++){
      long sunuke = s[i];
      long arai= s[N-1]-s[i];
      long dif = abs(sunuke-arai);
      m =min(dif,m);
    }
cout<<m<<endl;

  }


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    rep(i, 2) rep(j, n) cin >> a[i][j];
    vector<vector<int>> dp(2, vector<int>(n));
    dp[0][0] = a[0][0];
    rep(i, 2) rep(j, n) {
        if ( i == 0 ) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + a[i+1][j]);
        }
        if ( j != n - 1 ){
            dp[i][j+1] = max(dp[i][j+1], dp[i][j] + a[i][j+1] );
        }
    }
    cout << dp[1][n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int group;//クラスの人数
    int HowMany;//グループの人数
    cin >> group;
    int GP = group / 3;
    if(GP >= 1){
        HowMany += GP;
        /*if(GP2 >= 1){
            HowMany += GP2 / 3;
             cout << HowMany << endl;
        }*/
         cout << HowMany << endl;
        
    }else{
        HowMany = 0;
        cout << HowMany << endl;
    }
}

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

int main(){
	int n,d,x;
	cin>>n>>d>>x;
	vector<int> a(n);
	for(auto&e:a)cin>>e;
	for(int i=0; i<n; i++){
		x+=(d+a[i]-1)/a[i];
	}
	cout<<x<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  string  S;
  cin >> S;
  ll T=S.size();
  while(T>0){
    if(T>=5  && S.substr(T-5,5)=="dream"){
      T-=5;
    }
    else if(T>=7 && S.substr(T-7,7)=="dreamer"){
      T-=7;
    }
    else if(T>=6 && S.substr(T-6,6)=="eraser"){
      T-=6;
    }
    else if(T>=5 && S.substr(T-5,5)=="erase"){
      T-=5;
    }
    else{
      cNO;
      return 0;
    }
  }
  cYES;
}


Measured memory_bytes: 512
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

    int year;
    string name;

int main(){
    int n, m;
    cin >> n>> m;
    string ans = "kogakubu10gokan";
    rep(i,n){
        cin >> year >> name;
            if(m >= year){
                ans = name;
            }
    }
    cout << ans << endl;
}

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

// auto mod int
// https://github.com/atcoder-live/library/blob/master/mint.cpp
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i, k) cin >> l.at(i) >> r.at(i);
    
    vector<mint> dp(n+1), dpsum(n+1);
    dp.at(1) = 1;
    dpsum.at(1) = 1;
    for (int i = 2; i <= n; ++i) {
        rep(j, k) {
            int li = i - r.at(j);
            int ri = i - l.at(j);
            if (ri < 0) continue;
            if (li < 1) li = 1;
            dp.at(i) += dpsum.at(ri) - dpsum.at(li - 1);
        }
        dpsum.at(i) = dpsum.at(i-1) + dp.at(i);
    }
    
    cout << dp.at(n) << endl;
    return 0;
}

Measured memory_bytes: 6432
program main
  implicit none
  integer ::  M
  integer, allocatable :: a(:),b(:),x(:),y(:),c(:)
  integer :: i,j
  integer :: min_tmp,tmp
  read(*,*) i, j, M
  allocate(a(i),b(j))

  read(*,*) a
  read(*,*) b
  allocate( x(M), y(M), c(M))
  do i = 1, M
     read(*,*) x(i), y(i),c(i)
  end do

  min_tmp = minval(a) + minval(b)
  do i = 1,M
     tmp = a(x(i)) + b(y(i)) -c(i)
     if (min_tmp > tmp ) then
        min_tmp = tmp
     end if
  end do

  write(*,'(i0)') min_tmp

end program main


Measured memory_bytes: 2816
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int m[3][3];
  for (int i = 0; i < 3; ++i)
    cin >> m[i][0] >> m[i][1] >> m[i][2];

  int N;
  cin >> N;

  for (int i = 0; i < N; ++i) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (m[i][j] == b)
          m[i][j] = -1;
      }
    }
  }

  bool found = false;

  // check horizontal
  for (int i = 0; i < 3; ++i) {
    if (m[i][0] == -1 && m[i][1] == -1 && m[i][2] == -1) {
      found = true;
      break;
    }
  }

  if (found) {
    cout << "Yes" << endl;
    return 0;
  }

  // check vertical
  for (int i = 0; i < 3; ++i) {
    if (m[0][i] == -1 && m[1][i] == -1 && m[2][i] == -1) {
      found = true;
      break;
    }
  }

  if (found) {
    cout << "Yes" << endl;
    return 0 ;
  }

  // check diagonal
  if (m[0][0] == -1 && m[1][1] == -1 && m[2][2] == -1) {
    cout << "Yes" << endl;
    return 0;
  }
  if (m[0][2] == -1 && m[1][1] == -1 && m[2][0] == -1) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <climits>
#include <algorithm>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n), b(n);
  vector<long long> c(m), d(m);
  for (int i=0; i<n; i++) {
    cin >> a[i];
    cin >> b[i];
  }
  for (int i=0; i<m; i++) {
    cin >> c[i];
    cin >> d[i];
  }

  for (int i=0; i<n; i++) {
    long long min_dist = LONG_LONG_MAX;
    int ans;
    for (int j=0; j<m; j++) {
      long long dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if (dist < min_dist) {
        min_dist = dist;
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
struct no{
  no *left,*right;
  no(){left=right=NULL;}
};
typedef no* node;
string s[2];
int n;
node con(int l,int r){
  node po=new no();
  int p=0,c=-1;
  for(int i=l+1;i<r;i++)
    if(s[n][i]=='(')p++;
    else if(s[n][i]==')')p--;
    else if(s[n][i]==','&&!p){
      c=i;
      break;
    }
  if(l+1!=c)po->left=con(l+1,c-1);
  if(r-1!=c)po->right=con(c+1,r-1);
  return po;
}
string init(node a,node b){
  string l,r;
  if(a->left!=NULL&&b->left!=NULL)
    l=init(a->left,b->left);
  if(a->right!=NULL&&b->right!=NULL)
    r=init(a->right,b->right);
  return "("+l+","+r+")";
}
string unit(node a,node b){
  string l,r;
  if((a!=NULL&&a->left!=NULL)||(b!=NULL&&b->left!=NULL))
    l=unit((a!=NULL?a->left:a),(b!=NULL?b->left:b));
  if((a!=NULL&&a->right!=NULL)||(b!=NULL&&b->right!=NULL))
    r=unit((a!=NULL?a->right:a),(b!=NULL?b->right:b));
  return "("+l+","+r+")";
}
int main(){
  string s1;
  while(cin>>s1>>s[0]>>s[1]){
    n=0;node a=con(0,s[0].size()-1);
    n=1;node b=con(0,s[1].size()-1);
    if(s1=="i")cout<<init(a,b)<<endl;
    else cout<<unit(a,b)<<endl;
  }
}

Measured memory_bytes: 3068
#%%
n, m = map(int, input().split())
p = list(map(int, input().split()))
x, y = [0] * m, [0] * m
reach = [[] for _ in range(n + 1)]
for i in range(m):
    x[i], y[i] = map(int, input().split())
    reach[x[i]].append(y[i])
    reach[y[i]].append(x[i])


check = [0] * (n + 1)
color = [-1] * (n + 1)
c = -1

for i in range(n + 1):
    if check[i] == 1:
        pass
    else:
        c += 1
        check[i] = 1
        stack = reach[i]
        color[i] = c
        while len(stack) >= 1:
            tmp = stack.pop(-1)
            color[tmp] = c
            check[tmp] = 1
            tmp_list = reach[tmp]
            for i in range(len(tmp_list)):
                if check[tmp_list[i]] == 0:
                    stack.append(tmp_list[i])
                    check[tmp_list[i]] = 1
                else:
                    pass

color.pop(0)
#print(color)

ans_list = [0] * n
for i in range(n):
    ans_list[i] = color[p[i] - 1]
#print(ans_list)

ans = 0
for i in range(n):
    if color[i] == ans_list[i]:
        ans += 1
print(ans)

Measured memory_bytes: 29540
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long a[N] , b[N] , n , cnt , res;
int main(){
	int a , b , cnt = 0;
	cin >> a >> b;
	int c = a - 1;
	a = 1;
	while(a < b) a += c , cnt ++;
	cout << cnt << "\n";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static Map<BigInteger, Integer> memo;
    static boolean[][] vis;
    static List<List<Integer>> adj;
    static List<Integer> vertices;

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

        long h = sc.nextLong();

        System.out.println(countWin(h));
    }

    static long countWin(long h) {
        if (h == 1)
            return 1;

        return 2 * countWin(h / 2) + 1;

    }

    static int lowerBound(int[] arr, int element) {

        int low = 0, high = arr.length - 1, ans = 0;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            if (arr[mid] <= element) {
                low = mid + 1;
                ans = mid;
            } else
                high = mid - 1;

        }

        return high;
    }

    static boolean isPalindrome(String word) {
        int i = 0, j = word.length() - 1;

        while (i <= j) {
            if (word.charAt(i++) != word.charAt(j--))
                return false;
        }

        return true;
    }

    static String longestPalindrome(String[] words, String word, int i) {
        if (i >= words.length) {
            if (isPalindrome(word))
                return word;

            return "";
        }

        if (word.length() > 0 && isPalindrome(word))
            return word;
        String left = longestPalindrome(words, word + words[i], i + 1);
        String right = longestPalindrome(words, word, i + 1);

        if (left.length() > 0)
            return left;
        return right;
    }


    static int solve(int[] arr, int i, int j, int k) {
        if (i == j && arr[i] <= k)
            return 1;

        int left = 0, right = 0;
        if (arr[i] <= k)
            left = solve(arr, i + 1, j, k) + 1;

        else if (arr[j] <= k)
            right = solve(arr, i, j - 1, k) + 1;

        return left + right;
    }

    static int minMove(BigInteger bg, int count) {
        if (bg.equals(BigInteger.ONE))
            return count;

        int first = Integer.MAX_VALUE, sec = Integer.MAX_VALUE, last = Integer.MAX_VALUE;
        if (bg.mod(BigInteger.valueOf(2)).compareTo(BigInteger.ZERO) == 0)
            first = minMove(bg.divide(BigInteger.valueOf(2)), count + 1);

        else if (bg.mod(BigInteger.valueOf(3)).compareTo(BigInteger.ZERO) == 0)
            sec = minMove(bg.multiply(BigInteger.valueOf(2)).divide(BigInteger.valueOf(3)), count + 1);

        else if (bg.mod(BigInteger.valueOf(5)).compareTo(BigInteger.ZERO) == 0)
            last = minMove(bg.multiply(BigInteger.valueOf(4)).divide(BigInteger.valueOf(5)), count + 1);

        if (memo.containsKey(bg))
            return memo.get(bg);

        memo.put(bg, Math.min(first, Math.min(sec, last)));

        return Math.min(first, Math.min(sec, last));
    }
}


Measured memory_bytes: 35848
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string s;
        cin>>s;
        if(s=="SUN")cout<<7;
        if(s=="MON")cout<<6;
        if(s=="TUE")cout<<5;
        if(s=="WED")cout<<4;
        if(s=="THU")cout<<3;
        if(s=="FRI")cout<<2;
        if(s=="SAT")cout<<1;
        cout<<endl;
    }

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
 
int main()
{
    int a,b;
    cin >> a >> b;
    if(a==b) cout << 2*a << endl;
    else cout << max(a,b)*2-1 << endl;
    return 0;
}

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

const int MAXN = 3001;
long long int dp[MAXN][MAXN], a[MAXN], sums[MAXN];
int n;

long long int get_sum(int start, int end){
    if(start == 0){
        return sums[end];
    }
    return sums[end] - sums[start - 1];
}

long long int find_ans(int start = 0, int end = n - 1){
	if(start == end){
	    return 0;
	}else if(dp[start][end] != -1){
	    return get_sum(start,end) - dp[start][end];
	}else{
	    long long int ans1 = find_ans(start + 1, end);
	    long long int ans2 = find_ans(start, end - 1);
	    dp[start][end] = max(a[start] + ans1, a[end] + ans2);
	   // cout << "DP[" << start<< "]["<<end << "] = " << dp[start][end] << "\n"; 
	    return get_sum(start, end) - dp[start][end];
	}
}
  
int main(){
	cin >> n;
	long long int sum = 0;
	for(int i = 0; i < n; ++i){
      cin >> a[i];
      sum += a[i];
      sums[i] = sum;
    }
    
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= n; ++j){
            dp[i][j] = -1;
        }
    }
  
  	long long int ans = find_ans();
//   	cout << ans << "\n";
  	cout << sum - 2 * ans << "\n";
  	return 0;
}

Measured memory_bytes: 74012
H,W,K=map(int,input().split())
C=list()
for i in range(H):
  C.append(input())

h=[0]*H
w=[0]*W
ans=0
  
def cycle(x):
  for i in range(len(x)):
    if x[i]==0:
      x[i]=1
      break
    else:
      x[i]=0
  return x

c=0

for i in range(2**H):
  for j in range(2**W):
    for k in range(H):
      if h[k]==0:
        for l in range(W):
          if w[l]==0 and C[k][l]=="#":
            c+=1
    if c==K:
      ans+=1
    c=0
    cycle(w)
  cycle(h)

print(ans)

Measured memory_bytes: 9232
# https://atcoder.jp/contests/abc089/tasks/abc089_c



N = gets.to_i
Ss = Array.new(N) { gets.chomp }

march_count = Ss.each_with_object(Hash.new(0)) do |s, hash|
  hash[s[0]] += 1 if 'MARCH'.chars.include?(s[0])
end

ans = 0
if march_count.length > 2
  march_count.keys.combination(3) do |a, b, c|
    ans += march_count[a] * march_count[b] * march_count[c]
  end
end

puts ans


Measured memory_bytes: 10108
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    ll maxa = -1, maxb = -1;
    cin >> n;
    imfor(i, n) {
        ll a, b;
        cin >> a >> b;
        if (a > maxa) {
            maxa = a;
            maxb = b;
        }
    }
    cout << maxa + maxb << endl;
}

Measured memory_bytes: 256
import numpy as np
X = int(input())
A = np.array(range(X,X+100))
if X==2:
    print(X)
    exit()

A = np.array(range(3,10**5+4,2))
for i in range(3,int(np.sqrt(10**5+4))+1000,2):
    A = np.where((A%i == 0) & (A//i != 1), 1, A)

A = np.sort(A)
I = np.searchsorted(A,X, side="left")
print(A[I])

Measured memory_bytes: 15688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,a,b,v,w;
    cin>>a>>v>>b>>w>>t;
    if(w>=v){
        cout<<"NO";
        return 0;
    }    
    else {
        v-=w;
        if(t*v>=abs(a-b)){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int max_n (int a[], int n)
{
  int max = a[0];
  int p;
  for (int i = 1; i < n; i++)
    if (a[i] > max) {
      max = a[i];
      p = i;
    }
  return p;
}

int main(void)
{
  int n;
  int p[10];
  int sum = 0;
  int a;

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

  a = max_n(p, n);

  for (int i = 0; i < n; i++) {
    if (i == a)
      sum += p[i] / 2;
    else
      sum += p[i];
  }

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

  return 0;
}


Measured memory_bytes: 128
n = int(input())

for i in range(1,n+1):
  if i % 3 == 0:
    print("", i, end = "")
  else:
      x = i
      while(x):
        if(x % 10 == 3):
          print("", i, end = "")
          break
        x //= 10
print()


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

bool p[1000010];
bool ok[1000010];

void mkprime() {
	for(int i = 0; i < 1000010; i++) {
		p[i] = true;
	}
	p[0] = p[1] = false;
	for(int i = 0; i*i <= 1000010; i++) {
		if(p[i]) {
			for(int j = i*2; j < 1000010; j += i) {
				p[j] = false;
			}
		}
	}
}

int main() {
	int n, x;

	mkprime();
	while(cin >> n >> x, n || x) {
		vector<int> v;
		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			v.push_back(tmp);
		}
		for(int i = 0; i < 1000010; i++) {
			ok[i] = false;
		}
		ok[0] = true;
		for(int i = 0; i < v.size(); i++) {
			for(int j = 0; j < x + 10; j++) {
				if(j - v[i] >= 0 && ok[j - v[i]]) {
					ok[j] = true;
				}
			}
		}

		bool flg = true;
		for(int i = x; i >= 0; i--) {
			if(ok[i] && p[i]) {
				flg = false;
				cout << i << endl;
				break;
			}
		}
		if(flg) {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 3172
import java.util.Scanner;


public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] l = new int[n];
        for(int i=0;i<n;i++){
            l[i] = Integer.parseInt(sc.next());
        }
        sort(l, 0, n-1);
        int max = l[0];
        int sum = 0;
        for(int i=1;i<n;i++){
            sum += l[i];
        }
        if(max < sum){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

    

    public static void sort(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left + right)/2];
        int l=left, r=right;
        int tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp=d[l];
                d[l]=d[r];
                d[r]=tmp;
                l++;r--;
            }
        }
        sort(d, left, r);
        sort(d, l, right);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;
  
ll f(ll a,ll b){
  return a*a*a*a*a-b*b*b*b*b;
}

int main() {
  ll X;
  cin>>X;
  ll a=0,b=0,c=1;
  while(c){
    b=a;
    while(c){
   //   cout<<a<<" "<<b<<endl;
      
      if(f(a,b)==X){
        cout<<a<<" "<<b;
        c=0;
      }
      if(f(a,b)>X){
        break;
      }
      b--;
    }
    a++;
  }
  
      
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    int n;
    ll l[100];

    scanf("%d", &n);
#if 1
    l[0]=2LL, l[1]=1LL;
    for(int i = 2; i <= n; i++){
        l[i]= l[i-2] + l[i-1];
    }
    printf("%lld\n", l[n]);
#endif
    //ll ans = lucas(n);

    //printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main() {
  int x, y;

  cin >> x >> y; 

  if(x<=y){
    if(x>=0 || y<=0){
      cout << y-x << endl;
      return 0;
    }else if(-x>y){
      cout << -y-x+1 << endl;
      return 0;
    }else{
      cout << y+x+1 << endl;
      return 0;
    }
  }else if(x==0){
    cout << x-y+1 << endl;
  }else if(y>0 || x<0){
    cout << x-y+2 << endl;
  }else if(x>-y){
    cout << y+x+1 << endl;
  }else if(x<=-y){
    cout << -y-x+1 << endl;
  }
  return 0;  
}
	
  

Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  //vector<set> like(N);
  int ans=0;
  for(int i=0;i<N;++i){
    cin >> a.at(i);
    --a.at(i);
    if(a.at(i)<i){
      if(a.at(a.at(i))==i) ++ans;
    }
  }

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


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

int main() {
	string s; cin >> s;
	set<char> n;
	n.insert(s[0]);
	n.insert(s[1]);
	n.insert(s[2]);
	if(n.size()==3) cout << "Yes";
	else cout << "No";
	cout << endl;
}

Measured memory_bytes: 3600
package main

import "fmt"

func main() {
	var (
		a   int
		b   int
		ans int
	)

	fmt.Scan(&a, &b)

	for i := 0; i < 2; i++ {
		if a > b {
			ans = ans + a
			a = a - 1
		} else if a <= b {
			ans = ans + b
			b = b - 1
		}
	}

	fmt.Print(ans)

}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
int a[200002];
int cnt[200002];
int deg[200002];
vector<int> adj[200002];
vector<int> mapper;
bool vis[200002];
int p2[33];

int main(){
    p2[0] = 1;
    for(i=1;i<=31;++i)
        p2[i] = 2*p2[i-1];
    memset(cnt, 0, sizeof cnt);
    memset(vis, false, sizeof vis);
    scanf("%d", &n);
    multiset<int> s;
    for(i=0;i<n;++i){
        scanf("%d", a+i);
        mapper.pb(a[i]);
        s.insert(a[i]);
    }
    sort(mapper.begin(), mapper.end());
    mapper.erase(unique(mapper.begin(), mapper.end()), mapper.end());
    for(i=0;i<n;++i){
        ++cnt[lower_bound(mapper.begin(), mapper.end(), a[i]) - mapper.begin()];
    }
    for(i=0;i<mapper.size();++i){
        for(j=0;j<=30;++j){
            if(p2[j] <= 2 * mapper[i]) continue;
            int idx = lower_bound(mapper.begin(), mapper.end(), p2[j] - mapper[i]) - mapper.begin();
            if(idx < mapper.size() && mapper[idx] + mapper[i] == p2[j]){
                adj[i].pb(idx);
                adj[idx].pb(i);
                deg[i]++;
                deg[idx]++;
            }
        }
    }
    queue<int> q;
    for(i=0;i<mapper.size();++i){
        int idx = lower_bound(p2, p2+31, mapper[i]) - p2;
        if(deg[i] == 1 && mapper[i] != p2[idx]){
            q.push(i);
        }
    }
    int ans = 0;
    while(!q.empty()){
        int tmp = q.front();
        q.pop();
        if(vis[tmp]) continue;
        vis[tmp] = true;
        for(int x : adj[tmp]){
            if(vis[x]) continue;
            int val = min(cnt[tmp], cnt[x]);
            ans += val;
            cnt[tmp] -= val;
            cnt[x] -= val;
            if(--deg[x] == 1)
                q.push(x);
            break;
        }
    }
    for(i=0;i<mapper.size();++i){
        int idx = lower_bound(p2, p2+31, mapper[i]) - p2;
        if(mapper[i] != p2[idx]) continue;
        if(vis[i]){
            ans += cnt[i]/2;
            cnt[i] &= 1;
        }
        else if(deg[i] == 1){
            q.push(i);
        }
        else{
            ans += cnt[i]/2;
            cnt[i] &= 1;
        }
    }
    while(!q.empty()){
        int tmp = q.front();
        q.pop();
        if(vis[tmp]) continue;
        vis[tmp] = true;
        for(int x : adj[tmp]){
            if(vis[x]) continue;
            int val = min(cnt[tmp], cnt[x]);
            ans += val;
            cnt[tmp] -= val;
            cnt[x] -= val;
            if(--deg[x] == 1)
                q.push(x);
            break;
        }
        if(cnt[tmp]){
            ans += cnt[tmp]/2;
            cnt[tmp] &= 1;
        }
    }
    printf("%d\n", ans);
	return 0;
}

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

using namespace std;
#define maxn 100000
int n, m;
struct obj
{
    int l, r;
}a[maxn];

void input()
{
    cin >> n >> m;
    for(int i=0; i<m; ++i)
        cin >> a[i].l >> a[i].r;
}

bool cmp(obj a, obj b)
{
    return a.l < b.l;
}

int solve()
{
    sort(a, a+m, cmp);
    int l = 0, r = n;
    for(int i=0; i<m; ++i)
    {
        l = a[i].l; r = min(r, a[i].r);
    }
    if(l > r)
        return 0;
    else
        return r - l + 1;
}

int main()
{
    //freopen("test.inp","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    input();
    cout << solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {

	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	string s = ":(";

	if (e - a <=k ) {
		s = "Yay!";
	}
	cout << s << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
      int A,B,x;
      
      scanf("%d%d",&A,&B);
      
      if(A>B){
        x=A*2-1;
        printf("%d\n",x);
      }
      else if(A<B){
        x=B*2-1;
        printf("%d\n",x);
      }
      else{
        x=A+B;
        printf("%d\n",x);
      }
      return 0;
    }

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

int main()
{
    ll N, M;
    cin >> N >> M;

    priority_queue<ll> A;
    rep (i, N) {
        ll price;
        cin >> price;
        A.push(price);
    }

    rep (i, M) {
        ll price = A.top() / 2;
        A.pop();

        A.push(price);
    }

    ll answer = 0;
    while (!A.empty()) {
        answer += A.top();
        A.pop();
    }

    cout << answer << endl;
    return 0;
}


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

using namespace std;
#define BUF (1000)
#define ll long long 


ll n;
float snk(ll a){
	ll tmp=0;
	ll a_ = a;
	for(ll i=1;i<16;i++){
		tmp+=a_%10;
		a_/=10;
	}
	return (float)a/tmp;
}

int main(void){
	cin >> n;

	ll i=1;
	while(n){
		ll b = 10;
		float ans = snk(i);
		ll tmp=i;
		for(ll k=1;k<16;k++){
			if(ans>snk(i/b*b+b-1)){
				tmp = i/b*b+b-1;
				ans = snk(i/b*b+b-1);
			}
			b*=10;
		}
		cout << tmp << "\n";
		i=tmp+1;
		n--;
	}


	return 0;
}




Measured memory_bytes: 256
n, m, c = map(int, input().split())

b = list(map(int,input().split()))
ans = 0

for i in range(n):
    tmp = 0
    s = list(map(int,input().split()))
    for j in range(m):
        tmp += s[j]*b[j]
    tmp += c
    if tmp > 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        String temp = n.toUpperCase();
        if (n.equals(temp)) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35712
#include <iostream>
using namespace std;
int ch[23][23],cnt;
void dfs(int,int);
int main(){
  int w,h,i,j,k,l;
  string in[21];
  while(1){
    cnt=0;
    cin >> w >> h;
    if(w==0&&h==0) break;
    for(i=0;i<h;i++){
      cin >> in[i];
    }
    for(i=0;i<h+2;i++){
      for(j=0;j<w+2;j++){
    ch[i][j]=1;
      }
    }
    for(i=0,k=1;k<h+1;i++,k++){
      for(j=0,l=1;l<w+1;l++,j++){
    if(in[i][j]=='.') ch[k][l]=0;
    else if(in[i][j]=='#') ch[k][l]=1;
    else ch[k][l]=2;
      }
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
    if(ch[i][j]==2) dfs(i,j);
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
void dfs(int i,int j){
  if(ch[i][j]==1) return ;
  ch[i][j]=1;
  cnt++;
  dfs(i+1,j);
  dfs(i-1,j);
  dfs(i,j-1);
  dfs(i,j+1);
}

Measured memory_bytes: 1216
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;
//約数の列挙O(√n)
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int>a(m);
  for(int i=0;i<m;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int count=0;
  for(int i=0;i<m;i++){
    if(a[i]<x)count++;
  }
  cout<<min(count,m-count)<<endl;
}

Measured memory_bytes: 256
"use strict"

const main = (input) => {
    const parsedInput = parser(input);
    console.log(maxFloor(parsedInput.a, parsedInput.b, parsedInput.n));
}

const parser = (inputStr) => {
    const splitInput = inputStr.split(' ');
    return {
        a: Number(splitInput[0]),
        b: Number(splitInput[1]),
        n: Number(splitInput[2]),
    };
}

const maxFloor = (a, b, n) => {
    if ( b - 1 < n ) {
        return Math.floor((a * (b - 1)) / b) - (a * Math.floor((b - 1) / b));
    } else {
        return Math.floor((a * n) / b) - (a * Math.floor(n / b));
    }
}
// test
// const Q1 = '5 7 4'
// const Q2 = '11 10 2000';
// main(Q1);
// main(Q2);
// main(Q2);
// main(Q3);
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29628
#from collections import deque, Counter
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#from decimal import Decimal
#mod = 1000000007
#mod = 998244353
#N = int(input())
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################
 
#####ide_ele#####
ide_ele = -1
#################
 
class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
 
    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
 
    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele
 
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res



### https://qiita.com/ell/items/fe52a9eb9499b7060ed6 heapについて　最大最小の取り出し
N, K = map(int, input().split())
tree = [0 for _ in range(400000)]
tree = SegTree(tree, segfunc, ide_ele)
for k in range(N):
  A = int(input())
  n = tree.query(max(0, A-K), min(400000, A+K+1))
  tree.update(A, n+1)
print(tree.query(0, 400000))
#A = list(map(int, input().split()))
#flag = True
#for k in range(N):
#ans = 0
#print(ans)
#print('Yes')
#print('No')

Measured memory_bytes: 104388
x = [int(i) for i in input().split()]
n, k = x[0], x[1]
ans = 0
for i in range(1, n+1):
  temp, cnt = i, 0
  while(temp < k):
    temp = temp*2
    cnt = cnt + 1
  ans = ans + 0.5 ** cnt
ans = ans / n
print(ans)
  

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

int main()
{
    int N;
    int W;
    cin >> N >> W;
    long int w[N];
    long int v[N];
    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    long int dp[N + 1][W + 1];
    for (int i = 0; i < N + 1; i++)
    {
        dp[i][0] = 0;
    }
    for (int j = 0; j < W + 1; j++)
    {
        dp[0][j] = 0;
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < W + 1; j++)
        {
            if (j < w[i])
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                long int dp1 = dp[i][j];
                long int dp2 = dp[i][j - w[i]] + v[i];
                dp[i + 1][j] = max(dp1, dp2);
            }
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define N 2005
#define INF 0x3f3f3f3f
#define umx(i,j) ((i)=max(i,j))
//int n,a[N*3],dp2[2],dp1[2][N],dp[2][N][N],add=0;
int n,a[N*3],dp2,dp1[N],dp[N][N],add=0;

inline void upd(int i,int j,int v){
	umx(dp[i][j],v);umx(dp[j][i],v);
	//dp1[i]=max(dp1[i],v);dp1[j]=max(dp1[j],v);
	umx(dp1[i],v);umx(dp1[j],v);
	umx(dp2,v);
}
/*
inline int pnt(int v){
	return v<0?-1:v;
}
*/
struct Node{
	int i,j,v;
	inline Node(int ii,int jj,int vv){i=ii;j=jj;v=vv;}
};
vector<Node> gx;
int main(){
	/*
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
	*/
	scanf("%d",&n);
	for(int i=1;i<=3*n;++i) scanf("%d",a+i);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j) dp[i][j]=-INF;
		dp1[i]=-INF;
	}
	dp2=0;
	dp1[a[1]]=0;dp1[a[2]]=0;
	dp[a[1]][a[2]]=0;dp[a[2]][a[1]]=0;
	for(int i=1;i<n;++i){
		sort(a+3*i,a+3*i+3);
		if(a[3*i]==a[3*i+2]){
			++add;
			continue;
		}
		gx.push_back(Node(a[3*i+1],a[3*i+2],max(dp2,dp[a[3*i]][a[3*i]]+1)));
		gx.push_back(Node(a[3*i],a[3*i+2],max(dp2,dp[a[3*i+1]][a[3*i+1]]+1)));
		gx.push_back(Node(a[3*i],a[3*i+1],max(dp2,dp[a[3*i+2]][a[3*i+2]]+1)));
		for(int j=1;j<=n;++j){
			gx.push_back(Node(j,a[3*i],max(dp1[j],dp[j][a[3*i+1]]+(a[3*i+1]==a[3*i+2]))));
			gx.push_back(Node(j,a[3*i+1],dp1[j]));
			gx.push_back(Node(j,a[3*i+2],max(dp1[j],dp[j][a[3*i+1]]+(a[3*i+1]==a[3*i]))));
		}
		for(int j=0;j<gx.size();++j) upd(gx[j].i,gx[j].j,gx[j].v);
		gx.clear();
	}
	++dp[a[3*n]][a[3*n]];
	umx(dp1[a[3*n]],dp[a[3*n]][a[3*n]]);
	umx(dp2,dp1[a[3*n]]);
	printf("%d\n",dp2+add);
	return 0;
}

Measured memory_bytes: 19652
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool f = abs(a - c) <= d;
    f |= (abs(a - b) <= d && abs(b - c) <= d);
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

#+++++
		
def main():
	a = int(input())
	print(3*a*a)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    string s;

    cin >> s;

    s[5] = ' '; s[13] = ' ';

    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;
ll gcd( ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main (void) {
    ll N, ans;
    cin >> N;
    ll A, B;
    cin >> A;
    cin >> B;
    ans = gcd(A,B);
    REP(ll,i,2,N){
        cin >> A;
        ans = gcd(ans,A);
    }
    cout << ans << endl;
    return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

const int N_MAX = 3010;



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> A;
    int sum = 0;
    rp(i, 0, n) {
        int a;
        scanf("%d", &a);
        sum += a;
        A.emplace_back(a);
    }
    vector<int> d;
    for(int i = 1; i * i <= sum; i++) {
        if(sum%i == 0) {
            d.emplace_back(i);
            if(i != sum/i) d.emplace_back(sum/i);
        }
    }

    sort(d.rbegin(), d.rend());
    for(auto x: d) {
        int cnt = 0;
        priority_queue<int> q;
        rp(i, 0, n) {
            cnt += A[i]%x;
            q.push(A[i]%x);
        }
        int s = cnt / x;
        rp(i, 0, s) {
            cnt -= q.top(); q.pop();
        }
        if(cnt <= k) {
            cout << x << endl;
            return 0;
        }
    }
}


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

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

    vector<unsigned int> a(n);
    for(auto &e: a) {
        cin >> e;
    }
    vector<unsigned int> result(n);
    for(unsigned int i = 0; i < n; ++i) {
        result.at(a.at(i)-1) = i + 1;
    }
    for(auto e : result) {
        cout << e << " ";
    }
    cout << endl;

}



Measured memory_bytes: 1536
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    foreach (i; 1 .. n+1) {
        if (i % 3 == 0 || i.to!string.canFind("3")) write(" ", i);
    }
    writeln;
}


Measured memory_bytes: 2476