akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define M 10000
int dp[2][2][10][500];
char a[501];
char b[501];
int m;
int solve(char s[],bool cont){
	memset(dp,0,sizeof(dp));
	int n=strlen(s);
	int i,j,k,l;
	int pre=2,cur=2;
	int mm=0;
	bool use=true;
	int d=s[0]-'0';
	for(i=1;i<d;i++){
		dp[0][0][i][i%m]=1;
		dp[0][1][i][i%m]=1;
	}
	mm=d%m;
	if(n==1){
		int ans=0;
		for(i=1;i<d;i++)if(i%m==0)ans++;
		if(cont&&mm==0)ans++;
		return ans;
	}
	for(i=1;i<n;i++){
		for(j=0;j<2;j++)for(k=0;k<10;k++)for(l=0;l<m;l++)dp[i%2][j][k][l]=0;
		for(j=1;j<10;j++){
			dp[i%2][0][j][j%m]=1;
			dp[i%2][1][j][j%m]=1;
		}
		for(j=0;j<10;j++){
			for(k=0;k<m;k++){
				for(l=0;l<j;l++)dp[i%2][0][l][(k*10+l)%m]=(dp[i%2][0][l][(k*10+l)%m]+dp[(i+1)%2][1][j][k])%M;
				for(l=j+1;l<10;l++)dp[i%2][1][l][(k*10+l)%m]=(dp[i%2][1][l][(k*10+l)%m]+dp[(i+1)%2][0][j][k])%M;
			}
		}
		if(use){
			d=s[i]-'0';
			for(j=0;j<d;j++){
				if(cur==1||cur==2)if(j<s[i-1]-'0')dp[i%2][0][j][(mm*10+j)%m]++;
				if(cur==-1||cur==2)if(j>s[i-1]-'0')dp[i%2][1][j][(mm*10+j)%m]++;
			}
			pre=cur;
			if(s[i]>s[i-1])cur=1;
			else if(s[i]<s[i-1])cur=-1;
			else cur=0;
			if(pre==cur||cur==0)use=false;
		}
		mm=(mm*10+d)%m;
	}
	int ans=0;
	for(i=0;i<10;i++){
		ans+=dp[(n+1)%2][0][i][0];
		ans+=dp[(n+1)%2][1][i][0];
		if(i>=1&&i%m==0)ans--;
	}
	if(use&&cont&&mm==0)ans++;
	return ans%M;
}
int main(){
	scanf(" %s",a);
	scanf(" %s",b);
	scanf("%d",&m);
	int p=solve(a,false);
	int q=solve(b,true);
	printf("%d\n",(q-p+M)%M);
	return 0;
}

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

int main(){
  vector<long long>a(3);
  long long Y;
 cin>>a[0]>>a[1]>>a[2]>>Y;
sort(a.begin(),a.end());
for(int i=0;i<Y;i++){
a[2]*=2;
}
 
    cout<<a[0]+a[1]+a[2]<<endl;
}


Measured memory_bytes: 256
<?php
list($W, $H, $N) = explode(' ', trim(fgets(STDIN)));
$data = [];
for ($i = 0; $i < $N; $i++) {
    $data[] = explode(' ', trim(fgets(STDIN)));
}

$xmin = 0;
$xmax = $W;
$ymin = 0;
$ymax = $H;

foreach ($data as $d) {
    $x = $d[0];
    $y = $d[1];
    $a = $d[2];

    switch($a) {
    case 1:
        $xmin = max($x, $xmin);
        break;
    case 2:
        $xmax = min($x, $xmax);
        break;
    case 3:
        $ymin = max($y, $ymin);
        break;
    case 4:
        $ymax = min($y, $ymax);
        break;
    }
}

$w = max($xmax - $xmin, 0);
$h = max($ymax - $ymin, 0);

$s = (int)($w * $h);

echo "$s\n";

Measured memory_bytes: 3704
/*  -*- coding: utf-8 -*-
 *
 * 2925.cc: Angel Relief
 */

#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 */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  ll sum = 0;
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) {
      int a;
      scanf("%d", &a);
      sum += (ll)(y + 1) * (h - y) * (x + 1) * (w - x) * a;
    }

  printf("%lld\n", sum);
  return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

// mint N;

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;

// -------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(N,vector<int> (N,0));
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    for(int j=0; j<a; j++){
      int x,y;
      cin >> x >> y;
      x--;
      if(y == 1){
        A[i][x] = 2;
      }
      if(y == 0){
        A[i][x] = 1;
      }
    }
  }
  int ans=0;
  for(int bit=0; bit<(1<<N); bit++){
    vector<int> h(N,0);
    bool can=true;
    for(int i=0; i<N; i++){
      if(bit & (1<<i)){
        h[i] = 2;
      }else{
        h[i] = 1;
      }
    }
    for(int i=0; i<N; i++){
      if(bit & (1<<i)){
        for(int j=0; j<N; j++){
          if(A[i][j] == 1){
            if(h[j]==0 || h[j]==1){
              h[j] = 1;
            }else{
              can = false;
            }
          }
          if(A[i][j] == 2){
            if(h[j]==0 || h[j]==2){
              h[j] = 2;
            }else{
              can = false;
            }
          }
        }
      }
    }
    if(can){
      ans = max(ans,__builtin_popcount(bit));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  	int n;
  	string s;
    cin>>n;
    cin>>s;
    int ans = 0;
    for (int i = 1;i < n;i++){
        int cnt = 0;
        
        for (char c = 'a';c <= 'z';c++){
          bool left = false,right = false;
            for (int j=0;j<i;j++){
                if(s[j] == c) left = true;                
            }
            for (int j=i;j<n;j++){
                if(s[j] == c) right = true;
            }
            if(left&&right) cnt++;
        }
        if(cnt>ans) ans=cnt;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cstdlib>
using namespace std;

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  map<string,int> mp;
  for(int i = 0;i < s.size();i++){
    string emp = "";
    for(int j = i;j < min((int)s.size(),i+K);j++){
      emp += s[j];
      mp[emp] = 1;
    }
  }

  int index = 0;

  for(auto itr = mp.begin();itr != mp.end();itr++){
    if(index == (K-1)){
      cout << itr->first << endl;
      return 0;
    }
    index++;
  }
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ans = INF;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			string a = to_string(i); string b = to_string(n / i);
			chmin(ans, (int)max(a.size(), b.size()));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

buy = [0] * n
sell = [0] * n

prev = 1000
for i in range(n - 1):
    if a[i+1] > a[i]:
        buy[i] += 1

    if a[i+1] < a[i]:
        sell[i] += 1

for i in range(n - 1, 0, -1):
    if a[i-1] < a[i]:
        buy[i-1] += 1

    if a[i-1] > a[i]:
        sell[i-1] += 1

kabu = 0
money = 1000
for i, e in enumerate(a):
    if buy[i] == 2:
        get = money // e
        kabu += get
        money -= get * e

    if sell[i] == 2:
        money += kabu * e
        kabu = 0

if kabu:
    money += a[-1] * kabu

print(money)


Measured memory_bytes: 9240
tile = list(int(x) for x in input())
#print(tile)
tile1 = []
tile2 = []
for i in range(len(tile)):
    if i%2 == 1:
        tile1.append(1)
        tile2.append(0)
    else:
        tile1.append(0)
        tile2.append(1)
#print(tile1)
#print(tile2)
import numpy as np
tile = np.array(tile)
tile1 = np.array(tile1)
tile2 = np.array(tile2)
sum1 = sum(abs(tile-tile1))
sum2 = sum(abs(tile-tile2))
print(min(sum1,sum2))

Measured memory_bytes: 16356
n=int(input())
s=str(input())
s=list(s)
tempw=s.count("W")
ans=n-tempw
cnt=n-tempw
if s[0]=="E":
  ans=ans-1
  cnt=cnt-1
for i in range(1,n):
  if s[i-1]=="W":
    cnt=cnt+1
  if s[i]=="E":
    cnt=cnt-1
  ans=min(ans,cnt)  
print(ans)

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

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a<b&&b<c)
	{
		printf("Yes\n");
	}else
	{
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 2128
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		int strCount = Integer.parseInt(line[0]);
		int changeNumber = Integer.parseInt(line[1]);
		String target = sc.nextLine();
		
		String result = "";
		for(int i = 0;i<strCount;i++) {
			Character tmp = target.charAt(i);
			if((changeNumber - 1) == i) {
				tmp = tmp.toLowerCase(tmp);
			}
			
			result += tmp;
		}

		
		System.out.println(result);

		
		
		
	}
}
	
	

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

int main(){
  char h[100],w[100];
  scanf("%s",h);
  scanf("%s",w);
  int a[strlen(h)],b[strlen(w)];
  for(int i=0;i<strlen(h);i++)a[i]=h[i];
  for(int i=0;i<strlen(w);i++)b[i]=w[i];
  for(int i=0;i<strlen(h);i++){
    int min=i;
    for(int j=0;j<strlen(h)-i;j++){
      if(a[min]>a[i+j])min=i+j;
    }
    int temp=a[i];
    a[i]=a[min];
    a[min]=temp;
  }
  for(int i=0;i<strlen(w);i++){
    int min=i;
    for(int j=0;j<strlen(w)-i;j++){
      if(b[min]<b[i+j])min=i+j;
    }
    int temp=b[i];
    b[i]=b[min];
    b[min]=temp;
  }
  //for(int i=0;i<strlen(h);i++)printf("%d ",a[i]);
  //for(int i=0;i<strlen(w);i++)printf("%d ",b[i]);

  int ab;
  if(strlen(h)>=strlen(w)){
    ab=strlen(w);
    for(int i=0;i<ab;i++){
      if(a[i]<b[i]){
        printf("Yes");
        return 0;
      }else if(a[i]>b[i]){
        printf("No");
        return 0;
      }
    }
    //if(strcmp(h,w)<0){printf("Yes\n");return 0;}
    printf("No");
    return 0;
  }
  else{
    ab=strlen(h);
  for(int i=0;i<ab;i++){
    if(a[i]<b[i]){
      printf("Yes");
      return 0;
    }
    else if(a[i]>b[i]){
      printf("No");
      return 0;
    }
  }
  if(strcmp(h,w)==0){printf("No");return 0;}
  printf("Yes");
}
}


Measured memory_bytes: 128
def sum(n)
  n * (n+1) /2
end

N = gets.to_i
a = ([0] + gets.split.map(&:to_i))
(1..N).each do |i|
  a[i] += a[i-1]
end
h = Hash.new{0}
a[1..N].each do |i|
  h[i] += 1
end
ans = h[0]
h.each do |k, v|
  next if v <= 1
  ans += sum(v-1)
end
p ans


Measured memory_bytes: 30596
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    int ans = 0;
    FOR(i, 1, N + 1) {
        string a = to_string(i);
        if (a.size() % 2 == 1)
            ans++;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <map>
#include <cstdio>
using namespace std;
#define X 3
#define Y 3
int main(){
	int i=1,start_point;
	vector<int>start(X*Y),goal;
	for(;i<X*Y;i++)goal.push_back(i);goal.push_back(0);
	for(i=0;i<X*Y;i++){
		scanf("%d",&start[i]);
		if(start[i]==0)start_point=i;
	}
	if(start==goal){puts("0");return 0;}

	map<vector<int>,pair<int,int> >mstart;
	queue<vector<int> >q;
	mstart[start]=make_pair(start_point,0);
	q.push(start);
	for(;!q.empty();){
		vector<int> v=q.front();
		q.pop();
		map<vector<int>,pair<int,int> >&m=mstart;
		int coor=m[v].first,x=coor%X,y=coor/X;
		int depth=m[v].second;
		if(0<x){
			swap(v[coor],v[coor-1]);
			if(m.find(v)==m.end())m[v]=make_pair(coor-1,depth+1),q.push(v);
			if(v==goal){printf("%d\n",depth+1);return 0;}
			swap(v[coor],v[coor-1]);
		}
		if(x<X-1){
			swap(v[coor],v[coor+1]);
			if(m.find(v)==m.end())m[v]=make_pair(coor+1,depth+1),q.push(v);
			if(v==goal){printf("%d\n",depth+1);return 0;}
			swap(v[coor],v[coor+1]);
		}
		if(0<y){
			swap(v[coor],v[coor-X]);
			if(m.find(v)==m.end())m[v]=make_pair(coor-X,depth+1),q.push(v);
			if(v==goal){printf("%d\n",depth+1);return 0;}
			swap(v[coor],v[coor-X]);
		}
		if(y<Y-1){
			swap(v[coor],v[coor+X]);
			if(m.find(v)==m.end())m[v]=make_pair(coor+X,depth+1),q.push(v);
			if(v==goal){printf("%d\n",depth+1);return 0;}
			swap(v[coor],v[coor+X]);
		}
	}
}

Measured memory_bytes: 24112
#include<stdio.h>
#define ll long long
const int N = 200002;
int l, n, X[N], A[N], sm[N], AA[N];
ll S[N];
ll sumof(int s, int e) {//A[s]+...+A[e], sm[e]-sm[s-1]이 원래
	return sm[e + 1] - sm[s];
}
ll func() {
	int i, j, z;
	ll calc = (ll)0, ans=(ll)0;
	for (i = 1, sm[0] = (ll)0; i <= n + 1; i++) {
		sm[i] = sm[i - 1] + A[i - 1];
	}
	//sm[i]=A[0]+...+A[i-1]
	for (i = 0, j = n, calc = (ll)0, z = 0, S[1] = (ll)0; z < n; z++, S[1] += calc) {
		if (z % 2 == 0) {
			calc += A[i];
			i++;
		}
		else {
			calc += A[j];
			j--;
		}
	}
	ans = S[1];
	for (i = 2; i <= n; i++) {
		S[i] = S[i - 1] - sumof(0, i - 2) + sumof(i - 1, (i + n - 1) / 2) - sumof((i + n) / 2, n);
		ans = ans > S[i] ? ans : S[i];
	}
	return ans;
}
int main() {
	int i;
	ll ans1, ans2;
	scanf("%d%d", &l, &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &X[i]);
	}
	X[n + 1] = l;
	for (i = 0; i <= n; i++) {
		AA[i] = X[i + 1] - X[i];
	}
	for (i = 0; i <= n; i++) {
		A[i] = AA[i];
	}
	ans1 = func();
	for (i = 0; i <= n; i++) {
		A[i] = AA[n - i];
	}
	ans2 = func();
	printf("%lld", ans1 > ans2 ? ans1 : ans2);
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[3];
  cin>>s;
  if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
  	cout<<3;
  	return 0;
  }
  else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
    cout<<2;
  else if(s[0]!='R'&&s[1]!='R'&&s[2]!='R')
    cout<<0;
  else
    cout<<1;
  return 0;
}

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

int dp[105][4][2];

int main() {
string n;
cin >> n;
int l=n.size();
int K;
cin >> K;
dp[0][0][0]=1;
for (int i=0;i<l;i++){
for (int j=0;j<4;j++){
for (int k=0;k<2;k++){
int nd=n[i]-'0';
for (int d=0;d<10;d++){
int ni=i+1,nj=j,nk=k;
if (d!=0)nj++;
if (nj>K)continue;
if (k==0){
if (d<nd)nk=1;
if (d>nd)continue;
}
dp[ni][nj][nk]+=dp[i][j][k];
}
}}}
int ans = dp[l][K][0]+dp[l][K][1];
cout << ans <<endl;
}



Measured memory_bytes: 256
//bubble sort
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int n, d, i1, i2, times;
    cin >> n;
    int a[n];
    
    for(i1=0;i1<n;i1++){
        cin >> a[i1];
    }
    times=0;
    i2 = n;
    for(i2=n;i2>0;i2--){
        i1 = n;
        while(1){
            i1--;
            if(a[i1]<a[i1-1]){
                d=a[i1];
                a[i1]=a[i1-1];
                a[i1-1]=d;
                times++;
            }
            if(i1<=n-i2){break;}
        }
    }
    
    i1=0;
    //cout
    while(1){
        if(i1==0){cout << a[i1]; if(n==1){break;} else{i1++; continue;}}
        cout << " " << a[i1];
        i1++;
        if(i1==n){break;}
    }
    cout << endl << times << endl;
    
    
    return 0;
}

Measured memory_bytes: 1164
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		k: usize,
		mut l: [usize; n],
	}

	l.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..k {
		sum += l[i];
	}
	println!("{}", sum);
}



Measured memory_bytes: 2188
import java.util.Scanner;
//int[] date=new int[2];
public class Main {
int i,o,sum,h,s,e,u,ty,yu,ui,n,num,qw;
double m,t,r,j,k,f,d,g,w;
static double l;
String b,c,z,x,v,a,q;
Scanner scan =new Scanner(System.in);
//入力
	public void input() {	
	
	}
	//演算
	public void compute() {
	
		}
//出力
	public void output() {
h=scan.nextInt();
int[] date=new int[2];
for(o=0;o<2;o++) {
	date[o]=scan.nextInt();
}
while(true) {
	e+=1;
	o=h*e;
	if(o>=date[0]&&o<=date[1]) {
		System.out.println("OK");
		break;
	}else if(o<date[0]){
		
	}else {
		System.out.println("NG");
		break;
	}

}
		}
	public static void main(String [ ] args) {
		Main p = new  Main ();
		p.input();
		p.compute();
		p.output();
		}
	}

Measured memory_bytes: 35728
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
std::vector<std::vector<T>> mk2d(size_t s1, size_t s2, T const& val) {
  std::vector<T> tmp(s2, val);
  return std::vector<std::vector<T>>(s1, tmp);
}

int const MAXL = 1e5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> V(N), W(N);
  for(int i = 0; i < N; ++i) std::cin >> V[i] >> W[i];
  int pN = std::min(N+1, 1024);
  auto dp = mk2d(pN, MAXL+1, (int)0);
  for(int i = 1; i < pN; ++i) {
    int pi = i/2;
    // don't use V[i-1], W[i-1]
    std::copy_n(dp[pi].begin(), MAXL+1, dp[i].begin());
    // use V[i-1], W[i-1];
    for(int w = MAXL; w >= W[i-1]; --w) {
      int nv = dp[pi][w-W[i-1]] + V[i-1];
      if(nv > dp[i][w]) dp[i][w] = nv;
    }
  }
  int Q; std::cin >> Q;
  for(int q = 0; q < Q; ++q) {
    int u, L; std::cin >> u >> L;
    if(u < pN) {
      std::cout << dp[u][L] << "\n";
      continue;
    }
    std::vector<int> nodes;
    while(u >= pN) {
      nodes.push_back(u);
      u /= 2;
    }
    int ans = 0;
    int S = (1<<nodes.size());
    for(int s = 0; s < S; ++s) {
      int sumv = 0, sumw = 0;
      for(int i = 0; i < nodes.size(); ++i) if((1<<i)&s) {
        sumv += V[nodes[i]-1];
        sumw += W[nodes[i]-1];
      }
      if(sumw > L) continue;
      ans = std::max(ans, sumv + dp[u][L - sumw]);
    }
    std::cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 407128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  return res;
}

ll modinv(ll x,ll m){
  return power(x,m-2);
}

void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


void solve(){
    int n,m;
    cin>>n>>m;
    
    ll a[m];
    forn(i,0,m)
    cin>>a[i];
    ll sum=0;
    
    forn(i,0,m)
    sum+=a[i];
    if(sum>n){
        cout<<-1;
    }
    else
    cout<<n-sum;
}


int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
  
   while(test--)
   solve();
}

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];for(int i=0;i<n;++i)cin>>a[i];
int dp[n];dp[0]=0;dp[1]=abs(a[0]-a[1]);
for(int i=2;i<n;++i)dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
cout<<dp[n-1]<<"\n";
return 0;
}

Measured memory_bytes: 1024
# vim: fileencoding=utf-8


def main():
    s = input()
    c = 0
    if s[0] == "1":
        c += 1
    if s[1] == "1":
        c += 1
    if s[2] == "1":
        c += 1
    print(c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61864
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, A, B := getInt(), getInt(), getInt()

	C := A + B
	p := N / C
	r := N % C
	ans := p * A
	ans += min(A, r)
	out(ans)
}


Measured memory_bytes: 640
#include <stdio.h>

int main( void )
{
	int n;
	int i;
	int j;
	int k;
	int l;
	int pattern;
	
	while( scanf( "%d", &n ) != EOF )
	{
		pattern = 0;
		for( i = 0; i <= 9; i++ )
		{
			for( j = 0; j <= 9; j++ )
			{
				for( k = 0; k <= 9; k++ )
				{
					for( l = 0; l <= 9; l++ )
					{
						if( i + j + k + l == n )pattern++;
					}
				}
			}
		}
		printf( "%d\n", pattern );
	}
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int n;cin>>n;
  	vector<string> a(n);
  	for(int i=0;i<n;i++){
    	cin>>a.at(i);
    }
  
  //同じものはないか？
  	for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
      	if(a.at(i)==a.at(j)){
        	cout<<"No"<<endl;
          	return 0;
        }
      }
    }
    
  //最後の文字＝次の最初の文字か？
  	for(int i=0;i<n-1;i++){
      if(a.at(i).at(a.at(i).size()-1)!=a.at(i+1).at(0)){
      	cout<<"No"<<endl;
        return 0;
      }
    }
      cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

const INI: i64 = 1_000_000_000;
use std::cmp::*;

fn main() {
    input! {
        n: usize,
        h: [i64;n],
    }

    let mut dp = vec![INI; n];
    dp[0] = 0;
    dp[1] = (h[0] - h[1]).abs();

    for i in 2..n {
        dp[i] = min(
            dp[i - 1] + (h[i] - h[i - 1]).abs(),
            dp[i - 2] + (h[i] - h[i - 2]).abs(),
        );
    }

    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 6396
local mma = math.max
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      ret = self.func(ret, self.stage[stage][mce(l / sz)])
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  return ret
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n")
local robo = {}
local z = {}
local zmap = {}
for i = 1, n do
  local a, b = io.read("*n", "*n")
  if not zmap[a - b] then
    table.insert(z, a - b)
    zmap[a - b] = true
  end
  if not zmap[a + b] then
    table.insert(z, a + b)
    zmap[a + b] = true
  end
  robo[i] = {a - b, a + b}
end
table.sort(z)
local zinv = {}
local st = SegTree.new(#z, mma, 0)
for i = 1, #z do
  zinv[z[i]] = i
end
table.sort(robo, function(a, b) return a[1] < b[1] end)
for i = 1, n do
  local left, right = robo[i][1], robo[i][2]
  local lp, rp = zinv[left], zinv[right]
  local cur = st:getRange(1, lp)
  local nxt = mma(st:getRange(rp, rp), cur + 1)
  st:setValue(rp, nxt)
end
local tot = st:getRange(1, #z)
print(tot)


Measured memory_bytes: 44856
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        
	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        int[] a = new int[M];
	        int[] b = new int[M];
	        for (int i=0 ; i<M; i++) {
	            a[i] = sc.nextInt()-1;
	            b[i] = sc.nextInt()-1;
	        }
	        
	        long cnt=(long)N*(N-1)/2;
	        long[] ans = new long[M];
	        ans[M-1]=cnt;
	        Unionfind u = new Unionfind(N);
	        for(int i=M-1;i>=1;i--) {
	        	if(!u.same(a[i],b[i])) {
	        		cnt=cnt-u.getSize(a[i])*u.getSize(b[i]);
	        		u.union(a[i],b[i]);
	        	}
	        	ans[i-1]=cnt;
	        }
	        for(int i=0;i<M;i++) {
	        	System.out.println(ans[i]);
	        }
		 }
		 
	}

	 class Unionfind {
		 
			private int[] data;
			private int []size;
			
			public Unionfind(int size) {
				this.data = new int [size];
				this.size = new int [size];
				for(int i = 0 ;i < size ;i++) {
					initnode(i);
				}
				clear();
			}
			
			public void initnode(int i) {
				size[i] = 1;
			}
			
			public void clear() {
				Arrays.fill(data, -1);
			}
			
			public void union(int x , int y ) {
				if((x = root(x)) != (y = root(y))) {
					if(data[y] < data[x]) {
						final int t = x;
						x = y;
						y = t;
					}
					data[x] += data[y];
					size[root(x)] += size[root(y)];
					data[y] = x;
				}
			}
			
			public int getSize(int i) {
				return size[root(i)];
			}
			
			public int root(int x) {
				if(data[x] < 0) {
					return x;
				}
				else {
					return data[x] = root(data[x]);
				}
			}
			
			public boolean same(int x, int y) {
				return root(x) == root(y);
			}
			
		}

Measured memory_bytes: 61476
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
	String str;
	try{
	    InputStreamReader is = new InputStreamReader(System.in);
	    BufferedReader br = new BufferedReader(is);
	    int[] n = new int[2];
	    long[] l = new long[2];
	    int temp;
	    while(null != (str = br.readLine())){
		String[] strary = str.split(" ");
		n[0] = Integer.parseInt(strary[0]);
		n[1] = Integer.parseInt(strary[1]);
		l[0] = n[0];
		l[1] = n[1];
		while(n[0] != n[1]){
		    if(n[0] > n[1]){
			n[0] = n[0]-n[1];
		    }
		    else{
			n[1] = n[1]-n[0];
		    }
		}
		System.out.println(n[0]+" "+((l[0]*l[1])/n[0]));
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

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

int main(void) {
	int N, max=0, x=0;
	string S;
	cin >> N >> S;
	for (int i = 0;i<S.size(); ++i) {
		if (S[i] == 'I') ++x;
		if (S[i] == 'D') --x;
		if (x >= max) max = x;
	}
	cout << max << endl;

	return 0;
}

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

// F : T x T -> T
// G : T x E -> T
// H : E x E -> E
// R : E x int(length of the range) -> E
template<typename T, typename E, typename F, typename G, typename H, typename R>
struct SegL{
private:
    vector<T> node;
    vector<E> lazy;
    int n;
    T defVal;
    E defOp;
    F f;    // merge elements(T)
    G g;    // update element(T) 
    H h;    // merge operators(E)
    R r;    // operator depends on length

public:
    SegL(int siz, T defVal, E defOp, F f, G g, H h, R r) : defVal(defVal), defOp(defOp), f(f), g(g), h(h), r(r){
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, defVal);
        lazy.resize(2*n-1, defOp);
    }
    SegL(vector<T> v, T defVal, E defOp, F f, G g, H h, R r) : defVal(defVal), defOp(defOp), f(f), g(g), h(h), r(r){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1, defVal);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void eval(int k, int len){
        if(lazy[k] == defOp)    return;
        if(k < n-1){
            lazy[2*k+1] = h(lazy[2*k+1], lazy[k]);
            lazy[2*k+2] = h(lazy[2*k+2], lazy[k]);
        }
        node[k] = g(node[k], r(lazy[k], len));
        lazy[k] = defOp;
    }

    void update(int a, int b, E x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, r-l);
        if(b <= l || r <= a){
            return;
        }else if(a <= l && r <= b){
            lazy[k] = h(lazy[k], x);
            eval(k, r-l);
        }else{
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, r-l);
        if(b <= l || r <= a)    return defVal;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }
};

typedef long long ll;

int main(){
    int n, q;
    cin >> n >> q;
    auto f = [](ll x, ll y)->ll{return x+y;};
    auto g = [](ll x, ll y)->ll{return x+y;};
    auto h = [](ll x, ll y)->ll{return x+y;};
    auto r = [](ll x, ll y)->ll{return x*y;};
    ll defv = 0;
    ll defop = 0;
    SegL<ll, ll, decltype(f), decltype(g), decltype(h), decltype(r)> seg(n, defv, defop, f, g, h, r);
    while(q--){
        int op;
        cin >> op;
        if(op == 0){
            int s, t, x;
            cin >> s >> t >> x;
            s--, t--;
            seg.update(s, t+1, x);
        }else{
            int s, t;
            cin >> s >> t;
            s--, t--;
            cout << seg.query(s, t+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7080
#include <iostream>
#include <algorithm>

using namespace std;

long long euclid_gcd(long long a, long long b){
	if (a < b){
		return euclid_gcd(b, a);
	}
	long long r;
	while((r = a % b)){
		a = b;
		b = r;
	}
	return b;
}

int main(){
	long long A, B, C, D;
	cin >> A >> B >> C >> D;
	long long E = C * D / euclid_gcd(C, D);

	long long C_num = B / C - (A - 1) / C;
	long long D_num = B / D - (A - 1) / D;
	long long E_num = B / E - (A - 1) / E;

	cout << (B - A + 1) - C_num - D_num + E_num << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
s = []
m.times do
  l = gets.chomp.split.map(&:to_i)
  l.shift
  s << l
end
p = gets.chomp.split.map(&:to_i)

ans = 0
0.upto((1 << n) - 1) do |i|
  flag = true
  0.upto(m - 1) do |j|
    cnt = 0

    s[j].each do |sj_k|
      if i & (1 << (sj_k - 1)) > 0
        cnt += 1
      end
    end

    if cnt % 2 != p[j]
      flag = false
      break
    end
  end

  ans += 1 if flag
end
puts ans

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

#define N 100000

int main(){
  int H, Heap[N+1];

  cin >> H;

  for(int i = 1 ; i <= H ; i++){
    cin >> Heap[i];
  }

  for(int i = 1 ; i <= H ; i++){

    cout << "node " << i << ": key = " << Heap[i] << ", ";

    if(i / 2 >= 1){
      cout << "parent key = " << Heap[i/2] << ", ";
    }

    if(2 * i <= H){
      cout << "left key = " << Heap[2*i] << ", ";
    }

    if(2 * i + 1 <= H){
      cout << "right key = " << Heap[2*i+1] << ", ";
    }
  
    cout << endl;

  }
  return 0;
}

Measured memory_bytes: 1168
# -*- coding: utf-8 -*-
N = int(input())
x = []
for i in range(N):
    x.append([str(i) for i in input().split()])

ans = 0
for i in range(N):
    if x[i][1] == "JPY":
        ans += int(x[i][0])
    if x[i][1] == "BTC":
        ans += float(x[i][0]) * 380000
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
signed main(){
    string s;
    cin>>s;
    int p=0;
    int g=0;
    int n=s.size();
    for(int i=0;i<n;i++){
        if(i<=(n+1)/2-1&&s[i]=='p'){
            p++;
        }
        else if(i>(n+1)/2-1&&s[i]=='g'){
            g++;
        }
    }
    cout<<g-p<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

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

typedef struct {
	ll x, y, z;
}cake_t;

int main() {
	string s; cin >> s;
	int len = s.size();
	if (s[len - 1] == '3') cout << "bon" << endl;
	else if (s[len - 1] == '0' || s[len - 1] == '1' || s[len - 1] == '6' || s[len - 1] == '8')
		cout << "pon" << endl;
	else	cout << "hon" << endl;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = Console.ReadLine();
            string answer;
            switch (N.Last())
            {
                case '2':
                case '4':
                case '5':
                case '7':
                case '9':
                    answer = "hon";
                    break;
                case '0':
                case '1':
                case '6':
                case '8':
                    answer = "pon";
                    break;
                case '3':
                default:
                    answer = "bon";
                    break;
            }

            Console.WriteLine(answer);
        }
    }
}


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

namespace abc161b
{
    class Program
    {
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input
            List<int> input1 = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            int n = input1[0];
            int m = input1[1];
            List<int> input2 = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            int total = input2.Sum();


            var ans = input2.Where(v => v >= (double)total / (4 * m));



            //==========================================================================================================================
            //2) output
            string output = "Yes";

            if (ans.Count() < m)
            {
                output = "No";
            }


            Console.WriteLine(output);

        }
    }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


const ll MOD =  1000003;

ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

const int SZ = 2123456;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {

  int Q = nextInt();
  REP(_, Q) {

    ll x = nextInt();
    ll d = nextInt();
    ll n = nextInt();

    ll ans = 0;
    if (d == 0) {
      ans = mod_pow(x, n, MOD);
    } else {

      ll y = x * inv[d] % MOD;
      if (y + n - 1 < MOD) {
        ans = fact[y+n-1] * fact_inv[y-1];
        ans %= MOD;
        ans *= mod_pow(d, n, MOD);
        ans %= MOD;
      }
    }
    printf("%d\n", (int)ans);
  }
  return 0;
}

int main() {

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 50688
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            ok = mid
        else:
            ng = mid
    return ok

N, K = MAP()
A = LIST()
B = LIST()
A.sort()
B.sort(reverse=1)

def check(m):
    C = [0] * N
    for i in range(N):
        C[i] = m // B[i]
    res = 0
    for i in range(N):
        res += max(A[i] - C[i], 0)
    return res <= K

res = bisearch_min(-1, 10**12+1, check)
print(res)


Measured memory_bytes: 122752
N, W = map(int, input().split())
wv = [[int(_) for _ in input().split()] for _ in range(N)]
V_MAX = 10**5+1
dp = [[float('inf')]*(V_MAX) for _ in range(N+1)]
dp[0][0] = 0

for i in range(1, N+1):
    weight = wv[i-1][0]
    value = wv[i-1][1]
    for j in range(V_MAX):
        if j < value:
            dp[i][j] = min(dp[i-1][j], weight)
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-value] + weight)

for i in range(V_MAX):
    if dp[N][i] > W:
        print(i-1)
        break
else:
    print(i)

Measured memory_bytes: 313528
import java.util.Scanner;

/**
 * A - Air Conditioner
 * あなたは、室温が 30 度以上のとき、またそのときに限り、冷房の電源を入れます。
 * 今の室温は X 度です。冷房の電源を入れますか？
 */
public class Main {

    public static void main( String[] args ) {

        // 入力値
        Scanner sc = new Scanner( System.in );
        int x = sc.nextInt();   // 今の室温

        System.out.println( x >= 30 ? "Yes" : "No" );

        sc.close();
    }
}

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

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

fn main() {
    let x:usize = read();
    if x == 0 {
        println!("1");
    } else {
        println!("0");
    }
}


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

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

Measured memory_bytes: 3580
#include<stdio.h>
 
int main(){
 
int W,H,x,y,r;
 
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 
if((r<=x)&&(x<=(W-r))&&(r<=y)&&(y<=(H-r)))
printf("Yes\n");
else printf("No\n");
 
return 0;
 
}
 

Measured memory_bytes: 584