akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static int dp[];
  public static int func(int a[],int start,int k)
  {
    if(start>=a.length)
    return Integer.MAX_VALUE;
    if(start==a.length-1)
    return 0;
    if(dp[start]!=-1)
    return dp[start];
    int ans=Integer.MAX_VALUE;
    for(int i=start+1;i<=Math.min(start+k,a.length-1);i++)
    {
      ans=Math.min(ans,Math.abs(a[start]-a[i])+func(a,i,k));
    }
    return dp[start]=ans;
  }
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int a[]=new int[n];
    dp=new int[n+1];
    for(int i=0;i<n;i++)
    a[i]=sc.nextInt();
    for(int i=0;i<=n;i++)
    dp[i]=-1;
    System.out.println(func(a,0,k));
  }
}

Measured memory_bytes: 72664
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    string ans="";
    while(N!=0){
	if(N%2!=0){
	    N--;
	    ans='1'+ans;
	}
	else{
	    ans='0'+ans;
	}
	N/=-2;
    }
    if(ans=="") ans="0";
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll n,k;
	cin>>n>>k;
	if(!k){
		cout<<n*n<<endl;
		return 0;
	}
	n++;
	ll out=0;
	loop(b,k+1,n){
		int t=n/b;
		out+=t*(b-k);
		t=n%b;
		out+=max(0ll,t-k);
	}
	cout<<out<<endl;
}






Measured memory_bytes: 256
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=100,mod=1e9+7;
ll f[maxn];
int main(){
	int n;
	scanf("%d",&n);
	f[0]=2,f[1]=1;
	for(int i=2;i<=n;i++) f[i]=f[i-1]+f[i-2];
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int i, n;
    cin >> n;
    double x[n], y[n], z[n], D1 = 0.0, D2 = 0.0, D3 = 0.0, Dinf = 0.0;

    for(i=0; i<n; ++i) {
        cin >> x[i];
    }
    for(i=0; i<n; ++i) {
        cin >> y[i];
    }

    for(i=0; i<n; ++i) {
        z[i] = abs(x[i] - y[i]);
    }
    for(i=0; i<n; ++i) {
        D1 += z[i];
        D2 += z[i] * z[i];
        D3 += z[i] * z[i] * z[i];
        Dinf = max(Dinf, z[i]);
    }
    D2 = sqrt(D2);
    D3 = pow(D3, 1.0 / 3.0);

    cout << fixed;
    cout.precision(5);
    cout << D1 << endl;
    cout << D2 << endl;
    cout << D3 << endl;
    cout << Dinf << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n)
	{
		cin >> d[i];
	}

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

	int ans = d[n / 2] - d[n / 2 - 1];

	cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>

using namespace std;

int
main(void){
  string a, b, c;
  cin >> a >> b >> c;

  transform (a.begin (), a.end (), a.begin (), ::toupper);
  transform (b.begin (), b.end (), b.begin (), ::toupper);
  transform (c.begin (), c.end (), c.begin (), ::toupper);
  
  cout << a[0] << b[0] << c[0] << endl;
    
  return 0;
}


Measured memory_bytes: 256
N=int(input())
B=list(map(int,input().split()))
A=[-1]*N
x,y=0,0
for a in B:
  y=x+1
  if A[x]==-1:
    A[x]=a
    A[y]=a
  else:
    if A[x]>a:
      A[x]=a
    A[y]=a
  x+=1
print(sum(A))


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

int dp[3005][3005];

string LCS(string s, string t){
	int n = s.size();
	int m = t.size();
	rep(i,n)rep(j,m){
		if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
		chmax(dp[i+1][j+1], dp[i+1][j]);
		chmax(dp[i+1][j+1], dp[i][j+1]);
	}
	string res = "";
	int i = n, j = m;
	while(i > 0 && j > 0){
		if(dp[i][j] == dp[i-1][j]) --i;
		else if(dp[i][j] == dp[i][j-1]) --j;
		else{
			res = s[i-1] + res;
			--i; --j;
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	cout << LCS(s, t) << endl;
	return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

void read() {
  cin >> n;
  if (n == 0) {
    cout << 0;
    exit(0);
  }
}

void solve() {
  string sol;
  while (n) {
    int r = n % (-2);
    n /= -2;
    if (r < 0) {
      r += 2;
      ++n;
    }
    sol += (r + '0');
  }
  for(int i = sol.size() - 1; i >= 0; --i)
    cout << sol[i];
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
sl = []
for _ in range(h):
    sl.append(list(input()))
# G[v]: 頂点vに隣接する頂点list
# N: 頂点数
kuro = 0
for i in range(h):
    for j in range(w):
        if sl[i][j] == "#":
            kuro += 1

from collections import deque
dist = [-1]*w*h
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for i in [v+1, v-1, v+w, v-w]:
        if v % w == 0 and i == v-1:
            continue
        if v % w == w-1 and i == v+1:
            continue
        if 0 <= i <= w * h - 1:
            if sl[i//w][i%w] == ".":
                if dist[i] > -1:
                    continue
                dist[i] = d + 1
                que.append(i)

if dist[-1] == -1:
    print(-1)
else:
    print(w*h - dist[-1] -1 - kuro)

Measured memory_bytes: 3444
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
S = input().strip()
T = input().strip()
a = gcd(N,M)
L = (N//a)*(M//a)*a
ks = L//N
kt = L//M
flag = 0
if S[0]!=T[0]:
    flag = 1
else:
    b = gcd(ks,kt)
    kl = (ks//b)*(kt//b)*b
    for i in range(min(N,M)):
        if (kl//ks)*i<N and (kl//kt)*i<M and S[(kl//ks)*i]!=T[(kl//kt)*i]:
            flag = 1
            break
if flag==1:
    print(-1)
else:
    print(L)

Measured memory_bytes: 39792
N = int(input())
cooking = []

aoki = 0
for _ in range(N):
    a, b = map(int, input().split())
    cooking.append([a + b, a, b])
chokudai = 0
cooking.sort(reverse=True)
for i in range(0, N):
    if i % 2 == 0:
        chokudai += cooking[i][1]
    else:
        aoki += cooking[i][2]
ans = chokudai - aoki

print(ans)

Measured memory_bytes: 29204
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int A = sc.nextInt();
  int B = sc.nextInt();
  if(A%3 != 0 && B%3 != 0 && (A+B)%3 != 0)
    System.out.println("Impossible");
  else System.out.println("Possible");
}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
int aa[9];
int n;
void zidian(void);
int anum,bnum;
int a[10],b[10];
int comp(int *,int *,int n);
int main()
{
    int i;
    cin >> n;
    for(i=0;i<n;i++)
        cin >> a[i];
    for(i=0;i<n;i++)
        cin >> b[i];
        zidian();
        int kkk=anum-bnum;
        if(kkk<0)
            kkk=-kkk;
        cout << kkk;
    return 0;
}
int f=-1;
int sz[10]={0};
int ret;
void zidian(void)
{
    f++;
    if(f<n)
    {
        for(int i=1;i<=n;i++)
        {
            if(sz[i]!=0)
                continue;
            aa[f]=i;
            sz[i]=1;
            zidian();
            if(f==n-1)
            {
                ret++;
                if(comp(a,aa,n)==0)
                    anum=ret;
                if(comp(b,aa,n)==0)
                    bnum=ret;
            }
            sz[i]=0;
        }

    }
    f--;
}

int comp(int *a,int *b,int n)
{
    int flag=0;
    for(int i=0;i<n;i++)
    if(a[i]!=b[i])
    {
        flag=1;
        break;
    }
    return flag;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;
using ll = unsigned long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(5e5)+5;


set<int> ss;

int main()
{
    idfc;

    int x,n;
    cin>>x>>n;
    int i;

    for(i=-200;i<=200;i++)
    {
        ss.insert(i);
    }

    while(n--)
    {
        cin>>i;
        ss.erase(i);
    }

    int mx= 100000;
    i=1000000;
    int p;
    for(int ii:ss)
    {
        p=abs(x-ii);
        if(mx>p)
        {
            mx=p;
            i=ii;
        }
    }
    cout<<i;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, H[101010];
vector<int> E[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, N) cin >> H[i];
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}

	int ans = 0;
	rep(cu, 0, N) {
		bool ok = true;
		fore(to, E[cu]) if (H[cu] <= H[to]) ok = false;
		if (ok) ans++;
	}
	cout << ans << endl;
}







Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll evaluate(int contest, int date, vector<ll>& last, vector<ll>& c, vll& s) {
    ll point_today = 0;
    point_today += s[date][contest];
    for (ll j = 1; j <= 26; j++) {
        if(j==date){
            continue;
        }
        point_today -= c[j] * (date - last[j]);
    }
    return point_today;
}

int main(){
  ll d;
  cin >> d;//全日数
  vl c(27);
  for(ll i=1;i<=26;i++){//c_i==c[i]
    cin >> c[i];
  }
  vll s(d + 1, vl(27)); //s_d,i==s[d][i]
  for (ll i = 1; i <= d; i++){
    for (ll j = 1; j <= 26;j++){
      cin >> s[i][j];
    }
  }
  vl t;
  vl last(27, 0);//last(d,i)==last[i]
  //ll satisfy = 0;
  for (ll date = 1; date <= d;date++){
    priority_queue<pair<ll, int>> q;
    for (ll contest = 1; contest <= 26;contest++){
      q.push(mp(evaluate(contest, date, last,c,s), contest));
    }
    t.pb(q.top().S);
    //satisfy += q.top().F;
    last[q.top().S] = date;
  }
  rep(i,d){
    print(t[i]);
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
vi a;
int main() {
    cin>>n;
    a.resize(n+1);
    REP(i,n) cin>>a[i+1];

    int m = 0;
    vi b(n+1);
    fill(ALL(b),0);

    ll sum;
    int j;
    FORR(i,1,n+1){
        sum=0;
        j=1;
        do{
            //sum+=a[i*j];
            sum+=b[i*j];
            j++;
            if(i*j > n) break;
        }while(true);

        if(sum%2 != a[i]){
            b[i] = 1;
            m++;
        }

    }

    cout << m << endl;

    FOR(i,1,n+1){
        if(b[i]==1){
            cout << i;
            cout << " ";
        }
    }

    cout <<endl;
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main() {
  int l,r,lm,rm,ans=2019,i,j;
  cin>>l>>r;
  if(r-l+1>=2019) cout<<0<<endl;
  else{
    lm=l%2019;
    rm=r%2019;
    if(rm<=lm) cout<<0<<endl;
    else if(rm-lm+1>=673) cout<<0<<endl;
    else{
      for(i=lm;i<rm;i++){
        for(j=i+1;j<=rm;j++){
          if(i*j%2019<ans) ans=i*j%2019;
        }
      }
      cout<<ans<<endl;
    }
  }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, a, b, c, d;
  while (cin >> n >> a >> b >> c >> d) {
    
    bool f = false;

    for (int i = 0; i < n - 1; ++i) {
      const lli s = a - i * c;
      const lli t = a - i * d;

      const lli p = b - (n - 1 - i) * c;
      const lli q = b - (n - 1 - i) * d;

      if (min(p, q) <= min(s, t) && min(s, t) <= max(p, q)) {
        f = true;
        // cout << i << endl;
        // cout << min(p, q) << " <= " << min(s, t) << " <= " << max(p, q) << endl;
        break;
      }
      if (min(p, q) <= max(s, t) && max(s, t) <= max(p, q)) {
        f = true;
        // cout << i << endl;
        // cout << min(p, q) << " <= " << max(s, t) << " <= " << max(p, q) << endl;
        break;
      }      
    }

    cout << (f ? "YES" : "NO") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int l;
    cin>>n;
    std::deque<long long int> deq;
    for (int i=0;i<n;i++) {
        cin>>l;
        deq.emplace_back(l);
    }
    int count=0;
    for (int i=0;i+2<n;i++) {
        for (int j=i+1;j+1<n;j++) {
            for (int k=j+1;k<n;k++) {
                if (deq[i]!=deq[j]&&deq[i]!=deq[k]&&deq[j]!=deq[k]&&deq[i]+deq[j]>deq[k]&&deq[j]+deq[k]>deq[i]&&deq[k]+deq[i]>deq[j]) {
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;


int main(){
	char a, b;
	cin >> a >> b;
	cout << (a == b ? 'H' : 'D') << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(n):
  if a[i] >= b[i]:
    c += b[i]
  elif a[i]+a[i+1] >= b[i]:
    c += b[i]
    a[i+1] -= b[i]-a[i]
    continue
  else:
    c += a[i]+a[i+1]
    a[i+1]=0
print(c)

Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL n,i;cin>>n;
      string s;cin>>s;
      LL x=0;
      fo(i,0,n) if(s[i]=='R') x++;
      LL cnt=0;
      fo(i,0,x) if(s[i]=='R') cnt++;
      cout<<x-cnt;
    }
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MX = 1e18;

int main() {
    int n;
    cin >> n;
    ll a[n];
    bool flag = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) flag = true;
    }
    if (flag) {
        cout << 0 << endl;
        return 0;
    }
    ll num = 1;
    for (int i = 0; i < n; i++) {
        if (MX / num < a[i] || num * a[i] > MX) {
            num = -1;
            break;
        }
        num *= a[i];
    }
    cout << num << endl;
}

Measured memory_bytes: 4412
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    if(N == 1) {
        println("Hello World")
    } else if(N == 2) {
        val N2 = readLine()!!.toInt()
        val N3 = readLine()!!.toInt()
        val TOTL = N2 + N3
        println(TOTL)
    }

}

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

int main() {
    ll N;
    ll num[5];
    cin >>N;
    for(int i=0;i<5;i++){
        cin >> num[i];
    }
    ll maxOverHead =0;
    for(int i=0;i<5;i++){
        maxOverHead = max(maxOverHead,((N + num[i]-1)/num[i])-1);
    }
    cout << 5 + maxOverHead <<endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n,i=2;
  vector<int> h;
  vector<int> cost(n,0);
  cin>>n;
  for(int i=0;i<n;i++)
  {
     int a;
     cin>>a;
     h.push_back(a);
  }
  cost[0]=0;
    cost[1]=abs(h[1]-h[0]);
    while(i<n)
    {
        if(abs(h[i]-h[i-1])+cost[i-1]>(abs(h[i]-h[i-2]))+cost[i-2]){
            cost[i]=(abs(h[i]-h[i-2]))+cost[i-2];
            i++;
        }
        else if(abs(h[i]-h[i-1])+cost[i-1]<=(abs(h[i]-h[i-2]))+cost[i-2]){
            cost[i]=(abs(h[i]-h[i-1]))+cost[i-1];
            i++;
        }
    }
   
        cout << cost[n-1] << endl;
}
    
  

Measured memory_bytes: 17276
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  if(s=="RRR")cout << 3 << endl;
  else if(s=="RRS"||s=="SRR")cout<<2 << endl;
  else if(s=="SSS")cout << 0 << endl;
  else cout << 1 << endl;
  
  return 0;
}

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

int counter(int x)
{
	int count=0;
	while(x)
	{
		x/=10;
		count++;
	}
	return count;
}


int main()
{
	int a,b,x;
	while(cin>>a>>b)
	{
		x=a+b;
		cout<<counter(x)<<endl;
	}
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool is_r = false;
  int _a = a;
  for (int i=0; i<b; i++) {
    if (a % b == c) {
      is_r = true; break;
    }
    a += _a;
  }
  if (is_r) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
count = 0
l.sort()
for a,i in enumerate(l):
    for b,j in enumerate(l,a+1):
        if i >= j:
            continue
        for c,k in enumerate(l,b+1):
            if j >= k:
                continue
            if k-j<i:
                count+=1
                
print(count)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
using ii=long long;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    
    // b - k = -(a - k)
    // b - k = -a + k
    // a + b = 2k
    
    int c = a + b;
    if (c & 1) {
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    cout << c / 2 << "\n";
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a == b && b == c && c == a) {
    cout << 1 << endl;
  } else if (a != b && b != c && c != a) {
    cout << 3 << endl;
  } else {
    cout << 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 計算する最大値 */
	private static final int N = 100_000;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// 最大値まで2017に似た数を計算する
			int[] count = new int[N];
			count[0] = count[1] = count[2] = 0;
			List<Integer> primeList = new ArrayList<>();
			primeList.add(2);
			IntStream.range(3, N).forEach(i -> count[i] = count[i - 1] + (is2017LikeNumber(i, primeList) ? 1 : 0));
			int q = scanner.nextInt();
			IntStream.range(0, q).map(i -> {
				int l = scanner.nextInt();
				int r = scanner.nextInt();
				return count[r] - count[l - 1];
			}).forEach(System.out::println);
		}
	}

	/**
	 * 入力数字が素数かどうかを判定する
	 * 
	 * @param number    入力数字
	 * @param primeList 素数のリスト
	 * @return 入力数字が素数かどうか
	 */
	private static boolean isPrime(int number, List<Integer> primeList) {
		int sqrt = (int) Math.sqrt(number);
		for (int i : primeList) {
			if (i > sqrt) {
				primeList.add(number);
				return true;
			}
			if (0 == (number % i)) {
				return false;
			}
		}
		primeList.add(number);
		return true;
	}

	/**
	 * 入力数字が2017に似た数であるかどうかを計算
	 * 
	 * @param number 入力数字
	 * @return 入力数字が2017に似た数であるかどうか
	 */
	private static boolean is2017LikeNumber(int number, List<Integer> primeList) {
		return (1 == (number & 1)) && isPrime(number, primeList) && primeList.contains((number + 1) / 2);
	}
}


Measured memory_bytes: 67920
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n, sum; sum = 0, cin >> n, n; cout << sum << endl) while(n) sum += n /= 5;

    return 0;
}

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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  
  if ((P > Q) && (P > R)) cout << Q+R << endl;
  else if (Q > R) cout << P+R << endl;
  else cout << P + Q << endl;
}

Measured memory_bytes: 256
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 3e3+10;
vll a;
deque<ll> d;

signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	ll n;
	cin >> n;

	rep(i,0,n)
	{
		ll x;
		cin >> x;
		a.pb(x);

		ll k = a.size();
		while(k >= 3 and a[k-2] >= a[k-1] and a[k-2] >= a[k-3])
		{
			ll nawa = a[k-1]+a[k-3]-a[k-2];
			rep(i,0,3)
				a.pop_back();
			a.pb(nawa);
			k-=2;
		}
	}

	for(auto it: a)
		d.pb(it);

	ll ans = 0;
	ll sign = 1;
	while(d.size()!=0)
	{
		if(d.front()>=d.back())
		{
			ans+=sign*d.front();
			d.pop_front();
		}
		else
		{
			ans+=sign*d.back();
			d.pop_back();
		}
		sign*=-1;
	}
	cout<<ans<<endl;


	
	return 0;
}


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

using namespace std;

int main() {
	string  a,b,c;
	cin >> a >> b;
	c = a + a;
	if (c.find(b) != string::npos) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define MOD 1'000'000'007
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

vector<li> invpow(200010,1);

void make_pow(int n){
  invpow.at(1)=(MOD+1)/2;
  repa(i,2,n){
    invpow.at(i)=invpow.at(i-1)*invpow.at(1)%MOD;
    if(df)printf("%d:%ld\n",i,invpow.at(i));
  }
}

void dfs(int a,const vector<vector<int>>& adj,vector<int>& par
	 ,vector<int>& child){
  int cnt=1;
  for(int x: adj.at(a)){
    if(x==par.at(a))continue;
    par.at(x)=a;
    dfs(x,adj,par,child);
    cnt+=child.at(x);
  }
  child.at(a)=cnt;
}

template<typename T>
void print(vector<T>& vec){
  for(T x:vec) cout << x << " ";
  printf("\n");
}
template<typename T>
void print(vector<T>& vec,string str){
  cout << str << ":";
  for(T x:vec) cout << x << " ";
  printf("\n");
}

int size(int u,int v,const vector<int>& par
	 ,const vector<int>& child,int n){
  if(par.at(v)==u)return child.at(v);
  return n-child.at(u);
}

li calc(int u,const vector<vector<int>>& adj,const vector<int>& par
	,const vector<int>& child){
  if(adj.at(u).size()==1)return 0;
  int n=adj.size();
  li ret=1;
  li deg=adj.at(u).size();
  if(df)printf("%d,deg:%d ",u,deg);
  (ret+=(deg-1)*invpow.at(n-1))%MOD;
  for(int x:adj.at(u)){
    int sz=size(u,x,par,child,n);
    if(df)printf("cnt%d:%d ",x,sz);
    (ret-=invpow.at(n-1-sz))%=MOD;
  }
  (ret*=invpow.at(1))%=MOD;
  return (ret+MOD)%MOD;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;

  make_pow(n+2);
  
  vector<vector<int>> adj(n);
  rep(i,n-1){
    int a,b; cin >>a >>b; a--; b--;
    adj.at(a).push_back(b);
    adj.at(b).push_back(a);
  }
  vector<int> par(n,-1),child(n,1);
  
  dfs(0,adj,par,child);
  if(df){
    printf("adj:\n");
    for(auto& x: adj){
      print(x);
    }
    print(par,"parents");
    print(child,"childlen");
  }
  li ans=0;
  rep(i,n){
    li temp=calc(i,adj,par,child);
    if(df)printf("%ld\n",temp);
    (ans+=temp)%=MOD;
  }
  cout << ans;
}

/// confirm df==0 ///


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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define dup(x,y) (((x)+(y)-1)/(y))
#define vecadd emplace_back

typedef long long ll;

int main(){
  string str;
  cin>>str;
  
  bool isHard=false;
  
  rep(i,str.length()){
    if(i%2==0){
      if(str[i]=='L'){
        isHard=true;
      }
    }
    else{
      if(str[i]=='R'){
        isHard=true;
      }
    }
  }
  
  if(isHard){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF 2000000000
#define DESPACITO2 1000000000000000
#define DESPACITO 1000000000000000000
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define msi map<string,int>
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define TRvi(c,it) for(vi::iterator it=(c).begin();it!=(c).end();it++)
#define TRvii(c,it) for(vii::iterator it=(c).begin();it!=(c).end();it++)
#define TRmsi(c,it) for(msi::iterator it=(c).begin();it!=(c).end();it++)
 
 
using namespace std;


int main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr,arr+3);
    bool a=true;
    int minim=10000;
    while(a)
    {
    	int val=abs(arr[1]-arr[0])+abs(arr[2]-arr[1]);
    	minim=min(minim,val);
    	a=next_permutation(arr,arr+3);
    }
    cout << minim;
}

Measured memory_bytes: 256
def is_prime(n)
  return true if n == 2
  return false if n < 2  || n % 2 == 0
  i = 3 
  while i <= Math.sqrt(n)
    return false if n % i == 0
    i += 2
  end
  true
end

n = gets.to_i
c = 0

n.times do
  x = gets.to_i
  if is_prime(x)
    c += 1
  end
end

p c

Measured memory_bytes: 6116
import std.stdio;
import std.conv;
import std.string;

void main() {
    auto n = readln.chomp.to!(int);
    auto ans = 0;

    if (n / 100 == 9)
        ans += 100;
    else
        ans += 900;

    if (n % 100 >= 90)
        ans += 10;
    else
        ans += 90;

    if (n % 10 == 9)
        ans += 1;
    else
        ans += 9;

    ans.writeln;
}


Measured memory_bytes: 256
w="0357"
v=[p [a,b,c,d,e,f,g,h,i,j]|a<-w,b<-w,c<-w,d<-w,e<-w,f<-w,g<-w,h<-w,i<-w,j<-w]
u=[x|x<-v,not(elem '0' x),elem '3' x,elem '5' x,elem '7' x]
p ('0':s) = p s
p [] = "0"
p s = s
main=readLn>>=print.(\n->(sum[1|x<-[x|x<-u,(read x)<=(n::Int)]]))

Measured memory_bytes: 1020
N,A,B=map(int,input().split())
S=input()

a,b=0,0
for i,s in enumerate(S):
  if s=="c":
    print("No")
  elif s=="a":
    if a+b<A+B:
      print("Yes")
      a+=1
    else:
      print("No")
  else:
    if a+b<A+B and b<B:
      print("Yes")
      b+=1
    else:
      print("No")

Measured memory_bytes: 4016
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
#pragma comment(linker, "/STACK:1024000000,1024000000")
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 101010;
const int MOD = 1e9 + 7;
long long num[100005];
int main()
{
    long long  n;
    //scanf("%d",&n);
    //rep(i,0,n) scanf("%d",&num[i]);
    cin>>n;
    rep(i,0,n) cin>>num[i];
    sort(num,num+n);

    long long d=0,h=0,len=0;
    int flag=0;
    //for(int i=0;i<n;i++) printf("%d%c",num[i],i==n-1?'\n':' ');
    for(int i=n-1;i>=0;i--)
    {
        len=0;
        if(flag==2) break;
        while(num[i-len]==num[i]) len++;
        //de(len);
        if(len<=1) continue;
        if(flag==0)
        {
            if(num[i]>d)
                d=num[i];
            i--;
            flag=1;
            continue;
        }
        if(flag==1)
        {
            if(num[i]>h)
                h=num[i];
            i--;
            flag==2;
            continue;

        }
    }
    //de(flag);
    //de(h);de(d);
    if(h==0||d==0)
    {
        cout<<'0'<<endl;
        return 0;
    }
    long long ans=h*d;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
    
#pragma endregion library

int main(){
    int n; cin >> n;
    map<string,int> m;
    rep(i,n){
        string s; cin >> s;
        m[s] = m[s] + 1;
    }
    int M;cin >> M;
    rep(i,M){
        string s; cin >> s;
        m[s] = m[s] - 1;
    }
    int ans=0;
    for(auto it = m.begin(); it != m.end(); ++it){
        int value = it->second;
        if(value > 0) ans = max(ans, value);
    }
    cout << ans << '\n';
    


}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    ll ans = 0;
    for(ll i = 1; i <= N; i++) {
        if(i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

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


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

int main() {
  string s;
  cin >> s;
  int ans = 0, len = 0;
  for (size_t i = 0; i < s.length(); i++) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      len++;
      ans = max(len, ans);
    } else {
      len = 0;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main(void){
  int a[1001],n,m;

  while(cin >> n >> m,n|m){
    fill(a,a+n+1,0);
    int cnt=0,now=1,fg=0;
    while(true){
      for(int i=1;i<=n;i++){
	if(a[i])continue;
	if(cnt==n-1){
	  for(int j=1;j<=n;j++)
	    if(a[j]==0)cout << j << endl;
	  fg=1;
	  break;
	}
	if(now==m)a[i]=1,cnt++,now=0;
	now++;
      }
      if(fg)break;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(X)<<Y<<endl
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	int A,B;
	cin>>A>>B;
	if(A>9||B>9){
		cout<<-1<<endl;
	}
	else{
		cout<<A*B<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int A = Character.getNumericValue(s.charAt(0));
        int B = Character.getNumericValue(s.charAt(1));
        int C = Character.getNumericValue(s.charAt(2));
        int D = Character.getNumericValue(s.charAt(3));
        String[] op = new String[3];

        loop:
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                for(int k = 0; k < 2; k++){
                    int sum = A;
                    if(i == 0) { sum += B; op[0] = "+"; }
                    else { sum -= B; op[0] = "-"; }
                    
                    if(j == 0){ sum += C; op[1] = "+"; }
                    else { sum -= C; op[1] = "-"; }
                    
                    if(k == 0){ sum += D; op[2] = "+"; }
                    else { sum -= D; op[2] = "-"; }
                    
                    if(sum == 7) break loop;
                }
                
            }
           
        }
        System.out.println(A+op[0]+B+op[1]+C+op[2]+D+"=7");
    }
}

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

int main() {
  int n, cnt = 0;
  cin >> n;
  vector<int> a(n);
  int tmp = 1;
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
    if (i == 0) continue;

    if (a.at(i) == a.at(i - 1)) {
      tmp ++;
      continue;
    }
    if (a.at(i) != a.at(i - 1) && tmp > 1) {
      cnt += tmp / 2;
      tmp = 1;
    }
  }
  if (tmp > 1) {
    cnt += tmp / 2;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0,startp=0,endp=0,checker=0;
std::vector<unsigned long long int> vec{}, vecsec{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji,moji2;
bool okada = false,okada2=false;
std::string output, output2, input, one, two;
char cutcount[201];
int kakunou2[50][50] = {};

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >> moji >> moji2;
	if (moji > moji2) {
		cout << ">" << endl;
	}
	else if (moji < moji2) {
		cout << "<" << endl;
	}
	else {
		cout << "=" << endl;
	}
}

	
	





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

using namespace std;

const int N = 222222;

int n, k, cnt[N], ans;

int main(){
//	freopen("input.inp", "r", stdin);
	cin >> n >> k;
	int x;
	for(int i = 1; i <= n; ++i) cin >> x, ++cnt[x];
	sort(cnt + 1, cnt + 1 + n);
	for(int i = 1; i <= n - k; ++i) ans += cnt[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int N, K, i = 0, total = 0, A = 0, B = 0;
	scanf("%d %d", &N, &K);
	int ball_position[N];
	while (i < N) {
		scanf("%d", &ball_position[i]);
		i++;
	}

	for (i = 0; i < N; i++) {
		A = ball_position[i] * 2;
		B = (K - ball_position[i]) * 2;
		if (A < B)
			total += A;
		else
			total += B;
	}

	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  if(k == 0) {
    cout << n * n << endl;
    return 0;
  }
  ll ans = 0;
  REP(b,k+1,n+1) {
    ans += ((n + 1) / b) * (b - k);
    ans += max(((n + 1) % b - k), 0ll);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
c = [0] * (N + 1)
for i in range(N):
    c[i + 1] = c[i] + a[i]
ans = float('inf')
for n in c[1:-1]:
    ans = min(ans, abs(c[-1] - 2 * n))
print(ans)

Measured memory_bytes: 24832
s = int(input())
s_ = s
counter = 0

if s == 4 or s == 2 or s ==1:
  print(counter+4)
else:  
  while s!=4:
    if s%2 ==0:
      s = s//2
      counter +=1
    else:
      s = 3*s+1
      counter +=1
  else:
    print(counter+4)
    


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dx[4] = {1, 1, -1, -1};
int dy[4] = {1, -1, 1, -1};
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int xx[200010], yy[200010];
    rep(i, N) cin >> xx[i] >> yy[i];
    int ans = 0;
    rep(k, 4) {
        int x[200010], y[200010];
        int d[200010];
        rep(i, N) {
            x[i] = xx[i] * dx[k];
            y[i] = yy[i] * dy[k];
            d[i] = x[i] + y[i];
        }
        sort(d, d + N);
        ans = max(ans, d[N - 1] - d[0]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8348
import sys

input = sys.stdin.readline


class Segtree:
    # https://atcoder.jp/contests/agc038/submissions/7637556
    # の実装を借用しました
    
    # Segment tree
    # 1-indexed
    # 再帰を使わないもの
    # 最小値を求める
    def __init__(self, n, v, func, initial):
        self.initial = initial
        self.func = func
        self.size = 1 << n.bit_length()
        # Segment treeの台の要素数
        self.tree = [self.initial] * (2 * self.size)
        # 1-indexedなので、要素数2*self.size
        # Segment treeの初期値で初期化

        for i in range(n):  # Aを対応する箇所へupdate
            self.tree[i + self.size] = v[i]

        for i in range(self.size - 1, 0, -1):  # 親の部分もupdate
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, n, x):  # v[n]をxへ更新（反映）
        i = n + self.size
        self.tree[i] = x
        i >>= 1  # 子ノードへ

        while i != 0:
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])
            i >>= 1

    def getvalues(self, l, r):  # 区間[l,r)に関するfuncを調べる
        L = l + self.size
        R = r + self.size
        ANS = self.initial

        while L < R:
            if L & 1:
                ANS = self.func(ANS, self.tree[L])
                L += 1

            if R & 1:
                R -= 1
                ANS = self.func(ANS, self.tree[R])
            L >>= 1
            R >>= 1

        return ANS


class UnionFind:
    def __init__(self, n):
        self.v = [-1 for _ in range(n)]

    def find(self, x):
        if self.v[x] < 0:  # (負)は根
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if -self.v[x] < -self.v[y]:
            x, y = y, x
        self.v[x] += self.v[y]
        self.v[y] = x

    def root(self, x):
        return self.v[x] < 0


def main():
    n, k = map(int, input().split())
    p = tuple(int(x) for x in input().split())

    tr1 = Segtree(n, p, min, 1 << 30)
    tr2 = Segtree(n, p, max, -1)

    uf = UnionFind(n)

    cont = 1
    v = None
    for i in range(1, n):
        if p[i - 1] < p[i]:
            cont += 1
        else:
            cont = 1
        if cont >= k:
            # print(i - k + 1)
            if v is None:
                v = i - k + 1
            else:
                uf.unite(v, i - k + 1)
                # print(v, i - k + 1)

    for i in range(n - k):
        # print(f'i:{i} {p[i]} < {tr1.getvalues(i + 1, i + k)} < {tr2.getvalues(i + 1, i + k)} < {p[i + k]}')
        if p[i] < tr1.getvalues(i + 1, i + k) < tr2.getvalues(i + 1, i + k) < p[i + k]:
            uf.unite(i, i + 1)
            # print(i, i + 1)

    ans = sum(uf.root(x) for x in range(n - k + 1))
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  int N; cin>>N;
  float x[N];
  float sum=0.0;
  string u;
  for(int i=0;i<N;i++){
    cin>>x[i]>>u;
    if(u=="BTC") x[i]=x[i]*380000;
    sum += x[i];
  }
  cout<<sum;
}

Measured memory_bytes: 256