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

double x[100];
double y[100];

typedef double W;

const W INF = 1e9;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;


void dijkstra(int s, const Graph& G, vector<W>& d, vector<int>& prev) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	fill(prev.begin(), prev.end(), -1);

	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				prev[e.to] = v;
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

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

	int n, m;
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			int b;
			double xx, yy;
			cin >> b >> xx >> yy;
			b--;
			x[b] = xx, y[b] = yy;
		}

		Graph G(n);
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				double dx = x[i] - x[j];
				double dy = y[i] - y[j];
				double dist = sqrt(dx * dx + dy * dy);
				if(dist <= 50) {
					G[i].push_back({ j, dist });
					G[j].push_back({ i, dist });
				}
			}
		}

		cin >> m;
		vector<double> d(n);
		vector<int> prev(n);
		for(int i = 0; i < m; i++) {
			int s, g;
			cin >> s >> g;
			s--, g--;
			dijkstra(s, G, d, prev);
			if(d[g] == INF) {
				cout << "NA" << endl;
			}
			else {
				vector<int> ans;
				int v = g;
				ans.push_back(g);
				while(v != s) {
					v = prev[v];
					ans.push_back(v);
				}
				for(int j = ans.size() - 1; j >= 0; j--) {
					cout << ans[j] + 1;
					if(j != 0) cout << " ";
					else cout << endl;
				}
			}
		}

	}
}

Measured memory_bytes: 3216
#include "bits/stdc++.h"
using namespace std;

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

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;

int a[N];
bool dp[N];

int main(){
fast;
int n,k;
cin>>n>>k;

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

for(int v=0;v<=k;v++) {
    dp[v]=false;
    for(int i=0;i<n;i++) {
        if(v-a[i] >= 0 and !dp[v-a[i]]) {
            dp[v]=true;
        } 
    }
}

cout<<(dp[k] ? "First" : "Second")<<endl;
return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vll;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N;cin>>N;
    string S; cin>>S;
    vvi dp(N,vector<int>(N+1,-1));
    int maxi = 0;
    REP(i,N-1){
        FOR(k,i+1,N){
            if(dp[i][k] != -1) continue;
            int nowi = i;
            int nowk = k;
            int itr = 0;
            while(S[nowi] == S[nowk]){
                nowi++; nowk++;
                itr++;

                if(nowk >= N || nowi >= k) break;
            }
            dp[i][k] = itr;
            maxi = max(maxi,itr);
            for(int j = 1; j < itr; j++){
                dp[i+j][k+j] = 0;
            }
        }
    }

    cout<<maxi<<endl;
}

Measured memory_bytes: 98176
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class BGuidebook {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<pair<string, int>> v;
        map<pair<string, int>, int> id;
        REP(i, N) {
            string s;
            int p;
            cin >> s >>p;
            v.push_back({s, -p});
            id[{s, -p}] = i + 1;
        }
        sort(v.begin(), v.end());
        REP(i, v.size()) {
            cout << id[v[i]] << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BGuidebook solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  int v[n];
  for(int i = 0; i < n; i++){
    int a;
    cin>>a;
    v[a-1] = i+1;
  }
  for(int i = 0; i < n; i++){
    cout<<v[i]<<" ";
  }
  cout<<endl;
  return 0;
}


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

minus_cnt = 0
zero_cnt = 0
for ai in A:
    if ai == 0:
        zero_cnt += 1
    elif ai < 0:
        minus_cnt += 1

A = [abs(ai) for ai in A]

sm_a = sum(A)
min_a = min(A)

if zero_cnt > 0:
    print(sm_a)
else:
    if minus_cnt % 2 == 0:
        print(sm_a)
    else:
        r = sm_a - 2 * min_a
        print(r)

Measured memory_bytes: 14412
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let (a, b, t) = scan!(sc; i32, i32, i32);
  println!("{}", (t / a) * b);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
	int ans = 0;
	
	bool V[VMAX];
	for(int i = 0; i < n; i++) {
		B[i] = A[i];
		V[i] = false;
	}
	sort(B, B + n);
	for(int i = 0; i < n; i++) T[B[i]] = i;
	for(int i = 0; i < n; i++) {
		if( V[i] ) continue;
		int cur = i;
		int S = 0;
		int an = 0;
		int m = VMAX;
		while(1) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if( V[cur] ) break;			
		}
		ans += min(S + (an - 2) * m, S + m +(an + 1) * s);
	}
	
	return ans;
} 

int main() {
	cin >> n;
	s = VMAX;
	for(int i = 0; i < n; i++) {
		cin >> A[i];
		s = min(s, A[i]);
	}
	int ans = solve();
	cout << ans << endl;
	
	return 0;
}
 

Measured memory_bytes: 3156
n, m = map(int, input().split())
h = list(map(int, input().split()))
# h = [[i, h[i-1]] for i in range(1, n+1)]
# path = [list(map(int, input().split())) for i in range(m)]
# conn = {key: [] for key in range(1, n+1)}
tower = list(range(1, n+1))
ma = [0]*n

for i in range(m):
    p = list(map(int, input().split()))
    ma[p[0]-1] = max(ma[p[0]-1], h[p[1]-1])
    ma[p[1]-1] = max(ma[p[1]-1], h[p[0]-1])
    """
    # h0 > h1
    if h[p[0]-1] == h[p[1]-1]:
        if p[0] in tower:
            tower.remove(p[0])
        if p[1] in tower:
            tower.remove(p[1])
    elif h[p[0]-1] > h[p[1]-1]:
        if p[1] in tower:
            tower.remove(p[1])
    else:
        if p[0] in tower:
            tower.remove(p[0])
    """
cnt = 0
for i in range(n):
    cnt += (h[i] > ma[i])
print(cnt, end="")


Measured memory_bytes: 84824
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, t[MAXN], v[MAXN], g[40010];
int dp[40010][210];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> t[i];
    FOR(i,1,n) cin >> v[i];
    FOR(i,1,n) {
        t[i] = 2*t[i];
        v[i] = 2*v[i];
    }
    int s = 0, p = 0;
    FOR(i,1,n) {
        int preS = s;
        s += t[i];
        FOR(j,preS,s-1) g[j] = v[i];
        p = max(p, v[i]);
    }
    FOR(i,0,s) 
        FOR(j,0,p) dp[i][j] = -2000000000;
    dp[0][0] = 0;
    FOR(i,0,s-1) {
        FOR(j,0,g[i]) {
            FOR(k,-1,1) {
                int h = j + k;
                if (h > g[i] || h < 0) continue;
                dp[i+1][h] = max(dp[i+1][h], dp[i][j] + h);
            }
        }
    }
    cout << fixed << setprecision(9) << dp[s][0] / 4.0;
    return 0;
}

Measured memory_bytes: 33280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main() {
  int A[3][3];
  int isb[3][3]={{0,0,0},{0,0,0},{0,0,0}};

  int b[10];
  int n;
  rep(i,3){
    rep(j,3){
      cin >> A[i][j];
    }
  }
  cin >> n;
  rep(i,n) cin >> b[i];

  rep(i,n){
    int m=b[i];
    rep(j,3){
      rep(k,3){
        if(A[j][k]==m)isb[j][k]=1;
      }
    }
  }
  rep(i,3){

    if(isb[i][0]&&isb[i][1]&&isb[i][2])
      {cout << "Yes"; return 0;}
  }

  rep(i,3){
    if(isb[0][i]&&isb[1][i]&&isb[2][i])
      {cout << "Yes"; return 0;}
  }

  if(isb[0][0]&&isb[1][1]&&isb[2][2])
      {cout << "Yes"; return 0;}

  if(isb[0][2]&&isb[1][1]&&isb[2][0])
      {cout << "Yes"; return 0;}

  cout << "No";


}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int a[200000+100];
typedef long long LL;
LL min(LL  a,LL b)
{
	return a<b ? a:b;
}
int main()
{
	int N;
	scanf("%d",&N);
	LL sum=0;
	for(int i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	LL mining=-1;
	LL a1=0;
	LL a2=sum;
	for(int i=0;i < N-1;i++)
	{
		a1+=a[i];
		a2-=a[i];
		LL zhan;
		if(a1-a2 < 0)
			zhan=a2-a1;
		else
			zhan=a1-a2;
		if(mining==-1)
			mining=zhan;
		else
			mining=min(mining,zhan);
	}
	printf("%lld\n",mining);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL 

struct node {

  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};

typedef struct node* Node;
Node root;
 
void insert(int k) {
    
 Node y = NIL;
 Node x = root;
 Node z;  

 z = malloc(sizeof(struct node));
 z->key = k;
 z->left = NIL;
 z->right = NIL;
   
 while(x != NIL) {
    y = x;
  if(z->key < x->key)
    x = x->left;
  
  else x = x->right;
 }
  z->parent = y;
  
  if(y == NIL)
    root = z;
  
  else if(z->key < y->key)
    y->left = z;
  
  else 
    y->right = z;
  
}

void inorder(Node u) {
  
  if(u->left != NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)  
    inorder(u->right); 
}

void preorder(Node u) {
  printf(" %d",u->key);
  if(u->left != NIL)
    preorder(u->left);
  if(u->right != NIL)
    preorder(u->right); 
}

int main(void) {
  
  int i,n,x;
  char c[5];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",c);
    if(c[0] == 'i') {
      scanf("%d",&x);
      insert(x);
    }
    else if(c[0] == 'p') {
      if(root != NIL)   
	inorder(root);
      printf("\n");
      if(root != NIL)
	preorder(root);
      printf("\n");
      
    }
  }
  return 0;
}

Measured memory_bytes: 24036
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {

    public static void main(String[] args) throws IOException {
        ReaderA.init(System.in);
        System.out.println(ReaderA.nextInt()/3);
    }
}

/**
 * Reader class based on the article at "https://www.cpe.ku.ac.th/~jim/java-io.html"
 */
class ReaderA {
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    //    Get a whole line.
    static String line() throws IOException {
        return reader.readLine();
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}



Measured memory_bytes: 21332
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)

int main() {
    ll N;
    ll K;
    cin>>N>>K;
    vector<ll> A(N,-1);
    rep(i,N){
        cin>>A[i];
    }
    if(K >= 50){
        K = 50;
    }
    while(K--){
        vector<ll> B(N,0);
        rep(i,N){
            ll l = max((ll) 0,i-A[i]);
            B[l]++;
            ll r = min(N-1,i+A[i]);
            if(r+1<N){
                B[r+1]--;
            }
        }
        rep(i,N-1){
            B[i+1]+=B[i];
        }
        A = B;
    }
    for(auto x: A){
        cout<<x<<" ";
    }
    cout<<endl;
    return 0;
}

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

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DD(x,y)     cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << '\n'
#define DDD(x,y,z)  cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << '\n'
#define DBG         cerr << __LINE__ << ": Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction
#define MAX     1000
int k, failCost[MAX+10];

double dp[MAX+10], minCost[MAX+10][40][MAX+10], avg[40];
double solve(int n);
double call(int have, int needToUse, int curLen)
{
    assert(have >= needToUse);
    if(needToUse == 0)
    {
//        DBG;
        return solve(have) + failCost[0];
    }
    int total = have + curLen;
    double p = ((double)(curLen+1))/(total+1); /// probability of this failing
    if(have == needToUse)
    {
//        DBG;
//        D(p*failCost[needToUse]);
        double ret = p * (solve(curLen) + failCost[needToUse]);
        ret += (1-p) * (avg[needToUse]);
        return ret;
    }
//    assert(false);
    double &ret = minCost[have][needToUse][curLen];
    if(ret == ret)
        return ret;



    /// pick this

    double tmp = p * (solve(curLen) + failCost[needToUse])
                +(1-p) * call(have-1, needToUse-1, 0);

    ret = tmp;

    /// dont pick this
    tmp = call(have-1, needToUse, curLen+1);

    ret = min(ret, tmp);
    return ret;
}

double solve(int n)
{
//    D(n);
    if(n == 0)
        return 0;
    double &ret = dp[n];
    if(ret == ret)
        return ret;
    ret = 1e100;
    for(int i = 1; i<=min(n,k); i++)
    {
        ret = min(ret, call(n, i, 0));
    }
    return ret;
}
int main()
{
//    freopen("maxon.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int a, b;
    sfff(a,b,k);
    for(int i = 0; i<=k; i++)
        sf(failCost[i]);
    for(int i = 0; i<=k; i++)
    {
        for(int firstFail = 2; firstFail <= i+1; firstFail++)
        {
            avg[i] += (1.0/(i)) * failCost[i-firstFail+1];
        }
    }
    mem(dp, -1);
    mem(minCost, -1);
    printf("%.9f\n",solve(b-a+-1));
    return 0;
}





Measured memory_bytes: 322144
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string n;
  cin >> n;
  if (n[0] == '9' || n[1] == '9')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    S = rl().rstrip()
    
    accw, acce = [0] * (N + 1), [0] * (N + 1)
    for i in range(N):
        accw[i + 1] = accw[i] + (S[i] == 'W')
        acce[i + 1] = acce[i] + (S[i] == 'E')
    
    ans = 10 ** 6
    for i in range(N):
        ans = min(ans, acce[-1] - acce[i + 1] + accw[i])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 45552
def func(a, b, c):
    return a**2 + b**2 + c**2 + a*b + b*c + c*a

n = int(input())
ans = [0]*(n+1)
x, y, z = (1, 1, 1)
flag = 0
while flag == 0:
    if func(x, 1, 1) <= n:
        for y in range(1, x+1):
            for z in range(1, y+1):
                num = func(x, y, z)
                if num <= n and x == y == z:
                    ans[num] += 1
                elif num <= n and (x == y or y == z or z == x):
                    ans[num] += 3
                elif num <= n:
                    ans[num] += 6
    else:
        flag = 1
    x += 1

for i in range(1, n+1):
    print(ans[i])


Measured memory_bytes: 9280
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;


int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    rep(i,n)
    {
        int a;
        cin >> a;
        while(a%2==0 && a>0)
        {
            cnt++;
            a = a/2;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for(int i = 0; i < n; i++) cin >> a[i];
  a[n] = 0;
  int mbi = n, msi = n;
  for(int i = 0; i < n; i++) {
    if(a[mbi] < a[i]) mbi = i;
    if(a[msi] > a[i]) msi = i;
  }
  if(a[mbi] == 0 && a[msi] == 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<pair<int, int>> ans;
  if(abs(a[mbi]) > abs(a[msi])) {
    ans.push_back(make_pair(mbi + 1, n));
    ans.push_back(make_pair(mbi + 1, n));
    for(int i = 0; i < n - 1; i++) {
      ans.push_back(make_pair(n, i + 1));
      ans.push_back(make_pair(n, n));
    }
  } else {
    ans.push_back(make_pair(msi + 1, 1));
    ans.push_back(make_pair(msi + 1, 1));
    for(int i = n - 1; i > 0; i--) {
      ans.push_back(make_pair(1, i + 1));
      ans.push_back(make_pair(1, 1));
    }
  }
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    String y = sc.next();
    int xn = (int)x.charAt(0);
    int yn = (int)y.charAt(0);
    
    if(xn == yn) System.out.println("=");
    else if(xn > yn) System.out.println(">");
    else System.out.println("<");
  }
}


Measured memory_bytes: 35716
#include <stdio.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

int n, m;
int a[100], b[100];

int main() {
    for(;;) {
        scanf("%d%d", &n, &m);
        if(n==0 && m==0) return 0;
        rep(i, n) scanf("%d", a+i);
        rep(i, m) scanf("%d", b+i);
        const int s1 = accumulate(a, a+n, 0);
        const int s2 = accumulate(b, b+m, 0);
        int ans1=-1, ans2=-1, minv=1000;
        rep(i, n) rep(j, m) if(s1-a[i]+b[j]==s2+a[i]-b[j]) {
            const int v = a[i]+b[j];
            if(minv>v) minv=v, ans1=a[i], ans2=b[j];
        }
        if(minv==1000) printf("%d\n", -1);
        else printf("%d %d\n", ans1, ans2);
    }
}

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

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

  if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int n,m;
  while(cin>>n>>m) {
    string s;
    cin >> s;
    int cur = n;
    vector<int> ans;
    while (cur != 0) {
      int cnt;
      for (cnt=m; cnt>=1; cnt--) {
        if (cur-cnt>=0 && s[cur-cnt] == '0') break;
      }
      if (cnt == 0) break;
      cur = cur-cnt;
      ans.push_back(cnt);
    }
    if (cur != 0) {
      cout << -1 << endl;
    } else {
      reverse(ALL(ans));
      int as = ans.size();
      REP(i,as)
        printf("%d%c",ans[i], i!=as-1?' ':'\n');
    }
  }
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define pi acos(-1)
#define el << endl
#define yes cout << "YES" <<  endl
#define no cout << "NO" << endl
#define show(x) cout << x << endl
#define impossible cout<< "impossible" << endl
#define tc int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const ll maxn = 2e5+10;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);



	ll a,b;
	cin>>a>>b;
	cout << a*b<<endl;


	return 0;
}
///Alhamdulillah
///Full : by me:)




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ret = 0;
  if (a[0] > x) {
    ret += a[0] - x;
    a[0] = x;
  }
  for (int i = 1; i < n; i++) {
    int t = a[i] + a[i - 1] - x;
    if (t > 0) {
      a[i] -= t;
      ret += t;
    }
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

double dis(ll x,ll y,ll X,ll Y){
    return sqrt((x-X)*(x-X)+(y-Y)*(y-Y));
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    if(n%2){
        cout<<"No"<<endl;return 0;
    }
    string s;cin>>s;
    string k=s.substr(0,n/2);
    string t=s.substr(n/2,n/2);
    
    if(k==t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        boolean flag=false;
        if(N==0) {
            System.out.println(X);
            flag=true;
        }else {
            Set<Integer> nums = new HashSet<Integer>();
            for(int i=0; i<N; i++) {
                nums.add(sc.nextInt());
            }

            for(int i=0; i<Math.min(X,101-X)+1;i++) {
                if(!nums.contains(X-i)) {
                    System.out.println(X-i);
                    flag=true;
                    break;
                }else if(!nums.contains(X+i)){
                    System.out.println(X+i);
                    flag=true;
                    break;
                }
            }
            if(!flag) {
                if(X<=50) {
                    System.out.println(0);
                }else {
                    System.out.println(101);
                }
            }

        }
	}

}


Measured memory_bytes: 36016
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
unordered_map<ll,vector<ll>> adj;
vector<ll> vis(300005,0);
vector<ll> p(100005,0);
ll c[100005];
ll cnt;
void dfs(ll node)
{
  if(vis[node])
    return;
  vis[node]=1;
  cnt++;
  for(auto i:adj[node])
    {
      dfs(i);
    }
}

int main()
{
   ll x;
   cin>>x;
   if(x==0)
    cout<<"1";
  else
    cout<<"0";
}

Measured memory_bytes: 6228
n = int(input())
alp = [chr(i) for i in range(97, 97+26)]
ans = []
for i in range(n):
    a = list(input())
    a.sort()
    if len(ans) > len(a):
        bf = ans
        ans = a
        a = bf
    if i == 0:
        ans = a
    else:
        k = 0
        while k < len(a):
            if k >= len(ans):
                break
            if a[k] < ans[k]:
                del a[k]
            elif a[k] == ans[k]:
                k += 1
            elif a[k] > ans[k]:
                del ans[k]

for i in ans:
    print(i, end="")

Measured memory_bytes: 3064
/**
 *      ABC 62 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 02:00:07
**/
#include <bits/stdc++.h>
using namespace std;

char group(int x){
    if ((x == 1 || x == 3) || (x == 5 || x == 7)){
        return 'a';
    }
    else if ((x == 8 || x == 10) || x == 12){
        return 'a';
    }
    else if ((x == 4 || x == 6) || (x == 9 || x == 11)){
        return 'b';
    }
    else {
        return 'c';
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, y; cin >> x >> y;
    group(x) == group(y) ? cout << "Yes" : cout << "No";
    return 0;
}

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

int main() {
  int l[10];
  int v1, v2;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
	      &l[0], &l[1], &l[2], &l[3], &l[4], 
	      &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF) {

    int sum = 0;
    for(int i = 0; i < 10; i++) {
      sum += l[i];
    }

    double L1 = (double)v1*sum/(v1+v2);

    for(int i = 0; i < 10; i++) {
      L1 -= l[i];
      if(L1 <= 0) {
	cout << i+1 << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*切り上げの計算！*/
int maxtime(int x) {
	return(x + 9) / 10 * 10;

}
int main() {
	int H, W;
	int h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w);
}

Measured memory_bytes: 256
def golden_apple(n, d)
  ans = 0
  pos = d + 1
  while pos <= n
    ans += 1
    pos += 2 * d + 1
  end
  ans += 1 if pos - d <= n
  ans
end

n, d = gets.split.map(&:to_i)
puts golden_apple(n, d)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define turbo cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define ll long long
#define pii pair<int,int>
#define f first
#define pb push_back
#define mp make_pair
#define inf 999999999999999

using namespace std;

ll tab[100005][3];
ll dp[100005][3];

int main(){
    turbo
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++){
      cin >> tab[i][0] >> tab[i][1] >> tab[i][2];
    }
    for(ll i=1;i<=n;i++){
      dp[i][0]=max(dp[i-1][1],dp[i-1][2])+tab[i][0];
      dp[i][1]=max(dp[i-1][0],dp[i-1][2])+tab[i][1];
      dp[i][2]=max(dp[i-1][0],dp[i-1][1])+tab[i][2];
    }
    cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << "\n";
    return 0;
}


Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){
	int N[4];
	bool b[10] = {};
	cin >> N[0] >> N[1] >> N[2] >> N[3];

	for (int i = 0; i < 4; ++i){
		b[N[i]] = true;
	}

	if (b[1] && b[9] && b[7] && b[4])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

d = dict()
m = 0
for i in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1
    if m < d[s]:
        m = d[s]

result = list()
for x in d:
    if d[x] == m:
        result.append(x)

result.sort()
for x in result:
    print(x)

Measured memory_bytes: 32100
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        N: usize,
        A: usize,
        B: usize,
    }
    println!("{}", (N / (A+B)) * A + min(A, N % (A + B)));
}


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

int main()
{
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;
	if (s[k-1]=='A')
	s[k-1]='a';
	if (s[k-1]=='B')
	s[k-1]='b';
	if (s[k-1]=='C')
	s[k-1]='c';
	cout << s;
}


Measured memory_bytes: 256
#include <stdio.h>

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

  scanf("%d %d",&a,&b);

  if (1 <= a,b <= 1000000000){
    x=a/b;
    y=a%b;
    double f;
    f=1.0*a/b;
    printf("%d %d %f\n",x,y,f);
  }
  return 0;
}

Measured memory_bytes: 1064
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    int[] perm;
    boolean[] used;
    int[] p;
    int[] q;
    int count = 0;
    int pcount = -1;
    int qcount = -1;

    private void run() {
        int n = sc.nextInt();
        p = new int[n];
        q = new int[n];

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

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

        perm = new int[n];
        used = new boolean[n];
        permutation(0,n);
    }
    void permutation(int pos, int n) {
        if (pos == n) {
            count++;
            if (Arrays.equals(p, perm)) pcount = count;
            if (Arrays.equals(q, perm)) qcount = count;

            if (pcount > 0 && qcount > 0) {
                System.out.println(Math.abs(pcount - qcount));
                System.exit(0);
            }

            return;
        }

        for (int i = 0; i < n; i++) {
            if (!used[i]) {
                perm[pos] = i+1;
                used[i] = true;
                permutation(pos+1, n);
                used[i] = false;
            }
        }
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




vector<pair<ll, int> > prime_factorize(ll n) { // n <= 10^12も考慮
    ll tmp = n;
    vector<pair<ll, int> > v;
    for (ll i = 2; i * i <= n; ++i) {
        ll cnt = 0;
        while (tmp % i == 0) {
            tmp /= i;
            cnt++;
        }
        if (cnt) v.eb(i, cnt);
    }
    if (tmp != 1) v.eb(tmp, 1);
    return v;
}


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

    
    ll a, b;
    cin >> a >> b;
    ll tmp = gcd(a, b);
    
    auto v = prime_factorize(tmp);
    cout << sz(v) + 1 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(all(v));
    if(v[0] == 5 && v[1] == 5 && v[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+6;
const int MOD=998244353;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
struct node{
    int l,r;
};
vector<int> vec[600];
int main(void){

    int n,m,q;
    sf(n);sf(m);sf(q);
    for(int i=1;i<=m;i++){
        int l,r;
        sf(l);sf(r);
        vec[l].pb(r);
    }
    for(int i=1;i<=n;i++){
        if(!(int)vec[i].size()) continue;
        sort(vec[i].begin(),vec[i].end());
    }
    while(q--){
        int l,r;
        sf(l);sf(r);
        int ans=0;
        for(int i=l;i<=r;i++){
            ans+=upper_bound(vec[i].begin(),vec[i].end(),r)-lower_bound(vec[i].begin(),vec[i].end(),l);
        }
        printf("%d\n",ans);
    }


    return 0;
}


Measured memory_bytes: 2176
def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m + 1):
        for index in range(n - m + 1):
            if b == [i[index:index + m] for i in a[row:row + m]]:
                print('Yes')
                return

    print('No')

    # for row in range(n - m + 1):
    #    current_index = 0
    #    for index in range(n - m + 1):
    #        current_index = a[row].find(b[0], index)
    #        if current_index < 0:
    #            break
    #
    #        for i in range(m):
    #            if a[row + i].find(b[i], current_index) != current_index:
    #                break
    #        else:
    #            print('Yes')
    #            return
    #
    # print('No')


if __name__ == "__main__":

    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 100005
using namespace std;

int main(void)
{
    string str;
    cin >> str;
    if(str == "RRR")
        printf("%d", 3);
    else if(str == "RRS")
        printf("%d", 2);
    else if(str == "RSR")
        printf("%d", 1);
    else if(str == "SRR")
        printf("%d", 2);
    else if(str == "SSR")
        printf("%d", 1);
    else if(str == "RSS")
        printf("%d", 1);
    else if(str == "SRS")
        printf("%d", 1);
    else if(str == "SSS")
        printf("%d", 0);
    //system("pause");
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#define fst first
#define snd second

int main()
{

    int h, w, cx, cy, gx, gy;
    int gidx = INT32_MAX;
    cin >> h >> w >> cy >> cx >> gy >> gx;
    cy--;
    cx--;
    gy--;
    gx--;
    vector<string> g(h);
    rep(y, h) cin >> g[y];
    vvint hops = vvint(h, vint(w, INT32_MAX));

    deque<P> q;
    q.push_back(P(cy, cx));
    hops[cy][cx] = 0;

    int dir[] = {1, 0, -1, 0, 1};
    while (q.size())
    {
        P p = q.front();
        q.pop_front();

        int y = p.fst;
        int x = p.snd;

        rep(i, 4)
        {
            int ny = y + dir[i];
            int nx = x + dir[i + 1];
            if (ny >= h || nx >= w || ny < 0 || nx < 0)
                continue;
            if (g[ny][nx] == '#')
                continue;
            if (hops[ny][nx] > hops[y][x])
            {
                hops[ny][nx] = hops[y][x];
                q.push_front(P(ny, nx));
            }
        }

        for (int dy = -2; dy <= 2; dy++)
            for (int dx = -2; dx <= 2; dx++)
            {
                int ny = p.fst + dy,
                    nx = p.snd + dx;
                if (ny >= h || ny < 0 || nx >= w || nx < 0)
                    continue;
                if (g[ny][nx] == '#')
                    continue;
                if (hops[ny][nx] > hops[y][x] + 1)
                {
                    hops[ny][nx] = hops[y][x] + 1;
                    q.push_back(P(ny, nx));
                }
            }
    }

    int ans = hops[gy][gx];
    if (ans == INT32_MAX)
    {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9480
#include <iostream>
#include <algorithm>

constexpr int max_r()
{
    return static_cast<int>(1e+9);
}

constexpr int max_size()
{
    return static_cast<int>(2e+5);
}

constexpr int min_value()
{
    return 1 - max_r();
}

/**
@brief simple solution.
@detail O(n^2)
*/
int solve0(const int n, int const* r)
{
    int ret = min_value();
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            ret = std::max(ret, r[i] - r[j]);
        }
    }
    return ret;
}

/**
@brief hold min value.
@detail O(n)
*/
int solve1(const int n, int const* r)
{
    int ret = min_value();
    int temp_min = r[0];
    for (int i = 1; i < n; ++i) {
        ret = std::max(ret, r[i] - temp_min);
        temp_min = std::min(r[i], temp_min);
    }
    return ret;
}

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

    constexpr int N = max_size();
    int r[N];
    for (int i = 0; i < n; ++i) {
        std::cin >> r[i];
    }

    const int ret = solve1(n, r);
    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 3864
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int k = stdIn.nextInt();
    
    if(k == 1){
      System.out.println(0);
    }else{
      System.out.println(n-k);
    }
  }
}


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

const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> X(N);
    vector<ll> Y(N);
    vector<ll> Z(N);

    X[0] = 1;
    Z[0] = 0;
    ll cnt = 1;
    for (int n=1; n<N; n++){
        cnt = cnt * 8 % MOD;
        X[n] = 9 * X[n-1] % MOD;
        X[n] = (X[n] + cnt) % MOD;
        
        Z[n] = 10 * Z[n-1] % MOD;
        ll tmp = (2 * X[n-1]) % MOD;
        Z[n] = (Z[n] + tmp) % MOD;
    }

    cout << Z[N-1] << endl;
    return 0;
}

Measured memory_bytes: 26648