akhauriyash/Code-Regression huggingface dataset:
A, B, C, D = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def under_div(A, C, D):
    lcm = C*D//gcd(C, D)
    return A//C+A//D-A//lcm

print (B-A+1-under_div(B, C, D)+under_div(A-1, C, D))

Measured memory_bytes: 3064
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Range[] ranges = new Range[n];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int l = sc.nextInt();
            Range range = new Range(x + l, x - l);
            ranges[i] = range;
        }
        Arrays.sort(ranges, new SortByHigh());
        int max = ranges[0].high;
        int count = 1;
        for (int i = 1; i < n ; i++) {
            if (max <= ranges[i].low) {
                max = ranges[i].high;
                count++;
            }
        }
        System.out.println(count);
    }
    public static class Range {
        int high;
        int low;
        public Range(int high, int low){
            this.high = high;
            this.low = low;
        }
    }
    public static class SortByHigh implements Comparator<Range> {

        public int compare(Range a, Range b) {
            return a.high - b.high;
        }
    }

}


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

#define fi first
#define se second

const int N = 110;
const int mod = 1e9 + 7;

using namespace std;

int n, m, k;
int a[N][N];

int nxt(int &x, int &y)
{
        if(x % 2){
                y += 1;
                if(y == m + 1){
                        y = m;
                        x += 1;
                }
        } else{
                y -= 1;
                if(y == 0){
                        y = 1;
                        x += 1;
                }
        }
}

int main()
{
        ios_base::sync_with_stdio(0);

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

        cin >> n >> m >> k;
        int x = 1, y = 1;
        for(int i = 1; i <= k; i++){
                int c;
                cin >> c;
                while(c--){
                        a[x][y] = i;
                        nxt(x, y);
                }
        }
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        cout << a[i][j] << " \n"[j == m];
                }
        }
}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

double s[1000];

int main()
{
	int n;

	while (true) {
		double sum = 0.0, m, ans = 0.0;

		cin >> n;
		if (n == 0) break;

		rep(i, n) {
			cin >> s[i];
			sum += s[i];
		}
		m = sum / n;

		rep(i, n) ans += (s[i] - m) * (s[i] - m);
		ans = sqrt(ans / n);
		printf("%.10lf\n", ans);
	}



	return 0;
}



Measured memory_bytes: 3208
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		boolean answer = true;
		String[] A = new String[N];
		String[] B = new String[N];
		for(int i = 0;i < N;i++){
			A[i] = sc.next();
		}
		for(int i = 0;i < M;i++){
			B[i] = sc.next();
		}
		for(int i = 0;i < N-M+1;i++){
			for(int j = 0;j < N-M+1;j++){
				for(int k = 0;k < M;k++){
					for(int l = 0;l < M;l++){
						if(A[i+k].charAt(j+l)!=B[k].charAt(l)){
							answer = false;
							break;
						}
					}
				}
				if(answer == true){
					System.out.println("Yes");
					System.exit(0);
				}
				answer = true;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21844
N = int(input())
i = 1
list = []
while i <= N:
    data = input()
    list.append(data)
    i += 1

AC = 0
WA = 0
TLE = 0
RE = 0
for data in list:
    if data == "AC":
        AC += 1
    elif data == "WA":
        WA += 1
    elif data == "TLE":
        TLE += 1
    else:
        RE += 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x "+ str(RE))


Measured memory_bytes: 16244
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long

int main(){
	int a,b,t,ans,x;
	cin >> a >> b >> t;

	REP(i,1000){
		if(i*a>t){
			x=i-1;
			break;
		}
	}

	cout << x*b << endl;
	return 0;
}

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

int main() {
    vector<int> cnt(4);
    for(int i = 0; i < 3; ++i) {
        int a, b; cin >> a >> b;
        cnt[a - 1] += 1;
        cnt[b - 1] += 1;
    }
    sort(begin(cnt), end(cnt));
    vector<int> v = {1, 1, 2, 2};
    if(cnt == v) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

const int N = (int)1e5 + 50;
int n[2];
string s[2];
int asum[2][N], bsum[2][N];

int md(int x, int mod) {
    return (x % mod + mod) % mod;
}

int main() {
    cin >> s[0] >> s[1];
    for(int k = 0; k < 2; k++) {
        n[k] = s[k].length();
        s[k] = " " + s[k];
        for(int i = 1; i <= n[k]; i++) {
            asum[k][i] = asum[k][i-1] + (s[k][i] == 'A');
            bsum[k][i] = bsum[k][i-1] + (s[k][i] == 'B');
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int l[2], r[2];
        cin >> l[0] >> r[0] >> l[1] >> r[1];
        int sum[2];
        for(int k = 0; k < 2; k++) {
            sum[k] = md((bsum[k][r[k]] - bsum[k][l[k]-1]) - (asum[k][r[k]] - asum[k][l[k]-1]), 3);
        }
        cout << (sum[0] == sum[1] ? "YES" : "NO") << "\n";
    }
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

string s;

void init()
{
	cin >> s;
}

void solve()
{
	string t, ti;
	rep(i, s.length()) {
		if (s[i] != 'x') {
			t = t + s[i];
			ti = s[i] + ti;
		}
	}
	if (t != ti) {
		cout << -1 << endl;
		return;
	}
	vector<int> v(1, 0);
	rep(i, s.length()) {
		if (s[i] == 'x') {
			v.back()++;
		} else {
			v.PB(0);
		}
	}
	int si = v.size();
	int res = 0;
	rep(i, si / 2) {
		res += abs(v[i] - v[si - 1 - i]);
	}
	cout << res << endl;
}





Measured memory_bytes: 1432
# まずは全探索砂糖の質量、水の質量はともにO(F^2)だがそれらの組み合わせもO(F^2)であること（上限がFだから）に注意
A,B,C,D,E,F = map(int,input().split())
water = set()
for water1 in range(0,F+1,100*A):
    for water2 in range(0,F+1,100*B):
        if water1 + water2 <= F:
            water.add(water1+water2)

sugar = set()
for sugar1 in range(0,F+1,C):
    for sugar2 in range(0,F+1,D):
        if sugar1 + sugar2 <= F:
            sugar.add(sugar1+sugar2)
# print(water)
# print(sugar)
ans_s = 0
ans_w = 0
max_c = 0
for w in water:
    for s in sugar:
        if 0< w + s <= F:
            if w//100*E >= s:
                if max_c < (100*s)/(s+w):
                    ans_s = s
                    ans_w = w
                    max_c = (100*s)/(s+w)

if ans_s == 0 and ans_w == 0:
    ans_w = 100*A
print(ans_w+ans_s,ans_s)


Measured memory_bytes: 3188
n, k = map(int, input().split())
s = str(input())

a = [0]

ls = s.replace('10', '1,0')
ls = ls.replace('01', '0,1')
ls = ls.split(',')
for i in ls:
    a.append(a[-1] + len(i))

ans = 0
res = 0
if s[0] == '1':
    for i in range(len(a)):
        if i % 2 == 0:
            ans = a[min(i + 2 * k + 1, len(a) - 1)] - a[i]
        else:
            ans = a[min(i + 2 * k, len(a) - 1)] - a[i]

        res = max(res, ans)

else:
    for i in range(len(a)):
        if i % 2 == 0:
            ans = a[min(i + 2 * k, len(a) - 1)] - a[i]
        else:
            ans = a[min(i + 2 * k + 1, len(a) - 1)] - a[i]

        res = max(res, ans)

print(res)

Measured memory_bytes: 7908
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    string s;
    cin>>s;
    set<char>check;
    rep(i,0,s.size()){
        check.insert(s[i]);
    }
    cout<<(check.size()>1?"Yes":"No");
} 
 
  
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

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

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int a, b, q;
    cin >> a >> b >> q;

    vec<ll> s(a + 2), t(b + 2), x(q);

    for (int i = 1; i <= a; ++i)
    {
        cin >> s[i];
    }
    for (int i = 1; i <= b; ++i)
    {
        cin >> t[i];
    }
    for (int i = 0; i < q; ++i)
    {
        cin >> x[i];
    }

    constexpr ll inf = 100000000000;

    s.front() = -inf;
    t.front() = -inf;
    s.back() = inf;
    t.back() = inf;
    s.push_back(inf * 2);
    t.push_back(inf * 2);

    auto push = [](vec<ll> &ans, const vec<ll> &s, const vec<ll> &t, ll e) {
        auto ub = upper_bound(s.begin(), s.end(), e);
        auto list = {*ub, *(--ub)};
        for (auto l : list)
        {
            auto distance = abs(e - l);
            auto lb = lower_bound(t.begin(), t.end(), l);
            ans.push_back(distance + abs(*lb - l));
            ans.push_back(distance + abs(*(--lb) - l));
        }
    };

    for (auto e : x)
    {
        vec<ll> ans{};

        // s
        push(ans, s, t, e);
        // t
        push(ans, t, s, e);

        sort(ans.begin(), ans.end());

        // for (auto i : ans)
        // {
        //     cout << i << " ";
        // }
        cout << ans.front() << endl;
    }

    return 0;
}

Measured memory_bytes: 3680
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
        
        System.out.println(answer());
    }

    static String answer () {
        Scanner sc = new Scanner(System.in);
        int total = 0;
        int[] number = new int[3];
        for (int i = 0; i < number.length; i++) {
            number[i] = sc.nextInt();
            if (number[i] != 5 && number[i] != 7) {
                return "NO";
            } else {
                total += number[i];
            }
        }
        
        if (total == 17) {
            return "YES";
        } else {
            return "NO";
        }
    }
}

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

typedef unsigned long long ll;
const int N_MAX = 100;
ll T[N_MAX];

ll gcd(ll a, ll b) {
  ll tmp;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b != 0) {
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

ll lcd (ll a, ll b) {
  ll g = gcd(a, b);
  return a * (b / g);
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  ll l;
  if (N == 1) {
    l = T[0];
  }
  else {
    l = lcd(T[1], T[0]);
    for (int i = 2; i < N; i++) {
      l = lcd(T[i], l);
    }
  }
  cout << l << endl;
}

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

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;++i){
    int x = i;
    if(x%3 == 0){
      cout<<" "<<i;
    }else{
      do{
	if(x%10 == 3){
	  cout<<" "<<i;
	  break;
	}
	x/=10;
      }while(x);
    }
  }
  cout<<endl;
  return 0;
}

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

#define MAX_H 100

using namespace std;

string S[MAX_H];

int main() {
  int H, W;
  cin >> H >> W;
  printf("\n");
  for (int i = 0; i < H; ++i) {
    cin >> S[i];
  }
  for (int j = 0; j < W + 2; ++j) {
    printf("#");
  }
  printf("\n");
  for (int i = 0; i < H; ++i) {
    printf("#");
    for (int j = 0; j < W; ++j) {
      printf("%c", S[i][j]);
    }
    printf("#\n");
  }
  for (int j = 0; j < W + 2; ++j) {
    printf("#");
  }
  printf("\n");
}

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

typedef long long ll;
typedef long double ld;

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ALL(v)      v.begin(), v.end()
#define PB          push_back
#define MP          make_pair
#define UB          upper_bound
#define LB          lower_bound
#define PI          2*acos(0.0)
#define MOD         1000000007
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   ((a)*(b)) / GCD(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;
#define PRINTS(s)   for(auto i=s.begin(); i!=s.end(); i++) cout << *i << " "; cout << endl;
#define PRINTM(m)   for(auto i=m.begin(); i!=m.end(); i++) cout << i->first << " " << i->second << endl;

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
const int fxKing[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
const int fyKing[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move
const int fxKnight[] = {+2,+1,-1,-2,-2,-1,+1,+2}; /// Knight's move
const int fyKnight[] = {+1,+2,+2,+1,-1,-2,-2,-1}; /// Knight's move

pair <ll, ll> p[200000];

bool comp(pair<ll,ll>l, pair<ll,ll>r)
{
    if(l.second == r.second)
        return l.first < r.first;
    else return l.second < r.second;
}

int main()
{
    FIO;
    ll n;
    int t = 1;
//    cin >> t;
    while(t--)
    {
        cin >> n;
        ll mn = INT_MAX, mx = INT_MIN;
        ll MN = INT_MAX, MX = INT_MIN;
        for(int i=0; i<n; i++){
            cin >> p[i].first >> p[i].second;
            ll tot = p[i].first + p[i].second;
            if(tot < mn) mn = tot;
            if(tot > mx) mx = tot;
            tot = p[i].first - p[i].second;
            if(tot < MN) MN = tot;
            if(tot > MX) MX = tot;
        }
        cout << max(abs(mx-mn), abs(MX-MN)) << endl;
    }

    return 0;
}


Measured memory_bytes: 6748
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = []
now = -1
for i in range(k+1):
    mi = 9999
    pos = 0
    for j in range(n):
        if now != j and a[j] <= mi:
            pos = j
            mi = a[j]
    for j in range(n):
        if j != now and j != pos:
            ans.append(j+1)
            a[j] -= 1
            if a[j] < 0:
                print(-1)
                exit()
    ans.append(pos+1)
    a[pos] -= 1
    if a[pos] < 0:
        print(-1)
        exit()
    now = pos
print(len(ans))
print(*ans)


Measured memory_bytes: 3572
/*
 * drish1001
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>  
#include <iostream> 
using namespace __gnu_pbds; 
using namespace std;
#define     pb                 push_back
#define     mp                 make_pair
#define     ff                 first
#define     ss                 second
#define    MOD                1000000007
#define     pll                pair<ll,ll>
void        sorta(auto &v)     {sort(v.begin(),v.end());} 
void        sortd(auto &v)     {sort(v.begin(),v.end(), greater<>());} 
void        fast()            {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef        long long        ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> magic; 

//all variables and functions be1ow this ..

int main()
{
	fast();
	ll n;
	cin >> n;
	if(n==1)
		cout << 0 << endl;
	else
	{
		ll a=1, b=1, c=1;
		for(ll i=1;i<=n;i++)
		{
			a = (a*10)%MOD;	
			b = (b*9)%MOD;	
			c = (c*8)%MOD;	
		}
		b = (b*2)%MOD;
		a = (a+c)%MOD;
		a = (a-b+MOD)%MOD;
		cout << a << endl;
	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
 
  if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&s.at(0)!=s.at(2)){
   cout<<"Yes"<<endl;
  }
  else if(s.at(0)==s.at(2)&&s.at(1)==s.at(3)&&s.at(0)!=s.at(1)){
   cout<<"Yes"<<endl;
  }
  else if(s.at(0)==s.at(3)&&s.at(1)==s.at(2)&&s.at(0)!=s.at(2)){
   cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
char s[N];
struct node
{
    int id,op;
    char s;
}a[N];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>s+1;
    int t;
    cin>>t;
    int flag=0;
    for(int i=1;i<=t;i++){
        cin>>a[i].op;
        if(a[i].op==2){
            cin>>a[i].id>>a[i].s;
        }
    }
    stack<char>q;
    for(int i=t;i>=1;i--){
        if(a[i].op==1){
            flag=flag^1;
        }
        else{
            if(a[i].id==1){
                if(flag==0)cout<<a[i].s;
                else{
                    q.push(a[i].s);
                }
            }
            else{
                if(flag==1)cout<<a[i].s;
                else{
                    q.push(a[i].s);
                }
            }
        }
    }
    int len=strlen(s+1);
    if(flag==1)for(int i=len;i>=1;i--)cout<<s[i];
    else for(int i=1;i<=len;i++)cout<<s[i];
    while(!q.empty()){
        cout<<q.top();
        q.pop();
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3072
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

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

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int N;
    cin >> N;
    long long A[N], out = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for(int i = 1; i < N; i++)
    {
        if(A[i] < A[i-1])
        {
            out += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    cout << out << endl;
}

// Main

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

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


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

int main()
{
	int a,b,m;cin>>a>>b>>m;
	int c=a;
	for(int i=1;i<=b;i++){
		if(a%b==m){
			cout<<"YES\n";return 0;
		}
		a=a+c;
	}
	cout<<"NO\n";return 0;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  ll n, a, b;cin >> n >> a >> b;
  ll c = n/(a + b);
  ll d = min(a, n - (a + b)*c);
  cout << a*c + d << endl;
}


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

int main() {
    double n;
    cin>>n;
    int a=n;
    double ans=(a/2+1)/n;
    if(a%2==0) {
        cout<<0.5<<endl;
    }
    else {
        cout<<ans<<endl;
    }
  
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 63;
const int md = 1e9 + 7;

int dp[maxn][2][2];
ll n;
int nb[maxn];

int main() {
	sl(n); int msb = -1;  int idx = 0; fill(nb,nb+maxn,0);
	while (n > 0) {
		nb[idx] = n&1; n>>=1; msb++; idx++;
	}

	for (int i = msb; i >= 0; i--) {
		for (int c = 0; c < 2; c++) {
			for (int ex = 0; ex < 2; ex++) {
				if (i == msb) {
					if (ex) {
						if (c) { dp[i][c][ex] = 0; continue; }
						dp[i][c][ex] = 1; continue;
					} else {
						if (c) { dp[i][c][ex] = 1; continue; }
						else { dp[i][c][ex] = 2; continue; }
					}
				}
				int cur = 0;
				for (int xb = 0; xb < 2; xb++) {
					for (int yb = 0; yb <= xb; yb++) {
						int cd = (xb+yb+c)%2;
						int car = ((xb+yb+c)-cd)>>1;
						if (ex) {
							if (cd < nb[i]) {
								cur = (cur + dp[i+1][car][0])%md;
							} else {
								cur = (cur + dp[i+1][car][1])%md;

							}
						} else {
							if (cd <= nb[i]) {
								cur = (cur + dp[i+1][car][0])%md;
							} else {
								cur = (cur + dp[i+1][car][1])%md;
							}
						}
					}
				}
				dp[i][c][ex] = cur;
			}
		}
	}

	cout<<dp[0][0][0]<<endl;

}


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

int main() {
  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  sort(all(x));
  if ((x[0] == x[1] && x[1] != x[2]) || (x[1] == x[2] && x[1] != x[0])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    set<int> s;
    rep(i, 3) {
        int a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
#define MAXN 100
int n;
set<int>que;
struct node
{
	int x,y,c;
}a[MAXN*2+5];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].c=1;
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i+n].x,&a[i+n].y);
		a[i+n].c=0;
	}
	sort(a,a+n*2,cmp);
	int ans=0;
	set<int>::iterator p;
	for(int i=0;i<2*n;i++)
	{
		if(a[i].c==0)
		{
			int y=a[i].y;
			p=que.upper_bound(y);
			if(p==que.begin()) continue;
			p--;
			if(*p<y)
			{
				ans++;
				que.erase(*p);
			}
		}
		else
		{
			que.insert(a[i].y);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    
   int Q;
   cin>>Q;
   vector<int> l(Q), r(Q);
   rep(i,Q) cin>>l[i]>>r[i];

   int MAX = 100100;
   //エラストテネスの篩
   vector<int> is_prime(MAX, 1);
   is_prime[0]=0;
   is_prime[1]=0;
   for(int i=2;i<MAX;i++){
       //素数でない判定されたものは無視
       if(!is_prime[i]) continue;
       //素数判定されたものの倍数は無視
       for(int j=i*2;j<MAX;j+=i) is_prime[j]=0;
   }
   //2017に似た数かどうか
   vector<int> num(MAX, 0);
   for(int i=0;i<MAX;i++){
       //偶数は対象でない
       if(i%2==0) continue;
       if(is_prime[i] && is_prime[(i+1)/2]) num[i]=1;
   }
   
   //累積和、最大値MAX分前処理
   vector<int> sum(MAX+1, 0);
   rep(i,MAX){
       sum[i+1] = sum[i]+num[i];
   }

   rep(i,Q){
       cout<<sum[r[i]+1]-sum[l[i]]<<endl;
   }


    return 0;
}


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

#define pb push_back
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (t == 0) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

const int MAX_N = 1e6;
int n;
vvl edges;
vl size;
vector<mint> factorial(MAX_N);
vector<mint> factorial_inv(MAX_N);
vector<mint> dp;
vector<mint> ans;

int dfs(int root, int parent) {
    int sum = 1;
    mint dpr(1);
    for (auto ch : edges[root]) {
        if (ch == parent) continue;
        size[ch] = dfs(ch, root);
        sum += size[ch];
        dpr *= dp[ch] * factorial_inv[size[ch]];
    }
    size[root] = sum;
    dp[root] = factorial[sum-1] * dpr;
    return sum;
}

void calc(int root, int parent) {
    mint aux = ans[parent] * factorial_inv[n-1];
    aux *= factorial[size[root]] / dp[root];
    aux *= factorial[n-size[root]-1];
    ans[root] = dp[root] * factorial_inv[size[root]-1];
    ans[root] *= aux * factorial_inv[n-size[root]];
    ans[root] *= factorial[n-1];
    for (auto ch : edges[root]) {
        if (ch == parent) continue;
        calc(ch, root);
    }
}

int main() {
    cin >> n;
    edges.resize(n);
    dp.resize(n);
    ans.resize(n);
    size.resize(n);
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        edges[a].pb(b);
        edges[b].pb(a);
    }
    factorial[0] = factorial_inv[0] = mint(1);
    rng(i,1,MAX_N) {
        factorial[i] = mint(i) * factorial[i-1];
        factorial_inv[i] = factorial[i].inv();
    }
    dfs(0, -1);

    ans[0] = dp[0];
    for (auto ch : edges[0]) {
        if (ch == 0) continue;
        calc(ch, 0);
    }
    rep(i,n) {
        cout << ans[i].x << endl;
    }
    return 0;
}


Measured memory_bytes: 35056
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] r = new int[N + 1][N + 1];
		int ans = 0;

		for (int i = 0; i < M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			r[a][b] = 1;
			r[b][a] = 1;
		}

		int cnt = 0;

		while (cnt == 0) {
			cnt = 1;
			for (int i = 1; i <= N; i++) {
				int x = 0;
				int y = 0;
				for (int j = 1; j <= N; j++) {
					if (r[i][j] == 1) {
						x++;
						y = j;
					}
				}
				if (x == 1) {
					r[i][y] = 0;
					r[y][i] = 0;
					ans++;
					cnt = 0;
				}
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	string s;
	int n,k;
	cin>>n>>s>>k;
	for(int i=0;i<n;i++)
	{
		if(s[i]==s[k-1])cout<<s[i];
		else cout<<"*";
	}
}

Measured memory_bytes: 256
/**
 *  Author: Wasi Ur Rahman
 *  FROM RMSTU
**/
#include<bits/stdc++.h>
#define  fast           ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
#define  min3(a,b,c) min(a,min(b,c))
#define pi acos(-1.0)
int arr[200010];
    int a[200010] = {0};
int main()
{
    int p;
    scanf("%d",&p);
    for(int i = 2; i<=p; i++)
    {
        cin >> arr[i];
        a[arr[i]]++;
    }
    for(int i = 1; i<=p; i++)
        cout << a[i] << endl;

}





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


int main(){
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;

    if(U == S){
        A--;
    }else{
        B--;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
 
char island[13][13];
 
void dfs(int i, int j){
        int di, dj;
        
        island[i][j] = '0';
                
        for (di = -1; di <= 1; di += 2){
                if (0 <= i + di && i + di < 12 && island[i + di][j] == '1'){
                        dfs(i + di, j);
                }
        }
        for (dj = -1; dj <= 1; dj += 2){
                if (0 <= j + dj && j + dj < 12 && island[i][j + dj] == '1'){
                        dfs(i, j + dj);
                }
        }
}
 
int main(void)
{
        int i, j;
        char temp;
        int num, count;
        
        count = 0;
        while (1){
                
                for (i = 0; i < 12; i++){
                        if(scanf("%s", island[i])==EOF)return 0;
                        getchar();
                }
                
                num = 0;
                for (i = 0; i < 12; i++){
                        for (j = 0; j < 12; j++){
                                if (island[i][j] == '1'){
                                        dfs(i, j);
                                        num++;
                                }
                        }
                }
                
                printf("%d\n", num);
                
                count++;
        }
        return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t h, w;
    cin >> h >> w;

    vector<vector<int64_t>> a(h + 1, vector<int64_t>(w + 1)),
            b(h + 1, vector<int64_t>(w + 1));
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            cin >> a[i][j];
        }
    }
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            cin >> b[i][j];
        }
    }

    vector<vector<vector<bool>>> dp(
            h + 1L, vector<vector<bool>>(w + 1L, vector<bool>(160 * 80 + 1)));
    dp[0][1][0] = true;
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            auto diff = a[i][j] - b[i][j];

            for (auto k : irange(0L, 160 * 80 + 1L)) {
                if (!dp[i - 1][j][k]) {
                    continue;
                }

                for (auto d : {k + diff, k - diff}) {
                    if (d < 0) {
                        d *= -1;
                    }
                    dp[i][j][d] = true;
                }
            }

            for (auto k : irange(0L, 160 * 80 + 1L)) {
                if (!dp[i][j - 1][k]) {
                    continue;
                }

                for (auto d : {k + diff, k - diff}) {
                    if (d < 0) {
                        d *= -1;
                    }
                    dp[i][j][d] = true;
                }
            }
        }
    }

    auto ans = find(dp[h][w].begin(), dp[h][w].end(), true) - dp[h][w].begin();

    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, M, X; cin >> N >> M >> X; int C[N], A[N][M];
REP(i, N){ cin >> C[i]; REP(j, M){ cin >> A[i][j]; } }
int m=1<<12, ans=1e9+7;
for(int i=0; i<m; i++){
  int v=0, nw[M]={};
  for(int j=0, k=i; j<N; j++){ 
   if(k%2==1){ v+=C[j]; REP(p, M){ nw[p]+=A[j][p]; } }
    k>>=1;
  }
bool f=true;
REP(p, M){ if(nw[p]<X){ f=false; break; } }
if(f){ ans=min(ans, v); }
}
if(ans>1e9){ ans=-1; }
cout << ans << "\n";
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, k = input_to_int_map()
    a = {i + 1: int(val) for i, val in enumerate(input().split())}

    place = 1
    visit = {place}
    place_visits = [place]
    for i in range(k):
        place = a[place]
        if place in visit:
            left = place_visits.index(place)
            loop_list = place_visits[left:]
            return loop_list[(k - left) % len(loop_list)]
        else:
            visit.add(place)
            place_visits.append(place)

    return place


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 50732
#069-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
a=IL()
ans="No"
a2=0
a4=0
for i in range(n):
    if a[i]%4==0:
        a4+=1
    elif a[i]%2==0:
        a2+=1
if 2*a4+a2>=n:
    ans="Yes"
if 2*a4+1>=n:
    ans="Yes"
print(ans)

Measured memory_bytes: 14484
#include<stdio.h>
int main(void){
    int N, M, d, e, check = 0, keta, jyousuu, i, g, h;
    scanf("%d", &N);
    scanf("%d", &M);
    int s[M], c[M], A[N];
    for(i = 0; i < M; i++){
        scanf("%d", &s[i]);
        scanf("%d", &c[i]);
    }
    //事前準備として、答えのもとになるA[N]を初期化
    for(i = 0; i < N; i++){
        A[i] = 0;
    }
    //まずs[M]を基準に降順にしたい
    for(i = 0; i < M; i++){
        for(int j = i + 1; j < M; j++){
            if(s[i] < s[j]){
                d = s[i];
                s[i] = s[j];
                s[j] = d;
                d = c[i];
                c[i] = c[j];
                c[j] = d;
            }
        }
    }
    //入力で同じ桁に異なる数値が定義されていないかチェック
    for(i = 0; i < M - 1; i++){
        e = i + 1;
        if(s[i] == s[e]){
            if(c[i] != c[e]){
              if(check == 0){
                printf("-1\n");
                check += 1;}
            }
        }
    }
    //Mが0の場合、答えが確定する
    if(check == 0){
    if(M == 0){
    if(N > 1){
        h = 1;
        for(int ss = 0; ss < N - 1; ss++) h *= 10;
        printf("%d\n", h);
        check += 1;
    }
    else {
        
        printf("0\n");
        check += 1;
    }
    }
    }
    //最初の桁が0にならないかチェック、また左から数えて一桁目に1代入
    g = M - 1;
    if(N > 1){
    if(s[g] == 1){
      if(c[g] == 0){
        if(check == 0){
        printf("-1\n");
        check += 1;}
      }
    }
    else { A[0] = 1;
    }
    }
    //あとは各桁どんどん代入してく
    for(i = 0; i < M; i++){
        keta = s[i] - 1;
        A[keta] = c[i];
    }
    //最後にcheckを活用し、エラーがなければ答えを出力
    if(check == 0){
        int a = 0, x;
        for(i = 0; i < N; i++){
            jyousuu = 1;
            x = N - i - 1;
            for(int k = 0; k < i; k++) jyousuu *= 10;
            a += A[x] * jyousuu;
        }
        printf("%d\n", a);
    }
    return 0;

}

Measured memory_bytes: 128
'''
    handle - pruvi007
    questionName - 
    Contest - 
    Topic - 
    Platform - 
'''
from sys import stdin, stdout
from collections import defaultdict

def main():
    n = int(stdin.readline())
    a = list(map(int,stdin.readline().split()))
    f = 1
    flag=0
    a = sorted(a)
    for i in range(n):
        f = f*a[i]
        if f>10**18:
            flag=1
            break
    if flag:
        print("-1")
    else:
        print(f)

main()

Measured memory_bytes: 22540
import numpy as np

N = int(input())

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

sum = a[0]


if 0 in a:
    print('0')
    exit()

for i in range(1, N):
    sum = sum * a[i]
    if sum > 10**18:
        print('-1')
        exit()

print(sum)




Measured memory_bytes: 40096
#include <stdio.h>

int main(void){
    int a,tmp,e,k;
    scanf("%d",&a);
    scanf("%d",&tmp);
    scanf("%d",&tmp);
    scanf("%d",&tmp);
    scanf("%d",&e);
    scanf("%d",&k);
    if(e-a>k)printf(":(\n");
    else printf("Yay!\n");
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  using ll = long long;
  ll l, r;
  cin >> l >> r;
  if (r - l > 2019) {
    cout << 0 << '\n';
    return 0;
  }
  ll ans = 2019;
  for (ll i = l; i < r; i++) {
    for (ll j = l + 1; j <= r; j++) {
      ans = min(ans, i * j % 2019);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    }
}

Measured memory_bytes: 38488
import itertools
n,m,q = map(int,input().split())
l = []
for i in range(q):
    tl = list(map(int,input().split()))
    l.append(tl)
A = range(1,m+1)
h = itertools.combinations_with_replacement(A, n)

M = 0
for v in itertools.combinations_with_replacement(A, n):
    ans = 0
    for i in l:
        a,b,c,d = i
        if v[b-1]-v[a-1] ==c :
            ans +=d 
    M = max(ans,M)
print(M)

Measured memory_bytes: 9208
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=b)
		cout<<a<<endl;
	else
		cout<<a-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=1ll*(i+n/i*i)*(n/i)/2;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3820
#include<iostream>
#include<cstring>
#define ll long long
using namespace std;
const int INF = 1<<30;
const int maxn = 2e3+5;
int a[maxn];
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int t = min(j-i,abs(x-i)+abs(y-j)+1);
            a[t]++;
        }
    }
    for(int i=1;i<n;i++) cout<<a[i]<<endl;
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;

int main(){
    ull x;
    cin>>x;
    ull sum = 100;
    ull tot = 0;
    while(sum<x){
    	ull res = sum /100;
    	//cout<<res<<"0---";
    	sum += res;
    	tot++;
	}
	cout<<tot;
	return 0;
} 

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    long long a, b, k, eat;
    cin >> a >> b >> k;
    eat = min(a, k);
    a -= eat;
    k -= eat;
    eat = min(b, k);
    b -= eat;
    cout << a << " " << b << endl;
    return 0;
}

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

using namespace std;

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

int data[100];
inline int root(int x) {
  return data[x] < 0 ? x : data[x] = root(data[x]);
}

void unite(int x, int y) {
  x = root(x), y = root(y);
  if(x != y) {
    if(data[y] < data[x]) swap(x, y);
    data[x] += data[y]; data[y] = x;
  }
}
  
inline bool same(int x, int y) {
  return root(x) == root(y);
}

struct edges {
  int u, v, c;
  bool operator < (const edges& e) const {
    return c < e.c;
  }
};

int const INF = 1<<29;

int main() {
  
  int N, M;
  while(cin >> N >> M && (N|M)) {
    vector<edges> es;
    rep(i, M) {
      int a, b, c;
      cin >> a >> b >> c; a--, b--;
      es.push_back((edges){a, b, c});
    }
    sort(es.begin(), es.end());
    int ret = INF;
    
    for(; (int)es.size() >= N-1;) {
      memset(data, -1, sizeof data);
      int last = -1;
      int s = 0;
      rep(i, es.size()) {
	if(!same(es[i].u, es[i].v)) {
	  unite(es[i].u, es[i].v);
	  last = i;
	  s++;
	  if(s == N-1) break;
	}
      }
      rep(i, N) REP(j, i+1, N) {
	if(!same(i, j)) { goto exit; }
      }
      ret = min(ret, es[last].c-es[0].c);
      es.erase(es.begin());
    }
    
  exit:;
    cout << (ret < INF ? ret : -1) << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1352
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
N = int(input())
c = collections.Counter(prime_factorize(N))
d = list(c.values())
ans = 0
for j in range(len(d)):
  for i in range(1,40):
    k = i*(i+1)/2
    if d[j] == k:
      ans += i
      break
    elif d[j] < k:
      ans += i-1
      break
    else:
      continue
print(ans)

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

int n;
int dp[100055][2];

vector<int> g[100055];

const int MOD = 1e9 + 7;

void dfs(int v, int par = -1) {
	dp[v][0] = dp[v][1] = 1;
	
	for (auto u : g[v]) if (u != par) {
		dfs(u, v);
		
		dp[v][1] = (1ll * dp[v][1] * dp[u][0]) % MOD;
		dp[v][0] = (1ll * dp[v][0] * ((dp[u][0] + dp[u][1]) % MOD)) % MOD;
	}
}
int main() {
	cin >> n;
	
	for (int i = 0; i + 1 < n; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;
		
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	dfs(0);
	
	cout << (dp[0][0] + dp[0][1]) % MOD;
	
	return 0;
}


Measured memory_bytes: 13440
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	ll n; cin >> n;
	ll ans = 0, ctr = 0;
	for (ll i = 1; i * i < n; ++i) {
		if (n % i == 0) {
			int d = i;
			ll lo = n / (d + 1) + 1;
			ll hi = n / d;
			ll m = n - d;
			ll sq = sqrt(m);
			for (ll j = max(1ll, lo); j <= min(sq, hi); ++j) {
				if (m % j == 0) {
					ans += j;
					// ++ctr;
				}
			}
			ll t_lo = (n + hi - 1) / hi, t_hi = n / lo;
			for (ll j = max(1ll, t_lo); j <= min(sq, t_hi); ++j) {
				if (m % j == 0 and j * j != m) {
					ans += m / j;
					// ++ctr;
				}
			}
		}
	}
	cout << ans << endl;
	// cout << ctr << endl;
}

Measured memory_bytes: 256