akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  vector<int> fzbz(N);
  int countup = 1;
  
  for(int i = 0; i < N; i++){
    fzbz.at(i) = countup;
    countup++;
  }
  
  long long sum = 0;
  
  for(int i = 0; i < N; i++){
      
  bool a = fzbz.at(i) % 3 == 0;
  bool b = fzbz.at(i) % 5 == 0;
    
    if(a && b){
      continue;
    }
    
    else if(a){
      continue;
    }
    
    else if(b){
      continue;
    }
    
    else{
      sum += fzbz.at(i);
    }
  }
  
  cout << sum << endl;
}

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

using namespace std;
constexpr long long int mod = 1000000007;


//M*X+R=Y

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	for (size_t i = 0;; i++)
	{
		C-=B;
		if (C <= 0) { cout << "Yes"; return 0; }
		A -= D;
		if (A <= 0) { cout << "No"; return 0; }
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846

void solve()
{
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<int> v1;map<int,int> m;
    for(int i=0;i<n;i++)
    {
        v1.push_back(i+1-a[i]);
        m[i+1+a[i]]++;
    }
    int ans=0;
    sort(v1.begin(),v1.end());
    for(int i=0;i<n;i++)
    {
        if(m.find(v1[i])!=m.end())
            ans+=m[v1[i]];
    }
    cout<<ans<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 18784
# coding: utf-8

from collections import deque

class DoublyLinkedList(object):

    def __init__(self):
        self.queue = deque()
    
    def __call__(self, orders):
        for order in orders:
            order = order.split()

            if order[0] == 'insert':
                self.insert(order[1])
            elif order[0] == 'delete':
                self.delete(order[1])
            elif order[0] == 'deleteFirst':
                self.delete_first()
            elif order[0] == 'deleteLast':
                self.delete_last()
        print(' '.join(self.queue))

    def insert(self, x):
        self.queue.appendleft(x)
    
    def delete(self, x):
        try:
            self.queue.remove(x)
        except:
            pass
    
    def delete_last(self):
        self.queue.pop()
    
    def delete_first(self):
        self.queue.popleft()
    

if __name__ == "__main__":
    doubly_linked_list = DoublyLinkedList()

    n = int(input())
    orders = []
    for _ in range(n):
        orders.append(input())
    doubly_linked_list(orders)


Measured memory_bytes: 212332
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp.chars
(n - k).times do |i|
  t[i + k] = 'x' if t[i] == t[i + k]
end
puts t.count('r') * p + t.count('s') * r + t.count('p') * s

Measured memory_bytes: 8700
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, p = 1, q = 1;
pii a[N], b[N];

bool cmp (pii a, pii b) {
	if (a.f != b.f)
		return a.f > b.f;
	return a.s < b.s;
}


main () {
	cin >> n;
	forn (i, 1, n) {
		cin >> a[i].f >> a[i].s; 
		if (a[i].f > a[p].f || (a[i].f == a[p].f && a[i].s < a[p].s))
			p = i;
		if (a[i].s < a[q].s || (a[i].s == a[q].s && a[i].f > a[q].f))
			q = i;
	}
	
	int ans = 0;
	forn (i, 1, n)
		if (i != p && i != q)
			ans = max(ans, a[i].s - a[i].f + 1);		
	
	ans += max(0, a[q].s - a[p].f + 1);
	forn (i, 1, n) {	
		b[i].f = max(0, a[i].s - a[p].f + 1); 
		b[i].s = max(0, a[q].s - a[i].f + 1);
	}
					
	sort(b + 1, b + 1 + n, cmp);
	
	multiset < int > q;
	forn (i, 1, n)
		q.insert(b[i].s);


	forn (i, 1, n) {
		q.erase(q.find(b[i].s));
		ans = max(ans, b[i].f + *q.begin());
	}

	cout << ans << endl;
		
	
}


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

void chess(int a,int b){
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      int s = i+j;
      if(s%2==0){
        cout << "#";
      }
      else if(s%2==1){
        cout << ".";
      }
    }
    cout << endl;
  }
  cout << endl;
}

int main(){
  int h,w;
  while(true){
    cin >> h >> w;
    if(h==0&&w==0){
      break;
    }
    else{
      chess(h,w);
    }
  }
  return 0;
}


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

int main() {
	int n, m, k, ans = 0;
	vector<long long int> a(200010, 0), b(200010, 0);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		int ai;
		cin >> ai;
		a[i] = a[i - 1] + ai;
	}
	for (int i = 1; i <= m; i++) {
		int bi;
		cin >> bi;
		b[i] = b[i - 1] + bi;
	}
	int memo = m;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k) goto end_loop;
		for (int j = memo; j >= 0; j--) {
			if (b[j] <= k - a[i]) {
				ans = max(ans, i + j);
				memo = j;
				break;
			}
		}
	}
end_loop:
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6248
def f v, list, num, n
	ans = 0
	jd = true
	list.each do |ll|
		if ll == 0
			jd = false 
			break
		end
	end
	if jd 
		return 1 
	end
	n.times do |i|
		next if i == num 
		next if list[i] == 1
		if v[num][i] == 1 
			list[i] = 1 
			ans +=	f Marshal.load(Marshal.dump v), Marshal.load(Marshal.dump list), i, n
			list[i] = 0
		end
	end
	return ans
end


N,M = gets.split.map(&:to_i)

v = Array.new(N){Array.new(N){0}}

M.times do
	a = gets.split.map(&:to_i)
	v[a[0] - 1][a[1] - 1] = 1
	v[a[1] - 1][a[0] - 1] = 1
end
list = Array.new(N){0}
list[0] = 1

ans = f Marshal.load(Marshal.dump v), Marshal.load(Marshal.dump list), 0, N

puts ans

Measured memory_bytes: 2172
from sys import stdin
s_data = stdin.readline().rstrip().split()
data = [int(itr) for itr in s_data]
A = data[0]
B = data[1]
C = data[2]
if (B <= C and C <= A) or (A <= C and C <= B):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    key = "keyence"
    ans = False
    if s == key:
        ans = True
    for i in range(len(s)):
        for j in range(i+1,len(s)):
            ex = s[:i] + s[j:]
            if ex == key:
                ans = True
    print("YES" if ans else "NO")
main()            


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

int main() {
    int N; cin>>N;
    int count2=0;
    int count4=0;
    vector<ll> a(N,0);
    for(int i=0;i<N;i++){
        cin>>a[i];
        if(a[i]%4==0)count4++;
        else if(a[i]%2==0)count2++;
    }
    if(count4>=N/2){
        cout<<"Yes";
    }
    else if(count2==N-count4*2){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

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

int main(){
    int w, h;
    while(cin >> w >> h, w+h){
        vector<int> xi[2525], yj[2525];
        vector<vector<int>> dp(2525, vector<int>(2525,1<<30));
        int gi = -1, gj = -1, ma = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                string s;   cin >> s;
                if(isdigit(s[0])){
                    int num = stoi(s);
                    ma = max(ma, num);
                    xi[num].push_back(i), yj[num].push_back(j);
                }else if(s == "S"){
                    xi[0].push_back(i), yj[0].push_back(j);
                }else if(s == "G"){
                    gi = i, gj = j;
                }
            }
        }
        ma++;
        xi[ma].push_back(gi), yj[ma].push_back(gj);
        dp[0][0] = 0;
        for(int i = 0; xi[i+1].size(); i++){
            for(int j = 0; j < xi[i].size(); j++){
                for(int k = 0; k < xi[i+1].size(); k++){
                    dp[i+1][k] = min(dp[i+1][k], dp[i][j] + abs(xi[i][j]-xi[i+1][k])+abs(yj[i][j]-yj[i+1][k]));
                }
            }
        }
        cout << dp[ma][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 28428
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   int n; cin>>n;
   int ans=powermod(10ll,max(0ll,n),mod);
   ans-=((2*powermod(9ll,max(0ll,n),mod))%mod - powermod(8ll,n,mod));
   if(ans<0)ans+=mod;
   cout<<ans<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 3600
const Main = input=>{
  const given = input.split('\n');
  const given_s = given[1];

  const target = given_s[Number(given[2])-1];
  let rtn = ""; 
  for(let i=0; i<Number(given[0]); i++) rtn += (given_s[i]===target) ? given_s[i]:'*';
  console.log(rtn);
};

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

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

void print_frame(int h, int w)
{
  string border(w, '#');
  string s;
  if (w > 1) {
    s = string(1, '#') + string(max(0, w - 2), '.') + string(1, '#');
  }
  else {
    s = string(1, '#');
  }
  fprintf(stdout, "%s\n", border.c_str());
  for (int i = 0; i < h - 2; ++i) {
    fprintf(stdout, "%s\n", s.c_str());
  }
  if (h > 1) {
    fprintf(stdout, "%s\n", border.c_str());
  }
  return;
}

int main()
{
  int h, w;
  while (true) {
    fscanf(stdin, "%d %d", &h, &w);
    if (h == 0 && w == 0) { break; }
    print_frame(h, w);
    fprintf(stdout, "\n");
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

ll mod = 1e9+7;

int main(){
	ll n,k;
	cin >> n >> k;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	sort(arr.begin(),arr.end());
	arr.insert(arr.begin(),0);
	vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
	dp[0][0] = 1;
	ll count = 0;
	for (int z=1;z<=n;z++){
		ll sum = 0;
		count += arr[z];
		for (int x=0;x<=count && x <=k;x++){
			if (x > arr[z]) sum -= dp[z-1][x-arr[z]-1];
			sum += dp[z-1][x];
			if (sum < 0) sum += mod;
			dp[z][x] += sum;
			dp[z][x] %= mod;
			sum %= mod;
		}
	}
	// for (int z=0;z<=n;z++){
	// 	for (int x=0;x<=k;x++){
	// 		cout << dp[z][x] << " ";
	// 	} cout << endl;
	// }
	cout << dp[n][k] << endl;
	cin >> n;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
int read()
{
    char s;
    int k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
int a,b,n; 
int main()
{
	n=read();a=read();b=read();
	if (abs(a-b)%2==1) printf("Borys"); else printf("Alice");
	return 0;
} 

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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int mask =  0;
	int a, b;
	cin >> a >> b;
	mask |= (1 << a);
	mask |= (1 << b);
	for(int i = 1; i <= 3; i++)
		if(!(mask & (1 << i))) {
			cout << i;
			return 0;
		}

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



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

int main(){
    int k,s; cin>>k>>s;

    int ans=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0&&s-x-y<=k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7,N=2007;
int pw(int a,int n){
	int v=1;
	for(;n;n>>=1,a=(i64)a*a%P)if(n&1)v=(i64)v*a%P;
	return v;
}
int fac[N*N],fiv[N*N],mx;
int n,k,f[N];
int C(int n,int m){
	return (i64)fac[n]*fiv[m]%P*fiv[n-m]%P;
}
int main(){
	scanf("%d%d",&n,&k);
	if(k==1)return puts("1"),0;
	mx=n*k;
	for(int i=fac[0]=1;i<=mx;++i)fac[i]=i64(i)*fac[i-1]%P;
	fiv[mx]=pw(fac[mx],P-2);
	for(int i=mx;i;--i)fiv[i-1]=i64(i)*fiv[i]%P;
	f[1]=1;
	for(int i=1;i<=n;++i){
		for(int j=1,s=0;j<=i;++j){
			s=(s+f[j])%P;
			f[j]=(i64)s*C(i*(k-1)+j-2,k-2)%P;
		}
	}
	int ans=0;
	for(int i=1;i<=n;++i)ans=(ans+f[i])%P;
	ans=(i64)ans*fac[n]%P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int x, y, z;
	cin >> x >> y >> z;
	
	swap(x, y);
	swap(x, z);
	
	cout << x << " " << y << " " << z << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int a,b;
	string op;
	cin >> a >> op >> b;
	if (op == "+")
		cout << a + b << endl;
	else if (op == "-")
		cout << a - b << endl;
	else
		cout << "error" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    
    
    string s1, s2;
    cin >> s1 >> s2;
    
    int dp[sz(s1) + 2][sz(s2) + 2];
    fill_n(*dp, (sz(s1) + 2) * (sz(s2) + 2), inf);
    dp[0][0] = 0;
    
    rep(i, sz(s1) + 1) {
        dp[i][0] = i;
    }
    rep(i, sz(s2) + 1) {
        dp[0][i] = i;
    }
    
    rep(i, sz(s1) + 1) rep(j, sz(s2) + 1) {
        chmin(dp[i + 1][j], dp[i][j] + 1);
        chmin(dp[i][j + 1], dp[i][j] + 1);
        
        if (s1[i] == s2[j]) {
            chmin(dp[i + 1][j + 1], dp[i][j]);
        } else {
            chmin(dp[i + 1][j + 1], dp[i][j] + 1);
        }
    }
    
    cout << dp[sz(s1)][sz(s2)] << endl;
    
    // rep(i, sz(s1) + 1) { rep(j, sz(s2) + 1) cout << dp[i][j] << " "; cout << endl; }
}



Measured memory_bytes: 7128
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define nl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define flood(x) memset(x, 0x3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define dcit cin.sync_with_stdio(0);cin.tie(0);
#define frp(x, y) freopen(x, "r", stdin);freopen(y, "w", stdout);
typedef pair<int, int> pii;
typedef long long ll;

#ifdef LOCAL_PROJECT

#define gc getchar()
#define pc(x) putchar(x)

#endif
#ifndef LOCAL_PROJECT

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)

#endif

template<typename T> void scani(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printi(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
string nextstring() { string r; register char c=gc;while(c==32||c==10) c = gc;while(!(c==32||c==10)) { r += c;c = gc; }return r; }
char nextgetchar(){ register char c = gc; while(c==32 || c==10) c = gc; return c;}

void prints(string k){ for (int i = 0; i < k.length(); i++)pc(k[i]); }
void scani() {}

template<typename First, typename ... Ints>
void scani(First &arg, Ints&... rest) { scani(arg);scani(rest...); }

int N, W; ll ans=0;  ll dp[100002];
int main(){
    scani(N, W);
    for (int i = 0, v, w; i < N; i++) {
        scani(w, v);
        for (int j = 100000; j >= w; j--) dp[j] = max(dp[j], dp[j-w]+v);
    }

    printi(dp[W]);
    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
isIn = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        isOK = True
        for now in range(M):
            if A[i+now][j:j+M] != B[now]:
                isOK = False
                break
        if isOK:
            isIn = True
            break
    if isIn:
        break
if isIn:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e18;
typedef complex<double> P;
#define X real()
#define Y imag()
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};
bool xcomp(const C &a, const C &b){
    return (a.p.X != b.p.X)? a.p.X<b.p.X : a.p.Y<b.p.Y;
}
bool ycomp(const C &a, const C &b){
    return (a.p.Y != b.p.Y)? a.p.Y<b.p.Y : a.p.X<b.p.X;
}

double closest(vector<C> &c, int first, int last, double rmax){
    if(last -first <= 1) return INF;
    int mid = (first +last)/2;
    double midx = c[mid].p.X;
    double d = min(closest(c, first, mid, rmax), closest(c, mid, last, rmax));
    inplace_merge(c.begin()+first, c.begin()+mid, c.begin()+last, ycomp);

    vector<C> near;
    for(int i=first; i<last; i++){
        if(abs(c[i].p.X -midx) -c[i].r -rmax > d +EPS) continue;
        for(int j=near.size()-1; j>=0; j--){
            if(abs(c[i].p.Y -near[j].p.Y) -c[i].r -rmax > d +EPS){
                break;
            }
            d = min(d, abs(c[i].p -near[j].p) -c[i].r -near[j].r);
        }
        near.push_back(c[i]);
    }
    return d;
}
 
int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<C> c(n);
        double rmax = 0;
        for(int i=0; i<n; i++){
            double r,x,y;
            cin >> r >> x >> y;
            c[i] = C(P(x, y), r);
            rmax = max(rmax, r);
        }
        sort(c.begin(), c.end(), xcomp);

        cout << fixed << setprecision(10);
        cout << closest(c, 0, n, rmax) << endl;
    }
    return 0;
}


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

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

int main(){

    ll N;
    cin >> N;
    map<ll,int> m;

    for(ll i = 0; i < N; i++){
        ll key = 0;
        cin >> key;
        m[key]+=1;
    }
    for(auto & value : m){
        if(value.second > 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)
#define SP(i)           fixed << setprecision(i) 

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define H first
#define I second
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REP1(i,a,b) for(ll i=(a);i<=(b);i++)
#define mkp make_pair
#define pb push_back
const ll INF=1e18;
const ll MA=1e6+5;
const ll MOD=1e9+7;
const int M=1e5+5;
//}}}
ll n;
pll arr[100010];
ll ans[100010];
bool cmp(pll a,pll b){
	if(a.H!=b.H)	return a.H>b.H;
	return a.I<b.I;
}
int main(){
	cin>>n;
	ll k;
	for(int i=0;i<n;i++){
		cin>>k;
		arr[i]={k,i+1};
	}
	sort(arr,arr+n,cmp);
	int now=0;
	ll hi=arr[0].H;
	ll mi=INF;
	while(now<n){
		if(mi<INF)
			ans[mi]+=(hi-arr[now].H)*now;
		hi=arr[now].H;
		while(now<n&&arr[now].H==hi){
			mi=min(mi,arr[now].I);
			now++;
		}
	}
	ans[mi]+=hi*now;
	for(int i=1;i<=n;i++)
		cout<<ans[i]<< '\n';
	return 0;
}

Measured memory_bytes: 3456
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       s: Chars,
    }

    echo!(s.iter().take(3).toVec().joinToString(""));
}


Measured memory_bytes: 2128
/*
数列の値を全て同じ数に変える際の最小コスト
数をある数yに書き換えるのに必要なコストは二乗誤差
つまり元の数との差が大きいほどコストは大きくなる.
= 全ての数との間の距離の総和が最小になる点
= 全ての数の平均値
ただ計算しただけでは小数点以下は切り落としなので, 
sum % n > n/ 2で繰り上げを確かめる.
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    int A[n];
    REP(i, n) sc(A[i])

    int sum = 0;
    REP(i, n) sum += A[i];

    int ave = sum / n;
    if (sum % n > n / 2) ave += 1;

    int ans = 0;
    REP(i, n) ans += (A[i] - ave) * (A[i] - ave);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
int main()
{
	int n;
	cin >> n;
	vl A(n);
	vl B(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i] >> B[i];
	}
	ll sum = 0;
	for (int i = n - 1; i >= 0; i--) {
		ll x = (A[i] + sum) % B[i];
		if (x == 0)continue;
		else {
			sum += B[i] - x;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 1792
package main

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

func max(a, b int) (int, int) {
	if a > b {
		return a, b
	}
	return b, a
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
  return gcd(b, a%b)
}
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func main() {
	//var a, b, ans int
	var ans int
	//fmt.Scan(&a, &b)
	//d,s := max(a,b)
	sc.Split(bufio.ScanWords)
	s := nextInt()
	d := nextInt()
	//for i := 2; ; i++ {
	//	r := d * i
	//	if r%s == 0 {
	//		ans = r
	//		break
	//	}
	//}
	ans = lcm(s, d)

	fmt.Println(ans)
}

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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> L(M), R(M);
  for(int i=0; i<M; ++i){
    cin >> L.at(i) >> R.at(i);    
  }
  int L_max=0, R_min=N;
  for(int i=0; i<M; ++i){
    L_max = max(L_max,L.at(i));
    R_min = min(R_min,R.at(i));
  }
  cout << max(R_min - L_max +1,0) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long q,h,s,d,n,ans,x;
int main()
{
    cin>>q>>h>>s>>d>>n;
    x=min(q*4,min(h*2,s));
    if(x*2<=d)
        cout<<x*n;
    else
        cout<<((n%2)*x)+n/2*d;

    return 0;
} 

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

int main(void){
 int p[3],c=3;
 for(int i=0;i<3;i++){
  cin>>p[i];
  for(int j=i-1;j>=0;j--){
   if(p[j]==p[i])
      {c--;
       break;}
   }
  }
 cout<<c<<endl;
 return 0;
 }

Measured memory_bytes: 256
# returns weight sum from s to t
# assumed e is tree, bidirected directed graph
# TLE with max 100000
def bfs(s,e,k)
	mod = 10**9+7
	childs = Array.new(E.size){0}
	searched = Array.new(E.size){false}
	comb = k
	childs[s] = 0
	searched[s] = 0
	# [node, level]
	# q = e[s].map{|a| [a,s,1]}
	q = []
	e[s].each{|a| 
		q << [a,s,1]
	}
	while(!q.empty?)
		# p q
		v,v_p,lev = q.shift
		# p searched
		next if (searched[v])
		# p [v,v_p,lev]
		# calc
		return 0 if((k-[lev,2].min-childs[v_p])<=0)
		# p "*= is #{k-[lev,2].min-childs[v_p]}"
		# p "#{comb*(k-[lev,2].min-childs[v_p])}"
		comb = comb * (k-[lev,2].min-childs[v_p])
		comb %= mod
		childs[v_p] += 1		
		searched[v] = true
		# next
		v_nxt = e[v].each{|i| 
			q << [i,v,lev+1]
		}
		# p comb
	end
	return comb
end
N,K=gets.chomp.split(' ').map{|n| n.to_i}
# 0 indexed
E = Array.new(N){[]}
1.upto(N-1){
	p=gets.chomp.split(' ').map{|n| n.to_i}
	p[0] -= 1
	p[1] -= 1
	E[p[0]].push(p[1])
	E[p[1]].push(p[0])
}
puts bfs(0,E,K)


Measured memory_bytes: 26108
N,K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
pb = [(p[i] * (p[i] + 1)) / (p[i] * 2) for i in range(N)]
pr = sum(pb[:K])
m = pr
for i in range(N - K):
    pr += pb[i+K] - pb[i]
    m = max(m, pr)
print(m)

Measured memory_bytes: 31984
#include<bits/stdc++.h>
#define in inline
#define reg register
#define int long long
#define MAX 20030813
#define f(i,l,r) for(reg int i=l;i<=r;++i)
#define F(i,l,r) for(reg int i=l;i>=r;--i)
using namespace std;
namespace qwq{
	in void read(int &o)
	{
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			o=(o<<3)+(o<<1)+(c^48);
			c=getchar();
		}
		o*=w;
	}
	in void write(int x)
	{
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
    	putchar(x%10+48);
	}
	in int max(int x,int y)
	{
		return x>y?x:y;
	}
	in int min(int x,int y)
	{
		return x<y?x:y;
	}
}
using namespace qwq;
string s;
signed main()
{
	cin>>s;
	if(s=="Sunny")puts("Cloudy");
	if(s=="Cloudy")puts("Rainy");
	if(s=="Rainy")puts("Sunny");
	return 0;
}




Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	D = getlist()
	if N >= 24:
		print(0)
	elif N >= 12:
		d = defaultdict(int)
		judge = "Yes"
		for i in D:
			d[i] += 1
		if d[0] >= 1:
			judge = "No"
		if d[12] >= 2:
			judge = "No"
		for i in range(1, 12):
			if d[i] >= 3:
				judge = "No"
		if judge == "No":
			print(0)
		else:
			print(1)
	else:
		ans = 0
		for i in range(1 << N):
			L = [0, 24]
			for j in range(N):
				if ((i >> j) & 1) == 1:
					L.append(D[j])
				else:
					L.append(24 - D[j])
			L = sorted(L)
			val = 24
			for i in range(N + 1):
				val = min(val, L[i + 1] - L[i])
			ans = max(ans, val)
		print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3316
C = [list(map(int, input().split())) for _ in range(3)]

a = [0 for _ in range(3)]
b = [0 for _ in range(3)]

A = [sum(c) for c in C]
B = [C[0][i] + C[1][i] + C[2][i] for i in range(3)]

is_correct = True
for i in range(3):
    for j in range(i, 3):
        if abs(A[i] - A[j]) % 3 != 0:
            is_correct = False
        if abs(B[i] - B[j]) % 3 != 0:
            is_correct = False

print("Yes" if is_correct else "No")


Measured memory_bytes: 3188
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    mut n: i64
    }

    let mut tmp = 26;
    let mut l = 1;
    while n > tmp {
        n -= tmp;
        tmp *= 26;
        l += 1;
    }
    n -= 1;

    let mut vec = vec![];

    for _ in 0..l {
      let amari = n % 26;
      n = n / 26;
      vec.push((amari as u8 + b'a') as char);
    }

     println!("{}", vec.iter().rev().collect::<String>());
}


Measured memory_bytes: 2152
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
K,S = map(int,input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-(x+y) <= K:
            ans += 1

print(ans)

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

int main( void )
{
    char s[ 19 ];
    cin >> s;
    for ( int i = 0; i < 19; i++ )
    {
        if ( i == 5 || i == 13 )
        {
            cout << ' ' << flush;
        }
        else
        {
            cout << s[ i ];
        }
    }

    return 0;
}


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

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

    vector<long long> a(n);
    vector<long long> s(n+1, 0);

    long long sum = 0;
    for(long long i = 0; i < n; i++) cin >> a[i], sum += a[i];

    for(long long i = 0; i < n; i++) s[i+1] = s[i] + a[i];

    long long minv = 1e20;
    for(long long i = 1; i <= n-1; i++){
        long long x, y;
        x = s[i];
        y = sum - s[i];
        minv = min(minv, abs(x-y));
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 6364
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    ll w, h;
    int x, y;

    cin >> w >> h >> x >> y;
    printf("%.10lf %d\n", w*h/2.0, ((2*x == w) && (2*y == h)) ? 1 : 0);

    return 0;
}


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

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 3228
N,L = map(int,input().split())
aji_of_all = (L+L+N-1)*N//2
if L >= 0:
    print(aji_of_all - L)
elif L+N-1 > 0:
    print(aji_of_all)
else:
    print(aji_of_all - (L+N-1))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  if (n < m) swap(n, m);

  if (n - m >= 2) {
    outl(0);
    return;
  }

  ll ans = 1;
  if (n == m) ans *= 2;
  else {
    ans *= n;
    n--;
  }
  while (n > 1) {
    ans = ans * n % MOD;
    ans = ans * n % MOD;
    n--;
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<< #x <<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

ll dp[51][51][2601];
int main(){
    int N,A,NX,x[51];
    cin >> N >> A;
    REP(i,N) cin >> x[i];
    NX = N * 50;
    dp[0][0][0] = 1;

    REP(i,N)REP(j,N)REP(k,NX){
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
        dp[i+1][j][k] += dp[i][j][k];
    }

    ll ans = 0;
    FOR(i,1,N+1) ans += dp[N][i][A*i];
    cout << ans << endl;

    return 0;
}




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

class Class307
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var v = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var dic1 = new Dictionary<int, int>();
        var dic2 = new Dictionary<int, int>();
        dic1.Add(-1, 0);
        dic2.Add(-1, 0);
        for(int i = 0; i < n; i++)
        {
            int num = v[i];
            if (i % 2 == 0)
            {
                if (dic2.ContainsKey(num)) dic2[num]++;
                else dic2[num] = 1;
            }
            else
            {
                if (dic1.ContainsKey(num)) dic1[num]++;
                else dic1[num] = 1;
            }
        }
        var d1 = dic1.OrderByDescending(x => x.Value).ToArray();
        var d2 = dic2.OrderByDescending(x => x.Value).ToArray();

        if(d1[0].Key !=d2[0].Key)
        {
            Console.WriteLine(n-d1[0].Value -d2[0].Value );
        }
        else
        {
            int ans = Math.Min(n - d1[0].Value - d2[1].Value, n - d1[1].Value - d2[0].Value);
            Console.WriteLine(ans);
        }
    }

}


Measured memory_bytes: 26592
n = int(input())
S = [item for item in map(int, input().split())]
q = int(input())
T = [item for item in map(int, input().split())]

c = 0
for i in range(len(T)):
    lo = 0
    hi = n
    while lo < hi:
        mid = (lo + hi) // 2
        if S[mid] == T[i]:
            c += 1
            break
        elif T[i] < S[mid]:
            hi = mid
        else:
            lo = mid+1
print(c)


Measured memory_bytes: 16896
def main():
    num = int(input())
    l = list(map(int, input().split()))
    l.sort()

    ans_list = []

    for i in range(101):
        if i == 0:
            i = i + 1
        sum = 0
        for x in l:
            sum = sum + ((x - i) * (x - i))
        ans_list.append(sum)
    
    ans_list.sort()
    print(ans_list[0])


main()

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

int main(){
    
    int n, x;
    cin >> n >> x;
    std::vector<unsigned long int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans;
    for(int i=0; i<n; i++)
    {
        x -= a[i];
        
        if(x<0) 
        {
            ans = i;
            break;
        }
        else if(x==0)
        {
            ans = i+1;
            break;
        }
        ans = i;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())

if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()
    
yoko = h // 3

sa = 10**100

for i in range(2):
    s1 = w * (yoko + i)
    if w % 2 == 0:
        s2 = (h-yoko-i) * (w//2)
        sa = min(sa,abs(s1-s2))
    else:
        s2 = (h-yoko-i) * (w//2)
        s3 = (h-yoko-i) * ((w//2)+1)
        sa = min(sa,max(abs(s1-s2),abs(s1-s3),abs(s3-s2)))

tmp = h
h = w
w = tmp

yoko = h // 3

for i in range(2):
    s1 = w * (yoko + i)
    if w % 2 == 0:
        s2 = (h-yoko-i) * (w//2)
        sa = min(sa,abs(s1-s2))
    else:
        s2 = (h-yoko-i) * (w//2)
        s3 = (h-yoko-i) * ((w//2)+1)
        sa = min(sa,max(abs(s1-s2),abs(s1-s3),abs(s3-s2)))

        
print(min(sa,h,w))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,x,y,z;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	x=a/c;
	if(a%c>0){
		x+=1;
	}
	y=b/d;
	if(b%d>0){
		y+=1;
	}
	if(x>y){
		z=l-x;
	}
	else{
		z=l-y;
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 2728
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


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

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	cin >> a >> b;

	if (b >= a)cout << a << endl;
	else cout << a - 1 << endl;

	
	

}
	

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

B=[0 for i in range(n)]
B[n//2:]=A[n//2:]

for i in range(n//2,0,-1):
    B[i-1]= (sum(B[i*2-1::i])%2 != A[i-1])

print(sum(B))
for i,j in enumerate(B):
    if j==1:
        print(i+1)

Measured memory_bytes: 13508
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int n=5, m, i, j, k, l;
    double a[n];
    int b[n]={0};
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
    {
        b[i]=ceil(a[i]/10)*10-a[i];
    }
    /*for(i=0; i<n; i++)
    {
        cout<<b[i]<<" ";
    }*/
    sort(b, b+n);
    int sum=0;
    for(j=0; j<n; j++)
    {
        sum=ceil((sum+a[j])/10)*10;
    }
    //cout<<sum<<endl;
    cout<<sum-b[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(abc058_b(sc.next(),sc.next()));
    }

    static String abc058_b(String O, String E) {
        String[] o = new String[O.length()];
        for (int i = 0; i < o.length; i++) {
            o[i] = String.valueOf(O.charAt(i));
        }
        String[] e = new String[E.length()];
        for (int i = 0; i < e.length; i++) {
            e[i] = String.valueOf(E.charAt(i));
        }
        String pass = "";
        for (int i = 0; i < e.length; i++) {
            pass = pass + o[i] + e[i];
        }
        if (o.length == e.length) {
            return pass;
        }
        return pass + o[o.length - 1];
    }

}


Measured memory_bytes: 20820
<?php
list($a,$b)=explode(" ",trim(fgets(STDIN)));
$i=$b*10;
$n=$i+10;
while($i<$n){
  $t=floor($i*0.08);
  if($t==$a){
    echo $i;
    exit;
  }
  ++$i;
}
echo -1;

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <math.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> L;
	vector<int> R;
	int tmpL, tmpR;
	for (int i = 0; i < M; ++i) {
		cin >> tmpL >> tmpR;
		L.push_back(tmpL);
		R.push_back(tmpR);
	}
	sort(L.begin(), L.end(), greater<int>());
	sort(R.begin(), R.end());

	if (R.front() - L.front()  < 0) {
		cout << 0 << endl;
		exit(0);
	}
	cout << R.front() - L.front() + 1 << endl;
}

Measured memory_bytes: 1276
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	string S;
	cin >> S;
	int answer = 0;
	for (int i = 0; i < S.length(); i++) {
		answer += S[i] - '0';
	}
	cout << answer << endl;
}

Measured memory_bytes: 256