akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
   ll n,i;
   cin>>n;
   string ans;
   while(n>0){
       if(n%26==0)ans+='z';
       else
        ans+=('a' + (n-1)%26);
       n-=1;
       n/=26;
   }
   reverse(ans.begin(),ans.end());
   cout<<ans;
}

Measured memory_bytes: 3628
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
        Array.Sort(a);
        Array.Reverse(a);
        var alice = 0;
        var bob = 0;
        for (int i = 0; i < N; i++)
            if (i % 2 == 0) alice += a[i];
            else bob += a[i];
        var answer = alice - bob;
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

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

int main(){
  int cnt=0;
  vector<char> s(10);
  rep(i,3){
    cin >> s.at(i);
    if(s.at(i) == '1'){
      cnt++;
    }
  }
  
  
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		if (S.length() <= K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0, K) + "...");
		}
	}

}


Measured memory_bytes: 38612
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int k, x;
    cin >> k >> x;
    for (Int i = -1000000; i <= 1000000; i++) {
        if (abs(x - i) < k) {
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}

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

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class AWeLoveGolf {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;
    rep(i, 1000) {
      if (A <= K * i and K * i <= B) {
        cout << "OK" << Endl;
        return;
      }
    }
    cout << "NG" << endl;
  }
};


signed main() {
  AWeLoveGolf solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll gcd(ll a, ll b)
{
    return (b ? gcd(b, a % b) : a);
}
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    string a,b;
    cin >> a >> b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
        c("YES");
    }else{
        c("NO");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int a,b,c,d;
    b=c=d=a=0;
    cin >> a >> b >> c >> d;
    if(abs(c-a)<=d || (abs(b-a)<=d&&abs(c-b)<=d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

const int mod = 1000000007;

int dp[100005][40];
map < int, int > mp;
int main()
{
	int N, M;
	

	dp[0][0] = 1;

	cin >> N >> M;

	for ( int i = 1; i < 100005; i++ ) {
		for ( int j = 0; j < 40; j++ ) {
			dp[i][j] = dp[i - 1][j];
			if ( j > 0 ) (dp[i][j] += dp[i][j - 1]) %= mod;
		}
	}


	for ( int i = 2; i <= M; i++ ) {
		while ( M % i == 0 ) {
			mp[i]++;
			M /= i;
		}
	}

	int ans = 1;
	for ( auto &x : mp ) {
		ans = ((long long)ans * dp[N][x.second]) % mod;
	}

	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 16000
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

#define pb push_back

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define MOD(x, y) (((y) + (x) % (y)) % (y))

int main(int argc, char* argv[])
{
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	printf("%d\n", min(A * N, B));
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		int num;
		int point_Taro=0;
		int point_Hanako=0;
		int Taro, Hanako;
		char[] charstr_Taro;
		char[] charstr_Hanako;
		String str;
		String[] str_array;
		int len_Taro, len_Hanako;


		try{

			num=Integer.parseInt(reader.readLine());

			for(int i=0;i<num;i++){
				str=reader.readLine();
				str_array=str.split(" ");
				charstr_Taro=str_array[0].toCharArray();
				charstr_Hanako=str_array[1].toCharArray();

				len_Taro=charstr_Taro.length;
				len_Hanako=charstr_Hanako.length;


				for(int j=0;j<len_Taro&&j<len_Hanako;j++){//???????????????????????????????????????
					Taro=charstr_Taro[j];
					Hanako=charstr_Hanako[j];

					if(Taro>Hanako){

						point_Taro+=3;
					    break;
					}else if(Taro<Hanako){

						point_Hanako+=3;
					    break;
					}

					if(j==len_Taro-1 && len_Taro<len_Hanako){
						point_Hanako+=3;
						break;
					}else if(j==len_Hanako-1 && len_Taro>len_Hanako){
						point_Taro+=3;
						break;
					}else if(j==len_Taro-1&&len_Taro==len_Hanako){
					point_Hanako++;
					point_Taro++;
					break;}
				}



			}//num?????°????????????
			System.out.println(point_Taro+" "+point_Hanako);

		}catch(IOException e){
			System.out.print(e);
		}
	}

}

Measured memory_bytes: 25280
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		System.out.printf("%d %d\n",num1 * num2,(num1 + num2) * 2);
		sc.close();
	}	
}


Measured memory_bytes: 26300
#include <stdio.h>

int main()
{
	int x[3000], y[3000];
	int a, b, i;
	int p = 0;

	for(i=0;i<3000;i++){
		scanf("%d\n", &x[i]);
		scanf("%d\n", &y[i]);
		a = x[i];
		b = y[i];
		if(a==0 && b==0){
			break;
		}
		p++;
	}

	for(i=0;i<p;i++){
		a = x[i];
		b = y[i];
		if(a<b || a==b){
			printf("%d %d\n", a, b);
		}else if(b<a){
			printf("%d %d\n", b, a);
		}else if(a==0 && b==0){
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 2100
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Set;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    String[] s = str.split("");
    Set<String> st = new HashSet<>();
    for(int i=0; i<str.length(); i++) {
      st.add(s[i]);
    }
    System.out.println(str.length()==st.size()?"yes":"no");
  }
}

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

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	if (!(h % 2 == 0)) return 0;
	cout << (((a + b) * h) / 2) << endl;

	return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>

int main(){
  int n,i,k;
  int a[100];
  scanf("%d", &n);
  for(k=0;k<n;k++){
    scanf("%d", &a[k]);
  }
  for(i=n-1;i>=0;i--){
    if(i!=n-1) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
/*  Seventeen and we got a dream to have a family           */
/*  A house and everything in between                       */
/*  And then, oh, suddenly we turned twenty-three           */
/*  Now we got pressure for taking our life more seriously  */
/*  We got our dead-end jobs and got bills to pay           */
/*  Have old friends and know our enemies                   */
/*  Now I, I'm thinking back to when I was young            */
/*  Back to the day when I was falling in love              */
/*  He used to meet me on the Eastside                      */
/*  In the city where the sun don't set                     */

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;

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

ll t=1;
//cin>>t;
while(t--)
{

ll n,m,k;
cin>>n>>m>>k;
ll i;
string s[n];

for(i=0;i<n;i++)
cin>>s[i];
ll ans=0;

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

   for(ll j=0;j<(1<<m);j++)
   {
       ll cn=0;
    for(ll k=0;k<n;k++)
     {

      for(ll p=0;p<m;p++)
       {
         if((i&(1<<k)) && (j&(1<<p)) && s[k][p]=='#')
         cn++;
       }


     }

if(cn==k)
ans++;

   }

}

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



















Measured memory_bytes: 3628
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	while (N) {
		set<pair<long double, string> >s;
		for (int i = 0; i < N; i++) {
			string t;
			long double  p, a, b, c, d, e, f, n, m;
			cin >> t >> p >> a >> b >> c >> d >> e >> f >> n >> m;
			s.insert({ 1000-((f*n*m - p) / (a + b + c + d*m + e*m)) ,t });
		}
		for (auto i : s) {
			cout << i.second << endl;
		}
		cout << "#\n";
		cin >> N;
	}
	return 0;
}

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

using namespace std;

using vvint_t = vector<vector<int>>;
using vpair_t = vector<pair<int, int>>;

void print(vvint_t& s){
  int H = s.size();
  int W = s.at(0).size();
  for (int h = 0; h < H; h++){
    for (int w = 0; w < W; w++){
      int v = s.at(h).at(w);
      if (v == -1){
	cout << '#';
      }else if (v != INT_MAX){
	cout << v;
      }else{
	cout << ' ';
      }
    }
    cout << endl;
  }
}

void print(vpair_t& P){
  for (auto itr = P.begin(); itr != P.end(); itr++){
    cout << "(" << itr->first << "," << itr->second << ") ";
  }
  cout << endl;
}

void warp_search(vvint_t& S, vpair_t& P, int h, int w, int v);

void paint(vvint_t& S, vpair_t& P, int h, int w, int v){

  // (h,w)をvにする
  S.at(h).at(w) = v;
  P.push_back(make_pair(h, w));

  //cout << h << " " << w << endl;
  //print(S);

  // 上下左右の評価
  int c;

  // 左
  c = S.at(h).at(w-1);
  if (c != -1 && c > v){
    paint(S, P, h, w-1, v);
  }

  // 上
  c = S.at(h-1).at(w);
  if (c != -1 && c > v){
    paint(S, P, h-1, w, v);
  }

  // 右
  c = S.at(h).at(w+1);
  if (c != -1 && c > v){
    paint(S, P, h, w+1, v);
  }

  // 下
  c = S.at(h+1).at(w);
  if (c != -1 && c > v){
    paint(S, P, h+1, w, v);
  }

  // ワープ可能箇所を探してペイントする
  //warp_search(S, h, w, v+1);
}

void warp_search(vvint_t& S, vpair_t& P, int h, int w, int v){

  for (int nh = h-2; nh <= h+2; nh++){
    for (int nw = w-2; nw <= w+2; nw++){
      int c = S.at(nh).at(nw);
      if (c != -1 && c > v){
	//paint(S, P, nh, nw, v);
	P.push_back(make_pair(nh, nw));
      }
    }
  }
}

int main(){
  int H, W, Ch, Cw, Dh, Dw;
  
  cin >> H >> W;
  cin >> Ch >> Cw;
  cin >> Dh >> Dw;

  vvint_t S(H+4, vector<int>(W+4, -1));

  for (int h = 0; h < H; h++){
    string t;
    cin >> t;
    for (int w = 0; w < t.size(); w++){
      if (t[w] == '#'){
	S.at(h+2).at(w+2) = -1;
      }else{
	S.at(h+2).at(w+2) = INT_MAX;
      }
    }
  }

  //print(S);
  
  vpair_t P;		// paint()で塗りつぶした座標
  vpair_t X;		// warp_seaerch()でワープ先が見つかった座標
  int v = 0;
  paint(S, P, Ch+1, Cw+1, v);

  while(true){
    v++;
    for (auto itr = P.begin(); itr != P.end(); itr++){
      warp_search(S, X, itr->first, itr->second, v);
    }
    if (X.size() == 0){
      break;
    }
    P.clear();
    for (auto itr = X.begin(); itr != X.end(); itr++){
      int c = S.at(itr->first).at(itr->second);
      if (c != -1 && c > v){
	paint(S, P, itr->first, itr->second, v);
      }
    }
    if (P.size() == 0){
      break;
    }
    X.clear();
  }

  int g = S.at(Dh+1).at(Dw+1);
  if (g != INT_MAX){
    cout << g << endl;
  }else{
    cout << "-1" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 7784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N, A, B; cin >> N >> A >> B;
	ll T = B - A;
	if (T < 0) {
		cout << "0" << endl;
	} else if (T == 0) {
		cout << "1" << endl;
	} else if (N == 1) {
		cout << "0" << endl;
	} else if (N == 2) {
		cout << "1" << endl;
	} else {
		ull ans = 1 + (N - 2) * T;
		cout << ans << endl;
	}
}


Measured memory_bytes: 3588
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int A[110000], S[110000];

int main(){
	long long int N, M, V, P;
	cin >> N >> M >> V >> P;
	for(int i = 1; i <= N; i++){
		cin >> A[i];
	}
	sort(A + 1, A + N + 1);
	A[N + 1] = INF;
	for(int i = 1; i <= N; i++){
		S[i] = S[i - 1] + A[i];
	}
	int ans = 0;
	int pos = 1;
	for(int i = 1; i <= N; i++){
		while(A[i] + M >= A[pos]){
			pos += 1;
		}
		if(N - pos + 1 >= P){
			continue;
		}
		if(i + P - 1 >= N + 1){
			ans += 1;
			continue;
		}
		long long int S1 = S[N + 1 - (P - 1) - 1] - S[i];
		//cout << N - (P - 1) - i << endl; 
		if((V - i - (P - 1)) * M + S1 <= (A[i] + M) * (N - (P - 1) - i)){
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

    int N, M;
    int h[100000];
    int i;
    int a, b;
    int flag[100000] = {0};
    // 0がよい展望台
    int result = 0;


    cin >> N >> M;
    for(i=0; i<N; i++){
        cin >> h[i];
    }

    for(i=0; i<M; i++){
        cin >> a >> b;
        a --;
        b --;
        if(h[a] > h[b]){
            flag[b] = 1;
            //cout << h[a] <<" > " << h[b] << endl;
        }
        else if(h[a] < h[b]){
            flag[a] = 1;
            //cout << h[a] <<" < " << h[b] << endl;
        }
        else{
           flag[b] = 1;
            flag[a] = 1;
        }
    }
    for(i=0; i<N; i++){
        if(flag[i] == 0){
            result ++;
            //cout << "oooo" << i << endl;
        }
    }
    cout << result << endl;

}

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

int d;
vector<int> num;
int dp[10005][105][2];
int mod = 1e9+7;
int calc(int pos,int rem,int f)
{
    if(pos==num.size())
        return (rem==0);

    if(dp[pos][rem][f]!=-1)
        return dp[pos][rem][f];
    
    int lim=0,res=0;
    if(f==0)
        lim = num[pos];
    else 
        lim = 9;

    for(int i=0;i<=lim;i++)
    {
        int nf = f;
        int nrem = (rem+i)%d;
        if(i<lim)
            nf = 1;
        res = ( res+calc(pos+1,nrem,nf) )%mod;
    }

    return (dp[pos][rem][f] = res);
}

int solve(string x)
{
	for(int i=0;i<x.length();i++)
		num.push_back(x[i]-'0');
	memset(dp,-1,sizeof(dp));
    return calc(0,0,0);
}

int32_t main()
{
	string k;
	cin>>k>>d;
	cout<<(solve(k)-1LL+mod)%mod<<endl;
	return 0;	
}

Measured memory_bytes: 17664
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, num + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD


N = int(input())
x = list(map(int, input().split()))
MOD = 10 ** 9 + 7


ans = 0
k = 1
for i in range(1, N):
  k = k * i % MOD

com = comb(N, MOD)

t = 0
for i in range(1, N):
  t = (t + k * com.I[i]) % MOD
  ans = (ans + (x[i] - x[i - 1]) * t) % MOD

print(ans)

Measured memory_bytes: 76440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
//
//		while (true) {
//			long x = scan.nextLong();
//			if (x == 0l) {break;}
//			long sum = 0l;
//			while (x != 0l) {
//				sum += x % 10l;
//				x /= 10l;
//			}
//			sb.append(sum + "\n");
//		}
//		System.out.print(sb);

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	}

}

Measured memory_bytes: 26488
from sys import stdin
import queue

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

ans = 0

for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        else:
            q = queue.Queue()
            q.put((h, w, 0))
            temp_h = h
            temp_w = w
            visited = [[0] * W for _ in range(H)]
            visited[h][w] = 1
            while q.qsize() > 0:
                temp = q.get()
                temp_h = temp[0]
                temp_w = temp[1]
                temp_d = temp[2]
                ans = max(ans, temp_d)
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] == 0:
                    visited[temp_h + 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h + 1, temp_w, temp_d + 1))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] == 0:
                    visited[temp_h - 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h - 1, temp_w, temp_d + 1))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] == 0:
                    visited[temp_h][temp_w + 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w + 1, temp_d + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] == 0:
                    visited[temp_h][temp_w - 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w - 1, temp_d + 1))

print(ans)

Measured memory_bytes: 111464
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

LL p5(LL x) {
  return x * x * x * x * x;
}

LL x;

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  cin >> x;

  map<LL, int> mp;
  for (LL i = -1000; i <= 1000; i++) {
    mp[p5(i)] = i;
  }

  for (LL b = -1000; b <= 1000; b++) {
    LL a5 = x + p5(b);
    if (mp.find(a5) != mp.end()) {
      cout << mp[a5] << " " << b << endl;
      break;
    }
  }


  return 0;
}

Measured memory_bytes: 3760
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] str = reader.readLine().split(" ");
		int[] abc = new int[str.length];
		for (int i = 0; i < 3; i++) {
			abc[i]= Integer.parseInt(str[i]);
		}
		if (abc[0] == abc[1] && abc[1] == abc[2]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(0)
#define ll 				long long int
#define ld 				long double
#define mk 				make_pair
#define pb 				push_back
#define f				first
#define s				second
#define fo(i,a,b) 		for(i=a;i<b;i++)
#define foe(i,a,b) 		for(i=a;i<=b;i++)
#define all(x)			x.begin(),x.end()
// #define vi 				vector<int>
#define vl 				vector <long long int>
// #define pii 			pair <int,int>
#define pll 			pair <long long int, long long int>
// #define vpii			vector< pair<int,int> >
#define vpll 			vector < pair <long long int,long long int> >
#define MOD				1000000007
using namespace std;
const int inf = INT_MAX;
const ll inf64 = LLONG_MAX;

vl factors;
void primeFactors(ll n)
{
	// Print the number of 2s that divide n
	while (n % 2 == 0)
	{
		factors.pb(2);
		n = n / 2;
	}

	// n must be odd at this point. So we can skip
	// one element (Note i = i +2)
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		// While i divides n, print i and divide n
		while (n % i == 0)
		{
			factors.pb(i);
			n = n / i;
		}
	}

	// This condition is to handle the case when n
	// is a prime number greater than 2
	if (n > 2)
		factors.pb(n);
}

vector< pair<ll, ll> > CompressArray(vl arr)
{
	ll n = factors.size();
	vector < pair<ll, ll> > res;
	for (ll i = 0; i < n; i++)
	{
		if (res.size() == 0) res.push_back(make_pair(arr[i], 1));
		else
		{
			if (arr[i] == res[res.size() - 1].first) res[res.size() - 1].second++;
			else res.push_back(make_pair(arr[i], 1));
		}
	}
	return res;
}

int main()
{
	boost;
	ll n, i;
	cin >> n;
	if (n == 1) {
		cout << 0;
		return 0;
	}
	primeFactors(n);
	if (factors.size() == 1) {
		cout << 1;
		return 0;
	}
	vpll fact = CompressArray(factors);
	ll ans = 0;
	fo(i, 0, fact.size())
	{
		ans += (ll)((-1 + sqrt(1 + 8 * fact[i].s)) / 2);
	}
	cout << ans;







	return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
 
int a[(1 << 18) + 5];
 
int main(){
 
    int n; cin >> n;
    int maxi = 0;
    multiset<int> ms;
    for(int i = 0; i < (1 << n); i++){
        cin >> a[i];
        maxi = max(maxi, a[i]);
        ms.insert(a[i]);
    }
    if(ms.count(maxi) > 1){
        puts("No");
        return 0;
    }
    
    multiset<int> ms_cur; ms_cur.insert(maxi);
    for(int i = 0; i < n; i++){
        vector<int> aux;
        for(int x : ms_cur){
            if(ms.empty()){
                puts("No");
                return 0;
            }
            auto it = ms.lower_bound(x);
            if(it == ms.begin()){
                puts("No");
                return 0;
            }
            it--;
            aux.push_back(*it);
            ms.erase(it);
        }
        for(int x : aux)
            ms_cur.insert(x);
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 14328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;i++)
const ll mod=1e9+7;
const ll maH = 2020, maW = 2020;

ll H,W;
string S[maH];
ll L[2020][2020],R[maH][maW],U[maH][maW],D[maH][maW];

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

void func(){

    rep(i,H){

        rep(j,W){
            if(S[i][j] != '#'){
                if(j == 0){
                    L[i][j] = 1;
                }else {
                    L[i][j] = L[i][j-1] + 1;
                }
            }

        }

        for(int j=W-1;j>=0;j--){
            if(S[i][j] != '#'){
                if(j == W-1){
                    R[i][j] = 1;
                }else {
                    R[i][j] = R[i][j+1] + 1;
                }
            }
        }
    }

    rep(i,W){

        rep(j,H){
            if(S[j][i] != '#'){
                if(j == 0){
                    U[j][i] = 1;
                }else {
                    U[j][i] = U[j-1][i]+1;
                }
            }
        }

        for(int j=H;j>=0;j--){
            if(S[j][i] != '#'){
                if(j == H-1){
                    D[j][i] = 1;
                }else {
                    D[j][i] = D[j+1][i]+1;
                }
            }
        }
    }
}

int main(){
    cin >> H >> W;
    rep(i,H)cin >> S[i];
    Fill(L,0);
    Fill(R,0);
    Fill(U,0);
    Fill(D,0);

    ll ans = 0;
    func();
    rep(i,H){
        rep(j,W){
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 131840
#include<iostream>
		#include<vector>
		#include<algorithm>
		#include <string>
		#include<cmath>
		#include<map>
		#include<cstdio>
		#include<stack>
		#include<queue>

		using namespace std;

		#define ok printf("ok\n");
		#define ok1 printf("ok1\n");
		#define ok2 printf("ok2\n");
		#define MAX 1000000
		#define rep(i,n) for(int i=0;i<n;i++)
		#define REP(i,s,n) for(int i=(s);i<(n);i++)
		#define repr(i,n) for(int i=n-1;i>=0;i--)
		#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
		#define all(a) (a).begin(),(a).end()
		#define reall(a) (a).rbegin(),(a).rend()
		#define pb push_back
		#define s string

		typedef vector<int> vi;
		typedef vector
 vs;
		typedef long long ll;
		typedef vector<ll> vll;
		int facctorialMethod(int k);
		int gcd(int a, int b);
		int main()
		{
			int a,b,c;
			cin >> a>>b>>c;
			if((c-b)%2 == 0)
				cout << "Alice";
			else
				cout << "Borys";
			return 0;
		}

Measured memory_bytes: 256
private fun List<IntRange>.zipWithIndices() =
        mapIndexed { first, range ->
            range.map { second -> Pair(first, second) }
        }.flatten()

private fun Iterable<Long>.product() = reduce { a, b -> a * b }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = (0 until N).map { readLine()!! }
    val nums = S.map { it.first() }.groupBy { it }.mapValues { it.value.size.toLong() }
    val march = "MARCH".map { nums[it] ?: 0 }

    val sum = (0 until 5).map { (it + 1 until 5) }.zipWithIndices().map { pair ->
        val (first, second) = pair
        (0 until 5).filter { it != first && it != second }.map { march[it] }.product()
    }.sum()
    println(sum)
}

Measured memory_bytes: 39328
N=int(input())
L=list(map(int,input().split()))
count=0
sum=0
A=float("inf")
for i in L:
	sum+=abs(i)
	A=min(A,abs(i))
	if i<0:
		count+=1
if count%2==0:
	print(sum)
else:
	print(sum-A*2)

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

int main(void)
{
    string a,b,c;
    cin >> a >> b >> c;

    if(a.back() == b.front() && b.back() == c.front())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")

using namespace std;

int main() {
  int N, Q;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  for (int i = 1; i <= N; ++i) cin >> V[i] >> W[i];
  cin >> Q;
  constexpr int b = 9;
  vector<pair<int, int>> l1, l2, tmp;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    l1.clear();
    l2.clear();
    auto gen = [&](vector<pair<int, int>> &l, int thr) {
      l.emplace_back(0, 0);
      while (v >= thr) {
        int p1 = 0, p2 = 0;
        while (p1 < l.size() || p2 < l.size()) {
          pair<int, int> nxt;
          if (p1 < l.size() && l[p1].first < l[p2].first + W[v])
            nxt = l[p1++];
          else
            nxt = {l[p2].first + W[v], l[p2++].second + V[v]};
          if (tmp.empty() || tmp.back().second < nxt.second) tmp.push_back(nxt);
        }
        v /= 2;
        l.swap(tmp);
        tmp.clear();
      }
    };
    gen(l1, 1 << b);
    gen(l2, 1);
    int p1 = 0, p2 = 0;
    while (p2 + 1 < l2.size() && l1[p1].first + l2[p2 + 1].first <= L) p2++;
    int ans = l1[p1].second + l2[p2].second;
    while (++p1 < l1.size() && l1[p1].first <= L) {
      while (l1[p1].first + l2[p2].first > L) p2--;
      ans = max(ans, l1[p1].second + l2[p2].second);
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 5360
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
string nodetype[3] = {"root", "internal node", "leaf"};

struct tree{
	int parent, child, next;
};

int type(tree &node){

	if (node.parent == -1) return 0;
	else if (node.child == -1) return 2;
	else return 1;

}

int depth(vector <tree> &node, int e){
	int tmp = node[e].parent;

	if (tmp == -1) return 0;
	else return depth(node, tmp) + 1;
}

string children(vector <tree> &node, int i){
	stringstream ss;
	bool f = true;

	ss << "[";	
	int e = node[i].child;
	while (e!=-1){
		if (f) f = false;
		else ss << ", ";

		ss << e;
		e = node[e].next;
	}
	ss << "]";

	return ss.str();
}

int main(void){
	int n, e, nc, tmp, tmp2;
	string text;
	stringstream ss;

	cin >> n;
	vector <tree> node(n);
	for (int i=0; i<n; i++){
		node[i].parent = -1;
		node[i].child = -1;
		node[i].next = -1;
	}

	for (int i=0; i<n; i++){
		cin >> e;

		if (cin>>nc, nc != 0){
			for (int j=0; j<nc; j++){
				cin >> tmp;
				if (j==0) node[e].child = tmp;
				else node[tmp2].next = tmp;
				node[tmp].parent = e;
				tmp2 = tmp;
				}
		}
	}

	for (int i = 0; i<n; i++){
		ss.str("");
		ss << "node " << i <<": ";
		ss << "parent = " << node[i].parent << ", ";
		ss << "depth = " << depth(node, i) << ", ";
		e = type(node[i]);
		ss << nodetype[e] << ", ";
		ss << children(node, i);
		cout << ss.str() << endl;
	}

	return 0;
}

Measured memory_bytes: 4504
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
	int a , b , c ;
	cin >> a >> b >> c ;
	cout << a + b + c - max(a,max(b,c));
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n;
char s[N];
int cnt[N];
int main(){
	cin>>s+1;
	n=strlen(s+1);
	For(i,1,n)
		cnt[s[i]-'a']++;
	LL ans=1;
	For(i,1,n)
		ans+=min(i-1,n-i);
	For(i,1,n-1)
		ans+=min(i,n-i);
	For(i,0,25)
		ans-=(LL)cnt[i]*(cnt[i]-1)/2;
	cout<<ans<<endl;
	return 0;
}

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

void solve() 
{
    ll a=INT_MAX,b=-INT_MAX,c=INT_MAX,d=-INT_MAX;
    int n;cin>>n;
    while(n--){
        ll x,y;cin>>x>>y;
        a=min(a,x+y);
        b=max(b,x+y);
        c=min(c,x-y);
        d=max(d,x-y);
    }
    cout<<max(b-a,d-c)<<endl;
}

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'
//*
int main() {
  int n;
  cin >> n;
  vector<pii> l(n);
  rep (i, n) {
    cin >> l[i].first;
  }
  sort(all(l));
  rep (i, n) l[i].second = i;
  ll ans = 0;
  rep (i, n) {
    for (int j = i + 1; j < n; j++) {
      int x = l[i].first, y = l[j].first;
      int max_z = x + y;
      int min_z = y;
      min_z = max(min_z, y - x + 1);
      ans += lower_bound(all(l), pii(max_z, -inf)) - lower_bound(all(l), pii(min_z, j + 1));
    }
  }
  cout << ans << endl;
}
//*/


Measured memory_bytes: 256
def lucas(n, memo={}):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = lucas(n - 1, memo) + lucas(n - 2, memo)
        return lucas(n - 1) + lucas(n - 2)


n = int(input())
print(lucas(n))


Measured memory_bytes: 3060
#!/usr/bin/env python3
import numpy as np
import math
import re

n = input()
n = re.split(" ",n)

if(abs(int(n[0]) - int(n[1])) <= int(n[3]) and abs(int(n[1]) - int(n[2])) <= int(n[3])):
    print('Yes')
elif(abs(int(n[0]) - int(n[2])) <= int(n[3])):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21136
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <algorithm>
#include <queue>
#include <climits>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template <typename T>
using V = vector<T>;

struct E {
	int t, c;
};

struct P {
	int c, t, k;
	bool operator < (P a) const {return c > a.c;}
};

int main() {
	for (int c, n, m, s, d; c = in, n = in, m = in, s = in, d = in;) {
		s--, d--;
		V<V<E>> v(n, V<E>());
		times(i, m) {
			int a {(int) in - 1}, b {(int) in - 1}, f {in};
			v[a].push_back({b, f});
			v[b].push_back({a, f});
		}
		V<V<int>> dp(n, V<int>(c + 1, INT_MAX / 2));
		dp[s][c] = 0;
		priority_queue<P> q;
		q.push({0, s, c});
		while (!q.empty()) {
			P t = q.top();
			q.pop();
			if (t.t == d) {
				outl(t.c);
				break;
			}
			if (dp[t.t][t.k] < t.c)
				continue;
			for (E e: v[t.t]) {
				auto f = [&](int c, int k) {
					if (dp[e.t][k] > dp[t.t][t.k] + c) {
						dp[e.t][k] = dp[t.t][t.k] + c;
						q.push({dp[e.t][k], e.t, k});
					}
				};
				if (t.k > 0)
					f(e.c / 2, t.k - 1);
				f(e.c, t.k);
			}
		}
	}
}


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

int main(){
  int n, i;
  scanf("%d", &n);
  int w[n];
  int sum = 0;
  int s1[n];
  for(i = 0; i < n; i++){
    scanf("%d", &w[i]);
    sum += w[i];
    s1[i] = sum;
  }
  int min = abs(2 * s1[0] - sum);
  for(i = 0; i < n - 1; i++){
    if(min > abs(2 * s1[i] - sum)){
      min = abs(2 * s1[i] - sum);
    }
  }
  printf("%d\n", min);
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N, mi=200000, ma=-1;
  cin >> N;
  vector<ll> a(N);
  map<ll,ll> mp;
  rep(i,N) {
    ll x;
    cin >> x;
    mp[x]++;
    mi = min(mi, x);
    ma = max(ma, x);
  }

  if (mi == ma) {
    // すべてがことなる色（全てのネコがaloneな）とき
    if (mi == N-1) {
      cout << "Yes" << endl;
      return 0;
    }

    // すべてのネコが組になっている場合
    if (mi <= N/2) {
      cout << "Yes" << endl;
      return 0;
    }
  } else if (ma == mi + 1) {
    ll x = mp[mi]; // aloneなネコの数
    ll y = mp[ma]; // 組になっているネコの数

    // ma: 色の種類数
    // 少なくとも1組以上は存在して（x<ma）、なおかつ
    // 組になっているネコの数は2*(ma-x)以上
    if (x < ma && 2*(ma-x) <= y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 7296
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _splitNum = splitNum(lines[0]),
      _splitNum2 = _slicedToArray(_splitNum, 2),
      N = _splitNum2[0],
      P = _splitNum2[1];

  var max = Math.floor(Math.pow(P, 1 / N) + 0.0001);

  if (N === 1) {
    console.log(P);
    return;
  }

  var res = 1;

  for (var i = 2; i <= max; i++) {
    if (P % Math.pow(i, N) === 0) {
      res = i;
    }
  }

  console.log(res);
}

function gcd(a, b) {
  if (a < b) return gcd(a, b);
  if (b === 0) return a;
  var r = a % b;
  return gcd(b, r);
}

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

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 26052
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))
a,v=l_in()
b,w=l_in()
t=n_in()

if b > a:
    if b + w*t <= a + v*t:
        print("YES")
    else:
        print("NO")
elif a > b:
    if b - w*t >= a - v*t:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


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

#define MAX 1001

int dp[MAX][MAX];
int v[MAX], w[MAX];

int main() {
	int W, n, u = 0;
	char t;
	while (cin >> W) {
		if (W == 0) break;
		cin >> n;
		u++;

		for (int i = 0; i < n; i++) {
			cin >> v[i] >> t >> w[i];
		}

		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= W; j++) {
				if (w[i - 1] <= j) {
					dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
				} else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}

		int mv, mw;
		mv = mw = 0;
		for (int i = 0; i <= W; i++) {
			if (dp[n][i] > mv) {
				mv = dp[n][i];
				mw = i;
			}
		}

		cout << "Case " << u << ":" << endl;
		cout << mv << endl;
		cout << mw << endl;
	}
	return 0;
}

Measured memory_bytes: 6948
# AtCoder Beginner Contest 157: C (2020/03/07)
import math
A, B = map(int, input().split())
X = math.ceil(A/0.08)
Z = -1
while True:
    if int(X*0.08) != A:
        break
    if int(X*0.10) == B:
        Z = X
        break
    X = X + 1
print(Z)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
#define mem(a, b) memset(a, b, sizeof a)
#define mid ((l + r) >> 1)
#define lch l, mid, o << 1
#define rch mid + 1, r, o << 1 | 1

using namespace std;
const int N = 2e5 + 5, P = 998244353;
typedef long long ll;
int n, q, tag[N*4]; ll ten = 1, g[N*4], c[N*4];
void pushup(int o) { c[o] = (c[o<<1] + c[o<<1|1]) % P; }
void put(int v, int o) { c[o] = g[o] * v % P, tag[o] = v; }
void pushdown(int o) {
	if(~tag[o]) put(tag[o], o<<1), put(tag[o], o<<1|1), tag[o] = -1;
}
void bld(int l, int r, int o) {
	tag[o] = -1;
	if(l == r) return g[o] = c[o] = ten, ten = ten * 10 % P, void();
	bld(rch), bld(lch), pushup(o), g[o] = c[o];
}
void upd(int L, int R, int v, int l, int r, int o) {
	if(L <= l && r <= R) return put(v, o);
	pushdown(o);
	if(L <= mid) upd(L, R, v, lch);
	if(R > mid) upd(L, R, v, rch); 
	pushup(o);
}

int main() {
	cin >> n >> q, bld(1, n, 1);
	while(q--) {
		int l, r, v; scanf("%d%d%d", &l, &r, &v);
		upd(l, r, v, 1, n, 1), printf("%lld\n", c[1]);
	}
	return 0;
}

Measured memory_bytes: 13996
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int r,g,b,n,ans=0; cin>>r>>g>>b>>n;
    rep(i,n+1){
        rep(j,n+1){
            int num=n-i*r-j*g;
            if(0<=num && num%b==0) ans++;
        }
    } 
    cout<<ans<<endl;
}

Measured memory_bytes: 256