akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi T(5);
	REP(i, 5)cin >> T[i];
	sort(ALL(T), [](int a, int b) {return (a - 1) % 10 < (b - 1) % 10; });
	rev(T);
	int ans = 0;
	REP(i, 4) {
		ans += ((T[i] + 9) / 10) * 10;
	}
	ans += T[4];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [int(x) for x in list(input())]
li = []
lj = []
lk = []
count = 0
for i_id, i in enumerate(S[0:N-2]):
  if i not in li:
    for j_id, j in enumerate(S[i_id+1:N-1]):
      if j not in lj:
        for k in S[i_id+j_id+2:N]:
          if k not in lk:
            count += 1
            lk.append(k)
        lj.append(j)
        lk.clear()
    li.append(i)
    lj.clear()
print(count)

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

_LL getans(_LL n, _LL ox, _LL m, int *index)
{
    _LL sum = 0;
    _LL x = ox;
    vector<_LL> ans(m);
    for(_LL i = 1; i < n; i++ )
    {
        x = (x * x) % m;
        if( index[x] >= 0 )
        {
            int si = index[x];
            _LL looplen = i - si;
            _LL loopv = sum - ans[si];
            _LL looptime = (n - si) / looplen;
            _LL loopmod = (n - si) % looplen;
            return ox + ans[si] + loopv * looptime + (ans[si + loopmod] - ans[si]);
        } 
        else
        {
            ans[i] = sum;
            sum += x;
            index[x] = i;
        }
    }
    return sum + ox;
}

int main()
{
    _LL n, x, m; cin >> n >> x >> m;
    int *index = new int[m];
    rep(i, m) index[i] = -1;
    cout << getans(n, x, m, index) << endl;
    delete index;
    return 0;    
}

Measured memory_bytes: 4268
n, m = gets.split.map(&:to_i)
a = m.times.map{ gets.to_i }

foo = Array.new(n + 10, 0)
mod = 10 ** 9 + 7
foo[0] = 1
a.each{ |h| foo[h] = -1 }
(1..n).each do |i|
    foo[i] = foo[i] < 0 ? 0 : (foo[i-1] + foo[i-2]) % mod
end

puts foo[n]

Measured memory_bytes: 3764
#include <stdio.h>
#define MAX 100000

int parent(int );
int left(int );
int right(int );

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1 ) printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}

int parent(int n){
  return n/2;
}

int left(int n){
  return 2*n;
}

int right(int n){
  return 2*n +1;
}



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

using namespace std;

int main(){
  long n,k;
  cin >> n >> k;
  long r,s,p;
  cin >> r >> s >> p;
  map<char,long> po;
  po['r']=p;
  po['s']=r;
  po['p']=s;
  string t;
  cin >> t;
  vector<bool> f(t.size(),false);
  long ans=0L;
  for(int i=0;i<t.size();i++){
    if(i<k){
      ans+=po[t[i]];
      f[i]=true;
    }else{
      if(t[i-k]==t[i]&&f[i-k]){
        continue;
      }else{
        ans+=po[t[i]];
        f[i]=true;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

// 全マスを踏んだか
// 最短経路ではないからbfsではないか
// dfsでいけそう

int main() {
    // 左下にあったらアウトでは？
    int h, w;
    cin >> h >> w;
    char c[h][w];
    rep(i, h) rep(j, w) cin >> c[i][j];
    rep(i, h - 1) rep3(j, 1, w) {
        if (c[i][j] == '#' && c[i + 1][j - 1] == '#') { out("Impossible"); return 0; }
    }
    out("Possible");
    
    // 下、右が可能
    // 下で上は意味ない
    // 下で左
    // 左下#発生
    // 右で上
    // 左下#発生
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
    string s,t;
    cin >> s >> t;
    int count=0;
    for(int i=0; i<s.size();i++){
        if(s.at(i)!=t.at(i)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3688
//Optimise
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fast()                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

#define f first
#define s second
#define pb push_back
#define mp make_pair

const long long mod = 100000000;
const long long High = 1e16;

int main()
{
    fast();
    int m,n;
    cin >> m >> n ;
    if(n==1){
        cout << 0 ;
        return 0;
    }
    vector<int> Entries(n);
    for(ll i=0;i<n;++i)
        cin >> Entries[i];
    sort(Entries.begin(),Entries.end());
    n--;
    vector<int> Diff(n);
    for(ll i=0;i<n;++i)
        Diff[i] = Entries[i+1] - Entries[i];
    sort(Diff.begin(),Diff.end(),greater<int>());
    ll ans = 0;
    for(ll i = m - 1; i<n;++i)
        ans += Diff[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

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

	vector<int> niz(n);

	int cnt = 0, max = 0;
	for (int i = 0; i < n; i++)
		cin >> niz[i];

	bool flag = false;
	for (int i = 0; i < n - 1; i++)
	{
		if (niz[i] >= niz[i + 1])
		{
			cnt++;
			flag = false;
		}
		else flag = true;
		if (cnt > max)
			max = cnt;
		if (flag)
			cnt = 0;
	}

	cout << max;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;

  if (d2 == 1) {
    cout << "1" << '\n';
  } else {
    cout << "0" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;

int main() {
  int n;
  int a[1000100];

  while (1) {
    cin >> n;
    if (n == 0) break;

    REP(i, n) {
      cin >> a[i];
    }

    sort(a, a + n);

    int mind = IINF;
    FOR(i, 1, n) {
      mind = min(mind, a[i] - a[i - 1]);
    }
    cout << mind << endl;
  }

  return 0;
}

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}





void solve() {
        
        ll N, D;
        cin >> N >> D;
        
        D = (D * D);
        
        ll c = 0;
        
        
        for(ll i = 1; i <= N; i++) {
                ll x, y;
                cin >> x >> y;
                
                if(D >= ((x * x) + (y * y))) {
                        c++;
                }
        }
      
        cout << c << endl;
        
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   

    int t = 1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
      x: i32,
      y: i32,
      z: i32,
    }
    println!("{} {} {}", z, x, y)
}


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


int main(){
  int N, flg;
  cin>>N;
  vector<pair<int, int>> A(N);

  rep(i, N) {
    cin>>flg;
    A[i] = make_pair(flg, i);
  }


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

  rep(i, N) cout<<A[i].second+1<<" ";
}


Measured memory_bytes: 1536
### constant

MAX_X = 5

### main

loop do
  h = gets.to_i
  break if h == 0

  cells = MAX_X.times.map{[]}
  h.times do
    line = gets.split.map(&:to_i)
    for i in (0...MAX_X)
      cells[i].unshift(line[i])
    end
  end
  #p cells

  total = 0
  loop do
    changed = false
    for y in (0...h)
      max_len = max_c = max_x = 0
      x = 0
      while x < MAX_X
        if cells[x][y] <= 0
          x += 1
          next
        end
        c = cells[x][y]
        len = 1
        while x + len < MAX_X &&  cells[x + len][y] == c
          len += 1
        end
        if max_len < len
          max_len = len
          max_c = c
          max_x = x
        end
        x += len
      end
      #p [max_len, max_c, max_x]

      if max_len >= 3
        changed = true
        total += max_len * max_c
        for l in (0...max_len)
          cells[max_x + l][y] = 0
        end
      end
    end
    break if ! changed

    for x in (0...MAX_X)
      while ! (y = cells[x].index(0)).nil?
        cells[x].delete_at(y)
        cells[x] << -1
      end
    end
    #p cells
  end

  puts total
end

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

int main(){
    char s[11];
    char t[11];
    char u[11];
    scanf("%s %s",s,t);
    int a,b;
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u)==0){
        printf("%d %d",a-1,b);
    }
    else{
        printf("%d %d",a,b-1);
    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 30;
const double PI = acos(-1);
int main()
{
	ll n, m;
	int q;
	double sum = 0.0;
	ll ans = 1LL;
	cin >> q;
	V a(q);
	rep(i, q)
	{
		cin >> a[i];
	}
	sort(all(a));
	rep(i,q){
		//	clog<<log10(a)<<endl;
		if (a[i] != 0)
		{
			sum += log10(a[i]);
		}
		else
		{
			sum = 0.0;
			cout<<0<<endl;
			return 0;
		}
		ans *= a[i];
		if (sum > 18.00 or ans > 1000000000000000000LL)
		{
			ans = -1LL;
			cout<<-1<<endl;
			return 0;
		}
	}
	//clog<<sum<<endl;
	if (sum > 18.00 or ans > 1000000000000000000LL)
	{
		ans = -1LL;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4112
# -*- coding: utf-8 -*-

import bisect
import copy
import collections
import heapq
import itertools
import math
import numpy as np
from operator import itemgetter
import scipy.misc
import sys

"""
#### 入力例 ####
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
"""


N=int(input())
A = list(map(int, input().split()))

def main():
    A.sort(reverse=True)
    dq = collections.deque(A)
    now = dq.popleft()
    hq = []
    heapq.heapify(hq)
    heapq.heappush(hq, (-now, now))    
    ans = 0
    for n in range(1,N):
        ans += heapq.heappop(hq)[1]
        now = dq.popleft()
        heapq.heappush(hq, (-now, now))
        heapq.heappush(hq, (-now, now))
    print(ans)
    return
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 62012
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    double a,ans=0;
    char b[4];
    while(n--)
    {
        scanf("%lf %s",&a,b);
        if(b[i]=='J')
            ans+=a;
        else
            ans+=(a*380000.0);
    }
    printf("%lf\n",ans);
    return 0;
}


Measured memory_bytes: 384
from collections import deque
N,K=map(int,input().split())
V=list(map(int,input().split()))
res=0
for i in range(min(K,N)+1):
    for L in range(i+1):
        R=i-L
        li=[]
        for j in range(L):
            li.append(V[j])
        for j in range(R):
            li.append(V[N-j-1])
        li.sort()
        s=sum(li)
        for k in range(min(K-i,len(li))):
            if(li[k]<0):
                s-=li[k]
            else:
                break
        res=max(s,res)
print(res)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_4D2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] StringArray = Console.ReadLine().Split(' ');
            long[] NumArray = Array.ConvertAll(StringArray, new Converter<string,
 long>(s => long.Parse(s)));

            Console.WriteLine(NumArray.Min() + " "
                + NumArray.Max() + " "
                + NumArray.Sum());
        }
    }
}

Measured memory_bytes: 10324
#include <iostream>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 18], B[1 << 18], C[1 << 18];

void init() {
	N = 0;
	for (int i = 0; i < (1 << 18); i++) { A[i] = 0; B[i] = 0; C[i] = 0; }
}
int solve() {
	sort(A, A + N); reverse(A, A + N);
	sort(B, B + N); 

	for (int i = 0; i < N; i++) {
		int pos1 = lower_bound(B, B + N, A[i] + 1) - B;
		C[i] = (N - pos1) - i;
	}
	int maxn = 0, ret = (1 << 30);
	for (int i = 0; i < N - 1; i++) {
		maxn = max(maxn, C[i / 2]);
		if (maxn > (i + 1) / 2) { ret = min(ret, i + 1); break; }
	}
	return ret;
}

int main() {
	while (true) {
		init();
		cin >> N; if (N == 0) break;
		for (int i = 0; i < N; i++) scanf("%d", &B[i]);
		for (int i = 0; i < N; i++) scanf("%d", &A[i]);
		int ans = solve();
		if (ans == (1 << 30)) cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll n, k, a[N], b[N];
bool chk(ll mid){
        ll res = 0;
        for (int i = 1; i <= n; i++){
                ll x = mid / b[i];
                if (a[i] > x) res = res + a[i] - x;
        }
        return (res <= k);
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("WALKING.INP", "r")){
                freopen("WALKING.INP", "r", stdin);
                freopen("WALKING.OUT", "w", stdout);
        }
        cin >> n >> k;
        for (int i = 1; i <= n; i++){
                cin >> a[i];
        }
        for (int i = 1; i <= n; i++) {
                cin >> b[i];
        }
        sort(a + 1, a + n + 1, greater<ll>());
        sort(b + 1, b + n + 1);
        ll l = 0, h = 1e18;
        while (l <= h){
                ll mid = (l + h) >> 1;
                if (chk(mid)) h = mid - 1;
                else l = mid + 1;
        }
        cout << l;
}


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

int main(){
  int n;
  cin >> n;
  int d[n];
  int i,j;
  int ans=0;

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

  for(i=0;i<n;++i){
    for(j=i+1;j<n;j++){
        ans += d[i] * d[j];
    }
  }

  cout << ans << endl;

  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string S;
    cin >> S;
    ll cnt = 0;
    REP(i, S.size()) if(S[i] == 'x') cnt++;
    cout << (cnt <= 7 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc. nextInt();
        
        A -= 1;
        B -= 1;
        
        System.out.println(A * B);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,K;
  cin >> H >> W >>K;
  vector<vector <char>> c(H,vector<char> (W));
  for(int i = 0; i < H; i++){
	for(int j = 0; j < W; j++){
		cin >> c.at(i).at(j);
    }
  }
  
  int ans = 0;
  int cnt = 0;
  for(int h = 0; h < (1 << H); h++){
    for(int w = 0; w < (1 << W); w++){
      bitset<6> hline(h);
      bitset<6> wline(w);
      for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
          if(hline.test(i) and wline.test(j) and i < H and j < W){
           // cout << "h:" << hline << " w:" << wline << endl;
            if(c.at(i).at(j) =='#')cnt++;
           // cout << c.at(i).at(j) << endl;
          }
        }
      }
      
      if(cnt == K) ans++;
      cnt = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N;
    cin >> N;
    vector<vector<int>> A(N + 1, vector<int>(3));
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }

    vector<vector<int>> dp (N + 1, vector<int>(3));

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][k] = max(dp[i][k], dp[i-1][j] + A[i][k]);
                }
            }
        }
    }

    cout << *max_element(dp[N].begin(), dp[N].end()) << "\n";

    return 0;
}


Measured memory_bytes: 11264
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vvint mpb(k,vint(k,0));
    vvint mpw(k,vint(k,0));
    REP(i,n){
        ll x,y;
        char c;
        cin >> x >> y >> c;
        int z = 0;
        z += (x/k);
        z += (y/k);
        x %= k;
        y %= k;
        int t;
        if(c=='B'){
            t = 1;
        }else{
            t = -1;
        }
        if(z%2==1){
            t = 0-t;
        }
        if(t==1){
            mpb[x][y]++;
        }else{
            mpw[x][y]++;
        }
    }
    vvint dpb(k+1,vint(k+1,0));
    vvint dpw(k+1,vint(k+1,0));
    REP(i,k){
        REP(j,k-1){
            mpb[i][j+1] += mpb[i][j];
            mpw[i][j+1] += mpw[i][j];
        }
    }
    REP(i,k){
        REP(j,k){
            dpb[i+1][j+1] = dpb[i][j+1] + mpb[i][j]; 
            dpw[i+1][j+1] = dpw[i][j+1] + mpw[i][j]; 
        }
    }
    int ans = 0;
    REP(i,k+1){
        REP(j,k+1){
            {
                int cnt = 0;
                cnt += dpb[k][k];
                cnt -= dpb[k][j];
                cnt -= dpb[i][k];
                cnt += 2*dpb[i][j];
                cnt += dpw[k][j];
                cnt += dpw[i][k];
                cnt -= 2*dpw[i][j];
                ans = max(cnt,ans);
            }
            {
                int cnt = 0;
                cnt += dpw[k][k];
                cnt -= dpw[k][j];
                cnt -= dpw[i][k];
                cnt += 2*dpw[i][j];
                cnt += dpb[k][j];
                cnt += dpb[i][k];
                cnt -= 2*dpb[i][j];
                ans = max(cnt,ans);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19040
#include <iostream>
using namespace std;
int main() {
    char s[3];
    cin >> s;
    int a = 0, b = 0, c = 0;
    for (int i = 0; s[i] != 0; i++ ) {
        switch (s[i]) {
            case 'a':
                a++;
                break;
            case 'b':
                b++;
                break;
            case 'c':
                c++;
                break;
        }
    }
    if (a == 1 && b==1 && c==1) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int T[200010],f[200010],p[200010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=1;i<=n;++i)p[gi()]=i;
	for(int i=n-1;i;--i){
		if(!T[i+1]){if(p[i]>p[i+1])T[i]=1,f[i]=i+1;}
		else{
			if((p[i]<p[i+1])+(p[i+1]<p[f[i+1]])+(p[f[i+1]]<p[i])==2)T[i]=T[i+1],f[i]=f[i+1];
			else T[i]=T[i+1]+1,f[i]=i+1;
		}
	}
	printf("%d\n",T[1]);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
const ll mod=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L; cin >> L;
    vector<ll> A(L);
    rep(i,L) cin >> A[i];
    vector<vector<ll>> dp(L+1,vector<ll>(5,IINF));
    dp[0][0]=0;
    rep(i,L){
        rep(j,5){
            rep2(k,j,5){
                if (k==0||k==4) chmin(dp[i+1][k],dp[i][j]+A[i]);
                if (k==1||k==3) chmin(dp[i+1][k],dp[i][j]+(A[i]!=0?A[i]%2:2));
                if (k==2) chmin(dp[i+1][k],dp[i][j]+(A[i]+1)%2);
            }
        }
    }
    ll ans=IINF;
    rep(i,5) chmin(ans,dp[L][i]);
    cout << ans << endl;
}

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

int main(){
  string s,t,u;
  cin >> s >> t;
  int a,b;
  cin >> a >> b >> u;
  if(u==s){
    cout << a-1<< ' '<< b << endl;
  }else{
    cout << a <<' '<< b-1 << endl;
  }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  string s, t;
  cin >> s >> t;

  int ans = 1e9;
  rep(i,0,sz(s)) if (i+sz(t) <= sz(s)) {
    int d = 0;
    rep(j,0,sz(t)) d += s[i+j] != t[j];
    ckmin(ans, d);
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int w, h;
bool board[110][110];//?????????????????????
bool flag[110][110];
bool used[110][110];
//y??§?¨?????\???°
int dx_kisuu[6] = {1, 1, 1, 0, -1, 0};
int dy_kisuu[6] = {-1, 0, 1, 1, 0, -1};
//y??§?¨??????¶??°
int dx_gusuu[6] = {0, 1, 0, -1, -1, -1};
int dy_gusuu[6] = {-1, 0, 1, 1, 0, -1};

bool hantei(int nowy, int nowx){
	if(0 <= nowy && nowy <= h + 1 && 0 <= nowx && nowx <= w + 1){
		return true;
	}else{
		return false;
	}
}

int main(void){
	cin >> w >> h;
	//??????????????????????????¨??????0??§??????
	for (int i = 1; i <= h; ++i){
		for (int j = 1; j <= w; ++j){
			cin >> board[i][j];
		}
	}
	
	queue<pair<int, int> > q;
	q.push(make_pair(0, 0));
	while(!q.empty()){
		pair<int, int> now;//first y second x
		now = q.front(); q.pop();
		if(now.first % 2 == 0){
			rep(i, 6){
				int nowy = now.first  + dy_gusuu[i];
				int nowx = now.second + dx_gusuu[i];
				if(hantei(nowy, nowx)){
					if(!board[nowy][nowx] && !used[nowy][nowx]){
						q.push(make_pair(nowy, nowx));
						flag[nowy][nowx] = true;
						used[nowy][nowx] = true;
					}
				}
			}
		}else{
			rep(i, 6){
				int nowy = now.first  + dy_kisuu[i];
				int nowx = now.second + dx_kisuu[i];
				if(hantei(nowy, nowx)){
					if(!board[nowy][nowx] && !used[nowy][nowx]){
						q.push(make_pair(nowy, nowx));
						flag[nowy][nowx] = true;
						used[nowy][nowx] = true;
					}
				}
			}
		}
	}

	long long sum = 0;
	for (int i = 0; i <= h + 1; ++i){
		for (int j = 0; j <= w + 1; ++j){
			if(flag[i][j]){//flag=true??????????????¨??????board=true???????????¨??\?????????????????????????????§????????????
				int tmp = 0;
				if(i % 2 == 0){
					for (int k = 0; k < 6; ++k){
						int nowy = i + dy_gusuu[k], nowx = j + dx_gusuu[k];
						if(board[nowy][nowx] && hantei(nowy, nowx)) sum++;
					}
				}else{
					for (int k = 0; k < 6; ++k){
						int nowy = i + dy_kisuu[k], nowx = j + dx_kisuu[k];
						if(board[nowy][nowx] && hantei(nowy, nowx)) sum++;
					}
				}
			}
		}
	}
	printf("%lld\n", sum);
	return 0;
}

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


long long calc(int i, int j, vector<vector<long long> > &l, const string& x, const string& y){
  if(i == 0 || j == 0){
    l[i][j] = 0;
    return l[i][j];
  }
  if(l[i][j] >= 0){
    return l[i][j];
  }else{
    if(x[i-1] == y[j-1]){
      l[i][j] = 1 + calc(i-1, j-1, l, x, y);
    }else{
      l[i][j] = max(calc(i-1, j, l, x, y), calc(i, j-1, l, x, y));
    }
    return l[i][j];
  }
}
int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string x,y;
    cin >> x >> y;
    vector<vector<long long> > l(x.length()+1, vector<long long>(y.length()+1, -1));
    cout << calc(x.length(), y.length(), l, x, y) << endl;
  }
}

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

int main()
{
    int x,y,z,a,b,c;
    cin >> x >> y >> z;
    a=x;
    b=y;
    c=z;
    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 256
arr = []
b = []
cmp_arr = [[False] * 3 for _ in range(3)]

for i in range(3):
  arr.append(list(map(int,input().split())))

N = int(input())
for i in range(N):
  b.append(int(input()))

for i in range(3):
  for j in range(3):
    for k in range(N):
      if arr[i][j] == b[k]:
        cmp_arr[i][j] = True

for i in range(3):
  if cmp_arr[i][0] and cmp_arr[i][1] and cmp_arr[i][2]:
    print("Yes");exit()
  if cmp_arr[0][i] and cmp_arr[1][i] and cmp_arr[2][i]:
    print("Yes");exit()

if cmp_arr[0][0] and cmp_arr[1][1] and cmp_arr[2][2]:
  print("Yes");exit()
if cmp_arr[0][2] and cmp_arr[1][1] and cmp_arr[2][0]:
  print("Yes");exit()
print("No")

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}

int main(){
	ll n,m;
	cin>>n>>m;
	ll arr[n];
	for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	vector<pair<int,int>> v;
	ll x,y;
	for(int i = 0; i < m; i++){
		cin>>x>>y;
		v.push_back({y,x});
	}
	sort(v.rbegin(),v.rend());
	ll ind = 0;
	for(int i = 0; i < n; i++){
		if(arr[i] >= v[ind].first) break;
		if(v[ind].second){
			arr[i] = v[ind].first;
			v[ind].second--;
		}
		if(!v[ind].second) ind++;
	}
	ll sum = 0;
	for(int i = 0; i < n; i++) sum += arr[i];
	cout<<sum<<"\n";
}









Measured memory_bytes: 2168
#include<stdio.h>
int main(void)
{
  char s[11];
  int count = 0;
  int count_save = 0;
  int count_max = 0;
  int i;
  
  scanf("%s",s);
  
  for(i = 0;i < 11;i++){
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
      count++;
      count_save = count;
    }
  	else count = 0;
    
    if(count_max < count_save)
      count_max = count_save;
  }
  
  printf("%d\n",count_max);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(void){
    int n;
    int a[200000+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    long long int ans=0;
    for(int i=1; i<n; i++){
        if(a[i-1]>a[i]){
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2512
program b174

implicit none
integer(16) :: n, d, i, a
integer(16), allocatable :: x(:), y(:)

a = 0

read *, n, d

allocate(x(1:n))
allocate(y(1:n))

do i = 1, n
 read *, x(i), y(i)

if (x(i) ** 2 + y(i) ** 2 <= d ** 2) then
 a = a + 1
end if

!print *, x(i) ** 2 + y(i) ** 2

end do

print *, a

end program b174

Measured memory_bytes: 9124
def Cukky(a,b):

    if a%2 == 0:
        a = a/2
    else:
        a = (a-1)/2

    b += a

    return a,b



A,B,K = map(int,input().rstrip().split(' '))

for i in range(K):
    if i%2 != 0:
        B,A = Cukky(B,A)
    else:
        A,B = Cukky(A,B)

print("{} {}".format(int(A),int(B)))

Measured memory_bytes: 3060
def dfs(i, formula):
    if i + 1 == num_digits:
        return sum(list(map(int, formula.split("+"))))

    return dfs(i + 1, formula + "+" + s[i + 1]) + dfs(i + 1, formula + s[i + 1])


s = input()
num_digits = len(s)

print(dfs(0, s[0]))


Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

void solve() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n,0));
    Rep(i, 1, n){
        ll u, k; cin >> u >> k;
        rep(i, 0, k){
            ll v; cin >> v;
            a[u-1][v-1] = 1;
        }
    }
    rep(i, 0, n){
        rep(j, 0, n){
            if(j) cout << " ";
            cout << a[i][j];
        }
        cout << "\n";
    }

    return;
}

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

    solve();
    return 0;
}



Measured memory_bytes: 3160
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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;

ll H, W, K;
ll fld[20][1010];
ll S[20][1010];
std::vector<ll> hs;
ll ans = 1ll<<60;

ll sumRect( ll bi, ll bj, ll ei, ll ej )
{
  if( !(ei-bi >= 1 && ej-bj >= 1) )
    return 0;

  return S[ei][ej]-S[ei][bj]-S[bi][ej]+S[bi][bj];
}

bool C( ll prvj, ll nj )
{
  bool fl = true;

  rep( k, hs.size()-1 )
    fl &= sumRect( hs[k], prvj, hs[k+1], nj ) <= K;//, printf( "(%lld,%lld,%lld,%lld) %lld\n", hs[k], prvj, hs[k+1], nj, sumRect( hs[k], prvj, hs[k+1], nj ) );

  return fl;
}

int main()
{
  scanf( "%lld%lld%lld", &H, &W, &K );

  rep( i, H )
  {
    std::string S;
    std::cin >> S;

    rep( j, W )
      fld[i][j] = S[j]-'0';
  }

  rep( i, H )
    rep( j, W )
      S[i+1][j+1] = fld[i][j]+S[i+1][j]+S[i][j+1]-S[i][j];

  rep( bit, 1<<(H-1) )
  {
    hs.clear();

    hs.emplace_back( 0 );

    ll cntH = 0;

    rep( k, H-1 ) if( bit>>k&1 )
      hs.emplace_back( k+1 ), ++cntH;//, printf( "[%lld]\n", k+1 );

    hs.emplace_back( H );

    ll prvj = 0, nj = 0;
    ll cntW = 0;

    while( nj < W-1 )
    {
      ++nj;

      if( !C( prvj, nj ) )
        goto end;

      while( nj <= W && C( prvj, nj ) )
        ++nj;

      --nj;

      //printf( "j: %lld\n", nj );

      prvj = nj;

      if( nj != W )
        ++cntW;
    }

    if( !C( prvj, W ) )    
      continue;

    if( cntW < 0 )
      continue;

    chmin( ans, cntH+cntW );

end:;
    //printf( "%d+%d\n", cntH, cntW );
  }  

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

  return 0;
}

Measured memory_bytes: 384
s = gets.rstrip

head = s.slice(0, 2).to_i
tail = s.slice(2, 4).to_i

if 0 < head and head < 13 and 0 < tail and tail < 13
  puts 'AMBIGUOUS'
elsif 0 < head and head < 13
  puts 'MMYY'
elsif 0 < tail and tail < 13
  puts 'YYMM'
else
  puts 'NA'
end


Measured memory_bytes: 1788
N, M, Q = [int(_) for _ in input().split()]
LR = [[int(_) for _ in input().split()] for _ in range(M)]
PQ = [[int(_) for _ in input().split()] for _ in range(Q)]

cumsum = [[0] * (N+2) for _ in range(N+1)]
for lr in LR:
    cumsum[lr[0]][lr[0]] += 1
    if lr[1] < N:
        cumsum[lr[0]][lr[1]+1] -= 1
for i in range(N+1):
    for j in range(i, N):
        cumsum[i][j+1] += cumsum[i][j]
for pq in PQ:
    print(sum([cumsum[i][i]-cumsum[i][pq[1]+1]
               for i in range(pq[0], pq[1]+1)]))


Measured memory_bytes: 119640
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int N;
long long wv[110][2];
long long dp[110][100010];

int main() {
    int N, W;
    cin >> N >> W;
    rep(i, 0, N) {
        rep(r, 0, 2) { cin >> wv[i][r]; }
    }
    rep(i, 0, N+1) {
        rep(r, 0, 100010) { dp[i][r] = INF; }
    }

    dp[0][0]=0;
    rep(i, 0, N) {
        rep(sumV, 0, 100010) {
            if(sumV - wv[i][1] >= 0) {
                chmin(dp[i + 1][sumV], dp[i][sumV - wv[i][1]] + wv[i][0]);
            }
            chmin(dp[i + 1][sumV], dp[i][sumV]);
        }
    }
    long long res;
    rep(sumV, 0, 100010) {
        if(dp[N][sumV] <= W) {
            res = sumV;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 80128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(when {
        b <= a -> "delicious"
        b - a <= x -> "safe"
        else -> "dangerous"
    })
}

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

int main() {
    int N;
    int a[100000][3];
    cin >> N;
    for(int i=0; i<N; ++i) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    int dp[100000][3];
    for(int i=1; i<N; ++i) {
        for(int j=0; j<3; ++j) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i=1; i<N; ++i) {
        for(int j=0; j<3; ++j) {
            for(int k=0; k<3; ++k) {
                if(k==j) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
            }
        }
    }
    int ans = max(dp[N-1][0], dp[N-1][1]);
    ans = max(ans, dp[N-1][2]);
    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int x = in.nextInt();
        final int y = in.nextInt();
        final int lo = x * 2;
        final int hi = x * 4;
        if (y % 2 == 0 && lo <= y && y <= hi) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35816
// template version 1.7

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1e9+7
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int n;cin>>n;
  int t[5];
  int m=INF;
  rep(i,5){
    cin>>t[i];
    chmin(m,t[i]);
  }
  dump(m);
  int res=(n+m-1)/m;
  res += 4;
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main() {
  string s, t;
  cin >> s;
  cin >> t;

  bool res = true;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) {
      res = false;
      break;
    }
  }
  
  if (res) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N, cnt, ans=0;
  cin >>N;
  string S;
  cin >> S;
  int con1[30];
  int con2[30];
  for(int i=1; i<N-1; i++){
    cnt = 0;
    int con1[30]={0};
    int con2[30] ={0};
    for (int j = 0; j < i; ++j){
      con1[S[j] - 'a'] ++;
	  
    }
    for(int j=i; j<N; j++){
      con2[S[j] - 'a']++;
     
    }
    rep(j, 30){
    
      
      if(con1[j]&& con2[j]){
      cnt ++;
      }
  }
    
    ans = max(cnt, ans);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, cur;

int gcd(int x, int y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

int main()
{
	cin >> n;
	cin >> cur;
	for (int i = 2; i <= n; i++)
	{
		int x;
		cin >> x;
		cur = gcd(cur, x);
	}
	cout << cur << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sumA = 0, sumB = 0;
		int cnt = 0;
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			cnt++;
		}
		int tmp;
		for(int i = 0; i < n; i++) {
			for(int k = i + 1; k < n; k++) {
				if(a[i] < a[k]) {
					tmp = a[i];
					a[i] = a[k];
					a[k] = tmp;
				}
			}
		}
		int i = 0;
		while(i < n - 1) {
			sumA += a[i];
			sumB += a[i + 1];
			i += 2;
		}
		if(cnt % 2 != 0) {
			sumA += a[n - 1];
		}
		System.out.println(sumA - sumB);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=1;
	for (int i=1;i<n;i++){
		if (s[i]!=s[i-1])  ans++;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 512
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, K, Q = map(int, input().split())
    vals = np.array([K for _ in range(N)])
    for _ in range(Q):
        A = int(input())
        vals -= 1
        vals[A-1] += 1
    for v in vals:
        if v > 0:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


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

int main(){
    int N;
    int odd = 0;
    cin >> N;
    for(int n=1;n<=N;n++){
        if(n % 2 == 1) odd++;
    }
    cout << (double)odd / (double)N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s == "abc"){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main()
{
    int n,l;
    cin>>n>>l;

    vector <string> g(n);
    for (int i=0;i<n;i++) cin>>g[i];

    sort(g.begin(), g.end());
    for (int i=0;i<g.size();i++) cout<<g[i];
    return 0;
}


Measured memory_bytes: 256