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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int mod = 998244353;

const int N = 111;
// long long rep[N][N];
// long long dp[N][N];

// int pw[N];

map<string, long long> dp;
map<string, long long> rep;

void f(const string& s) {
	if (dp.count(s)) return;
	int len = s.length();
	if (len == 1) {
		dp[s] = s[0] - '0' + 1;
		rep[s] = 0;
		return;
	}

	long long& d = dp[s] = 0;
	long long& r = rep[s] = 0;

	for (int k = 1; k < len; ++k) {
		if (len % k) continue;

		string hmm(k, '1');
		for (int i = 0; i < len; ++i) {
			hmm[i % k] = min(hmm[i % k], s[i]);
		}

		f(hmm);
		r += dp[hmm];
	}

	r %= mod;

	f(s.substr(0, len - 1));
	d = r + (s.back() - '0' + 1) * dp[s.substr(0, len - 1)];
	for (int k = 1; k < len; ++k) {
		f(s.substr(k));
		f(s.substr(0, k));
		auto rr = rep[s.substr(k)];
		auto dd = dp[s.substr(0, k)];
		d += dd * rr % mod;
	}
	d %= mod;

	// cerr << "dp['" << s << "'] = " << d << "\n";
	// cerr << "rep['" << s << "'] = " << r << "\n";
}

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

	// pw[0] = 1;
	// for (int i = 1; i < N; ++i) {
	// 	pw[i] = pw[i - 1] * 2 % mod;
	// }

	f(s);
	cout << dp[s] << "\n";

	// int n = s.length();
/*
	for (int len = 1; len <= n; ++len) {
		dp[i][i] = 1;
		for (int i = 0; i + len <= n; ++i) {
			int j = i + len - 1;

			for (int k = 1; k < len; ++k) {
				if (len % k) continue;

				vector<char> hmm(k, '1');
				for (int ij = 0; ij < len; ++ij) {
					hmm[ij % k] = min(hmm[ij % k], s[i + ij]);
				}

				int cnt = 0;
				for (int ij = 0; ij < k; ++ij) {
					cnt += hmm[ij] - '0';
				}

				rep[i][j] += pw[cnt];
			}

			rep[i][j] %= mod;

			dp[i][j] = rep[i][j] + (s[j] - '0' + 1) * dp[i][j - 1];
			for (int k = i + 1; k <= j; ++k) {
				dp[i][j] += dp[i][k - 1] * rep[k][j] % mod;
			}
			dp[i][j] %= mod;
		}
	}
*/
	// for (int i = 0; i < n; ++i) {
	// 	for (int j = i; j < n; ++j) {
	// 		cerr << "dp['" << s.substr(i, j - i + 1) << "'] = " << dp[i][j] << "\n";
	// 		cerr << "rep['" << s.substr(i, j - i + 1) << "'] = " << rep[i][j] << "\n";
	// 	}
	// }

	// cout << dp[0][n - 1] % mod << "\n";

	return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	string a;
	cin >> a;
	while(a.size() > 3) a.pop_back();
	cout << a;
	return 0;
}


Measured memory_bytes: 3652
import itertools
N,M=map(int,input().split())

slist=[]
for i in range(M):
  k,*sl=list(map(int,input().split()))
  sw=[0]*N
  for s in sl:
    sw[s-1]=1
  slist.append(sw)
  
qlist=list(map(int,input().split()))
#print(slist)
#print(qlist)

answer=0
for bit in itertools.product(range(2),repeat=N):
  for i in range(M):
    parity=0
    for j in range(N):
      parity+=slist[i][j]&bit[j]
    if qlist[i]!=parity%2:
      break
  else:
    answer+=1
    
print(answer)

Measured memory_bytes: 3064
var
  a,i,n,x,y:longint;
  ch:char;
  s:ansistring;
begin
  readln(s);
  n:=length(s);
  for i:=1 to n do
    begin
      ch:=s[i];
      a:=ord(ch)-ord('0');
      if a=i mod 2 then inc(x) else inc(y);
    end;
  if x>y then write(y) else write(x);
end.

Measured memory_bytes: 256
N, K = STDIN.gets.chomp.split(' ').map(&:to_i)

h = []
STDIN.each_line do |l|
  hn = l.to_i
  h.push(hn)
end

h.sort!

# puts h.join(',')
array = []

d = 0
min = h[K-1] - h[0]
((K-1)..(h.length-1)).each do |i|
  # puts "#{h[i]}-#{h[d]}"
  diff = h[i] - h[d]
  min = diff if diff < min
  d += 1
end

puts min



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

int main() {
  ll n;
  cin >> n;
  vector<ll> k(n,0);
  
  rep(i,n) {
    ll a;
    cin >> a;
    while (a % 2 == 0) {
      k[i]++;
      a /= 2;
    }
  }
  
  ll ans = 0;
  rep(i,n) ans += k[i];
  cout << ans << endl;
}

Measured memory_bytes: 384
from collections import *
from heapq import *
import sys
input=lambda :sys.stdin.readline().rstrip()


N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
count=1
lst=[0,0,0]
for a in A:
    data=[i for i in range(3) if lst[i] == a]
    if not data:
        count=0
        break
    count*=len(data)
    count%=mod
    i=data[0]
    lst[i]+=1
print(count)


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

#define pb push_back
#define pf push_front
#define ar array
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, x, t;
	cin >> n >> x >> t;
	if(n%x)
		cout << (n/x+1)*t;
	else
		cout << n/x*t;
}


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

#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;

int main(){
    int n; cin >> n;
    vector<vector<pair<int, int>>> test(n);
    rep(i, n){
        int a; cin >> a;
        rep(j, a){
            int x, y; cin >> x >> y;
            pair<int, int> p = {x - 1, y};
            test[i].push_back(p);
        }
    }
    int ans = 0;
    rep(i, 1 << n){
        bool allok = true;
        int sum = 0;
        rep(j, n){
            if(i & (1 << j)){
                sum++;
                for(pair<int,int> p : test[j]){
                    if(((i >> p.first) & 1) != p.second){
                        allok = false;
                        break;
                    }
                }
                if(!allok) break;
            }
        }
        if(allok) ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N, K = int(input()), int(input())
op_a, op_b, total = 0, 0, 1

for i in range(N):
    op_a = total * 2
    op_b = total + K
    if op_a <= op_b:
        total = op_a
    else:
        total = op_b
        
print(total)

Measured memory_bytes: 2940
s = input()

count = 0
ans = 0

for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count += 1
    else:
        if ans < count:
            ans = count
        count = 0
        
if ans < count:
    ans = count

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  int a[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%lld",&k);
  for(i=1;i<=k;i++){
    for(j=1;j<=k;j++){
      for(m=1;m<=k;m++){
        tmp = gcd(i,j);
        result += gcd(tmp,m);
      }
    }
  }
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 1704
a, b, c, x, y = gets.split.map(&:to_i)

ans = 10 ** 5 * 50000 * 2
(0..([x, y].max)).each do |z|
  _x = [x - z, 0].max
  _y = [y - z, 0].max
  sum = (a * _x) + (b * _y) + (c * z * 2)
  ans = sum < ans ? sum : ans
end

puts ans



Measured memory_bytes: 1788
//JSD
#include<iostream>
#include<limits.h>
#define ll long long 
#include<cmath>
using namespace std;
ll n;
ll h[100005],ans[100005];
ll solve(ll i){
	if(ans[i]!=-1) return ans[i];
	if(i==n-1) return 0;
	ll p=INT_MAX,q=INT_MAX;
	if(i+1<n) p=solve(i+1);
	if(i+2<n) q=solve(i+2);
	p+=abs(h[i+1]-h[i]);
	q+=abs(h[i+2]-h[i]);
	ll r=min(p,q);
	ans[i]=r;
	return r;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++) ans[i]=-1;
	for(int i=0;i<n;i++) cin>>h[i];
	cout<<solve(0);
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n; scanf("%ld", &n); int s = 0; bool b = 1;
  while(n > 0){
    if(n > 9 && n % 10 != 9) b = 0;
    if(n > 9) s += 9;
    else s += n;
    n /= 10;
  }
  if(b) printf("%d\n", s);
  else printf("%d\n", s-1);
  return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll mod = 1e9 + 7;

constexpr int kMaxN = 2e5 + 7;

ll fenwick[kMaxN];

int last_bit(int x) {
  return x & -x;
}

ll query(int idx) {
  ll res = 0;
  return res;
}

void update(int idx, ll val) {
  while (idx) {

  }
}

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

  int n;
  cin >> n;

  vector<ll> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }

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

  set<pair<ll, ll>> beauties;
  beauties.emplace(0, 0);
  ll best = 0;
  for (int i = 0; i < n; ++i) {
    auto prev = --beauties.upper_bound({h[i], 0});
    pair<ll, ll> cur = {h[i], prev->second + a[i]};
    ++prev;
    while (prev != beauties.end() && prev->second < cur.second) {
      prev = beauties.erase(prev);
    }
    best = max(best, cur.second);
    beauties.emplace(cur);
  }

  cout << best << '\n';

  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
   string s;
   cin >> s;
   for(int i = 0; i < s.length(); i++){
       if(s[i] != ',')  cout << s[i];
       else{
           cout << ' ';
       }
   }
   cout << '\n';


    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $a);

if($a==2){
    echo $a."\n";
    return;
}
while(true){
    if($a%2==0){
        $a++;
        continue;
    }
    $flg = true;
    for($i=3;$i<=sqrt($a);$i+=2){
        if($a%$i==0){
          $flg=false;
          $a++;
          break;
        } 
    }
    if($flg){
        echo $a."\n";
        break;
    }
}
?>

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int N; cin >> N;
    vector<ll> A(N,0);
    rep(i,N) cin >> A[i];
    ll x2 = 0;
    rep(i,N){
        if (i%2==0) x2 += A[i];
        else x2 -= A[i];
    }

    vector<int> ans(N);
    ans[0] = x2/2;
    rep(i,N-1){
        ans[i+1] = A[i]-ans[i];
    }
    rep(i,N) ans[i] *= 2;
    rep(i,N) printf("%d%c", ans[i], i==N-1?'\n':' ');


}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e4 + 5, BOARD = 105;
int h, w, n, cnt[N], a[BOARD][BOARD], curh, curw;
void nxtGrid() {
	//curh % 2 = 0 => left to right. Else, right to left.
	if (curh % 2 == 0) {
		if (curw == w - 1) curh++;
		else curw++;
	} else {
		if (curw == 0) curh++;
		else curw--;
	}
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> h >> w >> n;
	fw (i, 0, n) cin >> cnt[i];
	curh = curw = 0;
	fw (i, 0, n) {
		while (cnt[i]--) {
			a[curh][curw] = i;
			nxtGrid();
		}
	}
	fw (i, 0, h) {
		fw (j, 0, w) cout << a[i][j] + 1 << " ";
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define int long long
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
int d,ans=0,pw[19];
int backtrack(int pos,int rem,bool first) {
	if (pos==0) return (rem==0?1:0);
	if (pos==1) return (rem==0?10:0);
	int tmp=0;
	fw (i,-9,10) {
		int tempy=rem-i*(pw[pos-1]-1);
		if (tempy%10==0) {
			if (first) {
				if (i>=0) tmp+=backtrack(pos-2,tempy/10,0)*(9-i);
			} else tmp+=backtrack(pos-2,tempy/10,0)*(10-abs(i));
		}
	}
	return tmp;
}
signed main() {
	#ifdef aome
	in("aome.inp");	
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>d;
	/*
	We have n = abcdef
	rev(n) - n = 99...9(a - f) + 99..0(b - e) + ...
	So 99...9(a - f) is the same as D mod 10
	a - f takes on merely 2 values.
	The same can be repeated for latter backtracks
	The backtrack takes 2 ^ 8 maximally
	*/
	pw[0]=1;
	fw (i,1,19) pw[i]=pw[i-1]*10;
	fw (i,1,19) ans+=backtrack(i,d,1);
	cout<<ans;
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int i,j;
	int p;
	bool flag;
	int ret = 0;
	for (i = a; i <= b; i++) {
		flag = true;
		string s;
		p = i;
		while (p != 0)s += ('0' + (p % 10)), p/=10;
		for (j = 0; j < s.size(); j++) {
			if (s[j] != s[s.size() - 1 - j])flag = false;
		}
		if (flag)ret++;
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}
template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(int i = 0; i < (n); ++i)
#define bits(x) __builtin_popcount(x)
 
int test_case_number = 1;

void print_case(){
    #ifdef LOCAL
    cout << "Case #" << test_case_number++ << ": ";
    #endif
}

void solve(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] != t[i]){
            ans ++;
        }
    }
    cout << ans << endl;
}
 
int main(){
    int t = 1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3916
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

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


int main()
{

    int n, sum = 0 , m = 0;
    cin >> n ; 
    for (int i = 0; i < n; i++)
    {
        int a; 
        cin >> a; 
        sum+=a;
        m = max(m,a);
    }
    sum-=m ;
    if(sum > m){
        cout << "Yes" << endl ;
    }
    else
    {
        cout << "No" << endl ;
    }

    return 0 ;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0)cout<<0<<endl;
    else cout<<min({a*b,a*c,b*c})<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>


void bubble(int n,int a[]);


int main(void){


   int N;
   scanf("%d",&N);
   
   int i,flag=1,array[N];
   for(i=0;i<N;i++)  {scanf("%d",&array[i]);}

   bubble(N,array);
   return 0;
   
   

 }


void bubble(int n,int a[]){
  int flag=1,j,kae,count=0;


  while (flag==1){
    flag=0;
    for(j=n-1;j>0;j--){
      
      if(a[j]<a[j-1]){
	kae=a[j-1];
	a[j-1]=a[j];
	a[j]=kae;
	count++;
	flag=1;
      }
    }

  }
  
  for(j=0;j<n;j++){

    if(j==n-1) printf("%d",a[j]);
  else if (j!=n){printf("%d ",a[j]);}

  }
  printf("\n%d\n",count);
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define x first
#define y second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

ll n;
vp p;

double f(double z, double w){
 double res=0;
 rep(i,0,n){
  double dx=z-double(p[i].x);
 double dy=w-double(p[i].y); 
  chmax(res,sqrt(dx*dx+dy*dy));
 }
 return res;
}

double g(double z){
 double l=0,r=1000;
 while(r-l>1e-9){
   double lm=(l*2+r)/3;
   double rm=(l+r*2)/3; 
   if(f(z,lm)>f(z,rm)) l=lm;
   else r=rm;
  } 
 return f(z,l);
}

void solve(){

  cin >> n;
   p=vp(n);
  rep(i,0,n) cin >> p[i].x >> p[i].y;

  double l=0,r=1000;
  while(r-l>1e-9){
   double lm=(l*2+r)/3;
   double rm=(l+r*2)/3; 
   if(g(lm)>g(rm)) l=lm;
   else r=rm;
    
  }

  cout  << setprecision(12) <<  g(l) << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3820
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)


int main()
{
    int m,N,MAX;
    // A[i][j]はi行j列
    int A[2][100];
    cin >> N;
    MAX = 0;
    REP(i,2) {
        REP(j,N) {
            cin >> A[i][j];
        }
    }
    
    REP(i,N) {
        m = 0;
        REP(j,i+1) {
            m += A[0][j];
            //cout << j << ":" <<  m << ",";
        }
        REP(j,N-i) {
            m += A[1][j+i];
            //cout << m << ",";
        }
        //cout << m << endl;
        MAX = max(m,MAX);
    }
    
    cout << MAX << endl;
    return 0;
}


Measured memory_bytes: 256
def solve():
    H, W = map(int, input().split())
    grid = [[] for _ in range(H)]
    for i in range(H):
        grid[i] = list(map(int, input().split()))
    
    ans = []
    for i in range(H):
        for j in range(W - 1):
            if grid[i][j] % 2 == 1:
                grid[i][j + 1] += 1
                ans += [[i + 1, j + 1, i + 1, j + 2]]
    for i in range(H - 1):
        if grid[i][W - 1] % 2 == 1:
            grid[i + 1][W - 1] += 1
            ans += [[i + 1, W, i + 2, W]]
    
    N = len(ans)
    print(N)
    for ans_i in ans:
        print(' '.join(map(str, ans_i)))


if __name__ == '__main__':
    solve()


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    vector<ll> A;
    string S;
    cin >> S;
    A.resize(S.size() + 1);
    for(ll i = 0;i < S.size();i++) {
        if(S[i] == '<') A[i + 1] = max(A[i + 1], A[i] + 1);
    }
    for(ll i = S.size() - 1;i >= 0;i--) {
        if(S[i] == '>') A[i] = max(A[i], A[i + 1] + 1);
    }
    cout << accumulate(A.begin(), A.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 4740
def solve():
    N = int(input())
    S = list(input())
    ans = S.count('R') * S.count('G') * S.count('B')
    for i in range(N-2):
        for j in range(i+1, N + (-(N-i-1)//2)):
            k = j+(j-i)
            if len(set([S[i], S[j], S[k]])) == 3:
                ans-=1
    return ans
print(solve())

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

using namespace std;

int N, M, A, B;

int main(){
    scanf("%d %d", &N, &M);
    int big = 0, low = (int)1e9;
    for(int i = 1; i <= M; ++i){
        scanf("%d %d", &A, &B);
        big = max(big, A), low = min(low, B);
    }
    printf("%d\n", max(0, low - big + 1));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct Res{
    ll node;
    ll edge;
};
ll r[200001]={0},d[200001]={0};
vector<Res> A[200001];
int search(ll x){
  r[x]=1;
  for(auto i:A[x]) if(!r[i.node]) d[i.node]=d[x]+i.edge,search(i.node);
}
int main(){
    int n,a,b,c,q,k,x,y;
    cin>>n;
    rep(i,n-1) cin>>a>>b>>c,A[a].push_back({b,c}),A[b].push_back({a,c});
    cin>>q>>k;
    search(k);
    rep(i,q) cin>>x>>y,cout<<d[x]+d[y]<<endl;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b;
  cin >>a>>b;
  if(a==1||b==1){
    cout<<1<<endl;
    return 0;
  }
  long long kotae;
  if(a%2==1&&b%2==1){
    kotae=a*b/2+1;
  }else{
    kotae=a*b/2;
  }
  cout <<kotae<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>

const double PI=3.14159265358979323846;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(){
  int a=1,b=1;

  while(true){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    rep(i,a){
      rep(j,b){
	if(i == 0 || i == a-1 || j == 0 || j == b-1) cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}



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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if(N==M)
			System.out.println("Yes");
		else
			System.out.println("No");

	}

}


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

int main() {
    long n;
    scanf("%ld", &n);
    long a[n];
    for (long i = 0; i < n; i++) {
        scanf("%ld", &a[i]);
    }
    long i = n - 1;
    printf("%ld", a[i]);
    i -= 2;
    for ( ; i >= 0; i -= 2) {
        printf(" %ld", a[i]);
    }
    if (n % 2 == 0) i = 0;
    else i = 1;
    for ( ; i < n; i += 2) {
        printf(" %ld", a[i]);
    }
    printf("\n");
}

Measured memory_bytes: 5388
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm

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

int64_t N; cin >> N;
VI h(N); rep(i, 0, N) cin >> h[i];
int ans = *min_element(ALL(h));
rep(i, 0, N) h[i] -= ans;
while (any_of(ALL(h), [](int i){return i > 0;})){
    int64_t s = 0;
    rep(i, 0, N) {
        if (h[i] == 0){
            int mini = *min_element(RANGE(h, s, i));
            ans += mini;
            rep(j, s, i) h[j] -= mini;
            s = i + 1;
        }
    }
    int mini = *min_element(RANGE(h, min(N-1,s), N));
    ans += mini;
    rep(j, s, N) h[j] -= mini;
}

cout << ans << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include<cstdio>

int main(){
  int i,j,n,pn=0,p[10000],sum[10000],ans[10001];
  
  for(i=2;i<=10000;i++){
    for(j=2;j*j<=i;j++){
      if(!(i%j))break;
    }
    if(i<j*j)p[pn++] = i;
  }
  
  sum[0] = 0;
  for(i=0;i<pn;i++)sum[i+1] = sum[i] + p[i];
  
  for(i=0;i<=10000;i++)ans[i] = 0;
  
  for(i=0;i<=pn;i++)
    for(j=i+1;j<=pn;j++)
      if(sum[j]-sum[i]<=10000)ans[sum[j]-sum[i]]++;

  while(scanf("%d",&n),n)printf("%d\n",ans[n]);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

int main() {
  string input;
  cin >> input;
  vector<string> strList;
  int ans = 50000;
  for(char c = 'a'; c <= 'z'; c++) {
    int tmpans = 0;
    strList.clear();
    string buffer;
    stringstream ss(input);
    while(getline(ss,buffer,c)) {
      strList.push_back(buffer);
    }
    for(int i = 0; i < strList.size(); i++) {
      if(tmpans < strList[i].length()) tmpans = strList[i].length();
    }
    if(tmpans < ans) ans = tmpans;
  }
  cout << ans << endl;
}

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

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

  int N;
  cin >> N;
  map<int, int> A;

  rep(i, N) {
    int a; cin >> a;
    A[a]++;
  }

  int ans = 0;
  int two = 0;
  for(auto a : A) {
    if(a.second == 1 || a.second % 2 == 1) {
      ans++;
      continue;
    }

    two++;
  }

  ans += two % 2 == 0 ? two : two - 1;

  cout << ans << endl;
}

// 重複について
// 3なら1にできる
// 4なら2にできる
// 5なら3にして1にできる
// 6なら4にして2にできる

// つまり重複が3以上で
// 偶数なら2になり、奇数なら1にできる

// 2つ余ったものが2つ
// 2,2, 3,3
// は 2,2,3 選択で
// 2,3にできる

// 2つ余ったものが3つ
// 2,2, 3,3, 4,4
// は 2,2,3 選択で
// 2,3にして
// 2,3,4 選択で
// 3,4にできる

// つまり2つ余ったものが
// 偶数なら全て1つにできる
// 奇数なら個数-1を全て1つにできる


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
 
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);

int main()
{
  string S,T,U;
  int A,B;
  cin>>S>>T;
  cin>>A>>B>>U;
  
  if (U==S) cout<<A-1<<" "<<B<<endl;
  else cout<<A<<" "<<B-1<<endl;
}

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

ll calc(string s)
{
  ll ret = stoll(s);
  int len = s.size();
  if (len == 0) return 0;
  for(int i=1; i<len; i++){ 
    string sl = s.substr(0, i);
    string sr = s.substr(i, len-1);
    
    ret += stoll(sl) * pow(2, len-i-1);
    ret += calc(sr);
  }
  return ret;
}

int main()
{
  string s;
  cin >> s;
  cout << calc(s) << endl;

  return 0;
}

Measured memory_bytes: 512
import sys
from math import pow
def main():
    x = int(input())
    for a in range(-1000,1001):
        for b in range(-1000,1001):
            if pow(a, 5) - pow(b, 5) == x:
                print(a, b)
                sys.exit()

if __name__ == '__main__':
    main()

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

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

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int A = ceil(double(a)/d);
  int B = ceil(double(c)/b);
  if(A >= B) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
char c[1000];
int vis[128];
int n,ans;
int main(){
	scanf("%d%s",&n,c+1);
	for(int i=1,tmp;i<=n;++i){
		memset(vis,tmp=0,sizeof vis);
		for(int j=1;j<=i;++j){
			if(!vis[c[j]])vis[c[j]]=1;
		}
		for(int j=i+1;j<=n;++j){
			if(vis[c[j]])tmp++,vis[c[j]]=0;
		}
		ans=max(ans,tmp);
	}
	return !printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, m;
	int x, y, in;
	scanf("%d %d %d %d", &n, &m, &x, &y);
	for(int i = 0; i < n; i++){
		scanf("%d", &in);
		if(x < in)x = in;
	}
	for(int i = 0; i < m; i++){
		scanf("%d", &in);
		if(in < y)y = in;
	}
	if(x < y)printf("No ");
	printf("War\n");
	return 0;
}


Measured memory_bytes: 128
let gcd m n =
  let rec doit x y =
    if y <= 0 then x else doit y (x mod y) in
  doit (max m n) (min m n)

let lcm m n = m * n / (gcd m n)

let f () = Scanf.scanf "%d " (fun i -> i)

let () =
  let n = read_int () in
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (lcm acc (f ())) in
  Printf.printf "%d\n" (doit 1 (f ()))

Measured memory_bytes: 2452
import java.util.Scanner;
import java.util.*;


public class Main {
    
    public static void main(String[] args) {
        
        Scanner entrada=new Scanner(System.in);
        
      
        int x[]=new int[3];
        int x2[]=new int[3];
        for (int i = 0; i < 3; i++) {
            x[i]=entrada.nextInt();
        }
        
        for (int i = 0; i < 2; i++) {
            x2[i]=x[i]+x[i+1];
        }
        x2[2]=x[0]+x[2];
        Arrays.sort(x2);
        System.out.println(x2[0]);
    }
    
}

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

#define INF 1e9+5
int absolute(int n){
    return (n<0) ? -1*n : n ;
}
int main(){
    int n,k;
    cin>>n>>k;
    int h[n]={0};
    for(int i=0;i<n;i++) cin>>h[i];
    int dp[n];
    for(int i=0;i<n;i++){
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j>=n) break;
            dp[i+j]=min(dp[i+j],dp[i]+absolute(h[i+j]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;



int main() {
	int n,a=100000;
	cin >> n;
	REP(i, 0, n) {
		a *= 1.05;
		if (a % 1000 != 0) {
			a -= a % 1000;
			a += 1000;
		}
		
		
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 3084
#2019/10/04
time = list(map(int, open(0).read().split()))
# print(time)

time_residual = [i%10 for i in time]
# print(time_residual)

time_residual_notZero = [i for i in time_residual if i%10 != 0 ]
# print(time_residual_notZero)

if(time_residual_notZero != []):
    ans = sum([-(-i//10)*10 for i in time]) + min(time_residual_notZero) - 10
else:
    ans = sum(time)
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    sum = n * (2*l + n - 1);
    sum = sum >> 1;

    int dif = abs(l);
    int t = 1;
    for(int i = 2; i <= n; i++){
        if(dif > abs(l+i-1)){
            dif = abs(l+i-1);
            t = i;
        }
    }

    cout << sum-(l+t-1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define rs register short
using namespace std;

const int N = 2005;

inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}

inline void Rchar(char &ch) {
  while (blank(ch = getchar()));
}

char ch[N][N];
short ri[N][N];
short sta[N], up[N], top = 0;

int main() {
  int n, m, empty = 0;
  scanf("%d%d", &n, &m);
  for (rs i = 1; i <= n; i ++)
    for (rs j = 1; j <= m; j ++) {
      Rchar(ch[i][j]);
      empty += (ch[i][j] == '.');
    }
  for (rs i = m; i; i --) ri[1][i] = m - i + 1;
  short inv, same;
  for (rs i = 2; i <= n; i ++) {
    inv = same = 0;
    for (rs j = m; j; j --) {
      if (ch[i][j] == ch[i - 1][j]) {same ++; inv = 0;}
      else {inv ++; same = 0;}
      ri[i][j] = max(same, inv);
    }
  }
  int ans = 0;
  for (rs j = 1; j <= m; j ++) {
    top = 0;
    for (rs i = 1; i <= n + 1; i ++) {
      rs d = i, t = ri[i][j];
      while (top > 0 && sta[top] >= t) {
	//cerr << "!" << (int)(i - up[top] + 1) * sta[top] << endl;
	if (up[top] != 1) ans = max(ans, (int)(i - up[top] + 1) * sta[top]);
	else ans = max(ans, (int)(i - up[top]) * sta[top]);
	d = up[top --];
      }
      sta[++ top] = t;
      up[top] = d;
      //cout << d << endl;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vl a,b;

int main(){
	cin>>n;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vl dp(n);
	for(int i=0;i<n;i++){
		for(int j=2;j<=i;j+=2) dp[i]=max(dp[i],dp[i-j]);
		dp[i]+=a[i];
	}
	pll p={-INF,n};
	for(int i=0;i<n;i++) p=max(p,{dp[i],i});
	int I=p.second;
	for(int i=1;i<n-I;i++) b.push_back(n-i);
	while(dp[I]!=a[I]){
		for(int j=2;j<=I;j+=2) if(dp[I-j]+a[I]==dp[I]){
			for(int k=j/2-1;k>=0;k--) b.push_back(I-j+(k>0?2:1));
			I-=j;
			break;
		}
	}
	for(int i=0;i<I;i++) b.push_back(0);
	cout<<p.first<<endl<<b.size()<<endl;
	for(auto i:b) cout<<i+1<<endl;
}

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

int main(){
	int n,count=0;
	cin>>n;

	vector<long> d(n);

	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	
	sort(d.begin(),d.end());


	cout <<d[n/2]-d[n/2-1]<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
    int A, B, C, X;

    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &X);

    int ans_num = 0;
    for(int i=0; i<A+1; i++){
        for(int j=0; j<B+1; j++){
            for(int k=0; k<C+1; k++){
                if(500*i + 100*j + 50*k == X){
                    ans_num++;
                }
            }
        }
    }

    printf("%d\n", ans_num);
    return 0;
}

Measured memory_bytes: 1700
stack = []
line = gets.chomp.split
line.each{|elem|
    case elem
    when "+"
        stack.push stack.pop + stack.pop
    when "-"
        stack.push (stack.pop - stack.pop) * -1
    when "*"
        stack.push  stack.pop * stack.pop
    else
        stack.push elem.to_i
    end
}
puts stack.pop

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

int main() {
  ll n,p;
  string s;
  cin >> n >> p >> s;
  ll ans=0;
  if(p==2||p==5) {
    for(ll i=0;i<n;i++) {
      if(int(s[i]-'0')%p==0) {
        ans+=i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  ll temp=1;
  ll sum=0;
  map<ll,ll> count;
  for(ll i=0;i<n;i++) {
    sum=(sum+(int(s[n-1-i]-'0')*temp)%p)%p;
    count[sum]++;
    temp=temp*10%p;
  }
  for(auto q:count) {
    ans+=q.second*(q.second-1)/2;
    if(q.first==0) {
      ans+=q.second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1028
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    
    long long int x,k,d,p;
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d >= k) cout << abs(x - (k*d)) << endl;
    else{ 
          p = x%d;
          k = k - (x/d);
          if(k%2 == 0) cout << p << endl;
          else{
               cout << abs(p-d) << endl;
          }
    }
    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
//cout << fixed << setprecision(12);
ll n,p; cin>>n>>p;
string s;
cin>>s;
reverse(all(s));
ll ca=0;
ll a[p]={};
ll ten=1;
if(p == 2){
ll k = n;
rep(i,n){
if((s.at(i)-'0')%2==0){
ca+=k;}
k--;}
cout << ca << endl;}
else if(p == 5){
ll k = n;
rep(i,n){
if((s.at(i)-'0')==0||(s.at(i)-'0')==5){
ca+=k;}
k--;}
cout << ca << endl;}
else{
rep(i,n){
ca +=((s.at(i)-'0')*ten);
ca %=p;
//cout << ca << endl;  
a[ca]++;
ten*=10;
ten%=p;}
ca=0;
ten=1;
a[0]++;
repl(i,0,p){
ca+=a[i]*(a[i]-1)/2;}
cout << ca << endl;}}



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

int main() {
  long X, K, D; cin >> X >> K >> D;
  X = abs(X);
  if (X / D >= K) cout << X - D * K << endl;
  else {
    K -= X / D;
    X -= (X / D) * D;
    if (K % 2 == 0) cout << X << endl;
    else cout << -X + D << endl;
  }
}

Measured memory_bytes: 3632
//Md. Shajibul Islam..
//East West University, CSE Department'19

#include<bits/stdc++.h>
using namespace std;
#define FAST             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define loop(i,n)        for(int i=0;i<n;i++)
#define CASE_PRINT       cout<<"Case "<<C<<": "
#define CASE_PRINT2      cout<<"Case "<<C<<":"<<endl
#define ll               long long
#define ld               long double
#define Pi               2*acos(0.0) // acos(-1.0)

int main()
{
    FAST;
    int TC,C=1;cin>>TC;

    int cnt=0;
    int flag=0;
    while(TC--)
    {
        int a,b;cin>>a>>b;

        if(a==b)cnt++;
        else cnt=0;

        if(cnt==3)flag=1;



       //C++;
    }
    (flag)?cout<<"Yes"<<endl:cout<<"No"<<endl;
}






Measured memory_bytes: 3640
#include<stdio.h>

int gcd(int a,int b,int c){
	int d=1,min;
	
	(a<b)?(min=a):(min=b);
	(min<c)?:(min=c);
	
	for(int i=0;i<min;i++){
		if(a%(i+1)==0&&b%(i+1)==0&&c%(i+1)==0){
			d=(i+1);
		}
	}
	return d;
}

int main(void){
	int k;
	long long int sum=0;
	scanf("%d",&k);
	for(int i=0;i<k;i++){
		for(int j=0;j<k;j++){
			for(int l=0;l<k;l++){
				sum+=gcd(i+1,j+1,l+1);
			}
		}
	}
	printf("%lld",sum);
}

Measured memory_bytes: 1728
#include <iostream> 
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int N;
    cin >> N;
    if (N%1000 == 0) {
        cout << "0" << endl;
    } else {
        cout << 1000-N%1000 << endl;
    }
    
}

Measured memory_bytes: 3596
function Main(s) {
	s[0] = s[0].split(" ").map(a => parseInt(a));
	s[1] = s[1].split(" ").map(a => parseInt(a));
	var n = s[0][0];
	var k = s[0][1];
	var sl = s[1].length;
	while(f(n)) n++;
	
	console.log(n);
	
	function f(k){
		while(k){
			var m = k % 10;
			for(var i = 0; i < sl; i++){
				if(m === s[1][i]) return true;
			}
			k = Math.floor(k * 0.1);
		}
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));


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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=0;
  for(int i=0;i<N-2;i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, k;
	cin >> a>> b>>c>> k;
	int ans;
	if (k > a + b){
		ans = a - (k - (a + b));
	}
	else {
		if (k >= a)ans = a;
		else ans = k;
	}

	cout << ans;
	return 0;

}

Measured memory_bytes: 3652
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = List.fill(n)(sc.nextInt())
  val ans = (-100 to 100).map{ x =>
    a.map{i =>
      val d = (i - x).abs
      d * d
    }.sum
  }.min
  println(ans)
}


Measured memory_bytes: 55640
#include<stdio.h>
int main()
{
    int a,b,s;
    char op;
    while(1)
    {
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')
        {
            break;
        }
        if(op=='+')
        {
            s=a+b;
        }
        else if(op=='-')
        {
            s=a-b;}
        else if(op=='*')
        {
            s=a*b;
        }
         else if(op=='/')
        {
            s=a/b;
        }
        printf("%d\n",s);
    }
    return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main() {
  float a, b, c, d ,e, f;
  float x, y;
  
  while(cin >> a >> b >> c >> d >> e >> f) {
    x = (c*e-f*b) / (a*e-d*b);
    y = (c*d-f*a) / (b*d-e*a);
    if(x == -0) x = 0;
    if(y == -0) y = 0;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    vector<int>a(m);
    rep(i,m)cin>>a[i];
    cout<<max(ll(-1),n - sumArr(a))<<endl;

    return 0;
}

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

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

  int a[m];
  for (int i = 0; i < m; i++)
    a[i] = 0;

  int k, ai;
  for (int i = 0; i < n; i++)
  {
    cin >> k;
    for (int j = 0; j < k; j++)
    {
      cin >> ai;
      a[ai - 1]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < m; i++)
    if (a[i] == n)
      ans++;

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int( input())
    S = [ list(input()) for _ in range(N)]
    for i in range(N):
        S[i] = "".join(sorted(S[i][:10]))
    S.sort()
    cnt = 1
    ans = 0
    now = S[0]
    for i in range(1, N):
        if now == S[i]:
            cnt += 1
            continue
        ans += cnt*(cnt-1)//2
        cnt = 1
        now = S[i]
    ans += cnt*(cnt-1)//2
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 107612