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

using namespace std;

signed main()
{
	int n=0;
	cin >> n;	
	if (n%2==1)
	{
		cout << 0;
		return 0;
	}
	int x = 5, res=0;
	for (int i=1; i<=100; i++)
	{
		res+=n/(2*x);
		x*=5;
		if (2*x>n)
			break;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
ans = 0
if B == 1:
    print(0)
    exit(0)
while True:
    if A*(ans+1) - ans == B:
        print(ans + 1)
        exit(0)
    elif A*ans + A - ans > B:
        print(ans + 1)
        exit(0)
    ans += 1
    

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

int prime(int a){
    if(a == 2) return 1;
    int msize = sqrt(a)+1;
    for(int i=2; i<msize; i++){
        if(a%i == 0){
            return 0;
            break;
        }
    }
    return 1;
}

int main(){
   
    while(1){
         int n; cin>>n;
        if(n==0) break;
        int ans=0;
        for(int i=n+1; i<=2*n; i++){
        if(prime(i) == 1) ans++;
        }

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


Measured memory_bytes: 3052
//
//  main.cpp
//  no.1
//
//  Created by MacBook_Virgo on 2015/04/23.
//  Copyright (c) 2015??´ MacBook_Virgo. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    while(cin >> n,n!=0){
    int max,min;
    max = 0;
    min = 1000;
    int x;
    int sum = 0;
    for(int i = 0;i <n;i = i+1){
        cin >> x;
        sum = sum + x;
        if(x >max){
            max = x;}
        if(x < min){
            min = x;}
    }
    cout << (sum - max - min) / (n-2) << endl;
    }return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

const int MAX_N = 200000;

ll inv[MAX_N], fac[MAX_N], fiv[MAX_N];
void COMinit() {
    inv[1] = fac[1] = fiv[1] = inv[0] = fac[0] = fiv[0] = 1;
    for (ll i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD; // n!
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
        fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
    }
}

ll com(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * fiv[k] % MOD * fiv[n-k] % MOD;
}

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

    ll tate = 0;
    for (ll i = 1; i < m; i++) (tate += i * (m - i)) %= MOD;
    tate = n * n % MOD * tate % MOD;

    ll yoko = 0;
    for (ll i = 1; i < n; i++) (yoko += i * (n - i)) %= MOD;
    yoko = m * m % MOD * yoko % MOD;

    COMinit();
    cout << (yoko + tate) * com(n * m - 2, K - 2) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define ha 1000000007
#define inv2 500000004
using namespace std;

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

const int N=200010;
const int M=8000;
int fac[M+10],ifac[M+10];
int f[M/2+10][M/2+10],base=M/4+2;
int n,A[N],B[N];

int Pow(int a,int b)
{
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%ha)
        if(b&1) ans=1ll*ans*a%ha;
    return ans;
}

void Init()
{
    fac[0]=1;
    for(int i=1;i<=M;i++)
        fac[i]=1ll*fac[i-1]*i%ha;
    ifac[M]=Pow(fac[M],ha-2);
    for(int i=M-1;i>=0;i--)
        ifac[i]=1ll*ifac[i+1]*(i+1)%ha;
}

int C(int n,int m){return 1ll*fac[n]*ifac[m]%ha*ifac[n-m]%ha;}

int main()
{
    Init(); n=read();
    for(int i=1;i<=n;i++)
    {
        A[i]=read(),B[i]=read();
        f[base-A[i]][base-B[i]]++;
    }
    for(int i=1;i<=M/2+2;i++)
        for(int j=1;j<=M/2+2;j++)
            f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%ha)%ha;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+f[A[i]+base][B[i]+base])%ha;
        ans=(ans-C(2*A[i]+2*B[i],2*A[i]))%ha;
    }
    ans=(ans+ha)%ha;
    ans=1ll*inv2*ans%ha;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 68924
from math import factorial
def ncr(n,r):
 return factorial(n) // factorial(r) // factorial(n - r)
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  d = list(int(i) for i in input().split())
  if d[0] != 0:
    print(0)
    exit()
    
  mod = 998244353
  query = [0]*n
  length = 0
  for i in range(n):
    tmp = d[i]
    length = max(tmp,length)
    query[tmp] += 1
  if query[0] != 1:
     print(0)
     exit()
  
  ans = query[0]
  for i in range(1,length+1):
    next = query[i]
    if query[i-1] == 1:
      ans *= 1
    else:
      ans *= query[i-1]**next
    ans %= mod
  print(ans)
solve()


Measured memory_bytes: 52508
#include<iostream>

using namespace std;

int main() {
    int AB, BC, CA;

    cin >> AB >> BC >> CA;

    int ans;

    if(AB < BC) {
        if(BC < CA){
            ans = AB + BC;
        } else {
            ans = AB + CA;
        }
    } else {
        if(AB < CA){
            ans = AB + BC;
        } else {
            ans = BC + CA;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int N;
int MOD = 1e9+7;

bool isPrime(int x) {
	for (int i = 2; i*i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

int main(int argc, char const *argv[]) {
	cin >> N;

	vector<int> primes;

	for (int i = 2; i <= N; i++) {
		if (isPrime(i)) primes.push_back(i);
	}

	map<int, int> mp;

	for (int i = 2; i <= N; i++) {
		int k = i;
		for (int j = 0; j < primes.size(); j++) {
			while (k % primes[j] == 0) {
				mp[primes[j]]++;
				k /= primes[j];
			}
			if (k == 1) break;
		}
	}

	ll res = 1;

	map<int, int>::iterator itr;
	for (itr = mp.begin(); itr != mp.end(); itr++) {
		int k = itr->second + 1;
		res *= k;
		res %= MOD;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
//K-OS WITH THE OCDE

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll n , f = 0;
     cin >> n;
     ll a[n+1];
     for(ll i=1 ; i<=n ; ++i) {
        cin >> a[i];

        if(i&1 && a[i]&1)
            f++;
     }

     cout << f;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	/**
	xr = a[2] ^ ... ^ a[n - 1]
	sum = a[0] + a[1]

	(x, y) 
		x ^ y = xr
		x + y = sum
		max(x) | x <= a[0]
	  */
	int n;
	cin >> n;
	vector<long long> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	long long xr = 0, sum = a[0] + a[1];
	for(int i = 2; i < n; i++)
		xr ^= a[i];
	if(sum < xr){
		cout << -1 << '\n';
		return 0;
	}
	long long miss = (sum - xr)>>1;
	long long x = miss, y = miss;
	for(int i = 60; i >= 0; i--){
		long long p = 1ll<<i;
		if(xr & p){
			if(x + p <= a[0]){
				x += p;
			} else {
				y += p;
			}
		}
	}
	if(a[0] >= x && min(x, y) > 0 && (x ^ y) == xr && x + y == sum){
		cout << a[0] - x << '\n';
	} else {
		cout << -1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    
    int n;
    cin >> n;
    ll j=0;
    double b = 0;
    rep(i,0,n){
	double a;
	string c;
	cin >> a >> c;
	if(c == "JPY")j+=(ll)a;
	else b+=a;
    }

    printf("%.10lf\n",j + b*380000);
    return  0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    int x = abs(a-b), y = abs(b-c), z = abs(c-a);
    cout << x + y + z - max({x,y,z}) << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
boxes = gets.chomp.split(' ').map(&:to_i)
answer = Array.new(boxes.length)
answer[0] = 0
boxes.each_cons(2).with_index do |con, i|
  answer[i+1] = con[0] < con[1] ? 0 : answer[i]+1
end
print answer.max

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,P;
ll W[101010],B[101010];
int V[101010];

ll SW[101010];
ll SB[101010];

bool cmp(int& a,int& b) {
	return 100*W[b]-P*(W[b]+B[a])>100*W[a]-P*(W[a]+B[b]);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>P;
	FOR(i,N) cin>>W[i]>>B[i], V[i]=i;
	sort(V,V+N,cmp);
	
	FOR(i,N) {
		SW[i+1]=SW[i]+W[V[i]];
		SB[i+1]=SB[i]+B[V[i]];
	}
	for(i=1;i<=N;i++) {
		ll TW=SW[N]-SW[N-i];
		ll TB=SB[N-i];
		
		if(100*TW>=P*(TW+TB)) {
			return _P("%d\n",i);
		}
		
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,d=26,f,i=0;cin>>a;
  vector<char> c;
  while(a>0){
    b=a%d;
        a/=26;
    if(b==0){
      b=26;
      a--;
    }
    c.push_back((char)(b)+'a'-1);
  }
  reverse(c.begin(),c.end());
  f=c.size();
  rep(i,f){
    cout<<c[i];
  }
}


Measured memory_bytes: 27036
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			while (sc.hasNext()) {
				int n = sc.nextInt();
				System.out.println(solve(n, 0));
			}
		}
	}

	public static int solve(int n, int d) {
		if (n < 0 || n > (4 - d) * 9 || d > 4) {
			return 0;
		}
		if (d == 4 && n == 0) {
			return 1;
		}
		int result = 0;
		for (int i = 0; i <= 9; i++) {
			result += solve(n - i, d + 1);
		}
		return result;
	}
}

Measured memory_bytes: 26184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  ll r, c, K;
  cin >> r >> c >> K;
  vector<vector<ll>> v(r, vector<ll>(c, 0));
  REP(i, K) {
    ll x, y, val;
    cin >> x >> y >> val;
    x--, y--;
    v[x][y] = val;
  }

  vector<vector<vector<ll>>> dp(r, vector<vector<ll>>(c, vector<ll>(4, 0)));
  dp[0][0][0] = 0;
  REP(i, r) {
    REP(j, c) {
      REP(k, 4) {
        ll take = dp[i][j][k] + v[i][j];
        ll notTake = dp[i][j][k];
        if (j + 1 < c) {
          chmax(dp[i][j + 1][k], notTake);
        }
        if (j + 1 < c && k < 3) {
          chmax(dp[i][j + 1][k + 1], take);
        }
        if (i + 1 < r) {
          if (k < 3) {
            chmax(dp[i + 1][j][0], take);
          } else {
            chmax(dp[i + 1][j][0], notTake);
          }
        }
      }
    }
  }
  ll ans = dp[r - 1][c - 1][3];
  REP(k, 3) { chmax(ans, dp[r - 1][c - 1][k] + v[r - 1][c - 1]); }
  cout << ans << endl;
}

Measured memory_bytes: 706660
#include<stdio.h>
int main()
{
	int a,b;
	do{
		scanf("%d %d",&a,&b);
		if(a==0 && b==0)
		break;
		for(int i=0;i<a;i++)
		{
			for(int j=0;j<b;j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}while(a!=0 && b!=0);
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int SZ=1<<18;
tuple<int,int,int> tree[2*SZ];
int A[200000], B[200000];

bool comp(tuple<int,int,int> a, tuple<int,int,int> b)
{
	return get<0>(a)+get<1>(a)>get<0>(b)+get<1>(b);
}

bool check(tuple<int,int,int> a)
{
	return get<0>(a) && get<1>(a);
}

void add_tree(int n, int v1, int v2)
{
	get<0>(tree[n+=SZ])+=v1;
	get<1>(tree[n])+=v2;
	while(n>>=1) {
		if(check(tree[2*n]) && check(tree[2*n+1])) tree[n]=comp(tree[2*n],tree[2*n+1]) ? tree[2*n]:tree[2*n+1];
		else if(check(tree[2*n])) tree[n]=tree[2*n];
		else tree[n]=tree[2*n+1];
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, cnt=0;
	long long ans=0;
	cin>>N;
	fill(tree,tree+2*SZ,make_tuple(0,0,-1));
	for(int i=0;i<N;i++) cin>>A[i];
	for(int i=0;i<N;i++) cin>>B[i];
	for(int i=0;i<N;i++) {
		get<2>(tree[SZ+i])=i;
		if(A[i]!=B[i]) {
			if(A[i]>B[i]) {
				cout<<"-1\n";
				return 0;
			}
			cnt++;
			if(B[(i+N-1)%N]<B[i]) get<0>(tree[SZ+i])=B[(i+N-1)%N];
			if(B[(i+1)%N]<B[i]) get<1>(tree[SZ+i])=B[(i+1)%N];
		}
	}
	for(int i=SZ-1;i;i--) {
		if(check(tree[2*i]) && check(tree[2*i+1])) tree[i]=comp(tree[2*i],tree[2*i+1]) ? tree[2*i]:tree[2*i+1];
		else if(check(tree[2*i])) tree[i]=tree[2*i];
		else tree[i]=tree[2*i+1];
	}
	while(cnt) {
		int v1, v2, idx, m;
		tie(v1,v2,idx)=tree[1];
		if(idx==-1) {
			cout<<"-1\n";
			return 0;
		}
		if((B[idx]-A[idx])%(v1+v2)==0) m=(B[idx]-A[idx])/(v1+v2);
		else m=(B[idx]+min(v1,v2)-1)/(v1+v2);
		if((B[idx]-=m*(v1+v2))<A[idx]) {
			cout<<"-1\n";
			return 0;
		}
		ans+=m;
		if(B[(idx+N-1)%N]>B[idx]) {
			add_tree(idx,-v1,0);
			if(A[(idx+N-1)%N]!=B[(idx+N-1)%N]) add_tree((idx+N-1)%N,0,B[idx]);
		}
		if(B[(idx+1)%N]>B[idx]) {
			add_tree(idx,0,-v2);
			if(A[(idx+1)%N]!=B[(idx+1)%N]) add_tree((idx+1)%N,B[idx],0);
		}
		if(A[idx]==B[idx]) {
			cnt--;
			add_tree(idx,-get<0>(tree[SZ+idx]),-get<1>(tree[SZ+idx]));
		}
	}
	cout<<ans<<'\n';
	return 0;
}

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

using namespace std;

typedef long long LL;

int f[50];
string s;

int main()
{
	cin>>s;
	for (int i=0;i<26;++i) f[i]=0;
	for (int i=0;i<s.size();++i) f[s[i]-'a']=1;
	if (s.size()!=26)
	{
		cout<<s;
		for (int i=0;i<26;++i) if (f[i]==0)
		{
			cout<<char('a'+i)<<endl;
			return 0;
		}
	}
	for (int i=s.size()-2;i>=0;--i)
	{
		f[s[i+1]-'a']=0;
		for (int j=0;j<26;++j)
		{
			if (f[j]==1) continue;
			if ('a'+j>s[i])
			{
				for (int k=0;k<i;++k) cout<<s[k];
				cout<<char('a'+j)<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n;cin>>n;
  map<string,ll>mp;
  rep(i,0,n){
    string s;cin>>s;
    mp[s]++;
  }

  out(mp.size());


  return 0;
}


Measured memory_bytes: 19208
#include <iostream>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define equal(a,b) (fabs((a)-(b)) < EPS)

class Point{
public:
  double x,y;

  Point(double x = 0, double y = 0): x(x),y(y){}

  Point operator + (Point p){
    return Point( x+p.x , y+p.y );
  }
  Point operator - (Point p){
    return Point( x-p.x , y-p.y );
  }
  Point operator * (double a){
    return Point( a*x , a*y );
  }

  double abs(){
    return sqrt(norm());
  }
  double norm(){
    return x*x+y*y;
  }

  bool operator < (const Point &p)const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p)const{
    return equal( x,p.x )&& equal( y,p.y );
  }
};

typedef Point Vector;

double dot(Vector a,Vector b){
  return a.x*b.x + a.y*b.y;
}

double cross(Vector a,Vector b){
  return a.x*b.y - b.x*a.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( Point p0 , Point p1 , Point p2 ){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if( cross(a,b) > EPS ) return COUNTER_CLOCKWISE;
  if( cross(a,b) < -EPS ) return CLOCKWISE;
  if( dot(a,b) < -EPS ) return ONLINE_BACK;
  if( a.norm() < b.norm() ) return ONLINE_FRONT;
  return ON_SEGMENT;
}

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;

  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    int a = ccw(Point(x1,y1),Point(x2,y2),Point(xp,yp));
    int b = ccw(Point(x2,y2),Point(x3,y3),Point(xp,yp));
    int c = ccw(Point(x3,y3),Point(x1,y1),Point(xp,yp));

    if(a == b && b == c) cout << "YES" << endl;
    else cout << "NO" << endl;
  }  

  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  for (int i = 1; i < 10; ++i) for (int j = 1; j < 10; ++j) {
    if (n == i * j) {
      return cout << "Yes" << '\n', 0;
    }
  }
  cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int a[5][5], b[15], c[5][5]={},i,j,k,l,n;
  scanf("%d %d %d ",&a[0][0],&a[0][1],&a[0][2]);
	  scanf("%d %d %d ",&a[1][0],&a[1][1],&a[1][2]);
	  scanf("%d %d %d ",&a[2][0],&a[2][1],&a[2][2]);
	scanf("%d", &n);
		for(i=0; i<n; i++){
		scanf("%d", &b[i]);
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
              
				if(b[i]==a[j][k]){
					c[j][k]=1;
				}

			}
		}
	}
  	
	for(j=0;j<3;j++){
		l=0;
	for(i=0;i<3;i++){
		l=l+c[j][i];
		}
      		if(l==3){
			printf("Yes\n");
			return 0;
	}
	}
		for(j=0;j<3;j++){
		l=0;
	for(i=0;i<3;i++){
		l=l+c[i][j];
	}
          		if(l==3){
			printf("Yes\n");
			return 0;
		}
	}
	
	l=0;
	l=c[0][0]+c[1][1]+c[2][2];
	if(l==3){
			printf("Yes\n");
			return 0;
		}
		
		l=0;
	l=c[0][2]+c[1][1]+c[2][0];
	if(l==3){
			printf("Yes\n");
			return 0;
		}
	
	printf("No\n");
	return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

const ll INF = 1e14;

void Main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b), x(q);
  rep(i, a) cin >> s[i];
  rep(i, b) cin >> t[i];
  rep(i, q) cin >> x[i];
  rep(i, q) {
    auto sn = lower_bound(s.begin(), s.end(), x[i]);
    auto tn = lower_bound(t.begin(), t.end(), x[i]);
    ll s1, s2, t1, t2;
    if (sn == s.begin()) s1 = -INF;
    else s1 = *(sn-1);
    if (sn == s.end()) s2 = INF;
    else s2 = *sn;
    if (tn == t.begin()) t1 = -INF;
    else t1 = *(tn-1);
    if (tn == t.end()) t2 = INF;
    else t2 = *tn;
    ll ans = max(s2, t2) - x[i];
    ans = min(ans, x[i] - min(s1, t1));
    ans = min(ans, x[i] - s1  + t2 - s1);
    ans = min(ans, x[i] - t1  + s2 - t1);
    ans = min(ans, s2 - x[i]  + s2 - t1);
    ans = min(ans, t2 - x[i]  + t2 - s1);
    cout << ans << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3712
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	A=LI()

	ans=1
	A.sort()
	for i in range(n):
		ans*=A[i]
		if ans>10**18:
			print(-1)
			exit(0)

	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 86048
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var dg = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var d = dg[0];
            var g = dg[1];
            var pi = new int[d];
            var ci = new int[d];
            var answer = (int)1e9;
            for (var i = 0; i < d; i++)
            {
                var pc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                pi[i] = pc[0];
                ci[i] = pc[1];
            }

            for (var bit = 0; bit < (1 << d); bit++)
            {
                var score = 0;
                var num = 0;
                var maxIndex = 0;
                for (var i = 0; i < d; i++)
                {
                    if (((bit >> i) & 1) == 1)
                    {
                        score += 100 * (i + 1) * pi[i] + ci[i];
                        num += pi[i];
                    }
                    else
                    {
                        maxIndex = i;
                    }
                }

                if (score < g)
                {
                    var max = 100 * (maxIndex + 1);
                    var need = (g - score + max - 1) / max;
                    if (need >= pi[maxIndex]) continue;
                    num += need;
                }
                answer = Math.Min(answer, num);
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
A=input()
B=input()
C=input()

l='a'

for i in range(300):
  if l=='a':
    if len(A)==0:
      print('A')
      exit()
    elif len(A)==1:
      l=A[0]
      A=''
    else:
      l=A[0]
      A=A[1:]
  elif l=='b':
    if len(B)==0:
      print('B')
      exit()
    elif len(B)==1:
      l=B[0]
      B=''
    else:
      l=B[0]
      B=B[1:]
  else:
    if len(C)==0:
      print('C')
      exit()
    elif len(C)==1:
      l=C[0]
      C=''
    else:
      l=C[0]
      C=C[1:]    



Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;
 
struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
void solve()
{
    int n, m; cin >> n >> m;
    int sx, sy, dx, dy; cin >> sx >> sy >> dx >> dy;
    --sx; --sy; --dx; --dy;
    
    vector<string> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
 
    deque<pair<pair<int, int>, int>> q;
    vector<vector<bool>> visited(n, vector<bool>(m, false));
    q.push_back({{sx, sy}, 0});
 
    while (!q.empty()) {
        pair<int, int> pos = q.front().first;
        int weight = q.front().second;
 
        if (pos.first == dx && pos.second == dy) {
            cout << weight << NL;
            return;
        }
 
        q.pop_front();
 
        visited[pos.first][pos.second] = true;
 
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                int nx = pos.first + i;
                int ny = pos.second + j;
 
                if (nx < 0 || ny < 0 || nx >= n || ny >= m || visited[nx][ny] || v[nx][ny] == '#') continue;

                if (abs(i) + abs(j) != 1) {
                    q.push_back({{nx, ny}, weight + 1});
                } else {
                    q.push_front({{nx, ny}, weight});
                }
            }
        }
    }
 
    cout << -1 << NL;
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 9848
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int ap = sc.nextInt();
    int as = sc.nextInt();
    int bp = sc.nextInt();
    int bs = sc.nextInt();
    if(bp < 0){
    	bp *= -1;
    	ap *= -1;
    }
    int time = sc.nextInt();
    int dis = bp - ap;
    int speed = as - bs;
    long tp = (long)speed * time;
    if(tp >= (long)dis){
    	System.out.println("YES");
    }else{
    	System.out.println("NO");
    }

  }
}

Measured memory_bytes: 35780
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int ans = -1;
	rep(n,a*10,2000){
		if( floor(n*0.08)==a && floor(n*0.1)==b ){
			ans = n;
			break;
		}
	}
	if( ans==-1 ) puts("-1");
	else printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    n = int(stdin.readline().rstrip())
    kekka = {"AC":0, "WA":0, "TLE":0, "RE":0}
    
    for _ in range(n):
        s = stdin.readline().rstrip()
        kekka[s] += 1
    
    for i,j in kekka.items():
        print(i,"x",j)
        
main()

Measured memory_bytes: 27216
#include <iostream>

using namespace std;

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

    if (n % 2 == 0) {
        long long res = 0;
        for (long long i = 10; n / i > 0; i *= 5) {
            res += n / i;
        }
        cout << res << endl;
    } else {
        cout << "0" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (max(a, c) - min(a, c) <= d || max(a, b) - min(a, b) <= d && max(b, c) - min(b, c) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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


int main(){
    string s;
    cin>>s;
    int cnt=0;
    int ans=0;
    
    rep(i,(int)s.size()){
        
        if(s[i]=='R'){
            cnt++;
            ans=cnt;
        }
        else cnt=0;
    }
    cout<<ans;
    
    }



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> ans;
    int sum = 0, mx = 0;
    for (int i = 1; i <= N; ++i) {
        sum += i;
        if (N <= sum) {
            mx = i;
            break;
        }
    }

    for (int i = 1; i <= mx; ++i) {
        if (i != sum - N) cout << i << endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
using namespace std;
ll a,b,d;
char c;
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
cin>>a;
cin>>c;
cin>>b;
cin>>c;
cin>>d;
if(a>2019){
    cout<<"TBD";
    return 0;
}else if(b>4&&a==2019){
    cout<<"TBD";
    return 0;
}else if(d>30&&b==4&&a==2019){
cout<<"TBD";
return 0;}
cout<<"Heisei";
return 0;}



Measured memory_bytes: 256
def kangaru(x):
    count = 0
    i = 0
    while count < x:
        count += i
        i += 1
#    while count != x:
#        if count + (i * 2 + 1) <= x:
#            count += i
#        elif count + i == x:
#            count += i
#        i += 1
    return i - 1

def main():
    x = int(input())
    print(kangaru(x))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
// AOJ 1030 Cubes Without Holes
// 2018.2.3 bal4u@uu

#include <stdio.h>
#include <string.h>

char buf[15], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

char f[500][500][3];

int main()
{
	int n, h, a, b, i, t, ans;
	char *c;

	while (fgets(p=buf, 15, stdin) && *p != '0') {
		n = in(), h = in();

		memset(f, 0, sizeof(f));
		ans = n*n*n - n*h;
		while (h--) {
			fgets(p=buf, 15, stdin);
			c = p, p += 3, a = in()-1, b = in()-1;
			if (*c == 'x' && *(c+1) == 'y') {
				f[a][b][0] = 1;
				i = n; while (i--) {  
					t = 0;
					if (f[a][i][1]) t++;
					if (f[b][i][2]) t++;
					if (t) ans++;
				}
			} else if (*c == 'x' && *(c+1) == 'z') {
				f[a][b][1] = 1;
				i = n; while (i--) {  
					t = 0;
					if (f[a][i][0]) t++;
					if (f[i][b][2]) t++;
					if (t) ans++;
				}
			} else {
				f[a][b][2] = 1;
				i = n; while (i--) {  
					t = 0;
					if (f[i][a][0]) t++;
					if (f[i][b][1]) t++;
					if (t) ans++;
				}
			}
		}

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


Measured memory_bytes: 2400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long

using namespace std;
int n;
ll W;
ll w[105];
ll v[105];
ll dp[105][105][305];
int main()
{
    scanf("%d%lld",&n,&W);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&w[i],&v[i]);
        memset(dp,0,sizeof(dp));
        for(int i=1;i<=n;i++)
          for(int j=1;j<=i;j++)
          for(int k=0;k<=3*i;k++)
          {
      dp[i][j][k]=max(dp[i-1][j][k],dp[i][j][k]);
      if(k-(w[i]-w[1])>=0)
     dp[i][j][k]=max(dp[i-1][j-1][k-(w[i]-w[1])]+v[i],dp[i][j][k]);}
          ll maxx=0;
          for(int j=1;j<=n;j++)
            for(int k=0;k<=3*j;k++)
             {if((ll)(j*w[1]+k)<=W)

            maxx=max(maxx,dp[n][j][k]);}
            printf("%lld\n",maxx);
            return 0;
}


Measured memory_bytes: 26496
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main(){
  string s;
  cin >> s;
  set<char> table;
  if(s.length()==26){
    bool y=true;
    for(int i=24;i>=0;--i){
      if(s[i]<s[i+1]){
        if(i>0){
        cout<<s.substr(0,i);
        }
        for(int j=25;j>i;--j){
          if(s[j]>s[i]){
            cout<<s[j]<<endl;
          break;
          }
        }
        y=false;
        break;
      }
    }
    if(y)cout<<-1<<endl;
  }
  else{
    for(int i =0;i <s.length();++i){
      table.insert(s[i]);
    }
    for(char c='a';c<='z';++c){
      if(table.count(c)==0){
        cout<<s<<c<<endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
unsigned long long gcd(unsigned long long x,unsigned long long y){return y?gcd(y,x%y):x;}//再帰関数
unsigned long long lcm(unsigned long long x,unsigned long long y){return x/gcd(x,y)*y;}//最大公約数
int main(){
    unsigned long long n,t,ans=1;
    cin>>n;
    for(int i = 0; i < n; i++){cin>>t;ans=lcm(ans,t);}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func checkEven(a []int) bool {
	for i := 0; i < len(a); i++ {
		if a[i] % 2 != 0 {
			return false
		}
	}
	return true
}

func main() {
    var (
		n	int
		count = 0
	)
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	for checkEven(nums) {
		for i := 0; i < n; i++ {
			nums[i] /= 2
		}
		count ++
	}
	fmt.Println(count)
}

Measured memory_bytes: 1784
#include<stdio.h>
int longth[110][110];
int main()
{
    int a,b,c,n,m,cou,i,j,k;
    while(scanf("%d%d",&n,&m),n + m)
    {
        for(i = 0; i < n + 1; i++)
        {
            for(j = 0; j < n + 1; j++)
            {
                longth[j][i] = -1;
            }
        }
        for(i = 0; i < m; i++)
        {
            scanf("%d%d%d",&a,&b,&c);
            if(a == 0)printf("%d\n",longth[b][c]);
            else
            {
                scanf("%d",&a);
                if(longth[b][c] > a || longth[b][c] == -1)
                {
                    longth[b][c] = a;longth[c][b] = a;
                    cou = 1;
                    while(cou != 0)
                    {
                        cou = 0;
                        for(j = 0; j < n; j++)
                        {
                            if(longth[j][b] != -1)
                            {
                                for(k = j + 1; k < n + 1; k++)
                                {
                                    if(longth[k][b] != -1 && (longth[j][k] == -1 || longth[j][b] + longth[k][b] < longth[j][k]))
                                    {
                                        longth[j][k] = longth[j][b] + longth[k][b];
                                        longth[k][j] = longth[j][k];
                                        cou = 1;
                                    }
                                }
                            }
                        }
                        for(j = 0; j < n; j++)
                        {
                            if(longth[j][c] != -1)
                            {
                                for(k = j + 1; k < n + 1; k++)
                                {
                                    if(longth[k][c] != -1 && (longth[j][k] == -1 || longth[j][c] + longth[k][c] < longth[j][k]))
                                    {
                                        longth[j][k] = longth[j][c] + longth[k][c];
                                        longth[k][j] = longth[j][k];
                                        cou = 1;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<utility>
#include<cstring>
#include<algorithm>
#define RI register int
#define CI const int&
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef pair <int,int> pi;
const int N=1005;
int n,mod,f[N],c[N],cnt,ans; pi t[N];
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline int Mod(int x)
{
	while (x>=mod) x-=mod; while (x<0) x+=mod; return x;
}
inline int F(CI x)
{
	int y=0; while (y<(n<<1)&&x*x+y*y<n*n) ++y; return y;
}
inline int G(CI x)
{
	int y=0; while (y<(n<<1)&&x*x+y*y<=(n<<1)*(n<<1)) ++y; return y;
}
int main()
{
	RI i,j,k; scanf("%d%d",&n,&mod);
	for (i=0;i<n;++i) t[++cnt]=mp(F(i),-i);
	for (i=n;i<(n<<1);++i) t[++cnt]=mp(G(i),1);
	for (i=0;i<n;++i) c[i]=G(i); sort(t+1,t+cnt+1);
	//for (i=1;i<=cnt;++i) printf("%d%c",t[i]," \n"[i==cnt]);
	for (k=0;k<=n;++k)
	{
		memset(f,0,(k+1)<<2); f[0]=1; int s1=0,s2=0;
		for (i=1;i<=cnt;++i) if (t[i].se==1)
		{
			for (j=0;j<=s2;++j) f[j]=1LL*f[j]*Mod(t[i].fi-s1-j)%mod; ++s1;
		} else
		{
			for (j=s2;~j;--j) inc(f[j+1],1LL*f[j]*Mod(t[i].fi-s1-j)%mod),
			f[j]=1LL*f[j]*Mod(c[-t[i].se]-(n+k+s2-j))%mod; ++s2;
		}
		//printf("%d %d\n",k,f[k]);
		if (k&1) inc(ans,Mod(-f[k])); else inc(ans,f[k]);
	}
	return printf("%d",ans),0;
}

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


signed main() {
  std::string s;
  int x,y,r=0,v=0,c=0,ff=0,gg=0,ss,sc;
  std::vector<int> f,g;
  std::cin >> s >> x >> y;
  ss=s.length();
  for(int i;i<ss;i++){
    c++;
    if(s[i]=='F'){
      x--;
    } else {
      break;
    }
  }
  sc=ss-c;
  if(sc){
  } else {
    if(x==0){
      if(y==0){
        puts("Yes");
        return 0;
      }
    }
    puts("No");
    return 0;
  }
  for(int i;i<sc;i++){
    if(s[i+c]=='F'){
      r++;
    } else {
      if(v){
        if(r){
          f.push_back(r);
          ff++;
        }
        v=1-v;
      } else {
        if(r){
          g.push_back(r);
          gg++;
        }
        v=1-v;
      }
      r=0;
    }
  }
  if (r) {
    if(v){
      f.push_back(r);
      ff++;
    } else {
      g.push_back(r);
      gg++;
    }
  }
  sort(f.rbegin(),f.rend());
  sort(g.rbegin(),g.rend());
  for(int i;i<ff;i++){
    if(x>0){
      x-=f[i];
    } else {
      x+=f[i];
    }
  }
  for(int i;i<gg;i++){
    if(y>0){
      y-=g[i];
    } else {
      y+=g[i];
    }
  }
  if(x==0){
    if(y==0){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
# input here
_INPUT = """\
4 5
0 5
-2 4
3 4
4 -4
"""

def main():
    # -*- coding: utf-8 -*-
    # スペース区切りの整数の入力
    N, D = map(int, input().split())
    xy = [list(map(int, input().split())) for i in range(N)]
    
    answer = []

    for j in range(len(xy)):
        # 距離求める
        distance = math.sqrt((xy[j][0]**2 + xy[j][1]**2))

        # Dとdistance比較する
        if D >= distance:
            answer.append(distance)

    print(len(answer))

if __name__ == '__main__':
    import io
    import sys
    import math

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 51696
def main():
    c = []
    for _ in range(3):
        c.append(list(map(int, input().split())))
    for i in range(101):
        flag1 = False
        flag2 = False
        b0 = c[0][0] - i
        b1 = c[0][1] - i
        b2 = c[0][2] - i
        a10 = c[1][0] - b0
        a11 = c[1][1] - b1
        a12 = c[1][2] - b2
        if a10 == a11 == a12:
            flag1 = True
        else:
            continue
        a20 = c[2][0] - b0
        a21 = c[2][1] - b1
        a22 = c[2][2] - b2
        if a20 == a21 == a22:
            flag2 = True
            break
    if flag1 and flag2:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()


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

vector<int> num(int &n) {
  vector<int> digit;
  while (n > 0) {
    digit.push_back(n % 10);
    n /= 10;
  }
  return digit;
}

int main() {
  int n, m;
  cin >> n >> m;
  bool flag1 = false;
  bool flag = false;
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < m; i++){
    cin >> s[i];
    cin >> c[i];
    if (n == 1 && c[i] == 0) flag1 = true;
  }

  for (int i = pow(10, n - 1); i < pow(10, n); i++){
    int x = i;
    vector<int> digit = num(x);
    for (int k = 0; k < m; k++){
        if (digit[n - s[k]] == c[k]) flag = true;
        else {
          flag = false;
          break;
        }
    }

    if (flag){
      cout << i; 
      break;
    }
  }

  if (flag1) cout << 0;
    else {
    if (m == 0) {
      if (n == 1) cout << 0;
      else if (n == 2) cout << 10;
      else cout << 100;
    }
    else if (!flag) cout << -1;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int n=read(),x=read(),m[999];
int main(){
int i;
for (i=1;i<=n;++i) x-=m[i]=read();
sort(m+1,m+n+1);
write(n+x/m[1]);
}

Measured memory_bytes: 256