akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	VI d(N);
	REP(i,N)cin>>d[i];
	SORT(d);
	int ans=1;
	REP(i,N-1){
		ans++;
		if(d[i]==d[i+1])ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    c=input().strip("\n")
    cntR=0
    cntW=0
    for i in range(N):
        if c[i]=="R":
            cntR+=1
        else:
            cntW+=1
    ans=N
    
    ans1=cntR
    for i in range(cntR):
        if c[i]=="R":
            ans1-=1
    ans=min(ans,ans1)
    
    print(ans)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 67552
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

// typedef  long long int ll;
// typedef long double   ld;

#define    int                      long long int
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <int , pii>
#define    sp(x)                    setprecision(x)


int32_t main()
{
    speed upp
    int a,b,n;
    cin>>a>>b>>n;
    if(a<b)
    swap(a,b);
    int ans=n/a;
    if(n%a!=0)
        ans++;
    cout<<ans;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
  "strconv"
)
func main() {
  var s string
  fmt.Scan(&s)
  n := 1 << uint(len(s)-1)
  result := 0
  for i := 0; i < n; i++ {
    from := 0
    for j := 0; j < len(s)-1; j++ {
      flag := (i >> uint(j))&1
      if flag == 1 {
        k, _ := strconv.Atoi(s[from:j+1]) 
        result += k
        from = j+1
      }
    }
    k, _ := strconv.Atoi(s[from:len(s)])
    result += k
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
int main(){
  ll n; cin >> n;
  string s; cin >> s;
  ll ans=0;
  ll n_r=0;
  ll n_g=0;
  ll n_b=0;
  rep(t,s.size()){
    char c = s[t-1];
    if(c=='R'){
      ans+=n_g*n_b;
      n_r++;
    }else if(c=='G'){
      ans+=n_b*n_r;
      n_g++;
    }else if(c=='B'){
      ans+=n_r*n_g;
      n_b++;
    }
  }
  rep(w,n){
    for(ll i=0;i<n;i++){
      ll j = i+w; ll k = j+w;
      if(k>=n) break;
      if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i]) ans--;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(all(l));
    ll ans = 0;
    for(int i = 0; i < n-2; i++){
        for(int j = i+1; j < n-1; j++){
            int min_sum = l[i] + l[j];
            auto itr = lower_bound(all(l), min_sum);
            size_t pos = distance(l.begin(), itr);
            ans += pos - 1 - j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fn input1<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn input_trio<T: std::str::FromStr + Copy> () -> (T, T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: Vec<T> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (s[0], s[1], s[2])
}

fn main() {
    let (n, k, q) = input_trio::<usize>();
    let mut ws = vec![0; n];
    for _ in 0..q {
        let i: usize = input1().unwrap();
        ws[i - 1] += 1;
    }

    for i in 0..n {
        println!("{}", if k + ws[i] > q { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<int> dp(n + 1, INT_MAX);
	dp[0] = -1;
	REP(i, n) {
		auto itr = lower_bound(dp.begin(), dp.end(), a[i]);
		*itr = a[i];
	}
	int res = lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin() - 1;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#define llint long long

using namespace std;

llint n;
string s, t;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s >> t;
	string ans;
	for(int i = 0; i < n; i++){
		ans += s[i];
		ans += t[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
 int a,b,c,d;
  cin>>a>>b>>c;
 d=a*100+b*10+c;
  if(d%4==0){
    cout<<"YES\n";
  }else{
    cout<<"NO\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, inf = 1e9 + 5;
int n, root, Pool;
int mx[maxn * 30], rc[maxn * 30], lc[maxn * 30];
void update(int l, int r, int &x, int p, int d) {
	if(!x) {
		x = ++Pool;
	}
	mx[x] = max(mx[x], d);
	if(l == r) {
		return;
	}
	int mid = l + r >> 1;
	if(p <= mid) {
		update(l, mid, lc[x], p, d);
	} else {
		update(mid + 1, r, rc[x], p, d);
	}
}
int query(int l, int r, int x, int a, int b) {
	if(!x || l > b || r < a) {
		return 0;
	}
	if(l >= a && r <= b) {
		return mx[x];
	}
	int mid = l + r >> 1;
	return max(query(l, mid, lc[x], a, b), query(mid + 1, r, rc[x], a, b));
}
int main() {
	scanf("%d", &n);
	vector<pair<int, int> > v;
	for(int i = 1; i <= n; ++i) {
		int x, l;
		scanf("%d%d", &x, &l);
		v.emplace_back(x + l, x - l);
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0; i < v.size(); ++i) {
		int tmp = query(-inf, inf, root, -inf, v[i].second) + 1;
		ans = max(ans, tmp);
		update(-inf, inf, root, v[i].first, tmp);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 23668
#include <iostream>
using namespace std;
int main (void) {
    char a, b;

    cin >> a >> b;

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

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n;
const int mod=1e9+7;
int ksm(int x,int y){
  int z=1;
  while(y){
    if(y&1)z=1ll*z*x%mod;
    x=1ll*x*x%mod;
    y>>=1;
  }
  return z;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  if(n<=1)cout<<0<<'\n';
  else{
    cout<<(ksm(10,n)-(2ll*ksm(9,n)-ksm(8,n)+mod)%mod +10ll*mod)%mod<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double t = (double) (h * 30 + (double) (m / 2));

        double ak = Math.toRadians(t);
        double bk = Math.toRadians(m * 6);
        double ax = a * Math.sin(ak);
        double ay = a * Math.cos(ak);
        double bx = b * Math.sin(bk);
        double by = b * Math.cos(bk);



        System.out.println(Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by)));
    }

}


Measured memory_bytes: 35984
A = str(input())
B = len(A)
C = list(A)
t = 0
for i in range(B):
    if i % 2 == 1:
        if C[i] == "L" or C[i] =="U" or C[i] =="D":
            t += 1
    else:
        if  C[i] == "R"or C[i] == "U" or C[i] =="D":
            t += 1
if t == B  :
    print("Yes")
else:
    print("No")
















Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int n = sc.nextInt();
	    	int[] p = new int[n];
	    	int max = 0;
	    	int count = 0;
	    	for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
			if (p[i] > max) {
				max = p[i];
			}
		}
	    	for (int i : p) {
			count += i;
		}
	    	System.out.println(count - (max /2));
	}
}


Measured memory_bytes: 23508
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Min(int a,int b){return a<b?a:b;}
const int N=2e5+1,M=(N<<2),oo=(~0u>>2);
int n,m,mn[M],z[M],t[M],g[M],ql,qr,qx;
static inline void pu(int x){z[x]=z[x*2];t[x]=t[x*2+1];mn[x]=Min(mn[x*2],mn[x*2+1]);}
static inline void build(int x,int l,int r){if(l==r){z[x]=l;t[x]=l;return;}int m=(l+r)/2;build(x*2,l,m);build(x*2+1,m+1,r);pu(x);}
static inline void pt(int x,int w,int r){g[x]=w;t[x]=w;z[x]=w;if(w<=m){mn[x]=w-r;}else{mn[x]=oo;}}
static inline void upd(int x,int l,int r)
{
  if(z[x]>qr||t[x]<ql){return;}
  if(z[x]>=ql&&t[x]<=qr){pt(x,qr+1,r);return;}
  int m=(l+r)/2;
  if(g[x]){pt(x*2,g[x],m);pt(x*2+1,g[x],r);g[x]=0;}
  upd(x*2,l,m);upd(x*2+1,m+1,r);pu(x);
}
int main()
{
  n=IN(),m=IN();build(1,1,m);
  for(int i=0;i<n;i++){ql=IN(),qr=IN();upd(1,1,m);if(mn[1]>m){puts(""),puts("-1");}else{OUT(mn[1]+i+1);}}
}

Measured memory_bytes: 9784
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n;  cin >> n;
  vll a(n);
  ll front_length = 0, back_length = 0;
  rep0(i,n){
    cin >> a[i];
  }
  int front = 0, back = n-1;
  while(front != back){
    if(front_length <= back_length){
      front_length += a[front];
      front++;
    }else{
      back_length += a[back];
      back--;
    }
  }
  if(front_length <= back_length){
    front_length += a[front];
    front++;
  }else{
    back_length += a[back];
    back--;
  }
  cout << abs(front_length-back_length);
}


Measured memory_bytes: 1792
#include <stdio.h>
typedef long long LL;

int main()
{	 
	long long a, c, b;
	char s[5];
	
	scanf("%lld%s", &a, s);
	b = (LL)(s[0] - 48) * 100 + (LL)(s[2] - 48) * 10 + (LL)(s[3] - 48);
	c = a * b / 100;
	printf("%lld\n", c);
		
	return 0;
}

Measured memory_bytes: 1708
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(X, A, B) :- A =< B , X is A, !.
f(X, A, B) :- X is A - 1.

main :-
	get_number(A),
    get_number(B),
    f(X, A, B),
    writeln(X).


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

int a[111];


int main(){
	int n;
	cin>>n;
	for(int i=0;i<2*n;i++) cin>>a[i];
	sort(a,a+2*n);
	int ans=0;
	for(int i=0;i<2*n;i+=2){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/9/ALDS1_9_C
from heapq import heapify, heappop, heappush, heappushpop


heap = []
# データの入力
while True:
    tmp = input()
    if tmp.startswith('end'):
        break
    elif tmp.startswith('insert'):
        k = int(tmp.split()[1])
        heappush(heap, -k)
    elif tmp.startswith('extract'):
        print(-heappop(heap))



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    ll res = 0;
    ll ma = 1;
    REP(i, N){
    	if(i==0) res += (a[i]-1);
    	else{
    		if(a[i]==ma+1){
    			ma++;
    		}else{
    			res += (a[i]-1)/(ma+1);
    		}
    	}
    }
    cout << res << endl;
    return 0;
}

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

int main(){
	string str;
	cin >> str;
	
	int count = 0;
	for (int i =0; i < str.size(); i++){
		if (str.at(i) == '1') {
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void Solver(int numberOfString,int lengthOfString,String[] arr)
    {
        Arrays.sort(arr);
        String k = "";
        for (int i = 0; i < arr.length; i++) {
            k += arr[i];
        }
        System.out.println(k);
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int numberOfString = input.nextInt();
        int lengthOfStrings = input.nextInt();
        String[] arr = new String[numberOfString];
        String temp;
        for (int i = 0; i < numberOfString; i++) {
            temp = input.next();
            if(temp.length() == lengthOfStrings)
                arr[i] = temp;
        }
        Solver(numberOfString,lengthOfStrings,arr);
    }
}


Measured memory_bytes: 26068
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-2 12:24:56
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  string S;
  cin >> S;
  int N = stoi(S);
  int k = 0;
  for (auto i = 0; i < (int)S.size(); i++)
  {
    k += S[i] - '0';
  }
  if (N % k == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

int main() {
  int n,A=0,B=0;
  cin >> n;
  vector<int>p(n);
  vector<int>q(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> q.at(i);
  }
  vector<int>a(n);
  for (int i = 0; i < n; i++) {
    a.at(i) = i+1;
  }
  map<vector<int>,int>mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(),a.end()));

  int ans = abs(mp.at(p) - mp.at(q));
  cout << ans << endl;
  
}  

Measured memory_bytes: 5248
def f(n):
    if n % 2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1


def main():
    s = int(input())
    elements = set()
    elements.add(s)

    i = 1
    val = s
    while True:
        val = f(val)
        elements.add(val)
        if len(elements) != i + 1:
            print(i + 1)
            exit()
        i += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;

int main()
{
	int n;
	set <int> s;
	s.clear();
	cin >> n;
	for(int i=0;i<n;++i)
	{
		int x;
		cin >> x;
		s.insert(x);
	}
	puts(s.size()==n ? "YES" : "NO");
 	return 0;
}


Measured memory_bytes: 12972
#include<bits/stdc++.h>
using namespace std;
bool check(int a[3][3])
{
    for(int i=0;i<3;i++)
    {
        int count=0;
        
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==-1)
            count++;
        }
        if(count==3)
        return true;
    }
     for(int i=0;i<3;i++)
    {
        int count=0;
        
        for(int j=0;j<3;j++)
        {
            if(a[j][i]==-1)
            count++;
        }
        if(count==3)
        return true;
    }
    if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1)
    return true;
    if(a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1)
    return true;
    return false;
    
}
int main()
{
    int t;
    int a[3][3];
    unordered_map<int,pair<int,int>> m;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
            m[a[i][j]]=make_pair(i,j);
        }
    }
    int n;
    cin>>n;
    while(n--)
    {
        int w;
        cin>>w;
        if(m.find(w)!=m.end())
        {
            int i=m[w].first;
            int j=m[w].second;
            a[i][j]=-1;

        }

    }
   if(check(a))
   cout<<"Yes";
   else
   cout<<"No";
   return 0;

}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    GVI(a,N);
    print(*max_element(ALL(a))-*min_element(ALL(a)));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; j += i) if (j % i == 0) ans += j;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
int s;
cin >> s;
int cnt=1;
  while(1)
  {
    
  if(s==1 || s==2 || s==4)
  {
    cnt+=3;
    break;
  } 
  if(s%2==0)
  {
    s/=2;
    cnt++;
  }
  else
  {
    s=3*s+1;
    cnt++;
  }
  }
cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;
int n;
vector<int> x(101,0), y(101), h(101);

int func(){
  for(int cx=0; cx <= 100; ++cx){
    for(int cy=0; cy <= 100; ++cy){
      int H=-1;
      for(int i=0; i < n; ++i){
        if(h[i] != 0){
          H = h[i] + abs(x[i] - cx) + abs(y[i]-cy);
          break;
        }
      }
      int flag = 1;
      for(int i =0; i<n; ++i){
        if(h[i] > 0 && h[i] != (H-abs(x[i] - cx) - abs(y[i]-cy))){
          flag = 0;
        }
        else if(h[i] == 0 && (H-abs(x[i] - cx) -abs(y[i]-cy))>0){
          flag = 0;
        }
      }
      if(flag){
        cout << cx << " "  << cy << " " << H << endl;
        return 0;
      }
    }
  }
}

int main(){

  cin >> n;

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

  func();

  return 0;
}




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

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

    int n;
    cin >> n;
    int x[n];
    rep(i,0,n) cin >> x[i];
    int sum;
    rep(i,0,n){
    	sum += x[i];
    }
    int ave = floor(sum/n);
    int ave2 = ave+1;
    int ans=0,ans2=0;
    rep(i,0,n){
    	ans += (x[i]-ave)*(x[i]-ave);
    }
     rep(i,0,n){
    	ans2 += (x[i]-ave2)*(x[i]-ave2);
    }
   ans = min(ans,ans2);
    cout << ans << "\n";


    
}

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

int main(void)
{
    long long D;
    cin >> D;
    vector<long long> c(26);
    vector<vector<long long>> used(26);
    for (long long i = 0; i < 26; i++)
    {
        cin >> c[i];
        used[i].push_back(-1);
    }
    vector<vector<long long>> s(D,vector<long long>(26));
    for (long long i = 0; i < D; i++)
    {
        for (long long j = 0; j < 26; j++)
        {
            cin >> s.at(i).at(j);
        }
    }

    long long lastnum = 0;
    vector<long long> ans(D);
    for (long long i = 0; i < D; i++)
    {
        long long pena = 0;
        for (long long j = 0; j < 26; j++)
        {
            pena += c[j] * (i - used.at(j).at(used[j].size() - 1));
        }
        ans[i] = -1;
        long long cnt = -100000000;
        for (long long j = 0; j < 26; j++)
        {
            pena -= c[j] * (i - used.at(j).at(used[j].size() - 1));
            if (s.at(i).at(j) - pena > cnt)
            {
                ans[i] = j;
                cnt = s.at(i).at(j) - pena;
            }
            pena += c[j] * (i - used.at(j).at(used[j].size() - 1));
        }
        used[ans[i]].push_back(i);
        lastnum += cnt;
    }

    while(clock() <  1.9 * CLOCKS_PER_SEC)
    {
        long long cnt = 100000000;
        long long ranD = rand() % D;
        long long ranq = rand() % 26;
        // for (long long i = 0; i < 26; i++)
        // {
        //     if (i != ans[ranD])
        //     {
        //         if (abs(s.at(ranD).at(ans[ranD]) - s.at(ranD).at(i)) < cnt)
        //         {
        //             ranq = i;
        //             cnt = abs(s.at(ranD).at(ans[ranD]) - s.at(ranD).at(i));
        //         }
        //     }
        // }

        used[ans[ranD]].erase(remove(used[ans[ranD]].begin(), used[ans[ranD]].end(), ranD), used[ans[ranD]].end());
        used[ranq].push_back(ranD);
        sort(used[ranq].begin(), used[ranq].end());
        long long oldans = ans[ranD];
        ans[ranD] = ranq;

        long long newnum = 0;
        for (long long i = 0; i< D; i++)
        {   
            newnum += s.at(i).at(ans[i]);
        }
        for (long long j = 0; j < 26; j++)
        {
            long long pena = 0;
            for (long long i = 0; i < used[j].size(); i++)
            {
                if ( used[j].size() == 1)
                {
                    pena += c[j] * D;
                }
                else
                {
                    pena += c[j] * (used[j][i+1] - used[j][i]) * (used[j][i+1] - used[j][i] + 1) / 2;
                }
            }
            newnum -= pena;
        }
        
        if(newnum <= lastnum)
        {
            used[ranq].erase(remove(used[ranq].begin(), used[ranq].end(), ranD), used[ranq].end());
            used[ans[ranD]].push_back(ranD);
            sort(used[ans[ranD]].begin(), used[ans[ranD]].end());
            ans[ranD] = oldans;
        }
        else
        {
            lastnum = newnum;
        }
    }

    for (long long i = 0; i < D; i++)
    {
        cout << ans[i]+1 << endl;
    }
}

Measured memory_bytes: 3908
#include<stdio.h>

int main()
{
    int N;
    double a,x;
    scanf("%d", &N);
    if(N%2==0){
        a=N/2;
        x=a/N;
        printf("%lf\n", x);
    }
    else{
        a=(N+1)/2;
        x=a/N;
        printf("%lf\n", x);
    }
    return 0;

}


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

int main() {
	long long N,K;
	cin >>N>>K;
	long long p;
	p=0;
	for(long long i=K;i<=N+1;i++){
		long long q,r;
		q=(0+i-1)*i/2;
		r=(N+N-i+1)*i/2;
		p+=(r-q)+1;
		p%=1000000007;
	}
	cout <<p;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main() {
  int n; string s; cin >> n >> s;
  int cnt = 0;
  rep(i,1000){
    int c[3] = {i/100,(i%100)/10,i%10};
    int f = 0;
    rep(j,n){
      if(s[j] == c[f] + '0') f++;
      if(f==3) break;
    }
    if(f==3) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=21;
vector<int> f[N][N];
int n,K; char s[1<<N];
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=0;i<=n;++i)
	{
		scanf("%s",s);
		for(int j=0;i+j<=n;++j) f[i][j].resize(1<<i+j);
		for(int j=0;s[j];++j) f[i][0][j]=(s[j]-'0');
	}
	for(int i=n;i;--i)
		for(int j=0;i+j<=n;++j)
			for(int k=0;k<(1<<i+j);++k) if(f[i][j][k])
			{
				int a=k>>j, b=(j?k&((1<<j)-1):0);
				f[0][j][b]+=f[i][j][k];
				if(a)
				{
					int p=32-__builtin_clz(a),nb=j?(b<<1|1):1;
					f[i-(i-p+1)][j+1][(a&((1<<p-1)-1))<<(j+1)|nb]+=f[i][j][k];
				}
				if(a!=(1<<i)-1)
				{
					unsigned tmp=(unsigned)a<<(32-i);
					int p=i-__builtin_clz(~tmp),nb=j?(b<<1):0;
					f[i-(i-p+1)][j+1][(a&((1<<p-1)-1))<<(j+1)|nb]+=f[i][j][k];
				}
			}
	for(int i=n;i;--i)
		for(int k=0;k<(1<<i);++k) if(f[0][i][k]>=K)
		{
			for(int j=i-1;~j;--j) putchar((k>>j&1)+'0');
			return 0;
		}
}


Measured memory_bytes: 167552
#include <iostream>
#include <string.h>

using namespace std;
const int N=2e5+10;
typedef long long LL;
LL head[N],cnt=0,sum[N],pre_sum[N];
struct edge
{
	LL to,next;
}p[N*2];
void add(LL x,LL y)
{
	 p[++cnt].to=y;
	 p[cnt].next=head[x];
	 head[x]=cnt;
}
void spread(LL x)
{
	for(LL i=head[x];i;i=p[i].next)
	{
		pre_sum[p[i].to]+=pre_sum[x];
	}
	sum[x]+=pre_sum[x];
	pre_sum[x]=0;
}
int main()
{
	LL n,q; cin>>n>>q;
	memset(sum,0,sizeof(sum));memset(pre_sum,0,sizeof(pre_sum));
	for(LL i=1;i<n;i++)
	{
		 LL x,y; cin>>x>>y;
		 add(x,y); add(y,x);
	}
	for(LL i=1;i<=q;i++)
	{
		LL x,v;cin>>x>>v;
		pre_sum[x]+=v;
		//spread(x);
	}
	for(LL i=1;i<=n;i++)
		spread(i);
    for(LL i=1;i<=n;i++)
	i!=n?cout<<sum[i]<<' ':cout<<sum[i]<<endl;
    return 0;
}


Measured memory_bytes: 13312
from math import factorial
n,k = map(int, input().split())

for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    else:
        a = factorial(i-1)
        b = factorial(k-1)//(factorial(k-i)*a) * factorial(n-k+1)//(a*i*factorial(n-k+1-i))
        print(b%(10**9+7))


Measured memory_bytes: 3316
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int A = one.get(0);
		int B = one.get(1);
		int C = one.get(2);
		if(C >= A && B >= C){
			myout("Yes");
		}else{
			myout("No");
		}
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 25476
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

def count(X, C, D):
    ret = X - (X//C + X//D - X//lcm(C, D))
    return ret

def main():
    A, B, C, D = map(int, input().split())
    ans = count(B, C, D) - count(A-1, C, D)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 1 << 19;
#define NUM 2147483647

int nn = 1;
int data[MAX_N];

void init(int first_N){
    nn = 1;
    if(first_N < 10) nn = 100;
	while(nn < first_N)nn *= 2;
}

// [left,right]の区間の値をvalueに更新する
// update_(left,right,value,0,0,nn-1)のように呼ぶ
void update_(int update_left,int update_right,int new_value,int node_id,int node_left,int node_right){
	if(update_right < node_left || update_left > node_right)return;
	else if(update_left <= node_left && update_right >= node_right){
		data[node_id] = new_value;
	}else{
		if(data[node_id] >= 0){
			data[2*node_id+1] = data[node_id];
			data[2*node_id+2] = data[node_id];
			data[node_id] = -1;
		}
		update_(update_left,update_right,new_value,2*node_id+1,node_left,(node_left+node_right)/2);
		update_(update_left,update_right,new_value,2*node_id+2,(node_left+node_right)/2+1,node_right);
	}
}

// query_(ite,ite,0,0,nn-1)のように呼ぶ
int query_(int search_left,int search_right,int node_id,int node_left,int node_right){
	if(search_right < node_left || search_left > node_right){
		return -1;
	}else if(node_left <= search_left && node_right >= search_right && data[node_id] >= 0){
		return data[node_id];
	}else{
		int left = query_(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
		int right = query_(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);
		return max(left,right);
	}
}

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

	init(n);

	for(int i = 0; i <= 2*nn-2; i++)data[i] = NUM;

	rep(i,Q){
		int command;
        cin >> command;

		if(command == 0){
            int left,right,value;
			cin >> left >> right >> value;
			update_(left,right,value,0,0,nn-1);
		}else{
            int loc;
			cin >> loc;
			cout << query_(loc,loc,0,0,nn-1) << endl;
		}
	}
}



Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000003,MAX=1000005;
const ll INF=1LL<<55;
ll fac[MAX];

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

void make(){
    fac[0]=fac[1]=1;
    for(ll i=2;i<MAX;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}

int main(){
    
    make();
    int Q;cin>>Q;
    
    while(Q){
        ll X,D,N;cin>>X>>D>>N;
        
        if(D==0){
            cout<<rui(X,N)<<endl;
        }else{
            X=X*rui(D,mod-2)%mod;
            if(X+N-1>=mod) cout<<0<<endl;
            else{
                cout<<fac[X+N-1]*rui(fac[X-1],mod-2)%mod*rui(D,N)%mod<<endl;
            }
        }
        
        Q--;
    }
}



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

using namespace std;

int main(void) {
    long n,m,p;
    cin >> n >> m >> p;

    vector<pair<pair<long,long>,long>> E(m);

    for(int i=0; i<m; i++) {
        long a,b,c;
        cin >> a >> b >> c;
        a--, b--;
        c -= p;
        c *= -1;
        E[i] = pair<pair<long,long>,long>(pair<long,long>(a,b), c);
    }

    vector<long> d(n, 1e15);
    d[0] = 0;

    for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            auto a = E[j].first.first;
            auto b = E[j].first.second;
            auto c = E[j].second;
            d[b] = min(d[a]+c, d[b]);
        }
    }

    long r = -d[n-1];

    for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            auto a = E[j].first.first;
            auto b = E[j].first.second;
            auto c = E[j].second;
            d[b] = min(d[a]+c, d[b]);
        }
    }

    long rr = -d[n-1];

    if(r == rr)
        cout << max(r, 0L) << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n, k; cin >> n >> k;
    int ans = 0;

    while(n>0) {
        ans++;
        n /= k;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {

        int keep=-1;
        string s,t;
        cin >> s >> t;

        for(int i=0; i<s.size()-t.size()+1; i++){
                bool fl=true;
                for(int j=0; j<t.size(); j++){
                        if(s[i+j]!='?'&&s[i+j]!=t[j]){
                                fl=false;
                                break;
                        }
                }

                if(fl){
                        keep=i;
                }
        }

        if(keep==-1)cout<< "UNRESTORABLE";
        else{
                for(int i=0; i<s.size(); i++){
                        if(i>=keep&&i<keep+t.size()) cout<<t[i-keep];
                        else{
                                if(s[i]=='?')cout<<'a';
                                else cout<<s[i];
                        }
                }
        }
        cout << endl;
        return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){

    cout << setprecision(20);

    int n;
    cin >> n;
    vector<i64> x(n), y(n);
    vector<pair<double, i64>> v;
    int n_ = n;
    for(i64 i = 0; i < n; ++i){
        cin >> x[i] >> y[i];
        if(!x[i] && !y[i]){
            --n_;
            continue;
        }
        v.emplace_back(atan2(x[i], y[i]), i);
        v.emplace_back(atan2(x[i], y[i]) + 10, i);
    }
    sort(v.begin(), v.end());
    n = n_;
    i64 ans = 0;
    for(i64 l = 0; l < n; ++l){
        for(i64 i = 0; i <= n; ++i){
            i64 r = l + i;
            i64 sx = 0, sy = 0;
            for(i64 k = l; k < r; ++k){
                sx += x[v[k].second];
                sy += y[v[k].second];
            }
            ans = max(ans, sx * sx + sy * sy);
        }
    }
    printf("%.20lf\n", sqrt(ans));
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int d;
    cin >> d;
    
    int c[26];
    for (int& e: c) cin >> e;

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

    int t[d];
    for (int& e : t) cin >> e;

    int m;
    cin >> m;
    for (int k=0; k<m; k++) {
        int x, y;
        cin >> x >> y;
        t[x-1] = y;

        int last[26] = {};

        ll cur = 0;
        for (int i=0; i<d; i++) {
            cur += s[i][t[i]-1];
            last[t[i]-1] = i+1;

            for (int j=0; j<26; j++) {
                cur -= c[j] * (i-last[j]+1);
            }
        }
        cout << cur << "\n";
    }
}


Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline


def main():
    N = int(input())
    H = list(map(int, input().split()))

    dp = [float("inf")]*N
    dp[0] = 0
    for i in range(N-1):
        dp[i+1] = min(dp[i+1], dp[i] + abs(H[i+1]-H[i]))
        if i+2<N:
            dp[i+2] = min(dp[i+2], dp[i] + abs(H[i+2]-H[i]))
        # print(dp)
    
    print(dp[N-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 52028
N = int(input())
B = list(map(int, input().split()))
ans_list = []
for i in range(N):
    for k in range(len(B)-1, -1, -1):
        if B[k] == k+1:
            ans_list.append(B[k])
            del B[k]
            break
        if k == 0:
            print(-1)
            exit()
for k in range(len(ans_list)):
    print(ans_list[- 1 - k])

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

int main()
{
	int a, b;
	cin >> a >> b;
	if(a == 1 && b == 1) cout << "Draw";
	else if(a == 1) cout << "Alice";
	else if(b == 1) cout << "Bob";
	else if(a > b) cout << "Alice";
	else if(a < b) cout << "Bob";
	else cout << "Draw";

	return 0;
}

Measured memory_bytes: 256