akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int MAX = 1000;
constexpr int VMAX = 2005;

int n, q;
int A[MAX];
bool dp[MAX][VMAX];
bool vis[MAX][VMAX];

//使用从第i个数及后面的数能否得到m
bool solve(int i, int m) {
    if (vis[i][m])   return dp[i][m];
    if (m == 0) { 
        vis[i][m] = true;
        return dp[i][m] = true; 
    }
    if (i >= n) {
        vis[i][m] = true;
        return false;
    }
    return solve(i + 1, m) || solve(i + 1, m - A[i]);
}


int main() {
    memset(dp, 0, sizeof(dp));
    memset(vis, 0, sizeof(vis));
    scanf("%d", &n);
    for (int i = 0; i < n; i++)    scanf("%d", &A[i]);
    scanf("%d", &q);
    int m;
    while (q--) {
        scanf("%d", &m);
        if(solve(0, m)) printf("yes\n");
        else        printf("no\n");
    }
     

    //system("pause");
    return 0;
}


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

int main() {
  
  int a=0, b=0, c=0;
  
  cin >> a >> b >> c;
  
  int sum1 = a+b;
  int sum2 = a+c;
  int sum3 = b+c;
  
  int ans = min(sum1, min(sum2, sum3));
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long h = scanner.nextInt();
        long w = scanner.nextInt();
        int n = scanner.nextInt();
        Map<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long a = scanner.nextInt();
            long b = scanner.nextInt();

            for (int dx = -1; dx <= 1; dx++) {
                for (int dy = -1; dy <= 1; dy++) {
                    if ((b + dx) > 1 && (b + dx) < w && (a + dy) > 1 && (a + dy) < h) {
                        map.compute((b + dx) * h + (a + dy), (key, value) -> value == null ? 0 : value + 1);
                    }
                }
            }
        }

        long sum = 0;
        int[] count = new int[9];
        for (int i : map.values()) {
            count[i]++;
            sum++;
        }
        System.out.println((h - 2) * (w - 2) - sum);
        Arrays.stream(count).forEach(System.out::println);
    }
}

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

a,b,c= map(int, input().split())
d= int(gcd(a,b))
if c==1:
  print(d)
else:
  arr=[]
  for i in range(1,d):
    if(d%i == 0):
      arr.append(i)
  print(arr[-(c-1)])
  

Measured memory_bytes: 3060
#include<stdio.h>

int main() {
   int n, x, i, j, k;

   while (1) {
      int c = 0;
      scanf("%d %d", &n, &x);

      if (n == 0 && x == 0) {
         break;
      }

      for (i = 1; i <= n - 2; i++) {
         for (j = i + 1; j <= n - 1; j++) {
            for (k = j + 1; k <= n; k++) {
               if (i + j + k == x) {
                  c++;
               }
            }
         }
      }
      printf("%d\n", c);
   }
   return 0;
}


Measured memory_bytes: 2140
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	vs, cs := make([]int, n), make([]int, n)
	for i := range vs {
		fmt.Scan(&vs[i])
	}
	for i := range cs {
		fmt.Scan(&cs[i])
	}

	ans := 0
	for i := range vs {
		if vs[i]-cs[i] > 0 {
			ans += vs[i] - cs[i]
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
bool dame,flag;

int main(){
	cin >> a >> b;
	p(a*b/2);
	return 0;
}

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

char S[200009];

int main() {
    scanf("%s", S+1);
    long long ans = 0;
    int N = strlen(S+1), c = 0;
    for(int i=1; i<N; i++) {
        if(S[i] == 'A') ++c;
        else if(S[i] == 'B' && S[i+1] == 'C') ans += c, ++i;
        else c = 0;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=2e5+20;

vector<int>ed[maxn];

int n,fa[maxn];
int mx[maxn],cmx[maxn],son[maxn];

void dfs(int u)
{
	for(int v:ed[u])
	{
		if(v==fa[u])continue;
		mx[v]=mx[u]; cmx[v]=cmx[u];
		if(v>mx[v])cmx[v]=mx[v],mx[v]=v;
		else if(v>cmx[v])cmx[v]=v;
		fa[v]=u;

		if(mx[v]==v);
		else if(mx[u]==u)son[v]=v;
		else son[v]=son[u];
		
		dfs(v);
	}
}


inline void init()
{
	n=read();
	REP(i,1,n-1)
	{
		int u=read(),v=read();
		ed[u].push_back(v);
		ed[v].push_back(u);
	}
	mx[1]=1; cmx[1]=0;
	dfs(1);
}

struct Node {
	int s1,s2,ls,rs;
};
Node c[maxn<<6];
int ctot;

int rt[maxn];

void update(int x,int d1,int d2,int &o,int l,int r)
{
	if(!o)o=++ctot;
	c[o].s1+=d1; c[o].s2+=d2;
	if(l==r)return;
	int mid=l+r>>1;
	if(x<=mid)update(x,d1,d2,c[o].ls,l,mid);
	else update(x,d1,d2,c[o].rs,mid+1,r);
}

int Merge(int x,int y)
{
	if(!x || !y)return x|y;
	c[x].s1+=c[y].s1; c[x].s2+=c[y].s2;
	c[x].ls=Merge(c[x].ls,c[y].ls);
	c[y].rs=Merge(c[x].rs,c[y].rs);
	return x;
}

struct Query {
	int x,op,id;
};

int query1(int x,int o,int l,int r)
{
	if(!o)return 0;
	if(l==r)return c[o].s1;
	int mid=l+r>>1;
	if(x<=mid)return query1(x,c[o].ls,l,mid);
	else return query1(x,c[o].rs,mid+1,r);
}

int query2(int x,int o,int l,int r)
{
	if(!o)return 0;
	if(l==r)return c[o].s2;
	int mid=l+r>>1;
	if(x<=mid)return query2(x,c[o].ls,l,mid);
	else return query2(x,c[o].rs,mid+1,r);
}

int ans[maxn];
vector<Query>Qu[maxn];

void dfs1(int u)
{
	if(mx[u])update(mx[u],1,0,rt[u],1,n);
	if(cmx[u])update(cmx[u],0,1,rt[u],1,n);
	for(int v:ed[u])
	{
		if(v==fa[u])continue;
		dfs1(v);
		rt[u]=Merge(rt[u],rt[v]);
	}
	for(Query t:Qu[u])
	{
		int x=t.x,op=t.op,id=t.id;
		if(op)ans[id]+=op*query2(x,rt[u],1,n);
		else ans[id]+=query1(x,rt[u],1,n);
	}
}

void dfs2(int u)
{
	ans[u]+=ans[fa[mx[u]]];
	for(int v:ed[u])if(v!=fa[u])dfs2(v);
}

void doing()
{
	REP(u,2,n)
	{
		if(mx[u]==u)
		{
			Qu[u].push_back((Query){cmx[u],1,u});
		}else
		{
			Qu[son[u]].push_back((Query){cmx[mx[u]],-1,u});
			Qu[son[u]].push_back((Query){mx[u],0,u});
			Qu[mx[u]].push_back((Query){cmx[mx[u]],1,u});
		}
	}
	dfs1(1);
	dfs2(1);
	REP(i,2,n)printf("%d ",ans[i]);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 139904
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	string a, b;

	cin >> a >> b;

	if (a[0] == 'H') {
		if (b[0] == 'H') {
			cout << "H" << endl;
		}
		else {
			cout << "D" << endl;
		}
	}
	else {
		if (b[0] == 'H') {
			cout << "D" << endl;
		}
		else {
			cout << "H" << endl;
		}

	}








	getchar();
	getchar();
	return 0;
}

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

const int MOD = 1000000007;

int main() {
    int N, M; cin >> N >> M;
    vector<bool> is_safe(N+1, true);
    for(int i = 0; i < M; ++i) {
        int a; cin >> a;
        is_safe[a] = false;
    }
    
    vector<int> dp(N+2, 0);
    dp[0] = 1;
    for(int i = 0; i < N; ++i) {
        if(is_safe[i]) dp[i+1] += dp[i], dp[i+1] %= MOD;
        if(is_safe[i]) dp[i+2] += dp[i], dp[i+2] %= MOD;
    }
    
    cout << dp[N] << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL K;
LL X[200011];

const int LOG = 18;
int Right[LOG][200011];
LL RightCnt[LOG][200011];
LL RightSum[LOG][200011];

int Left[LOG][200011];
LL LeftCnt[LOG][200011];
LL LeftSum[LOG][200011];

void MAIN() {
    scanf("%d%lld", &N, &K);
    REP (i, N) scanf("%lld", X+i);

    for (int i=0, j=0; i<N; i++) {
	while (j < N && X[j] - X[i] < K) j++;
	Right[0][i] = j;
	RightCnt[0][i] = j - i;
	RightSum[0][i] = j - i;
    }

    Right[0][N] = N;
    REP (t, LOG-1) {
	REP (i, N+1) {
	    int s = Right[t][i];
	    Right[t+1][i] = Right[t][s];
	    RightCnt[t+1][i] = RightCnt[t][i] + RightCnt[t][s];
	    RightSum[t+1][i] = RightSum[t][i] + RightSum[t][s] + (RightCnt[t][s] << t);
	}
    }

    for (int i=N-1, j=N-1; i>=0; i--) {
	while (j >= 0 && X[i] - X[j] < K) j--;
	Left[0][i] = j;
	LeftCnt[0][i] = i - j;
	LeftSum[0][i] = i - j;
    }
    REP (t, LOG-1) {
	REP (i, N) {
	    int s = Left[t][i];
	    if (s == -1) {
		Left[t+1][i] = -1;
		LeftCnt[t+1][i] = LeftCnt[t][i];
		LeftSum[t+1][i] = LeftSum[t][i];
	    } else {
		Left[t+1][i] = Left[t][s];
		LeftCnt[t+1][i] = LeftCnt[t][s] + LeftCnt[t][i];
		LeftSum[t+1][i] = LeftSum[t][s] + LeftSum[t][i] + (LeftCnt[t][i] << t);
	    }
	}
    }

    int Q;
    scanf("%d", &Q);
    REP ($, Q) {
	int L, R;
	scanf("%d%d", &L, &R);
	L--;

	LL ans = 0;
	{
	    int cur = L;
	    LL mult = 0;
	    LL sum = 0;
	    for (int t=LOG; t--;) {
		int s = Right[t][cur];
		if (s != N && s <= R) {
		    sum += RightSum[t][cur] + RightCnt[t][cur] * mult;
		    mult += 1LL<<t;
		    cur = s;
		}
	    }
	    sum += (R - cur) * (mult + 1);

	    ans += sum;
	}

	{
	    int cur = R-1;
	    LL cnt = 0;
	    LL sum = 0;
	    for (int t=LOG; t--;) {
		int s = Left[t][cur];
		if (L <= s) {
		    sum += LeftSum[t][cur] + cnt * (1LL<<t);
		    cnt += LeftCnt[t][cur];
		    cur = s;
		}
	    }

	    ans -= sum;
	}
	
	printf("%lld\n", ans);
    }

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 146020
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
    int key;
    struct node *next;
    struct node *prev;
};

typedef struct node * Node;
Node nil;

Node listSerch(int key){
    Node cur = nil -> next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
        return cur;
}
    
void init(){
    nil = malloc(sizeof(struct node));
    nil -> next = nil;
    nil -> prev = nil;
}

void printlist(){
    Node cur = nil -> next;
    int isf = 0;
    while(1) {
        if (cur == nil )break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur -> key);
        cur = cur -> next; 
    }
    printf("\n");
}

void deleteNode(Node t){
    if ( t == nil ) return;
    Node a = t -> prev, b = t -> next;
    a -> next = t -> next;
    b -> prev = t -> prev;
    free(t);
}

void deleteFirst(){
    Node t = nil -> next;
    deleteNode(t);
}

void deleteLast(){
    Node t = nil -> prev;
    deleteNode(t);
}

void deletekey(int key){
    Node t = listSerch(key);
    deleteNode(t);
}

void insert(int key){
    Node x;
    x = malloc(sizeof(struct node));
    x->key = key;
    nil->next->prev = x;
    x->next = nil->next;
    x->prev = nil;
    nil->next = x;
}

int main(){
    int key, n, i;
    char com[10];
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++ ){
        scanf("%s%d" , com, &key);
        if( com[0] == 'i') {insert(key);}
        else if(com[0] == 'd') {
            if( strlen(com) > 6) {
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L')deleteLast();
            }else {
                deletekey(key);
            }
        }
    }

    printlist();
    return 0;
}


Measured memory_bytes: 32972
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

int main() {
  int N;
  string S;
  cin >> N >> S;
  string OL_S;
  
  OL_S.push_back(S.at(0));
  for (int i = 1; i < N; ++i) {
    if(S.at(i) != S.at(i-1)) OL_S.push_back(S.at(i)); 
  }
  cout << OL_S.size() << endl;
}

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

#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
     int a,b,c;cin>>a>>b>>c;
     if(a==b&&a!=c)cout<<"Yes"<<endl;
     else if(a==c&&a!=b)cout<<"Yes"<<endl;
     else if(c==b&&b!=a)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	int N;
	cin >> N;
	vector<ll> a(N);

	ll count = 0;
	rep(i, N) {
		ll n = 0;
		cin >> n;
		a[i] = n;
		if (n < 0) count++;
	}

	ll max = 0;
	if (count % 2 == 0) {
		rep(i, N) {
			max += abs(a[i]);
		}
	} else {
		ll min = ll(1e9);
		rep(i, N) {
			if (min > abs(a[i])) min = abs(a[i]);
		}

		rep(i, N) {
			if (abs(a[i]) == min) max -= min*2;
			max += abs(a[i]);
		}
	}

	cout << max << endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var n = int.Parse(str);
            var count = count753("", n);
            Console.WriteLine(count);
        }

        static int count753(string s, long max){

            if (s.Length > 0 && long.Parse(s) > max)
            {
                return 0;
            }

            const string baseValue ="753";
            bool is753 = s.Contains("7") && s.Contains("5") && s.Contains("3");
            int count = 0;
            if (is753)
            {
                count++;
            }

            for(int i = 0; i < baseValue.Length; i++){
                count += count753(s + baseValue[i], max);
            }

            return count;
            
        }
    }
}


Measured memory_bytes: 15184
N = int(input())
S = input()
Rnum = 0
Gnum = 0
Bnum = 0
for i in S:
    if i == 'R':
        Rnum += 1
    elif i == 'G':
        Gnum += 1
    else:
        Bnum += 1

ans = Rnum*Gnum*Bnum

for i in range(1, N//2 + 1):
    for j in range(N):
        if j + 2*i >= N:
            break
        else:
            if S[j] != S[j+i] and S[j+i] != S[j+2*i] and S[j] != S[j+2*i]:
                ans -= 1

print(ans)

Measured memory_bytes: 73784
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int mini = 1001, maxi = -1;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        mini = min(mini, a);
        maxi = max(maxi, a);
    }
    cout << maxi-mini << endl;
    return 0;
}

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

int main() {
  int a,b,c,d;
  c=0;
  b=0;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>d;
    if(d%2==0){
      c++;
    }
    else{
      b++;
    }
  }
  if(c==0||b==0){
    cout<<"YES"<<endl;
  }
  else if(b%2==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main() {
  int a,b,c,d,A,B;
  cin>>a>>b>>c>>d;
  A=(c-1+b)/b;
  B=(a-1+d)/d;
  if(A<=B){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == a[1] || a[1] == a[2]) {
		if (a[0] != a[2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
n, l = map(int, input().split())
pix = [l + i -1 for i in range(1, n+1)]
if 0 in pix:
    print(sum(pix))
elif pix[-1] < 0:
    print(sum(pix)- pix[-1])
else:
    print(sum(pix) - l )

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(X,A,B) for(int X=A;X<=B;++X)
#define tep(X,A,B) for(int X=A;X>=B;--X)
#define LL long long
const int N=5010;
const int M=100010;
const LL MOD=1e9+7;
using namespace std;

int n,sz[N];
LL f[N][N][2],g[N],flp[N][2];
int edge[M],lst[N],nxt[M],t=0;

void ADD(int x,int y){
	edge[++t]=y;nxt[t]=lst[x];lst[x]=t;
}

void READ(){
	int u,v;
	scanf("%d",&n);
	rep(i,1,n-1){
		scanf("%d%d",&u,&v);
		ADD(u,v);ADD(v,u);
	}
}

void INIT(){
	g[0]=1;
	for(int i=2;i<=n;i+=2){
		g[i]=g[i-2]*(i-1)%MOD;
	}
}

void SEARCH(int x,int pa){
	sz[x]=1;
	f[x][1][0]=1;
	for(int r=lst[x];r;r=nxt[r]){
		int pos=edge[r];
		if(pos==pa)continue;
		SEARCH(pos,x);
		rep(i,1,sz[x]+sz[pos])rep(j,0,1)flp[i][j]=0;
		rep(i,1,sz[x])rep(j,1,sz[pos]){
			rep(a,0,1)rep(b,0,1){
				if(!f[x][i][a]||!f[pos][j][b])continue;
				LL hlp=f[x][i][a]*f[pos][j][b]%MOD;
				flp[i+j][a^b]+=hlp;
				flp[i+j][a^b]%=MOD;
				if(!(j&1)){
					flp[i][a^b^1]+=hlp*g[j]%MOD;
					flp[i][a^b^1]%=MOD;
				}
			}
		}
		rep(i,1,sz[x]+sz[pos])rep(j,0,1)f[x][i][j]=flp[i][j];
		sz[x]+=sz[pos];
	}
}

void SOLVE(){
	LL ans=0;
	for(int i=2;i<=n;i+=2){
		ans=(ans+f[1][i][0]*g[i]%MOD)%MOD;
		ans=(ans-f[1][i][1]*g[i]%MOD+MOD)%MOD;
	}
	printf("%lld\n",ans);
}

int main(){
	READ();
	INIT();
	SEARCH(1,0);
	SOLVE();
	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, n; std::cin >> h >> n;
  int sum = 0;
  rep(i, n) {
    int a; std::cin >> a;
    sum += a;
  }
  std::cout << (h <= sum ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char a=sc.next().charAt(0),b=sc.next().charAt(0);
    int na=0,nb=0;
    if(a=='H'){
      na=1;
    }else{na=-1;}
    if(b=='H'){
      nb=1;
    }else{nb=-1;}
    if(na*nb>0){
      System.out.println('H');
    }else{
      System.out.println('D');
    }
  }
}


Measured memory_bytes: 21844
n, m = [int(_) for _ in input().split(' ')]
c = [[int(_) for _ in input().split(' ')] for __ in range(n)]
c.sort(key = lambda x: x[0])

d = 0
answer = 0
for i in range(n):
    a, b = c[i]
    if d + b < m:
        d += b
        answer += a * b
    else:
        answer += a * (m - d)
        break
print(answer)


Measured memory_bytes: 22756
import java.io.*;
import java.util.*;
public class Main {

    static int solve(int[] arr, int s, int k, HashMap<Integer, Integer>  map) {
        if(s == arr.length - 1)
            return 0;
            
        if(map.containsKey(s))
            return map.get(s);
            
        int sum = Integer.MAX_VALUE;
        for(int i = 1; i <= k; i++) {
            if(s + i < arr.length) {
                sum = Math.min(sum, solve(arr, s + i, k, map) + Math.abs(arr[s] - arr[s + i]));
            }
        }
        
        map.put(s, sum);
        return sum;
    }
   public static void main(String args[]) {
       int n = 0;
       int k = 0;
       int[] arr = null;
       try (Scanner scanner = new Scanner(System.in)) {
           n = scanner.nextInt();
           k = scanner.nextInt();
           arr = new int[n];
           for (int i=0; i < n; i++) {
               arr[i] = scanner.nextInt();
           }
       }
       int ret = solve(arr, 0, k, new HashMap());
       System.out.println(ret);
   }
}


Measured memory_bytes: 176112
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
	int a,b,c,d;
	int s;
	cin>>a >>b >>c >>d;
	if (a < b)
		s+=a;
	else
		s+=b;

	if (c < d)
		s+=c;
	else
		s+=d;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
from itertools import accumulate
def input(): return sys.stdin.readline().strip()


def main():
    """
    全部の番組に対して、例えば[2, 4)->[1, 4)のように録画準備時間を確保してたけど、
    同一チャンネルなら、例えば[2, 4), [4, 6)のように続く場合レコーダーは１台で十分。。
    """
    N, C = map(int, input().split())
    channel = [[] for _ in range(C)]
    for _ in range(N):
        s, t, c = map(int, input().split())
        channel[c - 1].append((s, t))
    
    schedule = [0] * (10**5 + 3)
    for c in range(C):
        channel[c].sort()
        channel[c] = deque(channel[c])
        if not channel[c]: continue
        pre_s, pre_t = channel[c].popleft()
        while channel[c]:
            if pre_t == channel[c][0][0]:
                pre_t = channel[c][0][1]
                channel[c].popleft()
                continue
            schedule[pre_s - 1] += 1
            schedule[pre_t] -= 1
            pre_s, pre_t = channel[c].popleft()
        schedule[pre_s - 1] += 1
        schedule[pre_t] -= 1
    total = accumulate(schedule)
    print(max(total))

        
    



if __name__ == "__main__":
    main()


Measured memory_bytes: 81784
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main() {
  unsigned long int N, K;
  std::cin >> N >> K;
  std::vector<unsigned long int> A(N);
  for(auto& e : A) { std::cin >> e; }
  
  long int sum = 0;
  for(long int k=1 ; k<=K ; ++k) {
    sum += k%(1000000000+7);
  }

  unsigned long int ans = 0;
  for(int i = N-1 ; i >=0 ; --i) {
    for(int j = N-1 ; j >= 0 ; --j) {
      if(A[i] > A[j]) {
        if(i<j) {
          ans += sum;
          ans %= 1000000000+7;
        }
        else {
          ans += sum-K;
          ans %= 1000000000+7;
        }
      }
    }
  }
  std::cout << ans << std::endl;
}
  

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	List<Integer> prime = new ArrayList<>();
	int tri[] = { 0, 1, 3, 6, 10, 15, 21, 28, 36, 45 };

	public void main(Scanner sc) {
		prime.add(2);
		for (int i = 3; i <= 1000000; i += 2) {
			boolean flag = true;
			for (int j = 2; j * j <= i; j++) {
				if (i % j == 0) {
					flag = false;
				}
			}

			if (flag) {
				prime.add(i);
			}
		}

		long n = sc.nextLong();
		int ans = 0;
		for (int p : prime) {
			int cnt = 0;
			if (n % p == 0) {
				while (n % p == 0) {
					n /= p;
					cnt++;
				}
			}

			for (int i = 0; i < 10; i++) {
				if (tri[i] > cnt) {
					ans += (i - 1);
					break;
				}
			}
		}

		if (n != 1) {
			ans++;
		}

		System.out.println(ans);
	}

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


Measured memory_bytes: 40168
import java.util.*;
import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>(n);
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list = list.stream().distinct().collect(Collectors.toList());
		System.out.println(list.size());
	}
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

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

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int N = 5e5 + 1e3;

int n, L, fr = 1, tl;

struct water {
	double s; long long v;
	water(double s_ = 0, long long v_ = 0): s(s_), v(v_) {};
	inline water friend operator + (const water &lhs, const water &rhs) {
		return lhs.v + rhs.v != 0 ? water((lhs.s * lhs.v + rhs.s * rhs.v) / (lhs.v + rhs.v), lhs.v + rhs.v) : water();
	}
	inline water friend operator - (const water &lhs, const water &rhs) {
		return lhs.v - rhs.v != 0 ? water((lhs.s * lhs.v - rhs.s * rhs.v) / (lhs.v - rhs.v), lhs.v - rhs.v) : water();
	}
	inline water& operator -= (const water &rhs) { return *this = *this - rhs; }
	inline water& operator += (const water &rhs) { return *this = *this + rhs; }
} q[N], res, now;

int main () {

	File();

	n = read(); L = read();
	For (i, 1, n) {
		now.s = read(); now.v = read(); res += now;
		for (; fr <= tl && res.v > L; ++ fr) {
			if (res.v - L >= q[fr].v) res -= q[fr];
			else {
				water tmp = water(q[fr].s, res.v - L);
				q[fr] -= tmp; res -= tmp; break;
			}
		}
		for (q[++ tl] = now; fr + 1 <= tl && q[tl].s < q[tl - 1].s; -- tl) q[tl - 1] += q[tl];
		printf ("%lf\n", res.s);
	}

	return 0;

}

Measured memory_bytes: 16384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1){
        cin >> a.at(i);
    }
    
    ll count = 1;
    vector<ll> upper(n+1);
    upper.at(0) = 1;
    ll INF = 4223372036854775807;
    for(ll i=1; i<n+1; i++){
        count = min(INF, (count - a.at(i-1)) * 2);
        upper.at(i) = count;
    }
    
//    rep(i,n+1){
//        dunk(upper.at(i));
//    }
    
    ll sum = a.at(n);
    ll current = a.at(n);
    bool judge = true;
    
    if(current>upper.at(n)) judge=false;
    
    if(judge){
        for(ll i=n-1; i>=0; i--){
            current += a.at(i);
            if(current>upper.at(i)){
                if(ll((current+1)/2) > upper.at(i)){
                    judge = false;
                    break;
                }
                else{
                    current = upper.at(i);
                }
            }
            sum += current;
        }
    }
    
    if(judge) dunk(sum);
    else dunk("-1");
    
    return 0;
}



Measured memory_bytes: 4752
a, b = map(int, input().split())
res = ''
if b >= 0:
    if a <= 0:
        res = 'Zero'
    else:
        res = 'Positive'
else:
    if (b - a) % 2 == 0:
        res = 'Negative'
    else:
        res = 'Positive'
print(res)

Measured memory_bytes: 9120
#include <stdio.h>
int main(void){
    int a, b, N, s[100]={}, f[100]={}, i, x=0;
    scanf("%d %d %d", &a, &b, &N);
    for(i=0; i<N; i++){
        scanf("%d %d", &s[i], &f[i]);
        if(b > s[i] && a < f[i]){
            x=1;
            break;
        }
    }
    if(x == 1) printf("1\n");
    else printf("0\n");
    return 0;
}



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

using namespace std;

int solve(int x, int y, int z) {
	if (!x && !y) return 0;
	if (z & 1) return solve(x >> 1, y >> 1, z >> 1);
	if (y & 1) return solve(z >> 1, y >> 1, x >> 1) + solve((x | y | z) >> 1, 0, 0) + 1;
	if (x & 1) return solve(x >> 1, y >> 1, z >> 1) + 2 * solve((x | y | z) >> 1, 0, 0) + 2;
}

int main() {
	int n, m;
	while (cin >> n >> m, n + m) {
		int c[3] = {};
		for (int i = 0; i < 3; ++i) {
			int t; cin >> t;
			for (int j = 0; j < t; ++j) {
				int a; cin >> a;
				c[i] |= 1 << a - 1;
			}
		}
		int ans = min(solve(c[0], c[1], c[2]), solve(c[2], c[1], c[0]));
		cout << (ans <= m ? ans : -1) << endl;
	}
		
	return 0;
}


Measured memory_bytes: 2988
import sys,bisect

from sys  import stdin,stdout

from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right

from math import gcd,ceil,floor,sqrt

from collections import Counter,defaultdict,deque,OrderedDict

dx=[-1,1,0,0]
dy=[0,0,1,-1]


sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7

def isPrime(n):
    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def CC(d,v,i,l):
    v[i]=True
    stack=[i]
    c=1
    while stack:
        a=stack.pop()
        for i in d[a]:
            if not v[i]:
                stack.append(i)
                v[i]=True
                c+=1
    l.append(c)
    
def solve():
    n,m=mp()
    d={i:[] for i in range(1,n+1)}
    for i in range(m):
        a,b=mp()
        d[a].append(b)
        d[b].append(a)

    v=[False for i in range(n+1)]
    x=[]
    for i in range(1,n+1):
        if not v[i]:
            CC(d,v,i,x)
           
    pr(max(x))
        
        
    
for _ in range(1):
    solve()



Measured memory_bytes: 119184
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextByte();
    int y = sc.nextByte();
    sc.close();
    if((y & 1) == 0) {
      int t = (y/2) - x;
      int c = x - t;
      if(c < 0 || t < 0) {
        System.out.println("No");
      } else {
        if(((4*t) + (2*c)) == y) System.out.println("Yes");
      }
    } else {
      System.out.println("No");    
    }
  }
}

Measured memory_bytes: 35652
import math

X, K, D = map(int, input().split())

X = abs(X)

cand = math.floor(X / D)

min_v = 0

if cand > K:
    min_v = X - (K * D)
else:
    if cand % 2 == K % 2:
        min_v = X - cand * D
    else:
        min_v = abs(X - (cand + 1) * D)

print(min_v)

Measured memory_bytes: 9172
N = int(input())
a = [""]*N

text = input()
k = 0
for x in text:
    if x == " ":
        k = k+1
    else:
        a[k] = a[k]+x

dic ={}
def judge():
    for i in range(N):
        if (a[i] in dic.keys())==True:
            return "NO"
        else:
            dic[a[i]] = 1
    return "YES"

print(judge())


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

using namespace std;

long long gcd(long long a,long long b){
return a%b==0?b:gcd(b,a%b);
}



int main() {
string x;
cin>>x;
string y=x.substr(0,x.size()-8);
cout<<y<<endl;
return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint MOD = 1000000007;
	lint N;
	cin >> N;
	vector<lint>vec(N);
	for (int j = 2; j <= N; j++) {
		lint n = j;
		for (int i = 2; i <= j; i++) {
			while (n % i == 0) {
				n /= i;
				vec[i - 1]++;
			}
		}
	}
	lint ans = 1;
	rep(i, N) {
		ans *= (vec[i] + 1);
		ans %= MOD;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
import collections
N=int(input())
a=list(map(int,input().split()))
l=[]
if max(a)==0:
    print("Yes")
elif (N%3)==0:
    c=collections.Counter(a)
    values = list(c.values())  # aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
    key = list(c.keys())  # 先のvalue値に相当する要素のリスト(要素1,要素2,…)
    for i in range(len(key)):
        l.append([key[i], values[i]])  # lは[要素i,n_i]の情報を詰めたmatrix
    l.sort(key=lambda x:x[1],reverse=True)
    #print(l)
    if (len(l)==3)and(l[0][1]==l[1][1]==l[2][1])and(l[0][0]^l[1][0]==l[2][0]):
        print("Yes")
    elif (len(l)==2)and(l[0][1]==2*l[1][1])and(l[1][0]==0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

using namespace std;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
	unsigned long long result = a;
	unsigned long long k = 0;
	unsigned long long n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while(k != 0);
	return result;
}

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

unsigned long long lcm_n(vector<unsigned long long> &numbers) {
	unsigned long long l;
    unsigned long long g;
    l = numbers[0];
    for (unsigned long long i = 1; i < numbers.size(); i++) {
		l = lcm(l, numbers[i]);
	}
	return l;
}

int main(){

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

    unsigned long long n;
    cin >> n;
    vector<unsigned long long> t(n);
    for (int i = 0; i < n;i++){
        cin >> t[i];
    }

    cout << lcm_n(t) << endl;

    return 0;

}


Measured memory_bytes: 256
l, r = gets.strip.split.map(&:to_i)
y = 2019

min = 10**9

(l..l+2018).each do |i|
  (i+1..l+2018).each do |j|
    if i < r  && j <= r
      m = (i * j) % y
      min = m if m < min
      if m == 0
        puts "0"
        exit
      end
    end
  end
end
puts min

Measured memory_bytes: 1788
use proconio::input;
use std::cmp;

fn main() {
	input! {
		n: usize, k: usize,
		ps: [usize; n],
		cs: [i64; n]
	}

	let mut rounds: Vec<Vec<(i64, i64)>> = Vec::new();
	for start in 0..n {
		let mut i = start;
		let mut score = 0;
		let mut max = std::i64::MIN;
		let mut round: Vec<(i64, i64)> = vec![(score, max)];

		loop {
			i = ps[i]-1;
			score += cs[i];
			max = cmp::max(max, score);
			round.push((score, max));
			if i == start {
				break;
			}
		}

		rounds.push(round);
	}

	let mut max = std::i64::MIN;
	for start in 0..n {
		let round = &rounds[start];
		let length = round.len() - 1;
		let count = k / length;
		let last = round.last().unwrap();

		if count == 0 {
			max = cmp::max(max, round[k].1);
		} else if last.0 < 0 {
			max = cmp::max(max, last.1);
		} else {
			let score = last.0 * (count as i64 - 1);
			let max1 = score + last.1;
			let max2 = score + last.0 + round[k % length].1;
			max = cmp::max(cmp::max(max, max1), max2);
		}
	}

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

Measured memory_bytes: 402712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int white = 0;
		int black = 0;
		char map[][] = new char[100][100];
		for (int i = 0; i < 50; i++) {
			for (int j = 0; j < 100; j++) {
				if (i % 2 == 0) {
					if (j % 2 == 0) {
						map[i][j] = '#';
					} else {
						map[i][j] = '.';
						white++;
					}
				} else {
					map[i][j] = '#';
				}
			}
		}
		black++;
		for (int i = 50; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				if (i % 2 != 0) {
					if (j % 2 == 0) {
						map[i][j] = '.';
					} else {
						map[i][j] = '#';
						black++;
					}
				} else {
					map[i][j] = '.';
				}
			}
		}
		white++;
		for (int i = 0; i < 50; i++) {
			for (int j = 0; j < 100; j++) {
				if (A == white) {
					break;
				}
				if (map[i][j] == '.') {
					map[i][j] = '#';
					white--;
				}
			}
			if (A == white) {
				break;
			}
		}
		for (int i = 50; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				if (B == black) {
					break;
				}
				if (map[i][j] == '#') {
					map[i][j] = '.';
					black--;
				}
			}
			if (B == black) {
				break;
			}
		}

		System.out.println("100 100");
		for (int i = 0; i < 100; i++) {
			System.out.println(String.valueOf(map[i]));
		}
	}
}


Measured memory_bytes: 24276
//   //  /////       ///      
//  //   //  //     // //     
// //    //   //   //   //    
////     //   //  //     //   
// //    //   //  /////////    
//  //   //  //   //     //    
//   //  /////    //     //    

#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define iter(it,a,b) for(a::iterator it=b.begin(); it!=b.end();++it)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;
typedef vector<bool> vbool;
typedef priority_queue<p32> pq32;
typedef priority_queue<p32, vector<p32>, greater<p32> > pq32l;

#pragma GCC optimize ("-O2")
const ll LIM = 2e5+5;
const ll MOD = 1e9+7;
const ll inf = 1e10;


void dfs(vv32& adj, vbool& visited, int s, v64& black, v64& white){
	// NOTE MAKE VISITED TO BE 0 BEFORE STARTING
	// s is the source vertex
	visited[s]=1;

	bool isroot = 1;
	for(v32::iterator it = adj[s].begin(); it!=adj[s].end(); ++it){
		if(!visited[*it]) isroot=0;
	}

	if(isroot){
		black[s]=1;
		white[s]=1;
	}

	else{
		for(v32::iterator it = adj[s].begin(); it!=adj[s].end(); ++it){
			if(!visited[*it]){
				dfs(adj, visited, *it, black, white);
				black[s] = (black[s] * white[*it])%MOD;
				white[s] = (white[s] * (black[*it] + white[*it]))%MOD;
			}
		}
	}

//	cout << s << " " << black[s] << " " << white[s] << ln;

}

void makegraph(vv32& adj, int n, int m){
	// n is number of vertices
	// m is number of edges

	adj.resize(n);
	int x, y;

	forn(i,m){
		cin >> x >> y;
		adj[x-1].pb(y-1);
		adj[y-1].pb(x-1);
	}

}


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

	vv32 adj;

	int n;
	cin >> n;

	makegraph(adj, n, n-1);

	v64 black(n,1), white(n,1);

	vbool visited(n,0);

	dfs(adj, visited, 0, black, white);

	cout << (black[0]+white[0])%MOD;

}


Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B;
    cin >> A >> B;
    int ans = A - B * 2;
    if(ans<0)cout << 0 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  ll n,ans;
  cin >>n;
  for(ll i=5;i<=n;i*=5) ans += n%2?0:n/i/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>

const long long INF = 1000000007;

using namespace std;

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


int idx[22];
int n;
int dp[10000001];
int arr[22][22];
int visit[10000001];

int dd(int x) {
	if (x == 0) return 1;
	if (dp[x] >= 0) return dp[x];
	int v[22];
	int rt = 0;
	int tmp = x;
	int m = 0;
	int cnt = 0;
	while (tmp > 0) {
		if (tmp % 2) {
			v[m] = cnt;
			m += tmp % 2;
		}
		cnt++;
		tmp /= 2;
	}
	for (int i = 0; i < m; i++) {
		int cur = v[i];
		if (arr[m][cur + 1]) {
			if (dp[x - idx[cur]] < 0) rt = (rt + dd(x - idx[cur])) % INF;
			else rt = (rt + dp[x - idx[cur]]) % INF;
		}
	}
	dp[x] = rt;
	return rt;
}

int main() {
	scanf("%d", &n);
	int x = 1;
	for (int i = 0; i < n; i++) {
		idx[i] = x;
		x *= 2;
	}
	for (int i = 0; i < x; i++) {
		dp[i] = -1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) scanf("%d", &arr[i][j]);
	}
	printf("%d", dd(x-1));
}


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


#define ll long long
#define int long long
#define pb push_back

#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 998244353;
const ll inf = 2e18+5;




signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n; string s;
    cin>>n;
    double a = n/3.0;
    double b = n/3.0;
    double c = n/3.0;
        
    double vol = a*b*c;
    cout<<fixed<<setprecision(9)<<vol;
    return 0;
}   

Measured memory_bytes: 256
K, S = map(int, input().split())
X = (S + 2) * (S + 1)
if S - K - 1 >= 0:
  X -= 3 * (S - K + 1) * (S - K)
if S - 2 * K - 2 >= 0:
  X += 3 * (S - 2 * K) * (S - 2 * K - 1)

print(X // 2)

Measured memory_bytes: 3060