akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N; cin >> N;
    vector<int> A, Acp;
    for (int i = 0; i < N; i++)
    {
        int Ai; cin >> Ai;
        A.push_back(Ai);
    }
    copy(A.begin(), A.end(), back_inserter(Acp));
    sort(Acp.begin(), Acp.end(), greater<int>());
    for (int j = 0; j < N; j++)
    {
        if (A[j] == Acp[0])
        {
            cout << Acp[1] << endl;
        }
        else
        {
            cout << Acp[0] << endl;
        }
    }
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a),i<(b),i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
const double PI=acos(-1.0);
const int INF=1e9;
const double EPS=1e-10;


int main(){
  db a,b,t;
  cin>>a>>b>>t;
  int ans;
  ans=t/a;
  ans*=b;
  cout<<ans<<endl;
  
return 0;
}

Measured memory_bytes: 256
#coding:utf-8
r,D,x = map(int,input().split())
x2001 = r * x - D
x2002 = r * x2001 - D
x2003 = r * x2002 - D
x2004 = r * x2003 - D
x2005 = r * x2004 - D
x2006 = r * x2005 - D
x2007 = r * x2006 - D
x2008 = r * x2007 - D
x2009 = r * x2008 - D
x2010 = r * x2009 - D
print(x2001)
print(x2002)
print(x2003)
print(x2004)
print(x2005)
print(x2006)
print(x2007)
print(x2008)
print(x2009)
print(x2010)

Measured memory_bytes: 3064
//
// Created by Myabu on 2020/01/13.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int A,B;

    cin>>A>>B;

    if(B%A==0){
        cout<<A+B<<endl;
    }else{
        cout<<B-A<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

void main()
{
    auto hwk = readln.split.to!(int[]);
    auto H = hwk[0];
    auto W = hwk[1];
    auto K = hwk[2];

    char[][] C;
    foreach (_; 0..H) C ~= readln.chomp.to!(char[]);
    int r = int.max;

    foreach (x; 0..1<<(H-1)) {
        auto N = popcnt(x)+1;
        int[] cs, ccs;
        cs.length = N;
        ccs.length = N;
        int rr;
        foreach (j; 0..W) {
            {
                int k;
                foreach (i; 0..H) {
                    if (C[i][j] == '1') ++ccs[k];
                    if (x & (1<<i)) ++k;
                }
            }
            foreach (k; 0..N) if (cs[k] + ccs[k] > K) {
                if (ccs[k] > K) goto ng;
                ++rr;
                cs[] = 0;
                break;
            }
            foreach (k; 0..N) cs[k] += ccs[k];
            ccs[] = 0;
        }
        r = min(r, rr + N-1);
        ng:
    }
    writeln(r);
}

Measured memory_bytes: 380
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
int N,K,A[100010];
ll B[100010] = {};

int main(){
    cin >> N >> K;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i];        
    }
    int value = 0;
    ll ans = 0;
    set<int> s;
    for(int j=0;j<=30;j++){
        if(!(K&(1<<j))) s.insert(j);
    }
    for(int i=1;i<=N;i++){
        bool judge = true;
        for(auto x:s){
            if(A[i]&(1<<x)){
                judge = false;
                break;
            }
        }
        if(judge) ans += B[i];
    }
    for(int j=0;j<=30;j++){
        if(K<(1<<j)) break;
        if(K&(1<<j)){
            ll now = 0;
            if(j!=0) s.insert(j);
            for(int i=1;i<=N;i++){
                bool judge = true;
                for(auto x:s){
                    if(A[i]&(1<<x)){
                        judge = false;
                        break;
                    }
                }
                if(judge) now += B[i];
            }
            ans = max(ans,now);
            if(j!=0) s.erase(j);
        }else s.erase(j);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
import copy
n=int(input())
k=[0]*n
for i in range(n):
    k[i]=list(map(int,input().split()))
dp=[[0]*3]*n
dp[0]=copy.deepcopy(k[0])
for i in range(n-1):
    dp[i+1]=[copy.deepcopy(max(dp[i][1],dp[i][2]))+copy.deepcopy(k[i+1][0]),copy.deepcopy(max(dp[i][2],dp[i][0]))+copy.deepcopy(k[i+1][1]),copy.deepcopy(max(dp[i][1],dp[i][0]))+copy.deepcopy(k[i+1][2])]
print(max(dp[n-1]))


Measured memory_bytes: 89428
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        List<int> s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToList();
        ModInt[] dp = new ModInt[X + 1];
        dp[X] = 1;
        ModInt remain = s.Count - 1;
        foreach (var mod in s)
        {
            ModInt[] newDP = new ModInt[X + 1];

            for (int i = 0; i < dp.Length; i++)
            {
                newDP[i % mod] += dp[i];
                newDP[i] += dp[i] * remain;
            }
            remain--;
            dp = newDP;
        }
        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}


struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }
    public static implicit operator long(ModInt modInt) => modInt.Data;
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt(a.Data * b.Data);
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 29352
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import numpy as np

def funk(matrix, n, k, no_list, h, w):
    if n == 0:
        mask = np.ones((h, w))
        for i in range(h):
            if no_list[i] == 1:
                mask[i,] = 0
        for j in range(w):
            if no_list[h+j] == 1:
                mask[:,j] = 0
        if np.sum(matrix * mask) == k:
            return 1
        else:
            return 0
    ans = 0
    ans += funk(matrix, n - 1, k, no_list + [1], h, w)
    ans += funk(matrix, n - 1, k, no_list + [0], h, w)
    return ans

ans = 0
h, w, k = map(int, input().split())
n = h + w
matrix = np.zeros((h, w))
for i in range(h):
    line = input()
    for j in range(w):
        if line[j] == "#":
            matrix[i,j] = 1
        else:
            matrix[i,j] = 0
no_list = []
ans += funk(matrix, n, k, no_list, h, w)
print(ans)

Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> b(n - 1);
    for (ll i = 0; i < n - 1; i++)
    {
        cin >> b[i];
    }
    vector<ll> a(n);
    for (int i = n - 1; i >= 1; i--)
    {
        if (i == n - 1)
        {
            a[i] = b[i - 1];
        }
        else
        {
            a[i] = min(b[i], b[i - 1]);
        }
    }
    a[0] = b[0];
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += (ll)a[i];
    }
    cout << ans << endl;
}


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

# print(bin(A[0]))
# print(format(A[0], "b"))
MOD = (10**9) +7
result = 0

cnt = [0] *60
for num in a:
    for j in range(60):
        cnt[j] += (num >> j) %2

ans = 0
for b in range(60):
    ans += cnt[b] * (n - cnt[b]) << b
    ans %= MOD

print(ans)


Measured memory_bytes: 122936
#include <iostream>
            #include <algorithm>
         
            int main(){
            long long a , b , k;
            std :: cin >> a >> b >> k;
             
            if(a > k)
            std :: cout << a - k << ' ' << b << '\n';
            else std :: cout << 0 << ' ' << std :: max(b - k + a , 0LL)<< '\n';
            }

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    long T1, T2;
    long A1, A2;
    long B1, B2;
    scan(T1, T2);
    scan(A1, A2);
    scan(B1, B2);

    if (T1*A1 + T2*A2 < T1*B1 + T2*B2) {
        swap(A1, B1);
        swap(A2, B2);
    }
    // T1*A1 + T2*A2 >= T1*B1 + T2*B2

    auto d = T1*A1 + T2*A2 - (T1*B1 + T2*B2);
    auto v = T1*B1 - T1*A1;

    if (d == 0) {
        writeln("infinity");
        return;
    }

    if (v < 0) {
        writeln(0);
        return;
    }

    auto ans = 2 * (v / d + 1) - 1;
    if (v % d == 0) ans--;
    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int A[N],x;		    

int part(p,r){
  int i,tmp;
  x = A[r];
  i = p-1;
  for(int j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  
  return i+1;
}

int main()
{
  int n,i,result;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  result = part(0,n-1);
  for(i = 0; i < n - 1;i++){
    if(result == i) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  return 0;
}



Measured memory_bytes: 2168
#include<stdio.h>
int main(void)
{
    int a,b=100000,c,d=0,i;
    scanf("%d",&a);
    for(i=1;i<=a;i++){
        b=b*1.05;
    if(b%1000!=0){
        c=b/1000+1;
        b=c*1000;
    }
    }
    printf("%d\n",b);
    return 0;
}

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int N, a[100000];

	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> a[i];
		if (a[i] % 2 == 1){
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;

	return 0;
}


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

int main(){
   int n;
   bool a = 0;
   cin >> n;
   if(n/10 % 111 == 0)a = 1;
   while(n >= 1000){
      n -= 1000;
   }
   if(n%111 == 0)a = 1;
   //cout << a << endl;
   //cout << n << endl;
   if(a == 1 || n == 0){
      cout << "Yes" << endl;
   }else {
      cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
  int n;
  cin>>n;
  set<int>s;
  int a;
  bool ng=false;
  rep(i,n){
    cin>>a;
    if(s.count(a))ng=true;
    s.insert(a);
  }
  if(ng)cout<<"NO\n";
  else cout<<"YES\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int money[32501];
int main()
{
	for(int i=0;i<32501;i++)
	{
		money[i]=0;
	}
	int a,b,c,x;
	int ans;
	cin>>a>>b>>c>>x;
	for(int aa=0;aa<a+1;aa++)
	{
		for(int bb=0;bb<b+1;bb++)
		{
			for(int cc=0;cc<c+1;cc++)
			{
				int xx=500*aa+100*bb+50*cc;
				money[xx]++;
			}
		}
	}
	ans = money[x];
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<int> > sw(m+1,vector<int>(n+1,-1));
	for(int i=1;i<=m;i++){
		int k;
		cin >> k;
		for(int j=1;j<=k;j++){
			cin >> sw[i][j];
		}
	}
	for(int i=1;i<=m;i++){
		cin >> sw[i][0];
	}
	int ans = 0;
	for(int s=0;s<(1<<n);s++){
		bool flag = true;
		for(int i=1;i<m+1;i++){
			int cnt = 0;
			for(int j=1;j<n+1;j++){
				if(sw[i][j] == -1) continue;
				if(s>>(sw[i][j]-1)&1) cnt++;
			}
			if(cnt%2 != sw[i][0]) flag = false;
		}
		if(flag) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll H,W; cin >> H >> W;
    ll h,w; cin >> h >> w;
    res = (H-h)*(W-w);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
mod =  1000000007
ret = [0] * (N+1)
ret[0] = 1
for i in range(1,N+1):
    if i in a:
        continue
    elif i == 1:
        ret[1] = 1
    else:
        ret[i] = ret[i-2] + ret[i-1]

print(ret[len(ret)-1]%mod)


Measured memory_bytes: 460020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            var dict = new Dictionary<string, int>
            {
                { "SUN", 7 },
                { "MON", 6 },
                { "TUE", 5 },
                { "WED", 4 },
                { "THU", 3 },
                { "FRI", 2 },
                { "SAT", 1 },
            };
            string S = Read();
            Console.WriteLine(dict[S]);
        }
    }
}


Measured memory_bytes: 13268
from collections import defaultdict
import math

N = int(input())
d_ab = defaultdict(int)
d_ba = defaultdict(int)
mod = 1000000007
a0 = 0
b0 = 0
all0 = 0

for i in range(N):
    A,B = map(int,input().split())
    if A == 0 and B == 0:
        all0 += 1
    elif A == 0:
        a0 += 1
    elif B == 0:
        b0 += 1
    else:
        gcd = math.gcd(A,B)
        if (A < 0 and B > 0) or (A > 0 and B < 0):
            minus_f = True
        else:
            minus_f = False
        A //= gcd
        B //= gcd
        A = abs(A)
        B = abs(B)
        if minus_f:
            d_ab[(-A,B)] += 1
            d_ba[(B,A)] += 1
        else:
            d_ab[(A,B)] += 1
            d_ba[(-B,A)] += 1
        

ans = 1

#print(d_ab)
#print(d_ba)

pairs = list(map(list,d_ab.keys()))
visited = defaultdict(int)
#print(pairs)

for pair in pairs:
    ab = d_ab[tuple(pair)]
    ba = d_ba[tuple(pair)]
    r_pair = list(reversed(pair))
    if r_pair[0] > 0 and r_pair[1] > 0:
        r_pair[0] *= -1
    elif r_pair[1] < 0:
        r_pair[1] *= -1
    r_pair = tuple(r_pair)
    if ba != 0 and visited[tuple(pair)] == 0:
        visited[r_pair] = 1
        ans *= (pow(2,ab)+pow(2,ba)-1)
        ans %= mod
    if ba == 0 and visited[tuple(pair)] == 0:
        ans *= (pow(2,ab))
        ans %= mod
#    print(ans)

#print(visited)
ans *= (pow(2,a0)+pow(2,b0)-1)
ans %= mod

ans += all0 -1
ans %= mod

print(ans)

Measured memory_bytes: 219424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll dp[3005];
int main() {
    init();
    ll N,S;
    cin >> N >> S;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    rep(i,N){
        dp[0]++;
        reper(j,1,S+1){
            if (j >= A[i]) (dp[j] += dp[j - A[i]]) %= MOD;
        }
        (ans += dp[S]) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapify(A)

for _ in range(M):
    v = heappop(A)
    v /= 2
    heappush(A, v)

print(sum([int(-a) for a in A]))

Measured memory_bytes: 98584
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  while (x <= y)
  {
    ans++;
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(void) {
    ll n, k;
    cin >> n >> k;
    pll ab[n];
    rep (i, n) cin >> ab[i].first >> ab[i].second;

    sort(ab, ab + n);

    ll now = 0;

    rep (i, n) {
        if (now + ab[i].se < k) {
            now += ab[i].se;
            continue;
        }
        cout << ab[i].fi << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 1792
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    println!("{}", (((n + 1) / 2) as f64) / (n as f64));
}


Measured memory_bytes: 4352
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	int a[n];
	forci(0,n){
		cin>>a[i];
	}
	int mx=INT_MIN;
	int cnt=0;
	for(int i=1;i<n;i++){
		if(a[i]<=a[i-1]){
			cnt++;
		}
		else{
			mx=max(cnt,mx);
			cnt=0;
		}
	}
	mx=max(cnt,mx);
	cout<<mx<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 4400
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//組み合わせの数
//1 <= x の値を3つ使ってnを作成

//1,6,2
//1,5,3

int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int x;
    cin >> x;
	string res;

	if(x < 1200)res = "ABC";
	else res = "ARC";

    cout << res << endl;

    return 0;    
}



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

int main(void)
{
    enum { S = 11 };
    char s[S];
    char ans[S];
    scanf("%s", s);
    for (size_t i = 0, j = 0, l = strlen(s); i < l; ++i) {
        switch (s[i]) {
            case 'B':
                if (j != 0) {
                    --j;
                }
                break;
            case '0':
            case '1':
                ans[j] = s[i];
                ++j;
                break;
            default:
                break;
        }
        ans[j] = '\0';
    }
    printf("%s\n", ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc=new Scanner(System.in);
       while(true){
           int n=sc.nextInt();
           int x=sc.nextInt();
           if(n==0 && x==0)break;
           int count=0;
           for(int i=1;i<=n;i++){
               for(int j=i+1;j<=n;j++){
                   for(int k=j+1;k<=n;k++){
                       if((i+j+k)==x)count++;
                   }
               }
           }
           System.out.println(count);
       }
       
    }   
}


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

int main(int argc, char** argv) {
	int n, m;
	cin >> n >> m;
	int** A = new int*[n];
	int* B = new int[m];
	for(int i = 0; i < n; ++i) A[i] = new int[m];

	int tmp = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			cin >> tmp;
			A[i][j] = tmp;
		}
	}
	for(int j = 0; j < m; ++j) {
		cin >> tmp;
		B[j] = tmp;
	}

	for(int i = 0; i < n; ++i) {
		int mult = 0;
		for(int j = 0; j < m; ++j) {
			mult += A[i][j] * B[j];
		}
		cout << mult << endl;
	}

	for(int i = 0; i < n; ++i) delete[] A[i];
	delete[] A, B;

	return 0;
}

Measured memory_bytes: 1236
$pai = 3.14159265358979;

chomp($line = <>);
($a, $b, $h, $m) = split(/ /, $line);

$angle = abs($m * 6 - ((360 / 12 * $h) + (0.5 * $m)));
$angle = 360 - $angle if($angle > 180);
$angle = $angle * $pai / 180;

$r = sqrt($a ** 2 + $b ** 2 - (2 * $a * $b * cos($angle)));

print "$r\n";


Measured memory_bytes: 5336
N=int(input())
S=[input() for i in range(N)]
a=0
for i in range(N):
    for j in range(N-1):
        for k in range(j+1,N):
            if S[(j+i)%N][k]!=S[(k+i)%N][j%N]:
                break
        else:
            continue
        break
    else:
        a+=1
print(a*N)

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

int main(){
  int N,count=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  bool exist_odd=false;
  while(true){
     for(int i=0;i<N;i++){
      if(A.at(i)%2==1){
        exist_odd=true;
        break;
      }
     }
    if(exist_odd){
      break;
    }
    for(int i=0;i<N;i++){
      A.at(i)/=2;
    }
    count++;
  }
  cout << count << endl;
}

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

int dp[2][12345];

int main() {
  int n;
  cin >> n;
  memset(dp, 0, sizeof dp);
  dp[0][0] = 1;
  int t = 0;
  while (n --) {
    t ^= 1;
    int a; cin >> a;
    memset(dp[t], 0, sizeof dp[t]);
    for (int i = 0; i + a < 12345; i ++)
      if (dp[t ^ 1][i])
        dp[t][i]=dp[t][i + a] = 1;
  }
  int ans = 0;
  for (int i = 0; i < 12345; i ++)
    if (i % 10 != 0 && dp[t][i]) ans = i;
  cout << ans << endl;
}

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

int main() {
  // Grid Repainting 2
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s.at(i);

  vector<int> di = {1, 0, -1, 0};
  vector<int> dj = {0, 1, 0, -1};

  rep(i,h) {
    rep(j,w) {
      if (s.at(i).at(j) == '#') {
        int cnt = 0;
        rep(k,4) {
          int ni = i + di[k];
          int nj = j + dj[k];
          if (0 <= ni && ni < h && 0 <= nj && nj < w) {
            if (s.at(ni).at(nj) == '.') cnt++;
          }
        }
        if (cnt == 4) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3636
n = int(input())
A = list(map(int,input().split()))

A.sort()

mod = 10**9+7

f = True
if n%2:#nは奇数
    if A[0] != 0:
        f = False
    else:
        check = 2
        for i in range(1,(n-1)//2+1):
            if not (A[2*i-1] == check and A[2*i] == check):
                f = False
                break
            check += 2
else:#nは偶数
    check = 1
    for i in range(1,n//2+1):
        if not (A[2*i-2] == check and A[2*i-1] == check):
            f = False
            break
        check += 2
if f:
    if n%2:
        print(pow(2, (n-1)//2, mod))
    else:
        print(pow(2, n//2, mod))
else:
    print(0)

Measured memory_bytes: 84408
// https://atcoder.jp/contests/abc143/tasks/abc143_d

#include "algorithm"
#include "iostream"
#include "set"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

ll my_lower_bound(VL &arr, ll target) {
  ll ng = -1;
  ll ok = arr.size();

  while( ok - ng > 1) {
    ll mid = (ok + ng) / 2;

    if (arr[mid] >= target) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  return ok;
}

void solve() {
  ll N;
  cin >> N;

  VL ls(N);

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

  sort(ls.begin(), ls.end());

  ll res = 0;

  rep(i, 0, N) rep(j, i + 1, N) {
    ll m = ls[i] + ls[j];
    auto sep = my_lower_bound(ls, m);
    res += sep - j - 1;
  }

  cout << res << endl;
}

// 尺取り
void solve2() {
  ll N;
  cin >> N;

  VL ls(N);

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

  sort(ls.begin(), ls.end());

  ll res = 0;

  rep(b, 0, N) {
    ll c_r = b + 1;
    ll c_l = b + 1;

    rep(a, 0, b) {
      ll m = ls[a] + ls[b];

      // c: [c_l, c_r)
      while (c_r < N && ls[c_r] < m) c_r++;

      res += c_r - c_l;
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, 0, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
# 解説放送の解法

INF = 1001001001

N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    f = 0
    for c in list(map(int, input().split())):
        c -= 1
        # f は開けられる宝箱の集合
        f |= 1 << c
    key.append((f, a))

dp = [INF] * (1 << N)
dp[0] = 0

# 遷移元の状態
for f in range(1 << N):
    # 鍵を全て試す
    for i in range(M):
        # 遷移先の状態
        t = f | key[i][0]
        # 遷移先のコスト = 遷移元のコスト + 鍵の値段
        cost = dp[f] + key[i][1]
        # 小さい方に更新
        dp[t] = min(dp[t], cost)

ans = dp[-1]
if ans == INF:
    ans = -1

print(ans)

Measured memory_bytes: 45672
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    n = S.count("N")
    s = S.count("S")
    w = S.count("W")
    e = S.count("E")

    if (n == 0 and s != 0) or (n != 0 and s == 0) or (w != 0 and e == 0) or (w == 0 and e != 0):
        print("No")
    else:
        print("Yes")


    
    
    
    

if __name__ == '__main__':
    main()



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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  vector<int64_t> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int64_t hoge1,hoge2;
  hoge1 = a.at(0)/2;
  hoge2 = a.at(0) - hoge1;
  int64_t diff = abs(hoge2 - hoge1)*a.at(1)*a.at(2);
  cout << diff << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int k = sc.nextInt();
        
        int[] h = new int[n];
        
        for(int i = 0; i < n; i++) h[i] = sc.nextInt();
        
        long sum = Arrays.stream(h).filter(x -> x >= k).count();
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 50784
import java.util.Scanner;

public class Main {
	
	public void slove() {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		for (int i = a; i <= Math.min(b, a+k-1); i++) {
			System.out.println(i);
		}
		
		for (int i = Math.max(b-k+1, a+k); i <= b; i++) {
			System.out.println(i);
		}
	}
	
	public static void main(String[] args) {
		new Main().slove();
	}

}


Measured memory_bytes: 23636
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 200005;

int N, K;
char s[MAXN];
int a[MAXN];

void simulate() {
	if (!a[0]) {
		a[0] = 1;
		return;
	}
	for (int i = 0; i < N - 1; i++)
		a[i] = a[i + 1] ^ 1;
	a[N - 1] = 0;
}

int main() {
	scanf("%d%d%s", &N, &K, s);

	for (int i = 0; i < N; i++)
		a[i] = s[i] - 'A';
		
	int cnt = 0, mx = 0, best = 0;
	for (int i = 0; i <= N; i++) {
		if (i + cnt <= K) {
			best = i + cnt;
			mx = i;
		}
		cnt += !((a[i] + i) % 2);
	}
	
	for (int i = 0; i < mx; i++)
		a[mx - i - 1] = i % 2;
	
	for (int i = mx; i < N; i++)
		a[i] = (a[i] + mx) % 2;
	
	rotate(a, a + mx, a + N);
	
	K -= best;
	K %= 2;
	
	while (K--)
		simulate();
	
	for (int i = 0; i < N; i++)
		printf("%c", a[i] + 'A');
	puts("");
	
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#define N 100000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[N];
int Depth(int);
void Print(int);
int n;

int main(){
  int i,j,d,v,c,l,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      T[c].p=v;
      if(j==0) T[v].l=c;
      else T[a].r=c;
	a=c;
    }
  }

  for(i=0;i<n;i++) Print(i);
  return 0;
}

int Depth(int u){
  int i,d=0;
  for(i=u;T[i].p!=NIL;i=T[i].p,d++);
  return d;
}

void Print(int u){
  int b=Depth(u),c=T[u].l;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,b);
  if(b==0) printf("root, ");
  else if(T[u].l!=NIL) printf("internal node, ");
  else printf("leaf, ");
  printf("[");
  if(T[u].l!=NIL){
    while(1){
      printf("%d",c);
      if(T[c].r==NIL){
	printf("]\n");
	break;
      }
      else{
	printf(", ");
	c=T[c].r;
      }
    }
  }
  else printf("]\n");
}

Measured memory_bytes: 1788
import math
class Point:
	def __init__(self,x,y):
		self.x = x
		self.y = y
	def __add__(self,p):
		return Point(self.x+p.x,self.y+p.y)
	def __sub__(self,p):
		return Point(self.x-p.x,self.y-p.y)
	def __mul__(self,p):
		return Point(self.x*p,self.y*p)

def Dot(a,b):
	return a.x*b.x + a.y*b.y
def Cross(a,b):
	return a.x*b.y - a.y*b.x
def Dis(a,b):
	return math.sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) )

x1,y1,x2,y2 = map(int,input().split())
p1 = Point(x1,y1)
p2 = Point(x2,y2)
p1p2_dis = Dis(p1,p2)

q = int(input())
for i in range(q):
	x,y = map(int,input().split())
	p = Point(x,y)
	dot_res = Dot(p-p1,p2-p1)
	len = dot_res / p1p2_dis
	x = (p2-p1) * (len/p1p2_dis) + p1
	print(x.x,x.y)



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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    deque<char> dq;
    for (auto &c : s) dq.emplace_back(c);
    bool flg = false;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            flg = 1 - flg;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (!flg) dq.emplace_front(c);
                else dq.emplace_back(c);
            } else {
                if (!flg) dq.emplace_back(c);
                else dq.emplace_front(c);
            }
        }
    }

    if (!flg) for (auto &c : dq) cout << c;
    else for (int i = dq.size() - 1; i >= 0; i--) cout << dq[i];
    cout << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int cost;
  if (A <= 5) cost=0;
  else if (A <= 12) cost=B/2;
  else cost=B;
  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.Maybe
import Data.List
import Data.Char

main = do
  [n,_] <- map read . words <$> getLine
  ds <- filter isDigit <$> getLine
  putStrLn (iroha n ds)

iroha :: Int -> [Char] -> String
iroha n ds = fromJust $ find (null . intersect ds) $ map show [n..]

Measured memory_bytes: 1020
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

//main
float distance(vector<float> a, vector<float> b);

int main(){
    int N,D;
    cin >> N >> D;
    int c = 0;
    float dis;
    vector<vector<float>> v(N,vector<float>(D));
    rep(i,N) rep(j,D) cin >> v[i][j];
    rep(i,N){
        rep(j,N){
            if(i != j){
                dis = distance(v[i],v[j]);
                if(floor(dis)==dis) c += 1;
            }
        }
    }
    cout << c/2 << endl;
}

float distance(vector<float> a, vector<float> b){
    int l = a.size();
    float s = 0;
    rep(i,l){
        s += pow(a[i]-b[i],2);
    }
    return sqrt(s);
}




Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

const int mod = 1000000007;

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	char *S = new char[N + 1];
	scanf("%s", S);
	int happy = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'L') {
			if (i != 0 && S[i - 1] == 'L')happy++;
		}
		else if (S[i + 1] == 'R')happy++;
	}
	printf("%d", (happy + 2 * K) > N - 1 ? N - 1 : (happy + 2 * K));
	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int s[100000],t[100000],c[100000]; 
int sm[200002]; 
int tt[200002]; 

int main(void){
  int N, C;
  scanf("%d%d",&N,&C);
 
  rep(i, N) scanf("%d%d%d",&s[i],&t[i],&c[i]);
  rep_s(i, 1, C+1){
    for(int j=0;j<200002;j++)tt[j]=0; 
    for(int j=0;j<N;j++)if(c[j]==i)tt[s[j]*2-1]++,tt[t[j]*2]--; 
    for(int j=1;j<200002;j++)tt[j]+=tt[j-1]; 
    for(int j=0;j<200002;j++)if(tt[j]>0)sm[j]++;
  }
  int mx = 0;
  for(int j=0;j<200002;j++)if(mx<sm[j])mx=sm[j]; 
  printf("%d\n",mx);
}


Measured memory_bytes: 2944