akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  tourist
 *    created: 05.01.2020 11:08:10       
**/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll solve(ll n, ll a, ll b, ll m) {
    if (b == 0) return n * (a / m);
    if (a >= m) return n * (a / m) + solve(n, a % m, b, m);
    if (b >= m) return n * (n - 1) / 2 * (b / m) + solve(n, a, b % m, m);
    return solve((a + b * n) / m, (a + b * n) % m, m, b);
}

pair<long long, long long> GetKBest(int k, long long cx, long long cy) {
  long long low = 0, high = (long long) 1e15;
  while (low < high) {
    long long mid = (low + high) >> 1;
    long long cnt = solve(mid / cx + 1, mid % cx, cx, cy) + (mid / cx + 1);
    if (cnt >= k) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  long long sx = 0, sy = 0;
  for (int x = 0; x * cx <= high; x++) {
    long long cc = (high - x * cx) / cy + 1;
    sx += cc * x;
    sy += cc * (cc - 1) / 2;
  }
  return {sx, sy};
}

bool Solvable(int k, int X, int Y) {
  auto a = make_pair(-1LL, -1LL), b = a;
  long long total = (long long) 1e10 + 19;
  long long low = 0, high = total;
  while (low < high) {
    long long mid = (low + high) >> 1;
    auto p = GetKBest(k, total - mid, mid);
    if (p.first <= X && p.second <= Y) {
      return true;
    }
    if (p.first < X) {
      a = p;
      low = mid + 1;
    } else {
      b = p;
      high = mid;
    }
  }
  return (a.second * (b.first - X) + b.second * (X - a.first) <= Y * (b.first - a.first));
}

int main() {
  int X, Y;
  cin >> X >> Y;
  if (X > Y) {
    swap(X, Y);
  }
  int low = 3, high = (int) 2e6;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    if (Solvable(mid, X, Y)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << low - 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static List<List<Integer>> switchList;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        sc.close();

        if (X >= A) {
            System.out.println(10);
        } else {
            System.out.println(0);
        }

    }

}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n;cin >>n;
  vector<ll> v(n);
  ll tot = 0;
  for(int i=0;i<n;++i){
    ll t ;cin>>t;
    v[i]=t;
    tot += t;
    tot = tot%mod;
  }
  ll out =0;
  for(int i=0;i<n-1;++i){
    tot -= v[i];
    if(tot<0) tot += mod;
    out += (v[i]*tot)%mod;
    out = out%mod;
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 4832
#include <stdio.h>
#include <string.h>
#define loop(num)	for(int a = 0; a < num; a++)

char List[1234];
char After[1234];

int main(){
	int List_Num;
	int Ans_Num;
	char buf;
	while (1){
		memset(List, '\0', sizeof(List));
		memset(After, '\0', sizeof(After));
		scanf("%d", &List_Num);
		if (List_Num == 0) return 0;
		loop(List_Num){
			scanf(" %c %c", &List[a], &After[a]);
		}
		scanf("%d", &Ans_Num);
		loop(Ans_Num){
			scanf(" %c", &buf);
			for (int b = 0; b < List_Num; b++){
				if (buf == List[b]){
					buf = After[b];
					break;
				}
			}
			printf("%c", buf);
		}
		puts("");
	}
}

Measured memory_bytes: 2520
include Math

a, b, c = gets.split.map(&:to_i)
θ = c / 180.0 * PI
h = b * sin(θ)
x = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(θ))

puts a * h / 2
puts a + b + x
puts h


Measured memory_bytes: 6904
A, B, M = list(map(int,input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = [list(map(int, input().split())) for _ in range(M)]

# no discount
min_val = min(a) + min(b)
# with discount
for ai, bi, ci in m:
    val = a[ai-1] + b[bi-1] - ci
    if min_val > val:
        min_val = val
print(min_val)

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

using namespace std;

int main() {
  int k,s;
  cin>>k>>s;
  if(s<=k){
    cout<<((s+2)*(s+1))/2<<endl;
    return 0;
  }
  if(s<2*k){
    cout<<(k+1)*(k+2)/2-(s-k)*(s-k+1)/2+k*(k+1)/2-(2*k-s)*(2*k-s+1)/2<<endl;
    return 0;
  }
  cout<<(3*k-s+1)*(3*k-s+2)/2<<endl;
  
  
}

Measured memory_bytes: 3596
#include <iostream>

int main()
{
  char x, y;
  std::cin >> x >> y;
  if (x == y) { std::cout << '=' << std::endl; }
  else if (x < y) { std::cout << '<' << std::endl; }
  else { std::cout << '>' << std::endl; }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int Q = sc.nextInt();
			
			final int MAX = 100000;
			boolean[] is_prime = new boolean[MAX + 1];
			Arrays.fill(is_prime, true);
			is_prime[0] = is_prime[1] = false;
					
			for(int i = 2; i * i <= MAX; i++){
				if(!is_prime[i]){ continue; }
				
				for(int j = 2 * i; j <= MAX; j += i){
					is_prime[j] = false;
				}
			}
			
			int[] prefixs = new int[MAX + 1];
			for(int i = 0; i <= MAX; i++){
				if(is_prime[i] && is_prime[(i + 1) / 2]){
					prefixs[i]++;
				}
			}
			for(int i = 1; i <= MAX; i++){
				prefixs[i] += prefixs[i - 1];
			}
			
			
			for(int q = 0; q < Q; q++){
				final int l = sc.nextInt();
				final int r = sc.nextInt();
				
				System.out.println(prefixs[r] - prefixs[l - 1]);
			}
			
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 67156
#include<iostream>

int ball[10];
int ls = 0, rs = 0;
bool res = true;

int main(){
	int n;
	std::cin >> n;
	for (int j = 0; j < n; j++){
		ls = 0, rs = 0, res = true;

		for (int i = 0; i < 10; i++)std::cin >> ball[i];

		for (int i = 0; i < 10; i++){
			int d1 = ball[i] - ls, d2 = ball[i] - rs;

			if (d1 > 0 && d2 > 0){
				if (d1 <= d2)ls = ball[i];
				else rs = ball[i];
			}
			else if (d1 > 0 && d2 < 0)ls = ball[i];
			else if (d1 < 0 && d2 > 0)rs = ball[i];
			else res = false;
		}

		std::cout << (res ? "YES" : "NO") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,c;
    cin>>n>>c;
    vvec v(c,vec(200000));
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        c--;
        v[c][a]++;
        v[c][b]--;
    }
    rep(i,c){
        rep(j,200000-10){
            v[i][j+1]+=v[i][j]; // 累積和
        }
    }
    rep(i,c){
        rep(j,200000-10){
            if(v[i][j]==0&&v[i][j+1]==1){
                v[i][j]++; // そのチャンネルなら継続して録画可能
            }
        }
    }
    int ans=0;
    rep(j,200000){ // 時刻　　
        int cnt=0;
        rep(i,c){
            if(v[i][j]==1) cnt++;
        }
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 48768
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 1e7 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int lpf[N + 1], divi[N + 1], cnt[N + 1];
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int sum = 0;
	divi[1] = 1;
	
	FOR (i, 2, n)
	{
	    if (lpf[i]) continue;
	    for (int j = i; j <= n; j += i)
	    {
	        lpf[j] = i;
	        if ((j/i) % i) cnt[j] = 1;
	        else cnt[j] = cnt[j/i] + 1;
	    }
	}
	
	FOR (j, 2, n)
	{
	    int i = lpf[j];
	    if ((j/i) % i) divi[j] = divi[j/i] * 2;
	    else divi[j] = divi[j/i] * (cnt[j] + 1) / cnt[j];
	    
	    sum += j*divi[j];
	}
	
	print(sum + 1);
}



















Measured memory_bytes: 238000
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  long long n,k;cin>>n>>k;
	vector<int> A(n);
	for(int i = 0; n > i; i++){
		cin>>A[i];
	}
	int ans = 0;
	for(int i = 0; n > i; i++){
		for(int j = 0; n > j; j++){
			if(A[i] > A[j]){
				if(i<j){
					ans=(ans+(k*(k+1)/2))%mod;
				}else{
					ans=(ans+((k-1)*k/2))%mod;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

class UnionFind:
    def __init__(self, n):
        # par = Parent Number or NoV
        self.par = [-1 for i in range(n+1)]
        # rank = Tree Height
        self.rank = [0] * (n+1)
    
    # 自分が所属する集合の数を返す
    def size(self, x):
        return -self.find(self.par[x])

    # 根なら番号を返す
    def find(self, x):
        
        if(self.par[x] < 0):
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])

    # 親が同じか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # もう繋がれている
        if(x == y):
            return False

        # つなぎ替える
        if(self.size(x) < self.size(y)):
            x,y = y,x
        
        # xのサイズを更新
        self.par[x] += self.par[y]
        # yのサイズ(おやばんごう)をxに
        self.par[y] = x

        return True 

def solve(N: int, M: int, X: "List[int]", Y: "List[int]", Z: "List[int]"):
    uf = UnionFind(N)

    for i in range(M):
        uf.union(X[i],Y[i])

    ans = len([i for i in uf.par[1:] if i < 0])

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = [int()] * (M)  # type: "List[int]" 
    Y = [int()] * (M)  # type: "List[int]" 
    Z = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        X[i] = int(next(tokens))
        Y[i] = int(next(tokens))
        Z[i] = int(next(tokens))
    solve(N, M, X, Y, Z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14984
import sys
sys.setrecursionlimit(100005)
n,k = map(int, input().split())
Tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)
#print(Tree)

mod = 10**9+7
def dfs(cur, pre):
    ret = 1
    nodecnt = 0 if pre == -1 else 1
    if cur > n-1 or cur < 0: return 0
    for nd in Tree[cur]:
        #print("現在のnode:",nd)
        if nd == pre: continue
        nodecnt += 1
        ret = ret*(k-nodecnt)%mod
        ret = ret*dfs(nd, cur)%mod
    return ret%mod

print(k*dfs(0,-1)%mod)

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

int main() {
    int A1;
    int A2;
    int A3;
    cin >> A1 >> A2 >> A3;

    if ( A1 + A2 + A3 >= 22){
        cout << "bust" << endl;
        return 0;
    }

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



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long H, W, M;
  cin >> H >> W >> M;
  set<pair<long, long>> SE;
  vector<long> CH(H), CW(W);
  long mxh = 0, mxw = 0;
  for (long i = 0; i < M; i++) {
    long h, w;
    cin >> h >> w;
    h--, w--;
    SE.insert({h, w});
    mxh = max(mxh, ++CH.at(h));
    mxw = max(mxw, ++CW.at(w));
  }
  set<long> SH, SW;
  for (long i = 0; i < H; i++) {
    if (CH.at(i) == mxh) SH.insert(i);
  }
  for (long i = 0; i < W; i++) {
    if (CW.at(i) == mxw) SW.insert(i);
  }
  long cnt = 0;
  for (auto [a, b] : SE) {
    if (SH.count(a)) {
      if (SW.count(b)) cnt++;
    }
  }
  if (SH.size() * SW.size() != cnt) return cout << mxh + mxw << "\n", 0;
  cout << mxh + mxw - 1 << "\n";
}

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

const int N = 200;
ll c[200][200], f[200][200];
ll a[N];
int s, t;
const ll inf = 1e18;
vector<bool> used;

ll dfs(int v, ll mn) {
    if (v == t) return mn;
    used[v] = true;
    for (int to = 0; to <= t; ++to) {
        if (!used[to] && f[v][to] < c[v][to]) {
            ll dd = dfs(to, min(mn, c[v][to] - f[v][to]));
            if (dd > 0) {
                f[v][to] += dd;
                f[to][v] -= dd;
                return dd;
            }
        }
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    t = n + 1;
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] > 0) {
            c[i][t] = a[i];
            sum += a[i];
        } else {
            c[s][i] = -a[i];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = i + i; j <= n; j += i) {
            c[i][j] = inf;    
        }
    }
    ll res = 0;
    while (1) {
        used.assign(N, false);
        ll qwe = dfs(s, inf);
        if (qwe == 0) break;
        res += qwe;
    }
    cout << sum - res << '\n';
}















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


int main(){
    string s;
    cin>>s;
    int i=1;
    for(auto v:s){
        if(i%2==1){
            cout<<v;
        }
        i++;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(void){
    int flg[4]={0};
    int numbers[4];
    int result=1;
    cin>>numbers[0]>>numbers[1]>>numbers[2]>>numbers[3];
    
    for(int i=0;i<4;i++){
        if(numbers[i]==1)flg[0]=1;
        if(numbers[i]==7)flg[1]=1;
        if(numbers[i]==9)flg[2]=1;
        if(numbers[i]==4)flg[3]=1;
    }
    
    for(int i=0;i<4;i++){
        if(flg[i]==0)result=0;
    }
    
    if(result){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,max1=-3;
    scanf("%d%d",&a,&b);
    max1=max(a+b,a+a-1);
    max1=max(max1,b+b-1);
    printf("%d",max1);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
#define PI 3.14159265359
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
signed main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 2; i*i <= n; i++) {
		int cnt = 0;
		while (n%i == 0) {
			n /= i;
			cnt++;
		}
		f(j, cnt+2) {
			if (j*(j + 1) / 2 > cnt) {
				ans += j - 1;
				break;
			}
		}
	}
	if (n != 1)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3676
N,M = map(int, input().split())
As = list(map(int, input().split()))
As.sort()
BCs = [0 for i in range(M)]
for i in range(M):
    BCs[i] = list(map(int, input().split()))
BCs.sort(key=lambda x: x[1])
mark = 0
ans = 0
for i in reversed(range(M)):
    B = BCs[i][0]
    C = BCs[i][1]
    j = mark
    if As[j] >= C:
        break
    while As[j] < C and B > 0:
        As[j] = C
        j += 1
        if j >= N:
            break
        B -= 1
    
    ans += (j - mark)*C
    mark = j
    if j >= N:
        break
    
for i in range(mark,N):
    ans += As[i]

print(ans)


Measured memory_bytes: 32972
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{ 
  int i,j,k,n,d[50],ans;
  ans=0;
  cin>>n;
  for(i=0;i<n;i++){cin>>d[i];}
  for(i=0;i<n-1;i++)
  {
    for(j=i+1;j<n;j++)
    {
      ans=ans+d[i]*d[j]; 
    }
  }
  cout<<ans;
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <set>

using namespace std;

int main() {
    string s, t, u;
    int a, b;

    cin >> s >> t >> a >> b >> u;

    if (s == u)
        --a;
    else
        --b;

    cout << a << " " << b << endl;
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
const MOD: usize = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut n: usize = itr.next().unwrap().parse().unwrap();
    let mut m: usize = itr.next().unwrap().parse().unwrap();
    if n < m {
        std::mem::swap(&mut n, &mut m);
    }
    if n - m > 1 {
        println!("0");
    } else {
        let mut ans = 1;
        for i in 2..m + 1 {
            ans = ans * i % MOD * i % MOD;
        }
        for i in m + 1..n + 1 {
            ans = ans * i % MOD;
        }
        if n == m {
            ans = ans * 2 % MOD;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
s=input()
t=input()
a = len(s)
b = len(t)
l = []
for i in range(a-b+1):
    cnt = 0
    c = s[i:i+b]
    for x, y in zip(c, t):
        if x != y:
            cnt +=1
    l.append(cnt)
print(min(l))

Measured memory_bytes: 9084
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

ll calc(ll h) {
  if (h%2 == 0) return h/2;
  else return (h-1)/2;
}

ll mypow(ll N, ll P){
  if(P==0) return 1;
  if(P%2==0){
    ll t = mypow(N, P/2);
    return t*t;
  }
  return N * mypow(N, P-1);
}


int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  ll H;
  cin >> H;
  
  // -----------------------------

  int n_layers = 0;

  while(1){
    H = H/2;
    n_layers++;
    if(H==0) break;
  }
  
  /*
  n_layers++;
  while(1){
    H = calc(H);
    n_layers++;
    if (H == 1) break;
  }
  */


  ll sum = 0;
  /*
  while(n_layers > 0){
    sum += mypow(2, n_layers - 1);
    //sum += pow(2, n_layers - 1);
    n_layers--;
  }
  */

  sum = 1 * ( mypow(2, n_layers) - 1) / (2-1);

  cout << sum << endl;

  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 100000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
int res[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

// Main program
void solve(){
  ll N,K,R,S,P;
  string T;
  cin >> N ;
  cin >> K ;
  cin >> R ;
  cin >> S ;
  cin >> P ;
  cin >> T ;

  ll out=0;
  
  bool win;
  for(int i=0; i<N;i++){
    if(i<K){
      win=true;
    }
    else if(T[i]==T[i-K]){
      if(i>=2*K){
        if(res[i-K]==0){
          win=true;
        }
        else{
          win=false;
        }
      }
      else{
        win=false;
      }
    }
    else{
      win = true;
    }

    if(win){
      //cout << "w";
      res[i]=1;
      if(T[i]=='r'){
        out+=P;
      }
      else if(T[i]=='s'){
        out+=R;
      }
      else{
        out+=S;
      }
    }
    else{
      res[i]=0;
      //cout << "f";
    }
  }
  cout << out;

  return;

}

int main() {
    solve();
    return 0;
}






Measured memory_bytes: 848
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if (500 * a + 100 * b + 50 * c == X):
        count += 1

print(count)

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    ll l=0,r=INF;
    while(r-l>1){
        ll m=(l+r)/2;
        ll cnt=0;
        REP(i,n){
            cnt+=(a[i]+m-1)/m-1;
        }
        if(cnt<=k){
            r=m;
        }
        else{
            l=m;
        }
    }
    cout << r << endl;
}

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

int main() {
  int n, t, a;
  cin >> n >> t >> a;

  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h.at(i);
    h.at(i) = abs(t * 1000 - h.at(i) * 6 - a * 1000);
  }

  int minnum = h.at(0);
  for (int i = 0; i < n; ++i) {
    minnum = min(minnum, h.at(i));
  }
  for (int i = 0; i < n; ++i) {
    if (minnum == h.at(i)) {
      cout << i + 1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define all(x) x.begin(),x.end()
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long MOD=1e9+7;
const long long LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=200050;

int fa[MAXN];
int find(int x){
	if(fa[x]==x)return x;
	else return fa[x]=find(fa[x]);
}
void solve(int T){
	int n,m,u,v;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		fa[find(u)]=find(v);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(fa[i]==i)ans++;
	}
	printf("%d",ans-1);
}	
signed main(){
	int t=1;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//scanf("%d",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

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

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int ans = 0,ans2 = 0;
  int n = s.size();

  if (n == 1) cout << 0 << endl;
  else
  {
    for (int i = 1;i < n;i++)
      {
        if (s[0] == '0')
          {
            if (s[0] + (i % 2) != s[i])
              {
                ans++;
              }
          }
        else
          {
            if (s[0] - (i % 2) != s[i])
              {
                ans++;
              }
          }
      }

    for (int i = n - 2,j = 1;i >= 0;i--,j++)
      {
        if (s[n-1] == '0')
          {
            if (s[n-1] + (j % 2) != s[i])
              {
                ans2++;
              }
          }
        else
          {
            if (s[n-1] - (j % 2) != s[i])
              {
                ans2++;
              }
          }
      }
    cout << min(ans,ans2) << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int w,h;
pair<int, int> s,g;
int ice[20][20] = {{}};
int mini = 11;

int dfs(int y, int x, int k){
  if(k == 10) return 0;
  for(int i = y-1; i >= 0 ; i--){
    if(i == g.first && x == g.second){
      mini = min(k+1, mini);
      return 0;
    }
    if(ice[i][x] == 1 && i == y-1) break;
    if(ice[i][x] == 1 && i != y-1){
      ice[i][x] = 0;
      dfs(i+1, x, k+1);
      ice[i][x] = 1;
      break;
    }
  }
  for(int i = y+1; i < h ; i++){
    if(i == g.first && x == g.second){
      mini = min(k+1, mini);
      return 0;
    }
    if(ice[i][x] == 1 && i == y+1) break;
    if(ice[i][x] == 1 && i != y+1){
      ice[i][x] = 0;
      dfs(i-1, x, k+1);
      ice[i][x] = 1;
      break;
    }
  }
  for(int j = x-1; j >= 0 ; j--){
    if(y == g.first && j == g.second){
      mini = min(k+1, mini);
      return 0;
    }
    if(ice[y][j] == 1 && j == x-1) break;
    if(ice[y][j] == 1 && j != x-1){
      ice[y][j] = 0;
      dfs(y, j+1, k+1);
      ice[y][j] = 1;
      break;
    }
  }
  for(int j = x+1; j < w ; j++){
    if(y == g.first && j == g.second){
      mini = min(k+1, mini);
      return 0;
    }
    if(ice[y][j] == 1 && j == x+1) break;
    if(ice[y][j] == 1 && j != x+1){
      ice[y][j] = 0;
      dfs(y, j-1 , k+1);
      ice[y][j] = 1;
      break;
    }
  }
  return 0;
}

int main(){
  while(cin >> w >> h && w != 0){
    mini = 11;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w ; j++){
        cin >> ice[i][j];
        if(ice[i][j] == 2) s = make_pair(i, j);
        else if(ice[i][j] == 3) g = make_pair(i, j);
      }
    }
    dfs(s.first, s.second, 0);
    if(mini == 11) cout << -1 << endl;
    else cout << mini << endl;
  }
}



Measured memory_bytes: 3008
N=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
count=0
minus=0

for i in range(len(a)):
    if a[i]<0: minus+=1

if minus==0:
    for i in range(N-1):
        if a[i+1]-a[i]<0:
            a[i+1]+=a[i]
            b.append(i+1)
            c.append(i+2)
            count+=1
elif minus==len(a):
    for i in reversed(range(0,N-1)):
        if a[i+1]-a[i]<0:
            a[i]+=a[i+1]
            b.append(i+2)
            c.append(i+1)
            count+=1
else:
    count+=N
    if abs(max(a))>=abs(min(a)):
        ind=a.index(max(a))
        for i in range(N):
            b.append(ind+1)
            c.append(i+1)
        a2=list(map(lambda x:x+max(a),a))
        for i in range(N-1):
            if a2[i+1]-a2[i]<0:
                a2[i+1]+=a2[i]
                b.append(i+1)
                c.append(i+2)
                count+=1
    else:
        ind=a.index(min(a))
        for i in range(N):
            b.append(ind+1)
            c.append(i+1)
        a2=list(map(lambda x:x+min(a),a))
        for i in reversed(range(0,N-1)):
            if a2[i+1]-a2[i]<0:
                a2[i]+=a2[i+1]
                b.append(i+2)
                c.append(i+1)
                count+=1
print(count)
for i in range(len(b)):
    print(b[i]," ",c[i])

Measured memory_bytes: 3316
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    count = [0] * N
    for a in A:
        if a % 2 == N % 2:
            print(0)
            return
        count[a] += 1
    if N % 2 == 1 and count[0] == 1:
        count = count[1:]
    for cnt in count:
        if cnt != 0 and cnt != 2:
            print(0)
            return
    ret = (2 ** (N // 2)) % MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14768
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;


int main(){

string s;
cin>>s;
int a=0,b=0;
for(int i=0;i<s.length();i++){
    if(s[i]=='1')a++;
    else b++;
}
cout<<min(a,b)*2;



}

Measured memory_bytes: 512
while gets
  n,m=$_.split.map(&:to_i)
  break if n==0 and m==0
  mem=(1..n).map{|i| i}
  idx=m-1
  while mem.size>1
    mem.delete_at(idx)
    idx=(idx+m-1)%mem.size
  end
  puts mem
end

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	long double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed << w*h/2 << " " << (w/2 == x and h/2 == y) << endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (H, W, K) = Slice3<long>();
            var xyxy = Sarray();
            var sh = xyxy[0] - 1;
            var sw = xyxy[1] - 1;
            var gh = xyxy[2] - 1;
            var gw = xyxy[3] - 1;
            var ban = new string[H];
            for (var i = 0; i < H; ++i)
                ban[i] = ReadLine();
            var MAX = long.MaxValue / 2;
            var dsts = Enumerable.Repeat(0, (int)H).Select(_ => Enumerable.Repeat(MAX, (int)W).ToArray()).ToArray();
            dsts[sh][sw] = 0;
            var q = new Queue<(long h, long w)>();
            q.Enqueue((sh, sw));
            var dh = new int[4] { -1, 0, 0, 1 };
            var dw = new int[4] { 0, -1, 1, 0 };
            while (q.Any())
            {
                var (h, w) = q.Dequeue();
                var nd = dsts[h][w] + 1;
                for (var i = 0; i < 4; ++i)
                {
                    for (var k = 1; k <= K; ++k)
                    {
                        var nh = (int)(h + k * dh[i]);
                        var nw = (int)(w + k * dw[i]);
                        if (nh < 0 || H <= nh || nw < 0 || W <= nw) break;
                        if (ban[nh][nw] == '@') break;
                        if (dsts[nh][nw] < nd) break;
                        if (dsts[nh][nw] == nd) continue;
                        dsts[nh][nw] = nd;
                        q.Enqueue((nh, nw));
                    }
                }
            }
            if (MAX == dsts[gh][gw])
                WriteLine(-1);
            else
                WriteLine(dsts[gh][gw]);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 63352
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    int ans = a + b;
    ans = ans > a + c ? a + c : ans;
    ans = ans > b + c ? b + c : ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
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;}
//auto f = [&](int n)->int{return n;};
//auto a = [&](auto&&b){b(b)};



signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	multiset<int>st;
	REP(i,N){
		cin>>a[i];
		st.insert(-a[i]);
	}
	REP(i,N){
		st.erase(st.find(-a[i]));
		cout<<-(*st.lower_bound(-INF))<<endl;
		st.insert(-a[i]);
	}
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

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

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    string s; cin >> s;
    string ans = "";
    REP(i, s.size()){
        if (s[i] == '0') ans += "0";
        else if (s[i] == '1') ans += "1";
        else if (ans.size() > 0 && s[i] == 'B') ans.pop_back();
        else continue;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
L = gets.split.map(&:to_i)
sorted = L.sort

ans = 0
(0...(N - 1)).each do |ai|
  ((ai + 1)...N).each do |bi|
    a = sorted[ai]
    b = sorted[bi]
    n = a + b
    i = sorted.bsearch_index { |m| m >= n } || N
    ans += i - 1 - bi
  end
end
puts ans


Measured memory_bytes: 1916
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0;
  if(s[0]!=s[1]) a++;
  if(s[1]!=s[2]) a++;
  if(s[0]!=s[2]) a++;
  if(a!=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007LL
#define eps 1e-8
#define N 1000002
#define all(x) (x).begin(), (x).end()

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    bool f = false;
    while (n--) {
        int c;
        cin >> c;
        if (!(c%2)) {
            if ((c%3) && (c%5)) {
                f = true;
                break;
            }
        }
    }
    if (!f) cout << "APPROVED\n";
    else cout << "DENIED\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=3000;

signed main(){
    int N;cin>>N;
    vector<pair<pair<string,int>,int>>vec(N);
    REP(i,N){
        string s;int p;cin>>s>>p;
        vec[i]=mp(mp(s,-p),i+1);
    }
    sort(vec.begin(),vec.end());
    REP(i,N){
        cout<<vec[i].second<<endl;
    }
}

Measured memory_bytes: 256
INF=10**18
H,W=map(int,input().split())
G=[list(input()) for i in range(H)]

dp=[[INF]*W for i in range(H)]
dp[0][0]=0
dx=[0,1]
dy=[1,0]

for i in range(H):
    for j in range(W):
        for x,y in zip(dx,dy):
            if i+x>=H or j+y>=W:
                continue
            if G[i][j]=='.' and G[i+x][j+y]=='#':
                dp[i+x][j+y]=min(dp[i][j]+1,dp[i+x][j+y])
            else:
                dp[i+x][j+y]=min(dp[i][j],dp[i+x][j+y])
ans=dp[H-1][W-1]
print(ans if G[0][0]!='#' else ans+1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
constexpr int mxN = 5e3;
vl score[mxN];
void solve(){
    int n , k;
    read(n,k);
    vi p(n);
    vl c(n);
    REP(i,n){
        cin >> p[i];
        p[i]--;
    } 
    REP(i,n) cin >> c[i];
    
    for(int i = 0 ; i < n ; i++){
        int start_point = i;
        int current_point = start_point;
        //score[i].push_back(0);
        ll sum = 0;
        do{
            current_point = p[current_point]; 
            sum += c[current_point];
            score[i].push_back(sum);
        }while(current_point != start_point);
    }
    ll max_score = -1e9;
    for(int i = 0 ; i < n; i++){
        // for(int j = 0 ; j < score[i].size() ; j++){
        //     cout << score[i][j] << " ";
        // }
        // cout << endl;
        // find max_sub_score
        ll max_sub = -1e9;
        int max_sub_index = 0;
        for(int j = 0 ; j < min(k, (int) score[i].size()); j++){
            int left_k = k - j - 1; 
            ll sub = score[i][j];
            if( score[i].back() > 0){
                sub += left_k / (score[i].size()) * score[i].back();
            }
            if(sub > max_sub){
                max_sub = sub;
            }
        }
        if(max_sub > max_score){
            max_score = max_sub;
        }
    }
    cout << max_score << "\n";
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 218892
def solve():
    low, middle, high = sorted(list(map(int, input().split())))
    print(abs(high - middle) + abs(middle - low))


def model():
    tasks = list((map(int, input().split())))
    print(max(tasks) - min(tasks))


if __name__ == "__main__":
    # solve()
    model()


Measured memory_bytes: 2940
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,v,k[100001],g[100001],mk1,mk2,mg1,mg2,mx,mp1,kp1,gp1,kp2,gp2;
	scanf("%d",&n);
	for(i=1;i<=100000;i++)	{
		k[i]=0;	g[i]=0;
	}
	for(i=0;i<n/2;i++)	{
		scanf("%d",&v);
		g[v]++;
		scanf("%d",&v);
		k[v]++;
	}
	mk1=-1;	mg1=-1;
	for(i=1;i<=100000;i++)	{
		if(mk1<k[i])	{
			mk1=k[i];	kp1=i;
		}
		if(mg1<g[i])	{
			mg1=g[i];	gp1=i;
		}
	}
//	printf("   %d %d\n",kp1,gp1);
	k[kp1]=-1;	g[gp1]=-1;
	mk2=-1;	mg2=-1;
	for(i=1;i<=100000;i++)	{
		if(mk2<k[i])	{
			mk2=k[i];	kp2=i;
		}
		if(mg2<g[i])	{
			mg2=g[i];	gp2=i;
		}
	}
	if(kp1!=gp1)	{
		mx=mk1+mg1;
	}
	else {
		mx=max(mk1+mg2,mk2+mg1);
	}
	printf("%d\n",n-mx);
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			StringBuilder s=new StringBuilder(); 
			int val = Integer.parseInt(br.readLine());
			int x = 0;

			for (int i = 1; i <= val; i++) {
				if (i % 3 == 0 || i % 10 == 3) {
					s.append(" " + i);
				} else {
					x = i / 10;
					while (x != 0) {
						if (x % 10 == 3) {
							s.append(" " + i);
							break;
						}
						x /= 10;
					}
				}
			}
			System.out.println(s);
			br.close();
		} catch (Exception e) {
			System.err.println(e);
		}
	}
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string N;
  cin >> N;
  if(N[0]=='7'||N[1]=='7'||N[2]=='7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

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

	if(a==0){
		cout << b/x +1  << endl;
	}else{
		cout << b/x - (a-1)/x << endl;
	}

	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

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

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

    for (int i = 1; i <= 3; i++)
        if (a != i && b != i)
            cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 105
#define int long long int

void solve()
{
    double d,t,s;
    cin >>d>>t>>s;
    if(d/s <= t)
        cout << "Yes";
    else cout << "No";
    
    return;
}

int32_t main()
{
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    
    return 0;
}
/*
 AtCoder after Google Online Challenge Fail:(
 */


Measured memory_bytes: 3696
w,h,n=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
#x,y,a
#辺をどんどん更新していく
low_x=0
low_y=0
for i in range(n):
    if l[i][-1]==1 and low_x<l[i][0]:
        low_x=l[i][0]
    elif l[i][-1]==2 and w>l[i][0]:
        w=l[i][0]
    elif l[i][-1]==3 and low_y<l[i][1]:
        low_y=l[i][1]
    elif l[i][-1]==4 and h>l[i][1]:
        h=l[i][1]

#print(w,low_x,h,low_y)
print((w-low_x)*(h-low_y) if w>=low_x and h>=low_y else 0)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	int n;
	int i;
	int left,right;
	while(1){
		left = 0;
		right = 0;
		
		scanf("%d",&n);
		if(n == 0 ){
			break;
		}
		for(i = 0; i < n ;i++){
			int a, b;
			scanf("%d %d\n",&a,&b);
			if(a>b){
				left += a+b;
			}else if(a==b){
				left += a;
				right += b;
			}else { // a<b
				right += a+b;
			}
		}
		printf("%d %d\n",left,right);
	}
	return 0;
}

Measured memory_bytes: 0