akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <tuple>
using namespace std;

typedef pair<int,int> P;//駅id,会社id(0は改札外)
map<P,map<P,int>> G;//エッジリスト(キモい)
map<P,int> memo;
const int INF = 1000000000;
typedef tuple<int,int,int> T;//cost,駅id,会社id
priority_queue<T,vector<T>,greater<T>> que;
#define mygc(c) (c)=getchar_unlocked()
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;} }for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}

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

    int N,M;
    //cin>>N>>M;
    reader(&N); reader(&M);
    for(int i=1;i<=N;i++) memo[P(i,0)]=INF;
    for(int i=0;i<M;i++){
        int p,q,c;
        //cin>>p>>q>>c;
        reader(&p); reader(&q); reader(&c);
        G[P(p,c)][P(q,c)]=0;
        G[P(p,c)][P(p,0)]=0;
        G[P(p,0)][P(p,c)]=1;
        G[P(q,c)][P(p,c)]=0;
        G[P(q,c)][P(q,0)]=0;
        G[P(q,0)][P(q,c)]=1;
        memo[P(p,c)]=memo[P(q,c)]=INF;
    }
    memo[P(1,0)]=0;
    que.emplace(0,1,0);
    while(!que.empty()){
        T t = que.top(); que.pop();
        int cost=get<0>(t), station=get<1>(t), company=get<2>(t);
        if(station==N){
            cout<<cost<<endl;
            return 0;
        }
        if(cost>memo[P(station,company)]) continue;
        if(cost>memo[P(station,0)]+1) continue;
        for(auto &g:G[P(station,company)]){
            const P &p = g.first; int fee=g.second;
            if(cost+fee<memo[p]){
                memo[p]=cost+fee;
                que.emplace(cost+fee,p.first,p.second);
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 121204
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  std::vector<int> t(D);
  for(int i = 0; i < D; ++i) t[i] = i%26;
  std::set<int> last[26];
  for(auto& li: last) li.insert(-1); // sentinel
  int ans = 0;
  for(int d = 0; d < D; ++d) {
    int t1 = t[d];
    ans += s[d][t1];
    last[t1].insert(d);
    for(int i = 0; i < 26; ++i) {
      ans -= c[i]*(d - *last[i].rbegin());
    }
  }
  for(auto& li: last) li.insert(D); // sentinel
  
  // additional score when t[d] = i compare to t[d] = -1
  auto sum_up = [](int d) { return d*(d-1)/2; };
  auto score = [&](int d, int i)->int {
    int res = s[d][i];
    auto it = last[i].lower_bound(d);
    int nd = *it;
    int pd = *--it;
    int diff = sum_up(d-pd) + sum_up(nd-d) - sum_up(nd-pd);
    res -= c[i]*diff;
    return res;
  };
  int lm = 0, renew = 0;
  int sc[26];
  auto one_day = [&](int d) {
    int pi = t[d];
    last[pi].erase(d);
    for(int i = 0; i < 26; ++i) sc[i] = score(d, i);
    int mi = std::max_element(sc, sc+26) - sc;
    if(mi != pi) {
      t[d] = mi;
      ans += sc[mi] - sc[pi];
      ++renew;
    }
    last[mi].insert(d);
  };
  
  // hill climbing
  int range = 50;
  for(int rep = 0;; ++rep) {
    if((xor64()>>25)%2) {
      one_day(xor64()%365);
    } else {
      // swap
      int d1 = xor64()%D, d2 = xor64()%D;
      while(d1 < d2-range || d2 < d1-range || t[d1] == t[d2]) {
          d1 = xor64()%D; d2 = xor64()%D;
      }
      int pi1 = t[d1], pi2 = t[d2];
      last[pi1].erase(d1);
      int diff = score(d1, pi2) - score(d1, pi1);
      last[pi2].insert(d1);
      last[pi2].erase(d2);
      diff += score(d2, pi1) - score(d2, pi2);
      if(diff > 0) {
        last[pi1].insert(d2);
        t[d1] = pi2;
        t[d2] = pi1;
        lm = 0;
      } else {
        last[pi2].insert(d2);
        last[pi2].erase(d1);
        last[pi1].insert(d1);
      }
    }
    if(rep%100 == 0) {
      int x = get_time();
      if(x > 1980) break;
      if(x > 200) range = 25;
      if(x > 400) range = 20;
      if(x > 700) range = 15;
      if(x > 1000) range = 10;
    }
  }
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


Measured memory_bytes: 3724
import std,core.bitop;
int l,n,i;
void q(int[]a...){a.writefln!"%(%s %)";}
void main(){
  l.readf!"%d";
  for(i=l;i;i/=2)n++;
  q(n,l.popcnt+n*2-3);
  for(i=1;l>1;i++)l%2&&q(i,n,l-1),q(i,i+1,l/=2),l&&q(i,i+1,0);
}


Measured memory_bytes: 3652
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  vi d(n);
  rep0(i,n){
    cin >> d[i];
  }
  ll ans = 0;
  rep0(i,n){
    for(int j = i+1; j < n; j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int a,b;
  cin>>a>>b;
  if(b%a==0) cout<<a+b<<endl;
  else cout<<b-a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> s(n);
	rep(i, n) cin >> s[i];
	int sum = 0;
	rep(i, n) sum += s[i];
	if(sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	sort(all(s));
	rep(i, n) {
		if(s[i] % 10 != 0) {
			cout << sum - s[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
S = input().split(" ")
n = int(S[0])
k = int(S[1])

arr = []
for i in range(n):
  arr.append(int(input()))

def calculate(n, k, arr):
    drr = []
    arr.sort()
    for i in range(1,n):
      drr.append(arr[i] - arr[i-1])

    s = 0
    j = 0
    sums = []
    for i in range(len(drr)- (k-1) + 1):
      while j < i + (k-1):
        s = s + drr[j]
        j = j + 1
      sums.append(s)
      s = s - drr[i]
    print(min(sums))

calculate(n, k, arr)




Measured memory_bytes: 15564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e2+5;
int n,x,ans,minn,m[maxn][maxn],d[maxn],fa[maxn],vis[maxn];
int main(){
	n=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			x=read();
			m[i][j]=(x==-1)?INF:x;
		}
	for(int i=1;i<=n;i++) d[i]=INF;
	d[1]=0;
	int u;
	while(1){
		u=0;
		minn=INF;
		for(int i=1;i<=n;i++)
			if(minn>d[i]&&!vis[i]){
				u=i;
				minn=d[i];
			}
		if(u==0) break;
		vis[u]=1;
		for(int i=1;i<=n;i++)
			if(!vis[i]&&m[u][i]!=INF&&d[i]>m[u][i]){
				d[i]=m[u][i];
				fa[i]=u;
			}	
	}
	for(int i=1;i<=n;i++)
		if(fa[i]) ans+=m[i][fa[i]];
	printf("%d\n",ans);
	return 0;
}


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

int main() {
	string s;
	int num[4] = { 0, 0, 0, 0 };
	while (cin >> s) {
		s = s.substr(s.find(',')+1);
		if (s == "A") num[0]++;
		else if (s == "B") num[1]++;
		else if (s == "AB") num[2]++;
		else num[3]++;
	}
	cout << num[0] << endl;
	cout << num[1] << endl;
	cout << num[2] << endl;
	cout << num[3] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b, q;
    cin >> a >> b >> q;

    vll s(a + 2), t(b + 2);
    s[0] = -1e18, t[0] = -1e18, s[a + 1] = 1e18, t[b + 1] = 1e18;
    REP(i, a) cin >> s[i + 1];
    REP(i, b) cin >> t[i + 1];

    ll x;
    vll spos(2), tpos(2);
    while(q){
        cin >> x;
        //s[l]...x...s[r]
        ll rs = lower_bound(ALL(s), x) - s.begin();
        ll rt = lower_bound(ALL(t), x) - t.begin();
        spos[0] = s[rs];
        spos[1] = s[rs - 1];
        tpos[0] = t[rt];
        tpos[1] = t[rt - 1];
        ll res = 1e18;
        REP(i, 2){
            REP(j, 2){
                res = min(res, abs(x - spos[i]) + abs(tpos[j] - spos[i]));
                res = min(res, abs(x - tpos[i]) + abs(spos[j] - tpos[i]));
            }
        }
        cout << res << endl;
        q--;
    }
    return 0;
}

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

int main() {
    int e[4];
    for (int i = 0; i < 4; i++) {
        cin >> e[i];
    }
    sort(e, e + 4);
    if (e[0] == e[1] && e[2] == e[3]) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
}


Measured memory_bytes: 3164
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    let a: u32 = iter.next().unwrap().parse().unwrap();
    iter.next();
    iter.next();
    iter.next();
    let e: u32 = iter.next().unwrap().parse().unwrap();
    
    let k: u32 = iter.next().unwrap().parse().unwrap();
    
    if e - a > k {
        println!(":(");
    } else {
        println!("Yay!");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll mod = 1e9+7; 
ll pre[123456], cur[123456];
vector <ll> vec;



int main()
{
   ll n, k;
   cin >> n >> k;
   vec.resize(n+1);

   for(int i = 1; i <= n; i++){
       cin >> vec[i];
   }
   pre[0] = 1LL;
   for(int i = 1; i <= n; i++){
       for(int j = 1; j <= k; j++){
           pre[j] = pre[j]+pre[j-1];
           pre[j] %= mod;
       }
       for(int j = 0; j <= k; j++){
           ll val = pre[j];
           if(j > vec[i]) val -= pre[j-vec[i]-1];
           if(val < 0) val += mod;
           cur[j] = val;
           //cout << i << "|" << j << "|" << val << endl;
       }
       for(int j = 0; j <= k; j++)pre[j] = cur[j];
   }

   cout << cur[k];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)   //test cases
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define error(x) fixed<<setprecision(x) //cout<<error(5)<<someDouble    -> example - 3.14159
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll it = 0; it < n; it++)    cin>>a[it];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

ll n, comp[21][21], dp[21][1<<21];
ll count(ll i, ll mask){
	if(i == n)	return 1;
	if(dp[i][mask] != -1)	return dp[i][mask];
	ll ans = 0;
	for(ll j = 0; j < n; j++)
		if(comp[i][j] && !((1<<j)&mask))	ans = mop(ans, +, count(i+1, mask | (1<<j)));
	return dp[i][mask] = ans;
}
int main(){
	init();	fill(dp, -1);
	cin>>n;	for(ll i = 0; i < n; i++)	get(comp[i], n);
	cout<<count(0, 0);
}

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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

void dfs(int idx, bool *used, vector< int > &order, vector< int > *g)
{
  if(used[idx]++) return;
  for(auto &to : g[idx]) dfs(to, used, order, g);
  order.push_back(idx);
};

void rdfs(int idx, int k, int *cmp, vector< int > *rg)
{
  if(~cmp[idx]) return;
  cmp[idx] = k;
  for(auto &to : rg[idx]) rdfs(to, k, cmp, rg);
};

int main()
{
  int N;
  double p[100];
  int cmp[100];
  bool used[100];
  bool in[100];

  while(scanf("%d", &N), N) {
    vector< int > g[100], rg[100];

    for(int i = 0; i < N; i++) {
      int M;
      scanf("%lf %d", &p[i], &M);
      while(M--) {
        int a;
        scanf("%d", &a);
        g[i].push_back(--a);
        rg[a].push_back(i);
      }
    }

    vector< int > order;
    memset(cmp, -1, sizeof(cmp));
    memset(used, false, sizeof(used));
    memset(in, 0, sizeof(in));
    for(int i = 0; i < N; i++) dfs(i, used, order, g);
    reverse(begin(order), end(order));
    for(int i : order) rdfs(i, i, cmp, rg);

    for(int i = 0; i < N; i++) {
      for(int &to : g[i]) in[cmp[to]] += cmp[i] != cmp[to];
    }
    double ret = 1.0;
    for(int i = 0; i < N; i++) {
      if(cmp[i] == i && !in[cmp[i]]) {
        double curr = 1.0;
        for(int j = 0; j < N; j++) {
          if(cmp[i] == cmp[j]) curr *= p[j];
        }
        ret *= 1 - curr;
      }
    }
    cout << fixed << setprecision(10) << ret << endl;
  }
}

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

int main(){
    int D;
    cin >> D;
    vector<int> c(27, 0);
    vector<int> sum(27, 0);
    rep(j, 26){
        cin >> c[j+1];
        sum[j+1] = sum[j] + c[j+1];
    }

    int s[D+1][27];
    rep(i, D){
        rep(j, 26){
            cin >> s[i+1][j+1];
        }
    }
    // vector<int> t(D+1, 0);
    // rep(i, D) cin >> t[i+1];
    int val;
    int now;

    rep(i, D){
        val = ( (rand() << 5) + rand() )%sum[26];
        now = 1;
        while( (sum[now] < val) && (now <= 25) ){
            now++;
        }
        cout << now << endl;
    }

    // int M;
    // M = 0;
    // // cin >> M;
    // vector<int> d(M+1, 0);
    // vector<int> q(M+1, 0);
    // // rep(i, M) cin >> d[i+1] >> q[i+1];

    // ll ans = 0;
    // vector<int> lastday(27, 0);

    // for(int day = 1; day <= D; day++){
    //     ans += s[day][t[day]];
    //     lastday[t[day]] = day;
    //     for(int j = 1; j <= 26; j++){
    //         ans -= c[j] * (day - lastday[j]); 
    //     }
    // }

    // for(int que = 1; que <= M; que++){
    //     ans -= s[d[que]][t[d[que]]];
    //     ans += s[d[que]][q[que]];

    //     int before = 0;
    //     for(int pos = d[que] - 1; pos >= 1; pos--){
    //         if (t[pos] == t[d[que]]){
    //             before = pos;
    //             break;
    //         }
    //     }
    //     int after = D+1;
    //     for(int pos = d[que] + 1; pos <= D; pos++){
    //         if (t[pos] == t[d[que]]){
    //             after = pos;
    //             break;
    //         }
    //     }
    //     ans += c[t[d[que]]] * (after - d[que]) * (before - d[que]);

    //     before = 0;
    //     for(int pos = d[que] - 1; pos >= 1; pos--){
    //         if (t[pos] == q[que]){
    //             before = pos;
    //             break;
    //         }
    //     }
    //     after = D+1;
    //     for(int pos = d[que] + 1; pos <= D; pos++){
    //         if (t[pos] == q[que]){
    //             after = pos;
    //             break;
    //         }
    //     }
    //     ans -= c[q[que]] * (after - d[que]) * (before - d[que]);

    //     t[d[que]] = q[que];
    //     // cout << ans << endl;
    // }

    // rep(i, D){
    //     cout << t[i+1] << endl;
    // }
    // cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3664
#include <cstdio>
#include <string.h>
#include <vector>

using namespace std;

namespace {

class Dictionary {
 private:
  struct Node {
    Node* children[4];
    char flags[4];

    Node() {
      children[0] = NULL;
      children[1] = NULL;
      children[2] = NULL;
      children[3] = NULL;
      flags[0] = 0;
      flags[1] = 0;
      flags[2] = 0;
      flags[3] = 0;
    }
  };

 public:
  Dictionary()
      : root_(new Node),
        block_size_(4096),
        pool_index_(0),
        block_index_(0) {
    pool_.push_back(new Node[block_size_]);
  }

  ~Dictionary() {
    for (size_t i = 0; i < pool_.size(); ++i) {
      delete[] pool_[i];
    }
    delete root_;
  }

  void insert(const char* k, size_t n) {
    Node* p = root_;
    int id = 0;
    for (size_t i = 0; i < n; ++i) {
      const char c = k[i];
      id = Id(c);
      if (!p->children[id]) {
        p->children[id] = Alloc();
      }
      p = p->children[id];
    }
    p->flags[id] = 1;
  }

  bool find(const char* k, size_t n) const {
    Node* p = root_;
    int id = 0;
    for (size_t i = 0; i < n; ++i) {
      const char c = k[i];
      id = Id(c);
      p = p->children[id];
      if (!p) {
        return false;
      }
    }
    if (!p) {
      return false;
    }
    return p->flags[id];
  }

 private:
  Node* root_;

  static int Id(char c) {
      switch (c) {
        case 'A':
          return 0;
        case 'C':
          return 1;
          break;
        case 'G':
          return 2;
          break;
        case 'T':
          return 3;
          break;
      }
      // should not reach here.
      return 0;
  }

  Node* Alloc() {
    if (block_index_ >= block_size_) {
      pool_.push_back(new Node[block_size_]);
      pool_index_++;
      block_index_ = 0;
    }
    Node* r = &pool_[pool_index_][block_index_];
    block_index_++;
    return r;
  }

  size_t block_size_;
  size_t pool_index_; // pos in pool
  size_t block_index_; // pos in the block
  vector<Node* > pool_;
};

} // namespace

int main() {
  int n;
  scanf("%d", &n);

  Dictionary d;
  char op[7];
  char str[13];
  for (int i = 0; i < n; ++i) {
    scanf("%s ", op);
    scanf("%s", str);
    const char c = op[0];
    const size_t len = strnlen(str, 13);
    if (c == 'i') {
      d.insert(str, len);
      continue;
    }

    if (d.find(str, len)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 3005;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll arr[MX],dp[MX][MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N; cin >> N;

    F0R(i,N) cin >> arr[i];

    R0F(i,N) {
        FOR(j,i,N) {
            if (i == j) dp[i][j] = arr[i];
            else dp[i][j] = max(arr[i]-dp[i+1][j], arr[j]-dp[i][j-1]);
        }
    }

    cout << dp[0][N-1] << "\n";

}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen=1<<18|1;
inline char gc(){
	static char buf[rlen],*ib,*ob;
	(ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin));
	return ib==ob?-1:*ib++;
}
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
const int mod=1e9+7;
typedef pair<int,int> pii;
typedef long long ll;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int&a,int b){(a+=b)<mod?a:(a-=mod);}
inline void Dec(int&a,int b){(a-=b)<0?(a+=mod):a;} 
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))if(p&1)Mul(ret,a);return ret;}
const int N=200005;
char s[N];
int n,f[N][2],a[N],fac[N],ifac[N];
inline int C2(int n){return (ll)n*(n-1)/2%mod;}
inline int lowbit(const int&x){return x&-x;}
inline int calc(int x){
	int ret=1;
	while(x^1)++ret,x>>=1;
	return ret;
}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	for(ri i=1;i<=n;++i,puts(""))for(ri j=i+1;j<=n;++j)cout<<calc(lowbit(i^j))<<' ';
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = 0 ; i <= 10000 ; i++) {
            if (Math.floor(i * 0.08) == a && Math.floor(i * 0.1) == b) {
                System.out.println(i);
                return;
            }
        }
      System.out.println(-1);
    }

}

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

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

    if( (A == B && B != C) ||
        (B == C && C != A) ||
        (C == A && A != B)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;

int d, n;
int a[100], e[100], r[100];
//int ma[101];
int dp[101][101];

int main()
{
	while (scanf("%d %d", &d, &n), d){
		fill((int *)dp, (int *)dp + sizeof(dp) / sizeof(int), INF);
		dp[0][0] = 0;
		
		for (int i = 0; i < n; i++){
			scanf("%d %d %d", &a[i], &e[i], &r[i]);
		}
		
		for (int i = 0; i < d; i++){
			for (int j = 0; j <= 100; j++){
				for (int t = 0; t < n; t++){
					if (j < r[t]) continue;
					int nd = min(i + a[t], d);
					int ne = min(j + e[t], 100);
					dp[nd][ne] = min(dp[nd][ne], dp[i][j] + 1);
				}
			}
		}
		
		int res = INF;
		for (int i = 0; i <= 100; i++){
			res = min(res, dp[d][i]);
		}
		if (res - INF) printf("%d\n", res);
		else puts("NA");
	}
	
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    if(n >= b-1){
        cout << (a*(b-1))/b - a*((b-1)/b) << endl;
    }else{
        cout << (a*n)/b - a*(n/b) << endl;
    }
    return 0;
}

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

    char inputArray[1028];
    int slimeArray[10080];
    char str[31];
    int slimeNum;
    int changeCount;
void loadData(){
    fgets(str,31,stdin);//1行読み込む

    fgets(inputArray,256,stdin);
 //   printf("入力 %s\n",inputArray);
    char w[256];
    int i,j,k;

    j=0;
    k=0;
    for(i=0;inputArray[i]!='\0';i++){
        if(inputArray[i]==' '){
        w[j]='\0';
        slimeArray[k++]=atoi(w);
        j=0;
        }
        w[j++]=inputArray[i];
    }
        w[j]='\0';
        slimeArray[k++]=atoi(w);

    //for(i=0;i<k;i++)printf("%d\n",slimeArray[i]);
    slimeNum = k;

}
int checkColor(int i){
    return slimeArray[i-1] - slimeArray[i];
}
void checkArray(){
    for(int i = 1;i < slimeNum;i++){
        if(checkColor(i)==0){
            slimeArray[i]+=2;
            if(checkColor(i+1)==0)
            slimeArray[i]++;
            changeCount++;
        }
    }

}


int main(void){
    loadData();
    checkArray();
 /*   for(int i = 0;i < slimeNum;i++){
        printf("color : %d\n",slimeArray[i]);
    }*/
    
    printf("%d\n",changeCount);


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M, Q;
  cin >> N >> M >> Q;
  vll a(Q), b(Q), c(Q), d(Q);
  for(int i = 0; i < Q; i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--; b.at(i)--;
  }

  vll num(N, 0);
  
  auto calc = [&]{
    ll sum = 0;
    for(int i = 0; i < Q; i++){
      if(num.at(b.at(i)) - num.at(a.at(i)) == c.at(i)) sum += d.at(i);
    }
    return sum;
  };
  function<ll(ll, ll)> dfs = [&](ll depth, ll x){
    num.at(depth-1) = x;
    if(depth == N) return calc();

    ll res = 0;
    for(int i = x; i <= M; i++){
      chmax(res, dfs(depth+1, i));
    }
    return res;
  };
  
  cout << dfs(1, 1) << endl;
  
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N,M,X=0;
    cin >> N;
    vector<string>blue(N);

    for(int i = 0;i < N;i++)
        cin >> blue.at(i);

    cin >> M;

    vector<string>red(M);

    for(int i = 0;i < M;i++)
        cin >> red.at(i);

    map<string,int>mpa;
    set<string>ss;

    for(int i = 0;i < N;i++){
        mpa[blue.at(i)]++;
        ss.insert(blue.at(i));
    }
    for(int i = 0;i < M;i++){
        mpa[red.at(i)]--;
        ss.insert(red.at(i));
    }

    for(auto x:ss){
        if(X < mpa[x])
            X = mpa[x];
    }

    cout << X <<endl;
    
    
}

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

    public static void main(String[] args) {
        Scanner Ent = new Scanner(System.in);
        int a = Ent.nextInt();
        int b = Ent.nextInt();
        int suma1 = 2*a - 1;
        int suma2 = 2*b - 1;
        int suma3 = a + b;
        System.out.println(Math.max(suma1, Math.max(suma2, suma3)));
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
#define ONLINE_JUDGE
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
int n, m;
int a, b;
int c, d;
inline bool bound(int i, int j) {
    if (i<0 or i >= n or j<0 or j >= m) {
        return 0;
    }
    return 1;
}
int f(vector<char>maze[]) {
    map<pair<int, int>, int>dist;
    dist[ {a, b}] = 0;
    map<pair<int, int>, int>vis;
    vis[ {a, b}] = 1;
    set<pair<int, pair<int, int>>>s;
    s.insert({0, {a, b}});
    while (!s.empty()) {
        pair<int, pair<int, int>>p = *s.begin();
        s.erase(s.begin());
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int u = p.ss.ff + i, v = p.ss.ss + j;
                if (bound(u, v) and maze[u][v] == '.' and !(i == 0 and j == 0)) {
                    pair<int, pair<int, int>>temp;
                    temp.ff = p.ff + 1;
                    if (abs(i) + abs(j) == 1) {
                        temp.ff--;
                    }
                    if (dist.count({u, v}) != 0 and dist[ {u, v}] <= temp.ff) {
                        continue;
                    }
                    if (dist.count({u, v}) != 0) {
                        s.erase({dist[{u, v}], {u, v}});
                    }
                    dist[ {u, v}] = temp.ff;
                    temp.ss = {u, v};
                    s.insert(temp);
                }
            }
        }
    }

    if (dist.count({c, d}) == 0) {
        return -1;
    }
    return dist[ {c, d}];
}
inline void solve() {
    cin >> n >> m;
    cin >> a >> b >> c >> d;
    a--; b--; c--; d--;
    vector<char>maze[n];
    fl(i, 0, n - 1) {
        maze[i].resize(m);
        fl(j, 0, m - 1) {
            char ch; cin >> ch;
            maze[i][j] = ch;
        }
    }
    cout << f(maze) << endl;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 35736
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    
    int ans = 0;
    for(int i = 0; i <= k; i++){
        // 左からi個取る
        vector<int> take;
        int pos = 0;
        for(int j = 0; j < i && pos < n; j++){
            take.push_back(v[pos]);
            pos++;
        }
        if(pos == n){
            sort(take.begin(), take.end());
            for(int j = 0; j < min(k-i, (int)take.size()); j++){
                take[j] = max(take[j], 0);
            }
            ans = max(ans, accumulate(take.begin(), take.end(),0));
            continue;
        }
        for(int j = 0; j <= k-i; j++){
            // 右からi個取る
            vector<int> ntake = take;
            int rvpos = n-1;
            for(int x = 0; x < j && rvpos >= pos; x++){
                ntake.push_back(v[rvpos]);
                rvpos--;
            }
            sort(ntake.begin(), ntake.end());
            for(int x = 0; x < min(max(k-i-j, 0), (int)ntake.size()); x++){
                ntake[x] = max(ntake[x], 0);
            }
            ans = max(ans, accumulate(ntake.begin(), ntake.end(),0));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int MAX = 400000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	long long n,k,res=1;
	cin>>n>>k;
	COMinit();
	res=COM(2*n-1,n)%MOD;
	if(k<n){
		for(int i=k+1;i<n;i++){
			res-=(COM(n-1,i)*COM(n,i))%MOD;
			if(res<0)res+=MOD;
		}
		if(res<0)res+=MOD;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 9600
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

bool gauss(vector<vector<long double> > &a){
	if(a.empty())return false;
	int n=a.size();
	for(int i=0;i<n;i++){
		if(!a[i][i]){
			int j=i+1;
			for(;j<n;j++){
				if(a[j][i]){
					for(int k=i;k<=n;k++)a[i][k]+=a[j][k];
					break;
				}
			}
			if(j==n)return false;
		}
		for(int j=0;j<n;j++)if(i!=j){
			long double r=a[j][i]/a[i][i];
			for(int k=i;k<=n;k++)a[j][k]=a[j][k]-a[i][k]*r;
		}
	}
	for(int i=0;i<n;i++){
		long double x=a[i][i];
		for(int j=0;j<a[i].size();j++)a[i][j]/=x;
	}
	return true;
}
long long comb(int n,int k){
	if(k>n-k)k=n-k;
	long long r=1;
	for(int i=0;i<k;i++)r=r*(n-i)/(i+1);
	return r;
}
long long pow_binary(long long x,long long y){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x;
		x=x*x;
	}
	return z;
}
int main(){
	int A,M,B,N;
	for(;scanf("%d%d%d%d",&A,&M,&B,&N),A;){
		vector<vector<long double> >m(M*N+1);
		for(int i=0;i<=M*N;i++)m[i].resize(M*N+2);
		m[0][0]=m[0][M*N+1]=1;
		for(int i=0;i<=M*N;i++)for(int k=0;k<=i;k++){
			m[k%M*N+(i-k)%N+1][i<M*N ? i+1 : 0]+=(long double)comb(i,k)*pow_binary(A,k/M)*pow_binary(B,(i-k)/N);
		}
		gauss(m);
		printf("1");
		for(int i=M*N;i>0;i--)printf(" %d",(int)(roundl(m[i][M*N+1])));
		puts("");
	}
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <pair<ll, ll>> rlNum;
	vector <ll> boundary;
	bool isR = true;
	ll rCnt = 1;
	ll lCnt = 0;
	for (int ii = 0; ii < S.size()-1; ++ii){
		if (isR && (S[ii+1]=='R')){
			rCnt++;
		}
		if (!isR && (S[ii+1]=='L')){
			lCnt++;
		}
		if (isR && (S[ii+1]=='L')){
			boundary.push_back(ii);
			isR = false;
			lCnt = 1;
		}
		if (!isR && (S[ii+1]=='R')){
			isR = true;
			rlNum.push_back(make_pair(rCnt, lCnt));
			lCnt = 0;
			rCnt = 1;			
		}
	}
	rlNum.push_back(make_pair(rCnt, lCnt));

	ll N = S.size();
	vector <ll> ans(N, 0);

	for (int ii = 0; ii < rlNum.size(); ++ii){
		ll rNum = rlNum[ii].first;
		ll lNum = rlNum[ii].second;
		ll idx = boundary[ii];
		if ( (rNum % 2) == (lNum % 2) ){
			ans[idx] = (rNum + lNum) / 2;
			ans[idx+1] = (rNum + lNum) / 2;
		} else {
			ll large = (rNum + lNum+1) / 2;
			ll small = large - 1;
			if (rNum > lNum){
				if (rNum % 2 == 0){
					ans[idx] = small;
					ans[idx+1] = large;
				} else {
					ans[idx] = large;
					ans[idx+1] = small;
				}
			} else {
				if (lNum % 2 == 0){
					ans[idx] = large;
					ans[idx+1] = small;
				} else {
					ans[idx] = small;
					ans[idx+1] = large;
				}				
			}
		}
	}

	for (int ii = 0; ii < N; ++ii){
		cout << ans[ii] << " ";
	}
	cout << "\n";


	return 0;
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll x,a;
    cin >> x >> a;
    cout << (x<a?0:10) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  vector<int> variety(30,0);
  int N,M;
  cin >> N >> M;
  rep(i, N){
  int K;
    cin >>K;
    int a;
    rep(j, K){
    cin >> a;
      variety[a-1]++;
    }
  }
  int ans=0;
  rep(i, 30){
  if(variety[i]==N)
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{ int a,b,x;
while(~scanf("%d %d %d",&a,&b,&x))
{
    if(a>x)
        printf("NO\n");
      else
    if(a+b<x)
        printf("NO\n");
      else
    if(a+b>x)
        printf("YES\n");


}
    return 0;
}


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

int n;
ll ara[100000 + 5];

ll check(ll k) {
    for(int i = 0; i < n; i++)
        k -= k % ara[i];
    return k;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) 
        cin >> ara[i];
    ll lo = 0, hi = 100000000000000, ans = -1;
    while(lo <= hi) {
        ll mid = (lo + hi) / 2;
        ll k = check(mid);
        if(k == 2) {
            ans = mid;
            hi = mid - 1;
        }
        else if(k > 2)
            hi = mid - 1;
        else
            lo = mid + 1;
    }
    
    if(ans != -1)
        cout << ans << " ";
    else {
        cout << -1 << endl;
        return 0;
    }
    
    lo = 0, hi = 100000000000000, ans = -1;
    while(lo <= hi) {
        ll mid = (lo + hi) / 2;
        ll k = check(mid);
        if(k == 2) {
            ans = mid;
            lo = mid + 1;
        }
        else if(k > 2)
            hi = mid - 1;
        else
            lo = mid + 1;
    }
    
    if(ans != -1)
        cout << ans << " ";
    else {
        cout << -1 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
using namespace std;
int main(){
	int n;
	cin >> n;
	map<int,int> a;
	for(int i=0;i<n;i++){
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	int cnt=0;
	for(auto i=a.begin();i!=a.end();i++){
		cnt+=i->second-1;
	}
	int ans=cnt+cnt%2;
	cout << n-ans << endl;
	return 0;
}


Measured memory_bytes: 4992
m[5]['= r'],z,d[4]={0,-2},k,i;f(i){m[k][i]=i[*m]+47?0:m[k][i]?:1+f(d[k-1]-~i);}main(t){for(scanf("%*d%d",d),d[2]=-*d-2;m[0][++i-~*d]=~getchar(););for(;--i;z=fmax(z,t))for(t=k=0;k<4;t+=f(i-~*d))++k;printf("%d",z-3);}

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

bool g[51][51];
bool gg[51][51];

bool cone(int n){
  bool rtn=true;
  bool ck[n+1] = {false, true};
  for(int k=0; k<n; k++)
    for(int i=1; i<=n; i++)
      for(int j=i+1; j<=n; j++)
        if(gg[i][j] && (ck[i] || ck[j]))
          ck[i]=true, ck[j]=true;

  for(int i=1; i<=n; i++)
    if(ck[i]==false) rtn = false;

  return rtn;
}

bool coneRemoveAB(int n, int a, int b){
  for(int i=1; i<=n; i++)
    for(int j=1; j<=n; j++)
      gg[i][j] = g[i][j];

  gg[a][b]=false;
  gg[b][a]=false;

  return cone(n);
}


int main(void){
  int n, m;
  cin >> n>> m;

  int a[m], b[m];
  for(int i=0; i<m; i++){
    cin >> a[i] >> b[i];
    g[a[i]][b[i]] = true;
    g[b[i]][a[i]] = true;
  }

  int mminusans = 0;
  for(int i=0; i<m; i++)
    if(coneRemoveAB(n, a[i], b[i]))mminusans++;

  int ans = m - mminusans;

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


Measured memory_bytes: 256
n, k = map(int, input().split())

if k % 2 != 0:
    x1 = n // k
    print(x1 ** 3)
else:
    x1 = n // k
    x2 = n // (k // 2)
    print(x1 ** 3 + (x2 - x1) ** 3)

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

int main()
{
    int N, k;
    cin >> N >> k;
    for (int i = 1; i <= N; i++) {
        int tmp;
        scanf("%d", &tmp);
    }

    int cnt = 0;
    N = N - k;
    cnt++;

    cnt += ceil((double)N/(k-1));


    cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MAXN = 105;
using lint = long long;
using pi = pair<int, int>;

int n, W, w[MAXN], v[MAXN];
int dp[MAXN][3 * MAXN];

int main(){
	cin >> n >> W;
	for(int i=0; i<n; i++){
		cin >> w[i] >> v[i];
		int d = w[i] - w[0];
		for(int j=i; j>=0; j--){
			for(int k=3*i; k>=0; k--){
				dp[j+1][k+d] = max(dp[j+1][k+d], dp[j][k] + v[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0; i<=n; i++){
		for(int j=0; j<=3*n; j++){
			if(1ll * i * w[0] + j <= W){
				ans = max(ans, dp[i][j]);
			}
		}
	}
	cout << ans << endl;
}


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

main()
{
    int w,a,b,res;
    cin>>w>>a>>b;
    if((a<b && (a+w)>b) || (a>b && (b+w)>a) || a==b)
        cout<<"0"<<endl;
    else if(a<b)
        cout<<b-(w+a)<<endl;
    else if(a>b)
        cout<<a-(w+b)<<endl;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int h,a;
    R(h,a);
    int an=0;
    while(h>0){
        h-=a;
        an++;
    }
    W(an);
    return 0;
}


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

int main(){
  int n,m,c;
  cin >>n >>m >>c;
  vector<int> b(m);
  rep(i,m) cin >>b[i];
  vector<vector<int>> a(n, vector<int>(m));
  rep(i,n){
    rep(j,m){
      cin >>a[i][j];
    }
  }
  int cnt = 0;
  rep(i,n){
    int sum = c;
    rep(j,m){
      sum += a[i][j]*b[j];
    }
    if(sum > 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
fn read_line() -> String {
  let mut tmp = String::new();
  std::io::stdin().read_line(&mut tmp).unwrap();
  tmp.trim().to_string()
}

fn solve(w: i32, cards: &Vec<i32>) -> i32 {
  let len = cards.len();
  if len == 1 {
    (cards[0] - w).abs()
  } else {
    std::cmp::max(
      (cards[len - 1] - w).abs(),
      (cards[len - 2] - cards[len - 1]).abs()
    )
  }
}

fn main() {
  let line1: Vec<i32> = read_line().split(" ").map(|x| x.parse().unwrap()).collect();
  let line2: Vec<i32> = read_line().split(" ").map(|x| x.parse().unwrap()).collect();
  println!("{}", solve(line1[2], &line2));
}

struct Input {
  n: usize,
  z: i32,
  w: i32,
  cards: Vec<i32>,
  ans: i32,
}

#[test]
fn test() {
  let tests = vec![
    Input { n: 3, z: 100, w: 100, cards: vec![10, 1000, 100], ans: 900 },
    Input { n: 3, z: 100, w: 1000, cards: vec![10, 100, 100], ans: 900 },
    Input { n: 5, z: 1, w: 1, cards: vec![1, 1, 1, 1, 1], ans: 0 },
    Input { n: 1, z: 1, w: 1, cards: vec![1000000000], ans: 999999999 },
  ];
  for test in &tests {
    let ans = solve(test.w, &test.cards);
    println!("{}", ans);
    assert_eq!(ans, test.ans);
  }
}


Measured memory_bytes: 4352
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = readline().strip()

    ans = 0
    acgt = ["A", "C", "G", "T"]
    for i in range(len(S)):
        for j in range(i, len(S)):
            flag = True
            for k in S[i:j+1]:
                if k in acgt:
                    continue
                else:
                    flag = False
            if flag:
                ans = max(ans, j - i + 1)

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, D, A;
  vector<lpair> H;

  cin >> N >> D >> A;
  H.resize(N);
  for (auto &in: H) {
    cin >> in.first >> in.second;
  }
  sort(ALL(H));

  vector<llong> rui = {0}, pos = {0};
  llong ans = 0;
  for (auto &h: H) {
    llong left = (--lower_bound(ALL(pos), h.first)) - pos.begin();
    llong need = max(0ll, h.second - A * (rui.back() - rui[left]));
    llong res = ceil(1.0 * need / A);
    ans += res;
    rui.push_back(rui.back() + res);
    pos.push_back(h.first + 2 * D);
    // cerr << left << " " << rui[left] << endl;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long N, K;
	cin >> N >> K;
	long long a[110000], x, y;
	for (int i = 0; i < N; i++) {
		cin >> x >> y;
		a[i] = 1000000 * x + y;
	}
	sort(a, a + N);
	int i = 0;
	while (K > 0) {
		K -= a[i] % 1000000;
		i++;
	}
	cout << a[i - 1] / 1000000;
}

Measured memory_bytes: 1024
s = input()
if s == 'SUN':
    print(7)
elif s =='MON':
    print(6)
elif s =='TUE':
    print(5)
elif s =='WED':
    print(4)
elif s =='THU':
    print(3)
elif s =='FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 2940