akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

//Be careful 1-indexed
template<typename T>
struct BinaryIndexedTree{
    private:
    vector<T> dat;
    public:
    BinaryIndexedTree(int sz){
        dat.assign(++sz,0);
    }
    void add(int k,T x){
        for (;k<=dat.size();k+=k&-k) dat[k]+=x;
    }
    T sum(int k){
        T ret=0;
        for (;k>0;k-=k&-k) ret+=dat[k];
        return ret;
    }
    int lower_bound(T x){
        if (x<=0) return 0;
        int lb=0,r=1;
        while(r<dat.size()) r<<=1;
        for (;r>0;r>>=1){
            if (lb+r<dat.size()&&dat[lb+r]<x){
                x-=dat[lb+r];
                lb+=r;
            }
        }
        return lb+1;
    }
    T query(int l,int r){ //[l,r)
        return sum(r-1)-sum(l-1);
    }
};

const int alp=26;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n=S.size();
    vector<set<int>> cnt(alp);
    rep(i,n) cnt[S[i]-'a'].insert(i);
    int odd=0;
    rep(i,alp) if (cnt[i].size()%2==1) ++odd;
    if (odd>1){
        cout << -1 << endl;
        return 0;
    }
    vector<int> move(n);
    int now=0;
    rep(i,n){
        int a=S[i]-'a';
        if (cnt[a].empty()) continue;
        if (cnt[a].size()==1){
            move[i]=(n-1)/2;
            cnt[a].erase(i);
            continue;
        }
        int u=*cnt[a].begin(),v=*cnt[a].rbegin();
        move[u]=now,move[v]=n-1-now;
        cnt[a].erase(u),cnt[a].erase(v);
        ++now;
    }
    map<int,int> m;
    rep(i,n) m[move[i]]=i+1;
    BinaryIndexedTree<ll> BIT(n);
    ll ans=0;
    for (int i=n-1;i>=0;--i){
        int x=m[i];
        ans+=BIT.sum(x);
        BIT.add(x,1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12308
#include <stdio.h>
int main ()
{
	int N;
	scanf ("%d", &N);
	char S [10];
	
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;
	
	for (int i= 0; i < N; i++){
		scanf ("%s", S);
		if (S[0] == 'A'){
			AC++;
		}
		else if (S[0] == 'W'){
			WA++;
		}
		else if (S[0] == 'T'){
			TLE++;
		}
		else if (S[0] == 'R'){
			RE++;
		}
	}
printf ("AC x %d\n", AC);
printf ("WA x %d\n", WA);
printf ("TLE x %d\n", TLE);
printf ("RE x %d\n", RE);
return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

int main() {
  ll n, ans = 0, mn = INF,mcnt = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    ans += abs(a[i]);
    mn = min(mn, abs(a[i]));
    if (a[i] < 0) mcnt++;
  }
  cout << (mn == 0 || mcnt % 2 == 0 ? ans : ans - 2 * mn) << endl;
  return 0;
}


Measured memory_bytes: 1152
<?php
# 文字列の入力
fscanf(STDIN, "%d %d", $N ,$Y);
$tmp = '';
for($x = 0; $x <= $N; $x++){
    for($y = 0; $y <= $N; $y++){
        $z = $N - ($x + $y);
        if($z >= 0 && $Y - ((10000 * $x) + (5000 * $y) + (1000 * $z)) === 0){
            $tmp = $x . ' ' . $y . ' '. $z;
        }
    }
}
if ($tmp === '') {
    echo "-1 -1 -1";
} else {
    echo $tmp;
}

?>

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpr make_pair
#define mt make_tuple
 
using namespace std;
 
const ll N = 100010;
const ll mod = 1e9 + 7;
ll power(ll x, ll   y, ll p){ ll res = 1; x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;} return res; }
ll dp[N], visited[N];
vector<int> graph[N];

void dfs(int ind){
    visited[ind] = 1;
    for(int i=0;i<graph[ind].size();i++){
        if(!visited[graph[ind][i]])     dfs(graph[ind][i]);  
        dp[ind] = max(dp[ind],dp[graph[ind][i]] + 1);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,u,v;
    cin>>n>>m;
    memset(visited, 0, sizeof(visited));
    memset(dp, 0, sizeof(dp));
    for(int i=0;i<m;i++){
        cin>>u>>v;
        graph[u].pb(v);
    }
    for(int i=1;i<=n;i++){
        if(!visited[i]) dfs(i);
    }
    cout<<*max_element(dp, dp + n + 1)<<endl;
    return 0;
}

Measured memory_bytes: 9344
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, X := sc.NextInt(), sc.NextInt()
	L := sc.NextIntArray()

	D := 0
	count := 1
	for i := 0; i < N; i++ {
		D += L[i]
		if D <= X {
			count++
		}
	}
	fmt.Println(count)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
a = list(map(int, input().split()))
h = a[0]
w = a[1]
k = a[2]

cols = ([input() for i in range(h)])

ans = 0

for col_mask in range(1 << (h + 1) - 1):
    for row_mask in range(1 << (w + 1) - 1):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((1 << i) & col_mask) == 0 and ((1 << j) & row_mask) == 0 and cols[i][j] == '#':
                        black = black + 1
        if black == k:
            ans = ans + 1
print(ans)


Measured memory_bytes: 9216
#include<stdio.h>
#define SIZE 200000
int main()
{
  int n,m;
  int a[SIZE],b[SIZE];
  int i,x,y;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++) a[i]=b[i]=0;
  for(i=0;i<m;i++)
    {
      scanf("%d%d",&x,&y);
      if(x==1) a[y-1]=1;
      if(y==n) b[x-1]=1;
    }
  for(i=0;i<n;i++)
    {
      if((a[i]==1)&&(b[i]==1))
	{
	  printf("POSSIBLE\n");
	  break;
	}
    }
  if(i==n) printf("IMPOSSIBLE\n");
  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#define MAX 105
#define INF (1<<21)
int g[MAX][MAX],n,judge[MAX];
int prim();

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf ("%d",&g[i][j]);
      if(g[i][j]==-1) g[i][j]=INF;
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim(){
  int i,u,v,min,d[MAX],p[MAX],sum=0;
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    judge[i]=0;
  }
  d[0]=0;
  while(1){
    min=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i] && judge[i]!=1){
	u=i;
	min=d[i];
      }
    }
    if(u==-1) break;
    judge[u]=1;
    for(v=0;v<n;v++){
      if(judge[v]!=1 && g[u][v]!=INF){
	if(d[v]>g[u][v]){
	  d[v]=g[u][v];
	  p[v]=u;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=g[i][p[i]];
  }
  return sum;
}
  
    
  
  
  



Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cstring>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 303;

int dist[ms][ms];

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m, tank;
	std::cin >> n >> m >> tank;
	memset(dist, 0x3f, sizeof dist);
	for(int i = 0; i < n; i++) {
		dist[i][i] = 0;
	}
	while(m--) {
		int u, v, c;
		std::cin >> u >> v >> c;
		u--;v--;
		dist[u][v] = std::min(dist[u][v], c);
		dist[v][u] = dist[u][v];
	}
	for(int k = 0; k < n; k++) {
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(dist[i][j] <= tank) {
				dist[i][j] = 1;
			} else {
				dist[i][j] = 0x3f3f3f3f;
			}
		}
		dist[i][i] = 0;
	}
	for(int k = 0; k < n; k++) {
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	std::cin >> m;
	while(m--) {
		int u, v;
		std::cin >> u >> v;
		u--;v--;
		std::cout << (dist[u][v] <= tank ? dist[u][v] - 1 : -1) << '\n';
	}
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>

// a > b
inline int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

inline int lcm(int a, int b) {
    if (a < b)
        return a * b / gcd(b, a);
    return a * b / gcd(a, b);
}


int main(void) {
    int n, a, b, i, j, *x, ablcm, count;

    while (scanf("%d%d%d\n", &n, &a, &b) != EOF && (n || a || b)) {
        x = (int*)calloc(n+1, sizeof(int));

        for (i = b; i <= n; i += b) {
            x[i] = 1;
        }
        ablcm = lcm(a, b);
        for (i = 0; i <= ablcm; i += b) {
            for (j = 0; i + j <= n; j += a) {
                x[i + j] = 1;
            }
        }
        for (i = 1, count = 0; i <= n; i++) {
            count += x[i] == 0;
        }

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

        free(x);
    }

    return 0;
}

Measured memory_bytes: 4520
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int P = 1e9 + 7 ; 
const int N = 5000 + 5 ; 
int n, f[N][N], dp[N], sz[N], g[N] ; 
vector<int> G[N] ; 
void add( int x, int y ) { G[x].push_back(y), G[y].push_back(x) ; }
void dfs( int x, int fa ) {
	f[x][sz[x] = 1] = 1 ; 
	for( int v : G[x] ) {
		if( v == fa ) continue ; dfs( v, x ) ;
		rep( i, 0, sz[x] + sz[v] ) dp[i] = 0 ;
		rep( i, 0, sz[x] ) rep( j, 0, sz[v] ) dp[i + j] = ( dp[i + j] + f[x][i] * f[v][j] % P ) % P ; 
		rep( i, 1, sz[x] + sz[v] ) f[x][i] = dp[i] ; sz[x] += sz[v] ; 
	}
	rep( i, 1, sz[x] ) f[x][0] = ( f[x][0] - f[x][i] * g[i] % P + P ) % P ; 
}
signed main()
{
	n = gi(), g[0] = 1 ; int x, y ; 
	rep( i, 2, n ) x = gi(), y = gi(), add( x, y ) ;
	rep( i, 2, n ) ( i & 1 ) ? g[i] = 0 : g[i] = g[i - 2] * ( i - 1 ) % P ; 
	dfs( 1, 1 ), printf("%lld\n", P - f[1][0] % P ) ; 
	return 0 ;
}

Measured memory_bytes: 195072
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=4e5+5;
typedef long long ll;
#define lch x<<1
#define rch x<<1|1
ll tree[N];
ll a[N],b[N];
ll cnt,n,k;
ll sum[N];
ll t[N];
ll L[N],R[N];
ll dp[N];
void Pushdown(ll x){
    if(tree[x]){
        tree[lch]=tree[rch]=tree[x];
        tree[x]=0;
    }
}
void Modify(ll x,ll l,ll r,ll pl,ll pr,ll d){
    if(l>r||pl>pr)
        return ;
    if(pl<=l&&r<=pr){
        tree[x]=d;
        return ;
    }
    Pushdown(x);
    ll mid=(l+r)>>1;
    if(pl<=mid)
        Modify(lch,l,mid,pl,pr,d);
    if(pr>mid)
        Modify(rch,mid+1,r,pl,pr,d);
}
ll Query(ll x,ll l,ll r,ll pos){
    if(l==r)
        return tree[x];
    Pushdown(x);
    ll mid=(l+r)>>1;
    if(pos<=mid)
        return Query(lch,l,mid,pos);
    else
        return Query(rch,mid+1,r,pos);
}
ll Ask(ll pos){
    ll c=Query(1,1,cnt,pos);
    if(!c)
        return 0;
    ll res=1ll*dp[c]+(t[L[c]]-t[pos]+k)%k;
    return res;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(ll i=1;i<=n;i++){
        scanf("%d%d",&a[i],&b[i]);
        sum[i]=sum[i-1]+a[i];
        if(b[i]==1&&2*a[i]>k){
            puts("-1");
            return 0;
        }
    }
    for(ll i=1;i<=n;i++){
        if(b[i]==1){
            L[i]=(-2*sum[i-1]%k+k)%k;
            R[i]=(-2*sum[i]%k+k)%k;
        }
        else{
            L[i]=0;
            R[i]=k-1;
        }
        t[i*2-1]=L[i];
        t[i*2]=R[i];
    }
    sort(t+1,t+2*n+1);
    cnt=unique(t+1,t+2*n+1)-t-1;
    for(ll i=1;i<=n;i++){
        L[i]=lower_bound(t+1,t+cnt+1,L[i])-t,R[i]=lower_bound(t+1,t+cnt+1,R[i])-t;
    }
    for(ll i=n;i>0;i--){
        dp[i]=Ask(L[i]);
        if(L[i]>R[i]){
            Modify(1,1,cnt,R[i]+1,L[i]-1,i);
        }
        else{
            Modify(1,1,cnt,1,L[i]-1,i);
            Modify(1,1,cnt,R[i]+1,cnt,i);
        }
    }
    ll ans=dp[1];
    for(ll i=1;i<=cnt;i++){
        ans=min(ans,Ask(i));
        //printf("%lld\n",Ask(i));
    }
    printf("%lld\n",ans+sum[n]*2);
}


Measured memory_bytes: 21376
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset> //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip> //do setprecision
#include <ctime>
#include <complex>
using namespace std;

int main(void){
  int A,B,C;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  if((A+B)>=C){
   printf("Yes\n"); 
  }else{
    printf("No\n");
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vector<bool> dist(N, false);
  vector<int> ans(N);
  queue<int> Q;
  dist[0] = true;
  Q.push(0);

  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    for (int nv : G[v]) {
      if (dist[nv]) continue;
      dist[nv] = true;
      ans[nv] = v;
      Q.push(nv);
    }
  }
  
  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) {
    cout << ans[i]+1 << endl;
  }
}

Measured memory_bytes: 10116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> cnt(3,0);
    ll ans=1;
    rep(i,N){
        ll a=0;
        rep(j,3) if (cnt[j]==A[i]) ++a;
        if (a==0){
            ans=0;
            break;
        }
        ans*=a;
        ans%=MOD;
        rep(j,3) if (cnt[j]==A[i]){
            ++cnt[j];
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
f = True
if N == 1 and A[0] == 1:
    print(1)
    exit()

if N % 2 == 1:
    if A[0] != 1:
        f = False
    else:
        del A[0]
    if set(A) != set(range(2, N, 2)) or set(A.values()) != {2}:
        f = False
else:
    if set(A) != set(range(1, N, 2)) or set(A.values()) != {2}:
        f = False
if not f:
    print(0)
else:
    print(2 ** len(A) % (10 ** 9 + 7))

Measured memory_bytes: 16620
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define MOD 998244353
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll INF = 1e17;
const double pi = 3.141592653589793;

int T;

int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll N;
  ll ans = 1;
  cin >> N;
  bool flag = false;
  vector<ll> arr;
  vector<ll> pos;
  for(int i = 0 ; i < N ; i++) {
  	ll x;
  	cin >> x;
	arr.pb(x);
	if(x == 0) {
		cout << "0" << endl;
		return 0;
	}
  }
  for(int i = 0 ; i < arr.size() ; i++) {
   	if(ans > 1000000000000000000 / arr[i]) {
  		cout << "-1" << endl;
  		return 0;
  	}
  	ans *= arr[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4216
#include "bits/stdc++.h"
using namespace std;

int main() {
	int H, W;
	for (int a = 0; ; a++) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}


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

using namespace std;

int const NMAX = int(1e5);
int const INF = int(2e9);

int main() {
    int dp[NMAX];

    int n;
    cin >> n;
    vector<int> h(n);
    for (int i=0; i<n; ++i) cin >> h[i];

    fill(dp, dp+NMAX, INF);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i=2; i<n; ++i) {
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1152
from collections import defaultdict
from heapq import heappush, heappop
import math
import bisect
import random

def LI(): return list(map(int, input().split()))
def I(): return int(input())
def LIM(): return list(map(lambda x:int(x) - 1, input().split()))
def LS(): return input().split()
def S(): return input()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007


n, k = LI()
a_list = LI()


rev_tuple = []
for i in range(len(a_list)):
    num = a_list[i]
    a = len([j for j in a_list[i:] if j < num]) % mod
    b = len([j for j in a_list if j < num]) % mod
    rev_tuple += [(a, b)]



ans = 0

for a, b in rev_tuple:
    ans += b * k * (k - 1) // 2 % mod
    ans %= mod
    ans += a * k % mod
    ans %= mod





print(ans % mod)

Measured memory_bytes: 44252
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    ans = 0
    a = []
    for c in S:
        a.append(chr(((ord(c) - ord('A')) + N) % 26 + ord('A')))
    return ''.join(a)


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6860
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	if(n==0 || n==2){
		cout<<1<<endl;
	}else if(n==1){
		cout<<2<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mods[] = {998244353, 1000000007, 1000000009};
const ll bases[] = {997, 1009, 1013};
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

class union_find {
private:
  vl *par;
  vl *rnk;
  vl *siz;
public:
  union_find (ll n){
    par = new vl(n);
    iota(par->begin(),par->end(),0);
    rnk = new vl(n,0);
    siz = new vl(n,1);
  }
  ll find(ll x){
    if(par->at(x) == x) return x;
    else return par->at(x) = find(par->at(x));
  }
  ll size(ll x){
    return siz->at(find(x));
  }
  void unite(ll x,ll y){
    x = find(x);y = find(y);
    if(x == y)return;
    if(rnk->at(x) < rnk->at(y)){
      par->at(x) = y;
      siz->at(y) += siz->at(x);
    }
    else {
      par->at(y) = x;
      siz->at(x) += siz->at(y);
      if(rnk->at(x) == rnk->at(y)) rnk->at(x)++;
    }
  }
  bool same(ll x,ll y){
    return find(x) == find(y);
  }
};

ll n,m;
graph g,t;
graph tmp;
vl a,b;
vl used;
vl cnt;
mt ans;



ll dfs(ll curr, ll prev){
  ll ret = 0;
  if(used[curr]) cerr << "!";
  used[curr] = 1;
  for(auto next : t[curr]){
    if(next.first == prev) continue;
    ll hoge = dfs(next.first, curr);
    if(hoge){
      ans.push_back(vl({next.first, curr}));
      cnt[next.first]++;
    }else{
      ans.push_back(vl({curr, next.first}));
      cnt[curr]++;
    }
  }

  return cnt[curr]%2;

}

void error(){
  cout << -1 << endl;
  exit(0);
}

union_find uf(0);

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

  a = b = vl(m);
  for(ll i = 0;i < m;i++) cin >> a[i] >> b[i];
  if(m%2 == 1){
    error();
  }
  for(ll i = 0;i < m;i++) g[a[i]][b[i]] = g[b[i]][a[i]] = 1;
  used = vl(n+1);
  cnt = vl(n+1);
  uf = union_find(n+1);
  for(ll i = 0;i < m;i++){
    if(uf.same(a[i], b[i])){
      ans.push_back(vl({a[i],b[i]}));
      cnt[a[i]]++;
    }else{
      t[a[i]][b[i]] = t[b[i]][a[i]] = 1;
      uf.unite(a[i], b[i]);
    }
  }
  // for(ll i = 0;i <= n;i++) cerr << used[i] << " ";
  // cerr << endl;

  // for(ll i = 1;i <= n;i++) cerr << cnt[i] << " ";
  // cerr << endl;
  // used = vl(n+1);
  // // cerr << dfs(1, 0) << endl;
  // // for(ll i = 0;i <= n;i++) cerr << used[i] << " ";
  // // cerr << endl;
  dfs(1, 0);

  // graph verificaiton;
  // for(vl& x : ans){
  //   verificaiton[x[0]][x[1]] = 1;
  // }
  // for(ll i = 1;i <= n;i++){
  //   if(verificaiton[i].size()%2 != 0){
  //     cerr << "WA" << endl;
  //     for(ll i = 1;i <= n;i++) cerr << cnt[i] << " ";
  //     cerr << endl;
  //     return 0;
  //
  //   }
  //
  // }
  // cerr << "AC" << endl;

  for(vl& x : ans){
    cout << x[0] << " " << x[1] << endl;
  }



}


Measured memory_bytes: 59804
#include <stdio.h>
int main()
{
  int a,b;
  
  scanf("%d%d",&a,&b);
  if (a==b)
  
  {
    printf("Yes");
    
  }
  
  else
  {
   
    
  printf("No");
  }
  
  return 0;
  
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
        int h, w;

        while(true) {
                cin >> h >> w;
                if(h == 0 && w == 0) break;
                for(int i = 0; i < h; i++) {
                        printf("#");
                        for(int n = 2; n < w; n++) {
                                if(i == 0) {
                                        printf("#");
                                } else if(i == (h - 1)) {
                                        printf("#");
                                } else {
                                  //if(n == 0) printf("#");
                                  //if(n == (h - 1)) printf("#");
                                  printf(".");
                                }
                        }
                        printf("#");
                        cout << endl;
                }
                cout << endl;
        }
}



Measured memory_bytes: 3072
from collections import Counter

N = int(input())
A =input()
B =input()
C =input()

L = [[A[i],B[i],C[i]] for i in range(N)]

c = 0
for l in L:
    l.sort()
    c += 3 - max(list(Counter(l).values()))
 
print(c)
    



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

int main(void){
    ll N,M,K;
    cin >> N >> M >> K;
    ll mem[N*M+1];
    memset(mem,0,N*M+1);
    REP(i,N+1){
        REP(j,M+1){
            mem[i*M+j*N-2*i*j] = 1;
        }
    }
    if(mem[K]==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main(){
  vector<char> S(3);
  for(int i=0;i<3;i++){
    cin >> S.at(i);
  }
  if(S.at(0)==S.at(1)){
    if(S.at(1)==S.at(2)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
	"strings"
)

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func ifval(cond bool, a interface{}, b interface{}) interface{} {
	return map[bool]interface{}{true: a, false: b}[cond]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	arr, _ := mapf(strconv.Atoi, strings.Split(scanner.Text(), " ")).([]int)
	W, H, x, y, r := arr[0], arr[1], arr[2], arr[3], arr[4]

	fmt.Println(ifval((x >= r && x <= W-r) && (y >= r && y <= H-r), "Yes", "No").(string))
}



Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int r;
	cin>>r;
	ld Radius = r;
	ld pi = 3.14159265359;
	cout<<fixed<<setprecision(8)<<2*pi*Radius<<"\n";
	return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <set>
#include <stdio.h>

using namespace std;
using ll = unsigned long long;

int mul(ll* out, ll a, ll b)
{
  ll x1,x2,x3,x4;
  x1 = ( a & 0xffffffffULL ) * ( b & 0xffffffffULL );
  x2 = ( a >> 32 ) * ( b & 0xffffffffULL );
  x3 = ( a & 0xffffffffULL ) * ( b >> 32 );
  x4 = ( a >> 32 ) * ( b >> 32 );
  if( x4 != 0 ) return -1;
  if( ( x2 >> 32 ) != 0 || ( x3 >> 32 ) != 0 ) return -1;
  if( ( x1 >> 32 ) + ( x2 & 0xffffffffULL ) + ( x3 & 0xffffffffULL ) > 0x7fffffffULL ) return -1;
  ll rc = x1 + (x2 << 32) + (x3 << 32);
  if( rc > 1000000000000000000ULL ) return -1;
  *out = rc;
  return 0;
}

int main()
{
  int n;
  cin >> n;
  
  long long x = 1;
  for(int i=0;i<n;i++){
    ll a;
    cin >> a;
    if( a == 0 ){
      x = 0;
    } else if( x == -1 ){
      ;
    } else {
      long long o;
      if( mul((ll*)(&o),x,a)<0 ){
        x = -1;
      } else {
        x = o;
      }
    }
  }
  
  cout << x << "\n";
  return 0;
  
}



Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(), y = scanner.nextInt();
		for(int i=0;i<=n;i++){
			for(int j=n-i;j>=0;j--){
				int sum = i * 10000;
				sum += j * 5000;
				sum += (n - (i + j)) * 1000;
				if(sum == y){
					System.out.println(i + " " + j + " " + (n-(i+j)));
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}

}


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

int main(){
    int n, i, sum = 0;
    cin >> n;
    int b[n] = {};
    b[0] = 100000;
    for(i=1; i<n; i++){
        cin >> b[i];
        sum += min(b[i-1], b[i]);
    }
    sum += b[n-1];
    cout << sum;
}

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

using namespace std;

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100100];

int main(void) {
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < 100010; i++) dp[i] = INF;

    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            long long tmp = dp[i] + abs(h[i] - h[i + j]);
            if (dp[i + j] > tmp) {
                dp[i + j] = tmp;
            }
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		int max = 0;
		int min = 500;
		int a;
		while(n>0){
		    int point = 0;
		    for(int i=0; i<5; i++){
			a = kbd.nextInt();
			point += a;
		    }
		    if(max < point) max = point;
		    if(min > point) min = point;
		    n--;
		}
		System.out.println(max+" "+min);
	    }
	}
    }
}

Measured memory_bytes: 33664
N = int(input())
nums = list(map(int, input().split()))
cnt = 0
ren = 0
for i in range(N):
  if nums[i] == i+1:
    cnt += 1
    ren += 1
  elif ren > 1:
    cnt -= ren//2
    ren = 0
  else:
    ren = 0
if ren > 1:
  cnt -= ren//2
print(cnt)


Measured memory_bytes: 14008
import sys
input = sys.stdin.readline

H,W = map(int, input().split())
dp = [[] for _ in range(H)]
for i in range(H):
	data = input()
	for j in range(W):
		if data[j] == "." : dp[i].append(1)
		else : dp[i].append(0)
for i in range(H):
	for j in range(W):
		if(dp[i][j]!=0):
			if(i > 0 and j > 0) : dp[i][j] = dp[i-1][j]+dp[i][j-1]
			elif(i > 0) : dp[i][j] = dp[i-1][j]
			elif(j > 0) : dp[i][j] = dp[i][j-1]
print(dp[H-1][W-1]%(10**9+7))

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int kagamiKasane = 1;
  for (int i = 1; i < vec.size(); i++) {
    if (vec.at(i) > vec.at(i - 1)) kagamiKasane++; 
  }
  
  cout << kagamiKasane << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  ll n,a,b,ng=-1,ok=-1;cin>>n>>a>>b;
  vector<ll> h(n);
  for(int i=0;i < n;i++)
  {
    cin>>h[i];
    ok=max(ok,(h[i]+b-1)/b);
  }
  ok++;

  while(abs(ok-ng)>1){
    ll mid=(ng+ok)/2,need=0;

    rep(i,n){
      need+=max((h[i]-b*mid+a-b-1)/(a-b),0ll);
    }

    if(need<=mid){
      ok=mid;
    }else{
      ng=mid;
    }
  }

  cout<<ok<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,s,x[N];
long long z,p[N];
int main()
{
	scanf("%d%d",&n,&s);
	for (int i=1;i<=n;i++)scanf("%d%d",&x[i],&p[i]);
	for (int l=1,r=n;l<=r;)
	 {
	 	if (x[l]>=s)
	 	 {
	 	 	z+=x[r]-s;
	 	 	break;
		 }
		if (x[r]<=s)
		 {
		 	z+=s-x[l];
		 	break;
		 } 
		z+=x[r]-x[l];
		if (p[l]>=p[r])
		 {while (l<r&&p[l]>=p[r])p[l]+=p[r--];}
		else {while (l<r&&p[l]<p[r])p[r]+=p[l++];}  
	 }
	printf("%lld",z);
	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int N, A, B;
    cin >> N >> A >> B;
    string s;
    cin >> s;

    int na = 0;
    int nb = 0;
    rep(i, N) {
        if (s[i] == 'a') {
            if (na + nb < A + B) {
                cout << "Yes" << endl;
                na++;
            } else {
                cout << "No" << endl;
            }
        }
        if (s[i] == 'b') {
            if (na + nb < A + B && nb < B) {
                cout << "Yes" << endl;
                nb++;
            } else {
                cout << "No" << endl;
            }
        }
        if (s[i] == 'c') {
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef double ld;

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

	ll n, c[4] = {}, i, j, k, a, N = 301;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		c[a]++;
	}

	ld dp[N][N][N], total = 0.0;

	for (i = 0; i < N; i++)
		for (j = 0; j < N; j++)
			for (k = 0; k < N; k++)
				dp[i][j][k] = 0.0;

	for (k = 0; k <= c[3]; k++)
		for (j = 0; j <= c[3] + c[2]; j++)
			for (i = 0; i <= n; i++)
			{
				total = i + j + k;
				if (total > 0)
					dp[k][j][i] += n / total;
				if (k > 0)
					dp[k][j][i] += k * dp[k - 1][j + 1][i] / total;
				if (j > 0)
					dp[k][j][i] += j * dp[k][j - 1][i + 1] / total;
				if (i > 0)
					dp[k][j][i] += i * dp[k][j][i - 1] / total;
			}

	printf("%.15lf\n", dp[c[3]][c[2]][c[1]]);
	return 0;
}

Measured memory_bytes: 213248
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
//typedef struct fac { LL n, exp; }F;
//LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 300009

void run(void) {
	int x;
	in("%d", &x);
	printf(x >= 30 ? "Yes" : "No");
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
		fflush(stdout);
	}
	return 0;
}

Measured memory_bytes: 1716
line = [i for i in input().split()]
a = 0
b = ""
c = 0
d = ""
for i in range(len(line)):
    if i == 0:
        a = line.count(line[i])
        b = line[i]
        c = len(line[i])
        d = line[i]
    elif line.count(line[i]) > a:
        a = line.count(line[i])
        b = line[i]
    if len(line[i]) > c:
        c = len(line[i])
        d = line[i]
print(b+" "+d)

Measured memory_bytes: 7436
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {

	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}

		out << "\n";
	}
		
    return out;

}

vector<vector<int> > tree;
map<pair<int, int>, int> colors;
int used;

void dfs(int u, int p) {
	if (p != -1) {
		for (int i = 0, c = 1; i < tree[u].size(); ) {
			if (tree[u][i] == p) {
				++i;
				continue;
			}

			if (colors[make_pair(p, u)] != c) {
				colors[make_pair(u, tree[u][i])] = c;
				colors[make_pair(tree[u][i], u)] = c;
				dfs(tree[u][i], u);
				used = max(used, c);
				++i;
			}

			++c;
		}
	} else {
		for (int i = 0, c = 1; i < tree[u].size(); ++c, ++i) {
			colors[make_pair(u, tree[u][i])] = c;
			dfs(tree[u][i], u);
			used = max(used, c);
		}
	}
}

int main() {

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

	int n;
	cin >> n;

	tree = vector<vector<int> > (n + 1, vector<int> ());
	vector<pair<int, int> > edges(n - 1);
	int u, v;
	for (int i = 0; i < n - 1; ++i) {
		cin >> u >> v;
		tree[u].push_back(v);
		tree[v].push_back(u);
		edges[i] = {u, v};
	}

	dfs(1, -1);

	cout << used << "\n";
	for (int i = 0; i < n - 1; ++i) {
		cout << colors[edges[i]] << "\n";
	}

	return 0;

}

Measured memory_bytes: 19456
#include <stdio.h>
#include <string.h>
int main(){
	char words[105];
	int k;
	int word;
	scanf("%d" ,&k);
	scanf("%s" ,words);
	word = strlen(words);
	if (word <= k){
		printf("%s" ,words);
	}
	else if(word > k){
		words[k] = '\0';
		printf("%s..." ,words);
	}
	return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
string s;
unsigned long long n;
unsigned long long a[2000005],b[2000005];
int main(){
	cin>>s;
	n=s.size();
	int i,j;
	for(i=n-1;i>-1;--i) a[i]+=a[i+1]+(long long)(s[i]=='B');
	for(i=n-1;i>-1;--i) b[i]+=b[i+1]+(long long)(s[i]=='W');
//	for(i=n-1;i>-1;--i) if(s[i]=='W') a[i]+=a[i+1];
//	for(i=n-1;i>-1;--i) if(s[i]=='B') b[i]+=b[i+1];
//	for(i=0;i<n;++i) cout<<a[i]<<' ';
//	cout<<endl;
//	for(i=0;i<n;++i) cout<<b[i]<<' ';
//	cout<<endl;
	unsigned long long aa=0,bb=0;
	for(i=0;i<n;++i) if(s[i]=='B') aa+=b[i]; else bb+=a[i];
	cout<<aa<<endl;
	return 0;
}

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

using namespace std;

int N;
int dp[1000001], dpodd[1000001];

int main() {

	//前計算でdpテーブルを計算。8sもあるのでオーダーは怪しいけど大丈夫のはず
	for (int i = 1; i <= 1000000; i++)dp[i] = 1 << 29, dpodd[i] = 1 << 29;

	dp[0] = 0, dpodd[0] = 0;
	for (int i = 1;; i++) {
		int cur = i * (i + 1) * (i + 2) / 6;
		
		if (cur > 1000000)break;

		for (int j = cur; j <= 1000000; j++) {
			if (cur % 2 == 1) {

				dpodd[j] = min(dpodd[j], dpodd[j - cur] + 1);
			}

			dp[j] = min(dp[j], dp[j - cur] + 1);
		}

	}

	while (1) {
		cin >> N;
		if (N == 0)break;
		cout << dp[N] << " " << dpodd[N] << endl;
	}
	return 0;
}


Measured memory_bytes: 10796
//=Main Part==================================================================//
@inlinable
func main(_ args: [String]) -> Int32 {
  // Your code goes here
  let a = geti()
  print(a * (a * (a + 1) + 1))

  return 0
}

//=Utilities for Programming Contests=========================================//
import Foundation
// input
@discardableResult
@inlinable @inline(__always) func gets() -> String { readLine()! }
@inlinable @inline(__always) func geti() -> Int    { Int(gets())! }
@inlinable @inline(__always) func getd() -> Double { Double(gets())! }
// array
@inlinable @inline(__always) func getsA(_ c: Character = " ") -> [String] { gets().split(separator: c).map(String.init) }
@inlinable @inline(__always) func getiA(_ c: Character = " ") -> [Int]    { gets().split(separator: c).map{ Int(String.init($0))! } }
@inlinable @inline(__always) func getdA(_ c: Character = " ") -> [Double] { gets().split(separator: c).map{ Double(String.init($0))! } }
// structured bindings: splat
prefix operator *
@inlinable @inline(__always) prefix func * <E> (a: [E]) -> (E, E)       { (a[0], a[1]) }
@inlinable @inline(__always) prefix func * <E> (a: [E]) -> (E, E, E)    { (a[0], a[1], a[2]) }
@inlinable @inline(__always) prefix func * <E> (a: [E]) -> (E, E, E, E) { (a[0], a[1], a[2], a[3]) }

//=Execution==================================================================//
exit(main(CommandLine.arguments))


Measured memory_bytes: 13292
#include<cstdio>
long long a,b,k;
main(){
    scanf("%lld%lld%lld",&k,&a,&b);
    if(k<=a)return puts("1"),0; //按思路特判
    else if(a<=b)return puts("-1"),0;   //按思路特判
    else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
    //按思路求解，此处的位运算 <<1 = *2 , |1 = +1
}

Measured memory_bytes: 128
rank = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]

a, b = map(str, input().split())

if rank.index(a) > rank.index(b):
    print(">")
elif rank.index(a) == rank.index(b) : 
    print("=")
else :
    print("<")

Measured memory_bytes: 3060
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]


H, W = map(int, input().split())
S = [0]*H
for i in range(H):
    S[i] = input()

ans = makelist(H, W)

def check(p):
    x, y = p
    return x >= 0 and y >= 0 and x < W and y < H

def calc(p, vol):
    return (p[0]+vol[0], p[1]+vol[1])

vols = [ (x, y) for x in range(-1, 2) for y in range(-1, 2) if x != 0 or y != 0] 

for y in range(H):
    for x in range(W):
        if S[y][x] == '#':
            ans[y][x] = '#'
            for vol in vols:
                now = calc((x, y), vol)
                if check(now):
                    if ans[now[1]][now[0]] != '#':
                        ans[now[1]][now[0]] += 1
for e in ans:
    print("".join(map(str, e)))


Measured memory_bytes: 3064
N = input()
a = map(int, raw_input().split())
div4 = sum(map(lambda x: 1 if x % 4 == 0 else 0, a))
div2 = sum(map(lambda x: 1 if x % 2 == 0 else 0, a)) - div4
edge = 1 if div4 > 0 else 0
penalty = 1 if div2 == 1 else 0
if N <= div4 * 2 + edge or N <= div4 * 2 + div2 - penalty:
  print "Yes"
else:
  print "No"


Measured memory_bytes: 11320
n, k = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
min = Float::INFINITY

0.upto(n - k) do |i|
  a = x[i].abs + (x[i + k - 1] - x[i]).abs
  b = x[i + k - 1].abs + (x[i] - x[i + k - 1]).abs
  min = [[a, b].min, min].min
end

puts min

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

void solve(){
  int n, l;
  cin>>n>>l;
  vector<string> st;
  string input;
  for(int i=0; i<n; i++){
    cin>>input;
    st.push_back(input);
  }
  string resultString = "";
  sort(st.begin(), st.end());

  for(int i=0;i<n;i++){
    resultString += st[i];
  }

  cout<<resultString;

}

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

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <memory>

template <class M>
class segtree {
    private:
        //using value_type = typename M::value_type;
        typedef typename M::value_type value_type;
        value_type value;
        std::unique_ptr<segtree> lch, rch;
        int size;
        M append;
    public:
        segtree(int n) : value(M::init), size(n) {
            if (n <= 1) return;
            lch.reset(new segtree(n / 2));
            rch.reset(new segtree(n - n / 2));
        }
        value_type range_query(int a, int b) {
            if (a <= 0 && size <= b) return value;
            if (b <= 0 || size <= a) return M::init;
            int lsize = lch->size;
            auto left = lch->range_query(a, b),
                 right = rch->range_query(a - lsize, b - lsize);
            return append(left, right);
        }
        void update(int k, value_type x) {
            if (!lch && !rch) {
                value = x;
                return;
            }
            else if (k < lch->size) lch->update(k, x);
            else rch->update(k - lch->size, x);
            value = append(lch->value, rch->value);
        }
};

struct MinInt {
    //using value_type = int;
    typedef int value_type;
    static constexpr value_type init = std::numeric_limits<int>::max();
    int operator() (int a, int b) const {
        return std::min(a, b);
    }
};

enum command { Update, Find, };

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, q;
    std::cin >> n >> q;
    segtree<MinInt> rmq(n);
    for (auto i = 0; i < q; i++) {
        int com, x, y;
        std::cin >> com >> x >> y;
        switch (com) {
            case Update:
                rmq.update(x, y);
                break;
            case Find:
                std::cout << rmq.range_query(x, y + 1) << '\n';
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 10596
//RohitKaushal
#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
    return a*a + b*b;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lf%lf", &x[i], &y[i]);
        X += x[i]; Y += y[i];
    }
    X /= n; Y /= n;
    double P = 0.1;
    for (int i = 0; i < 30000; i++) {
        int f = 0;
        d = dist(X - x[0], Y - y[0]);
        for (int j = 1; j < n; j++) {
            e = dist(X - x[j], Y - y[j]);
            if (d < e) { d = e; f = j; }
        }
        X += (x[f] - X)*P;
        Y += (y[f] - Y)*P;
        P *= 0.999;
    }
    printf("%.10lf", sqrt(d));
}

Measured memory_bytes: 128