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

int main() {
  int64_t n;
  std::cin >> n;
  int64_t m;
  std::cin >> m;

  std::vector<bool> r(n, false);

  std::vector<std::pair<int64_t, int64_t>> f(m);
  for (auto &i : f) {
    std::cin >> i.first >> i.second;
    i.first--;
    i.second--;
    if (i.first == 0) {
      r[i.second] = true;
    }
    if (i.second == 0) {
      r[i.first] == true;
    }
  }

  for (const auto &i : f) {
    if ((r[i.first] && i.second == n - 1) || (r[i.second] && i.first == n - 1)) {
      std::cout << "POSSIBLE" << std::endl;
      return 0;
    }
  }

  std::cout << "IMPOSSIBLE" << std::endl;
  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>                                                                               
using namespace std;
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)
int main () {
  int a, b, i;
  cin >> a >> b;
  if (a < b) {
    FOR(i, b) {
      cout << a;
    }   
    cout << endl;
  } else {
    FOR(i, a) {
      cout << b;
    }   
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b, cnt = 0;
	cin >> a >> b;
	for (int i=a; i<=b; i++)
	{
		if((i%10 == i/10000) && (((i%100)/10) == ((i/1000)%10)))
		{
			//cout << i << endl;
			cnt ++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  string s;
  cin >> s;
  int a=0;
  int b=0;
  int c=0;
  int n=s.size();
  rep(i,n){
    if(s.at(i)=='a')a++;
    else if(s.at(i)=='b')b++;
    else if(s.at(i)=='c')c++;
  }
  int x=abs(a-b);
  int y=abs(b-c);
  int z=abs(c-a);
  if(x>=2 || y>=2 || z>=2){
    cout << "NO" << endl;
  }
  else cout << "YES" << endl;
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<vector>

void display( std::vector<int> A ){
    for( int i = 0; i < A.size(); i++ ){
      std::cout << A[i];
      if( i < A.size()-1 ) std::cout << " ";
      else std::cout << std::endl;
  }
}

int bubblesort( std::vector<int>& A, int N ){
  int cnt = 0;
  for( int i = 1; i < N; i++ ){
    for( int j = i; j > 0; j-- ){
      //display( { A[j-1], A[j] } );
      if( A[j-1] > A[j] ){
        std::swap( A[j], A[j-1] );
        cnt++;
      } else  break;
      //display( A );
    }
  }
  return cnt;
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for( auto &a : A ) std::cin >> a;

  int cnt = bubblesort( A, N );

  display( A );

  std::cout << cnt << std::endl;

}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string t,s;
    cin>>t>>s;
    int i=0;
    while(1)
    {
        i=t.find(s,i);
        if(t.find(s,i)!=t.npos)
        {
            cout<<i<<'\n';
            i++;
        }
        else
        {
            break;
        }
    }

}



Measured memory_bytes: 4504
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>
#include <random>
#include <time.h>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	int A[200200];
	int B[200200];
	int ACount[200200];
	int BCount[200200];
	for(int i = 0; i < 200200; i++){
		ACount[i] = 0;
		BCount[i] = 0;
	}
	clock_t start = clock();
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		ACount[A[i]]++;
	}
	for(int i = 0; i < N; i++){
		cin >> B[i];
		BCount[B[i]]++;
	}
	int over = 0;
	for(int i = 1; i <= N; i++){
		if(ACount[i] > 0 && BCount[i] > 0){
			over = max(over, ACount[i] + BCount[i]);
		}
	}
	if(over > N){
		cout << "No" << endl;
		return 0;
	}else{
		cout << "Yes" << endl;
	}
	reverse(B, B+N);
	int counter = 0;
	std::random_device rnd;
	while(static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0 < 1920){
		for(int i = 0; i < N; i++){
			if(A[i] == B[i]){
				int next = rnd() % N;
				int temp = B[next];
				B[next] = B[i];
				B[i] = temp;
				if(A[next] == B[next]){
					int nextnext = rand() % N;
					int temp2 = B[nextnext];
					B[nextnext] = B[next];
					B[next] = temp2;
				}
			}
		}
	}
	
	for(int i = 0; i < N; i++){
		cout << B[i] << " ";
	}
	cout << endl;
	
	return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

// #define mod (ll)(1e9 + 7)
ll ModVal = mod;

struct ModInt {
  ll x;

  ModInt(ll _x = 0) : x((_x % ModVal + ModVal) % ModVal) {
  }

  ModInt operator-() {
    return ModInt(-x);
  }
  ModInt& operator+=(const ModInt a) {
    x += a.x;
    if (x >= ModVal)
      x -= ModVal;
    return *this;
  }
  ModInt& operator-=(const ModInt a) {
    x = x + ModVal - a.x;
    if (x >= ModVal)
      x -= ModVal;
    return *this;
  }
  ModInt& operator*=(const ModInt a) {
    x *= a.x;
    x %= ModVal;
    return *this;
  }

  ll ext_gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
      x = 1;
      y = 0;
      return a;
    }
    ll tmp = a / b;
    ll d = ext_gcd(b, a - b * tmp, y, x);
    y -= tmp * x;
    return d;
  }

  // 逆元
  ModInt inv() {
    ll u, v;
    ext_gcd(x, ModVal, u, v);
    return ModInt(u);
  }

  ModInt inv(const ModInt a) {
    ll u, v;
    ext_gcd(a.x, ModVal, u, v);
    return ModInt(u);
  }

  ModInt& operator/=(const ModInt a) {
    return (*this) *= inv(a);
  }

  ModInt operator+(const ModInt a) {
    ModInt retval(*this);
    return retval += a;
  }
  ModInt operator-(const ModInt a) {
    ModInt retval(*this);
    return retval -= a;
  }
  ModInt operator*(const ModInt a) {
    ModInt retval(*this);
    return retval *= a;
  }
  ModInt operator/(const ModInt a) {
    ModInt retval(*this);
    return retval /= a;
  }

  ModInt pow(ll n) {
    ModInt ans(1);
    while (n) {
      if (n & 1)
        ans = ans * x;
      *this = (*this) * (*this);
      n = n >> 1;
    }
    return ans;
  }

  const ll& value() {
    return this->x;
  }
};

ostream& operator<<(ostream& os, const ModInt& a) {
  os << a.x;
  return os;
}

using mint = ModInt;
using vm = vector<mint>;
using vvm = vector<vm>;
using vvvm = vector<vvm>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll k;
  cin >> k;

  if (k == 2 || k == 5) {
    cout << -1 << endl;
    return 0;
  }

  ModVal = k;
  mint v = 0;
  mint pow10 = 1;
  REP(i, (ll)1e7) {
    v += mint(7) * pow10;
    pow10 *= 10;
    if (v.value() == 0) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3632
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a):
    return [0 for i in range(a)]

def Zeros(a,b):
    if(b<=0):
        return Zeros(a)
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



n,ave = list(map(int, input().split()))
a = list(map(int, input().split()))

dp = [Zeros(3000,n+1) for k in range(n+1)]

dp[0][0][0] = 1
for i in range(n):
    for j in range(2900):
        for k in range(n):
            dp[i+1][j+a[i]][k+1] += dp[i][j][k]
            dp[i+1][j][k] += dp[i][j][k]

            
ans = 0
for k in range(n):
    ans+= dp[-1][ave*(k+1)][k+1]
print(ans)

















































Measured memory_bytes: 134232
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int x, y, z;

    cin >> x >> y >> z;

    printf("%d %d %d", z, x, y);
}

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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
sum = 0
leaf = gets.split.map(&:to_i)
leaf.map{|n| sum += n}
done = false
count = 0
nodes = []
answer = -1

if N == 0 
    if leaf.first == 0
        puts 0
        return
    end
    if leaf.first == 1
        puts 1
        return
    end
    puts answer
    return
end    

leaf.each_with_index do | n , i |
    if i == 0
        nodes << 1
        next
    end

    max_next_nodes = ( nodes[ i - 1 ] - leaf[ i - 1 ] ) * 2
    if  max_next_nodes  < leaf [i]
        break
    end

    sum = sum - leaf [ i-1 ]
    
    
    if sum <= max_next_nodes
        nodes << sum
        next
    end

    nodes << max_next_nodes

end

if nodes.length == leaf.length
    done = true 
end

if ! done
    puts answer
else
    nodes.map{|n| count += n}
    puts count
end


Measured memory_bytes: 23252
# Problem C - Same Integers

# input
A, B, C = map(int, input().split())

# initialization
num_list = sorted([A, B, C])
sa = num_list[2] - num_list[1]
count = sa

# count 1
for i in range(3):
    if num_list[i]<num_list[2]:
        num_list[i] += sa

# count 2
num_list = sorted(num_list)
if num_list[0]<num_list[1] and num_list[0]<num_list[2]:
    if (num_list[1]-num_list[0])%2==0:
        count += (num_list[1]-num_list[0])// 2
    else:
        count += (num_list[1]-num_list[0])// 2 + 2
elif num_list[2]>num_list[0] and num_list[2]>num_list[1]:
    count += 1

# output
print(count)


Measured memory_bytes: 3064
N = int(input())
last = int(repr(N)[-1])
if (last == 2):
    print("hon")
elif last == 4:
    print("hon")
elif last == 5:
    print("hon")
elif last == 7:
    print("hon")
elif last == 9:
    print("hon")
elif last == 0:
    print("pon")
elif last == 1:
    print("pon")
elif last == 6:
    print("pon")
elif last == 8:
    print("pon")
else :
    print("bon")

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

ll A[3];

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

	for (ll i = 0; i < 3; i++) {
		cin >> A[i];
	}

	ll x = *max_element(A, A+3);

	for (ll i = x; ; i++) {
		ll cur = 0;
		for (ll j = 0; j < 3; j++) {
			cur += i - A[j];
		}
		if (cur % 2 == 0) {
			cout << cur / 2 << "\n";
			return 0;
		}
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int a, b; char c;
	while (true) {
		cin >> a >> c >> b;
		if (c == '?') return 0;
		if (c == '+') cout << a + b << endl;
		if (c == '-') cout << a - b << endl;
		if (c == '*') cout << a * b << endl;
		if (c == '/') cout << a / b << endl;
	}
}


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

string S;

int main(){
    cin >> S;
    long long ans = 0, buf = 0;
    for(int i = 0; i < S.size(); ++i){
        if(S[i] == 'B') ++buf;
        else if(S[i] == 'W') ans += buf;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		double L = scanner.nextInt();
		double x = L/3;
		//System.out.println(x);
		double V = x*x*x;
		System.out.println(V);
	}
}

Measured memory_bytes: 22736
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){ 
    ll s,w; cin>>s>>w;
    if(w>=s) cout<<"unsafe";
    else cout<<"safe";
    return 0;
}   

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {

  int n;
  double x1,y1,x2,y2,x3,y3,x4,y4;
  int i;
  char c;
  
  scanf("%d",&n);

  //c=getchar();

  for(i=0;i<n;i++) {
    
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);

    if(x2-x1==0.0) {
      if(x4-x3==0.0) printf("YES\n");
      else printf("NO\n");
    }

    else if((x2-x1)*(y4-y3)==(x4-x3)*(y2-y1)) printf("YES\n");
    else printf("NO\n");

  }

  return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
	unsigned long n,c2,c5;

	while(1){
		cin>>n; if(n==0) return 0;
		c2=0; c5=0;
		for(unsigned long i=1;i<=n;i++){
			unsigned long j=i;

			while(j%2==0){c2++;j/=2;}
			j=i;
			while(j%5==0){c5++;j/=5;}
		}
		if(c2>=c5)cout<<c5<<endl;
		else cout<<c2<<endl;
	}
}

Measured memory_bytes: 0
using System;

namespace A___Poor
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var c = int.Parse (input[2]);
            if (a == b && b != c || b == c && a != b || a == c && a != b)
                Console.WriteLine ("Yes");

            else
                Console.WriteLine ("No");

        }
    }
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;
int index;

int main()
{
    bool attendance[31];
    
    for(int i = 0; i < 31; i++) {
        attendance[i] = true;
    }
    
    for(int i = 0; i < 28; i++) {
        cin >> index;
        attendance[index] = false; 
    }
    
    for(int j = 1; j < 31; j++) {
        if(attendance[j]) {
            cout << j << endl;
        }
    }
    
}



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

bool is_ok(vector<pair<int, vector<int>>> cnct, vector<int> swt, vector<int> cnd, int M){
  for(int i = 0; i < M; i++){
    int count = 0;
    for(int j = 0; j < cnct.at(i).first; j++){
      count += swt.at(cnct.at(i).second.at(j) - 1);
    }
    if(count % 2 != cnd.at(i)){
      return false;
    }
  }
  return true;
}


void srch(int a, vector<pair<int, vector<int>>> cnct, vector<int> &swt, vector<int> cnd, int &ans, int N, int M){
  if(a == N){
    if(is_ok(cnct, swt, cnd, M)){
      ans++;
    }
    swt.at(a - 1) = 1;
    if(is_ok(cnct, swt, cnd, M)){
      ans++;
    }
    swt.at(a - 1) = 0;
    return;
  }
  srch(a + 1, cnct, swt, cnd, ans, N, M);
  swt.at(a - 1) = 1;
  
  srch(a + 1, cnct, swt, cnd, ans, N, M);
  swt.at(a - 1) = 0;
  return;
}


int main(){
  int N, M;
  cin >> N >> M;
  
  // 対応するスイッチの読み込み
  vector<pair<int, vector<int>>> cnct(M);
  for(int i = 0; i < M; i++){
    int a;
    cin >> a;
    
    vector<int> vec(a);
    for(int j = 0; j < a; j++){
      cin >> vec.at(j);
    }
    
    cnct.at(i) = make_pair(a, vec);
  }
  
  // 光る条件の読み込み
  vector<int> cnd(M);
  for(int i = 0; i < M; i++){
    cin >> cnd.at(i);
  }
  
  vector<int> swt(N, 0);
  
  int ans = 0;
  srch(1, cnct, swt, cnd, ans, N, M);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int x,a,b;
	cin>>x>>a>>b;
	if(a>=b) cout<<"delicious"<<endl;
	else if(x>=b-a) cout<<"safe"<<endl;
	else cout<<"dangerous"<<endl;
	return 0;
}

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

using namespace std;

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

	vector<char> ans;

	for (int i = 0; N >= 0; i++) {
		N -= 1;
		ans.push_back((char)(N % 26L + 97L));
		if (N >= 26L)
			N /= 26L;
		else
			N = -1;
	}
	reverse(ans.begin(), ans.end());

	for (int i = 0; i < (int)ans.size(); i++) {
		cout << ans.at(i);
	}
	cout << endl;
	return 0;
}

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

int main(){
    vector<int> x(5);
    int i;
    rep(i, 5){cin >> x.at(i);}
    rep(i, 5){
        if(x.at(i) == 0){
            cout << i+1 << endl;
        }
    }
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    auto i = find(s.begin(), s.end(), 'A');
    auto j = find(s.rbegin(), s.rend(), 'Z');
    ll ans = distance(s.begin(),i);
    ll anss = distance(s.rbegin(), j);
    cout << s.size()-(anss + ans) << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int n; cin >> n;
    //愚直にやって間に合う？
    for(int i = 1; i <= n; i++){
        ll ans = 0;
        for(int x = 1; x <= 100; x++){
            if(x*x > i) break;
            for(int y = 1; y <= 100; y++){
                if(x*x + y*y > i) break;
                for(int z = 1; z <= 100; z++){
                    if(x*x + y*y + z*z + x*y + y*z + z*x > i) break;
                    if(x*x + y*y + z*z + x*y + y*z + z*x == i){
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
  int N, Q;
  while(cin >> N >> Q && (N|Q)) {
    int date[100];
    fill(date,date+100,0);
    for(int i = 0; i < N; ++i) {
      int M;
      cin >> M;
      while(M--) {
	int d;
	cin >> d;
	++date[d];
      }
    }
    int ans = 0;
    for(int i = 1; i < 100; ++i)
      if(date[i] > date[ans]) ans = i;
    cout << (date[ans] >= Q ? ans : 0) << endl;
  }
  return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
	}
	double sum = 0.0;
	for (int i = 0; i < n; i++) {
		if (u[i].compare("JPY") == 0) {
			sum += x[i];
		} else {
			sum += (380000.0 * x[i]);
		}
	}
	cout << sum << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
ll k; 
int main(){
	scanf("%lld",&k);
	printf("50\n");
	ll x=k/50,y=k%50;
	for(int i=0;i<50;i++)
		if(i<y) printf("%lld\n",i+x+51-y);
		else printf("%lld\n",i+x-y);
	return 0;
}

Measured memory_bytes: 3812
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop
import itertools


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = input()

a = 0
if S == 'SUN':
    a = 0
elif S == 'MON':
    a = 1
elif S == 'TUE':
    a = 2
elif S == 'WED':
    a = 3
elif S == 'THU':
    a = 4
elif S == 'FRI':
    a = 5
elif S == 'SAT':
    a = 6

print(7-a)


Measured memory_bytes: 20384
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s; cin >> s;
    map<char, int> m;
    set<char> st;
    int res = 100000;
    for (char tc: s) {
        if (st.find(tc) != st.end()) {
            continue;
        }
        st.insert(tc);

        int tmp = 0;
        int mx = 0;
        for (char c: s) {
            if (c != tc) {
                tmp++;
            } else {
                mx = max(tmp, mx);
                tmp = 0;
            }
        }
        mx = max(tmp, mx);
        res = min(res, mx);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

monster_sum = sum(A)

for i in range(N):
    if B[i] >= A[i]:
        B[i] -= A[i]
        A[i] = 0
        A[i + 1] -= min(A[i + 1], B[i])
    else:
        A[i] -= B[i]
        B[i] = 0
        
rest_sum = sum(A)

print(monster_sum - rest_sum)

Measured memory_bytes: 19244
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, k, q; cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> ans(n, 0);
    rep(i, q){
        cin >> a[i];
        --a[i];
        ++ans[a[i]];
    }

    vector<bool> res(n);
    rep(i, n){
        if(k - q + ans[i] > 0) res[i] = true;
        else res[i] = false;
    }

    rep(i, n){
        cout << (res[i] ? "Yes" : "No");
        cout << endl;
    }

return 0;
}

Measured memory_bytes: 3992
import sys
def input(): return sys.stdin.readline().rstrip()
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n # 親(uf.find()で経路圧縮して根)の番号。根の場合は-(そのグループの要素数)
    def find(self,x):
        #グループの根を返す
        if self.parents[x]<0:return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        #要素x,yのグループを併合
        x,y=self.find(x),self.find(y)
        if x==y:return
        if self.parents[x]>self.parents[y]:#要素数の大きい方をxに
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x #要素数が大きい方に併合
    def roots(self):
        #全ての根の要素のリスト
        return [i for i, x in enumerate(self.parents) if x<0]
    def group_count(self):
        #グループの数
        return len(self.roots())

def main():
    n,m=map(int,input().split())
    uf=UnionFind(n)
    XYZ=[tuple(map(int,input().split())) for i in range(m)]
    for x,y,_ in XYZ:
        uf.unite(x-1,y-1)
    print(uf.group_count())


if __name__=='__main__':
    main()

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

int main(){
    string a;
    int s = 0;
    cin>>a;
    int na = a.size();

    for(int i = 0; i<na; i++){
        if(a[i] == '7')
       s++;
    }
    if(s!=0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


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

int main()
{
	int V,D;
	while(cin >> V >> D)
	{
		int s=0,f[2];
		f[0]=f[1]=1;
		
		bool t[1024]={0};
		for(int i=0; i<V; i++)
		{
			f[s]+=f[1-s];
			f[s]%=1001;
			t[f[s]]=1;
			s=1-s;
		}


		int p=-1,c=0;
		for(int i=0; i<1001; i++)
		{
			if(t[i])
			{
				if(i-p>=D && p!=-1)
				{
					c++;
				}
				p=i;
			}
		}
		cout << c+1 << endl;
	}
}

Measured memory_bytes: 0
lines = readlines.map{|line| line.split(' ')}
rep=lines[0][1].to_i
gu=lines[1][0].to_i
cyo=lines[1][1].to_i
pa=lines[1][2].to_i
pafo=lines[2][0]
a=[]
b=[]
d=0
for i in 0..lines[0][0].to_i-1
  a.push(pafo[i])
end
for j in 0..rep-1
  if a[j]=="r" then
    b[j]="p"
    d=d+pa
  elsif a[j]=="s" then
    b[j]="r"
    d=d+gu
  elsif a[j]=="p" then
    b[j]="s"
    d=d+cyo
  end
end
for k in rep..lines[0][0].to_i-1  
  if a[k]=="r"&&b[k-rep]!="p" then
    b[k]="p"
    d=d+pa
  elsif a[k]=="s"&&b[k-rep]!="r" then
    b[k]="r"
    d=d+gu
  elsif a[k]=="p"&&b[k-rep]!="s" then
    b[k]="s"
    d=d+cyo
  else
    b[k]=nil
  end
end
p d

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(void)
{
  ll n, m; cin >> n >> m;
  vector<ll> p(m);
  vector<string> s(m); REP(i, m) cin >> p[i] >> s[i];
  ll ans = 0;
  vector<ll> pen(n+1); REP1(i, n) pen[i] = 0;

  vector<bool> ac(n+1);
  REP1(i, n) ac[i] = false;
  REP(i, m) {
    if(ac[p[i]]) {
    } else {
      if(s[i] == "AC") {
	ac[p[i]] = true;
	ans++;
      } else {
	pen[p[i]] ++;
      }
    }
  } 
  ll pt = 0;
  REP1(i, n) {
    if(ac[i]) pt += pen[i];
  }
  cout << ans << " " << pt << endl;
  // cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 7296
#include<stdio.h>

void trace(int A[],int N);
void insertionSort(int A[],int N);

int main(void)
{
  int N,i;
  int A[100];

  scanf("%d",&N);

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

  trace(A,N);
  insertionSort(A,N);

  return 0;
}

void insertionSort(int A[],int N)
{
  int i,j,v;

  for(i=1;i<N;i++)
    {
      v=A[i];
      j=i-1;
      while(j>=0&&A[j]>v)
	{
	  A[j+1]=A[j];
	  j--;
	}
      A[j+1]=v;

      trace(A,N);
    }
}

void trace(int A[],int N)
{
  int i;

  for(i=0;i<N;i++)
    {
      if(i>0)
	{
	  putchar(' ');
	}
	  printf("%d",A[i]);
	}
      putchar('\n');
    }




Measured memory_bytes: 2144
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

signed main() {
    int N, S;
    cin >> N >> S;

    if (S > N) {
        cout << -1 << endl;
        return 0;
    }
    if (S == N) {
        cout << N + 1 << endl;
        return 0;
    }

    // 以下 S < N
    // bを√N以上にすると2桁になる
    // 各桁の和は S = x + y where xb + y = N (1 <= x <= √N)
    // y = S - x
    // xb = N - y

    for (int b = 2; b <= sqrt(N); b++) {
        int num = N;
        int s = 0;
        while (num > 0) {
            s += num % b;
            num /= b;
        }
        if (s == S) {
            cout << b << endl;
            return 0;
        }
    }

    int mn_b = INF;
    bool found = false;
    for (int x = 1; x <= sqrt(N); x++) {
        int y = S - x;
        if (y < 0 || N - y < 0) continue;
        if ((N - y) % x != 0) continue;
        int b = (N - y) / x;
        if (y < b && b > sqrt(N)) {
            mn_b = min(mn_b, b);
            found = true;
        }

    }

    if (!found) {
        cout << -1 << endl;
        return 0;
    }

    cout << mn_b << endl;
    return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    string rlt;

    if (A == B) rlt = "Draw";
    else if (A == 1) rlt = "Alice";
    else if (B == 1) rlt = "Bob";
    else if (A > B) rlt = "Alice";
    else rlt = "Bob";

    cout << rlt << endl;

    return 0;
}

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

int main() {

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

        int cnt=0;

        for(int x=0; x<=k; x++)
            for(int y=0; y<=k; y++)
                if(s-x-y>=0 && s-x-y<=k)
                    cnt++;

        cout<<cnt<<endl;

    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int>arr;
int dp[20][150][2];
int getsum(int n,int sum,int flag,int ind)
{
	if(ind>n)return sum;
	int limit=9;
	if(!flag)limit = arr[ind];
	if(dp[ind][sum][flag]!=-1)return dp[ind][sum][flag];
	int res=0;
	for(int i=0;i<=limit;i++)
	{
		if(flag || i<limit)
		{
			res = max(res,getsum(n,sum+i,true,ind+1));
		}
		else {
			res = max(res,getsum(n,sum+i,false,ind+1));
		}
	}
	return dp[ind][sum][flag]=res;
}
int main() {
	// your code goes here
	cin.tie(NULL);
	cout.tie(NULL);
	unsigned long long n;
	while(cin>>n)
	{
		int k=0;
		memset(dp,-1,sizeof(dp));
		arr.clear();
		// arr.push_back;
		while(n>0)
		{
			arr.push_back(n%10);
			n/=10;
			k++;
		}
		reverse(arr.begin(),arr.end());
		arr.resize(k);
		int res = getsum(k-1,0,0,0);
		cout<<res<<endl;
	}
	return 0;
}

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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s,w;
    cin >> s >>w;
    if(w>=s){
    	cout << "unsafe\n";
    }
    else{
    	cout << "safe\n";
    }
    

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e3+20 , M = 230;
int n,m,b[M][N],L[M][N],R[M][N],st[N],top;
ll sum[N][N],a[N],ans;
inline void input(void)
{
    scanf("%d%d",&n,&m);
    for (int i=2;i<=n;i++)
        scanf("%lld",&a[i]) , a[i] += a[i-1];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            scanf("%d",&b[j][i]);
}
inline void solve(void)
{
    for (int i=1;i<=m;i++)
    {
        for (int j=1;j<=n;j++)
        {
            while ( top && b[i][j] >= b[i][st[top]] )
                R[i][st[top]] = j-1 , top--;
            st[++top] = j;
        }
        while ( top ) R[i][st[top]] = n , top--;
        for (int j=n;j>=1;j--)
        {
            while ( top && b[i][j] >= b[i][st[top]] )
                L[i][st[top]] = j+1 , top--;
            st[++top] = j;
        }
        while ( top ) L[i][st[top]] = 1 , top--;
        for (int j=1;j<=n;j++)
        {
            sum[L[i][j]][j] += b[i][j];
            sum[L[i][j]][R[i][j]+1] -= b[i][j];
            sum[j+1][j] -= b[i][j];
            sum[j+1][R[i][j]+1] += b[i][j];
        }
    }
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    for (int i=1;i<=n;i++)
        for (int j=i;j<=n;j++)
            ans = max( ans , sum[i][j] - a[j] + a[i] );
}
int main(void)
{
    input();
    solve();
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 210176
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();

        System.out.println((int)Math.ceil(n / (double) x) * t );

    }
}


Measured memory_bytes: 35636
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

ans = []

def solve(R0, W0, C, R):
    if C*W0 <= R0 :
        return 0
    else :
        return (W0 * C - R0 - 1) // R + 1


while True :
    R0, W0, C, R = LI()
    if R0 == 0:
        break
    ans.append(solve(R0, W0, C, R))

for a in ans:
    print(a)



Measured memory_bytes: 8180
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<ll,ll> pll ;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];*/
int main()
{
	fast;
	ll x;
	cin>>x;
	ll a,a1,b,b1,c,c1,d,d1;
	a=x%500;
	a1=x/500;
	b1=a/5;
	cout<<1000*a1+5*b1;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define int long long
const int N=1e5+10,M=3e5+10,p=998244353,inv2=(p+1)>>1;
int n,m,v[N];
char l[N],r[N],u[N],d[N];
int fac[M],inv[M];
inline int C(int x,int y){
	return fac[x]*inv[x-y]%p*inv[y]%p;
}
inline int solve(int n,int m,char *l,char *r,char *u,char *d){
	memset(v,0,sizeof v);
	int ln=count(l+1,l+n+1,'1');
	int rn=count(r+1,r+n+1,'1');
	int un=0,dn=0,qu1=1,qu2=1;
	for (int i=1;i<=m;++i){
		if (u[i]=='0'&&d[i]=='0') {v[i]=v[i-1];continue;}
		if (ln==0) v[i]=(un==0&&dn==0); else v[i]=C(ln+un+dn-1,ln-1);
		v[i]=(v[i]*qu1+v[i-1])%p;
		if (u[i]=='1'&&d[i]=='1') qu1=qu1*inv2%p,qu2=qu2*2%p;
		un+=u[i]=='1';
		dn+=d[i]=='1';
	}
	if (ln+rn+un+dn==0) {puts("1");exit(0);}
	int ans=0;
	un=dn=0;
	for (int i=m;i;--i){
		if (u[i]=='0'&&d[i]=='0') continue;
		if (rn==0) ans=(ans+(un==0&&dn==0)*v[i]*qu2)%p; else ans=(ans+C(rn+un+dn-1,rn-1)*v[i]%p*qu2)%p;
		if (u[i]=='1'&&d[i]=='1') qu2=qu2*inv2%p;
		un+=u[i]=='1';
		dn+=d[i]=='1';
	}
	return ans;
}
main(){
	fac[0]=1;for (int i=1;i<M;++i) fac[i]=fac[i-1]*i%p;
	inv[0]=inv[1]=1;for (int i=2;i<M;++i) inv[i]=inv[p%i]*(p-p/i)%p;
	for (int i=2;i<M;++i) inv[i]=inv[i]*inv[i-1]%p;
	scanf("%lld%lld%s%s%s%s",&n,&m,l+1,r+1,u+1,d+1);
	printf("%lld",((solve(n,m,l,r,u,d)+solve(m,n,u,d,l,r))%p+p)%p);
	return 0;
}

Measured memory_bytes: 6144
n = int(input())
lst = list(map(int, input().split()))
count = 0
t = 0
for i in range(n):
    if i == 0:
        continue
    if lst[i] < lst[i-1]:
        t = lst[i-1] - lst[i]
        count += t
        lst[i] += t
print(count)


Measured memory_bytes: 32116
n,k=map(int,input().split())
a=list(map(int,input().split()))
v=sum(a)
if k<a[0]:
    a[0]=k
for i in range(n-1):
    if k<a[i]+a[i+1]:
        a[i+1]=k-a[i]
print(v-sum(a))

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

using namespace std;



int main(){
    string s;
    cin >>s;
    int ans = 0, c = 0;
    for(int i=s.length()-1;i>=0;i--){
        int b = 0;
        for(int j = 0;j<10;j++){
            if((j + c + s[i] - '0')%10 + j < (b + c + s[i] - '0')%10 + b){
                b = j;
            }
            else if((j + c + s[i] - '0')%10 + j == (b + c + s[i] - '0')%10 + b && i>0 && s[i-1] - '0'>=5){
                b = j;
            }
        }
        ans += (b + c + s[i] - '0')%10 + b;
        c = (b + c + s[i] - '0') / 10;
    }

    if(c==1)
        ans++;
    cout <<ans;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

	int na=count(s.begin(),s.end(),'a');
	int nb=count(s.begin(),s.end(),'b');
	int nc=count(s.begin(),s.end(),'c');
	puts(max({na,nb,nc})-min({na,nb,nc})<=1?"YES":"NO");

	return 0;
}


Measured memory_bytes: 512
N = gets.chop.to_i

tasks = []

N.times { tasks << gets.chop.split.map(&:to_i) }

tasks = tasks.sort_by { |t| t[1] }

time = 0
tasks.each do |task|
  time += task[0]
  if task[1] < time
    puts "No"
    exit
  end
end

puts "Yes"


Measured memory_bytes: 22520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 100005

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int dp[N], n, q, l, r;
string s;

int main(){
    cin >> n >> q >> s;
    for (int i=1; i<n; i++)
        dp[i + 1] = dp[i] + (s[i] == 'C' && s[i-1] == 'A');
    while (q--){
        cin >> l >> r;
        cout << dp[r] - dp[l] << '\n';
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  int count=0;
  cin>>S>>T;
  for(int i=0;i<S.size();i++){
    if(S[i]==T[i]){
      count++;
    }
  }
  if(count==S.size())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=205;
int T,n,a[N],b[70];char s[N];
void ins(int x){
	per(i,62,0)if(x>>i&1){
		if(!b[i]){
			b[i]=x;
			return;
		}
		x^=b[i];
	}
}
bool qry(int x){
	per(i,62,0)if(x>>i&1)x^=b[i];
	return x==0;
}
signed main(){
	rd(T);
	while(T--){
		memset(b,0,sizeof(b));
		rd(n);rep(i,1,n)rd(a[i]);
		scanf("%s",s+1);
		bool flg=0;
		per(i,n,1){
			if(s[i]=='0'){
				ins(a[i]);
			}else{
				if(!qry(a[i])){
					flg=1;
				}
			}
		}
		printf("%d\n",flg);
	}
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n,m;
string buf[35];
set<string> all;
bool vis[35][35];
int dx[] = {-1,0,1,-1,1,-1,0,1};
int dy[] = {-1,-1,-1,0,0,1,1,1};

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d%d",&n,&m) && n!=0) {
		for (int i=0; i<n; i++) cin>>buf[i];

		all.clear();
		int best = 0;
		string str;
		for (int k=0; k<8; k++) {;
			for (int i=0; i<n; i++) {
				for (int j=0; j<m; j++) {
					for (int x=0; x<n; x++) for (int y=0; y<m; y++) vis[x][y] = 0;
					int x = i;
					int y = j;
					string s;
					while (!vis[x][y]) {
						vis[x][y] = 1;
						s = s + buf[x][y];
						x = (x + dx[k] + n)%n;
						y = (y + dy[k] + m)%m;
						if (s.length()>=2) {
							if (all.find(s)==all.end()) all.insert(s);
							else {
								if (best<=(int)s.length()) {
									if (best<(int)s.length()) {
										best = s.length();
										str = s;
									}
									else if (str>s) {
										str = s;
									}
								}
							}
						}
					}
				}
			}
		}
		
		if (best==0) cout<<"0"<<endl;
		else cout<<str<<endl;
	}
	
    return 0;

}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
    // cin>>n>>m;
 	cin>>n;
 	int a[n];
 	fo(i,n) cin>>a[i];
 	cout<<*max_element(a,a+n)-*min_element(a,a+n)<<endl;
 
  	
 	return 0;

   }

Measured memory_bytes: 3616