akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()

def comb(N,x):
    ret = 1
    for i in range(N-x+1,N+1):
        ret *= i
        ret %= mod

    for i in range(1, x+1):
        ret *= pow(i,mod-2,mod)
        ret %= mod

    return ret%mod

class Combination:
    def __init__(self,N):
        self.fac = [1]*(N+1)
        for i in range(1,N+1):
            self.fac[i] = (self.fac[i-1]*i)%mod
        self.invmod = [1]*(N+1)
        self.invmod[N] = pow(self.fac[N],mod-2,mod)
        for i in range(N,0,-1):
            self.invmod[i-1] = (self.invmod[i]*i)%mod

    def calc(self,n,k):#nCk
        return self.fac[n]*self.invmod[k]%mod *self.invmod[n-k] %mod




if N <= K:
    ans = comb(N*2-1, N)
    print(ans)
else:
    C = Combination(200000+3)
    ans = 0
    for z in range(K+1):
        r = N - z
        m = N - r
        ans += C.calc(N, z) * C.calc(r+m-1, m)
        ans %= mod

    print(ans)


Measured memory_bytes: 45036
import math

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

def gcd(x,y):
    return x if y == 0 else gcd(y,x%y)

def lcm(x,y):
    return (x*y)//gcd(x,y)

now_lcm = a[0]
for i in range(n):
    now_lcm = lcm(now_lcm,a[i])

ans = 0
for e in a:
    ans += now_lcm//e

print(int(ans%(10**9+7)))


Measured memory_bytes: 4084
/*
   THE DARK NIGHT RISES
I LOVE YOU 72 AND WILL FOREVER DO SO
Patience, Persistence, Perseverance, Passion, Purpose
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int N = 2e5 + 20 ;
#define F first
#define S second
# define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mk make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x)       (int)x.size()
const long long int mod=1e9 + 7;
const long double EPS=1e-12;
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )
 
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 

int solve()
{
  ll n ;
  cin >> n ;
  if(n%2)return cout << 0 , 0 ;
  ll st = 5;
  ll cnt = 1 ;
  ll ans = 0 ;
  while(n)
  {
  		ll val = n/st ;
  		if(val%2)val--;
  		ans += val/2 ;
  		n/=st ;
  }
  cout << ans ;

}
int main()
{
	fast;
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
 
	return 0;
}
// Patience, Persistence, Perseverance, Passion, Purpose
// I LOVE YOU 72 AND WILL FOREVER DO SO.

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = Integer.valueOf(scn.nextLine()).intValue();
		String line2[] = scn.nextLine().split(" ");
		int H[] = new int[N];
		for(int i = 0;i < N;i++) {
			H[i] = Integer.valueOf(line2[i]).intValue();
		}

		// 一番西は絶対海が見えるから
		int countOceanViewHotels = 1;
		// 一番でかいホテルを記録していく
		int biggestHotelsHigh = H[0];
		for(int i = 1;i < N;i++) {
			if(H[i] >= biggestHotelsHigh) {
				countOceanViewHotels++;
				biggestHotelsHigh = H[i];
			}
		}

		System.out.println(countOceanViewHotels);
	}
}


Measured memory_bytes: 21588
#include<stdio.h>

int main()
{
        int A, B, C;
        scanf("%d %d %d", &A, &B, &C);
        if(A==5 && B==5 && C==7){
            printf("YES");
        }
        else if(A==5 && B==7 && C==5){
            printf("YES");
        }
        else if(A==7 && B==5 && C==5){
            printf("YES");
        }
        else{
            printf("NO");
        }

        return 0;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,string> P;

int main(){
  int N;
  cin >> N;
  while(N--){
    double x1,y1,x2,y2,x3,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a = 2*(x2-x1),b = 2*(y2-y1),c = x1*x1 - x2*x2 + y1*y1 - y2*y2;
    double d = 2*(x3-x1),e = 2*(y3-y1),f = x1*x1 - x3*x3 + y1*y1 - y3*y3;
    double x = (b*f - e*c)/(a*e - d*b);
    double y = (c*d - f*a)/(a*e - d*b);
    double r = sqrt((x-x1)*(x-x1) + (y-y1)*(y-y1));
    printf("%.3f %.3f %.3f\n",x,y,r);
  }
}
  

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

int main(){
	char a,b; cin>>a>>b;
	if(a=='H'){
		if(b=='H') cout<<'H'<<endl;
		else cout<<"D"<<endl;
	}else if(a=='D'){
		if(b=='H') cout<<'D'<<endl;
		else cout<<"H"<<endl;
	}		
}

Measured memory_bytes: 3552
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define reset(x) memset(x,0,sizeof x)
#define sz(x) x.size()
#define pb push_back
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;


int main() {

    FASTIO
    string s;cin >> s;

    ll ans = 0,b=0;
    FOR(i,0,sz(s)){
        if(s[i] == 'B')
            b++;
        else
            ans += b;
    }
    cout << ans;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++) {
			a[i] = sc.nextInt();
			if(a[i] % 2 == 0) {
				if(a[i] % 3 == 0 || a[i] % 5 == 0) {

				}else {
					System.out.println("DENIED");
					return;
				}
			}
		}
		System.out.println("APPROVED");

	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll d, n;
	cin >> d >> n;
	ll ans = pow(100, d);
	if (n == 100) cout << ans * (n + 1) << endl;
	else cout << ans * n << endl;
}


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

int main(){
  int a,b,c,d,cou;
  while(1){
    cin >>a >>b;
    if(b>a)swap(a,b);
    if(a==0&&b==0)break;
    cou=1;
    while(1){
      if(a%b==0)break;
      d=a%b;
      a=b;
      b=d;
      cou++;
    }
    cout <<b<<" "<<cou<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  ll ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
function calc_mp(depth,N,ABC,abc,ls){
  if(depth==N){
    if(Math.min(...abc)>0){
      const mp = Math.abs(ABC[0]-abc[0])+Math.abs(ABC[1]-abc[1])+Math.abs(ABC[2]-abc[2]) -30;
      return mp;
    }else{
      const m = 1000*1000;
      return m*m*m;
    }
  }

  const ret0 = calc_mp(depth+1, N, ABC, abc, ls);
  var ret1 = calc_mp(depth+1, N, ABC, [abc[0]+ls[depth], abc[1], abc[2]], ls)+10;
  var ret2 = calc_mp(depth+1, N, ABC, [abc[0], abc[1]+ls[depth], abc[2]], ls)+10;
  var ret3 = calc_mp(depth+1, N, ABC, [abc[0], abc[1], abc[2]+ls[depth]], ls)+10;

  return Math.min(ret0, ret1, ret2, ret3);
}

function main(input){
  const lines = input.split('\n');
  const N = lines[0].split(' ').map(x => parseInt(x))[0];
  const A = lines[0].split(' ').map(x => parseInt(x))[1];
  const B = lines[0].split(' ').map(x => parseInt(x))[2];
  const C = lines[0].split(' ').map(x => parseInt(x))[3];
  var Ls = lines.map(x => parseInt(x));
  Ls.shift();


  const result = calc_mp(0,N,[A,B,C],[0,0,0],Ls);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10276
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

float Abs(float n) {
    if (n < 0) {
        return -n;
    } else {
        return n;
    }
}

int main() {
    int n, T;
    cin >> n >> T;
    int cost = 10000;
    for (int i = 0; i < n; i++) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            if (c < cost) {
                cost = c;
            }
        }
    }

    if (cost == 10000) {
        cout << "TLE" << endl;
    } else {
        cout << cost << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N, M;

    cin >> N >> M;

    ll A[N];
    ll sum = 0;
    ll pass = 0;

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

    for(ll i = 0; i < N; i++){
        if(A[i] > sum / (4 * M) || (A[i] == sum / (4 * M) && sum % (4 * M) == 0)){
            pass++;
        }
        if(pass >= M){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<math.h>


int main() {
  
  long long int a,b,c;
  
  
  
  scanf("%lld %lld %lld\n",&a,&b,&c);
 
 if(4*a*b<(c-a-b)*(c-a-b)&&(c-a-b)>0){
 	printf("Yes\n");
 }else{
 	printf("No\n");
 }
  
  return 0;
  
}

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

int main(){
  int n,a,b,ans[3]={0,0,0};
  cin>>n >>a >>b;
  for(int i=0;i<n;i++){
    int c; cin>>c;
    if(c<=a){
      ans[0]++;
    }else if(c<=b){
      ans[1]++;
    }else{
      ans[2]++;
    }
  }
  
  cout<<min({ans[0],ans[1],ans[2]})<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a0 = int(input())
a1 = int(input())
max_profit = a1 - a0
min_i = min(a1, a0)
for i in range(n-2):
    c=int(input())
    if c - min_i > max_profit:
        max_profit = c - min_i
    min_i = min(min_i, c)
print(max_profit)


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

using namespace std;

struct sPlant {
	string name;
	double sale;
};

bool Greater(const sPlant& lPlant, const sPlant& rPlant) {
	if( lPlant.sale != rPlant.sale) return lPlant.sale > rPlant.sale;
	return lPlant.name < rPlant.name;
}

int main()
{
	int n;
	while(cin >> n, n) {
		sPlant plants[51];
		for(int i = 0; i < n; ++i) {
			string name;
			int cost, a, b, c, d, e, num, price, rep;
			int plus, t;
			cin >> name >> cost >> a >> b >> c >> d >> e >> num >> price >> rep;
			t = a + b + c + (d + e) * rep;
			plus = price * num * rep - cost;
			plants[i].name = name;
			plants[i].sale = (double)plus / t;
		}
		sort(plants, plants + n, Greater);
		for(int i = 0; i < n; i++) {
			cout << plants[i].name << endl;
		}
		cout << '#' << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const unsigned int BIT_ARRAY_SIZE = 500005;
ll BIT_ARRAY[BIT_ARRAY_SIZE];
int l = BIT_ARRAY_SIZE;

void BIT_update(int i, ll val) {
  while (i <= l) {
    BIT_ARRAY[i] += val;
    i = i + (i & (-i));
  }
}

ll BIT_query(int i) {
  ll s = 0;
  while (i > 0) {
    s += BIT_ARRAY[i];
    i = i - (i & (-i));
  }
  return s;
}
int lastpos[BIT_ARRAY_SIZE * 10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, x, y, q;
  cin >> n >> q;
  vector<int> v(n + 1);
  for (int i = 1; i <= n; i++)
    cin >> v[i];
  vector<pair<pair<int, int>, int>> Q;
  vector<int> ans(q + 1);
  for (int i = 1; i <= q; i++) {
    cin >> x >> y;
    Q.push_back(make_pair(make_pair(y, x), i));
  }
  sort(Q.begin(), Q.end());
  int pos = 1;
  for (int i = 0; i < q; i++) {
    while (pos <= Q[i].first.first) {
      if (lastpos[v[pos]] != 0)
        BIT_update(lastpos[v[pos]], -1);
      BIT_update(pos, 1);
      lastpos[v[pos]] = pos;
      pos++;
    }
    ans[Q[i].second] =
        BIT_query(Q[i].first.first) - BIT_query(Q[i].first.second - 1);
  }
  for (int i = 1; i <= q; i++)
    cout << ans[i] << "\n";
}

Measured memory_bytes: 19548
use std::io;
use std::cmp;
use std::collections::HashSet;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    let n = read_t_in_line::<usize>()[0];
    let mut v = (0..n).map(|_| read_t_in_line::<i32>()[0] ).collect::<Vec<i32>>();

    v.sort();

    let mut sum = 0;
    for i in 0..n-1 {
        sum += v[i];
        // println!("{}", v[i])
    }
    sum += v[n-1] / 2;

    println!("{}", sum);
}


Measured memory_bytes: 4476
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define MOD (long long int)(1e9+7)
#define ll long long
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()


int main(void) {
	vector<int> vec{ 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 K;
	cin >> K;
	cout << vec.at(K - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int ok[11][1000];
int bit[1100][1000];

int bitcount(int a){
	int i;
	for(i=0;a;i++){
		a&=a-1;
	}
	return i;
}

int f(int a,int b){
	int i;
//cout<<a<<" "<<b<<endl;
	if(b<0)return 0;
	if(bit[a][b]>=0)return bit[a][b];
	if(a==0)return 0;
	int res=0;
	int bits=bitcount(a);
	for(i=0;i<10;i++){
		if(a&1<<i){
			res+=f(a^1<<i,b-bits*i);
		}
	}
	bit[a][b]=res;
	return res;
}

int main() {
	int i,j;
	memset(bit,-1,sizeof(bit));
	bit[0][0]=1;
	for(i=0;i<1<<10;i++){
		for(j=0;j<1000;j++){
			f(i,j);
			ok[bitcount(i)][j]+=bit[i][j];
		}
	}
//cout<<"hoge"<<endl;
/*	for(i=0;i<10;i++){
		for(j=0;j<100;j++){
			cout<<ok[i][j]<<" ";
		}
		cout<<endl;
	}
*/	int n,s;
	while(cin>>n>>s){
		cout<<ok[n][s]<<endl;
	}
	return 0;
}

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

using namespace std;

typedef unsigned long long ULL;

void process();
int main(){
    int i;
    int data;

    for(i=0;i<5;i++){
        cin >> data;
        if( data == 0){
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}
void process(){

}

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

const int mxn = 1e5 + 5;

int n, color[mxn];
bool vis[mxn];
vector<pair<int, int>> adj[mxn];

void dfs(int u, int c) {
    vis[u] = true;
    color[u] = c;
    for (auto v : adj[u]) {
        if (vis[v.first] == false) {
            dfs(v.first, c ^ (v.second % 2));
        }
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
    dfs(1, 0);
    for (int i = 1; i <= n; i++) {
        cout << color[i] << endl;
    }
}



Measured memory_bytes: 11568
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7;
vector <int> tree[N];

int dfs(int u) {
    vector <int> ans;
    for (int v : tree[u]) {
        ans.app(dfs(v));
    }
    int mx = tree[u].size();
    sort(all(ans));
    reverse(all(ans));
    for (int i = 0; i < ans.size(); ++i)
        mx = max(mx, ans[i] + i + 1);
    #ifdef HOME
    cout << u << ' ' << mx << endl;
    #endif
    return mx;
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        int p;
        cin >> p;
        tree[p].app(i);
    }   
    cout << dfs(1) << endl;
}

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

#define llt long long int
#define modm 1000000007

int main(){
	int a,ans=0;
	string s1,s2;
	cin>>a;
	ans=a+(a*a)+(a*a*a);
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3620
def dfs(i, f):
    
    if i==3:
        if(eval(f)==7):
            print(f + '=7')
            exit()
    
    else:
        # operand がプラス
        dfs( i + 1, f + '+' + s[i+1] ) 
    
        # operand がマイナス
        dfs( i + 1, f + '-' + s[i+1] ) 
        
s = list(input())
dfs(0, s[0])


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int n, m;
bool img1[51][51] = {}, img2[51][51] = {};

bool solve(){
	for(int sx = 0;sx < n;sx++){
		for(int sy = 0;sy < n;sy++){
			bool flag = true;
			for(int px = 0;px < m;px++){
				for(int py = 0;py < m;py++){
					if(sx + px >= n || sy + py >= n) {
						flag = false;
						continue;
					}
					if(img1[sx+px][sy+py] != img2[px][py]) flag = false;
				}
			}
			if(flag) return true;
		}
	}
	return false;
}

int main() {
	cin >> n >> m;
	string str;
	for(int i = 0;i < n;i++){
		cin >> str;
		for(int j = 0;j < str.size();j++){
			if(str[j] == '#') img1[j][i] = true;
			else img1[j][i] = false;
		}
	}

	for(int i = 0;i < m;i++){
		cin >> str;
		for(int j = 0;j < str.size();j++){
			if(str[j] == '#') img2[j][i] = true;
			else img2[j][i] = false;
		}
	}

	if(solve()) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i,m,n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  REP(i,3) {
    if(s[i] == '1') {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int k,n,arr[33] = {0, 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(){
	cin>>k;
	cout<<arr[k]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> s(n);
	vector<int> t(m);

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

	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	vector<vector<ll>> dp(n + 1, vector<ll>(m + 1));


	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {


			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD_CONST;
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = (dp[i][j] + 1) % MOD_CONST;
			}
			else {
				dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] + MOD_CONST) % MOD_CONST;

			}
		}
	}
	cout << (dp[n][m] + 1 + MOD_CONST) % MOD_CONST << endl;
}




Measured memory_bytes: 31616
// Marcin Knapik
#include<bits/stdc++.h>
using namespace std;
#define ld long double

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	cout << setprecision(10) << fixed << 1.0 / (ld)n * (ld)(n - (n/2)); 
}

Measured memory_bytes: 256
MOD = 10**9 + 7
n, oddness = [int(item) for item in input().split()]
# Oddness must be even
if oddness % 2 ==  1:
    print(0)
    exit()
oddness //= 2
max_oddness = n*n + n
max_pending = n + 1

dp = [[[0] * (max_oddness) for _ in range(max_pending)] for _ in range(n)]
oddness_itr = [item for item in range(n*n)]
for i in range(n):
    if i == 0:
        dp[0][0][0] = 1
        dp[0][1][1] = 1
        continue
    for j in range(i+1):
        for k in oddness_itr:
            # Connect in line
            # Oddness increase by num of pending item
            dp[i][j][k+j] += dp[i-1][j][k]
            # Choose 1 from pending
            dp[i][j][k+j] += dp[i-1][j][k] * j*2 
            dp[i][j][k+j] %= MOD
            # Choose 2 from pending
            if j > 0:
                dp[i][j-1][k+j-1] += dp[i-1][j][k] * j*j
                dp[i][j-1][k+j-1] %= MOD 
            # Do nothing 
            dp[i][j+1][k+j+1] += dp[i-1][j][k] 
            dp[i][j+1][k+j+1] %= MOD 

print(dp[n-1][0][oddness])

Measured memory_bytes: 93660
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,cnt=0; cin>>n;
    vector<ll> l(n);    
    rep(i,n) cin>>l[i];
    rep(i,n){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]){
                    if(l[i]+l[k]>l[j] && l[k]+l[j]>l[i] && l[i]+l[j]>l[k]) cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int Q;
int A,B,C,D;

string hoge(int A,int B,int C,int D) {
	int i;
	int L=(max(A,B)+min(A,B))/(min(A,B)+1);
	
	int na=0;
	for(i=30;i>=0;i--) {
		int nac=na+(1<<i);
		int nb=max(0,(nac-1)/L);
		if(nac>A || nb>B) continue;
		int ma=A-nac;
		int mb=B-nb;
		
		if(mb>1LL*(ma+1)*L) continue;
		na+=1<<i;
	}
	
	
	int p=na+max(0,(na-1)/L);
	string R;
	for(i=C;i<=D;i++) {
		if(i<p) R+='A'+(i%(L+1)==L);
		else R+='B'-((A+B-1-i)%(L+1)==L);
	}
	//cout<<p<<" "<<A<<" "<<B<<" ";
	return R;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>Q;
	//Q=400;
	FOR(i,Q) {
		cin>>A>>B>>C>>D;
		/*
		A=1+i/20;
		B=1+i%20;
		C=1;
		D=A+B;
		*/
		cout<<hoge(A,B,C-1,D-1)<<endl;
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 55
#define ll long long
char s[N][N];
ll dp[N][N][N];
ll getans(int l, int r, int m)
{
	if (dp[l][r][m] != -1) return dp[l][r][m];
	if (l == r) return dp[l][r][m] = 1;
	if (l == m || r == m) return dp[l][r][m] = 0;
	ll &res = dp[l][r][m];
	res = 0;
	for (int i = l; i <= m - 1; i++)
		for (int j = m + 1; j <= r; j++)
		{
			if (s[i][j] == '0') continue;
			for (int s = i; s <= m - 1; s++)
				for (int t = m + 1; t <= j; t++)
					res += getans(l, s, i) * getans(s + 1, t - 1, m) * getans(t, r, j);
		}
	return res;
}
int n;
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n * 2; i++)
		scanf("%s", s[i] + 1);
	memset(dp, -1, sizeof(dp));
	ll ans = 0;
	for (int i = 2; i <= n * 2; i++)
		if (s[1][i] == '1') ans += getans(2, n * 2, i);
	printf("%lld\n", ans);
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

	if ((b - a) == (c - b)) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 504
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

A, B = LI()
if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')


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

int main(){
  int N , A[3][3] , B[10];
  bool a[3][3]= {false};//定義づけ
  for(int i =0;i<3;i++){
    for(int j =0;j<3;j++){
      cin >> A[i][j] ;
    }
  }
  cin >> N ;
  for(int i =0;i<N;i++) cin >> B[i];//入力終了
  
  for(int i =0;i<N;i++){
    for(int j =0;j<3;j++){
      for(int k =0;k<3;k++){
        if(B[i]==A[j][k]) a[j][k] = true;
      }
    }  
  }
    bool ans = false;//フラグ
  
  if(a[0][0]&&a[0][1]&&a[0][2]) ans = true;
  if(a[1][0]&&a[1][1]&&a[1][2]) ans = true;
  if(a[2][0]&&a[2][1]&&a[2][2]) ans = true;
  if(a[0][0]&&a[1][0]&&a[2][0]) ans = true;
  if(a[0][1]&&a[1][1]&&a[2][1]) ans = true;
  if(a[0][2]&&a[1][2]&&a[2][2]) ans = true;
  if(a[0][0]&&a[1][1]&&a[2][2]) ans = true; 
  if(a[0][2]&&a[1][1]&&a[2][0]) ans = true;
    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
  }



Measured memory_bytes: 3632
import java.io.*;

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		sb.append(br.readLine());
		sb.append(sb.toString());
		String p = br.readLine();
		if(sb.indexOf(p)==-1)	System.out.println("No");
		else		System.out.println("Yes");
	}
}

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

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i  < s.size(); i++){
        for(int j = 0 ; j < s.size(); j++){
            if(s[i] == s[j]) cnt++;
        }
        if((cnt % 2) != 0){
            cout << "No"<<endl;;
            return 0;
        }
        cnt = 0;
    }
    cout << "Yes"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>

using namespace std;

using ll = long long;

ll n, x;

ll a[2000];
ll mina[2000];

int main()
{
	scanf("%lld %lld", &n, &x);
	for (ll i = 0; i < n; ++i)
	{
		scanf("%lld", a + i);
		mina[i] = a[i];
	}
	ll ans = 12345678901234567;
	for (ll diff = 0; diff < n; ++diff)
	{
		ll sum = diff * x;
		for (ll i = 0; i < n; ++i)
		{
			mina[i] = min(mina[i], a[(i - diff) < 0 ? i - diff + n : i - diff]);
			sum += mina[i];
		}
		ans = min(sum, ans);
	}
	printf("%lld\n", ans);
	return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

const int MAX = 2e5+10;

string T;

int dp[MAX][2];

string solve() {
    if (T[0] == 'D') {
        dp[0][0] = 1;
        dp[0][1] = -100;
    } else if (T[0] == 'P') {
        dp[0][0] = 0;
        dp[0][1] = 0;
    } else {
        dp[0][0] = 1;
        dp[0][1] = 0;
    }
    REP (i, T.size()-1) {
        if (T[i+1] == 'D') {
            dp[i+1][0] = max(dp[i][0]+1, dp[i][1]+2);
            dp[i+1][1] = -100;
        } else if (T[i+1] == 'P') {
            dp[i+1][0] = 0;
            dp[i+1][1] = max(dp[i][0], dp[i][1]);
        } else {
            dp[i+1][0] = max(dp[i][0]+1, dp[i][1]+2);
            dp[i+1][1] = max(dp[i][0], dp[i][1]);
        }
    }
    string ret;
    if (T[T.size()-1] == 'P') ret = "P";
    else ret = "D";

    REPR (i, T.size()-1) {
        if (T[i] != '?') {
            ret += T[i];
            continue;
        }
        if (ret[ret.size()-1] == 'D') {
            if (dp[i][0] > dp[i][1]+1) ret += 'D';
            else ret += 'P';
        } else {
            if (dp[i][0] > dp[i][1]) ret += 'D';
            else ret += 'P';
        }
    }
    reverse(ALL(ret));
    return ret;
}

int main() {
    cout << fixed << setprecision(15);
    cin >> T;
    cout << solve() << endl;
}

Measured memory_bytes: 5428
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include<cstring>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;


//119 D

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int main(void) {
	ll n,k;
	cin >> n >> k;
	const ll MAX_DIGIT = 41;
	vector<ll> a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	ll dp[MAX_DIGIT+1][2];
	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	rep(i, 0, MAX_DIGIT) {
		ll mask = (ll)1 << (MAX_DIGIT - i - 1);

		int num = 0;
		rep(j, 0, n) if (a[j] & mask)	++num;

		ll cost0 = mask * num;
		ll cost1 = mask * (n - num);

		if (dp[i][1] != -1) {
			chmax(dp[i+1][1], dp[i][1] + max(cost0, cost1));
		}

		if (dp[i][0] != -1) {
			if (k & mask) {
				chmax(dp[i + 1][1], dp[i][0] + cost0);		
 			}

			if (k & mask) chmax(dp[i + 1][0], dp[i][0] + cost1);
			else chmax(dp[i + 1][0], dp[i][0] + cost0);
		}
	}

	cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
	
	
}

Measured memory_bytes: 1024
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    x,v=map(int,input().split())
    weight.append(x)
    value.append(v)
    
dp=[[0 for i in range(w+1)]for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        
        if j+weight[i]<=w :
            dp[i+1][j+weight[i]]=max(dp[i+1][j+weight[i]],dp[i][j]+value[i])
        
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])

print(dp[-1][-1])

Measured memory_bytes: 171656
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin >> n;
  double ans = 0;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    ans += 1. / static_cast<double>(x);
  }
  cout << setprecision(10) << 1. / ans;
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int h, w, i;
  string str;
  vector<string> lines;

  cin >> h >> w;

  for(i = 0; i < h; i++) {
    cin >> str;
    lines.push_back(str);
    lines.push_back(str);
  }

  vector<string>::iterator it;
  for (it = lines.begin(); it != lines.end(); it++){
    cout << *it << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int x;
  scanf("%d",&x);
  if (x >= 400 && x < 600)
    printf("8");
  else if (x < 800)
    printf("7");
  else if (x < 1000)
    printf("6");
  else if (x < 1200)
    printf("5");
  else if (x < 1400)
    printf("4");
  else if (x < 1600)
    printf("3");
  else if (x < 1800)
    printf("2");
  else
    printf("1");
}

Measured memory_bytes: 1648
#include<stdio.h>
 
int sum(int m,int n)
{
    int a;
    a = (m+n-1) * (m+n) / 2 - (m-1) * m / 2 ;
    return a ;
}

int main()
{
  int i,j,a;
  int n[1001]={0};
  for(i=2;i<45;i++){
    for(j=1;;j++){
      if(sum(j,i)>1001){
    break;
      }
 n[sum(j,i)]++;
    }
  }

  while(scanf("%d",&a),a){
      printf("%d\n",n[a]);
  }
  return 0;
}

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

int main() {
  int a,b;
  int c=0;
  cin>>a>>b;
  vector<int> d(b);
  for (int i=0;i<b;i++){
    cin>>d.at(i);
    c+=d.at(i);
  }
  if(c<a){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

ll LCSubstr(string str, string tar){
    ll res = 0;
    ll Ns = str.length(), Nt = tar.length();
    ll s=0, t=0;
    while(s < Ns){
        if(str[s]!= tar[0]){
            t = ++s;
            continue;
        }
        while( t - s <= Nt && t < Ns){
            if(str[t] == tar[t - s])
                t++;
            else
                break;
        }
        //* Now [s, t) is good
        res = max(res, t - s);
        s = t;
    }
    return res;
}

void solve(long long N, std::string S){
    ll ans = 0;
    vector<vll> dp(N, vll(N, 0));
    dp[N-1][N-1] = 1;
    for(ll i = N -1; i >= 0; i--){
        for(ll j = N-1; j >= 0; j--){
            if(S[i] != S[j]) continue;
            if(i== N-1 && j == N-1) continue;
            if(i < N-1 && j == N-1){
                dp[i][j] = 1;
            } else if(j < N-1 && i == N-1){
                dp[i][j] = 1;
            } else{
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }
    REP(i, N){
        REP(j, N){
            ans = max(ans, min(dp[i][j], abs(i-j)));
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int R, G, B, N, ans = 0, c;
	
	cin >> R >> G >> B >> N;
	
	for(int i = 0; i <= (int)N/R+1; i++){
		for(int j = 0; j <= (int)N/G+1; j++){
			if(i*R + j*G <=N && (N - i*R - j*G) % B == 0){
				 ++ans;
				 //cout << i << " " << j << " " << (N - i*R + j*G) /B << endl;
			 }
		}
	}
	cout << ans;

}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  int a,b;cin>>a>>b;
  string ans=(max(a,b)>8?":(":"Yay!");
  cout << ans << endl;
}


Measured memory_bytes: 256
def resolve():
    n, q = map(int, input().split())

    to = [[] for _ in range(n)]

    for _ in range(n-1):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)

    ns = [0 for _ in range(n)]
    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        ns[p] += x

    visited = [False] * n
    stack = [0]
    while len(stack) > 0:
        num = stack.pop()
        visited[num] = True
        for i in to[num]:
            if visited[i]:
                continue
            ns[i] += ns[num]
            stack.append(i)
    print(*ns)
resolve()

Measured memory_bytes: 107084
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9+1
#define int long long int


struct item
{
    int wt;
    int val;
};

int solve(vector<item> ar,int n,int W)
{
    int maxVal=n*1000;
    int dp[n+1][maxVal+1];
    for(int val=0;val<=maxVal;val++)
    {
        dp[1][val]=inf;
    }
    dp[1][0]=0;
    dp[1][ar[1].val]=ar[1].wt;
    for(int i=2;i<=n;i++)
    {
        for(int v=0;v<=maxVal;v++)
        {
            dp[i][v]=dp[i-1][v];
            if(ar[i].val>v)
                continue;
            dp[i][v]=min(dp[i][v],ar[i].wt+dp[i-1][v-ar[i].val]);
        }
    }
    int ans=0;
    for(int x=0;x<=maxVal;x++)
    {
        if(dp[n][x]<=W)
            ans=x;
    }
    return ans;
}

int32_t main()
{
    int n,w;
    cin>>n>>w;
    vector<item>ar(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i].wt>>ar[i].val;
    }
    cout<<solve(ar,n,w);
}



Measured memory_bytes: 81752
function Main(input) {
  var sum = 0;
  for (let i = 1; i <= input; i++){
    if (i % 3 !== 0 && i % 5 !== 0){
      sum += i;
    }
  }
  console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 35076
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple

void func()
{
 ll n,k;
 cin>>n>>k;
 ll dp[n],h[n];
 f(i,0,n)  cin>>h[i],dp[i]=infl;
 dp[0]=0;
 f(i,0,n)
 {
   /*if(i+1<n)
   {
     dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
   }
   if(i+2<n)
    {
     dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
   }*/
  f(j,1,k+1) if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
 }
 cout<<dp[n-1]<<endl;
}
 
int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    
    ll q=1;
    //cin>>q;
    while(q)
    {
      func();
      q--;
    }
 
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ref(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef pair<int,int> P;

int a,b,d;


int main()
{
    cin>>a>>b>>d;
    int f=b/d-(a-1)/d;
    cout<<f;
    return 0;

}


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

int main() {
  int L,R; cin>>L>>R;
  int l = L-(L/2019)*2019;
  int r = R-(R/2019)*2019;
  int ans=2019;
  if(R-L>=2019-l||R%2019==0||L%2019==0) {
    cout<<0<<endl;
    return 0;
  }
  else {
    for(int i=l;i<r;i++){
      for(int j=i+1;j<=r;j++){
        ans=min(ans,(i*j)%2019);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  a, v = I()
  b, w = I()
  t = int(input())
  if v <= w:
    print('NO')
  else:
    if abs(a-b) <= (v-w)*t :
      print('YES')
    else:
      print('NO')

if __name__ == '__main__':
  main()

Measured memory_bytes: 9100
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

long long modpow(long long x, long long n, long long m) {
	long long ans = 1;
	while (0 < n) {
		if (n % 2 == 0)x = x * x%m, n >>= 1;
		else ans = ans * x%m, n--;
	}
	return ans;
}

vector<long long> v = { 2,7,61 };

//ミラー-ラビン素数判定法(n <= 4759123140 >= 4*10^9)
bool Miller_Rabin(long long n) {
	if (n == 2)return true;
	if (n < 2 || n % 2 == 0)return false;

	long long d = n - 1, s = 0;
	while (d % 2 == 0)
		d /= 2, s++;

	for (auto a : v) {
		if (a == n)return true;
		bool flag = false;
		long long r = modpow(a, d, n);
		if (r == 1 || r == n - 1)flag = true;
		for (int j = 0; j < s; j++) {
			r = modpow(r, 2, n);
			if (r == n - 1)flag = true;
		}
		if (!flag)return false;
	}
	return true;
}

int main() {
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		int x; cin >> x;
		ans += Miller_Rabin(x);
	}
	Cout(ans);
}


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



int main(){

  int N = 0;
  cin >> N;
  vector<int> veca(N);
  for(int i=0; i<N; i++){
   cin >> veca[i];
  }
long long itra = 1;
  
  for(int i=0; i<N; i++){
    if(veca[i] == itra){
     itra = itra +1; 
    }
  }
    if(itra==1){
     cout << -1; 
    }else{
     cout << (N - (itra - 1)); 
    }
}

Measured memory_bytes: 1152
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String line = input.nextLine();
		Scanner in = new Scanner(line);
		Stack<String> stack = new Stack<String>();
		
		while(in.hasNext()) {
			String str = in.next();
			
			if(str.equals("+")) {
				int x = Integer.parseInt(stack.pop());
				int y = Integer.parseInt(stack.pop());
				String xy = String.valueOf(y+x);
				stack.push(xy);
			}
			
			else if(str.equals("-")) {
				int x = Integer.parseInt(stack.pop());
				int y = Integer.parseInt(stack.pop());
				String xy = String.valueOf(y-x);
				stack.push(xy);
			}
			
			else if(str.equals("*")) {
				int x = Integer.parseInt(stack.pop());
				int y = Integer.parseInt(stack.pop());
				String xy = String.valueOf(y*x);
				stack.push(xy);
			}
			
			else if(str.equals("/")) {
				int x = Integer.parseInt(stack.pop());
				int y = Integer.parseInt(stack.pop());
				String xy = String.valueOf(y/x);
				stack.push(xy);
			}
			
			else {
				stack.push(str);
			}
		}
		input.close();
		in.close();
		System.out.println(stack.pop());
	}
}


Measured memory_bytes: 26356
n = int(input())
a = list(map(int,input().split()))
bit = [-1] * 40
c = 0
m = -1
for i in range(n):
  cur = bin(a[i])[2::]
  cur = cur[::-1]
  for j,k in enumerate(cur):
    if k == '1':
      m = max(m,bit[j])
      bit[j] = i
  bit = [j if j>m else -1 for j in bit]
  c += i-(m+1)
print(c+n)

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  int ans;
  if(n%2 == 1){
    int l = a[n/2];
    int r = b[n/2];
    ans = r-l+1;
  }
  else{
    int l2 = a[n/2-1]+a[n/2];
    int r2 = b[n/2-1]+b[n/2];
    ans = r2-l2+1;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4756
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, ans;
	int c[10][10];
	cin >> n >> m;
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) cin >> c[i][j];
	}

	for (k = 0; k < 10; k++) 
		for (i = 0; i < 10; i++) {
			for (j = 0; j < 10; j++) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	}

	ans = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			int x;
			cin >> x;
			if (x != -1) ans += c[x][1];
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256