akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	
	public static Integer revPol(String s) {
		
		String[] notation = s.split(" ");
		Stack<Integer> workS = new Stack<>();
		ArrayList<String> operations = new ArrayList<>();
		operations.add("+");
		operations.add("-");
		operations.add("*");
		operations.add("/");
		for(String current : notation) {
			//System.out.println(workS);
			if(operations.contains(current)) {
				//System.out.println("Operation");
				int toAdd = 0;
				int val1 = workS.pop();
				int val2 = workS.pop();
				if(current.equals("+")) {
					toAdd = val1 + val2;
				}
				else if(current.equals("-")) {
					toAdd = val2 - val1;
				}
				else if(current.equals("*")) {
					toAdd = val1 * val2;
				}
				
				
				workS.push(toAdd);
			}
			else {
				workS.push(Integer.parseInt(current));
			}
		}
		
		return workS.pop();
	}
	
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String inp = s.nextLine();
		System.out.println(revPol(inp));
		s.close();
		
	}

}



Measured memory_bytes: 26348
import numpy as np

line_1 = np.array(list(map(int, input().split())))
line_2 = np.array(list(map(int, input().split())))
line_3 = np.array(list(map(int, input().split())))
n = int(input())
lists = [int(input()) for i in range(n)]

line = np.concatenate([line_1, line_2, line_3])
for i in lists:
  index = np.where(line == i)
  line[index] = 0

line = np.reshape(line, (3,3))
condition_1 = line[0].sum() == 0
condition_2 = line[1].sum() == 0
condition_3 = line[2].sum() == 0
condition_4 = line[:,0].sum() == 0
condition_5 = line[:,1].sum() == 0
condition_6 = line[:,2].sum() == 0
condition_7 = line[0,0] + line[1,1] + line[2,2] == 0
condition_8 = line[2,0] + line[1,1] + line[0,2] == 0

if condition_1 or condition_2 or condition_3 or condition_4 or condition_5 or condition_6 or condition_7 or condition_8:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 27324
N = int(input())
A = [int(input()) - 1 for _ in range(N)]
cur = 0
answer = 0
for i in range(N):
    answer += 1
    if A[cur] == 1:
        print(answer)
        break
    else:
        cur = A[cur]
        
else:
    print(-1)

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

using LL = long long;

#define MOD (7 + (int)1e9)

vector<LL> f(100000);

LL factorial(LL k){
    f[1] = 1;
    for (int i = 1; i <= k; ++i)
    {
        f[i+1] = (f[i] * (i+1)) % MOD;
    }
    return f[k] % MOD;
}

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

    LL N, M;

    cin >> N >> M;

    LL res;
    if(labs(N-M) >= 2){
        cout << 0 << endl;
        return 0;
    }else if(labs(N-M) == 1){
        res = ((factorial(N) % MOD) * (factorial(M) % MOD)) % MOD;
    }else{
        res = ((factorial(N) % MOD) * (factorial(M) % MOD) * 2) % MOD;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toInt()
        val P = sc.next().toInt()

        pw.println((A * 3 + P) / 2)
    }
}


Measured memory_bytes: 29472
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
signed main(){
    IOS;
    int n;
    cin>>n;
    vector<char>v;
    int cntw=0,cntr=0;
    int l=1e9;
    int r=-1;
    for(int i=0;i<n;i++){
        char a;
        cin>>a;
        v.push_back(a);
        if(a=='W'){
            cntw++;
            l=min(l,i);
        }
        else {
            r=i;
            cntr++;
        }
    }
    int ans=min(cntw,cntr);
    int cnt=0;
    while(l<r&&l<n&&r>=0){
        swap(v[l],v[r]);
        cnt++;
        l++;
        r--;
        while(v[l]=='R'&&l<=n){
            l++;
        }
        while(v[r]=='W'&&r>=-1){
            r--;
        }
        if(l==n || r==-1)break;
    }
    cout<<min(ans,cnt);

}

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

#define debug(x) cout << #x << " = " << x << endl

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> P;


int main(){
   int N,A,B;
   cin >> N >> A >> B;
   string s;
   cin >> s;

   int cnt = 0;
   int cnt2 = 0;
   
   for(int i=0; i<s.size(); i++){
	  if(s[i] == 'c') cout << "No" << endl;
	  else if(s[i] == 'a' && cnt < A+B){
		 cout << "Yes" << endl;
		 cnt++;
	  } else if(s[i] == 'b' && cnt < A+B && cnt2 < B){
		 cnt2++;
		 cnt++;
		 cout << "Yes" << endl;
	  } else {
		 cout << "No" << endl;
	  }
   }
   return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;


long long int A,V,B,W,T;
int main(){
    cout << fixed << setprecision(18);
    cin>>A>>V>>B>>W>>T;
    IFYES(V>W&&abs(B-A)<=(V-W)*T);
    
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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


int DFS(int n, vector<vector<int>> &G, vector<bool> &V) {
	int c = 1;
	for (int nn: G[n]) {
		if (!V[nn]) {
			V[nn] = true;
			int u = DFS(nn, G, V);
			c += u;
		}
	}
	return c;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> G(n, vector<int>());
	vector<bool> V(n, false);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!V[i]) {
			V[i] = true;
			int x = DFS(i, G, V);
			ans = max(ans, x);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 26684
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel
int minCost(int n, int k, int *arr, int *dp)
{
	if (n == 0)
		return INT_MAX;
	if (n == 1)
		return 0;
	if (dp[n] != -1)
		return dp[n];
	int mx = INT_MAX;
	for (int i = 1; i <= k; i++)
	{
		if (n - i >= 1)
			mx = min(mx, minCost(n - i, k, arr, dp) + abs(arr[n] - arr[n - i]));
		else break;
	}
	dp[n] = mx;
	return mx;
}

void solve()
{
	int n;
	cin >> n;
	int k;
	cin >> k;
	int arr[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	int dp[n + 1];
	memset(dp, -1, sizeof(dp));
	int ans = minCost(n, k, arr, dp);
	cout << ans << endl;
}

signed main()
{
	fasterthanlight;
	int T; T = 1;
	//cin>>T;
	while (T--)
	{
		solve();
	}

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf = LLONG_MAX;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cout << #x << " " << x << endl

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif

    ll n;
    cin >> n;
    vector<ll> cnt(n+1,0);
    
    for(ll i=0,tmp ; i<n-1 ; ++i) { 
        cin >> tmp;
        cnt[tmp]++;
         }

    for(ll i=1 ; i<=n ; ++i) cout << cnt[i] << endl;
} 

Measured memory_bytes: 4780
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
import heapq
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 10 ** 9 + 7
def mint(lis):
    return list(map(int, lis))

def bifind(arr_sorted, x):
    idx = bisect_left(arr_sorted, x)
    if idx == len(arr_sorted):
        return False
    if arr_sorted[idx] == x:
        return True
    else:
        return False
def getyaku(n):
    ret = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)

    return ret

def find(x, a):
    idx = bisect_left(a, x)
    if idx == len(a):
        return False
    if a[idx] == x:
        return True
    else:
        return False

def main():
    # n = getN()
    h1, m1, h2, m2, k = getList()
    diff = h1*60 + m1 - h2*60 - m2
    print(-diff - k)
if __name__ == "__main__":
    main()



Measured memory_bytes: 67964
a,b,c= gets.chomp.split(" ").map(&:to_i)

# if (Math.sqrt(a) + Math.sqrt(b) < Math.sqrt(c))
#   puts "Yes"
# else
#   puts "No"
# end

if ((c-a-b) <= 0)
  puts "No"
  exit
end

if (4 * a * b < (c-a-b) ** 2)
  puts "Yes"
else
  puts "No"
end

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

int main()
{
    int N;
    cin >> N;
    set<int> s;
    rep(i, N) {
        int a;
        cin >> a;
        auto f = s.find(a);
        if (f == s.end()) {
            s.insert(a);
        } else {
            s.erase(f);
        }
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <assert.h>
#include <algorithm>
using namespace std;
struct P{
	int S,w;
	P(){}
	P(int a,int b){S=a;w=b;}
}G[1000005];
int n,v,m,a[200005],len[25],L[200005][25],R[200005][25],f[1000005],g[1000005];
priority_queue<P> q;
bool cmp(P a,P b){
	return a.w<b.w;
}
bool operator <(P a,P b){
	return a.w<b.w;
}
int main(){
	scanf("%d%d",&n,&v);
	while(v) len[m++]=v,v>>=1;len[m++]=0;
	for(int i=0;i<m/2;i++) swap(len[i],len[m-i-1]);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		for(int p=0;p<m;p++){
			L[i][p]=L[i-1][p];
			if(i==1||a[i]-a[i-1]>len[p]) L[i][p]=i;
		}
	}
	for(int i=n;i;i--){
		for(int p=0;p<m;p++){
			R[i][p]=R[i+1][p];
			if(i==n||a[i+1]-a[i]>len[p]) R[i][p]=i;
		}
	}
	f[0]=0;g[0]=n+1;
	for(int i=1;i<(1<<m);i++){
		g[i]=n+1;
		for(int p=0;p<m;p++) if(i&(1<<p)){
			f[i]=max(f[i],f[i^(1<<p)]);
			f[i]=max(f[i],R[f[i^(1<<p)]+1][p]);
			g[i]=min(g[i],L[g[i^(1<<p)]-1][p]);
		}
	}
	int S=(1<<m-1)-1;
	for(int i=0;i<=S;i++) G[i]=P(i,g[i]);
	sort(G,G+S+1,cmp);
	for(int i=1,pos=0;i<=n;i++){
		while(G[pos].w<=R[i][m-1]+1&&pos<=S) q.push(P(S^G[pos].S,f[S^G[pos].S])),pos++;
		if(q.empty()||q.top().w<L[i][m-1]-1) puts("Impossible");
		else puts("Possible");
	}
	return 0;
}

Measured memory_bytes: 55792
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn uc(a : i64, b : i64) -> i64{
    fn ucc(la : i64, sm : i64) -> i64 {
        let ans = la % sm;
        if ans == 0 {
            return sm;
        }
        ucc(sm, ans)
    }
    if a > b {ucc(a, b)} else {ucc(b, a)}
}

fn main() {
    input!{
        n: usize
    }
    let mut answer = 0;
    for i in 1..n+1 {
        let ii = i as i64;
        for j in 1..n+1 {
            let jj = j as i64;
            let uc1 = uc(ii, jj);
            for k in 1..n+1 {
                let kk = k as i64;
                answer += uc(uc1, kk);
            }
        }
    }
    println!("{}", answer);
}


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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int x ;
	multiset<int>s ;
	multiset<int>::iterator it ; 
	int ans = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>x ;
		if(s.size() == 0)
		{
			s.insert(x) ;
			ans++ ;
		}
		else
		{
			int a = *s.begin() ;
			if(a >= x)
			{
				s.insert(x) ;
				ans++ ;
			}
			else
			{
				it = s.lower_bound(x) ;
				it-- ;
				s.erase(s.find((*it))) ;
				s.insert(x) ;
 			}
		}
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 4992
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const double pai=acos(-1.0);
typedef long long ll;
const int mod=200003,g=2;
const int N=1600010;
struct complex{
    double real,imaginary;
    complex(double x=0,double y=0):real(x),imaginary(y){}
    complex operator=(const double b){
        real=b;
        return *this;
    }
    complex operator+(const complex b){
        return complex(real+b.real,imaginary+b.imaginary);
    }
    complex operator-(const complex b){
        return complex(real-b.real,imaginary-b.imaginary);
    }
    complex operator*(const complex b){
        return complex(real*b.real-imaginary*b.imaginary,real*b.imaginary+imaginary*b.real);
    }
    complex operator*=(const complex b){
        *this=*this*b;
        return *this;
    }
};
int n,t[N],r[N];
complex f[N];
ll ans;
void FFT(complex *a,int limit,int type){
    for(int i=0;i<limit;i++)
        if(i<r[i])
            swap(a[i],a[r[i]]);
    for(int mid=1;mid<limit;mid<<=1){
        const double x=pai/(const int)mid;
        complex wn=complex(cos(x),type*sin(x));
        for(int R=mid<<1,j=0;j<limit;j+=R){
            complex w=complex(1,0);
            for(int k=0;k<mid;k++,w*=wn){
                complex y=a[k+j],z=w*a[k+j+mid];
                a[k+j]=y+z;
                a[k+j+mid]=y-z;
            }
        }
    }
    if(type==-1)
    	for(int i=0;i<limit;i++)
	    	f[i].real/=limit;
    return;
}
int main(){
	scanf("%d",&n);
	for(int i=g,l=1;i!=1;i=1ll*i*g%mod,l++)
		t[i]=l;
	t[1]=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		ans-=1ll*x*x%mod;
		if(x)
			f[t[x]].real=f[t[x]].real+1;
	}
	int limit=1;
	while(limit<=mod*2)
		limit<<=1;
	for(int i=0;i<limit;i++)
		r[i]=(r[i>>1]>>1)|((i&1)?(limit>>1):0);
	FFT(f,limit,1);
	for(int i=0;i<limit;i++)
		f[i]=f[i]*f[i];
	FFT(f,limit,-1);
	int p=1;
	for(int i=0;i<limit;i++){
		ans+=((ll)(f[i].real+0.5))*p;
		p=2ll*p%mod;
	}
	printf("%lld\n",ans/2);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    vector<int> lst;
    lst.push_back(a.at(0));

    if(debug){    
        cout << "lst:";
        rep(j,lst.size()) cout << lst.at(j) << " ";
        cout << endl;
    }
    for(int i=1;i<n;i++) {
        int l = -1,r = lst.size();
        while(l+1<r){
            int x = (l+r)/2;
            if(lst.at(x) < a.at(i)) r = x;
            else l = x;
        }

        if(debug) cout << a.at(i) << " r:" << r << endl;

        if(r == lst.size()){
            lst.push_back(a.at(i));
        }else{
            lst.at(r) = a.at(i);
        }

        if(debug){
            cout << "lst:";
            rep(j,lst.size()) cout << lst.at(j) << " ";
            cout << endl;
        }
    }

    cout << lst.size() << endl;
    return 0;
}

Measured memory_bytes: 1276
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;  using i64 = int64_t;  using str = string;
using u32 = uint32_t; using u64 = uint64_t; using usize = size_t;
using f64 = double_t; template <typename T> using vec = vector<T>;
#define times(n, i) for (i64 i = 0; i < (n); ++i)
#define range(n, m, i) for (i64 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i64 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i64 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i64 n, k;
vec<i32> e[2000];
i32 d[2000];

i32 solve(i32 c) {
    i32 ret = 0;
    memset(d, -1, sizeof(d));
    queue<pair<i32,i32>> rest;
    rest.push(make_pair(c, 0));
    while (rest.size()) {
        i32 p = rest.front().first;
        i32 v = rest.front().second;
        rest.pop();

        d[p] = v;
        if (v > k/2)
            ret++;

        times(e[p].size(), i) {
            if (d[e[p][i]] < 0) {
                rest.push(make_pair(e[p][i], v+1));
            }
        }
    }

    return ret;
}

i32 solve(i32 c1, i32 c2) {
    i32 ret = 0;
    memset(d, -1, sizeof(d));
    queue<pair<i32, i32>> rest;
    rest.push(make_pair(c1, 0));
    rest.push(make_pair(c2, 0));
    while (rest.size()) {
        i32 p = rest.front().first;
        i32 v = rest.front().second;
        rest.pop();

        if (d[p] > -1 && d[p] <= v)
            continue;
        d[p] = v;
        if (v > (k-1)/2)
            ret++;

        times(e[p].size(), i) {
            if (d[e[p][i]] < 0) {
                rest.push(make_pair(e[p][i], v+1));
            }
        }
    }

    return ret;
}

i32 main()
{
    cin >> n >> k;

    times(n-1, i) {
        i32 a, b;
        cin >> a >> b;
        a--; b--;
        e[a].append(b);
        e[b].append(a);
    }

    i32 ans = INT_MAX;
    times(n, i) {
        if (even(k)) {
            ans = min(solve(i), ans);
        } else {
            times(e[i].size(), j) {
                ans = min(solve(i, e[i][j]), ans);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

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

    // 1スタート
    vector<int> h(n+1);
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }

    // dp[i] = i番目までの最小のコスト
    int dp[n+1];
    for(int i=0; i<=n; i++) dp[i] = 100000000000;
    dp[1] = 0;
    for(int i=2; i<=n; i++){
        for(int j=1; j<=k; j++){
            // j 戻って外に出たらいけない。
            if(i - j >= 1){
                // k 通りの更新ができている。
                dp[i] = min(dp[i], dp[i-j]+abs(h[i-j] - h[i]));
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
import Data.Fixed

solve :: RealFrac a => [a] -> [String]
solve (_:_:_:_:_:_:[]) = []
solve (a:b:c:d:e:f:xs) = showSolution ((b*f-c*e)/(b*d-a*e)) ((a*f-c*d)/(a*e-b*d)) : solve xs
    where
        showSolution x y = showE3 x ++ " " ++ showE3 y
        showE3 x = show ((fromIntegral (round (1000 * x)) / 1000) :: Milli)

main = getContents >>= mapM_ putStrLn . solve . (++[0,0,0,0,0,0]) . map read . words

Measured memory_bytes: 4556
//                               //
    // author : samars_diary //
    // 17-09-2020 │ 16:02:11 //
//                               //

#include <iostream>
using namespace std;

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

    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int a;
    cin>>a;
    if (a>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

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

int n,m,maxx=0,var[4][2]={{1,0},{0,1},{-1,0},{0,-1}},xxx,yyy;
char tat[21][21];
bool b[21][21];
struct node
{
	int x,y,k;
};
queue<node>Q;
void clear(queue<node>&Q)
{
	queue<node>q;
	swap(q,Q);
}

void dfs(int x,int y,int k,bool way[4])
{
	maxx=max(k,maxx);
	for(int i=0;i<=3;i++)
	{
		if(way[i])continue;
		if(tat[x+var[i][0]][y+var[i][1]]=='.'&&!b[x+var[i][0]][y+var[i][1]])
		{
			way[i]=true;
			b[x+var[i][0]][y+var[i][1]]=1;
			dfs(x+var[i][0],y+var[i][1],k+1,way);
			way[i]=false;
		}
	}
}
void bfs(int x,int y)
{
	clear(Q);
	memset(b,0,sizeof(b));
	b[x][y]=1;
	node tm;
	tm.x=x;
	tm.y=y;
	tm.k=0;
	Q.push(tm);
	while(!Q.empty())
	{
		node cur=Q.front();
		Q.pop();
		maxx=max(maxx,cur.k);
		node tmp;
		tmp.k=cur.k+1;
		int x=cur.x,y=cur.y;
		for(int i=0;i<=3;i++)
		{
			if(x+var[i][0]>0&&x+var[i][0]<=n&&y+var[i][1]>0&&y+var[i][1]<=m&&tat[x+var[i][0]][y+var[i][1]]=='.'&&!b[x+var[i][0]][y+var[i][1]])
			{
				b[x+var[i][0]][y+var[i][1]]=1;
				tmp.x=x+var[i][0];
				tmp.y=y+var[i][1];
				Q.push(tmp);
			}
		}
	}
}
int main()
{
	bool b[4]={0,0,0,0};
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>tat[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(tat[i][j]=='.')
			{
				bfs(i,j);
				//cout<<maxx<<endl;
			}
	cout<<maxx;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }

    int cnt = 0;
    for (int i = 0; i < n - 2; i++)
    {
        if ((arr[i] < arr[i + 1] && arr[i + 1] < arr[i + 2]) || (arr[i] > arr[i + 1] && arr[i + 1] > arr[i + 2]))
        {
            cnt++;
        }
    }

    printf("%d\n", cnt);
    return 0;
}


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

#define ll long long
const char newl = '\n';

//***---***---***---Useless Code---***---***---***//

template<class T> void read(T &t) {
	cin >> t;
}
template<class A, class...B> void read(A& a, B&... b) {
	read(a);
	read(b...);
}
template<class T> void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(string s) { return s; }
string to_string(const char* str) { return string(str); }
string to_string(vector<bool> vt) {
	string ret;
	bool ft = 1;
	for(bool x : vt) {
		if(!ft)
			ret += ' ';
		ft = 0;
		ret += char('0' + x);
	}
	return ret;
}
template<class T> string to_string(vector<T> vt) {
	string ret;
	bool ft = 1;
	for(auto a : vt) {
		if(!ft)
			ret += ' ';
		ft = 0;
		ret += to_string(a);
	}
	return ret;
}

template<class T> void write(T t) {
	cout << to_string(t);
}
template<class A, class... B > void write(A a, B... b) {
	write(a);
	if(sizeof...(b))
		write(' ');
	write(b...);
}
void print() {
	write(newl);
}
template<class A, class... B> void print(A a, B... b) {
	write(a);
	if(sizeof...(b))
		write(' ');
	print(b...);
}

//***---***---***---Useless Code---***---***---***//

int n,k;

void solve() {
	read(n,k);
	ll a[n];
	vector<string> ans;
	for(int i = 0; i < n; ++i)
		read(a[i]);
	for(int i = 0; i + k < n; ++i) {
		ans.push_back(a[i] < a[i+k] ? "Yes" : "No");
	}
	print(ans);
}

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

	solve();
}


Measured memory_bytes: 31344
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&x)

	count := 0

	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				total := 500*i + 100*j + 50*k
				if total == x {
					count++
				}
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	int a;
	cin >> a;
	cout << a*a << endl;
}

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

int main() {
	string a;
	cin >> a;
	if(a.find("a") != string::npos){
		if(a.find("b") != string::npos){
			if(a.find("c") != string::npos){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main()
{
  int n;
  vector<int> vec_a;
  int diff;
  int diff_min;
  
  while (1) {
    cin >> n;
    if (n == 0) break;
    
    vec_a.clear();
    while (n--) {
      int a;
      cin >> a;
      vec_a.push_back(a);
    }
    
    sort(vec_a.begin(), vec_a.end());
    
    diff_min = 1000000;
    for (int i = 1; i != vec_a.size(); i++) {
      diff = vec_a.at(i) - vec_a.at(i - 1);
      if (diff < diff_min) diff_min = diff;
    }

    cout << diff_min << endl;
  }
}
      
  



Measured memory_bytes: 3148
#include <stdio.h>

int main(){
  int i,j,x,np,p[100000];
  p[0]=2;
  np=1;
  for(i=3;i<101000;i+=2){
    for(j=1;j<np;j++){
      if(i%p[j]==0) break;
    }
    if(j==np){
      p[np]=i;
      np++;
    }
  }
  scanf("%d",&x);
  for(i=0;p[i]<x;i++);
  printf("%d",p[i]);
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int k, x;
    cin >> k >> x;
    cout << (k*500>=x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define P pair<ll, ll>
#define INF 10e6
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

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

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> lst;
    rep(i, 0, n) lst.push_back(i);
    int ans = 0;
    do
    {
        if (lst[0] != 0)
            break;
        bool flag = true;
        rep(i, 0, n - 1) if (find(all(g[lst[i]]), lst[i + 1]) == g[lst[i]].end()) flag = false;
        if (flag)
            ans++;
    } while (next_permutation(all(lst)));
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

int N,C;
int s[100005],t[100005], c[100005];
int tm[31][100005];
int mx[31];

int main(){
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        cin >> s[i] >> t[i] >> c[i];
        for(int j = s[i]; j <= t[i]; j++)
            tm[c[i]][j] = 1;
        mx[c[i]] = max(t[i], mx[c[i]]);
    }

    int mx = 0;
    for(int i = 1; i <= 100005; i++){
        int cnt = 0;
        for(int j = 1; j <= C; j++){
            if(tm[j][i] == 1) cnt++;
        }
        mx = max(mx, cnt);
    }
    cout << mx << endl;
}



Measured memory_bytes: 13184
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int m;
    int n;
    int c;
    int sum;
    int ans = 0;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }

    for(int i=0; i<n; i++){
        sum = 0;
        for(int j=0; j<m; j++){
            sum += a[i][j]*b[j];
        }
        if(sum+c>0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 3000;
const int P = 998244353;
llong f[mxN+3][mxN+3];
int n1,m1,n2,m2;

int main()
{
	n1 = read(),m1 = read(),n2 = read(),m2 = read();
	for(int i=n1; i<=n2; i++) for(int j=m1; j<=m2; j++)
	{
		if(i==n1&&j==m1) {f[i][j] = 1ll;}
		else {f[i][j] = (j*f[i-1][j]+i*f[i][j-1]-(i-1)*(j-1)*f[i-1][j-1]%P+P)%P;}
	}
	printf("%lld\n",f[n2][m2]);
	return 0;
}

Measured memory_bytes: 73964
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1,0)),memoOfPre(n+1,vector<int>(m+1,0));
    string ans;
    rep(i,n){
        rep(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
                memoOfPre[i+1][j+1]=0;
            }
            else if(dp[i][j+1]>dp[i+1][j]){
                dp[i+1][j+1]=dp[i][j+1];
                memoOfPre[i+1][j+1]=2;//from i
            }
            else{
                dp[i+1][j+1]=dp[i+1][j];
                memoOfPre[i+1][j+1]=1;//from j
            }
        }
    }
    int a=n,b=m;
    while(a>0&&b>0){
        if(memoOfPre[a][b]==0){
            ans.push_back(s[a-1]);a--;b--;
        }
        else if(memoOfPre[a][b]==2){
            a--;
        }
        else{
            b--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70912
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

void fail(void) {
  cout << "IMPOSSIBLE" << endl;
  exit(0);
}

const int N = 1192;
int p[N], x[N];
VI child[N];
int opp[N];


int lux(int tot, const vector<PI> &dat) {
  int n = dat.size();
  vector<vector<bool> > dp(n + 1, vector<bool>(tot + 1, false));
  dp[0][0] = true;
  REP(i, 0, n) {
    int u = dat[i].first;
    int v = dat[i].second;
    REP(j, 0, tot + 1) {
      if (j >= u) {
	dp[i + 1][j] = dp[i + 1][j] || dp[i][j - u];
      }
      if (j >= v) {
	dp[i + 1][j] = dp[i + 1][j] || dp[i][j - v];
      }
    }
  }
  int sol = -1;
  REP(i, 0, tot + 1) {
    if (dp[n][i]) {
      sol = i;
    }
  }
  return sol;
}


void dfs(int v) {
  vector<PI> dat;
  int tot = 0;
  REP(i, 0, child[v].size()) {
    int w = child[v][i];
    dfs(w);
    dat.push_back(PI(x[w], opp[w]));
    tot += x[w] + opp[w];
  }
  int res = lux(x[v], dat);
  if (res < 0) {
    fail();
  }
  opp[v] = tot - res;
}


int main(void) {
  int n;
  cin >> n;
  p[0] = -1;
  REP(i, 1, n) {
    cin >> p[i];
    p[i]--;
    child[p[i]].push_back(i);
  }
  REP(i, 0, n) {
    cin >> x[i];
  }
  /*
  REP(i, 0, n) {
    // check a -> b -> i
    int b = p[i];
    if (b == -1) { continue; }
    int a = p[b];
    if (a == -1) { continue; }
    if (x[a] < x[b] && x[b] < x[i]) {
      fail();
    }
  }
  */
  dfs(0);
  cout << "POSSIBLE" << endl;
}


Measured memory_bytes: 384
import sys
s = list(input())
c = len(s)
if c%2 == 1:
    print("No")
    sys.exit()
else:
    for i in range(c//2):
        if s[2*i] != "h" or s[2*i+1] != "i":
            print("No")
            sys.exit()
print("Yes")

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

int N,ans=0;
map<ll,int> mp;

int main(){
  scanf("%d",&N);
  mp[0]=-1;

  ll x,y=0;
  for(int i=0;i<N;i++){
    scanf("%lld",&x);
    y+=x;
    if(mp.count(y)>0)ans=max(ans,i-mp[y]);
    if(mp.count(y)==0)mp[y]=i;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 15668
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n;
	vector<ll> v, v2;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		v.push_back(a);
		v2.push_back(a);
	}

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

	ll x = (v2[n / 2] + v2[n / 2 - 1]);

	REP(i, n) {
		if (v[i] * 2 < x) {
			cout << v2[n / 2] << endl;
		}
		else {
			cout << v2[n / 2 - 1] << endl;
		}
	}
}

Measured memory_bytes: 5476
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int N;
	while (1) {
		cin >> N;
		if (!N)break;
		VI w(N);
		int dp[310][310];
		REP(i, 310)REP(j, 310)dp[i][j] = 0;
		REP(i, N) cin >> w[i];
		eFOR(W, 2, N) {
			REP(i, N) {
				int r = i + W;
				if (r > N)continue;
				if (dp[i + 1][r - 1] == W - 2 && abs(w[i] - w[r - 1]) <= 1)
					dp[i][r] = W;
				eFOR(mid, i, r) {
					dp[i][r] = max(dp[i][r], dp[i][mid] + dp[mid][r]);
				}
			}
		}
		/*eREP(i, N) {
			eREP(j, N)cout << dp[i][j] << " ";
			cout << endl;
		}*/
		cout << dp[0][N] << endl;


	}
	
	return 0;
}




Measured memory_bytes: 3908
import math
N = int(input())
A = list(map(int, input().split()))

def percent_2(x):
	x = x % 2
	return x

def slash_2(x):
	x = x / 2
	return x
ans = 0

for i in range(10000000000000000):
	if sum(list(map(percent_2, A))) == 0:
		ans += 1
		A = list(map(slash_2, A))
	else:
		break
print(ans)


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

#define MOD 1000000007
// #define INF 100000000000

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int K;
    cin >> K;
    string S;
    cin >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}


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

Measured memory_bytes: 128
#include <cstdio>
#include <cassert>
#include <algorithm>

int testcase_ends() {
  int R0, W0, C, R;
  scanf("%d %d %d %d", &R0, &W0, &C, &R);
  if (R0 == 0 && W0 == 0 && C == 0 && R == 0) return 1;

  for (int X = 0; X <= 100000; ++X) {
    int CY = X*R + R0 - C*W0;
    if (CY < 0) continue;
    return !printf("%d\n", X);
  }
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if(N * A > B) {
		cout << B << endl;
	}
	else if (N * A < B) {
		cout << N * A << endl;
	}
	else {
		cout << B << endl;
	}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a%2 == 1 && b%2 == 1){
			System.out.println("Odd");
		}else {
			System.out.println("Even");
		}

	}

}


Measured memory_bytes: 21716
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll ans=0;
    ll bb=0;
    rep(i,n){
        ll a,b;
        cin>>a>>b; 
        if(a>bb){
            bb=a;
            ans=a+b;
        }
    }
    cout<<ans<<"\n";
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  char a, b, c, d;
  a = S.at(0);
  b = S.at(1);
  c = S.at(2);
  d = S.at(3);
  int count = 0;
  
  if (a == b) {
    count++;
  }
  if (a == c) {
    count++;
  }
  if (a == d) {
    count++;
  }
  
  if (b == a) {
    count++;
  }
  if (b == c) {
    count++;
  }
  if (b == d) {
    count++;
  }
  
  if (c == a) {
    count++;
  }
  if (c == b) {
    count++;
  }
  if (c == d) {
    count++;
  }
  
  if (d == a) {
    count++;
  }
  if (d == b) {
    count++;
  }
  if (d == c) {
    count++;
  }
  
  if (count == 4) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
import sys
n=int(input())
a=[0]*n
a=list(map(int,input().split()))
judge=True
for i in range(0,n):
  if a[i]%2==0:
    if a[i]%3==0 or a[i]%5==0:
      pass
    else:
      judge=False
      print("DENIED")
      sys.exit()
if judge==True:
  print("APPROVED")

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<pair<ll,ll> >vepa;
typedef set<string>se;
typedef map<int ,int> mpp;
const int N=1e5+5 ,OO=1e18;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
ll TC,n,mx,arr[N];
bool vis[N],f;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
      ll a ,v,b,w,t;
      cin>>a>>v>>b>>w>>t;
      if(a>b)
        swap(a,b);
      if(b-a<=(v-w)*t)
        cout<<"YES";
      else
        cout<<"NO";
go;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <deque>
#include <set>
#include <map>
using namespace std;
typedef long long int lli;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000000
#define IOS ios_base::sync_with_stdio(0); cin.tie(0) //making cin faster
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FOR_R(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define REP_R(i,n)   FOR_R(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SIZ(x) ((int)(x).size())
//int IsPrime(int Nvrbl){int i;if(Nvrbl<2){return 0;}else if(Nvrbl==2){return 1;}else if(Nvrbl%2==0){return 0;}for(i=3;i<=sqrt(Nvrbl);i+=2){if(Nvrbl%i==0){return 0;}}return 1;} // 1 for prime, 0 for not prime

int sortselection(vector<int>&,int);

int main(void)
{
  
  int N;
  cin >> N;
  
  vector<int> A(N);

  int cnt;
  
  REP(i,N)
    {
      cin >> A[i];
      
    }

  cnt = sortselection(A,N);

  REP(i,N)
    {
      if( i != N-1 )
	{
	  cout << A[i] << " " ;
	}
      else
	{
	  cout << A[i] << "\n" ;
	}
    }

  cout << cnt << "\n" ;
  
  
}

int sortselection(vector<int>& A, int N)
{
  int cnt = 0;
  int mini;
  
  
  REP(j,N-1)
    {
      mini = j;

      FOR(i,j+1,N)
	{
	  if( A[i] < A[mini] )
	    {
	      mini = i;
	      
	    }
	}

      if( mini != j )
	{
	  swap(A[j],A[mini]);
	  ++ cnt;
	  

	}
      
    }

  return cnt;
  
  
}



Measured memory_bytes: 3096