akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	int a, b, i;
	scanf("%d %d", &a, &b);
	int n = b - a;
	//printf("%d\n", n);
	int high = 0;
	for (i = 1; i < n; i++)
	{
		high += i;
	}
	//printf("%d\n", high);
	printf("%d\n", high - a);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int a,b;

  scanf("%d%d",&a,&b);

  if(a >= 13) printf("%d",b);
  else if(a >= 6 && a <= 12) printf("%d",b/2);
  else if(a <= 5) printf("0");

  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    vector<ll> p(n);
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>> > que;
    priority_queue<pair<ll,ll>> que2;
    bool ok=false;
    ll tmp=0;
    rep(i,n) cin>>p[i];
    rep(i,k-1){
        que.push({p[i],i});
        que2.push({p[i],i});
        if(i>0&&p[i-1]<=p[i])tmp++;
    }
    ll res=0;
    for(int i=k-1;i<n;i++){
        while(true){
            if(que.top().second+k<i)que.pop();
            else break;
        }
        while(true){
            if(que2.top().second+k<i)que2.pop();
            else break;
        }
        bool jud=false;
        if(p[i-1]<=p[i])tmp++;
        if(p[i-k]<=p[i-k+1])tmp--;
        if(tmp==k-1){
            if(ok)jud=true;
            else ok=true;
        }
        que.push({p[i],i});que2.push({p[i],i});
        ll x=que.top().first,y=que2.top().first;
        if(jud)continue;
        if(x!=p[i-k]||y!=p[i]) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 11312
#include <stdio.h>

int main ()
{
    int n;
    int ans = 10000000;
    scanf("%d", &n);
    int x[n];
    int i;
    for (i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        x[i] = a;
    }
    int max = 0, min = 100;
    for (int i = 0; i < n; i++)
    {
        if (max < x[i])
        {
            max = x[i];
        }
        if (min > x[i])
        {
            min = x[i];
        }
    }
    for (int i = min; i <= max; i++)
    {
        int sum = 0;
        for (int j = 0; j < n; j++)
        {
            sum += (i - x[j]) * (i - x[j]);
        }
        if (sum < ans)
        {
            ans = sum;
        }
        
    }
    printf("%d", ans);
    return 0;
}

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

using namespace std;

int n,m,k;

int main() {
    cin>>n>>m>>k;
    for (int i=0;i<=n;i++)
        for (int j=0;j<=m;j++)
            if (i*m + j*n - 2*i*j == k) {
                cout<<"Yes";
                return 0;
            }
    cout<<"No";
}


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

int main() {
    int d,g;
    cin >> d >> g;
    vector<int>p(d);
    vector<int>c(d);
    rep(i,d) cin >> p[i] >> c[i];
    ll res = 1001001001;
    for(int bit = 0; bit < (1<<d);bit++) {
        ll sum = 0;
        ll cnt = 0;
        for(int i = 0;i<d;i++) {
            if(bit & 1<<i) {
                sum += p[i]*(i+1)*100+c[i];
                cnt += p[i];
            }
        }
        if(sum>=g) {
            res = min(res,cnt);
        } else {
            for(int j = d-1;j>=0;j--) {
                if(bit & (1<<j)) continue;
                for(int k = 0;k<p[j];k++) {
                    if(sum>=g) break;
                    sum += (j+1)*100;
                    cnt++;
                }
            }
        }
        res = min(res,cnt);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string str;
ll dp[100005];
int rui[100005];
int n;
vector<int>adj;
vector<int>pos[3];
int las = -1;
ll rec(int beg){
	if(beg == n) return 1;
	if(dp[beg] >= 0) return dp[beg];
	
	char ch = str[beg];
	ll add = rec(beg+1);
	if(beg+1 != n && rui[n-1] == rui[beg] && las >= beg) add = (add+1)%mod;
	if(las == beg){
		int zan = n-1-beg;
		if(zan > 0 && zan%2 == 0) zan -= 2;
		add = (add+1LL*(zan/2))%mod;
	}
	int f = POSL(adj,beg);
	if(f != adj.size()){
		int rg = adj[f]+1;
		int need = (str[beg] == 'a'?1:2);
		int target = (rui[beg]+need)%3;
		int h = POSL(pos[target],rg);
		if(h != pos[target].size()){
			int en = pos[target][h];
			add = (add+rec(en+1))%mod;
			if(en+1 != n && rui[n-1] == rui[en]) add = (add+1)%mod;
			if(las <= en){
				int zan = n-1-en;
				if(zan > 0 && zan%2 == 0) zan -= 2;
				add = (add+1LL*(zan/2))%mod;
			}
		}
	}
	return dp[beg] = add;
}
int main(){
	cin>>str;
	n = str.size();
	for(int i=1;i<n;i++){
		if(str[i-1] == str[i]){
			adj.pb(i-1);
			las = i-1;
		}
	}
	for(int i=0;i<n;i++){
		rui[i] = (str[i]=='a'?1:2);
		if(i) rui[i] = (rui[i]+rui[i-1])%3;
		pos[rui[i]].pb(i);
	}
	memset(dp,-1,sizeof(dp));
	ll ans = rec(0);
	ans = (ans%mod+mod)%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 9336
Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim output As Long = 0
    For i As Long = 1 To n
      If i.ToString().Length() Mod 2 = 1 Then output += 1
    Next
    Console.WriteLine(output.ToString())
  End Sub
End Class

Measured memory_bytes: 15188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(m);
  for (int i=0;i<m;i++){
    cin >> a[i];
  }
  int l=0,h=0;
  for (int i=0;i<m;i++){
    if(a[i]<x){
      l++;
    }
    else{
      h++;
    }
  }
  cout << min(l,h) << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc123B
{
    class Program
    {
        static void Main(string[] args)
        {
            double max = 0;
            double[] a = new double[5];
            for (int i = 0; i<=4;i++)
            {
               a[i] = Convert.ToInt16(Console.ReadLine());
               if ((a[i]-1)%10<10-max )
                {
                    max = 10 - a[i] % 10;
                }
                a[i] = Math.Ceiling(a[i] / 10) * 10;
            }
            if (max == 10)
            {
                max = 0;
            }
            Console.WriteLine(a[0] +a[1]+a[2]+a[3]+a[4]-max);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void agc_a_divide_a_cuboid(void) {
	long long a, b, c;
	cin >> a >> b >> c;
	// 底面の決め方で3通り
	long long min_diff = a * b;

	long long s = 0;

	if ((a % 2 == 0) || (b % 2 == 0) || (c % 2 == 0)) {
		cout << "0" << endl;
		return;
	}

	s = b * c;
	if (s< min_diff) min_diff = s;

	s = a * c;
	if (s < min_diff) min_diff = s;

	cout << min_diff << endl;
}

int main()
{
    agc_a_divide_a_cuboid();
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

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

    int ans = 0;
    for (int i = A; i <= B; i++){
        if(i / 10000 == i % 10){
            if ((i / 1000) % 10 == (i % 100) / 10){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq

n, k = map(int, input().split())
a = list(map(int, input().split()))
a_sum = sum(a)

b = []
ssum = 0
for item in a:
    kosu = (k * item // a_sum) + 1
    dv = item / kosu
    b.append((-dv, kosu, item))
    ssum += (kosu - 1)

left = k - ssum
heapq.heapify(b)

while left > 0:
    left -= 1
    _, kosu, item = heapq.heappop(b)
    if item / (kosu + 1) <= 1:
        print('1')
        exit()
    else:
        heapq.heappush(b, (-(item / (kosu + 1)), kosu+1, item))

_, kosu, item = heapq.heappop(b)
print((item + kosu - 1) // kosu)


Measured memory_bytes: 43556
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int num;
map<string,int> mp;

int get(const string &s) {
  if (mp.count(s) == 0) mp[s] = num++;
  return mp[s];
}

int t[100000];
vector<int> v[100000];
vector<pii> g[100000];

void add(int i, int j, int d) {
  g[i].push_back(pii(j,d));
  g[j].push_back(pii(i,d));
}

struct P {
  int now, dist, count;
  P(int now, int dist, int count) :
    now(now),dist(dist),count(count) {}
  bool operator<(const P&b) const {
    return dist != b.dist ? dist > b.dist : count > b.count;
  }
};

pii dist[100000];
bool seen[100000];

int main() {
  int n,T;
  cin >> n >> T;
  string A,B;
  cin >> A >> B;
  int a = get(A);
  int b = get(B);
  int cnt = 0;
  map<pii,int> idmap;
  REP(i,n) {
    int k; cin >> k;
    REP(j,k) {
      string s;
      cin >> s;
      t[cnt] = get(s);
      v[get(s)].push_back(cnt);
      idmap[pii(i,j)] = cnt++;
    }
    REP(j,k-1) {
      int d; cin >> d;
      add(idmap[pii(i,j)], idmap[pii(i,j+1)], d);
    }
  }
  priority_queue<P> Q;
  REP(i,cnt) dist[i] = pii(INT_MAX, INT_MAX);
  FOR(it, v[a]) {
    Q.push(P(*it, 0, 0));
    dist[*it] = pii(0,0);
  }
  while(!Q.empty()) {
    P p = Q.top(); Q.pop();
    // cout << p.now << " " << p.dist  << " " << p.count << endl;
    pii pi = pii(p.dist, p.count);
    if (dist[p.now] < pi) continue;
    if (!seen[t[p.now]]) {
      seen[t[p.now]] = 1;
      FOR(it, v[t[p.now]]) {
        pii nxt = pii(p.dist+T,p.count+1);
        if (dist[*it] > nxt) {
          dist[*it] = nxt;
          Q.push(P(*it,nxt.first,nxt.second));
        }
      }
    }
    FOR(it, g[p.now]) {
      pii nxt = pii(p.dist+it->second, p.count);
      if (dist[it->first] > nxt) {
        dist[it->first] = nxt;
        Q.push(P(it->first, nxt.first, nxt.second));
      }
    }
  }
  pii ans(INT_MAX,INT_MAX);
  FOR(it, v[b]) {
    ans = min(ans, dist[*it]);
  }
  if (ans.first == INT_MAX) cout << -1 << endl;
  else cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 25900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>]
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////

int main() {

	int R;
	cin >> R;

	float ans = R * 2 * 3.14;

	cout << ans << endl;

}


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

int main()
{
ll x;
cin>>x;
if(x==0)
cout<<1<<endl;
else
{
    cout<<0<<endl;
}

return 0;

}

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

namespace AtCoder.ABC124.C
{
    class Program
    {
        static void Rep(int n, Action<int> action) { for (var i = 0; i < n; ++i) { action(i); } }
        static void Rep(int n, int s, Action<int> action) { for (var i = s; i < n; ++i) { action(i); } }


        public static void Main()
        {
            // Solve("000"); // 1  ng:2
            // Solve("10010010"); // 3 ng:5 
            // Solve("0"); // 0 ng:1

            // return;
            var S = Console.ReadLine();
            Solve(S);
        }

        static void Solve(string S)
        {
            var len = S.Length;
            // var p1 = "";
            // Rep(len / 2, i =>
            // {
            //     p1 += "01";
            // });
            // if (len % 2 == 1)
            // {
            //     p1 += "0";
            // }
            var count = 0;
            Rep(len, i =>
            {
                if (S[(int)i] != (i % 2 == 0 ? '0' : '1'))
                {
                    ++count;
                }
            });
            if (count > len / 2)
            {
                Console.WriteLine(len - count);
            }
            else
            {
                Console.WriteLine(count);
            }
        }
        static int popcount3(int x)
        {
            x = (x & 0x55555555) + (x >> 1 & 0x55555555);
            x = (x & 0x33333333) + (x >> 2 & 0x33333333);
            x = (x & 0x0F0F0F0F) + (x >> 4 & 0x0F0F0F0F);
            x = (x & 0x00FF00FF) + (x >> 8 & 0x00FF00FF);
            x = (x & 0x0000FFFF) + (x >> 16 & 0x0000FFFF);
            return x;
        }
    }
}



Measured memory_bytes: 11232
N,M = gets.split.map(&:to_i)
$es = {}
M.times{
  a,b = gets.split.map(&:to_i)
  $es[a] ||= {}; $es[b] ||= {}
  $es[a][b] = $es[b][a] = 1
}

$visited = {}

def makepath(next_to)
  ps = []
  while next_to
    ps << next_to
    $visited[next_to] = 1
    next_to = $es[next_to].keys.find{ |n| !$visited[n] }
  end
  ps
end

ps1 = makepath(1)
ps2 = makepath(1)[1..-1]
pathway = ps1.reverse + ps2

#p ps1, ps2
puts pathway.size, pathway.join(" ")


Measured memory_bytes: 47380
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
int main(){
	int n,m;
	int a,b,c,t,r;
	while(cin >> m >> n && n){
		int time[n][n],cost[n][n];
		rep(i,n)rep(j,n)time[i][j]=cost[i][j]=(1<<21);
		rep(i,n)time[i][i]=cost[i][i]=0;
		rep(i,m){
			cin >> a >> b >> c >> t;
			a--;b--;
			cost[a][b]=cost[b][a]=c;
			time[a][b]=time[b][a]=t;
		}
		rep(k,n)rep(i,n)rep(j,n){
			cost[i][j]=cost[j][i]=min(cost[i][j],cost[i][k]+cost[k][j]);
			time[i][j]=time[j][i]=min(time[i][j],time[i][k]+time[k][j]);
		}
		cin >> m;
		rep(i,m){
			cin >> a >> b >> r;
			a--;b--;
			printf("%d\n",r?time[a][b]:cost[a][b]);
		}
	}
}

Measured memory_bytes: 944
package main

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

func main() {
	scanInit()

	x := nextInt()
	if x == 1 {
		fmt.Println(0) //! DBG
	} else {

		fmt.Println(1) //! DBG
	}

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

const char* r = "hijklmnopuy";

int main()
{
    char s[64];

    while (scanf("%s", s), *s != '#'){
        bool now_right;
        int cnt = 0;
        int len = strlen(s);

        now_right = binary_search(r, r + 11, s[0]);
        for (int i = 1; i < len; i++){
            if (binary_search(r, r + 11, s[i]) != now_right){
                cnt++;
                now_right = !now_right;
            }
        }
        printf("%d\n", cnt);
    }

    return 0;
}

Measured memory_bytes: 1136
#include <iostream>
using namespace std;
#define MAX 1000000

int main()
{
    int prime[MAX-1], S[MAX-1];
    for (int i = 0; i < MAX; i++)
    {
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for (int i = 2; i < MAX; i++)
    {
        if (prime[i] != 0)
        {
            for (int j = 2 * i; j < MAX; j += i)
            {
                prime[j] = 0;
            } } }
        
        
    for (int i = 1; i < MAX; i++)
    {
        S[i] = prime[i] + S[i - 1];
    }
    S[0] = prime[0];
    int N;
    while (cin >> N)
    {
        cout << S[N] << endl;
    }
    return 0;
}



Measured memory_bytes: 10880
#include <iostream>

using namespace std;

int main() {
	int n,a[100];
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for(int i = 0;i < n-1;i++) cout << a[i] << " ";
	cout << a[n-1] << endl;
	for(int i = 1;i < n;i++) {
		int v = a[i];
		int j = i - 1;
		while(j >= 0 && a[j] > v) {
			a[j+1]=a[j];j--;
		}
		a[j+1]=v;
		for(int i = 0;i < n-1;i++) cout << a[i] << " ";
		cout << a[n-1] << endl;
	}
}



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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N; cin >> N;
    V<ll> A = V<ll>(N+1);
    V<int> B = V<int>(N+1);
    REP(i,1,N+1) cin >> A[i] >> B[i];

    ll ans = 0;
    rrep(i,N) {
        A[i] += ans;
        int k;
        if(B[i]==1 || A[i]==0 || A[i]%B[i]==0) k = 0;
        else k = B[i] - A[i]%B[i];
        A[i] += k;
        ans += k;
        // cout << ans << " ";
    }
    // cout << endl;
    cout << ans << endl;
    // REP(i,1,N+1) cout << A[i] << " ";
    // cout << endl;
    return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;

	LL ans = 0;
	for (LL i = 1; i <= N; ++i)
	{
		LL cnt = 0, i_ = i;
		while (i > 0)
		{
			i /= 10;
			++cnt;
		}
		i = i_;
		if (cnt % 2 == 1) ++ans;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))

using namespace std;


int main(){
    int N;
    int *h,*t;
    cin >> N;
    h = new int[N];
    t = new int[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
        t[i] = 0;
    }
    t[0]=0;
    t[1]=abs(h[0]-h[1]);
    for(int i=2;i<N;i++){
        int a = abs(h[i]-h[i-2])+t[i-2];
        int b = abs(h[i]-h[i-1])+t[i-1];
        t[i]=min(a,b);
    }
    cout<<t[N-1];
    
    delete[] t;
    delete[] h;
    return 0;
}


Measured memory_bytes: 1024
X=int(input())
if 400<=X<=599:
  print('8')
elif 600<=X<=799:
  print('7')
elif 800<=X<=999:
  print('6')
elif 1000<=X<=1199:
  print('5')
elif 1200<=X<=1399:
  print('4')
elif 1400<=X<=1599:
  print('3')
elif 1600<=X<=1799:
  print('2')
elif 1800<=X<=1999:
  print('1')

Measured memory_bytes: 9212
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    rep(i,n){
        string ujimatu; cin>>ujimatu;
        map<string,int>mp;
        ll ans=0;
        for(int i=0; i<ujimatu.size()-1;i++){
            string a,b;
            for(int j=0; j<=i;j++)
                a+=ujimatu[j];
            for(int j=i+1; j<ujimatu.size();j++)
                b.push_back(ujimatu[j]);
            //cout<<a<<" "<<b<<endl;
            vector<string>gotiusa;
            gotiusa.push_back(a);
            gotiusa.push_back(b);
            reverse(all(a)); reverse(all(b));
            gotiusa.push_back(a); gotiusa.push_back(b);
            for(int i=0; i<gotiusa.size();i++){
                for(int j=0; j<gotiusa.size();j++){
                    if(i==j || i%2==j%2)continue;
                    string rize=gotiusa[i];
                    string syaro=gotiusa[j];
                    //cout<<rize<<" "<<syaro <<endl;
                    if(mp[rize+syaro]==0){
                        ans++;
                        mp[rize+syaro]++;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3288
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T> void max_self(T& a, T b) {
    a = max(a, b);
}

// dp[n][m]

bool first_row_or_column(pair<int,int> p) {
    return p.first == 0 || p.second == 0;
}

const int INF = 1e9 + 5;

int main() {
    string a, b;
    cin >> a >> b;
    vector<vector<pair<int,pair<int,int>>>> dp(a.length() + 1,
        vector<pair<int,pair<int,int>>>(b.length() + 1, {-INF,{0,0}}));
    dp[0][0] = {0, {0,0}};
    // dp[i][j] - the max total length so far
    for(int i = 0; i < (int) a.length(); ++i) {
        for(int j = 0; j < (int) b.length(); ++j) {
            if(a[i] == b[j]) {
                max_self(dp[i+1][j+1], make_pair(dp[i][j].first + 1, make_pair(i,j)));
            }
            max_self(dp[i+1][j], make_pair(dp[i][j].first, make_pair(i,j)));
            max_self(dp[i][j+1], make_pair(dp[i][j].first, make_pair(i,j)));
        }
    }
    pair<int,pair<int,int>> answer = {0,{0,0}};
    for(int i = 0; i <= (int) a.length(); ++i) {
        for(int j = 0; j <= (int) b.length(); ++j) {
            max_self(answer, make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    string s;
    pair<int,int> cur = answer.second;
    while(!first_row_or_column(cur)) {
        int i = cur.first;
        int j = cur.second;
        pair<int,int> previous = dp[i][j].second; // a cell from which we came to (i,j)
        
        if(previous == make_pair(i - 1, j - 1)) {
            assert(a[i-1] == b[j-1]);
            s += a[i-1];
        }
        cur = previous;
    }
    //~ debug() << answer;
    reverse(s.begin(), s.end());
    cout << s << endl;
}


Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;

const int mod = 1e9+7;
string s;
int mult;
int memo[2][101][10010] = {0};

int solve(int pos, int sumMod, bool allEqualSoFar) {
    if(pos == (int)s.size()) {
        if(sumMod == 0) return 1;
        return 0;
    }
    if(memo[allEqualSoFar][sumMod][pos] != -1) return memo[allEqualSoFar][sumMod][pos];
    int res = 0;
    if(allEqualSoFar) {
        for(int digit = 0; digit <= s[pos]-'0'; ++digit) {
            bool equal = (digit == s[pos]-'0');
            res += solve(pos+1, (sumMod+digit)%mult, allEqualSoFar&equal);
            res %= mod;
        }
    } else {
        for(int digit = 0; digit <= 9; ++digit) {
            res += solve(pos+1, (sumMod+digit)%mult, allEqualSoFar);
            res %= mod;   
        }
    }
    return memo[allEqualSoFar][sumMod][pos] = res;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> mult;
    for(int i = 0; i < mult; ++i) {
        for(int j = 0; j < (int)s.size(); ++j) {
            memo[0][i][j] = -1;
            memo[1][i][j] = -1;
        }
    }
    //cout << solve(0,0,1) << '\n';
    int res = 0;
    for(int digit = 0; digit <= s[0]-'0'; ++digit) {
        bool equal = (digit == s[0]-'0');
        res += solve(1, digit%mult, equal);
        res %= mod;
    }
    cout << (res-1+mod)%mod << '\n';
    return 0;
}


























Measured memory_bytes: 8960
x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]
    

    return (s, )


def solve(s):

    result = None
    if s == 'RRS' or s == 'SRR':
        result = 2
    elif s == 'RRR':
        result = 3
    elif s == 'SSS':
        result = 0
    else:
        result = 1
        
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;

    int a[n], b[m];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + m);

    string ans = "War";
    for (int i = x + 1; i <= y; i++) {
        if (a[n - 1] < i && b[0] >= i) {
            ans = "No War";
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def bfs(start):
    que=deque([start])
    D=[-1]*(h*w)
    D[start]=0
    while que:
        x=que.popleft()
        for next_x in (x+1,x-1,x+w,x-w):
            if maze[next_x]=='.' and D[next_x]==-1:
                D[next_x]=D[x]+1
                que.append(next_x)
    return max(D)

def main():
    global h,w,maze
    h,w=map(int,input().split())
    h+=2
    w+=2
    maze="#"*w
    for _ in range(h-2):
        maze+="#"+input()+"#"
    maze+="#"*w 
    print(max(bfs(i) for i,c in enumerate(maze) if c=='.'))


if __name__=='__main__':
    main()




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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  vector<int> t,n;
  vector<pair<int,int> > ts;
  int p,q;
  REP(i,4){
    cin >> p >>q;
    ts.pb(make_pair(p, q));
  }
  REP(j,4){
    if(ts[j].first == 1){
      cout << (6000 * ts[j].second) << endl;
    }else{
      cout << (((6 - ts[j].first) * 1000) * ts[j].second) << endl;
  }
    
}
return 0;
}



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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int ans = 0;
  int sum = 0;
  for(int j=0; j<N; j++){
    sum = sum + vec.at(j);
  }
  ans = (X - sum) / vec.at(0) + N;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        int res = 0;
        for (int i = 1; i < n; i++) {
            String x = s.substring(0, i);
            String y = s.substring(i);

            HashMap<String, Integer> mapX = new HashMap<>();
            HashMap<String, Integer> mapY = new HashMap<>();

            for (int j = 0; j < x.length(); j++) {
                String key = new String(new char[]{x.charAt(j)});
                if (mapX.containsKey(key)) {
                    mapX.put(key, mapX.get(key) + 1);
                } else {
                    mapX.put(key, 1);
                }
            }

            for (int j = 0; j < y.length(); j++) {
                String key = new String(new char[]{y.charAt(j)});
                if (mapY.containsKey(key)) {
                    mapY.put(key, mapY.get(key) + 1);
                } else {
                    mapY.put(key, 1);
                }
            }

            int max = 0;// XとYでの同じ文字の数
            for (Map.Entry entry: mapX.entrySet()) {
                String key = (String) entry.getKey();

                if (mapY.containsKey(key)) {// XとYで同じ文字をカウントする
                    max++;
                }
            }

            res = Math.max(max, res);
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 24276
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	long long n, W;
	cin >> n >> W;

	vector<long long> w(n), v(n);
	for(long long i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}

	vector<vector<long long>> dp(n + 1, vector<long long>(W + 1, 0));
	for(long long i = 0; i <= n; i++) {
		for(long long j = 0; j <= W; j++) {
			if(i == 0 or j==0) {
				dp[i][j] = 0;
			}
			else if(w[i - 1] <= j) {
				dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n][W];

}

Measured memory_bytes: 80256
#include <iostream>

using namespace std;

int main()
{
    int A , B , X , r ;
    cin >> A >>B >>X;
    r = X-A;
    if (X >= A && r <= B ){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO" <<endl;
    }


    return 0;
}


Measured memory_bytes: 256
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    int a, b;
    cin >> a >> b;
    
    if((a*500) >= b)
        cout << "Yes" << endl;
    else
        cout  << "No" << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int a,b;
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b})<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  int n;
  cin>>n;
  vector<int> a(n), b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  sort(b.rbegin(),b.rend());
  vector<int> c(200005);
  rep(i,n) c[a[i]]++;
  rep(i,n) c[b[i]]++;
  priority_queue<P> q;
  rep(i,200005) if (c[i]) q.emplace(c[i],i);
  if (q.top().first > n) {
      cout<<"No"<<endl;
      return 0;
  }
  cout<<"Yes"<<endl;
  rep(i,n){
    if(a[i]!=b[i])continue;
    else{
        rep(j,n){
          if(a[i]!=b[j]&&a[j]!=b[i]){
            swap(b[i],b[j]);
            break;
          }
        }
    }
  }
  bool hantei=true;
  rep(i,n){
    if(a[i]!=b[i])continue;
    else{
        hantei=false;
        rep(j,n){
          if(a[i]!=b[j]&&a[j]!=b[i]){
            swap(b[i],b[j]);
            hantei=true;
            break;
          }
        }
    }
  }
  rep(i,n)cout<<b[i]<<" ";
  cout<<endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) --a[i];
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  vector<int> c(n-1);
  rep(i, n-1) cin >> c[i];
  int ans = 0;
  rep(i, n) {
    ans += b[a[i]];
    if (i < n-1 && (a[i] + 1 == a[i+1])) {
      ans += c[a[i]];
    }
    //cout << ans << '\n';
  }
  cout << ans << '\n';
  
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        if(a<b && b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
    }
}



Measured memory_bytes: 26208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int MAXN=262144,MAXM=30000000;
int P;
#define L 1048576
#define real long double
#define eps 1e-9
char _buf[L],*S,*T,_buf1[L],*S1=_buf1;
inline char gc()
{
	if(S==T)
	{
		T=(S=_buf)+fread(_buf,1,L,stdin);
		if(S==T)return 0;
	}
	return *S++;
}
template<class T> void get(T &x)
{
	char c;
	for(c=gc();(c<'0'||c>'9')&&c!='-';c=gc());
	bool b=0;
	if(c=='-')
	{
		b=1;
		c=gc();
	}
	for(x=c^'0',c=gc();c>='0'&&c<='9';c=gc())x=(x<<3)+(x<<1)+(c^'0');
	if(b)x=-x;
}
inline void pc(char c)
{
	if(S1==_buf1+L)
	{
		fwrite(_buf1,1,L,stdout);
		S1=_buf1;
	}
	*S1++=c;
}
void out(ll x)
{
	if(x>9)out(x/10);
	pc(x%10^'0');
}
int Pow(int x,int y)
{
	int s=1;
	for(;y;y>>=1,x=(ll)x*x%P)if(y&1)s=(ll)s*x%P;
	return s;
}
int A(int x)
{
	return x<0?-x:x;
}
int n,N,m,s,t,i,j,a[50],o[1048576];
long long d[20][2],f[50],ans,c[55][55];
int O(ll x)
{
	return o[x>>40]+o[x>>20&1048575]+o[x&1048575];
}
void dfs(int x,ll y,int w)
{
	if(!y)return;
	if(x==18)
	{
		f[O(y)]+=w;
		return;
	}
	dfs(x+1,y,w);
	if(t>>x&1)
	{
		dfs(x+1,y&d[x][0],-w);
		dfs(x+1,y&d[x][1],-w);
	}
}
int main()
{
	for(i=1;i<1<<20;i++)o[i]=o[i>>1]+(i&1);
	get(n);
	get(m);
	get(s);
	get(t);
	if((t&s)!=s)
	{
		puts("0");
		return 0;
	}
	while(n--)
	{
		get(i);
		if((i&s)==s&&!(i&~t))a[N++]=i^s;
	}
	t^=s;
	for(i=0;i<18;i++)if(t>>i&1)for(j=0;j<N;j++)d[i][a[j]>>i&1]|=1LL<<j;
	for(i=c[0][0]=1;i<=N;i++)for(j=c[i][0]=1;j<=i;j++)c[i][j]=c[i-1][j]+c[i-1][j-1];
	dfs(0,(1LL<<N)-1,1);
	for(i=1;i<=N;i++)for(j=1;j<=m;j++)ans+=f[i]*c[i][j];
	cout<<ans<<endl;
	fwrite(_buf1,1,S1-_buf1,stdout);
	return 0;
}

Measured memory_bytes: 7780
li = []
d = 0
co = 0
inp = [int(i) for i in input().split()]
inp2 = [int(i) for i in input().split()]
for k in range(inp[0]):
  li.append([int(i) for i in input().split()])
  
  
for g in li:
  for f in range(inp[1]):
    d += g[f] * inp2[f]
  d += inp[2]
  if d > 0:
    co += 1
  d = 0
print(co)

Measured memory_bytes: 3064
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
main=do
 [n,m]<-map (read . BS.unpack) . BS.words <$> BS.getLine
 a<-map (read . BS.unpack) . BS.words <$> BS.getLine
 cb<-replicateM m ((\x->(x!!1,x!!0)).map (read . BS.unpack) . BS.words <$> BS.getLine)
 (print.sum)(take n (reverse(sort((f n m (reverse(sort cb)))++a))))
  where f n m cb = if n*m<=0 then [] else ((take(snd(head cb))(repeat(fst(head cb))))++(f (n-(snd(head cb))) (m-1) (tail cb)))

Measured memory_bytes: 83324
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

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

  vector<int64_t> a(n);
  cin >> a;
  int64_t out = numeric_limits<int64_t>::max();

  for(size_t k = 0; k < 2; ++ k)
  {
    int64_t acc = 0, val = 0;
    for(size_t i = 0; i < n; ++i)
    {
      acc += a[i];
      int64_t inc;

      if((i & 1) == k)
        inc = acc - min(acc, (int64_t) -1);
      else
        inc = max(acc, (int64_t)1) - acc;

      val += inc;
      acc += (i & 1) == k ? -inc : inc;
    }

    out = min(out, val);
  }
  cout << out << '\n';

  return EXIT_SUCCESS;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, ans=0;
    string S;
    cin >> N;
    cin >> S;

    for(int i=0; ; i++){
	if(S[i+2]=='\0')
	    break;
	if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C')
	    ans++;
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
import Data.List
import qualified Data.Map as M
import Control.Monad

getInputData :: IO [(Int,Int)]
getInputData = do
 n <- read <$> getLine :: IO Int
 ans <- replicateM n ((\[x,y] -> (x-1,y)) . map read . words <$> getLine) 
 return ans

getHonestStatement ::  [[(Int, Int)]] -> [[(Int, Int)]] -> [Int] -> [[(Int, Int)]]
getHonestStatement statement ans choice
 | null choice = ans
 | otherwise   = getHonestStatement statement ((statement !! (head choice)):ans) (tail choice)
 
judge :: [(Int, Int)] -> Int
judge a = (\x -> if elem (-1) x then 0 else 1) $ map snd $ M.toList $ M.fromListWith (\x y -> if x == y then x else -1) a

getPremise :: Int -> [Int] -> [(Int, Int)]
getPremise n choise = union (zip ([0..(n-1)]\\choise) (repeat 0)) (zip (choise) (repeat 1))

main = do
 n <- read <$> getLine :: IO Int
 let choices = subsequences [0..(n-1)]
 statements <- replicateM n getInputData
 let ans1 = map length choices
 let ans2 = map judge $ zipWith (++) (map (getPremise n) choices) $ map (concat . (getHonestStatement statements [])) choices
 print $ maximum $ zipWith (*) ans1 ans2

Measured memory_bytes: 5244
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vi a(N);
    Rep(i,N){
        Scd(a[i]);
    }

    bool APPROVED = true;
    Rep(i,N){
        if( a[i]%2==0 && a[i]%3 && a[i]%5 ) APPROVED = false;
    }

    printf ("%s\n", APPROVED?"APPROVED":"DENIED" );

    return 0;
}



Measured memory_bytes: 256
import statistics
n = int(input())
a = list(map(int, input().split()))
l = []
m = []
for i in range(n):
    m.append(a[i]-i)
med = int(statistics.median(m))
for i in range(n):
    l.append(abs(a[i]-(med+i)))
print(sum(l))

Measured memory_bytes: 29704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long pow2 = 1;
		int count = 0;
		while (true) {
			if (pow2 > H) {
				break;
			}
			count++;
			pow2 *= 2;
		}
		System.out.print((long) Math.pow(2, count) - 1);
	}
}

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

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
    }

    rep(l, k+1) {
        rep(r, k-l+1) {
            if(l + r > n) {
                continue;
            }
            int d = k-l-r;
            int now = 0;
            vector<int> s;
            rep(i, l) {
                now += v[i];
                s.push_back(v[i]);
            }
            for(int i = n-r; i < n; i++) {
                now += v[i];
                s.push_back(v[i]);
            }

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

            rep(i, d) {
                if(i >= s.size()) {
                    break;
                }
                if(s[i] >= 0) {
                    break;
                }

                now -= s[i];
            }

            ans = max(ans, now);
        }
    }

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

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct node { int v, p; };

int N, Q;
vector<vector<int>> adj;
vector<node> v;
map<int, int> query;

void init(int n=0) {
  for (auto x: adj[n] ) {
    if (x!=v[n].p) {
      v[x].p = n;
      init(x);
    }
  }
}

void dfs(int n=0,int q=0) {
  v[n].v = q+query[n];
  for (auto x: adj[n] ) if (x!=v[n].p) dfs(x, v[n].v);
}

int main() {
  cin >> N >> Q;
  adj.assign(N,{}); v.assign(N,(node){0,-1});
  rep(i,N-1) {
    int a, b; cin >> a >> b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  rep(i,Q) {
    int p, x; cin >> p >> x; p--;
    query[p] += x;
  }

  init(); dfs();
  rep(i,N) cout << v[i].v << " "; cout << endl;
  return 0;
}

Measured memory_bytes: 39936
<?php

fscanf(STDIN, "%d%d%d", $x, $k, $d);

$times_to_origin = (int)floor(abs($x) / $d);
if ($times_to_origin > $k) {
    $times_to_origin = $k;
}

$k -= $times_to_origin;
$x = $x > 0 ? $x - $d * $times_to_origin : $x + $d * $times_to_origin;

if ($k % 2 === 0) {
    echo abs($x);
} else {
    $x = $x > 0 ? $x - $d : $x + $d;
    echo abs($x);
}


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

int main() {
   int N, K;
   cin >> N >> K;
  int x = 1;
  for(int i = 0; i < N; i++){
    if(x < K){
      x *= 2;
    }
    else{
      x += K;
    }
  }
 cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            if (!((a[i] % 3 == 0) || (a[i] % 5 == 0)))
                flag = false;
        }
    }
    
    if (flag)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;

    return 0;
}


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

int main(){
    string stg;
    cin >> stg;

    int placeA = -1;
    int placeZ = -1;
    for (int i = 0; i < stg.size(); i++) {
        if (stg.at(stg.size() - 1 - i) == 'A') {
            placeA = stg.size() - 1 - i;
        }
        if (stg.at(i) == 'Z') {
            placeZ = i;
        }
    }

    int ans = placeZ - placeA + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	#define ll long long
	ll n, w;
	cin>>n>>w;
	vector<pair<ll,ll>> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i].first>>v[i].second;
	vector<ll> dp(100100); //dp[i]=max value with weight i
	for(int i=0;i<n;i++){
		for(int j=w;j>=0;j--)
			if(j+v[i].first<=w)
				dp[j+v[i].first]=max(dp[j+v[i].first],dp[j]+v[i].second);
	}
	cout<<dp[w];
}


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

#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(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  string s;
  cin >> s;
  string ans;
  int l = s.size();
  for (int i=0; i<l; i++) {
    if (i%2==0) ans.push_back(s[i]);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 512
// Learn more about F# at http://fsharp.org

open System

let Input f =
    stdin.ReadLine() |> f

let InputArray f =
    stdin.ReadLine().Split(' ') |> Array.map f

[<EntryPoint>]  
let main argv =

    let n = Input int
    let a = InputArray int

    let ableDivCount n =
        let mutable c = 0
        let mutable d = 2
        while n % d = 0 do
            d <- d * 2
            c <- c + 1
        c

    a
    |> Seq.map ableDivCount
    |> Seq.min
    |> printfn "%d"

    0 // return an integer exit code


Measured memory_bytes: 14172