akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(){
    while(true){
        int n, a, b, c, x;
        cin >> n >> a >> b >> c >> x;
        if(n == 0){ break; }
        vector<int> y;
        for(int i = n; i > 0; --i){
            int tmp;
            cin >> tmp;
            y.push_back(tmp);
        }
        int answer = 0, idx = 0;
        while(answer <= 10000){
            if(x == y[idx]){
                if(++idx == n){ break; }
            }
            x = (a * x + b) % c;
            ++answer;
        }
        cout << (answer > 10000 ? -1 : answer) << endl;
    }
    return 0;
}

Measured memory_bytes: 908
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110000
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
	ll x;
	while (1)
	{
		x = a % b;
		if (x == 0)
			return b;
		else
		{
			a = b;
			b = x;
		}
	}
}

ll lcm(ll a, ll b)
{
	ll ans, gcd_ab;
	gcd_ab = gcd(a, b);
	ans = a * b / gcd_ab;
	return ans;
}

int main() {
	ll i, j;
	ll A, B, C, D;
	ll ans;
	ll anstmp;
	cin >> A >> B >> C >> D;
	ll lcmCD = lcm(C, D);
	A--;
	ans = B - A;
	anstmp = B / C;
	anstmp -= A / C;
	ans -= anstmp;
	anstmp = B / D;
	anstmp -= A / D;
	ans -= anstmp;
	anstmp = B / lcmCD;
	anstmp -= A / lcmCD;
	ans += anstmp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toLong

  //
  if (N % 2 == 1)
    println(0)
  else {
    var a = N / 2L

    var ans = 0L
    while (a > 0) {
      ans += a / 5
      a /= 5
    }

    println(ans)
  }

}



object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b;
  cin>>a>>b;
  if(a==1)a+=13;
  if(b==1)b+=13;
  cout<<(a>b ? "Alice" : a<b ? "Bob" : "Draw")<<endl;
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int MAXN = 1e5 + 10;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int>> dp(n + 1, vector<int>(2));
    dp[0][1] = 1;
    for (int i = 0; i < n; i++) {
        int c = s[i] - '0';
        dp[i + 1][0] = min(dp[i][0] + c, dp[i][1] + 10 - c);
        dp[i + 1][1] = min(dp[i][0] + c + 1, dp[i][1] + 10 - c - 1);
    }
    cout << dp[n][0];
    return 0;
}


Measured memory_bytes: 58876
def minus(n):
  if n>=0:
    return 0
  else:
    return 1
N=int(input())
L=list(map(int,input().split()))
c=sum(list(map(minus,L)))
if c%2==0:
  t=sum(list(map(abs,L)))
  print(t)
else:
  L=list(map(abs,L))
  print(sum(L)-min(L)*2)

Measured memory_bytes: 20140
h,w = map(int,input().split())	

if h == 1 or w == 1:
    print(1)
else:
    h *= w
    if h % 2 == 0 :
         h /= 2
         print(int(h))
    else :
         h += 1
         h /= 2
         print(int(h))

Measured memory_bytes: 2940
mod = 998244353
N = int(input())
D = [int(i) for i in input().split()]
if D[0] != 0:
    print(0)
    exit()
for i in range(1,N):
    if D[i] == 0:
        print(0)
        exit()
def pow_k(a,n,mod): #a**n
    if n == 0:
        return 1
    if n % 2 ==0:
        return pow_k(a*a % mod,n//2,mod)
    else:
        return a * pow_k(a,n-1,mod) % mod
import collections
c = collections.Counter(D)
li = list(c.keys())
li.sort()
n = li[-1]
ans = 1
for i in range(1,n+1):
    if c[i] == 0:
        print(0)
        exit()
    else:
        j = i-1
        k = pow_k(c[j],c[i],mod)
        ans *= k
        ans %= mod
print(ans)

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

int main(){
  int A,B,total;
  cin >> A;
  cin >> B;

  if (A > B) total = 2*A-1;
  else if (A == B) total = 2*A;
  else total = 2*B-1;

  cout << total << endl;

  return 0;
}


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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();

int main(){
    int N;
    int a;
    int p,q;
    ULL temp;
    int i,j;
    bool *use;
    int count;
    cin >> N;
    p = q = 1;
    temp = 1;

    use = new bool[N];
    for(i=0;i<N;i++){
        use[i] = false;
    }
    for(i=0;i<N;i++){
        cin >> a;
        temp = 1;
        for(j=i+1;j<N;j++){
            temp *= (N - j);
        }
        count = 0;
        for( j = a-2; j >= 0;j--){
            count += !use[j];
        }
        //cout << count << "," << temp << endl;
        p += count * temp;
        use[a-1] = true;
    }
    for(i=0;i<N;i++){
        use[i] = false;
    }
    for(i=0;i<N;i++){
        cin >> a;
        temp = 1;
        for(j=i+1;j<N;j++){
            temp *= (N - j);
        }
        count = 0;
        for( j = a-2; j >= 0;j--){
            count += !use[j];
        }
        //cout << count << "," << temp << endl;
        q += count * temp;
        use[a-1] = true;
    }
    cout << abs(p-q) << endl;
    return 0;
}

void process(){
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

map<pll, ll> dp[22][22];
int N, A[22];

ll Do(int l, int r, int a, int b) {
	if(l > r) return 0;
	if(dp[l][r].find(pll(a, b)) != dp[l][r].end()) return dp[l][r][pll(a, b)];
	int c = a + b;
	ll res = 1e18;
	for(int i=l;i<=r;i++) {
		ll rv = Do(l, i-1, a, c) + Do(i+1, r, c, b) + (ll) A[i] * c;
		res = min(res, rv);
	}
	return dp[l][r][pll(a, b)] = res;
}

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%d", A + i);
	printf("%lld\n", Do(2, N-1, 1, 1) + A[1] + A[N]);
	return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(x) cout << x << endl
const int INF = 1e+8+7;
ll n,m;
int a,b,c = 0;
string s,t;
// int d[100],dp1[500][500],dp2[500][500];
int d[200010];
vi vec;

int main(){
  cin >> n >> m;
  rep(i,0,n){
    cin >> a;
    d[a]++;
  }
  lep(i,1,n){
    if(d[i] != 0)c++;
  }
  if(c <= m){
    b = 0;
  }else{
    int count = 0;
    lep(i,1,n){
      lep(j,1,n){
        if(d[j] == i){
          count++;
          b += i;
          d[j] = -1;
        }
        if(count == c-m)break;
      }
      if(count == c-m)break;
    }
  }
  print(b);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll p[200005];


int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll count = 1;
	for (int i = 0; i < n-1; i++) {
		if (s[i] != s[i + 1]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
 
template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	string s;
	while(cin >> s, s[0] != '#'){
		int y, m, d;
		cin >> y >> m >> d;
		if((m >= 5 and y == 31) or y > 31){
			cout << "?" << ' ' << y - 31 + 1 << ' ' << m << ' ' << d << endl;
		}else{
			cout << "HEISEI" << ' ' << y << ' ' << m << ' ' << d << endl;
		}
	}
}



Measured memory_bytes: 3168
INF = 10**6


n, m = gets.split.map(&:to_i)

N = 1 << n 
keys = Array.new(N, INF)

m.times do
    a, b = gets.split.map(&:to_i)
    c = gets.split.map(&:to_i)

    num = 0
    c.each do |x|
        num += 1 << (x - 1)
    end

    keys[num] = a if keys[num] > a
end

keys[0] = 0
for x in 0...N
    for y in x+1...N
        if keys[x|y] > keys[x] + keys[y]
            keys[x|y] = keys[x] + keys[y]
        end
    end
end

if keys[N-1] == INF
    puts -1
else
    puts keys[N-1]
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LLONG_MIN
#define     INF         LLONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    ll ar[5];
    mem(ar,0);
    for(ll i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="AC") ar[0]++;
        else if(s=="TLE") ar[1]++;
        else if(s=="WA") ar[2]++;
        else ar[3]++;
    }
    cout<<"AC x "<<ar[0]<<endl;
    cout<<"WA x "<<ar[2]<<endl;
    cout<<"TLE x "<<ar[1]<<endl;
    cout<<"RE x "<<ar[3]<<endl;
    return 0;
}



















Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    cin>>n;
    
    vector<pii> ans;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            string s = string(n,'0');
            s[i] = s[j] = '1';
            cout<<"? "<<s<<endl;
            
            int res;
            cin>>res;
            if(res){
                ans.pb(pii(i,j));
            }
        }
    }
    cout<<"!";
    rep(i,ans.size()){
        cout<<" (";
        cout<<ans[i].first<<","<<ans[i].second;
        cout<<")";
    }
    cout<<endl;
}

Measured memory_bytes: 852
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        boolean f0 =  str.charAt(0)==str.charAt(1) && str.charAt(2)==str.charAt(3);
        boolean f1 = str.charAt(0)==str.charAt(2) && str.charAt(1)==str.charAt(3);
        boolean f2 =  str.charAt(0)==str.charAt(3) && str.charAt(1)==str.charAt(2);
        boolean nf =  str.charAt(0)==str.charAt(1) && str.charAt(0) == str.charAt(2);
        if((f0 || f1 || f2) && !nf){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int min1 = min(a, b);
    int min2 = min(c, d);
    cout << min1 + min2 << endl;

    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		int N = sc.nextInt();
		//String S = sc.next();
		double sum=0;
		//char buff=S.charAt(0);
		List<Double> array=new ArrayList<Double>();
		for(int i=0;i<N;i++) {
			array.add((double) sc.nextInt());
		}

		for(int i=0;i<N-1;i++) {
			Collections.sort(array);
			array.set(0,(array.get(0)+array.get(1))/2);
			array.remove(1);
		}
		System.out.println(array.get(0));
	}


	public static int sample() {
		return 1;
	}

}


Measured memory_bytes: 21844
n, m, k = map(int, input().split())
R = [[0]*n for _ in range(n)]
for _ in range(m):
  l, r = map(int, input().split())
  l -= 1
  r -= 1
  R[r][l] += 1

for i in range(1,n):
  for j in range(n):
    R[i][j]+=R[i-1][j]
    
for i in range(n):
  for j in range(n-2,-1,-1):
    R[i][j] += R[i][j+1]

#[print(R[i]) for i in range(n)]
for _ in range(k):
  p, q = map(int, input().split())
  print(R[q-1][p-1])

Measured memory_bytes: 58892
// Contest: AtCoder Beginner Contest 173 (https://atcoder.jp/contests/abc173)
// Problem: D: Chat in a Circle (https://atcoder.jp/contests/abc173/tasks/abc173_d)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    int n; cin >> n;
    vi a(n);
    trav(ai, a) cin >> ai;
    sort(all(a));

    int rem = n - 2;
    ll sum = a[n-1];
    for (int i = n - 2; i >= 0; --i) {
        sum += a[i] * min(2, rem);
        rem -= min(2, rem);
    }

    cout << sum << '\n';
    return 0;
}


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

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int,int>> edge;
    for(int i = 1; i <= n; i++) {
        for(int j = i+1; j <= n; j++) {
            if(n&1) {
                if(i+j != n) edge.push_back({i, j});
            }
            else {
                if(i+j != n+1) {
                    edge.push_back({i, j});
                }
            }
        }
    }
    cout << edge.size() << endl;
    for(auto t : edge) {
        cout << t.first << " " << t.second << endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll x = 0;
  rep(i,n){
    if(i%2==0) x += a[i];
    if(i%2)x -= a[i];
  }
  vector<int> ans(n);
  ans[0] = x/2;
  
  for(int i=0;i<n-1;i++){
    ans[i+1] = a[i] - ans[i];
  }
  rep(i,n){
    ans[i] *= 2;
  }
  rep(i,n){
    printf("%d%c",ans[i],i==n-1 ? '\n' : ' ');
  }
}

Measured memory_bytes: 2048
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int m1, int d1, int m2, int d2) {
    if (m1 == m2) {
      return 0;
    }
    return 1;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int m1 = reader.nextInt();
    int d1 = reader.nextInt();
    int m2 = reader.nextInt();
    int d2 = reader.nextInt();
    out.println(solve(m1, d1, m2, d2));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21204
x=int(input())

if x<100:
  print('0')
  exit()

aa=x // 100
a=x- 100*aa
b=a//5
c=a%5

def g(r):
  if r==0:
    return 0
  else:
    return 1
if b+g(c)<=aa:
  print('1')
else:
  print('0')

Measured memory_bytes: 3064
N = int(input())

L0 = 2
L1 = 1
L2 = 3
if N == 0:
    print(L0)
elif N==1:
    print(L1)
else:
    ans = {}
    ans[0] = L0
    ans[1] = L1
    for i in range(2,N+1):
        ans[i] = ans[i-1]+ans[i-2]
    print(ans[N]) 



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





class Solution {
  int n, m;
public:
  void run() {
    cin >> n >> m;
    vector<pair<int, int>> A(n);
    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      A[i] = {a, b};
    }
    sort(A.begin(), A.end());
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      long long buy = min(m, A[i].second);
      m -= buy;
      ans += buy * A[i].first;
    }
    cout << ans << '\n';
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Solution().run();
}


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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> order(N);
	for (int i{}; i < N; i++)
	{
		int A;
		scanf("%d", &A);
		order[A - 1] = i;
	}

	for (int i{}; i < N; i++)
		printf("%d%c", order[i] + 1, i + 1 == N? '\n': ' ');

	return 0;
}

Measured memory_bytes: 1152
s = input()

while len(s) > 0:
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        break

if len(s) > 0:
    print("NO")
else:
    print("YES")

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans = "";
  for(int i = 0; i < s.size(); i += 2) {
    ans.push_back(s[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  ll ans = 0;
  vector<ll> v[11];
  v[0].push_back(0);

  rep(i, 10) {
    rep(j, ll(v[i].size())) {
      ll tmp = v[i][j] * 10;

      if (tmp + 3 > n) break;
      v[i+1].push_back(tmp+3);
      if (tmp + 5 > n) break;
      v[i+1].push_back(tmp+5);
      if (tmp + 7 > n) break;
      v[i+1].push_back(tmp+7);
    }
  }

  rep(i, 10) {
    rep(j, ll(v[i].size())) {
      string s = to_string(v[i][j]);
      if(s.find("3") == string::npos || s.find("5") == string::npos || s.find("7") == string::npos)
        continue;

      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
}
    

Measured memory_bytes: 3792
W,H,x,y,r= input().split()

W = int(W)
H = int(H)
x = int(x)
y = int(y)
r = int(r)

if x+r <= W and x-r >= 0 :
    if y+r <= H and y-r >= 0:
        out_put = "Yes"
    else:
        out_put = "No"
        
else:
    out_put = "No"


print(out_put)


Measured memory_bytes: 5596
n = int(input())
sp = []
for i in range(n):
    s, p = map(str, input().split())
    sp.append([s, int(p), i+1])


sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])

for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 38512
Public Class Program
  Shared Sub Main()
    Dim x As Integer = Cin.Int()
    Dim ans As Integer = 0
    Do While ans = 0
      If x = 2 Then
        ans = x
      ElseIf x Mod 2 <> 0 Then
        Dim sqrtX As Double = Math.Sqrt(x)
        For i As Integer = 3 To Math.Floor(sqrtX) Step 2
          If x Mod i = 0 Then
            ans = 0
            Exit For
          Else
            ans = x
          End If
        Next
      End If
      x += 1
    Loop
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K,cnt = 0,ans = 0;
    cin >> N >> K;
    vector<int> A(N,0);
    for(int i = 0;i < N;i ++){
        int num;
        cin >> num;
        A[num-1] ++;
    }
    sort(A.begin(),A.end());
    for(int i = N-1;i >= 0;i --){
        if(A[i] != 0) cnt++;
        else break;
    }
    for(int i = 0;cnt > K;i ++){
        if(A[i] != 0){
            ans += A[i];
            cnt --;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b;
  c = a*b;
  if (c%2 == 0){
    cout << "Even" << endl;
  }else if (c%2 != 0){
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n,m;
	int a[101][101],b[101],c[101];
	int i,j;

	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	
	for(j=0;j<m;j++)
	{
		scanf("%d",&b[j]);
	}	
	
	for(i=0;i<n;i++)
	{
		c[i]=0;
		for(j=0;j<m;j++)
		{
			c[i]+=a[i][j]*b[j];
		}
	}
	
	for(i=0;i<n;i++)
	{
		printf("%d\n",c[i]);
	}	
	
	return 0;
}



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

int main() {
    int arr[26]={0};
    string str;
    while(getline(cin, str)) {
      for(int i=0; i<str.length(); i++) {
        char c = str[i];
        if (c>='a' && c<='z') {
            arr[c-'a']++;
        } else if (c>='A' && c<='Z') {
            arr[c-'A']++;
        }
      }
    }


    for (int i=0; i<26; i++) {
        char a = 'a'+i;
        cout << a << " : " << arr[i] <<endl;
    }
    return 0;
}



Measured memory_bytes: 3168
//  यस्य स्मरणमात्रेण जन्मसंसारबन्धनात् ।  विमुच्यते नमस्तस्मै विष्णवे प्रभविष्णवे ॥
 
 
 
/****
*     Author- Indrajeet Mishra
*             MNNIT Allahabad, Prayagraj
*             Chemical Engineering undergraduate
 
 
 
****/
 
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
 
#include <bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 

using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=0;cin>>n;
    string s;cin>>s;
    vector<char>v;
    rep(i,0,s.size()){
        v.pb(s[i]);
    }
    ll count=0;
    auto it=unique(all(v));
    for(auto itr=v.begin();itr!=it;++itr)
        count++;
    cout<<count;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n;
    cin >> n;
    vector<int> v(3, 0);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v[a-1]++;
    }
    long double p = 1.0/n;
    auto dp = make_v(n+1, n+1, n+1, 0.0L);
    for (int k = 0; k <= n; ++k) {
        for (int j = 0; j <= n; ++j) {
            for (int i = 0; i <= n; ++i) {
                if(i+j+k == 0 || i+j+k > n) continue;
                if(i) dp[i][j][k] += dp[i-1][j][k]*i*p;
                if(j) dp[i][j][k] += dp[i+1][j-1][k]*j*p;
                if(k) dp[i][j][k] += dp[i][j+1][k-1]*k*p;
                dp[i][j][k] = (dp[i][j][k]+1)/(1-(n-i-j-k)*p);
            }
        }
    }
    cout << setprecision(15) << dp[v[0]][v[1]][v[2]] << "\n";
    return 0;
}


Measured memory_bytes: 431360
X=gets.chomp.split("")
scnt = 0
cnt = 0
for i in 0..(X.size-1)
	case X[i]
	when "S"
		scnt += 1
	when "T"
		if(scnt > 0)
			scnt -= 1
			cnt += 1
		end
	end
end
puts X.size - 2*cnt



Measured memory_bytes: 12796
#include <stdio.h>

int main(void) {
  int N;
  int K;
  int D;
  int A;
  int okashi[256] = {};
  int cnt = 0;
  scanf("%d", &N);
  scanf("%d", &K);
  for (int i = 0; i < K; i++) {
    scanf("%d", &D);
    for (int j = 0; j < D; j++) {
      scanf("%d", &A);
      okashi[A - 1] = 1;
    }
  }
  for (int p = 0; p < N; p++) {
    if (okashi[p] == 0) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1736
N = int(input())
X = [[0] * 10 for _ in range(10)]
for i in range(1, N+1):
    s = str(i)
    X[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += X[i][j] * X[j][i]
print(ans)

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        sb.append(sc.next());
        StringBuilder sbl = new StringBuilder();
        StringBuilder sbr = new StringBuilder();
        int normal = 1;
        int q = Integer.parseInt(sc.next());
        for(int i=0; i<q; i++) {
            int t = Integer.parseInt(sc.next());
            if(t == 1) {
                if(normal==1) normal = -1;
                else normal = 1;
            }else {
                int f = Integer.parseInt(sc.next());
                String c = sc.next();
                if(f == 1) {
                    if(normal==1) sbl.append(c);
                    else sbr.append(c);
                }
                else {
                    if(normal==1) sbr.append(c);
                    else sbl.append(c);
                }
            }
        }
        if(normal==1) {
            System.out.println(sbl.reverse()+String.valueOf(sb)+sbr);
        }else {
            System.out.println(sbr.reverse()+String.valueOf(sb.reverse())+sbl);
        }
    }
}

Measured memory_bytes: 89100
// Beginning with the name of ALMIGHTY GOD ALLAH
// Author:: Mohammad Faisal
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  bool one=false, two=false, three=false;
  if(a==1)
    one=true;
  else if(a==2)
    two = true;
  else if(a==3)
    three = true;
  
  if(b==1)
    one=true;
  else if(b==2)
    two = true;
  else if(b==3)
    three = true;
  
  if(one && three)
    cout<<"2"<<endl;
  else if(two && one)
    cout<<"3"<<endl;
  else if(two && three)
    cout<<"1"<<endl;
  
  return 0;
}
 
 

Measured memory_bytes: 256
num=int(input())
r_1=int(input())
r_2=int(input())

max_profit=r_2-r_1
if r_1<r_2:
    min_value=r_1
else:
    min_value=r_2

for i in range(2,num):
    x=int(input())
    t=x-min_value
    if max_profit<t:
        max_profit=t
    if x<min_value:
        min_value=x
        
print(max_profit)

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2000;
int n;
ll x, a[N], b[N], sol;

int rep(int i) {
  if (i < 0) {
    i += n;
  }
  return i;
}

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

  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    sol += a[i];
  }
  for (int i = 1; i <= n; i++) {
    ll cur = x * i;
    for (int j = 0; j < n; j++) {
      int k = rep(j - i);
      b[j] = min(b[j], a[k]);
      cur += b[j];
    }
    sol = min(sol, cur);
  }
  cout << sol << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

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

// const int kMaxN;

int N;
// int ans = 0;

signed main() {
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A, B;
    cin >> A;
    cin >> B;
    cout << A+B << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int > vi;
typedef pair<int ,int > pii;
typedef vector<pii> vii;
const int inf=0x3f3f3f3f, maxn=100007, mod=1e9+7;
const ll linf=0x3f3f3f3f3f3f3f3fLL;
int n,a[2007];
vi e[2007];
vi e2[2007];
bool vis[2007];
int deg[2007];
void dfs(int x){
	if(vis[x])return ;
	vis[x]=true;
	for(int i=0;i<e[x].size();i++){
		if(!vis[e[x][i]]){
			e2[x].pb(e[x][i]);
			deg[e[x][i]]++;
			dfs(e[x][i]);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(__gcd(a[i],a[j])>1)e[i].pb(j),e[j].pb(i);
		}
	}
	for(int i=1;i<=n;i++)sort(e[i].begin(),e[i].end());
	for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++){
		for(int j=n;j>=1;j--){
			if(!deg[j]&&!vis[j]){
				vis[j]=true;
				printf("%d ",a[j]);
				for(int k=0;k<e2[j].size();k++)deg[e2[j][k]]--;
				break;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main() {
	int h, w;
	cin >> h >> w;
	int i, j;
	char s[100][100];
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	bool flag = true;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				bool ok = false;
				for (int dir = 0; dir < 4; dir++) {
					int ni = i + dx[dir];
					int nj = j + dy[dir];
					if (ni<0 || ni>h || nj<0 || nj>w) continue;
					if (s[ni][nj] == '#') ok++;
				}
				if (!ok) flag = false;
			}
		}
	}
	if (flag) cout << "Yes";
	else cout << "No";
	return(0);
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let ab = read_vec::<i64>();
    let (a,b) = (ab[0],ab[1]);
    let plus = a + b;
    let div = a * b;
    let ans = if plus == 15 {
        "+".to_string()
    } else if div == 15 {
        "*".to_string()
    } else {
        "x".to_string()
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
import sys
from operator import itemgetter


class BinaryIndexedTreeCustom:
    def __init__(self, n, init, func):
        self.size = n
        self.tree = [init] * (n + 1)
        self.depth = n.bit_length()
        self.init = init
        self.func = func

    def get(self, i):
        s = self.init
        while i > 0:
            s = self.func(s, self.tree[i])
            i -= i & -i
        return s

    def put(self, i, x):
        while i <= self.size:
            self.tree[i] = self.func(self.tree[i], x)
            i += i & -i


n, *aaa = map(int, sys.stdin.buffer.read().split())
bit1 = BinaryIndexedTreeCustom(n, 0, max)
bit2 = BinaryIndexedTreeCustom(n, n + 1, min)
aaa_with_index = list(enumerate(aaa, start=1))
aaa_with_index.sort(key=itemgetter(1))
ans = 0
for i, a in aaa_with_index:
    li = bit1.get(i)
    ri = bit2.get(n - i)
    ans += a * (i - li) * (ri - i)
    bit1.put(i, i)
    bit2.put(n + 1 - i, i)
print(ans)


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


int main(){

    // 読み込み
    int N,M;
    long K;
    cin >> N >> M >> K;
    vector<int> A(N,0); for(int i=0;i<N;i++) cin >> A[i];
    vector<int> B(M,0); for(int i=0;i<M;i++) cin >> B[i];

    // 累積和データを保存しておく
    vector<long> sumA(N+1,0);
    sumA[0] = 0;
    sumA[1] = sumA[0] + A[0];
    for(int i=2;i<=N;i++){
        sumA[i] = sumA[i-1]+A[i-1]; // i冊目まで読んだときの合計時間
        // Kが10^9以下なのでオーバーフロー考慮しなくて良い
        if(sumA[i]>K){ // 上限超えとなるので i冊目は存在しないこととする
            N = i-1;
            break;
        }
    }
    vector<long> sumB(M+1,0);
    sumB[0] = 0;
    sumB[1] = sumB[0] + B[0];
    for(int i=2;i<=M;i++){
        sumB[i] = sumB[i-1]+B[i-1]; // i冊目まで読んだときの合計時間
        // Kが10^9以下なのでオーバーフロー考慮しなくて良い
        if(sumB[i]>K){ // 上限超えとなるので i冊目は存在しないこととする
            M = i-1;
            break;
        }
    }
    // sumA, sumB の各要素は 10^9 以下であるから足し合わせてもオーバーフローしない

    // 読める数最大値
    int maxv = 0;
    for(int i=0;i<=N;i++){
        // Aをi冊読んだらK以上となる -> おしまい
        if(sumA[i]>K) break;

        // Bを全部読んでもK以下となる -> 全部読んだときをmaxとして次へ
        if(sumA[i]+sumB[M]<=K){
            maxv = i+M;
            continue;
        }

        // 全探索すると遅いので二分探索

        // B側を読むのに使っていい時間
        long dst = K-sumA[i];

        int L=0, R=M;
        while(R-L!=1){
            int mid=(L+R)/2;
            long tmp = sumB[mid];
            if(tmp<dst){
                L = mid;
            }else if(tmp==dst){
                L = mid;
            }else{ // tmp > dst
                R = mid;
            }
        }

        if(maxv < i+L){
            maxv = i+L;
        }
    }

    cout << maxv << endl;
    
    return 0;
}

Measured memory_bytes: 7984
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int keta(int i) {
	int ret=0;
	while (i > 0) {
		i /= 10;
		ret++;
	}
	return ret;

}
void ita(int y, vector<int> *x) {
	int i = x->size()-1;
	while (y > 0) {
		x->at(i--) = y % 10;
		y /= 10;
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	int count = 0;
	for (int i = a; i <= b; i++) {
		vector<int> x(keta(i));
		ita(i, &x);
		int l = 0, r = x.size() - 1;
			while (x.at(l++) == x.at(r--)) {
				if (l > r) {
					count++;
					break;
				}
			}
		
	}
	cout << count << endl;
}

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

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a >= 13)
    {
        printf("%d\n", b);
    }
    else if (a <= 5)
    {
        printf("%d\n", 0);
    }
    else
    {
        printf("%d\n", b / 2);
    }
    return 0;
}

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

typedef long long LL;
const int maxn = 1000+100;
LL A[maxn],B[maxn];
int n;


int main()
{
    //freopen("./test.txt","r",stdin);
    scanf("%d",&n);
    for(int i = 1;i <= n;++i)
        scanf("%lld %lld",&A[i],&B[i]);
    LL resx = A[1],resy = B[1];
    for(int i = 2;i <= n;++i)
    {
        LL t1 = resx/A[i] + (resx % A[i] != 0);
        LL t2 = resy/B[i] + (resy % B[i] != 0);

        LL t = max(t1,t2);
        resx = t*A[i];
        resy = t*B[i];
    }
    printf("%lld\n",resx+ resy);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();
		char[] c = s.toCharArray();

		int ans = 1;
		for (int i = 0; i < n-1; i++) {

			if (c[i] != c[i + 1])

				ans++;
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 26404
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct Item {
    double v, w;
} item[100000];

bool cmp(Item a, Item b) {
    return a.v / a.w > b.v / b.w;
}
int main() {
    int N, W;
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> item[i].v >> item[i].w;
    }
    sort(item, item + N, cmp);
    double ans = 0;
    int i = 0;
    while (W > 0 && i<N) {
        if (item[i].w > W)ans += item[i].v * W / item[i].w;
        else ans += item[i].v;
        W -= item[i].w;
        i++;
    }
    printf("%.8lf", ans);
    return 0;
}



Measured memory_bytes: 4880
my @c;
for ^3 {
    my ($a,$b)=get.words>>.Int;
    @c[$a - 1]++; @c[$b - 1]++;
}
say (@c.grep(* %% 2) == +@c - 2 or @c.grep(* %% 2) == +@c) ?? "YES" !! "NO";


Measured memory_bytes: 67484
#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

typedef long double ldouble;

const ll MXN = 2e5 + 1;

int n, a[MXN], b[MXN], sum, ind;
double mn = MXN * 5000;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + n + 1);
    for(int i = 1; i < n; i++){
        if(abs(b[i] - 1.0 * b[n] / 2) * 1.0 < mn){
            mn = abs(b[i] - 1.0 * b[n] / 2);
            ind = i;
        }
    }
    cout << b[n] << ' ' << b[ind];
    return 0;
}


Measured memory_bytes: 1024
import itertools
N=int(input())
S=[int(thing) for thing in list(input())]
kes=N-3
pass_set=set([])
def passkosu(k):
    num = 0

    if k in S[0:N-1]:
        l_left=S.index(k)
        for l in range(0,10):
            if l in S[l_left+1:N-1]:
                l_center=S[l_left+1:].index(l)+l_left+1
                dif=len(set(S[l_center+1:]))
                num=num+dif
    return num

print(sum([passkosu(i) for i in range(0,10)]))

Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e6)

int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<ull>> t;
	t=vector<vector<ull>>(n+1, vector<ull>(0,0));
	int p[m];
	ull y[m];
	for(int i=0; i<m; i++){
		cin >> p[i] >> y[i];
		t[p[i]].push_back(y[i]);
	}
	for(int i=1; i<=n; i++){
		sort(t[i].begin(), t[i].end());
	}
	for(int i=0; i<m; i++){
		int j=lower_bound(t[p[i]].begin(), t[p[i]].end(), y[i])-t[p[i]].begin();
		printf("%06d%06d\n", p[i], j+1);
	}
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  while(S!="0") {
      int count=0;
      for (int i=0; i<S.size(); i++) {
          string a;
          a=S.at(i)+"2"-"2";
          int n=stoi(a);
          count+=n;
      }
      cout << count << endl;
      cin >> S;
  }
}


Measured memory_bytes: 3156
import java.util.*;

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

		int h = scan.nextInt();

		int[] a = new int[h+1];

		for(int i = 1; i <= h; i++)
			a[i] = scan.nextInt();

		for(int i = h/2; i > 0; i--)
			maxHeap(a, i);

		for(int i = 1; i <= h; i++)
			System.out.print(" "+ a[i]);
		System.out.print("\n");

		scan.close();
		System.exit(0);
	}

	private static void maxHeap(int[] a, int i){
		int l = i * 2;
		int r = i * 2 + 1;
		int max = i;
		if(l < a.length && a[l] > a[i])
			max = l;
		if(r < a.length && a[r] > a[max])
			max = r;
		if(max != i){
			int work = a[i];
			a[i] = a[max];
			a[max] = work;
			maxHeap(a, max);
		}
	}
}

Measured memory_bytes: 167524