akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long  ll;

int main()
{
    int n;

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

    max_n[n - 2] = r[n - 1];
    for (int i = n - 3; i >= 0; --i)
        max_n[i] = max(r[i + 1], max_n[i + 1]);

    int ans = -1e9 - 1;
    for (int i = 0; i < n - 1; ++i)
        ans = max(ans, max_n[i] - r[i]);

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 2580
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int k, x;
	cin >> k >> x;

	rep(i, 2 * k - 1) {
		cout << i + x - k + 1;
		if (i != 2 * k - 2) {
			cout << " ";
		}
	}
	cout << endl;
	
}

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

ll N, K;

int main(){
	string s, t;
	cin >> s >> K;
	t = s;
	ll c = 0, sc = 0;
	N = s.size();
	bool sameC = true;
	for(int i = 1; i < N; ++i){
		sameC = sameC && (s[i] == s[0]);
		if(s[i-1] == s[i]){
			s[i] = '0';
			c++;
		}
	}
	for(int i = 0; i < N; ++i){
		if((i == 0 && s[N-1] == t[0]) || (i > 0 && t[i-1] == t[i])){
			t[i] = '0';
			sc++;
		}
	}
	c = c + sc* (K-1);
	/*if(s[0] == s[N-1])
		c += K-1;
		*/
	if(sameC)
		c = (K*N)/2;
	cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back

const int P = 1e9+7;

using namespace std;

int n;
string s;
ll dp[3030][3030];

int main(){

	cin >> n >> s;

	dp[0][0] = 1;
	int m = s.size();

	for(int i=0; i<m; i++){
		ll sum = 0;
		if(s[i] == '<'){
			for(int j=0; j<i+2; j++){
				dp[i+1][j] = sum;
				sum = (sum+dp[i][j])%P;
			}
		} else {
			for(int j=i; j>=0; j--){
				sum = (sum+dp[i][j])%P;
				dp[i+1][j] = sum;
			}
		}
	}

	ll ans = 0;

	for(int i=0; i<n; i++){
		ans = (ans+dp[m][i])%P;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 70272
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define M 110000
#define n 40
using namespace std;
typedef long long ll;

void binary(ll a, int B[])
{
	int j;
	for (j = 0; j < n; j++)
	{
		if (a % 2)
			B[j]++;
		a /= 2;
	}
}

ll func(int Bx[], int Ba[], int N)
{
	int i;
	ll f = 0;
	for (i = 0; i < n; i++)
	{
		if (Bx[i])
			f += (N - Ba[i]) * powl(2, i);
		else f += Ba[i] * powl(2, i);
	}
	return f;
}

int main() {
	int N, i, j, Ba[n], Bk[n], Bxwant[n], Bx[n];
	ll K, A[M], fmax = 0;
	bool change = false;
	cin >> N >> K;
	for(i = 0; i < N; i++)
		cin >> A[i];
	for (i = 0; i < n; i++)
		Ba[i] = 0;
	for(i = 0; i < N; i++)
		binary(A[i], Ba);
	for (i = 0; i < n; i++)
	{
		if (max(N / 2, Ba[i]) == Ba[i])
			Bxwant[i] = 0;
		else Bxwant[i] = 1;
	}
	binary(K, Bk);
	for (i = 0; i < n; i++)
	{
		if (Bk[i])
		{
			for (j = 0; j < i; j++)
			{
				Bx[j] = Bxwant[j];
				if (Bx[j] != Bk[j] && Bx[j] == 1)
					change = true;
			}
			if (change)
			{
				Bx[i] = 0;
				change = false;
			}
			else Bx[i] = Bk[i];
		}
		else
		{
			for (j = 0; j < i + 1; j++)
			{
				if (Bk[j])
					Bx[j] = Bxwant[j];
				else Bx[j] = Bk[j];
			}
		}
		for (j = i + 1; j < n; j++)
		{
			if (Bk[j])
				Bx[j] = Bxwant[j];
			else Bx[j] = Bk[j];
		}
		fmax = max(func(Bx, Ba, N), fmax);
	}
	cout << fmax << endl;
}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    if (A > B) swap(A, B);
    if (B > C) swap(B, C);

    cout << A + B + (C << K) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

void s_sort(int*a , int n , int* count){
	int lowest;
	for(int i=0;i<n;++i){
		lowest=i;
		for(int j=i+1 ; j<n ;++j){
			if(a[j]<a[lowest]){
				lowest=j;
				}
			}
		if(a[i]>a[lowest]){
		swap(a[i] , a[lowest]);
		(*count)++;
		}
	}
	
}

int main(){
	int n , cnt=0;
	cin >> n;
	int*a = new int [n];
	for(int i=0;i<n ;++i){
		cin >> a[i];
	}
	s_sort(a , n , &cnt);
	for(int i=0;i<n-1 ; ++i){
		cout << a[i] << " ";
	}
	cout << a[n-1] << endl << cnt << endl;
	delete [] a;
	return 0; 
}

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

template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int cnt = 0;
    vector<int> a = readVector<int> (n);
    for(int i=0; i<n; i++) {
        if((i+1)%2 == 1 && a[i]%2 == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	bool takahashi_win;
	while (true) {
		C -= B;
		if (C <= 0) {
			takahashi_win = true;
			break;
		}
		A -= D;
		if (A <= 0) {
			takahashi_win = false;
			break;
		}
	}
	if (takahashi_win) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3612
n=int(input())
a=list(map(int,input().split()))
set_a=set(a)
if len(set_a)==3:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    num2 = a.count(set_a[2])
    if (set_a[0]^set_a[1]^set_a[2]==0) and (num0==num2) and (num1==num2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==2:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    if (set_a[0]==0 and num1 == num0*2)or(set_a[1]==0 and num0==num1*2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==1:
    if 0 in set_a:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  string l = "", r = "";
  rep(i,n) {
    l += s[i];
    r += s[2*n-1-i];
  }
  map<P,ll> m;
  ll ans = 0;
  rep(i,1<<n) {
    string a = "", b = "";
    rep(j,n) {
      if(i & (1<<j)) a += l[j];
      else b += l[j];
    }
    m[P(a,b)]++;
  }
  rep(i,1<<n) {
    string a = "", b = "";
    rep(j,n) {
      if(i & (1<<j)) a += r[j];
      else b += r[j];
    }
    ans += m[P(a,b)];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 91904
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

pll dat[1005];

int main(){
    int n; scanf("%d", &n);
    REP(i,1,n) scanf("%lld %lld", &dat[i].fi, &dat[i].se);
    //
    REP(i,2,n){
        ll reta = (dat[i-1].fi + dat[i].fi - 1) / dat[i].fi;
        ll retb = (dat[i-1].se + dat[i].se - 1) / dat[i].se;
        dat[i].fi *= max(reta, retb);
        dat[i].se *= max(reta, retb);
    }
    //
    printf("%lld\n", dat[n].fi + dat[n].se);
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    S = [input() for i in range(N)]
    ans = sum([s.count('AB') for s in S])
    a1 = len([1 for s in S if s[-1] == 'A'])
    b1 = len([1 for s in S if s[0] == 'B'])
    ab1 = len([1 for s in S if s[-1] == 'A' and s[0] == 'B'])

    #print('ans,a1,b1,ab1',ans,a1,b1,ab1)
    if a1 > b1:
        return ans + b1
    elif a1 < b1:
        return ans + a1

    if a1 == ab1 and ab1 > 0:
        return ans + ab1 - 1

    return ans + a1

print(solve())


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

using namespace std;

inline int read()
{
    char ch=getchar(); int f=1,x=0;
    while (ch<'0' || ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
    return f*x;
}

const int N=300005;
ll t2[N];
int n,m,cnt[N],s[N],t[N],id[N];

inline void add1(int x,int y) { for (;x<=n;x+=x&-x) t[x]+=y; }

inline void add2(int x,int y) { for (;x<=n;x+=x&-x) t2[x]+=y; }

inline int query1(int x)
{
    int ans=0;
    for (;x;x-=x&-x) ans+=t[x];
    return ans;
}

inline ll query2(int x)
{
    ll ans=0;
    for (;x;x-=x&-x) ans+=t2[x];
    return ans;
}

inline bool check(int c,int mid)
{
    int x=query1(n)-query1(mid-1);
    ll sum=query2(mid-1);
    return sum>=1ll*(c-x)*mid;
}

signed main()
{
    n=read();
    for (int i=1;i<=n;i++) cnt[read()]++;
    for (int i=1;i<=n;i++)
    {
        if (!cnt[i]) continue;
        s[++m]=cnt[i];
    }
    for (int i=1;i<=m;i++)
    {
        add1(s[i],1);
        add2(s[i],s[i]);
    }
    for (int i=1;i<=n;i++)
    {
        int l=0,r=n/i;
        while (l<r)
        {
            int mid=(l+r+1)>>1;
            if (check(i,mid)) l=mid;
            else r=mid-1;
        }
        printf("%d\n",l);
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    string s;
    cin >> s;

    int a = 0, b = 0, c = 0;
    rep(i, s.size()){
        if(s[i] == 'a') a++;
        if(s[i] == 'b') b++;
        if(s[i] == 'c') c++;
    }

    int len = (s.size() + 2) / 3;
    if(a <= len && b <= len && c <= len){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 512
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


K = I()
ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += math.gcd(math.gcd(i,j),k)

print(ans)

Measured memory_bytes: 69428
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll K, string S) {
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    S.resize(K);
    cout << S << "..." << endl;
  }
}

int main() {
  ll K;
  cin >> K;
  string S;
  cin >> S;
  solve(K, S);
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int t[500010];
ll l[500010],r[500010],sum[500010],nisum[500010],w[500010],ls[500010];
int n;
struct que
{
	ll cop[500010],tim[500010];
	int head,tail;
	void clear()
	{
		for (int i=0;i<=head;i++) cop[i]=tim[i]=0;
		head=0;tail=0;
	}
	void push(int t,long long x)
	{
		while ((head>1)&&((cop[head]-cop[head-1])*(t-tim[head-1])-(x-cop[head-1])*(tim[head]-tim[head-1])<=0)) head--;
		cop[++head]=x;tim[head]=t;tail++;
	}
	long long top(int t)
	{
		if (head<tail) tail=head;
		while ((tail>1)&&(cop[tail]-t*tim[tail]<cop[tail-1]-t*tim[tail-1])) tail--;
		//cout<<tim[tail]<<endl;
		return cop[tail]-t*tim[tail];
		//long long ans=-4e18;
		//for (int i=1;i<=head;i++) ans=max(ans,cop[i]-t*tim[i]);return ans;
	}
}que;
struct que2
{
	ll cop[500010],tim[500010];
	int head,tail;
	void clear()
	{
		for (int i=0;i<=head;i++) cop[i]=tim[i]=0;
		head=0;tail=1;
	}
	void push(int t,long long x)
	{
		while ((head>1)&&((cop[head]-cop[head-1])*(t-tim[head-1])-(x-cop[head-1])*(tim[head]-tim[head-1])<=0)) head--;
		cop[++head]=x;tim[head]=t;
	}
	long long top(int t)
	{
		while ((head>tail)&&(cop[tail]-t*tim[tail]<cop[tail+1]-t*tim[tail+1])) tail++;
		//cout<<tim[tail]<<endl;
		return cop[tail]-t*tim[tail];
	}
}que2;
void work(int pl,int pr)
{
	if (pl==pr)
	{
		w[pl]=max(w[pl],l[pl-1]+r[pl+1]+1-t[pl]);
		return;
	}
	int mid=(pl+pr)>>1;
	work(pl,mid);work(mid+1,pr);
	que2.clear();que2.push(0,0);
	for (int i=pl;i<=mid;i++) que2.push(i,l[i]+sum[i]+(ll)i*(i-1)/2);
	ll x=-4e18;
	for (int i=pr;i>mid;i--)
	{
		x=max(x,que2.top(i)+(ll)i*(i+1)/2-sum[i]+r[i+1]);
		w[i]=max(w[i],x);
	}
	que2.clear();que2.push(0,0);
	for (int i=pr;i>mid;i--) que2.push(n-i+1,r[i]+nisum[i]+(ll)(n-i+1)*(n-i+1-1)/2);
	x=-4e18;
	for (int i=pl;i<=mid;i++)
	{
		x=max(x,que2.top(n-i+1)+(ll)(n-i+1)*(n-i+1+1)/2-nisum[i]+l[i-1]);
		w[i]=max(w[i],x);
	}
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("myout.txt","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&t[i]);sum[i]=sum[i-1]+t[i];}
	for (int i=n;i>=1;i--) nisum[i]=nisum[i+1]+t[i];
	que.clear();que.push(0,0);
	for (int i=1;i<=n;i++)
	{
		l[i]=max(l[i-1],que.top(i)+(ll)i*(i+1)/2-sum[i]);
		que.push(i,l[i]+sum[i]+(ll)i*(i-1)/2);
	}
	/*reverse(t+1,t+n+1);for (int i=1;i<=n;i++) sum[i]=sum[i-1]+t[i];
	que.clear();que.push(0,0);
	for (int i=1;i<=n;i++)
	{
		r[i]=max(r[i-1],que.top(i)+(ll)i*(i+1)/2-sum[i]);
		que.push(i,r[i]+sum[i]+(ll)i*(i-1)/2);
	}
	reverse(t+1,t+n+1);for (int i=1;i<=n;i++) sum[i]=sum[i-1]+t[i];
	reverse(r+1,r+n+1);*/
	que.clear();que.push(0,0);
	for (int i=n;i>=1;i--)
	{
		r[i]=max(r[i+1],que.top(n-i+1)+(ll)(n-i+1)*(n-i+1+1)/2-nisum[i]);
		que.push(n-i+1,r[i]+nisum[i]+(ll)(n-i+1)*(n-i+1-1)/2);
	}
	//l[i]为前i个的dp值,r[i]为i~n的dp值 
	//for (int i=1;i<=n;i++) printf("%lld\n",r[i]);return 0;
	memset(w,214,sizeof(w));//w[i]表示强制i这个题目一定要做的最大cost 
	work(1,n);
	//for (int i=1;i<=n;i++) cout<<w[i]<<endl;
	int q;scanf("%d",&q);
	while (q--)
	{
		int p;ll x;scanf("%d%lld",&p,&x);
		printf("%lld\n",max(l[p-1]+r[p+1],w[p]+t[p]-x));
	}
}

Measured memory_bytes: 33280
use std::collections::HashMap;

fn main() {
  let _: usize = read();
  let vecd: Vec<i64> = read_vec();
  let _: usize = read();
  let vect: Vec<i64> = read_vec();

  let mut hashd: HashMap<i64, usize> = HashMap::new();
  let mut hasht: HashMap<i64, usize> = HashMap::new();
  for d in vecd {
    let counter = hashd.entry(d).or_insert(0);
    *counter += 1;
  }
  for t in vect {
    let counter = hasht.entry(t).or_insert(0);
    *counter += 1;
  }

  for (kt,vt) in hasht {
    let vd = hashd.get(&kt);
    if vd == None {
      println!{"NO"};
      return;
    }
    if vd.unwrap() < &vt {
      println!{"NO"};
      return;
    }
  }

  println!("YES");
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}


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

int main() {
    int n, k, ans = 1;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {   
        if (ans <= k) {
            ans *= 2;
        } else {
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
B = set([int(input()) for _ in range(n)])

cr1 = {A[0][0], A[1][1], A[2][2]}
cr2 = {A[2][0], A[1][1], A[0][2]}
main_list= [cr1, cr2]

R = [set([A[i][j] for j in range(3)]) for i in range(3)]
C = [set([A[i][j] for i in range(3)]) for j in range(3)]
main_list.extend(R)
main_list.extend(C)

for D in main_list:
  if D.issubset(B):
    print('Yes')
    quit()

print('No')

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]

f_inf = float("inf") # sys.maxsize

N, M, P = map(int, input().split())
ABC_d = {}
for m in range(M):
    A, B, C = map(int, input().split())
    if A in ABC_d:
        ABC_d[A].append((B, C - P))
    else:
        ABC_d[A] = [(B, C - P)]

cost = [-f_inf] * N
cost[0] = 0

max_num_sum = (N * (N + 1)) // 2

def solve(pos, cnt, num_sum):
    global cost

    if not(pos in ABC_d): return
    if cnt > N or num_sum > max_num_sum:
        cost[pos-1] = f_inf;

    for B, C in ABC_d[pos]:
        if cost[B - 1] == f_inf or cost[B - 1] >= cost[pos - 1] + C:
            pass
        elif cost[B - 1] < cost[pos - 1] + C:
            cost[B - 1] = cost[pos - 1] + C
            solve(B, cnt + 1, num_sum + B)

solve(1, 1, 1)

if (cost[-1] == f_inf):
    print (-1)
else:
    print (max(0, int(cost[-1])))


Measured memory_bytes: 124892
/* Copyright 2016 AcrossTheSky */
#include <iostream>
#include <cstdio>
#include <utility>
#include <cassert>
#include <map>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <sstream>
#include <fstream>
#include <string>
#include <cmath>
#include <algorithm>
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define PER(i, a, b) for (int i = (a); i >= (b); --i)
#define RVC(i, c) fot (int i = 0; i < (c).size(); ++i)
#define RED(k, u) for (int k = head[(u)]; k; k = edge[k].next)
#define SQR(k) (k) * (k)
#define lowbit(x) ((x) & (-(x)))
#define CL(x, v) memset(x, v, sizeof x)
#define MP std::make_pair
#define PB push_back
#define FR first
#define SC second
#define rank rankk
#define next nextt
#define link linkk
#define index indexx
#define abs(x) ((x) > 0 ? (x) : (-(x)))
using namespace std;
typedef long long LL; typedef pair<int, int> PII;

template<class T> inline
bool getmin(T *a, const T &b) {
    if (b < *a) {
        *a = b;
        return true;
    }
    return false;
}

template<class T> inline
bool getmax(T *a, const T &b) {
    if (b > *a) {
        *a = b;
        return true;
    }
    return false;
}

template<class T> inline
void read(T *a) {
    char c;
    while (isspace(c = getchar())) {}
    bool flag = 0;
    if (c == '-') flag = 1, *a = 0;
    else
        *a = c - 48;
    while (isdigit(c = getchar())) *a = *a * 10 + c - 48;
    if (flag) *a = -*a;
}

const int mo = 1000000007;
template<class T>
T pow(T a, T b, int c = mo) {
    T res = 1;
    for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c) if (b & i) res = 1LL * res * a % c;
    return res;
}
/*======================= TEMPLATE =======================*/
const int N = 210000;
int a[N], b[N];
int n;
bool check(int x) {
    REP(i, 1, 2 * n - 1) if (a[i] <= x) b[i] = 1;
    else b[i] = 0;
    REP(i, 0, n - 2) {
        if (b[n - i - 1] == b[n - i]) return b[n - i];
        if (b[n + i] == b[n + i + 1]) return b[n + i];
    }
    return b[n] ^ 1 ^ (n & 1);
}
int main() {
    cin >> n;
    REP(i, 1, 2 * n - 1) read(a + i);
    int l = 1, r = n * 2 - 1, res;
    while (l <= r) {
        int m = (l + r) >> 1;
        if (check(m)) res = m, r = m - 1;
        else l = m + 1;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n;
ll a[400000];
ll f1[400000],f2[400000];

struct node
{
    ll x,y;
};

int s1[200000],s2[200000];
int t1=0,t2=0;
node s[200000];
int t=0;
ll select1[200000],select2[200000];

bool cmp(ll a, ll b)
{
    return a>b;
}

int main()
{
    ll tot=0;
    cin>>n;
    for (int i=0; i<n; ++i)
    {
        scanf("%lld",&a[i]);
        if (a[i]>=0) s1[t1++] = a[i];
        else s2[t2++] = a[i];
        tot+=a[i];
    }
    sort(s1,s1+t1);
    sort(s2,s2+t2,cmp);
    if (t2==0)
    {
        cout<<tot-2*s1[0]<<endl;
        ll ans =s1[0];
        for (int i=1; i<t1-1; ++i)
        {
            cout<<ans<<' '<<s1[i]<<endl;
            ans-=s1[i];
        }
        cout<<s1[t1-1]<<' '<<ans;
        
        return 0;
    }
    while (t1>1)
    {
        s[t].x = s2[t2-1];
        s[t].y = s1[t1-1];
        t++;

        s2[t2-1] = s2[t2-1] - s1[t1-1];
        t1--;
    }
    ll ans = 0;
    if (t1==0)
    {
        ans=s2[0];
        for (int i=1; i<t2; ++i)
        {
            s[t].x = ans;
            s[t].y = s2[i];
            t++;
            ans = ans-s2[i];
        }
    }else
    {
        ans=s1[0];
        for (int i=0; i<t2; ++i)
        {
            s[t].x = ans;
            s[t].y = s2[i];
            t++;
            ans = ans-s2[i];
        }
    }
    cout<<ans<<endl;
    for (int i=0; i<t; ++i)
        cout<<s[i].x<<' '<<s[i].y<<endl;
    return 0;
}



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

int main() {
    string in;
    cin >> in;
    int n=0;
    rep(i,3) n += bool(in.at(i)=='R');
    if (in.at(1) == 'S') cout << bool(n>=1) << endl;
    else cout << n << endl;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			long[] arr = new long[N];
			for(int i = 0; i < N; i++) { arr[i] = sc.nextLong(); }
			
			long[] DP = new long[N + 1];
			Arrays.fill(DP, Integer.MAX_VALUE);
			DP[0] = 0;
			
			for(int i = 0; i < N; i++) {
				for(int next = 1; next <= K; next++) {
					if(i + next >= N) { continue; }
					
					DP[i + next] = Math.min(DP[i + next], DP[i] + Math.abs(arr[i] - arr[i + next]));
				}
			}
			
			System.out.println(DP[N - 1]);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

constexpr int mod = 1000000007;
class mint {
private:
    std::int64_t m_x;
public:
    mint(std::int64_t m_x = 0) : m_x(m_x% mod) {}
    std::int64_t get() { return m_x; }
    mint& operator+=(const mint a) {
        if ((m_x += a.m_x) >= mod) m_x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((m_x += mod - a.m_x) >= mod) m_x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (m_x *= a.m_x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(const std::int64_t t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

void Main() {
    int n, k;
    cin >> n >> k;
    vint a(n);
    rep(i, n) {
        cin >> a[i];
    }

    mint ans = 0;
    vint num(2005, 0);
    for (int i = n - 1; i >= 0; --i) {
        ans += accumulate(num.begin(), num.begin() + a[i], 0);
        ++num[a[i]];
    }

    mint ans2 = 0;
    rep(i, n) {
        ans2 += accumulate(num.begin(), num.begin() + a[i], 0);
    }

    mint sum = ans * k + ans2 * k * (k - 1) / 2;
    cout << sum.get() << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;


class Program
{
    
    static void Main(string[] args)
    {
        string s = crS();
        if (s.EndsWith('s')) s += "es";
        else s += "s";

        Console.WriteLine(s);

    }

   

   



    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static long crL() { return long.Parse(Console.ReadLine()); }
    static int[] arrInt() { return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray(); }
    static long[] arrLong() { return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr() { return Console.ReadLine().Split(' ').ToArray(); }
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<long[]> mapLong(long h)
    {
        List<long[]> mapLong = new List<long[]>();
        for (int i = 0; i < h; i++)
        {
            mapLong.Add(arrLong());
        }
        return mapLong;
    }


    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }

    //二次元配列出力用
    static void output2DArray(int h , int w , int[,] map)
    {
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (j == w - 1) Console.WriteLine(map[i, j]);
                else Console.Write(map[i, j] + " ");
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
ll inf = (ll)1 << 60;

int main() {
    ll n, w;
    cin >> n >> w;

    vector<ll> best(100001,inf);
    best[0] = 0;

    for(int i = 0; i < n; i++) {
        ll wi, vi;
        cin >> wi >> vi;

        for(ll i = 100001; i >= 0; i--) {
            if(i + vi > 100000) {
                continue;
            }
            best[i+vi] = min(best[i+vi],best[i]+wi);
        }
    }

    ll ans = 0;
    for(ll i = 0; i < best.size(); i++) {
        if(best[i] <= w) {
            ans = i;
        }
    }
    cout << ans << endl;
}


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


int main(){
 
 
	string s;
 
	cin >> s;
 
	long long int sum = 0;

	rep(i,s.size()) sum += s[i] - '0';
 
 
	if (sum % 9 == 0)
		cout << "Yes" << endl;
	else cout << "No" << endl;
 
    return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for (int i = 0; i < N; i++)
    cin >> a.at(i);
  
  sort(a.begin(),a.end());
  
  int cur = 0;
  int x = 0;
  for (int i = 0; i < N; i++)
    if(cur < a.at(i)){
      x++;
      cur = a.at(i);
    }
 cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	
	int a2 = a*a;
	int a3 = a*a*a;
	
	System.out.println(a + a2+ a3);
	
	
	}

}

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

#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;

int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
  int W,H,N,ans=0;
  cin >> W >> H >> N;
  int x,y;
  cin >> x >>y;
  for(int i=0; i<N-1; ++i){
  	int tx,ty;
  	cin >> tx >> ty;
  	while(1){
  		if(x<tx && y<ty){
  			x++;
  			y++;
  			ans++;
  		}else if(x>tx && y>ty){
  			x--;
  			y--;
  			ans++;
  		}else{
  			ans += abs(tx - x) + abs(ty - y);
  			break;
  		}
  	}
  	x=tx;
  	y=ty;
  }
  cout << ans << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int mini, int maxx) {
  vector < int > int_array;
  for (int i = 2; i <= maxx; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(maxx);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  while(true)if(mini<=sosu[0])break;else sosu.erase(sosu.begin());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b) swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b) swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {return nPr(n, n);}

ll nCr(ll n, ll r) {
  if (0 != n - r && n - r < r) r = n - r;
  return nPr(n, r) / nE(r);
}


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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long tot = 0;
  unordered_map<string, int> chk;
  for (int i = 0; i < n; i++) {
    string w;
    cin >> w;
    sort (w.begin(), w.end());
    tot += chk[w];
    chk[w]++;
  }
  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 10660
import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	int n = scan.nextInt();
 	int x = scan.nextInt();
	int Max = Math.max(n,x) ;
    int min = Math.min(n,x) ;
    int count = 0 ;
    for(int i = min ; i<=Max ;i++){
      if((i*n*x) % 2 != 0){
        count++;
        break;
      }
    }
    if(count!=0){
      System.out.println("Yes");
    }else{
      System.out.println("No") ;
    }
    
  }
}

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

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

    int ans = 0;
    for(int i = 0; i < N - 2; i++) {
        for(int j = i; j < N - 1; j++) {
            for(int k = j; k < N; k++) {
                if(L.at(i) == L.at(j) || L.at(j) == L.at(k) ||
                   L.at(i) == L.at(k)) {
                    continue;
                }
                if(L.at(i) + L.at(j) > L.at(k)) {
                    ans++;
                }
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3624
def main():
    n = input()[::-1]
    a = 0
    borrow = False
    for i in enumerate(n):
        if i[0] == len(n)-1:
            if borrow:
                a += int(i[1])-1
            else:
                a += int(i[1])
        else:
            if int(i[1]) < 9:
                borrow = True
            a += 9
    print(a)
        
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9128
#include <iostream>

using namespace std;

#define C2I(a) (a - '0')

int main() {
    string s;
    cin >> s;
    int m, d;
    m = C2I(s[5]) * 10 + C2I(s[6]);
    d = C2I(s[8]) * 10 + C2I(s[9]);
    cout << (m * 31 + d <= 4 * 31 + 30 ? "Heisei" : "TBD") << endl;

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  bool flag = true;
  for (int i = 0; i < s.length(); ++i) {
    if (i % 2 == 0) {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        flag = false;
        break;
      }
    } else {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        flag = false;
        break;
      }
    }
  }
  if (!flag) {
    cout << "No" << '\n';
  } else {
    cout << "Yes" << '\n';
  }
  return 0;
}

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

int main(){
	int H,W;
  	cin >> H >>W;
  	cout << "#";
  	for(int i = 0; i < W;i++)cout << "#";
    cout << "#" << endl;
  
	string a;
  	for(int j = 0; j < H; j++){
    	cout << "#";

       	cin >> a;
        cout << a;

    	cout << "#" << endl;
    }
  
  	cout << "#";
  	for(int i = 0; i < W;i++)cout << "#";
    cout << "#" << endl;




}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e18+5);
void max_self(int &a, int b){
    a= max(a,b);
}
void min_self(ll &a, ll b){
    a=min(a,b);
}
ll mul(ll &a, ll b){
    return (a*b)%mod;
}

vector<int> adj[(int)1e5+5];

pair<int,int> dfs(int a, int par){

    ll bl=1,w=1;
    for(int b: adj[a]){
        if(b==par) continue;
        pair<int,int> p = dfs(b,a);
        bl = mul(bl,p.second);
        w = mul(w,(p.second+p.first));
    }
    return make_pair(bl,w);
}

ll run() {
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
    }
    pair<int,int> ans = dfs(1,-1);
    cout<<(ans.first+ans.second)%mod;
}



















Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
const int N=105;
string s;
ll ans=0,cheng;
int n,k,c[N];
vi v;
ll dfs(int now,int cnt,bool f)
{
//	cout<<now<<' '<<cnt<<' '<<f<<endl;
	if(cnt==k)return 1;if(now>=n)return 0;
	if(f)
	{
		ll res=0;
		for(int i=now;i<n;i++)
		{
			res+=dfs(i+1,cnt+1,f);
		}
		return res*9;
	}
	else
	{
		ll res=0;
		if(cnt+1!=k)
		{
			if(s[v[cnt+1]]=='0')res=0;
			else res=dfs(v[cnt+1],cnt+1,f);
		}else if(s[now]!='0')res=1;
		res+=dfs(v[cnt]+1,cnt,!f);
		res+=dfs(v[cnt]+1,cnt+1,!f)*max(s[now]-'0'-1,0);
		return res;
	}
}
int main()
{
	cin>>s>>k;
	n=s.size();
	v.clear();
	if(s=="0")
	{
		cout<<"0\n";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]!='0')
		{
			v.pb(i);
		}
	}
	while(v.size()<k)v.pb(v[v.size()-1]+1);
	if(v[v.size()-1]>=s.size())
	{
		puts("0");
		return 0;
	}
	cout<<dfs(v[0],0,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

aa = list(set(a))
if len(a) == len(aa):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 104660
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

int main() {
    int N;

    while (cin >> N, N) {
        int ans = 0;
        for (int i = N + 1; i <= 2 * N; i++) {
            bool flag = true;
            for (int j = 2; j * j <= i; j++) {
                if (i % j == 0) {
                    flag = false;
                    break;
                }
            }

            if (flag) ans++;
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main (void)
{
  int a;
  char str[11];
  
  scanf("%d\n",&a);
  scanf("%s\n",str);
  
  if(a>=3200){
    printf("%s",str);
  }else if(a<3200){
    printf("red");
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

int main(){
	int n; scanf("%d",&n);
	static int l[499999],r[499999],depth[500000];
	rep(u,n-1){
		scanf("%d%d",l+u,r+u), l[u]--, r[u]--;
		depth[l[u]]=depth[u]+1;
		depth[r[u]]=depth[u]+1;
	}

	static int leaf[500000];
	static ll dp1[500000]; // dp1[u] := ( 頂点 u にいて, u でセーブする. 以降セーブせずに u 以下の葉を全攻略するための最小時間 )
	static ll dp2[500000]; // dp2[u] := ( 頂点 u にいて, 好きにセーブしてもいいとしたときの, u 以下の葉を全攻略するための最小時間 )
	leaf[n-1]=1;
	for(int u=n-2;u>=0;u--){
		leaf[u]=leaf[l[u]]+leaf[r[u]];

		dp1[u]=leaf[u]+dp1[l[u]]+dp1[r[u]];

		dp2[u]=1+dp2[l[u]]+depth[u]+1+dp2[r[u]];
		dp2[u]=min(dp2[u],leaf[l[u]]+dp1[l[u]]+1+dp2[r[u]]);
		dp2[u]=min(dp2[u],leaf[r[u]]+dp1[r[u]]+1+dp2[l[u]]);
	}

	printf("%lld\n",dp2[0]);

	return 0;
}

Measured memory_bytes: 16648
nums = gets.chomp.split(" ").map(&:to_i)
cnt = nums[0]
x = nums[1]
bounds = gets.chomp.split(" ").map(&:to_i)
bounds_cnt = 1
current_x = 0
bounds.each_with_index do |bound|
  current_x = current_x + bound
  if x >= current_x
    bounds_cnt += 1
  end
end

p bounds_cnt
    

Measured memory_bytes: 1788
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>  
#include<cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include<map>
#include<algorithm>
#include<functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include<deque>
#include<climits>
#include<typeinfo>
#include<utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10);


int gcda(int a, int b, int c) {
	int m = min(a, min(b, c));
	for (int i = m;i>=1;i--) {
		if (a%i == 0 && b%i == 0 && c%i == 0) return i;
	}
}



int main() {
	
	int k;
	cin >> k;
	int ans = 0;
	int tmp;
	for (int i = 1;i <= k;i++) {
		for (int j = 1;j <= k;j++) {
			for (int l = 1;l <= k;l++) {
				tmp = GCD(i, j);
				ans = ans + GCD(tmp, l);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
int main() {
  
  int N;
  cin>>N;
  
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin>>P[i];
  }
  
  int ans=0;
  
  int low=P[0];
  
  
  for(int i=0;i<N;i++){
    if(P[i]<=low){
      low=P[i];
      ans++;
    }
  }
  
  cout<<ans<<endl;
}

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

//dp[i+1][j] := i番目までの素数を使って個数をj個にする場合の数
//dp[0][1] = 1
//dp[i+1][j*k] += dp[i][k] 
int dp[101][76];
int P[101];

void prime_deviation(int n) {
    for(int i = 2; i * i <= n; ++i) {
        if(n % i != 0) continue;
        int num = 0;
        while(n%i == 0) { n /= i; ++num; }
        P[i] += num;
    }
    if(n != 1) P[n] += 1;
}

int main()
{
    int N;
    cin >> N;
    
    for(int i = 2; i <= N; ++i) 
        prime_deviation(i);
    
    dp[0][1] = 1;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j <= 75; ++j) {
            for(int k = 1; k <= P[i] + 1 && j*k <= 75; ++k) {
                dp[i+1][j*k] += dp[i][j];
            }
        }
    }

    cout << dp[N][75] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    int mx=0,len;
    cin>>len>>s;

    for(int i=0; i<len; i++)
    {
        map<int,int>mp;
        int cnt=0;
        for(int j=i; j>=0; j--)
           mp[s[j]]=1;
        for(int j=i+1; j<len; j++)
            {
                if(mp[s[j]]==1)
                    mp[s[j]]=2,cnt++;

            }
        mx=max(mx,cnt);
    }
    cout<<mx<<endl;


    return 0;
}


Measured memory_bytes: 3644
//
// Created by Tetsuya Shiota on 2019-03-30.
//

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<cstdlib>
#include<string>
#include<sstream>

using namespace std;

int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    int R, B;
    R = B = 0;
    for(char c : s){
        if(c == 'R')R++;
        else B++;
    }
    if( R >  B){
        cout << "Yes"<<endl;
    }else{
        cout << "No" <<endl;
    }

    return 0;

}

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

int main() {
    int64_t K, A, B;
    cin >> K >> A >> B;
    if (((A / K) + 1) * K <= B || A % K == 0) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632