akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, "%d%d", $a, $b);
for($i = 1; $i <= $a; $i++){
  $array = explode(" ", trim(fgets(STDIN)));
  if(in_array("snuke", $array)){
    $A = "A";
    $pos = array_search("snuke", $array);
    for($j = 0; $j < $pos; $j++){
      $A++;
    }
    echo $A.$i;
    exit;
  }
}

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

map<ll,ll> factor(ll x) {
    map<ll,ll> cand;
    ll p = 2;
    if (x == 1) {
        return cand;
    }
    while (p * p <= x) {
        if (x % p == 0) {
            cand[p]++;
            x /= p;
        } else {
            p++;
        }
    }
    if (x != 1) {
        cand[x]++;
    }

    return cand;
}

void solve() {
    ll a, b;
    cin >> a >> b;

    map<ll, ll> fac_a = factor(a);
    map<ll, ll> fac_b = factor(b);

    ll ans = 0;
    for (auto it = fac_a.begin(); it != fac_a.end(); it++) {
        if (fac_b[it->first] != 0) {
            ans++;
        }
    }

    cout << ans + 1 << endl;
}

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


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

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

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

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

  bool yes = true;

  for (int i = 1; i < n; ++i) {
    if (a[i - 1] == a[i])
      yes = false;
  }

  if (yes)
    puts("YES");
  else
    puts("NO");
}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 10;
const int oo = 1e18;

int n, ans;
int a[N], b[N], sum[N];

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);

    cin >> n;
    FOR(i, 1, n) {
        cin >> a[i] >> b[i];
        sum[i] = -(a[i] + b[i]);
        ans -= b[i];
    }

    sort(sum + 1, sum + n + 1);
    FOR(i, 1, n) if(i % 2) ans -= sum[i];
    return cout << ans, 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a-b)) << endl;
    return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int p, q, r;
    cin >> p >> q >> r;
    int sum = p + q + r;
    int maxx = max(p, max(q, r));
    cout << sum - maxx << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        int T = scan.nextInt();
        String[] status = {"AC", "WA", "TLE", "RE"};
        int[] count = new int[4];
        while(T != 0) {
            String ans = scan.next();
            if(ans.equals("AC")) {
                count[0] = count[0] + 1 ;
            } else if (ans.equals("WA")) {
                count[1] = count[1] + 1;
            } else if (ans.equals("TLE")) {
                count[2] = count[2] + 1;
            } else if (ans.equals("RE")){
                count[3] = count[3] + 1;
            }
            T--;
        }
        for(int i = 0; i < count.length; i++) {
            System.out.println(status[i] + " x " + count[i]);
        }
    }
}


Measured memory_bytes: 59092
import java.util.Arrays;
import java.util.Scanner;
public class Main {

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

		int n = sc.nextInt();
		double[] v = new double[n];
		double ans = 0;

		for(int i = 0; i< n; i++) {
			v[i] = sc.nextInt();
		}

		Arrays.sort(v);

		ans = (v[0] + v[1])/2;
		for(int i = 2; i < n; i++) {
			ans = (ans + v[i])/2;
		}

		System.out.println(String.format("%.5f", ans));

	}

}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	ll arr[200];
	for(ll i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	ll k=1;
	ll brr[200];
	brr[0]=INF;
	sort(arr+1,arr+1+n);
	for(ll i=1;i<=arr[n];i++)
	{
		ll sum=0;
		for(ll j=1;j<=n;j++)
		{
			sum+=(fabs(arr[j]-i)*fabs(arr[j]-i));
		}
		brr[k]=sum;
		k++;
	}
	for(ll i=1;i<=arr[n];i++)
	{
		if(brr[i+1]>brr[i])
		{
			cout<<brr[i]<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def nyu():
    num1 = input()
    #num2 = input().
    num2 = list(map(int,input().split()))
    num1 = int(num1)
    return num1,num2

def kansu(N,a):
    a_sum = 0
    b_sum = 0

    list.sort(a,reverse = True)
 
    
    for n in range(N):
        if n%2 == 0:
            a_sum += a[n]
        else:
            b_sum += a[n]
    
    print(a_sum - b_sum)
        
N,a = nyu()
kansu(N,a)


Measured memory_bytes: 3060
#include<set>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int l[1000005]={0};
int ans[1000005]={0};
int main()
{
   int n,x;
   cin>>n>>x;
   for(int i=1;i<=n;i++)
   {
        cin>>l[i];
   }
   ans[0]++;int d=0;   
   for(int i=1;i<=n;i++)
   {
        d+=l[i];
        ans[d]++;

   }
   int tot=0;
   for(int i=0;i<=x;i++)
   {
    //cout<<ans[i]<<" ";
    tot+=ans[i];
    }
    cout<<tot;
return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int a;
		int b;
		try (Scanner scanner = new Scanner(System.in)) {
			a = scanner.nextInt();
			b = scanner.nextInt();
		}

		if ((a & b & 1) == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

int func( const std::vector<int>& v, int n, int s ){
    int sum = 0;
    if ( n == v.size() ){
        if ( std::accumulate(v.begin(),v.end(),0) == s ){ return 1; }
        return 0;
    } else {
        for( int i=*(v.end()-1)+1; i<10; ++i ){
            std::vector<int> vx{v};
            vx.push_back(i);
            sum += func(vx, n, s);
        }
    }
    return sum;
}

int main(){
    for(;;){
        int n,s; int sum = 0;
        std::cin >> n >> s;
        if ( (n==0) && (s==0) ){return 0;}
        for( int i=0; i<10; ++i ){
            std::vector<int> v = {i};
             sum += func( v, n, s );
        }
        std::cout << sum << std::endl;
    }
}


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

//0 1->codeforces
#define LL "%lld"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf(LL,&a);return a;}

int main() {
  int n=gi();
  cout<<n*(n+1)/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	vector<ll> q(n);
	vector<ll> s(n);
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		q[i] = x + y;
		s[i] = x - y;
	}
	sort(q.begin(), q.end());
	sort(s.begin(), s.end());
	ll ans = abs(q[n - 1] - q[0]);
	ans = max(ans, abs(s[n - 1] - s[0]));
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 6460
#include<stdio.h>
int main (void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a!=1&&b!=1)
        printf("1\n");
    if(a!=2&&b!=2)
        printf("2\n");
    if(a!=3&&b!=3)
        printf("3\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
string s;
int q;

int main() {
    cin >> s >> q;
    deque<char> dq;
    for(int i = 0; i < s.length(); ++i) {
        dq.push_back(s.at(i));
    }

    int rev = 0;
    for(int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if(t == 1) {
            // 反転
            rev++;
        }else {
            int f;
            char c;
            cin >> f >> c;
            if(rev % 2 == 0) {
                if(f==1) dq.push_front(c);
                else dq.push_back(c);
            }else {
                if(f==1) dq.push_back(c);
                else dq.push_front(c);
            }
        }
    }



    if(rev % 2 == 1) reverse(dq.begin(), dq.end());

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

Measured memory_bytes: 896
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int c[N];

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

	int n;
	cin >> n;

	long long sum = 0;

	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		c[x]++;
		sum += x;
	}

	int q;
	cin >> q;

	while(q--) {
		int a, b;
		cin >> a >> b;

		sum += 1ll * c[a] * (b - a);
		
		cout << sum << "\n";
		
		c[b] += c[a];
		c[a] = 0;
	}



	return 0;
}


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

using namespace std;

/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)  //a~(b - 1)?????§
#define all(i) (i).begin(),(i).end() //??¨??????(sort??¨???)
#define mp make_pair //mp(OO, OO)??¨???:::pint??¨???

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/

int main(void)
{
  string a; cin >> a;
  for (int i = a.size(); i--;){
    cout << a[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1172
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String[] str = s.split(" ");
		long count = 0;
		long timer = 0;
		int time = 0;
		int n = Integer.parseInt(str[0]);
		int q = Integer.parseInt(str[1]);
		String name = new String();
		int[] array = new int[n];
		Queue<Integer> queue = new LinkedList<Integer>();
		Queue<String> namequeue = new LinkedList<String>();
		for(int i=0;i<n;i++){
			s = br.readLine();
			str = s.split(" ");
			namequeue.add(str[0]);
			queue.add(Integer.parseInt(str[1]));
		}
		for(int i=0;queue.isEmpty()!=true;i++){
			time=queue.poll();
			name=namequeue.poll();
			if(time>q){
				queue.add(time-q);
				namequeue.add(name);
				timer+=q;
			}
			else{
				timer+=time;
				System.out.println(name+" "+timer);
			}
		}
	}
}

Measured memory_bytes: 64368
#include "bits/stdc++.h"
using namespace std;
using ll = long long;


int main() {
    int n;
    cin >> n;
    vector< ll> v(n), a(n), b(n);
    for (auto& e : v) cin >> e;
    a[0] = v[0];
    b[n - 1] = v[n - 1];

    for (int i = 1; i < n; ++i) a[i] = a[i - 1] + v[i];
    for (int i = n - 2; i >= 0; i--) b[i] = b[i + 1] + v[i];
    ll res = 1e18;
    for (int i = 0; i + 1 < n; ++i) {
        res = min(res, llabs(a[i] - b[i + 1]));
    }
    cout << res << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
const ll MAX_NUM = 1000000009;

// int is_prime[MAX_NUM];
// ll factorial[MAX_NUM];

// void init_primes()
// {
//     rep(i, 0, MAX_NUM) is_prime[i] = 1;
//     is_prime[0] = is_prime[1] = 0;
//     rep(i, 2, MAX_NUM)
//     if (is_prime[i])
//     {
//         for (int j = i*i; j < MAX_NUM; ++j)
//             is_prime[j] = 0;
//     }
// }

vector<pll> decompose(ll n)
{
    vector<pll> res;
    int num_loop = n + 1;
    rep(i, 2, num_loop)
    {
        // cout << i << '.' << n % i << endl;
        if (n % i == 0)
        {
            int cnt = 0;
            while (n % i == 0)
            {
                ++cnt;
                n /= i;
            }
            // cout << "*******" << i << ' ' << cnt << ' ' << num_loop << ' ' << n % 3 << endl;
            res.emplace_back(i, cnt);
            if (n == 1) break;
        }
    }
    return res;
}

// void init_factorial()
// {
//     factorial[0] = factorial[1] = 1;
//     rep(i, 2, MAX_NUM)
//         factorial[i] = (factorial[i - 1] * i) % MOD;
// }

ll factorial(ll n)
{
    ll res = 1;
    rep(i, 2, n + 1)
        res = (res * i) % MOD;
    return res;
}
ll power_mod(ll n, ll m)
{
    ll res = 1;
    ll base = n;
    while (m > 0)
    {
        if (m&1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        m >>= 1;
    }
    return res;
}

ll inv_mod(ll n)
{
    return power_mod(n, MOD - 2);
}

ll comb_mod(ll n, ll m)
{
    ll res = 1;
    for (int i = n; i > n - m; i --)
        res = (res * i) % MOD;
    rep(i, 2, m + 1)
        res = (res * inv_mod(i)) % MOD;
    return res;
}

int main()
{
    // init_primes();
    // init_factorial();
    int n, m;
    cin >> n >> m;
    vector<pll> components = decompose(m);

    ll ans = 1;
    for (auto comp: components)
    {
        ll cnt = comp.second;
        // cout << comp.first <<' ' << comp.second << endl;
        ans = (ans * comb_mod(n - 1 + cnt, cnt)) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	cout<<setprecision(10)<<fixed<<double((n+1)/2)/n<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf=2333;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
ll n;
int g[233];
void init(){
	g[1]=0;
	for(int i=2;i<=80;++i){
		for(int k=1;;++k){
			if((1LL<<k)-i>=g[k]){
				g[i]=k;break;
			}
		}
	}
}
const int table[6][23] = {
{},
{1,2},
{0,0,2},
{0,0,0,4,6},
{0,0,0,0,36,108,220,334,384},
{0,0,0,0,0,976,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf}
};
int Get_g(ll n){
	if(n<=80)return g[n];
	for(int k=1;;++k){
		if((1LL<<k)-n>=g[k])return k;
	}
	return 114514;
}
int Solve(ll n,ll k){
	if(n<k)swap(n,k);
	if(!k)return 1;
	if(k<63&&(1LL<<(k-1))<n){
		return Solve((1LL<<k)-n,k);
	}
	if(k<=5)return table[k][n];
	return inf;
}
int main(){
	init();
	n=read();
	int ans=Solve(n,Get_g(n))+(n==4)+(n==7)*2;
	printf("%d\n",ans>1000?-1:ans);
	return 0;
}



Measured memory_bytes: 3732
#include <stdio.h>
#include <string.h>
 
int same(char *A, char *B, int i, int plength){
  int j;
 
  for(j = 0; j < plength; j++){
    if(A[i+j] != B[j]){
      return 0;
    }
  }
  return -1;
}
 
int main(){
  char A[1000], B[1000];
  int i, tlength, plength;
 
  scanf("%s", A);
  scanf("%s", B);
 
  tlength = strlen(A);
  plength = strlen(B);
 
  for(i = 0; i < tlength; i++){
    if(same(A, B, i, plength)){
      printf("%d\n", i);
    }     
  }
  return 0;
}

Measured memory_bytes: 540
module IntMap = Map.Make (struct type t = int let compare = compare end)

let rec solve k ((a, b) :: abs) =
  if k <= b then a
  else solve (k - b) abs

let () =
  let n, k = Scanf.scanf "%d %d\n" (fun n k -> n, k) in
  Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun a b -> a, b))
  |> Array.fold_left (fun s (a, b) ->
      IntMap.add a (b + try IntMap.find a s with Not_found -> 0) s) IntMap.empty
  |> IntMap.bindings
  |> solve k
  |> Printf.printf "%d\n"


Measured memory_bytes: 17024
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine()) - 1;
            int B = int.Parse(Console.ReadLine()) - 1;

            int[] f = new int[3];

            f[A] = 1;
            f[B] = 1;

            for (int i = 0; i < f.Length; i++)
            {
                if(0 == f[i])
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}



Measured memory_bytes: 11092
#include <iostream>

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


using namespace std;

typedef long long LL;



int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);


	int N,K,cnt;
	bool flg;

	cin >> N >> K;

	flg=false;

	cnt=0;
	for(int i=1;i<=N;i+=2){
		cnt++;
	}

    if(cnt>=K) flg=true;

	if(flg){
		cout << "YES";
	}else{
		cout << "NO";
	}

	return 0;
}

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

int main(){
    ll T; cin >> T;
    string store;
    for(ll i = 1; i <= T+1; i++){
        string x; cin >> x;
        v.push_back(x);
        if(i == T+1) store = x;
    }
    ll lastnum = T+1;
    ll firstnum = 1;
    set<ll> s;
    for(ll i = 0; i < v.size()-1; i++){
        string test = v[i];
        ll siz = min(store.size(), test.size());
        for(ll j = 0; j < siz; j++){
            if(test[j] == '?' && store[j] != 'a' && store[j] != 'z') break;
            else if(test[j] > store[j] && test[j] != '?'){
                s.insert(lastnum);
                lastnum --;
                break;
            }
            else if(test[j] < store[j] && test[j] != '?'){
                s.insert(firstnum);
                firstnum ++;
                break;
            }
            if(j == siz - 1){
                if(test.size() > store.size()){
                    s.insert(lastnum);
                    lastnum--;
                }
                else if(test.size() < store.size()){
                    s.insert(firstnum);
                    firstnum++;
                }
            }
        }
    }
    vector<ll> v2;
    for(ll i = 1; i <= T+1; i++){
        set<ll> :: iterator it = s.lower_bound(i);
        ll numfound = *it;
        if(numfound != i){
            v2.push_back(i);
        }
    }
    for(ll i = 0; i < v2.size(); i++){
        cout << v2[i];
        if(i != v2.size() - 1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    //freopen("in.txt","r",stdin);
    int n;
    scanf("%d",&n);
    printf("%d\n",a[n-1]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b;cin >> a >>b;
    cout << max({a+b,a*2-1,b*2-1}) << endl;
    return 0;
}

Measured memory_bytes: 3536
N = int(input())

if N <= 9 :
    print(0)
else :
    primeCount = [0] * (N + 1)
    for i in range(2, N + 1) :
        current = i
        for j in range(2, i + 1) :
            while current % j == 0:
                primeCount[j] += 1
                current = current // j

    def primeNum(m) :
        return len(list(filter(lambda x : x >= m - 1, primeCount)))

    ans = 0
    ans += primeNum(75)
    ans += primeNum(25) * (primeNum(3) - 1)  # 3 には 25が含まれる
    ans += primeNum(15) * (primeNum(5) - 1)
    ans += primeNum(5) * (primeNum(5) - 1) * (primeNum(3) - 2) // 2
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

typedef struct _point {
	int x;
	int y;
} point_t;

int main(int argc, char *argv[])
{
	int i;
	point_t s, t;
	scanf("%d %d %d %d", &s.x, &s.y, &t.x, &t.y);

	/* 1回目 */
	for ( i = 0; i < t.y-s.y; i++ ){
		printf("%c", 'U');
	}
	for ( i = 0; i < t.x-s.x; i++ ){
		printf("%c", 'R');
	}

	/* 2回目 */
	for ( i = 0; i < t.y-s.y; i++ ){
		printf("%c", 'D');
	}
	for ( i = 0; i < t.x-s.x+1; i++ ){
		printf("%c", 'L');
	}

	/* 3回目 */
	for ( i = 0; i < t.y-s.y+1; i++ ){
		printf("%c", 'U');
	}
	for ( i = 0; i < t.x-s.x+1; i++ ){
		printf("%c", 'R');
	}
	printf("%c", 'D');

	/* 4回目 */
	printf("%c", 'R');
	for ( i = 0; i < t.y-s.y+1; i++ ){
		printf("%c", 'D');
	}
	for ( i = 0; i < t.x-s.x+1; i++ ){
		printf("%c", 'L');
	}
	printf("%c\n", 'U');
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<climits>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<unordered_set>
#include<unordered_map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack> 
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define ull             unsigned long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define si              set<int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1e9+7
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(t)            int t; cin>>t; while(t--)
#define asc(i,a,n)      for (int i=a;i<n;i++)
#define dsc(i,a,n)      for (int i=n-1;i>=a;i--)
#define sz(x)           ((int)(x).size())
#define flg             if(flag==0)cout<<"Yes"<<endl;else{cout<<"No"<<endl;}
#define FLG             if(flag==0)cout<<"YES"<<endl;else{cout<<"NO"<<endl;}
#define input(arr,n)    for(int i=0; i<n ; i++) cin>>arr[i];
#define output(arr,n)   for(int i=0; i<n ; i++) cout<<arr[i]<<" ";
#define fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 


 
int32_t main()
{
  int s,w;
  cin>>s>>w;

  if(w>=s)
  {
    cout<<"unsafe"<<endl;
  }
  else
    cout<<"safe"<<endl;
}





Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
 
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    ll ans=0;
    rep(i,n){
        ll tmp=0;
        if(i==0){
            tmp+=a[i]/2;
            a[i]-=2*(a[i]/2);
        }
        else{
            bool f=false;
            if(a[i-1]>0){
                a[i]++;
                f=true;
            }
            tmp+=a[i]/2;
            a[i]-=2*(a[i]/2);
            if(tmp==0 && f) a[i]--;
        }
        ans+=tmp;
        //cout<<i<<" "<<tmp<<endl;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 105
#define INF (1e8)
struct edge{int from,to,cost;};
 
int n,m;
int si,ti,H;
 
vector<edge> E;
int d[MAX_N];
int prev[MAX_N];
int flg[MAX_N];
int G[MAX_N][MAX_N];
 
void init();
void input();
 
bool check(edge e){
  if(d[e.from]<=0)return false;
  int C=min(H,d[e.from]+e.cost);
   
  if(C<=d[e.to]||C<=0)return false;
  d[e.to]=C;
  prev[e.to]=e.from;
 
   
  int pos=e.from;
  map<int,bool> visited;
  vector<int> V;
  while(1){
    if(pos==-1)break;
    if(visited[pos])break;
    V.push_back(pos);
    visited[pos]=true;
    pos=prev[pos];
  }
  if(pos==-1||pos!=e.from)return true;
  reverse(V.begin(),V.end());
 
  int sum=0,size=V.size(),maxm=-INF;
  map<int,int> t;
  for(int i=0;i<size;i++){
    int p=V[i],q=V[(i+1)%size];
    sum=min(H,sum+G[p][q]);
    t[q]=sum;
    maxm=max(maxm,sum);
  }
  for(int i=0;i<size;i++){
    int p=V[i];
    if(t[p]==maxm)d[p]=H;    
  }
  return true;
}
 
void solve(){
  bool update=true;
  while(update){
    update=false;
    for(int i=0;i<(int)E.size();i++){
      if( check(E[i]) )update=true;
    }
  }
}
 
int main(){
  int Tc=1;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    init();
    input();
    solve();
    cout<<"Case "<<Tc++<<": ";
    if(d[ti]<=0)cout<<"GAME OVER"<<endl;
    else cout<<d[ti]<<endl;
  }
  return 0;
}
 
 
 
void init(){
  E.clear();
  for(int i=0;i<MAX_N;i++){
    d[i]=-INF;
    flg[i]=0;
    prev[i]=-1;
    for(int j=0;j<MAX_N;j++)G[i][j]=-INF;
  }
}
 
void input(){
  
  for(int i=0;i<m;i++){
    edge e;
    cin>>e.from>>e.to>>e.cost;
    G[e.from][e.to]=max(G[e.from][e.to],e.cost);
  }
  cin>>si>>ti>>H;
  d[si]=H;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(G[i][j]!=-INF&&i!=ti)
        E.push_back((edge){i,j,G[i][j]});
}

Measured memory_bytes: 1292
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int maxn=2e5+10;
typedef long long ll;const ll inf=1e15;
ll sum[maxn],f[maxn],ans=inf;int n,m,A,B,x[maxn];
struct seg{
	ll mn[maxn<<2];
	void build(int l,int r,int o){
		if(l==r){mn[o]=inf;return;}
		int mid=(l+r)>>1;
		build(l,mid,o<<1);build(mid+1,r,o<<1|1);
		mn[o]=min(mn[o<<1],mn[o<<1|1]);
	}
	ll query(int l,int r,int ql,int qr,int o){
		if(ql>r||qr<l) return inf;
		if(ql<=l&&r<=qr) return mn[o];
		int mid=(l+r)>>1;
		return min(query(l,mid,ql,qr,o<<1),query(mid+1,r,ql,qr,o<<1|1));
	}
	void upd(int l,int r,int o,int x,ll y){
		if(l==r){mn[o]=min(mn[o],y);return;}
		int mid=(l+r)>>1;
		if(x>mid) upd(mid+1,r,o<<1|1,x,y);
		else upd(l,mid,o<<1,x,y);mn[o]=min(mn[o<<1],mn[o<<1|1]);
	}
}c1,c2;
void dp(){
	c1.build(1,n,1);c2.build(1,n,1);c1.upd(1,n,1,x[0],f[1]-x[0]);c2.upd(1,n,1,x[0],f[1]+x[0]);
	rep(i,2,m){
		f[i]=min(c1.query(1,n,1,x[i],1)+sum[i-1]+x[i],c2.query(1,n,x[i]+1,n,1)+sum[i-1]-x[i]);
		c1.upd(1,n,1,x[i-1],f[i]-x[i-1]-sum[i]);c2.upd(1,n,1,x[i-1],f[i]+x[i-1]-sum[i]);
	}
	rep(i,1,m) ans=min(ans,f[i]+sum[m]-sum[i]);
}
int main(){
	scanf("%d%d%d%d",&n,&m,&A,&B);
	rep(i,1,m) scanf("%d",&x[i]);
	rep(i,2,m) sum[i]=sum[i-1]+abs(x[i]-x[i-1]);
	f[1]=abs(A-x[1]);x[0]=B;dp();
	f[1]=abs(B-x[1]);x[0]=A;dp();
	printf("%lld\n",ans);
	return 0;
}

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

int R, G, B, n, ans, ball;

int main(){
	cin >> R >> G >> B >> n;
	for(int r=0; r<n/R+1; r++){
		for(int g=0; g<n/G+1; g++){
			ball = n-r*R-g*G;
			if(ball<0){
				continue;
			}
			if(ball%B==0){
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
i;float x,z[8];float o(float*a,float*b,float*c){return a[1]*(*c-*b)+c[1]*(*b-*a)+b[1]*(*a-*c);}main(){for(;~scanf("%f,",z+i++%8);)i%8||puts(x*o(z+2,z+4,z+6)>0&x*o(z+4,z+6,z)>0&x*o(z+6,z,z+2)>0?"YES":"NO",x=o(z,z+2,z+4));}

Measured memory_bytes: 0
N = int(input())
sticks = list(map(int, input().split()))

answer = 0

if N < 3:
  print(answer)
  exit()

sticks.sort()

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if sticks[i] + sticks[j] > sticks[k] and sticks[i] != sticks[j] and sticks[j] != sticks[k]:
        answer += 1
print(answer)

Measured memory_bytes: 73656
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int h,n,a;
	cin>>h>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		h-=a;
		if(h<=0){
		cout<<"Yes"<<endl;	
		return 0;
		} 
		
	}
	cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define int long long int
#define vec vector<int>
#define mp map<int,int>
#define inf 1e18
using namespace std;
vector<int> v;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt=1;
  //cin>>tt;
  while(tt--)
  {
    int n,x,mod,i;
    cin>>n>>x>>mod;
    int dp[100011]={0},h[100011]={0};
    dp[1]=x,h[x]=1;
    for(i=2;1;i++)
    {
      dp[i]=((dp[i-1]) * (dp[i-1]))%mod;
      if(h[dp[i]])
        break;
      h[dp[i]]=i;
    }
    int y=i-1,z=h[dp[i]];
    for(i=2;i<=z-1;i++)
       dp[i]+=dp[i-1];
    int r=dp[z-1];
    dp[z-1]=0;
    for(i=z+1;i<=y;i++)
       dp[i]+=dp[i-1];
    int ans=(((((n-z+1)/(y-z+1))) * (dp[y]))+dp[(n-z+1)%(y-z+1)+z-1]+r);
    cout<<ans<<"\n";
  }
}


Measured memory_bytes: 5184
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
cnt = 0
for i in range(n):
    mat = 0
    for j in range(m):
        mat += a[i][j]*b[j]
    if mat + c > 0: cnt += 1
print(cnt)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#define _USE_MATH_DEFINES
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int p[105] = {0}, x, n;
    cin>>x>>n;
    while (n--){
        int pp;
        cin>>pp;
        p[pp]++;
    }

    int l = x, r = x;
    while (p[l]){
        l--;
    }
    while (p[r]){
        r++;
    }

    if (r-x < x-l){
        cout<<r<<"\n";
    }
    else{
        cout<<l<<"\n";
    }

    return 0;
}






Measured memory_bytes: 3168
X=int(input())
A=0
G=0
N=0
M=0
Z=0
N=int(X/500)
M=int(X%500)
Z=int(M/5)
N=N+Z
for i in range(0,N):
    if X>=500:
        X=X-500
        G=G+1000
    elif X>=5:
        X=X-5
        G=G+5
    else:
        break
        
print(G)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a;
    int a1,a2;
    cin >> a1;
    a2= a1%100;
    a1= a1/100;
    if(a1<=12&&a1!=0){
        a1 = 9; 
    }else{
        a1 =0;
    }
    if(a2<=12&&a2!=0){
        a2 = 9; 
    }else{
        a2 = 0;
    }
    if(a1*a2 == 81){
        cout << "AMBIGUOUS";
    }else if(a1 == 9 && a2 ==0){
        cout << "MMYY";
    }
    else if(a1 == 0 && a2 == 9){
        cout << "YYMM";
    }else{
        cout <<"NA";
    }
    cout << endl;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n);
    vector<int> count(n);
    forn(m) {
        int x, y;
        cin >> x >> y;
        v[x - 1].pb(y - 1);
        count[y - 1]++;
    }

    set<pair<int, int>> s;
    vector<int> dp(n);
    forn(n) {
        s.insert({count[i], i});
    }
    while (!s.empty()) {
        auto temp = *(s.begin());
        s.erase(s.find(temp));
        for (auto i : v[temp.ss]) {
            dp[i] = max(dp[i], dp[temp.ss] + 1);
            s.erase({count[i], i});
            count[i]--;
            s.insert({count[i], i});
        }
    }
    cout << *(max_element(dp.begin(), dp.end())) << '\n';
}

int main() {
    quick;
    solve();
}

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

bool judge(int a, int b, string &s) {
	if ((int)(s.length()) != a + b + 1)return false;

	int i;
	for (i = 0; i < a; i++) {
		if (s[i] < '0' || '9' < s[i])return false;
	}

	if (s[a] != '-')return false;

	for (i = a + 1; i < a + b + 1; i++) {
		if (s[i] < '0' || '9' < s[i])return false;
	}

	return true;
}

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

	cout << (judge(a, b, s) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int A, B; cin >> A >> B;
    int ans = 0;
    int n = 1;
    while(n < B){
        ans++;
        n += A - 1;
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline()[:-1]


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

A_ = []
B_ = []
end = False
for i in range(1, 1001):
	if i*8//100 == A and i//10 == B:
		print(i)
		end = True
		break
	else:
		continue
if end:
	pass
else:
	print(-1)


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;



int main() {
	unsigned int A, B, K;

	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 == 1) {
				A--;
			}
			A /= 2;
			B += A;
		}
		else {
			if (B % 2 == 1) {
				B--;
			}
			B /= 2;
			A += B;
		}
	}

	cout << A << " " << B;
	return 0;
}

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<ll,int> P;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

struct Point{
  double x,y,r;
  Point(double _x, double _y, double _r) {
    x = _x;
    y = _y;
    r = _r;
  }
};

int n;
double sx,sy,gx,gy;
bool used[1010];
double d[1010];

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

  cin >> sx >> sy >> gx >> gy;
  cin >> n;
  REP(i,n+2) d[i] = INF;
  vector<Point> p;
  p.pb(Point(sx,sy,0));
  p.pb(Point(gx,gy,0));
  REP(i,n) {
    double x,y,r;
    cin >> x >> y >> r;
    p.pb(Point(x,y,r));
  }

  priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<ll,int>>> pq;
  pq.push({0,0});
  d[0] = 0;
  while (!pq.empty()) {
    pair<ll,int> tp = pq.top();
    pq.pop();
    if (used[tp.se]) continue;
    if (d[tp.se] < tp.fi) continue;
    used[tp.se] = 1;
    REP(i,sz(p)) {
      if (used[i]) continue;
      double dist = max((double)0, sqrt((p[tp.se].x - p[i].x) * (p[tp.se].x - p[i].x) + (p[tp.se].y - p[i].y) * (p[tp.se].y - p[i].y)) - p[tp.se].r - p[i].r);
      if (d[tp.se] + dist < d[i]) {
        d[i] = d[tp.se] + dist;
        pq.push({d[i], i});
      }
    }
  }
  cout << setprecision(20) << d[1] << endl;
  return 0;
}


Measured memory_bytes: 6404
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, p;
    cin >> a >> p;
    cout << (3*a + p) / 2 << endl;
}

Measured memory_bytes: 764
# coding: utf-8
import numpy as np
mod = 998244353
N, S = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))

dp = np.array([[0 for _ in range(S+1)] for i in range(N+1)])

for k in range(0, N):
  dp[k+1,:] += (2 * dp[k,:] - dp[k-1,:]) % mod
  if S > A[k+1]:
    dp[k+1, A[k+1]+1:] += (dp[k, 1:S-A[k+1]+1] - dp[k-1, 1:S-A[k+1]+1]) % mod
  if A[k+1] <= S:
    dp[k+1,A[k+1]] += k+1

print(dp[N,S] % mod)

Measured memory_bytes: 161044
#include<bits/stdc++.h>
    #define ll long long
    #define f   first
    #define s   second
    #define pb          push_back
    #define mod         1000000007
    #define hell        998244353
    #define inf         1000000000000000000LL
    using namespace std;
    ll n,k,m,sum,q;
    ll s,l,r,x,y,h,w;
    //ll a[1005][1005];
    
    void solve()
    {   
        ll n1,n2,n3;
        cin>>n>>k;
        vector<ll> v(n+1);
        for(int i=1;i<=n;i++) cin>>v[i];
        bool vis[n+1];
        memset(vis,0,sizeof(vis));
        vector<ll> ans;
        ans.pb(1);
        vis[1]=1;
        ll cur=v[1];
        ll id;
        while(1)
        {
            if(vis[cur]){n1=cur;break;}
                if(!vis[cur]){vis[cur]=1;ans.pb(cur);cur=v[cur];}    
        }
        for(int i=0;i<ans.size();i++)
        {
            if(ans[i]==n1) {n2=ans.size()-i;id=i;}
        }
        n3=ans.size()-n2;
        if(k<=n3)
        {
            cout<<v[ans[k-1]];
        }
        else
        {
            k-=n3;
            k=(k%n2);
            vector<ll> ans2;
            for(int i=id;i<ans.size();i++) ans2.pb(ans[i]);
            //for(auto x:ans2) cout<<x<<" ";
            cout<<ans2[k];


        }

        
    }   
    int main()
    {   
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        //cout<<primes.size();
        ll t=1;
      //cin>>t;
        while(t--)
            solve();
    }


    


Measured memory_bytes: 9424
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define ll long long

using namespace std;


int main() {
    int x;
    cin >> x;
    if (x < 600) {
        cout << 8;
    } else if (x < 800) {
        cout << 7;
    } else if (x < 1000) {
        cout << 6;
    } else if (x < 1200) {
        cout << 5;
    } else if (x < 1400) {
        cout << 4;
    } else if (x < 1600) {
        cout << 3;
    } else if (x < 1800) {
        cout << 2;
    } else if (x < 2000) {
        cout << 1;
    }
}


Measured memory_bytes: 3616
#include <stdio.h>
int main(void){
  int i;
  char  s[1024];
  char t[8]={'k','s','t','n','h','m','y','r'};
  scanf("%s",s);
  for(i=0;s[i];i=i+2){
    if(s[i]=='0'&&s[i+1]=='U')
      printf("nn");
    else{
      if(s[i]=='0')
	putchar('w');
      else if('2'<=s[i]&&s[i]<='9')
	putchar(t[s[i]-'0'-2]);
      switch(s[i+1]){
      case 'T':putchar('a');break;
      case 'L':putchar('i');break;
      case 'U':putchar('u');break;
      case 'R':putchar('e');break;
      case 'D':putchar('o');
      }
    }
  }
  puts("");
  return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  vector<int> moji[26];
  rep(i,s.size() ){
    moji[s[i]-97].push_back(i);
  }
  int ans=INF;
  rep(i,26){
    if(moji[i].size() !=0) {
      int prev=-1,now=0;
      rep(j,moji[i].size() ){
	now=max(now,moji[i][j]-prev-1);
	prev=moji[i][j];
	if(now > (s.size()-moji[i][j]-1)) break;
	else if(j==moji[i].size()-1){
	  now=s.size()-moji[i][j]-1;
	}
      }
      ans=min(ans,now);
      //cout<<i+97<<" "<<now<<endl;
    }
  }
  if(ans==INF) ans=0;
  cout<<ans<<endl;
		   
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	int n;
	char h;
	string s;
	int abo[4] = { 0 };

	while (cin >> n >> h >> s){
		if (s == "A"){
			abo[0]++;
		}
		else if (s == "B"){
			abo[1]++;
		}
		else if (s == "AB"){
			abo[2]++;
		}
		else{
			abo[3]++;
		}
	}
	
for (int i = 0; i < 4; i++){
	cout << abo[i] << endl;
}
}

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;


void printv(int v[], int len) {
	int ifs = 1;
	for (int i = 0; i < len; i++) {
		if (ifs == 0)
			cout << " ";
		cout << v[i];
		ifs = 0;
	}
	cout << endl;
}

int main() {
	int n;
	while (cin >> n, n) {
		int *s = new int[n];
		for (int i = 0; i < n; i++)
			cin >> s[i];
		int *c = new int[n];
		int *p = new int[n];
		int cnt = 0;
		int vlen = sizeof(int) * n;
		memcpy(c, s, vlen);
		while (1) {
			memset(p, 0, vlen);
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					if (c[i] == c[j])
						p[i]++;
			if (memcmp(c, p, vlen) == 0)
				break;
			memcpy(c, p, vlen);
			cnt++;
		}
		cout << cnt << endl;
		printv(p, n);

		delete[] s;
		delete[] c;
		delete[] p;
	}
	return 0;
}

Measured memory_bytes: 1204
import numpy as np
H, W, *A = open(0).read().split()
H = int(H)
W = int(W)

A = list(map(lambda x: list(map(int, x.replace(".", "0").replace("#", "1"))), A))
A = np.array(A)
r = np.sum(A, axis = 0)
c = np.sum(A, axis = 1)

A = A[c != 0, :]
A = A[:, r != 0]

res = list(map(lambda x: "".join(list(map(str, list(x)))).replace("0", ".").replace("1", "#"), list(A)))
for x in res:
  print(x)



Measured memory_bytes: 12588
#include "bits/stdc++.h"
using namespace std;
const int N=1e5+20;
int n,a[N],b[N];
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);


	for(int i=1;i<=n;i++)
	{
		if(b[i]>=a[i])
		{
			ans+=a[i];
			b[i]-=a[i];
			if(i+1<=n+1)
			{
				if(b[i]>=a[i+1])
				{
					ans+=a[i+1];
					a[i+1]=0;
				}
				else
				{
					ans+=b[i];
					a[i+1]-=b[i];
				}
			}
		}
		else
		{
			ans+=b[i];
		}
	}

	cout<<ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
using namespace std;

int arr[100013];
int dp[100013];

int mut(int x){
	if(x<0){
		return -x;
	}
	return x;
}
 
int main(){
	//fri("a.txt");
	//fro("b.txt");
	int n;
	sc(n);
	for(int i=1;i<=n;i++){
		sc(arr[i]);
	}
	dp[n-1]=mut(arr[n]-arr[n-1]);
	for(int i=n-2;i>=1;i--){
		dp[i]=min(dp[i+2]+mut(arr[i+2]-arr[i]),dp[i+1]+mut(arr[i+1]-arr[i]));
	}
	cout<<dp[1]<<endl;
	
	return 0;
}

Measured memory_bytes: 1024