akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = 1234567;

char s[N];
int n;
int dp[N];
int used[N];

struct suffix_automata {
  int last, sz;

  struct state {
    int len;
    int link;
    map<char, int> next;
  } st[N];

  suffix_automata() {
    last = 0;
    sz = 1;
    st[last].len = 0;
    st[last].link = -1;
  }

  void add(char c) {
    int cur = sz++;
    st[cur].len = st[last].len + 1;
    int p;
    for (p = last; p > -1 && !st[p].next.count(c); p = st[p].link) {
      st[p].next[c] = cur;
    }
    if (p == -1) {
      st[cur].link = 0;
    } else {
      int q = st[p].next[c];
      if (st[p].len + 1 == st[q].len) {
        st[cur].link = q;
      } else {
        int clone = sz++;
        st[clone].len = st[p].len + 1;
        st[clone].link = st[q].link;
        st[clone].next = st[q].next;
        for (; p > -1 && st[p].next[c] == q; p = st[p].link) {
          st[p].next[c] = clone;
        }
        st[cur].link = st[q].link = clone;
      }
    }
    last = cur;
  }

  void dfs(int v = 0) {
    used[v] = 1;
    for (auto e : st[v].next) {
      char c = e.first;
      int to = e.second;
      if (!used[to]) {
        dfs(to);
      }
      dp[v] += dp[to];
    }
    dp[v]++;
  }

  void solve(int k) {
    int cur = 0;
    string ans;
    if (k > dp[0] - 1) {
//      assert(0);
    }
    while (k > 0) {
      bool ok = false;
      for (auto e : st[cur].next) {
        char c = e.first;
        int to = e.second;
        if (k <= dp[to]) {
          ans.push_back(c);
          ok = true;
          cur = to;
          k--;
          break;
        } else {
          k -= dp[to];
        }
      }
      if (!ok) {
        break;
      }
    }
    printf("%s\n", ans.c_str());
  }

} automata;

int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    automata.add(s[i]);
  }
  automata.dfs();
  int k;
  scanf("%d", &k);
  automata.solve(k);
  return 0;
}

Measured memory_bytes: 72576
// https://arxiv.org/ftp/arxiv/papers/1501/1501.04750.pdf
#include <cstdio>
#include <cstring>

using int64 = long long;

const int N = 1e5 + 10, mod = 1e9 + 7;

int fac[N], ifac[N], inv[N];

int calc(int n, int m) {
  int ret = 0;
  for (int64 j = -m; j <= m; ++j) {
    if (m + j * (n + 2) < 0) continue;
    int64 s = (m + (n + 2) * j) / 2;
    if (s < 0 || s > m) continue;
    int binom = (int64)fac[m] * ifac[s] % mod * ifac[m - s] % mod;
    if (j % 2 == 0) ret += binom;
    else ret += mod - binom;
    ret %= mod;
  }
  return ret;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  inv[1] = 1;
  for (int i = 2; i <= m; ++i) {
    inv[i] = int64(mod - mod / i) * inv[mod % i] % mod;
  }
  fac[0] = ifac[0] = 1;
  for (int i = 1; i <= m; ++i) {
    fac[i] = (int64)i * fac[i - 1] % mod;
    ifac[i] = (int64)inv[i] * ifac[i - 1] % mod;
  }
  int ret = calc(n - 1, m) - calc(n - 2, m);
  printf("%d\n", (ret % mod + mod) % mod);
  return 0;
}

Measured memory_bytes: 3800
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next

  val ans = s.count(_ == '1')

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int n,  k;

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	
	scanf("%d %d", &n , &k);
	map < int , int > vis;
	for(int i = 0 ; i < k ; ++i){
		int x;
		scanf("%d",  &x);
		for(int j = 0 ; j < x ; ++j){
			int rkm;
			scanf("%d", &rkm);
			vis[rkm]++;
		}
	}
	int cnt = 0;
	for(int i = 1 ; i <= n ; ++i)
		if(!vis[i])
			cnt++;
		
	printf("%d\n", cnt);
	
	
	
    return 0;
}




Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int K,N,x,next;
  vector<int> A;
  cin>>K>>N;
  rep(i,N)
  {
    cin>>x;
    A.push_back(x);
    if(i==0)next=x;
    if(i>0)next=max(x-A.at(i-1),next);
    if(i==N-1)next=max(K-x+A.at(0),next);
  }
  cout<<K-next<<endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }

    for(int i=0;i<1000000000*100;i++){
        int aho;
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


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

using namespace std;

int main()
{
    int l;
    int a;
    int b;
    int c;
    int d;
    cin >> l;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    cout << (l - max(static_cast<int>(ceil(static_cast<double>(a) / c)),
                     static_cast<int>(ceil(static_cast<double>(b) / d))))
         << endl;
}

Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<p> pn = vector<p>(n);

    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        pn[i] = p(x, y);
    }

    // 昇順にソート済みの入力
    vector<int> v = vector<int>(n);
    rep(i, n)
    {
        v[i] = i;
    }

    double total_sum = 0;
    double count = 0;
    do
    {
        count++;
        double loop_sum = 0;
        for (int i = 1; i < n; ++i)
        {
            loop_sum += sqrt(pow(pn[v[i]].first - pn[v[i - 1]].first, 2) + pow(pn[v[i]].second - pn[v[i - 1]].second, 2));
        }
        total_sum += loop_sum;
    } while (next_permutation(v.begin(), v.end()));

    cout << fixed << setprecision(7) << total_sum / count << endl;
}

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

int main()
{
	int H, W;
	scanf("%d %d", &H, &W);
	
	int i, j;
	char a[100][100];
	for (i = 0; i < H; i++)
		for (j = 0; j < W; j++) {
			do {
				a[i][j] = getchar();
			} while (a[i][j] != '#' && a[i][j] != '.');
		}

	bool exRow[100] = { 0 }, exCol[100] = { 0 };

	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++)
			if (a[i][j] == '#')
				break;

		if (j == W)
			exRow[i]++;
	}

	for (j = 0; j < W; j++) {
		for (i = 0; i < H; i++)
			if (a[i][j] == '#')
				break;

		if (i == H)
			exCol[j]++;
	}

	for (i = 0; i < H; i++)
		if (!exRow[i]) {
			for (j = 0; j < W; j++)
				if (!exCol[j])
					putchar(a[i][j]);

			putchar('\n');
		}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int table[ 11 ][ 50 ] = { };

  for ( int i = 0; i < 0x400; ++i )   /* 0x400: (10000000000)_2 (10 zeros) */
  {
    int sum = 0;
    int ctr = 0;
    int cur = -1;

    while ( true )
    {
      int __tmp = i >> ++cur;

      if ( !__tmp ) break;
      if ( __tmp & 1 )
      {
        sum += cur;
        ++ctr;
      }
    }

    table[ ctr ][ sum ]++;
  }

  while ( true )
  {
    int n, s;

    cin >> n >> s;
    if ( n == 0 && s == 0 ) break ;

    cout
      << ( n >= 0 && n <= 10
           && s >= 0 && s < 50 ? table[ n ][ s ]
                                : 0 ) << endl;
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

struct dice {
    int u, d, l, r, f, b;

    void spinl(){ // f -> l
        int tmp = f; f = r; r = b; b = l; l = tmp;
    }
    void spinr(){
        for (int i = 0; i < 3; ++i) spinl();
    }

    void gof(){
        int tmp = f; f = u; u = b; b = d; d = tmp;
    }

    void gob(){
        for (int i = 0; i < 3; ++i) gof();
    }

    void gor(){
        int tmp = u; u = l; l = d; d = r; r = tmp;
    }

    void gol(){
        for (int i = 0; i < 3; ++i) gor();
    }

    dice(int a, int x) {
        u = 1, d = 6, f = 2, b = 5, l = 4, r = 3;
        if(a == 2) gob();
        else if(a == 3) gol();
        else if(a == 4) gor();
        else if(a == 5) gof();
        else if(a == 6) gof(), gof();
        while(f != x) spinl();
    }
};

int main() {
    int n;
    while(cin >> n, n){
        vector<dice> v;
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            v.emplace_back(x, y);
        }
        map<pair<int, int>, int> m, ans;
        for (int i = 0; i < n; ++i) {
            int x = 0, y = 0;
            auto D = v[i];
            int ok = 1;
            m[{x, y}]++;
            while(ok){
                ok = 0;

                for (int j = 6; j >= 4; --j) {
                    if(ok) continue;
                    if(D.f == j){
                        if(m[{x+1, y}] < m[{x, y}]-1){
                            ok = 1;
                            m[{x+1, y}]++; m[{x, y}]--;
                            x++;
                            D.gof();
                        }
                    }else if(D.r == j){
                        if(m[{x, y+1}] < m[{x, y}]-1){
                            ok = 1;
                            m[{x, y+1}]++; m[{x, y}]--;
                            y++;
                            D.gor();
                        }
                    }else if(D.l == j){
                        if(m[{x, y-1}] < m[{x, y}]-1){
                            ok = 1;
                            m[{x, y-1}]++; m[{x, y}]--;
                            y--;
                            D.gol();
                        }
                    }else if(D.b == j){
                        if(m[{x-1, y}] < m[{x, y}]-1){
                            ok = 1;
                            m[{x-1, y}]++; m[{x, y}]--;
                            x--;
                            D.gob();
                        }
                    }
                }
            }
            ans[{x, y}] = D.u;
            v[i] = D;
        }
        vector<int> ans2(6);
        for (auto &&k : ans) {
            ans2[k.second-1]++;
        }
        for (int i = 0; i < 6; ++i) {
            if(i) cout << " ";
            cout << ans2[i];
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3120
A_V = input().split(" ")
B_W = input().split(" ")
T = int(input())
A = int(A_V[0])
V = int(A_V[1])
B = int(B_W[0])
W = int(B_W[1])
dA = A + V * T
dB = B + W * T
ndA = A - V * T
ndB = B - W * T
if (A<B):
    if (dA < dB):
        print("NO")
    else:
        print("YES")
else:
    if (ndA > ndB):
        print("NO")
    else:
        print("YES")

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


int main() {
	double x;
	cin >> x;

	ll now = 100;
	for (int i = 1; i <= 4000; i++) {
		now += (double)now / 100;
		
		
		if (now >= x ) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3716
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int A, B, C, D;
	scanf("%d%d%d", &A, &B, &C);
	D = B / A;
	if (D <= C) {
		printf("%d", D);
	}else {
		printf("%d", C);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;
 
int a[200000];
int tmp_a[200000];
int data[200000];
int N;
int sum(int i){ // does not include i
    int ans = 0;
    for(;i > 0; i -= i & (-i)){
        ans += data[i - 1];
    }
    return ans;
}

void add(int i, int x){
    for(; i < N; i += (i + 1) & (-(i + 1))){
        data[i] += x;
    }
}

void init(int n){
    N = n;
    for(int i = 0; i < N; i++){
        data[i] = 0;
    }
}

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

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

    sort(a, a + n);
    map <int, int> elem_rank;
    for(int i = 0; i < n; i++){
        elem_rank[a[i]] = i;
    }

    init(n);
    long long ans = 0;
    for(int i = 0; i < n; i++){
        //cout << sum(i) << endl;
        ans += i - sum(elem_rank[tmp_a[i]]);
        add(elem_rank[tmp_a[i]], 1);
        //cout << tmp_a[i] << ", " << elem_rank[tmp_a[i]] << endl;
    }
    cout << ans << endl;
    //for(int i = 0; i < n; i++){
    //    cout << data[i] << " ";
    //}
    return 0;
}


Measured memory_bytes: 14852
// Single Source Shortest Path I
#include <stdio.h>

#define INF 999999999
#define NIL -1
#define MAX 100

// 以下の3色でvの訪問状態を示す
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;           // Gの頂点の数
int color[MAX];  // 訪問状態を記録する
int G[MAX][MAX]; // 隣接行列
int d[MAX];      // d[v]:始点からvまでの最短コストを記録する
int p[MAX];      // p[v]:最短経路木における頂点vの親を記録する

void dijkstra(){
  int i, j, u, mincost;
  
  for(i=0; i < n; i++){
    color[i] = WHITE;
    d[i] = INF;
    p[i] = NIL;
  }
  
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    mincost = INF;
    for(i=0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INF) break;
    
    //d[u] = mincost;
    color[u] = BLACK;
    
    for(i=0; i < n; i++){
      if(color[i] != BLACK && G[u][i] != INF){
        if(d[u] + G[u][i] < d[i]){
          d[i] = d[u] + G[u][i];
          p[i] = u;
          color[i] = GRAY;
        }
      }
    }
  }
  for(i=0; i < n; i++){
    printf("%d %d\n", i, d[i]);
  }
}

int main(){
  int i, j, k, u, v;
  
  scanf("%d", &n);
  
  for(i=0; i < n; i++){
    for(j=0; j < n; j++){
      G[i][j] = INF;
      //G[i][j] = 0;
    }
  }
  
  for(i=0; i < n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j < k; j++){
      scanf("%d", &v);
      scanf("%d", &G[u][v]);
    }
  }
  dijkstra();
  
  return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	int N;
	while (cin >> N, N) {
		vector<int> score(N);
		for (int i = 0; i < N; i++)
			cin >> score[i];
		sort(score.begin(), score.end());
		
		int sum = 0;
		for (vector<int>::iterator it = score.begin() + 1; it != score.end() - 1; it++)
			sum += *it;
		int avg = sum / (N - 2);

		cout << avg << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

LL n, x, ans;
LL a[N];

signed main() {
	read(n), read(x);
	for (int i = 1; i <= n; i++) read(a[i]);
	if (a[1] > x) {
		ans += a[1] - x;
		a[1] = x;
	}
	for (int i = 2; i <= n; i++)
		if (a[i] + a[i - 1] >= x) {
			ans += a[i] + a[i - 1] - x;
			a[i] = x - a[i - 1];
		}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
int p=a[1]-a[0];
if(p%2)p=p/2+2;
else p/=2;
cout<<(a[2]-a[1]+p)<<endl;
}

Measured memory_bytes: 256
from itertools import groupby
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()
    ans = 0
    for i in range(k):
        x = i
        li = []
        while x < n:
            li.append(t[x])
            x += k
        for key, value in groupby(li):
            if key=='r':
                a=p
            elif key=='s':
                a=r
            else:
                a=s

            ans += ((len(list(value))+1)//2)*a
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10472
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;


int h, w, alp[26], cnt2, cnt1;
char mem;
int main() {
	cin >> h >> w;
	lp(26)
		alp[i] = 0;
	lp(h*w) {
		cin >> mem;
		alp[mem - 'a']++;
	}
	cnt1 = cnt2 = 0;
	lp(26) {
		alp[i] %= 4;
		if (alp[i] == 1)
			cnt1++;
		else if (alp[i] == 2)
			cnt2++;
		else if (alp[i] == 3) {
			cnt1++;
			cnt2++;
		}
	}
	if (!(h % 2) && !(w % 2)) {
		if (cnt1 != 0 || cnt2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	else if (!(h % 2)) {
		if (cnt1 != 0 || cnt2 > h/2) {
			cout << "No" << endl;
			return 0;
		}
	}
	else if (!(w % 2)) {
		if (cnt1 != 0 || cnt2 > w/2) {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		if (cnt1 != 1 || cnt2 > (w + h - 2)/2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

typedef long long ll;
#define MOD 1000000007LL
ll dp[2][5001];
int main(void){
  int N, i, j;
  char buf[5001];
  scanf("%d%s", &N, buf);
  dp[0][0] = 1;
  for(i=0;i<N;++i){
    int w = i&1;
    dp[1-w][0] = dp[1-w][1] = dp[w][0];
    for(j=1;j<=N;++j){
      dp[1-w][j-1] = (dp[1-w][j-1]+dp[w][j]*2)%MOD;
      dp[1-w][j+1] = dp[w][j];
    }
  }
  printf("%lld\n", dp[N&1][strlen(buf)]);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
    
int main(void)
{ double r;
  double f1,f2;
  scanf("%lf" , &r);
      
  f1 = r*r*3.141592653589;
  f2 = 2*r*3.141592653589;
    
  printf("%lf %lf" ,f1,f2);
  return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool can_make_triangle(ll a, ll b, ll c) {
    if ((a < b + c) && (b < a + c) && (c < a + b)) {
        return true;
    } else {
        return false;
    }
}

int main() {
    ll N;
    cin >> N;
    vector<ll> L(N);
    ll l;
    REP(i, N){
        cin >> l;
        L[i] = l;
    }
    sort(ALL(L));

    ll res = 0;
    FOR(i, 0, N) {
        FOR(j, i+1, N) {
            ll apb = L[i] + L[j];
            FOR(k, j+1, N) {
                if (apb <= L[k]) {
                    break;
                }
                if (can_make_triangle(L[i], L[j], L[k])) {
                    res += 1;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int X, A;
  cin >> X >> A;
  if(X < A)
    cout << 0 << endl;
  else
    cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cctype>

using namespace std;

int main(int argc, char *argv[]) {
	queue<char> a, b, c;

	string S;
	cin >> S;
	for (char ch : S) a.push(ch);
	cin >> S;
	for (char ch : S) b.push(ch);
	cin >> S;
	for (char ch : S) c.push(ch);

	char turn = 'a';
	while (true) {
		if (turn == 'a') {
			if (a.empty()) break;
			turn = a.front();
			a.pop();
		} else if (turn == 'b') {
			if (b.empty()) break;
			turn = b.front();
			b.pop();
		} else if (turn == 'c') {
			if (c.empty()) break;
			turn = c.front();
			c.pop();
		}
	}

	cout << (char)toupper(turn) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

goukei=0
for i in range(N):
    #print(goukei)
    if A[i]>=B[i]:
        goukei = goukei+B[i]

    elif A[i]+A[i+1]>=B[i]:
        A[i+1] = A[i+1] - (B[i]-A[i])
        goukei = goukei + B[i]

    else:
        goukei = goukei + A[i]+A[i+1]
        A[i+1] = 0


print(goukei)

Measured memory_bytes: 81892
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int main() {

    fast

    int n;
    cin>>n;

    double odd=0;

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

    if(i%2==1)
    odd++;
    }

    cout<<(odd/n);

	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/




Measured memory_bytes: 256
while True:
	a, op, b = map(str, input().split())
	a = int(a)
	b = int(b)
	
	if op == "+":
		output = a + b
	elif op == "-":
		output = a - b
	elif op == "*":
		output = a * b
	elif op == "/":
		output = a // b
	elif op == "?":
		break
	print(output)

Measured memory_bytes: 7676
n, m = gets.split.map(&:to_i)
ar = Array.new(n){[]}
m.times do
  a, b = gets.split.map(&:to_i)
  a -= 1
  b -= 1
  ar[a] << b
  ar[b] << a
end

ans = Array.new(n, -1)
ans[0] = 0
q = [0]
until q.empty? do
  x = q.shift
  ar[x].each do |i|
    next if ans[i] != -1
    ans[i] = x + 1
    q.push(i)
  end
end

if ans.include?(-1)
  puts 'No'
else
  puts 'Yes'
  puts ans[1..-1]
end


Measured memory_bytes: 32600
#include<stdio.h>

int main(void)
{
	int sum = 0;
	int i = 0;
	int kosuu = 0;
	float ave;
	char comma;
	int tanka;
	int kazu;
	
	while (scanf("%d%c%d",&tanka,&comma,&kazu) != EOF){
		sum += (tanka * kazu);
		kosuu += kazu;
		i++;
	}
	
	ave = 1.0 * kosuu / i;
	if (kosuu * 10 / i % 10 > 4){
		ave++;
	}
	printf("%d\n", sum);
	printf("%d\n",(int)ave);
	
	return (0);
}

Measured memory_bytes: 596
s=input()
x,y=map(int,input().split())
xx,yy=[],[]
w=[0,0]
ans=chk=0
f=0
for i in s:
    if f==0 and i=='F':
        w[0]+=1
    elif f==0 and i=='T':
        f=1
    elif f==1 and i=='F':
        chk+=1
    elif f==1 and i=='T':
        yy.append(chk)
        chk=0
        f=2
    elif f==2 and i=='F':
        chk+=1
    elif f==2 and i=='T':
        xx.append(chk)
        chk=0
        f=1
if chk and f==1:
    yy.append(chk)
elif chk and f==2:
    xx.append(chk)
xx.sort()
yy.sort()
for i in xx[::-1]:
    if w[0]<x:
        w[0]+=i
    else:
        w[0]-=i
for i in yy[::-1]:
    if w[1]<y:
        w[1]+=i
    else:
        w[1]-=i
print("Yes" if w[0]==x and w[1]==y else "No")

Measured memory_bytes: 40688
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main()
{
    cin >> a >> b >> c >> d;
    int ab = a + b;
    int cd = c + d;
    if (ab > cd)
    {
        cout << "Left" << endl;
    }
    else if (ab < cd)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
int main(){
	int A,B,H,S;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&H);
	S=(A+B)*H/2;
	printf("%d\n",S); 
	system("pause");
	return 0;
	}

Measured memory_bytes: 504
#include <iostream>
int main() {
	char s[4]="000", c = '0';
	std::cin >> s;
	for (int i = 0; s[i] != '\0'; i++)c += (s[i] == '1' ? 1 : 0);
	std::cout << c << std::endl;
	return 0;
}

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

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

		ArrayList<Integer> arrayList = new ArrayList<Integer>();

		arrayList.add(Integer.parseInt(sc.next()));
		arrayList.add(Integer.parseInt(sc.next()));
		arrayList.add(Integer.parseInt(sc.next()));

		long count_5 = arrayList.stream().filter(c -> c == 5).count();
		long count_7 = arrayList.stream().filter(c -> c == 7).count();

		if(count_5 == 2 && count_7 == 1){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  ll n;cin>>n;
  vector<ll>num(n);
  for(int i=0;i<n;i++)cin>>num[i];
  ll ans=0;
  ll now=0;
  ll sum=0;
  ll cnt=0;
  ll back=0;
  for(int i=0;i<n;i++){
    sum+=num[i];
    now=(now^num[i]);
    if(sum==now){
      cnt++;
    }else{
      while(sum!=now){
	//	cout<<sum<<" "<<back<<" "<<i<<" "<<cnt<<endl;
	ans+=cnt;
	cnt--;
	sum-=num[back];
	now=(now^num[back]);
	back++;
      }
      cnt++;
    }
  }
  cout<<(ll)ans+((cnt+1)*cnt)/2<<endl;
  return 0;
}


Measured memory_bytes: 1920
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class BMinorChange {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        string a,b;
        cin>>a>>b;
        int count=0;
        int n=a.length();
        for (int i=0;i<n;i++)
            if (a[i]!=b[i])
                count++;
        cout<<count;
	}
};


int main() {
	BMinorChange solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define ll long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >

const int N = 1e3 + 7;
const int mod = 1e9 + 7;

ll dp[N][N];
char s[N][N];
int n, m;

main(){
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            scanf(" %c", &s[i][j]);
        }
    }
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            if (i + j == 2)
                continue;
            if (s[i][j] == '.'){
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= mod;
            }
        }
    }
    printf("%lld", dp[n][m]);
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,ma = 0,ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int p;
		cin >> p;
		chmax(ma,p);
		ans += p;
	}
	cout << ans - ma / 2 << endl;
}

Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=='?':
        break
    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    else:
        print(a//b)
        


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

int ary[20][10010];
int main(){
	int R,C,res,tmp,cnt;
	while(true){
		cin>>R>>C;
		if(R==0&&C==0) break;
		for(int i=0;i<R;i++){
			for(int j=0;j<C;j++){
				cin>>ary[i][j];
			}
		}

		res=0;
		for(int i=0;i<(1<<R);i++){
			cnt=0;
			for(int j=0;j<C;j++){
				tmp=0;
				for(int k=0;k<R;k++){
					tmp+=(ary[k][j]^((i>>k)&1));
				}
				cnt+=max(tmp,R-tmp);
			}
			res=max(res,cnt);
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF 1000000000 // 10^9
#define mod 1000000007
#define EPS 0.000000001 //10^-9
#define rep(i,a,b) for((i)=(a);(i)<=(b);(i++))
#define pb push_back 
using namespace std;
typedef long long ll;
class node
{
public:
    int value;
    node *left;
    node *right;
};
class node* newnode(int value)
{

    node* a=(node*)malloc(sizeof(node));
    a->value=value;
    a->left=NULL;
    a->right=NULL;
    return a;
};

ll power(ll x,ll n)
{
    if(x==0 || x==1||n==0)
        return 1;
    if(n==1)
        return x;
    if(n%2==0)
        return (power(((x%mod)*(x%mod))%mod,n/2)%mod);
    else
        return ((x%mod)*(power(x,n-1)%mod)%mod);
}
ll fun(ll n,ll k,ll i)
{
    if(i==17)
        return k-1;
    if(k%2==0)
        return -1;
    if(n%k==0)
        return i;
    else
        return fun(10*n+7,k,i+1);
}
int main()
{
    ll n,r=0,w=0,rl=0,rr,wr,wl,i;
    string a;
    cin>>n;
    cin>>a;
    rep(i,0,n-1)
    {
        if(a[i]=='W')
            w++;
        else
            r++;
    }
    for(i=0;i<r;i++)
        if(a[i]=='R')
            rl++;
    wl=r-rl;
    wr=w-wl;
    rr=r-rl;
    cout<<max(wl,rr);

 
}

Measured memory_bytes: 3752
import Data.List
import Data.Maybe
import Data.Bool
import Control.Monad

main = replicateM 2 (map read.words <$> getLine) >>= print.solve

solve [[n,k], as] = fromJust $ find eval ds where
  eval d = sum (take (n - sum rs `div` d) rs) <= k where
    rs = sort $ map (`mod` d) as
  ds = reverse $ sort $ divisiors $ sum as

divisiors n = concatMap (\x -> bool [] [x, div n x] $ mod n x == 0)
  $ takeWhile ((<=n).(^2)) [1..]


Measured memory_bytes: 1148
#include <iostream>
using namespace std;
typedef long long ll;
ll n, k, d, s, M=1e9+7;
string a, b;

int main() {
	cin>>n>>a>>b;
	a[k]==b[k] ? (d=1,s=3) : (d=2,s=6);
	k += d;
	while(k<n) {
		if(a[k]==b[k]) s*=3-d, d=1;
		else s*=d+1, d=2;
		k += d;
		s %= M;
	}
	cout<<s;
	return 0;
}

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

int main(void){
    int k, n, a[200000], max = 0;
    cin >> k >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 1; i < n; ++i) {
        if(a[i] - a[i-1] > a[max] - a[max-1]) max = i;
    }
    if(k - a[n-1] + a[0] > a[max] - a[max-1]) cout << (a[n-1] - a[0]) << endl;
    else cout << (k - (a[max] - a[max-1])) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,x,t;
    cin>>n>>x>>t;
    if(n/x==0)cout<<t<<endl;
    else if(n%x==0)cout<<(n/x)*t<<endl;
    else cout<<(n/x+1)*t<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

int main() {

	int N;
	cin >> N;

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

	vector<int> ans(N);

	for (int i = 0; i < N - 1; ++i)
	{
		ans[A[i] - 1]++;
	}

	for (int i = 0; i < N; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b=scanner.nextInt();
		
		int sum=0;
		for(int i=1;i<=999;i++) {
			if(b-a==i) {
				System.out.println(sum-a);
				return;
			}
			sum+=i;
		}
	}
}


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

#define sz(v) int(v.size())
#define sqr(x) ((x) * (x))
#define range(i, n) for (int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()

using ll = long long;
using ld = long double;
using namespace std;

template <class T1, class T2>
istream& operator >> (istream &in, pair <T1, T2> &a) {
    in >> a.first >> a.second;
    return in;
}

template <class T1, class T2>
ostream& operator << (ostream &out, pair <T1, T2> &p) {
    out << p.first << ' ' << p.second;
    return out;
}

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;
    return in;
}

template <class T>
ostream& operator << (ostream &out, vector <T> &a) {
    out << sz(a) << '\n';
    for (T i : a) out << i << ' ';
    out << '\n';
    return out;
}

void fastIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
}

int n, k;

signed main() {
    fastIO();

    cin >> n >> k;
    vector <int> a(n);

    cin >> a;
    sort(all(a));

    ll ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += a[i];
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3620
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();
		int X = sc.nextInt();

		if (A<=X && A+B>=X)
			System.out.println("YES");
		else
			System.out.println("NO");
		sc.close();
	}

}

Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
using namespace std;
string a;
int main()
{
	cin>>a;
	for(int i=0;i<a.size()-1;i++)
		if(a[i]=='C')
			for(int j=i;j<=a.size()-1;j++)
				if(a[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
  auto y=x;
  sort(y.begin(),y.end());
  for(Int i=0;i<n;i++){
    Int k=lower_bound(y.begin(),y.end(),x[i])-y.begin();
    if(k<n/2){
      cout<<y[n/2]<<endl;
    }else{
      cout<<y[n/2-1]<<endl;
    }
  }
  
  return 0;
}


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

using namespace std;

#define int long long
#define double long double

struct pt {
	double x, y;
	int it;
	double an = 0;
	pt(double x, double y, int it): x(x), y(y), it(it){}
};

bool cmp (pt a, pt b) {
	return a.x < b.x || a.x == b.x && a.y < b.y;
}

bool cw (pt a, pt b, pt c) {
	return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) < 0;
}

bool ccw (pt a, pt b, pt c) {
	return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) > 0;
}

void convex_hull (vector<pt> & a) {
	if (a.size() == 1)  return;
	sort (a.begin(), a.end(), &cmp);
	pt p1 = a[0],  p2 = a.back();
	vector<pt> up, down;
	up.push_back (p1);
	down.push_back (p1);
	for (size_t i=1; i<a.size(); ++i) {
		if (i==a.size()-1 || cw (p1, a[i], p2)) {
			while (up.size()>=2 && !cw (up[up.size()-2], up[up.size()-1], a[i]))
				up.pop_back();
			up.push_back (a[i]);
		}
		if (i==a.size()-1 || ccw (p1, a[i], p2)) {
			while (down.size()>=2 && !ccw (down[down.size()-2], down[down.size()-1], a[i]))
				down.pop_back();
			down.push_back (a[i]);
		}
	}
	a.clear();
	for (size_t i=0; i<up.size(); ++i)
		a.push_back (up[i]);
	for (size_t i=down.size()-2; i>0; --i)
		a.push_back (down[i]);
}

double getdist(pt a, pt b){
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
double an[100];

main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pt> a;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        a.push_back(pt(x, y, i));
    }
    convex_hull(a);
    const double pi = atan2(0, -1);
    int t = a.size();
    for(int i = 0; i < t; i++){
        double sum = 0;
        for(int j = 0; j < t; j++){
            for(int k = 0; k < t; k++){
                if(i == j || j == k || i == k) continue;
                double A = getdist(a[i], a[j]);
                double B = getdist(a[i], a[k]);
                double C = getdist(a[j], a[k]);
                sum = max(sum, acos((A*A+B*B-C*C)/(2*A*B)));
            }
        }
        an[a[i].it] = (pi - sum) / (2 * pi);
    }
    cout << fixed << setprecision(12);
    for(int i = 0; i < n; i++) cout << an[i] << endl;
}


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

signed main(){
    cout << fixed << setprecision(20) << flush;

    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double a_ang = 30.0*h + 0.5*m;
    double b_ang = 6.0*m;
    double co = cos((a_ang-b_ang) * 2.0*M_PI/360.0);
    double c = sqrt(a*a+b*b-2*a*b*co);
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
int n, m;
const int inf = 1e18;
int a[85][85];
int b[85][85];
bool can[85][85][30005] = {{false}};
int buck = 15000;
bool cool (int k) {
	return k >= 0 and k <= 30000;
}
void solve() { 
	cin >> n >> m;
	for (int i = 1; i <= n; i += 1) {
		for (int j = 1; j <= m; j += 1) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i += 1) {
		for (int j = 1; j <= m; j += 1) {
			cin >> b[i][j];
		}
	}
	can[1][1][buck + (a[1][1] - b[1][1])] = true;
	can[1][1][buck + (b[1][1] - a[1][1])] = true;
	for (int i = 1; i <= n; i += 1) {
		for (int j = 1; j <= m; j += 1) {
			for (int now = 0; now <= 30000; now += 1) {
				if (cool(now - (a[i][j] - b[i][j]))) can[i][j][now] |= can[i - 1][j][now - (a[i][j] - b[i][j])];
				if (cool(now - (a[i][j] - b[i][j]))) can[i][j][now] |= can[i][j - 1][now - (a[i][j] - b[i][j])];
				if (cool(now - (b[i][j] - a[i][j]))) can[i][j][now] |= can[i - 1][j][now - (b[i][j] - a[i][j])];
				if (cool(now - (b[i][j] - a[i][j]))) can[i][j][now] |= can[i][j - 1][now - (b[i][j] - a[i][j])];	
			}
		} 
	}
	int mn = inf;
	for (int i = 0; i <= 30000; i += 1)
		if (can[n][m][i])
			mn = min(mn, llabs(i - buck));
	cout << mn;
}	



Measured memory_bytes: 201216
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int T;

int calcTemperature(int height) {
    return T * 1000 - height * 6;
}

int main(void){

    int N, A;
    cin >> N >> T >> A;

    int diffT;
    int res = 1 << 30;
    int ans = 0;
    int tmp;

    FOR(i, 1, N+1) {
        cin >> tmp;
        diffT = calcTemperature(tmp) - A * 1000;
        if (diffT < 0) {
            diffT = -diffT;
        }

        if (res > diffT) {
            res = diffT;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
	int n, k;
	int m;
	cin >> n >> k;
	int minm=100000000;
	int ans=n;
	for(int i=0; i<n; i++){
		int m;
		cin >> m;
		k-=m;
		minm=min(minm,m);
	}
	
	ans += k/minm;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int N;
int C[100010];
int res[100010] = {};
vector<vector<int>> v(100010);

int main(){
    cin >> N;
    int a,b;
    for(int i=0;i<N-1;i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=1;i<=N;i++) cin >> C[i];
    sort(C+1,C+N+1);
    int ans = 0;
    for(int i=1;i<=N-1;i++) ans += C[i];
    int id = N;
    queue<P> Q;
    res[1] = C[id];
    id--;
    Q.push({1,0});
    while(!Q.empty()){
        P p = Q.front(); Q.pop();
        int n = p.first,pre = p.second;
        for(auto x:v[n]){
            if(x==pre) continue;
            res[x] = C[id];
            id--;
            Q.push({x,n});
        }
    }
    cout << ans << endl;
    for(int i=1;i<=N;i++) cout << res[i] << (i!=N? " ":"\n");
}

Measured memory_bytes: 3200
#include<stdio.h>
 
int main()
{
 
 int Time, i, min=1000000001, max=0, profit;
 profit = max - min;
 scanf("%d",&Time);
  
 int price[200000];
 scanf("%d", &price[0]);
 min = price[0];

 for(i = 1;i < Time;i++) {
   scanf("%d", &price[i]);
 if ((price[i] - min) >= profit) {
       profit = price[i] - min;
   }
   if (price[i] < min) {
       min  = price[i];
   }   
 }
  
 printf("%d\n",profit);
  
 return 0;
}

Measured memory_bytes: 2640
#include <stdio.h>
#define N 500000

int A[N],H;

void swap(int *a, int *b){
  int tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}

void maxHeapify(int *A, int i){
  int l,r,largest;
  l=2*i;
  r=(2*i)+1;
  
  if(l<=H && A[l] > A[i]) largest=l;
  else largest=i;
  if(r<=H && A[r] > A[largest]) largest=r;

  if(largest != i){
    swap(&A[i],&A[largest]);
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i=H/2;i>=1;i--) maxHeapify(A,i);
}

int main(){
  int i;
  A[0]=0;
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);

  buildMaxHeap(A);

  for(i=1;i<=H;i++) printf(" %d",A[i]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 3684
N, M = (int(x) for x in input().split()) 

like = []
cnt = 0

for i in range(N):
	like.append([int(x) for x in input().split()][1:])

for j in range(1, M+1):
	if all([j in x for x in like]):
		cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	string str;
	cin >> str;
	int k;
	scanf("%lld", &k);
	int ans = 1;
	int n = str.size();
	rep(i,n){
		if(str[i] != '1'){ans = str[i]-'0';break;}
		if(i+1 == k)break;
	}
	printf("%lld\n", ans);
	return 0;
}






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

typedef long long LL;

const int N=200000,mod=998244353;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
int Power(int a,int k,int p=mod){int res=1;for (;k;k>>=1,smul(a,a,p)) if (k&1) smul(res,a,p);return res;}

int n;

void into(){
  scanf("%d",&n);
}

struct tree{
  int pw,sum,cov;
}tr[N*4+9];

void Pushup(int k){tr[k].sum=add(tr[k<<1].sum,tr[k<<1|1].sum);}
void Update_cov(int k,int v){tr[k].cov=v;tr[k].sum=mul(v,tr[k].pw);}

void Pushdown(int k){
  if (!tr[k].cov) return;
  Update_cov(k<<1,tr[k].cov);
  Update_cov(k<<1|1,tr[k].cov);
  tr[k].cov=0;
}

void Build(int l,int r,int k){
  if (l==r) {tr[k].pw=tr[k].sum=Power(10,n-l);return;}
  int mid=l+r>>1;
  Build(l,mid,k<<1);
  Build(mid+1,r,k<<1|1);
  Pushup(k);
  tr[k].pw=add(tr[k<<1].pw,tr[k<<1|1].pw);
}

void Change_cov(int L,int R,int v,int l,int r,int k){
  if (L<=l&&R>=r) {Update_cov(k,v);return;}
  int mid=l+r>>1;
  Pushdown(k);
  if (L<=mid) Change_cov(L,R,v,l,mid,k<<1);
  if (R>mid) Change_cov(L,R,v,mid+1,r,k<<1|1);
  Pushup(k);
}

void work(){
  Build(1,n,1);
}

void outo(){
  int cq;
  scanf("%d",&cq);
  for (;cq--;){
	int l,r,v;
	scanf("%d%d%d",&l,&r,&v);
	Change_cov(l,r,v,1,n,1);
	printf("%d\n",tr[1].sum);
  }
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 9968
'use strict';
(function(stdin) {
  var inputs  = stdin.toString();
  var cols =inputs.split('/n')[0].split(' ').map(Number);
  var a = cols[0];
  var b = cols[1];
  var c = cols[2];
  if (a<b && b<c){
    console.log('Yes');
  }else {
    console.log('No');
  }


  
 
  
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376