akhauriyash/Code-Regression huggingface dataset:
import itertools
import math

n = int(input())
m = []
items = []
for i in range(n):
    m.append([int(x) for x in input().split(' ')])
    items.append(i)

#print(m)

total = 0
count = 0
for perms in itertools.permutations(items):
    #print(perms)
    d = 0
    for i in range(n - 1):
        dx = m[perms[i]][0] - m[perms[i + 1]][0]
        dy = m[perms[i]][1] - m[perms[i + 1]][1]
        d += math.sqrt(dx * dx + dy * dy)
    #print(d)
    total += d
    count += 1

print(total / count)


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

int main() {
  int i,k,n,ans,r=0,l=0,minr,minl;
  int A[200000];
  cin>>k>>n;
  for(i=0;i<n;i++){
    cin>>A[i];
  }

  //時計回り
  minr=A[n-1]-A[0];
  for(i=1;i<n;i++){
    r=A[n-i]+k-A[n-i+1];
    if(r>0&&r<minr) minr=r;
  }
  ans=minr;
  cout << ans;
  return 0;
}

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

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


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

void call(int n)
{
    for (int i = 1; i <= n; i++)
    {
        bool flag = false;
        if (i % 3 == 0)
        {
            flag = true;
        }
        for (int j = i; j; j /= 10)
        {
            if (j % 10 == 3)
            {
                flag = true;
            }
        }
        if (flag)
        {
            cout << " " << i;
        }
    }
    cout << endl;
}

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

    call(n);

    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    int n,l,sum=0,num=1e9,num2;
    cin>>n>>l;
    rep(i,n){
        int a=i+l;
        sum+=a;
        if(num>abs(a-0)){
            num=abs(a-0);
            num2=a;
        }
    }
    cout<<sum-num2;
}

Measured memory_bytes: 3576
#include <stdio.h>

int r[200000];

int calc_Max_difference(int r[], int n) {
  int rmin = r[0];
  int max = r[1] - r[0], i;

  for (i = 1; i < n; i++) {
    max = (max > r[i] - rmin ? max : r[i] - rmin);
    rmin = (rmin < r[i] ? rmin : r[i]);
  }
  return max;
}

int main(void) {
  int n, i, j, ans;

  scanf("%d", &n);

  for (i = 0; i < n; i++)
    scanf("%d", &r[i]);

  ans = calc_Max_difference(r, n);

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2568
from collections import deque
import sys
input=sys.stdin.readline


def BFS():
    point=0
    color=[["white" for _ in range(w)] for _ in range(h)]
    D=[[0 for _ in range(w)] for _ in range(h)]

    queue=deque([])
    for i in range(h):
        for j in range(w):
            if A[i][j]=="#":
                color[i][j]="gray"
                queue.append([i,j])
                D[i][j]=0

    while len(queue)>0:
        x,y=queue.popleft()
        for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:
            X,Y=x+a,y+b
            if 0<=X<h and 0<=Y<w:
                if color[X][Y]=="white":
                    color[X][Y]="gray"
                    D[X][Y]=D[x][y]+1
                    point=max(point,D[X][Y])
                    queue.append([X,Y])
        color[x][y]="black"

    return point


h,w=map(int,input().split())
A=[list(input()) for _ in range(h)]
print(BFS())

Measured memory_bytes: 186204
#include<iostream>
#include<cstring>
using namespace std;
long long a;
string b;
int main()
{
	cin>>b;
	for(int i=0;i<b.length()-1;i++)
	{
		if(b[i]!=b[i+1])a++;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
struct Linear_Sieve{
int n;
vector<int> lp,primes;
//lp[i]...the least prime of i. primes...prime numbers
Linear_Sieve(int n = 1):n(n),lp(n+1){
    for(int i = 2;i < n+1;i++){
        if(lp[i] == 0) {
            primes.push_back(i);
            lp[i] = i;
        }
        for(int j = 0;j<primes.size() && primes[j] <= lp[i] && i*primes[j] < n+1; ++j) lp[i*primes[j]] = primes[j];
    }
}
bool isPrime(int x) {return lp[x] == x;}

vector<int> factorList(int x){
    //make list which contains prime factors of x. Ans it toralates multipled components.
    vector<int> res;
    while(x != 1){
        res.push_back(lp[x]);
        x /= lp[x];
    }
    return res;
}

vector<pair<int,int>> factor(int x){
        //make list of pairs which couple prime factor and multiplicity.
    vector<int> fl = factorList(x);
    if(fl.size() == 0) return{};
    vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
    for(int p : fl){
        if(res.back().first == p){
            res.back().second++;
        }else{
            res.emplace_back(p,1);
        }
    }
    return res;
}
};

int main(){
    int n;cin >> n;
    Linear_Sieve s(1000005);
    vector<int> plis(1000005),a(n);
    int g = 0;
    bool pflag = true;
    rep(i,n){
        cin >> a[i];
        g = __gcd(g,a[i]);
        if(a[i] == 1) continue;
        if(!pflag) continue;
        for(auto p:s.factor(a[i])){
            if(plis[p.first] != 0) pflag = false;
            plis[p.first] = 1;
        }
    }

    if(g != 1) cout << "not coprime" << endl;
    else if(!pflag) cout << "setwise coprime" << endl;
    else cout << "pairwise coprime" << endl;
    

}



Measured memory_bytes: 15168
#include <bits/stdc++.h>
using namespace std;
string s,t;
main()
{
    cin>>s>>t;
    int ans=t.size();
    for(int i=0;i<=s.size()-t.size();++i)
    {
        int c=0;
        for(int j=0;j<t.size();++j)c+=s[j+i]!=t[j];
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}

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

int main()
{
  string str;

  cin >> str;
  int len = str.size(), m = len, ct = 0;
  for (int i = 0; i < len; i++){
    if (str[i] == 'S') ct++;
    if (0 < ct && str[i] == 'T'){
      ct--;
      m -= 2;
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 640
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let v: Vec<usize> = 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,
    ];
    let k: usize = scan(tokens);
    println!("{}", v[k - 1]);
}


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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("a_in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int r;
    cin >> r;
    cout << 3 * r * r;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int r;
	cin>>r;
	cout<<3*(r*r)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  static public void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String str=sc.next();
    Set<String>set=new HashSet<>();
    for(int i=0;i<str.length();i++){
        String num=String.valueOf(str.charAt(i));
        set.add(num);
    }
    System.out.println(str.length()==set.size()?"yes":"no");
    sc.close();
  }
}


Measured memory_bytes: 35616
#include <stdio.h>

int main()
{
	short a, b, c;
	short tmp;

	scanf("%d%d%d", &a, &b, &c);
	if (a > b) tmp = a, a = b, b = tmp;
	if (b > c) {
		tmp = b, b = c, c = tmp;
		if (a > b) tmp = a, a = b, b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int c[501],s[501],f[501];

void input(){
    cin >> n;
    for(int i=0;i<n-1;i++) cin >> c[i] >> s[i] >> f[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int t;
    for(int i=0;i<n;i++){
        t=0;
        for(int j=i;j<n-1;j++){
            if(t<s[j]) t=s[j];
            else if(t%f[j]==0);
            else t += f[j]-(t%f[j]);
            t+=c[j]; 
        }
        cout << t << endl;
    } 
    return 0;
}

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

int main(){
    int a,b;
    while(1){
        cin >> a >> b;
        if(a==0 && b==0) break;
        for(int i=1; i<=a; i++){
            for(int j=1; j<=b; j++){
                if(i!=1 && j!=1 && i!=a && j!=b)
                    cout << ".";
                else
                    cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int  i = (0; i < n; i++)
#define irrep2(i,a,n) for(int i = (a); i <= (int)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std; 

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

    v_int t(n, 0), v(n, 0);
    v_int sum_t(n, 0);

    irep(i, n) { cin >> t[i]; }
    irep(i, n) { cin >> v[i]; }
    
    int T = 0;
    irep(i, n) { T += t[i]; }

    v_double v_max(2*T+1);
    int time = 0;
    irep(i, n) {
        irep(j, t[i]-1) {
            v_max[time+1] = v[i];
            v_max[time+2] = v[i];
            time += 2;
        }
        v_max[time+1] = v[i];
        v_max[time+2] = min(v[i], v[i+1]);
        time += 2;
    }
    
    v_max[2*T] = 0;
    v_max[0] = 0;

    irep2(i, 1, 2*T) {
        v_max[i] = min(v_max[i], v_max[i-1] + 0.5);
    }

    for(int i = 2*T-1; i >= 0; i--) {
        v_max[i] = min(v_max[i], v_max[i+1] + 0.5);
    }
    
    double ans = 0.0;
    irep2(i, 1, 2*T) {
        ans += (v_max[i] + v_max[i-1]) * 0.25;
        //cout << ans << "," << i << endl;
    }

    printf("%.7f\n", ans);
    return 0;
}
/** atcoder **/


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

int main()
{
 	int ans, x, i, n;
  	cin >> n;
  
  	ans=0;
  	for(i=1; i<=n; i+=1)
    {
     	cin >> x;
      	if((i&1) && (x&1))
          ans+=1;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
    string s;

    cin>>s;

    map<char,int> mp;
    mp['N'] = mp['W'] = mp['E'] =mp['S'] = 0;

    for(int i=0;i<s.size();i++) mp[s[i]]++;

    bool turn = false;
    if(((mp['N'] && mp['S']) || (mp['N'] == mp['S'])) && (mp['E'] && mp['W'])) turn = true;
    if(mp['N'] && mp['S'] && ((mp['E'] && mp['W']) || (mp['E'] == mp['W']))) turn = true;

    if(turn) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
x,y=map(int,input().split())

dist=abs(abs(x)-abs(y))
if x<=y:
  if x*y>=0:
    ans=dist
  else:
    ans=dist+1
else:
  if x*y>0:
    ans=dist+2
  else:
    ans=dist+1

print(ans)

Measured memory_bytes: 8920
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    K,S = (int(_) for _ in input().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):            
            if(K >= S - x - y and S - x - y >= 0):
                ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
S = input()
ans = 1
prev = S[0]
i = 1

while i < len(S):
  tmp = S[i]
  while 1:
    if prev != tmp:
      break
    else:
      i += 1
      tmp += S[i]
  
  if i == len(S) - 2 and tmp == S[-1]:
    tmp += S[-1]
    i += 1
  ans += 1
  i += 1
  prev = tmp
print(ans)

Measured memory_bytes: 3500
#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 N;
ll T;
vector<pair<ll,ll>> A;
vector<ll> B;

ll dp[202020];

bool comp(pair<ll,ll>& L,pair<ll,ll>& R) {
	return (R.first+1)*(L.second+1)+R.second<(L.first+1)*(R.second+1)+L.second;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	FOR(i,N) {
		cin>>x>>y;
		if(x>0) A.push_back({x,y});
		else B.push_back(y);
	}
	
	FOR(i,N+1) dp[i]=1LL<<60;
	dp[0]=0;
	
	sort(ALL(A),comp);
	FORR(v,A) {
		ll a=v.first;
		ll b=v.second;
		for(i=40;i>=0;i--) if(dp[i]<T) {
			ll nex=(dp[i]+1)+(dp[i]+1)*a+b;
			dp[i+1]=min(dp[i+1],nex);
		}
	}
	
	sort(ALL(B));

	vector<ll> sum;
	sum.push_back(0);
	FORR(b,B) sum.push_back(sum.back()+1+b);
	int ma=0;
	for(i=N;i>=0;i--) if(dp[i]<=T) {
		ma=max(ma,i);
		x=lower_bound(ALL(sum),T-dp[i]+1)-sum.begin()-1;
		ma=max(ma,i+x);
	}
	cout<<ma<<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: 6512
#include<stdio.h>
int main()
{
    int N,X,T,a,b,c;
    scanf("%d%d%d",&N,&X,&T);
    a=N/X;
    b=N%X;
    if(b!=0)
        c=(a+1)*T;
    else
        c=a*T;
    printf("%d\n",c);

}

Measured memory_bytes: 1708
#include<iostream>
using namespace std;
#define max 500000
#define infty 2000000000


int cnt;

void merge(int A[], int left, int mid, int right){
	int nl = mid - left;
	int nr = right - mid;
	int L[nl + 1], R[nr + 1];
	for(int i = 0; i < nl; i++) L[i] = A[left+i];
	for(int i = 0; i < nr; i++) R[i] = A[mid+i];
	L[nl] = R[nr] = infty;

	int j = 0, k = 0;
	for(int i = left; i < right; i++){
		cnt++;
		if(L[j] < R[k]){
			A[i] = L[j++];
		}
		else{
			A[i] = R[k++];
		}
	}
}

void mergeSort(int A[], int left, int right){
	if(left+1 < right){
		int mid = (left + right)/2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(void){
	int A[max], n;
	cnt = 0;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> A[i];
	mergeSort(A, 0, n);
	for(int i = 0; i < n; i++){
		if(i == n-1){
			cout << A[i] << endl;
		}
		else{
			cout << A[i] << ' ';
		}
	}
	cout << cnt << endl;

	return 0;
}


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

int main() {
  double n;
  cin >> n;
  double a[110];
  rep(i,n) cin >> a[i];
  double sum = 0;
  rep(i,n) sum += 1 / a[i];
  double ans = 1 / sum;
  cout << setprecision(20) << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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


bool p[1000000];
vector<int> psum;

int main(){
	p[2] = true;
	psum.push_back(2);
	for(int i = 3; i < 1000000; i+=2) p[i] = true;
	for(int i = 3; i < 1000000; i+=2){
		if(p[i]){
			psum.push_back(i);
			for(int j = i; j < 1000000; j+=i) p[j] = false;
		}
	}
	FOR(i, 1, psum.size()) psum[i] += psum[i-1];

	int n;
	while(cin >> n, n){
		cout << psum[n-1] << endl;
	}

	return 0;
}

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


using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define sortA(arr)   sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vi flag(1000001,0);
    vi arr(n);
    rep(i,0,n){
        cin>>arr[i];
        flag[arr[i]]++;
    }
    int count=0;
    int sp,sp1;
    rep(i,0,n){
        sp=0,sp1=0;
        int k=arr[i];
        for(int j=1;j<=sqrt(k);j++){
            if(k%j==0){
                if(j==1){
                    if(flag[k/j]>1)
                    {sp=1;
                    break;
                    }
                    if(flag[j]>=1){
                    if(k!=1){
                        sp=1;
                        break;
                    }
                }
                }
            else{
            if(flag[k/j]>=1||flag[j]>=1){
                sp=1;
                break;
            }
        }
        }
        }
            if(sp==0){
            count++;
    }
    
}
cout<<count<<endl;
}


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

int main()
{
  int N;
  double sum, x[10];
  string u[10];

  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> x[i] >> u[i];

  for(int i = 0; i < N; i++){
    if(u[i] == "JPY")
      sum += x[i];
    else
      sum += x[i] * 380000.0;
  }

  cout << sum << endl;
  return 0;
}


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

string str[3] = {"delicious", "safe", "dangerous"};
int main(){
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);
	if(b-a <= 0)cout << str[0] << endl;
	else if(b-a <= x)cout << str[1] << endl;
	else cout << str[2] << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0]*N
x = [[0]*N for i in range(N)]
y = [[0]*N for i in range(N)]

maxsum = 0

for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        x[i][j],y[i][j] = map(int,input().split())

sum = 0
for i2 in range (2**N):
    i = 2**N-1-i2
    TF=[0]*N
    ans=True
    
    for j in range(N):
        if(i >> j & 1):
            TF[j]=1
    for j in range(N):

        if(TF[j] == 1):
            for k in range(A[j]):
                if(TF[x[j][k]-1] != y[j][k]):
                    ans=False
    if(ans):
        sum=0
        for j in range(N):
            if(i >> j & 1):
                sum += 1
            maxsum = max(sum,maxsum)

print(maxsum)
             

Measured memory_bytes: 49244
import java.util.*;
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int i = 0;

    while (a > 0 && c > 0) {
      if (i % 2 == 0) {
        c -= b;
      } else {
        a -= d;
      }
      i++;
    }
    if (a > 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
    sc.close();

  }
}

Measured memory_bytes: 35728
#!/usr/bin/env python3

import math
import sys


def calculate_area(side_a, side_b, angle_c):
    return (side_a*side_b*math.sin(math.radians(angle_c))) / 2


def calculate_perimeter(side_a, side_b, angle_c):
    side_c = math.sqrt(side_a**2 + side_b**2
                       - 2*side_a*side_b*math.cos(math.radians(angle_c)))
    return side_a + side_b + side_c


def calculate_height_from_side_a(side_a, area):
    return (area*2)/side_a


def main():
    nums = [float(num) for num in sys.stdin.readline().split()]

    area = calculate_area(nums[0], nums[1], nums[2])
    perimeter = calculate_perimeter(nums[0], nums[1], nums[2])
    height_from_side_a = calculate_height_from_side_a(nums[0], area)

    print(area)
    print(perimeter)
    print(height_from_side_a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7960
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)


Measured memory_bytes: 86552
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int main()
{
   int a, b, c, d, e, f;
   cin >> a >> b >> c >> d >> e >> f;
   int g[1000]={0}, gcount=0;
   int sug[3001]={0}, scount = 0;

   for(int i = 0; i <= 30; i++){
       for(int j =0; j <= 30;j++){
           if(100*a*i + 100*b*j<=f){
               g[gcount]=100*a*i + 100*b*j;
               gcount++;
           }
       }
   }

    for(int i =0; i <= 3000; i++){
        for(int j =0; j <=3000; j++){
			if(c*i+d*j >3000) continue;

         	sug[c*i+d*j]++;
        }
    }

	float max = 0.0;
	int sug_t, g_t;
	double eg = e/100.0;
	for(int i = 0; i < gcount;i++){
		for(int j=0; j <= 3000; j++){
			if(g[i] ==0 ||j+g[i] > f || sug[j]==0){
				continue;
			}
			double tmp = (double)(100 * j)/(double)(j + g[i]);
			if(max < tmp && !(((double)j / (double)g[i]) > eg)){
				max = tmp;
				sug_t = j;
				g_t = g[i];
			}
		}
	}
	if(max < 0.0001){

	cout << a*100 << " "<< 0 << endl;
	}else{

	cout << g_t + sug_t << " "<< sug_t << endl;
	}
   

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> L;
  for(int i = 0; i < 2*N; ++i)
  {
    int l;
    cin >> l;
    L.push_back(l);
  }
  sort(L.begin(), L.end());

  int sum = 0;
  for(int i = 0; i < N; ++i)
    sum += L[2*i];
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[1100];
const long long inf=1e18;
int u[2200],v[2200],w[2200],n,m;
long long bell_man()
{
    for(int i=1; i<=n; i++)dp[i]=-inf;
    dp[1]=0;
    int f=0,i=1;
    for(int i=0;i<=n*(n-1)/2;i++)
    {
        for(int j=0; j<m; j++)
            if(dp[v[j]]<dp[u[j]]+w[j])
            {
                dp[v[j]]=dp[u[j]]+w[j];
                if(v[j]==n)
                {
                    f++;
                    if(f==n)
                        return inf;
                }
            }
    }
    return dp[n];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
        scanf("%d%d%d",&u[i],&v[i],&w[i]);
    long long ans=bell_man();
    if(ans==inf)
        puts("inf");
    else
        printf("%lld\n",ans);
    return 0;

}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
W = [0, w]
H = [0, h]
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and W[0] < x:
        W[0] = x
    elif a == 2 and W[1] > x:
        W[1] = x
    elif a == 3 and H[0] < y:
        H[0] = y
    elif a == 4 and H[1] > y:
        H[1] = y

if W[1]-W[0] < 0 or (H[1]-H[0]) < 0:
    print(0)
else:
    print((W[1]-W[0]) * (H[1]-H[0]))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) mp[n]++;
  ll ans = 0;
  for (auto a : mp) {
    ll m = a.second;
    for (int i = 1; i <= 40; ++i) {
      if (i <= m) {
        ans++;
        m -= i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);

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

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool used[210];

int main() {
	int a, b, c, ans = 0;
	std::cin >> a >> b >> c;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		if (a == b&&b == c) {
			std::cout << -1 << std::endl;
			flag = false;
			break;
		}
		int A = a, B = b, C = c;
		a = B / 2 + C / 2;
		b = A / 2 + C / 2;
		c = A / 2 + B / 2;
		ans++;
	}
	if (flag) {
		std::cout << ans << std::endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int count = 0;
			String square =  br.readLine();

			for(int i = 0; i < 3; i++) {
				if(square.charAt(i) == '1') {
					count++;
				}
			}

			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
#define coutv(v) for (int i = 0; i < (v).size(); ++i) cout << v[i] << ' '; cout << endl;
#define coutvv(v) for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cout << v[i][j] << ' '; cout << endl;}
#define debugv(v) {for (int i = 0; i < (v).size(); ++i) cerr << v[i] << ' '; cerr << endl;}
#define debugvv(v) {for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cerr << v[i][j] << ' '; cerr << endl;}}
#define TC int TESTCASE; cin >> TESTCASE; while (TESTCASE--)
typedef long long ll;
 


int main() {
	int n;
	cin >> n;
	string a;
	cin >> a;
	int deff = 1;
	if (n % 2 == 0) {
		for (int i = 0; i < n / 2; ++i)
		{
			if (a[i] != a[i+n/2]) {
				deff = 0;
			}
		}
	} else {
		deff = 0;
	}
	if (deff) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}
 


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  for(int i = 0; i < n; i++)
    ans += (i%2==0?a[i]:-a[i]);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
    int n,m,Ci,Co,max,Ct,flag=0;
 
    cin >> n;
    cin >> m;
    Ct = m;
    max = m;
    for( int i = 0 ; i < n ; i++ ){
	cin >> Ci >> Co;
	Ct += Ci - Co;
	if( Ct < 0 ) flag = 1;
	if( max < Ct ) max = Ct;
    }
    if( flag == 1 ) cout << "0" << endl;
    else cout << max << endl;
    return 0;
}

Measured memory_bytes: 3104
def check(A, F, K, x):
    for i in range(len(A)):
        if A[i] * F[i] > x:
            need = (A[i] * F[i] - x + F[i] - 1) // F[i]
            if need > K:
                return False
            K -= need
    return True


N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
F = list(map(int, input().split(' ')))
A.sort()
F.sort()
F = F[::-1]

high, low = 10 ** 13, -1
while high - low > 1:
    mid = (high + low) // 2
    if check(A, F, K, mid):
        high = mid
    else:
        low = mid
print(high)

Measured memory_bytes: 117212
#include<iostream>

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    string s;
    cin >> s;

    if(s == "Sunny"){
        cout << "Cloudy";
    }
    if(s == "Cloudy"){
        cout << "Rainy";
    }
    if(s == "Rainy"){
        cout << "Sunny";
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
int A[MAX];

int LinearSearch(int key,int n){//Aの要素数とkey入れると　あるかどうか判定出来る
  int i=0;
  A[n]=key;//最後に番兵設置 Aの要素はn-1までだから問題ない
  while (A[i] != key)i++;
  
  if (i == n)return 0;//見つからなかった
  return 1;//見つかった
}

int main(){
  int i;
  int n;
  int key_num;
  int key;
  int count=0;//一致した数
  
  scanf("%d",&n);//input
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&key_num);
  
  for(i=0;i<key_num;i++){//Aにkeyがあるか
    scanf("%d",&key);
    if(LinearSearch(key,n)==1)count++;
  }
  
  printf("%d\n",count);
  return 0;
}
/*
  数字の数
  数　数　数A
  確かめるkeyの数
  key　key　keyT

  出力
  TのうちAの中にある数
*/



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

vector<int> vis;
int cnt = 0;

void dfs(int i, vector<vector<int>>& adj) {
    if (vis[i]) return;
    vis[i] = 1;
    cnt++;
    for (int v : adj[i]) {
        dfs(v, adj);
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        const int mxn = 1e6;
        vector<int> cnt(mxn);
        int g = 0, p = 1;
        for (int x : a) {
            g = __gcd(g, x);
        }
        for (int j = 0; j < n; j++) {
            int x = a[j];
            bool ok = 1;
            for (int f = 2; f * f <= x && ok; f++) {
                if (x % f == 0) {
                    cnt[f]++;
                    if (cnt[f] > 1) {
                        // cout << f << endl;
                        ok = false;
                        break;
                    }
                    while (x % f == 0) x /= f;
                }
            }
            if (x > 1) {
                cnt[x]++;
                if (cnt[x] > 1) ok = false;
            }
            if (!ok) {
                p = 0;
                break;
            }
        }
        if (p) cout << "pairwise coprime";
        else if (g == 1) cout << "setwise coprime";
        else cout << "not coprime";
    }
    return 0;
}


Measured memory_bytes: 18764
def myAnswer(H:int,W:int,S:list) -> None:
   ans = [["#" for _ in range(W+2)]]
   index = []
   for i,s in enumerate(S):
      tmp = ["#"]
      for j,b in enumerate(s):
         if(b == "."):
            tmp.append(0)
         else:
            index.append([i+1,j+1])
            tmp.append(b)
      tmp.append("#")
      ans.append(tmp)
   ans.append(["#" for i in range(W+2)])
   for i,j in index:
      for n in range(i-1,i+2,1):
         for m in range(j-1,j+2,1):
            if(ans[n][m]!="#"):
               ans[n][m] +=1
   ans.pop(0)
   ans.pop()
   for a in ans:
      a.pop(0)
      a.pop(-1)
      string = ""
      for s in a:
         string += str(s)
      print(string)
      
def main():
   H,W = map(int,input().split())
   S = [list(input()) for _ in range(H)]
   myAnswer(H,W,S[:])
if __name__ == '__main__':
   main()

Measured memory_bytes: 3316
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    HashMap<Character,Integer> roman = new HashMap<Character,Integer>();
    char[] charArr = {'I','V','X','L','C','D','M'};
    int[] intArr   = {1,5,10,50,100,500,1000};
    for (int i = 0; i < 7; i++) {
      roman.put(charArr[i],intArr[i]);
    }
    while(sc.hasNext()) {
      String str = sc.next();
      int sum = roman.get(str.charAt(0));
      for(int i = 1; i < str.length(); i++) {
        if(roman.get(str.charAt(i)) > roman.get(str.charAt(i-1))) {
          sum += roman.get(str.charAt(i)) - 2*roman.get(str.charAt(i-1));
        }
        else {
          sum += roman.get(str.charAt(i));
        }
      }
      System.out.println(sum);
    }
  }
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
using namespace std;
int n,c,k,t[100005],ans,cnt,f;
main()
{
    cin>>n>>c>>k;
    for(int i=0;i<n;i++)cin>>t[i];
    sort(t,t+n);
    f=t[0];
    for(int i=0;i<n;i++){
      	if(t[i]-f<=k)cnt++;
        if(cnt==c)cnt=0,ans++,f=t[i+1];
      	if(t[i+1]-f>k)cnt=0,ans++,f=t[i+1];
      	if(i==n-1 && cnt>0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    ll n;
    cin>>n;
    vl x(n);
    ll sum=INT_MAX;
    forr(i, n)
    {
        cin>>x[i];
    }
    sort(all(x));
    for(ll i=0; i<101; i++)
    {
        ll cur=0;
        for(ll j=0; j<n; j++)
        {
            cur+=(x[j]-i)*(x[j]-i);
        }
        sum=min(cur, sum);
    }
    cout<<sum<<endl;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

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

int main(){
  int A, B;     //開始と終了
  int X, Y, Z;  //Xは逆の数
  int K = 0;    //回文数

  cin >> A >> B;
  
  for ( int i=A; i<=B; i++ ){
    Y = i;
    X = 0;
    for ( int j=0; j<5; j++ ){
      Z = Y % 10; 
      X = X * 10 + Z;
      Y /= 10;
    }
    if ( i == X ) {
//      cout << X << endl;
      K++;
    }
  }
  
  cout << K << endl;
}     

Measured memory_bytes: 256
#include<stdio.h>

#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,k;
  cin>>n>>k;
  
  int* arr =new int[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int *dp =new int[n];
  dp[0]=0;
 int a;
  for(int i=1;i<n;i++)
  {
      int min =INT_MAX;
      for(int j=1;j<=k;j++)
      {
          if(i-j>=0)
       a = dp[i-j] +abs(arr[i]-arr[i-j]);
       if(min>a)
       {
           min=a;
       }
      }
    dp[i]=min;
       
      
   
  }
  
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int vfind(vector<ll> v, ll num) {
    auto itr = find(v.begin(), v.end(), num);
    size_t index = distance( v.begin(), itr );
    if (index != v.size()) { // 発見できたとき
        return 1;
    }
    else { // 発見できなかったとき
        return 0;
    }
}

int main(){
    ll a,b;
    vector<ll> x{1,3,1,2,1,2,1,1,2,1,2,1};
    cin >> a >> b;
    if (x[a-1]==x[b-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
from math import sqrt
N, D = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for s1 in S:
    for s2 in S:
        c = 0
        for x1, x2 in zip(s1, s2):
            c += (x1-x2)**2
        if int(sqrt(c))**2 == c:
            ans += 1
print((ans-N)//2)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

vector<int> read_vec(int n){
    vector<int> ret(n);
    for (int i = 0; i < n; i++){
        cin >> ret[i];
    }
    return ret;
}

int main() {
    long long n, ans = -1000000000, a, b, mi;
    cin >> n;
    vector<int>mins(n);
    vector<int>r(n);
    for (int i = 0; i < n; i++){
        cin >> r[i];
    }
    mins[0] = r[0];
    for (int i = 1; i < n; i++){
        mins[i] = min(mins[i - 1], r[i]);
    }
    for (int i = 1; i < n; i++){
        ans = max(int(ans), int(r[i] - mins[i - 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4276
#include <stdio.h>
int abs(int x) {
	return (x > 0) ? x : (-x);
}
int main() {
	int n, dis;
	int t, x, y;
	int tt, xx, yy;
	scanf("%d", &n);
	tt = 0; xx = 0; yy = 0;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d%d", &t, &x, &y);
		dis = abs(x - xx) + abs(y - yy);
		if (dis > t || (t - dis) % 2 != 0)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int A[110000],B[110000],C[110000],dp[110000][3];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            if(i==0){
                if(j==0)dp[i][j]=A[i];
               else if(j==1)dp[i][j]=B[i];
                else if(j==2)dp[i][j]=C[i];
            }else{
            for(int k=0;k<3;k++){
                if(j==k)continue;
                if(j==0)dp[i][j]=max(dp[i][j],dp[i-1][k]+A[i]);
                if(j==1)dp[i][j]=max(dp[i][j],dp[i-1][k]+B[i]);
                if(j==2)dp[i][j]=max(dp[i][j],dp[i-1][k]+C[i]);            }
                
            }
            }
        }
    
    int res=0;
    res=max(res,dp[n-1][0]);
    res=max(res,dp[n-1][1]);
    res=max(res,dp[n-1][2]);
    cout<<res;
    return 0;
}

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

#define maxn
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 __y0
#define y1 __y1
#define x0 __x0
#define x1 __x1
#define next __next
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int main() {
    //freopen("add.inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    printf("%lld", max(0LL, 1LL*(n-2)*b-1LL*(n-2)*a+1));
}


Measured memory_bytes: 256
import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]
for h, w in itertools.product(range(H), range(W)):
    if A[h][w] == 'S':
        break
visited = [['.'] * W for _ in range(H)]
res = K - 1
Q = collections.deque([[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                       [h, w + 1, res]])
sH = set([h])
sW = set([w])
while Q:
    h, w, res = Q.popleft()
    if 0 <= h < H and 0 <= w < W and A[h][w] == '.' and visited[h][w] != '#':
        visited[h][w] = '#'
        sH.add(h)
        sW.add(w)
        if res:
            res -= 1
            Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                  [h, w + 1, res]]
print(1 +
      math.ceil(min([min(sH), H - 1 - max(sH),
                     min(sW), W - 1 - max(sW)]) / K))


Measured memory_bytes: 107228
#include<iostream>

using namespace std;

int main()
{
	int sum,heights[10];
	for(int i = 0; i<10;i++)
	{
		cin>>heights[i];
	}
	for(int i = 1;i<10;i++)
		if(heights[i]>heights[0])
		{
			sum = heights[i];
			heights[i] = heights[0];
			heights[0] = sum;
		}
		//heights[0] = heights[i]>heights[0]?heights[i]:heights[0];
	for(int i = 2;i<10;i++)
		if(heights[i]>heights[1])
		{
			sum = heights[i];
			heights[i] = heights[1];
			heights[1] = sum;
		}
		//heights[1] = heights[i]>heights[1]?heights[i]:heights[1];
	for(int i = 3;i<10;i++)
		if(heights[i]>heights[2])
		{
			sum = heights[i];
			heights[i] = heights[2];
			heights[2] = sum;
		}
		//heights[2] = heights[i]>heights[2]?heights[i]:heights[2];
	cout<<heights[0]<<endl;
	cout<<heights[1]<<endl;
	cout<<heights[2]<<endl;
	return 0;
}

Measured memory_bytes: 1160
def solve(N, K):
    n = N // K
    #print(n)
    answer = n ** 3
    if K % 2 == 0:
        m = K//2
        n = (N + m) // K
        #print(n)
        answer += n ** 3
    return answer
        
N, K = [int(x) for x in input().split()]
print(solve(N, K))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long

const int maxn = 500100;
const int base = 998244353;

using namespace std;

ll fac[maxn],inv[maxn],n,k,res;

ll pow(ll n,int k) {
    if (k==0) return 1;
    if (k==1) return n;
    ll mid = pow(n,k/2);
    mid = (mid*mid) % base;
    if (k%2==0) return mid;
    return (mid*n) % base;
}

ll C(int n,int k) {
    //cout<<n<<" "<<k<<" "<<fac[n]<<" "<<inv[k]<<" "<<inv[n-k]<<endl;
    if (k>n) return 0;
    if (k==n) return 1;
    //cout<<n<<" "<<k<<" "<<fac[n]<<" "<<inv[k]<<" "<<inv[n-k]<<" "<<((fac[n] * inv[k]) % base * inv[n-k]) % base<<endl;
    return ((fac[n] * inv[k]) % base * inv[n-k]) % base;
}

int main() {
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    fac[0]=1; inv[0]=1;
    for (int i=1;i<=maxn;i++) {
        fac[i] = (fac[i-1]*i) % base;
        inv[i] = pow(fac[i],base-2) % base;
    }
    cin>>n>>k;
    if (k<n) {
        cout<<0<<endl;
        return 0;
    }
    for (int R=0;R<=k;R++) {
        int B = k-R;
        if (R==B) res = (res + C(R+B-1,R) - C(R+B-1,R+B-n+1)) % base;
        else if (R>B) res = (res + C(R+B,R) - C(R+B,2*R-n+1)) % base;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 8192
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s, t;
  cin >> s >> t;
  ll a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(u == s){
    a--;
  }else{
    b--;
  }
  print(a, b);
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
con =0
ex = -1
for i in range(n):
    if a[i] % 4 == 0:
        con +=1
    elif a[i] % 2 == 0:
        ex +=1
    
if ex == -1:
    ex = 0
if (n-ex)//2 <= con:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252