akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

typedef struct{
  int top,front,right,left,back,bottom;
}dice;

void diceroll(dice* d, char c);

int main(void){
  dice d[100];
  int i,j,n;
  int c=0;
  scanf("%d",&n);

  for(i=0;i<n;i++)
  scanf("%d %d %d %d %d %d", &d[i].top, &d[i].front, &d[i].right, &d[i].left, &d[i].back,&d[i].bottom);
 
  for(i=1;i<n;i++){  
  if(d[i].top==d[0].front) diceroll(&d[i],'S');
  else  if(d[i].bottom==d[0].front) diceroll(&d[i],'N');
  else if(d[i].right==d[0].front) diceroll(&d[i],'W'),diceroll(&d[i],'S');
  else if(d[i].left==d[0].front) diceroll(&d[i],'E'),diceroll(&d[i],'S');
  else if(d[i].back==d[0].front) diceroll(&d[i],'S'),diceroll(&d[i],'S');
  }

   for(i=0;i<4;i++){
     for(j=1;j<n;j++){
        if(d[0].top==d[j].top&&
        d[0].bottom==d[j].bottom&&
        d[0].right==d[j].right&&
        d[0].left==d[j].left&&
        d[0].back==d[j].back){
            printf("No\n");
            return 0;
        }
        diceroll(&d[j],'E');
    }
   }
 
    printf("Yes\n");
     
  return 0;
}


void diceroll(dice* d, char c){
  int temp;

  switch(c){
  case 'E':
  temp=d->top;
  d->top=d->left;
  d->left=d->bottom;
  d->bottom=d->right;
  d->right=temp;
  break;
  case 'N':
  temp=d->top;
  d->top=d->front;
  d->front=d->bottom;
  d->bottom=d->back;
  d->back=temp;
  break;
  case 'S':
  temp=d->top;
  d->top=d->back;
  d->back=d->bottom;
  d->bottom=d->front;
  d->front=temp;
  break;
  case 'W':
  temp=d->top;
  d->top=d->right;
  d->right=d->bottom;
  d->bottom=d->left;
  d->left=temp;
  break;
  case 'R':
  temp=d->front;
  d->front=d->left;
  d->left=d->back;
  d->back=d->right;
  d->right=temp;
  break;
  case 'L':
  temp=d->front;
  d->front=d->right;
  d->right=d->back;
  d->back=d->left;
  d->left=temp;
  break;
 case 's':
   temp=d->right;
  d->right=d->left;
  d->left=temp;
  break;
 case 'b':
   temp=d->front;
  d->front=d->back;
  d->front=temp;
  break;
case 'B':
   temp=d->top;
  d->top=d->bottom;
  d->bottom=temp;
  break;
  default:
    break;
  }


}

Measured memory_bytes: 1788
import java.util.*;

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

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        Set<Integer> set = new TreeSet<>();
        for (int i = 0; i < k; i++) {
            set.add(Math.min(a + i, b));
            set.add(Math.max(b - i, a));
        }
        for (int i : set) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <limits.h>

int main(void)
{
    int N, T, c, t, ans = INT_MAX, i;
    scanf("%d%d", &N, &T);
    for (i = 0; i < N; ++i) {
        scanf("%d%d", &c, &t);
        if (t <= T && c < ans) ans = c;
    }
    if (ans == INT_MAX) puts("TLE");
    else printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Unionfind uf=new Unionfind(n+m);
		int[] u=new int[m];
		int q=0;
		for(int i = 0; i<n; i++){
			int k = sc.nextInt();
			for(int j = 0; j<k; j++){
				int l = sc.nextInt()-1;
				if(u[l]==0){
					q++;
					u[l]++;
				}
				uf.unite(i,n+l);
			}
		}
		if(uf.size(0)==q+n){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
	static class Unionfind{
		int[] parent;
		int[] size;
		public Unionfind(int n){
			this.parent=new int[n];
			this.size=new int[n];
			for(int i = 0; i<n; i++){
				parent[i]=i;
				size[i]=1;
			}
		}
		public int root(int t){
			if(parent[t]==t){
				return t;
			}else{
				return parent[t]=root(parent[t]);
			}
		}
		public void unite(int x,int y){
			if(same(x,y)){
				return;
			}
			int xroot = root(x);
			int yroot = root(y);
			parent[yroot]=xroot;
			size[xroot]+=size[yroot];
		}
		public boolean same(int x,int y){
			return root(x)==root(y);
		}
		public int size(int x){
			return size[root(x)];
		}
	}
}


Measured memory_bytes: 66104
//雋ｰ縺・DP繝ｫ繝ｼ繝・
#include<bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

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; }
template<typename T,typename U>
void Printarray(T f,U n){for(U i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n,k;cin>>n>>k;
  int h[n];rep(i,n)cin>>h[i];
  long long dp[n];
  const long long INF = 1LL << 60;

  dp[0]=0;
  for(int i = 1; i < n; i++){
    dp[i]=INF;
    for(int j=1;j<=k;j++){
      if(i-j>=0)
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }

  //Printarray(dp,n);

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


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

#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)

using namespace std;

ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}

int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}

ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}

ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
// 2 2 2 7
// 2 2 2 3 3
// 3 3 7

// 3
// 2 
// 3 3
bool isprime[200001];
void makesieve() {
	memset(isprime, true, sizeof(isprime));
	for (int i = 2; i <= sqrt(200000); ++i)
	{
		/* code */
		if(isprime[i]) {
			for (int j = i*i; j <= 200000; j+=i)
			{
				/* code */
				isprime[j]=false;
			}
		}
	}
}
// 3 - (1+1)*4
// 5 - (2+2+2+2+1+1+1)
void solve() {
	int k; cin>>k;
	string s; cin>>s;
	if(s.length()>k) cout<<s.substr(0,k) << "...";
	else cout << s;
 }
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3652
if __name__=='__main__':
    N = int(input())
    hi = [int(i) for i in input().split()]
    dp = [0 for i in range(N)]
    dp[1] = abs(hi[0]-hi[1])
    
    for i in range(2,N):
        dp_1 = dp[i-1] + abs(hi[i]-hi[i-1])
        dp_2 = dp[i-2] + abs(hi[i]-hi[i-2])
        dp[i] = min(dp_1,dp_2)
            
    print(dp[N-1])

Measured memory_bytes: 13924
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
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;}


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

  rep(i,0,n-1){
    cin >> a[i];
    b[a[i]-1]++;
  }
  rep(i,0,n){
    cout << b[i] << endl;
  }
}


Measured memory_bytes: 4840
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>
#include<map>
#include<bitset>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void solve() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for (int i = 0; i < N; i++)cin >> p[i];

	// 1000までの単一の期待値を計算
	vector<double> ev(1010);
	for (int x = 1; x <= 1000; x++) {
		ev[x] = 0;
		for (int y = 1; y <= x; y++) {
			ev[x] += (y + .0) / (x + .0);
		}
	}

	// Kまでの和
	double sum = 0;
	for (int i = 0; i < K; i++) { sum += ev[p[i]]; }

	double ans = sum;
	for (int i = K; i < N; i++) {
		sum += ev[p[i]];
		sum -= ev[p[i - K]];
		ans = max(ans, sum);
	}
	// 桁数格納やめて(半ギレ)
	printf("%.6f", ans);
}

int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 1024
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let n=nin()
  let s=sin()
  for(let k=0;k<n;k++){
    let t='';
    for(let i=0;i<s.length;i++){
      t+=sw(s[i],[
        'A','B',
        'B','C',
        'C','D',
        'D','E',
        'E','F',
        'F','G',
        'G','H',
        'H','I',
        'I','J',
        'J','K',
        'K','L',
        'L','M',
        'M','N',
        'N','O',
        'O','P',
        'P','Q',
        'Q','R',
        'R','S',
        'S','T',
        'T','U',
        'U','V',
        'V','W',
        'W','X',
        'X','Y',
        'Y','Z',
        'Z','A'
      ]);
    }
    s = t;
  }
  out(s);
}
main()


Measured memory_bytes: 14264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int k;
    cin >> k;
    vector<ll> a;
    rep(i,9){
        a.push_back(i+1);
    }
    while(1){
        if(k <= a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();

        vector<ll>old;
        swap(old,a);

        for(ll x:old){
            for(int i = -1;i < 2;i++){
                ll y = x%10+i;
                if(y<0 || y>9)continue;
                ll xy = x*10+y;
                a.push_back(xy);
            }
        }

    }
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
#define sort(x) sort((x).begin(), (x).end())
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;

int N, A, B, C;
int boo[20];
int ans = INF;

void dfs(int i, int a, int b, int c, int mp){
    if(i == N)
        if(a == A || b == B || c == C)return;
        else{
            ans = min(ans, abs(a)+abs(b)+abs(c)+mp);
            return;
        }
    else{
    dfs(i+1, a-boo[i],b,c, mp+ (a==A?0:10) );
    dfs(i+1, a,b-boo[i],c, mp+ (b==B?0:10) );
    dfs(i+1, a,b,c-boo[i], mp+ (c==C?0:10) );
    dfs(i+1, a,b,c, mp);
    }
}

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    cin>> N>>A>>B>>C;
    for(int i = 0; i < N; ++i)
        cin>>boo[i];

    dfs(0, A, B ,C, 0);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

using Point=std::complex<long double>;

const long double EPS=1e-10;
const long double PI=std::acos(-1.0l);

bool EQ(long double a,long double b){return std::abs(a-b)<EPS;}
bool EQP(Point a,Point b){return EQ(a.real(),b.real())&&EQ(a.imag(),b.imag());}

Point unitvec(Point a){return a/std::abs(a);}

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

  ll n;
  while(std::cin>>n,n){
    std::vector<Point> point;
    rep(i,0,n){
      long double a,b;
      std::cin>>a>>b;
      point.emplace_back(a,b);
    }

    std::vector<Point> candi;
    rep(i,0,n){
      rep(j,i+1,n){
        if(std::abs(point[j]-point[i])<=2.0l+EPS){
          Point mid=(point[i]+point[j])/2.0l;

          Point unit=unitvec(point[i]-mid);
          unit*=std::sqrt(1.0l-std::norm(point[i]-mid));
          candi.push_back(unit*Point(0,1)+mid);
          candi.push_back(unit*Point(0,-1)+mid);
        }
      }
    }

    ll ans=1;
    for(auto e:candi){
      ll cnt=0;
      rep(i,0,n){
        if(std::abs(e-point[i])<=1.0l+EPS)cnt++;
      }
      chmax(ans,cnt);
    }
    std::cout<<ans<<"\n";
  }

  return 0;
}



Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,m,d;
  cin >> n >> m >> d;
  char c[n][m];
  rep(i,n){
    rep(j,m){
      cin>>c[i][j];
    }
  }
  int ans=0;
  rep(i,n){
    int res=1;
    rep(j,m-1){
      if(c[i][j]==c[i][j+1] && c[i][j]=='.'){
        res++;
        if(res>=d)ans++;
      }
      else res=1;
    }
  }
  rep(j,m){
    int res=1;
    rep(i,n-1){
      if(c[i][j]==c[i+1][j] && c[i][j]=='.'){
        res++;
        if(res>=d)ans++;
      }
      else res=1;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;cin>>n;
  double ans=0.0,x=0.0;
  string u;
  rep(i,n) {
    cin>>x>>u;
    if(u=="JPY") ans+=x;
    else ans+=x*380000.0;
  }
  printf("%.10f",ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long ans = Long.MAX_VALUE;
		int end = 1 << n;
		for (int i = 0; i < end; i++) {
			long val = 0;
			int now = 0;
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if ((i >> j & 1) == 1) {
					val += Math.max(now + 1 - a[j], 0);
					now = Math.max(now + 1, a[j]);
					cnt++;
				} else {
					now = Math.max(now, a[j]);
				}
			}
			if (cnt >= k) {
				ans = Math.min(ans, val);
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;cin>>s;
  string hoge[]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
  rep(i,7){
    if(s==hoge[i]){
      cout<<i+1<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
N = int(input())
S = [x for x in input()]

for i in range(len(S)) :
    if ord(S[i])+N > 90 :
        S[i] = chr(ord(S[i])+N-26)
    else :
        S[i] = chr(ord(S[i])+N)

print("".join(S))


Measured memory_bytes: 3060
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *D = map(int, read().split())

    print(len(set(D)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;

template <typename T>
class FenwickTree
{
public:
  int N;
  vector<T> dat;

  FenwickTree(int n, T m = 0)
  {
    init(n, m);
  }

  void init(int n, int m)
  {
    N = n;
    dat.resize(n + 1);
    for (int i = 0; i < dat.size(); i++)
    {
      dat[i] = m;
    }
  }

  int64_t sum(int i)
  {
    T s = 0;
    while (i > 0)
    {
      s += dat[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, T x)
  {
    while (i <= N)
    {
      dat[i] += x;
      i += i & -i;
    }
  }
};

int main()
{
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  vector<int64_t> S(N + 1, 0);
  for (int i = 1; i <= N; i++)
  {
    S[i] = S[i - 1] + A[i - 1];
  }
  vector<int64_t> v, cv;
  for (int i = 0; i <= N; i++)
  {
    v.push_back(S[i] - i * K);
  }
  cv = v;
  sort(v.begin(), v.end());
  map<int64_t, int64_t> mp;
  int n = 1;
  for (int i = 0; i <= N; i++)
  {
    if (i && v[i - 1] < v[i])
    {
      n++;
    }
    mp[v[i]] = n;
  }
  for (int i = 0; i <= N; i++)
  {
    cv[i] = mp[cv[i]];
  }
  int64_t ans = 0;
  FenwickTree<int64_t> ft(MAXN);
  for (auto c : cv)
  {
    ans += ft.sum(c);
    ft.add(c, 1);
  }
  cout << ans << endl;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


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



void print(const vint& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

void insertionSort(vint &A){
  for(ll i=1; i<A.size(); ++i){
    rep(k,A.size()-1) cout<<A[k]<<" ";
    cout<<A.back()<<endl;
    ll v = A[i];
    ll j = i - 1;
    while( j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }
}

int main() {


  cout<<fixed<<setprecision(10);

  ll n; cin>>n;
  vint v(n);rep(i,n)cin>>v[i];

  insertionSort(v);
  rep(k,v.size()-1) cout<<v[k]<<" ";
  cout<<v.back()<<endl;
}





//




Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    string s;
    cin>>s;
    rep(i,s.size()) {
        if(s[i]!='?') cout<<s[i];
        else cout<<'D';
    }    
}

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

int main()
{
  int d;
  int n;
  long square[600], s;
  int max=0;
  int i;

  square[0]=0;
  while(cin>>d){
    n=600/d-1;
    if(max<n){
      for(i=max+1; i<=n; i++){
        square[i]=square[i-1]+i*i;
      }
      max=n;
    }
    s=square[n]*d*d*d;
    printf("%ld\n", s);
  }

  return 0;
}

Measured memory_bytes: 0
using System;
public class AOJ1335
{
	public static void Main ()
	{
		new AOJ1335 ();
	}

	Scanner sc;
	int N, K, S;

	public AOJ1335 ()
	{
		sc = new Scanner (Console.In);
		while (sc.HasNext()) {
			N = sc.NextInt ();	K = sc.NextInt ();	S = sc.NextInt ();
			if (N == 0)	break;
			solve ();
		}
	}
	void solve ()
	{
		Console.WriteLine (f1 (N, S, 1));
	}

	int f1 (int prev, int sum, int depth)
	{
		if (depth > K)	return sum == 0 ? 1 : 0;
		if (sum <= 0)	return 0;

		int ret = 0;
		for (int i=prev; i>=1; --i)	ret += f1 (i - 1, sum - i, depth + 1);
		return ret;
	}
}



public class Scanner
{
	int p, n;
	const int MAX = 1 << 10;
	System.IO.TextReader src;
	char[] buf = new char[MAX];
	bool[] isSpace = new bool[128];

	public Scanner (System.IO.TextReader src)
	{
		this.src = src;
		isSpace [' '] = isSpace ['\n'] = isSpace ['\r'] = isSpace ['\t'] = true;
	}
			
	private int Read ()
	{
		if (n == -1)
			return -1;
		if (p >= n) {
			p = 0;
			n = src.Read (buf, 0, MAX);
			if (n <= 0) {
				n = -1;
				return -1;
			}
		}
		return buf [p++];
	}

	public bool HasNext ()
	{
		int c = Read ();
		while (c>=0 && isSpace[c])
			c = Read ();
		if (c == -1)
			return false;
		--p;
		return true;
	}

	public int NextInt ()
	{
		if (!HasNext ())
			throw new Exception ("NoSuchElementException");
		int c = Read (), sign = 1;
		if (c == '-') {
			sign = -1;
			c = Read ();
		}
		int ret = 0;
		do {
			if (!('0' <= c && c <= '9'))
				throw new Exception ("InputMismatchException " + (char)c);
			ret = ret * 10 + (int)(c - '0');
			c = Read ();
		} while(c>=0 && !isSpace[c]);
		return ret * sign;
	}

}

Measured memory_bytes: 5548
#include <stdio.h>

int min(int a, int b) {
	if (a < b) { return a; }
	else { return b; }
}

int max(int a, int b) {
	if (a > b) { return a; }
	else { return b; }
}

int dp[5005][5005];

int main() {

	int N;

	char S[5005];

	scanf("%d",&N);

	scanf("%s",S);

	int i, j;

	for (i = N - 1; i >= 0; i--) {
		for (j = N - 1; j >= 0; j--) {
			if (S[i] == S[j]){
				dp[i][j] = dp[i + 1][j + 1] + 1;
			}
			else{
				dp[i][j] = 0;
			}
		}
	}

	int ans = 0;

	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (i < j) {
				int v = min(dp[i][j],j-i);
				ans = max(ans,v);
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 97920
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.WebSockets;

class Test
{

    // Driver code 
    public static void Main()
    {
        ///var t = int.Parse(Console.ReadLine());

        //while (t > 0)
        {
          //  t--;

            var ii = Console.ReadLine().Split(' ').Where(xx => !string.IsNullOrEmpty(xx)).Select(xx => int.Parse(xx)).ToArray();

            var n = ii[0];
           // var x = ii[1];
           // var tt = ii[2];

             var arr = Console.ReadLine().Split(' ').Where(x => !string.IsNullOrEmpty(x)).Select(xx => long.Parse(xx)).ToList();

            long ans = 0;

            for(int i=1;i<n;i++)
            {
                if(arr[i]<arr[i-1])
                {
                    ans = ans + arr[i - 1] - arr[i];
                    arr[i] = arr[i] + (arr[i - 1] - arr[i]);
                }
            }
            Console.Write(ans);
            Console.WriteLine();
        }
    }

}




Measured memory_bytes: 44584
#include <stdio.h>

int main(void)
{
    int p[3][3][2], t[3], i, j, k;
    
    for(i = 0; i < 3; i++){
        for(k = 0; k < 2; k++){
            for(j = 0; j < 3; j++){
                scanf("%d", &p[i][j][k]);
            }
        }
        t[i] = (p[i][0][1] * 60 * 60 + p[i][1][1] * 60 + p[i][2][1]) - (p[i][0][0] * 60 * 60 + p[i][1][0] * 60 + p[i][2][0]);
    }
    
    
    for(i = 0; i < 3; i++){
        printf("%d ", t[i] / 3600);
        t[i] %= 3600;
        printf("%d ", t[i] / 60);
        t[i] %= 60;
        printf("%d\n", t[i]);
    }
    
    return (0);
}

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

double len = 0;
int cnt = 0;

void solve(vector<pair<int, int>> &coords, vector<int> &path, vector<bool> &visited, int cur) {
    if (cur == path.size()) {
        for (int i = 1; i < path.size(); i++) {
            int x = coords[path[i]].first - coords[path[i - 1]].first;
            int y = coords[path[i]].second - coords[path[i - 1]].second;
            len += sqrt(x * x + y * y);
        }
        cnt++;
        return;
    }
    for (int i = 0; i < visited.size(); i++) {
        if (!visited[i]) {
            visited[i] = true;
            path[cur] = i;
            solve(coords, path, visited, cur + 1);
            visited[i] = false;
        }
    }
}

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

    int N;
    cin >> N;
    vector<pair<int, int>> coords(N);
    for (int i = 0; i < N; i++)
        cin >> coords[i].first >> coords[i].second;

    vector<int> path(N);
    vector<bool> visited(N, false);
    solve(coords, path, visited, 0);
    cout << fixed << setprecision(10) << len / cnt << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 2000005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll r1, c1, r2, c2, fac[N] = {1, 1}, inv[N] = {1, 1}, fiv[N] = {1, 1};

ll s(ll p, ll q) {
	return (fac[p + q + 2] * fiv[p + 1] % M * fiv[q + 1] % M - 1 + M) % M;
}

int main()
{
	ll i;
	cin >> r1 >> c1 >> r2 >> c2;
	for (i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % M;
		inv[i] = inv[M % i] * (M - M / i) % M;
		fiv[i] = fiv[i - 1] * inv[i] % M;
	}
    cout << (s(r2, c2) - s(r1 - 1, c2) - s(r2, c1 - 1) + s(r1 - 1, c1 - 1) + 2 * M) % M << endl;
    return 0;
}

Measured memory_bytes: 47104
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF = 1LL << 55;

int n,p;
bool odd=false;
int a;

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

    cin>>n>>p;
    rep(i,n){
        cin>>a;
        if(a%2!=0) odd=true;
    }

    if(!odd){
        if(p==0) cout<<(1LL<<n)<<endl;
        else cout<<0<<endl;
    }else{
        cout<<(1LL<<(n-1))<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//-------------------------------------------------------
long S[100000]; 
int last[100000];
void Calc(){
	int N = rei();
	//(A-B)*k
	//N-1 - (A-B)*k
	//N-1-A = (A-B)*(K-1)
	for(int i=0;i<N;i++){
		S[i] = rei();
	}
	long ans = 0;
	for(int i=1;i<=N-1;i++){
		long sum = 0;
		for(int j=0;j<N;j+=i){
			if(last[j] == i || last[N-1-j] == i || j == N-1-j || N-1-j < i){
				break;
			}
			sum += S[j] + S[N-1-j];
			last[j] = i;
			last[N-1-j] = i;
			ans = max(ans,sum);
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1408
A, B, C, D, E, F = map(int, input().split())
sugar_total = [-1, 1]
for a in range(0, F + 1, 100 * A):
    for b in range(0, F - a + 1, 100 * B):
        water = a + b
        if water == 0:
            continue
        for c in range(0, F - water + 1, C):
            for d in range(0, min(F - water - c, (water // 100) * E - c) + 1, D):
                sugar = c + d
                total = water + sugar
                if sugar / total > sugar_total[0] / sugar_total[1]:
                    sugar_total[0], sugar_total[1] = sugar, total
print(sugar_total[1], sugar_total[0])


Measured memory_bytes: 3064
def main():
    from heapq import heappush, heappop
    import sys
    sys.setrecursionlimit(10 ** 7)

    n,q=map(int,input().split())

    event=[]
    for _ in range(n):
        s,t,x=map(int,input().split())
        event.append((s-x,1,x))
        event.append((t-x,-1,x))

    for i in range(q):
        event.append((int(input()),2,i))
    event.sort()

    ans=[0]*q

    stop=set()
    hq=[]
    for t,op,x in event:
        if op==1:
            heappush(hq,x)
            stop.add(x)
        elif op==-1:
            stop.remove(x)

        else:
            while hq and hq[0] not in stop:
                heappop(hq) 
            ans[x]=hq[0] if hq else -1
        
    for x in ans:
        print(x)

main()

Measured memory_bytes: 97552
#include <iostream>

using namespace std;

int main()
{
    int W, H, x, y , r;
    cin >> W >> H >> x >> y >> r;
    if((x+r)>W || (x-r)<0 || (y+r)>H || (y-r)<0 || x<0 || y<0) cout << "No";
    else cout << "Yes";
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  cout << str[0];
  for(int i=0; i<str.size();i++){
  if(str[i]==' '){
   cout << str[i+1];
  }
  }
  cout << endl;
 
}

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

int main(void){
  int N,i;
  int x[105];
  scanf("%d\n",&N );
  for(i=0; i < N; i++){
    scanf("%d\n",&x[i] );
    if(x[i] % 2 == 0){
      if((x[i] % 3 != 0) && (x[i] % 5 != 0)){
        printf("DENIED" );
        exit(0);
      }
    }
  }
  printf("APPROVED");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

const int smax = 3005;
int ss, st;
string s, t;

vector<vector<int> > dp(3005, vector<int>(3005, 0));

int main() {
	cin>>s>>t;
	
	ss = (int) s.size();
	st = (int) t.size();
	
	for(int i=0; i<=ss; i++) {
		for(int j=0; j<=st; j++) {
			if(i==0 || j==0) continue;
			if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	
	int sx = ss, sy = st;
	
	int longest = dp[sx][sy]-1;
	string res(dp[sx][sy], '?');
	while(sx>0 && sy>0) {
		if(s[sx-1] == t[sy-1]) {
			res[longest] = s[sx-1];
			sx--;
			sy--;
			longest--;
		} else {
			if(dp[sx-1][sy] > dp[sx][sy-1]) sx--;
			else sy--;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
void solve()
{
  int n,a,b;
  cin>>n>>a>>b;
  if(a/n==b/n && a%n!=0 && b%n!=0)
  {
    cout<<"NG";return;
  } 
  cout<<"OK";

}
int main()
{
  fastio;
//  fopen();
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}


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

int main() {
    string s;
    cin >> s;
    int price = 700;
    if (s[0] == 'o') price+=100;
    if (s[1] == 'o') price+=100;
    if (s[2] == 'o') price+=100;
    cout << price << endl;
}

Measured memory_bytes: 256
n = int(input())
t = 0
h = 0
for i in range(n):
    cardt,cardh = input().split()
    if cardt == cardh:
        t += 1
        h += 1
    elif cardt > cardh:
        t += 3
    else:
        h += 3
print(t,h)
    


Measured memory_bytes: 5596
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int x,y;
	cin>>x>>y;
	if(x*2<=y && x*4>=y && y%2==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;

}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 3576
import math

aka, mi, ao = map(int, input().split(" "))
k = int(input())

for i in range(k):
    if mi <= aka:
        mi *= 2
        continue
    if ao <= mi:
        ao *= 2
        continue
    ao *= 2

if ao > mi > aka:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<stdio.h>
int main(void) {
	int i;
	int n;
	int max;
	int min;
	long int sum = 0;
	int a[10000];
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	max = min = a[0];
	for(i = 0; i < n; i++) {
		if(a[i] > max) {
			max = a[i];
		} else if(a[i] < min) {
			min = a[i];
		}
		sum += a[i];
	}
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;
 
const int N = 100005, M = 200005;
 
int n, m, dfn[N], val[N], l[M], r[M], ans[M], cnt = 0;
pair<int, int> vec[N];
vector<pair<int, int> > g[N];
bool vis[N], flag = true;
 
int dfs (int u) {
	int x = val[u];
	vis[u] = true;
	for (int i = 0; i < g[u].size(); i++) {
		int v = g[u][i].first;
		if (!vis[v]) {
			int y = dfs(v);
			if (y) ans[g[u][i].second] = 1, x ^= 1;
		}
	}
	return x;
}
int main () {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%d%d", &vec[i].first, &vec[i].second);
 
	sort(vec, vec + n);
	for (int i = 0; i <= n; i++) {
		val[i] = 0;
		if (i < n) val[i] ^= vec[i].second;
		if (i) val[i] ^= vec[i - 1].second;
	}
 
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &l[i], &r[i]);
		int pos_l = lower_bound(vec, vec + n, make_pair(l[i], 0)) - vec;
		int pos_r = lower_bound(vec, vec + n, make_pair(r[i] + 1, 0)) - vec;
		if (pos_l == pos_r) continue;
		g[pos_l].push_back(make_pair(pos_r, i));
		g[pos_r].push_back(make_pair(pos_l, i));
	}
 
	for (int i = 0; i <= n; i++) vis[i] = false;
	for (int i = 1; i <= m; i++) ans[i] = 0;
	for (int i = 0; i <= n; i++) {
		if (!vis[i]) flag &= !dfs(i);
	}
 
	if (!flag) puts("-1");
	else {
		int k = 0;
		for (int i = 1; i <= m; i++) k += ans[i];
		printf("%d\n", k);
		for (int i = 1; i <= m; i++) {
			if (ans[i]) printf("%d ", i);
		}
		printf("\n");
	}
	return 0;
}
/*
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;
 
const int N = 100005, M = 200005;
 
int n, m, dfn[N], val[N], l[M], r[M], ans[M], cnt = 0;
pair<int, int> vec[N];
vector<pair<int, int> > g[N];
bool vis[N], flag = true;
 
int dfs (int u) {
	int x = val[u];
	vis[u] = true;
	for (int i = 0; i < g[u].size(); i++) {
		int v = g[u][i].first;
		if (!vis[v]) {
			int y = dfs(v);
			if (y) ans[g[u][i].second] = 1, x ^= 1;
		}
	}
	return x;
}
int main () {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%d%d", &vec[i].first, &vec[i].second);
 
	sort(vec, vec + n);
	for (int i = 0; i <= n; i++) {
		val[i] = 0;
		if (i < n) val[i] ^= vec[i].second;
		if (i) val[i] ^= vec[i - 1].second;
	}
 
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &l[i], &r[i]);
		int pos_l = lower_bound(vec, vec + n, make_pair(l[i], 0)) - vec;
		int pos_r = lower_bound(vec, vec + n, make_pair(r[i] + 1, 0)) - vec;
		if (pos_l == pos_r) continue;
		g[pos_l].push_back(make_pair(pos_r, i));
		g[pos_r].push_back(make_pair(pos_l, i));
	}
 
	for (int i = 0; i <= n; i++) vis[i] = false;
	for (int i = 1; i <= m; i++) ans[i] = 0;
	for (int i = 0; i <= n; i++) {
		if (!vis[i]) flag &= !dfs(i);
	}
 
	if (!flag) puts("-1");
	else {
		int k = 0;
		for (int i = 1; i <= m; i++) k += ans[i];
		printf("%d\n", k);
		for (int i = 1; i <= m; i++) {
			if (ans[i]) printf("%d ", i);
		}
		printf("\n");
	}
	return 0;
}*/

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

#define int long long int

int32_t main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;++i) cin >> arr[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1] - arr[0]);

    for(int i=2;i<n;++i)
    {
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]) , dp[i-2] + abs(arr[i] - arr[i-2]));
    }

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

Measured memory_bytes: 1792
N,M=map(int,input().split())
dp=[-1]*N
dp[-1]=1
dp+=[1]
mod=10**9+7
for i in range(M):
  a=int(input())
  dp[a]=0
i=N-2
while i>=0:
  if dp[i]==-1:
    dp[i]=(dp[i+1]+dp[i+2])%mod
  i-=1
print(dp[0])


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

bool my_compare(pair<int, string> a, pair<int, string> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
        // return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}
int main(){
  int N,i,num=0;
  cin >> N;
  vector<string> S(N);
  map<string,int> cnt;
  vector<pair<int,string>> V;

  for(i=0;i<N;i++)
  cin >> S.at(i);

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

  for(i=0;i<N;i++){
    if(cnt.count(S.at(i)))
    cnt[S.at(i)]++;
    else
    cnt[S.at(i)] = 1;
  }

  for(auto p : cnt){
    auto k = p.first;
    auto v = p.first;
    V.push_back(make_pair(p.second, p.first));
  }
  sort(V.begin(),V.end(),my_compare);

  for(i=0;i<V.size();i++){
    if(i==0)
    num = V.at(i).first;
    if(num == V.at(i).first)
    cout << V.at(i).second << endl;
    else
    break;
  }
  
}

Measured memory_bytes: 31216
#include <bits/stdc++.h>
using namespace std;
 
long long n;
 
int main(){
	
  cin >> n;
  
  if (n % 2==1) cout << "0" << endl;
  else{
    long long ans;
    
  	n/=2;
    
    while (n!=0){
    	  ans+=n/5;
      	  n/=5;
    }
    
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import sys
N = int(input())
W=[]
for i in range(N):
	W = W +[input()]
for j in range(N-1):
	if W[j][-1]==W[j+1][0]:
		pass
	else:
		print("No")
		sys.exit()
for k in range(N):
	if W.count(W[k])==1:
		pass
	else:
		print("No")
		sys.exit()
print("Yes")

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

int main(){
  int w,h,n;
  int x,y,a,b[110][110]={0},s=0;
  cin >> w >> h >> n;
  for(int i=0; i <n ; ++i){
    cin >> x >> y >> a;
    if(a==1)for(int j =0;j<x;j++)for(int k =0;k<h;k++)b[j][k]=1;
    if(a==2)for(int j =x;j<w;j++)for(int k =0;k<h;k++)b[j][k]=1;
    if(a==3)for(int j =0;j<w;j++)for(int k =0;k<y;k++)b[j][k]=1;
    if(a==4)for(int j =0;j<w;j++)for(int k =y;k<h;k++)b[j][k]=1;
    }
  for(int j =0;j<w;j++)for(int k =0;k<h;k++)if(b[j][k]==0)s++;
  cout << s << endl;
}


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

void compute(){
    int A[9], B[9];
    for ( int i = 0; i < 9; i++ ) cin >> A[i];
    for ( int i = 0; i < 9; i++ ) cin >> B[i];
    
    sort(A, A + 9);
    int w = 0, sum = 0;
    do{
	int a = 0, b = 0;
	for ( int i = 0; i < 9; i++ ){
	    if ( A[i] > B[i] ) a += A[i]+B[i];
	    else b += A[i]+B[i];
	}
	if ( a > b ) w++;
	sum++;
    } while( next_permutation(A, A+9));
    double ra = 1.0*w/sum;
    double rb = 1 - ra;
    printf("%.8lf %.8lf\n", ra, rb);
}

main(){
    int tcase; cin >> tcase;
    for ( int i = 0; i < tcase; i++ ) compute();
}

Measured memory_bytes: 908
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

//Z-algorithm
vector<int> Zalgo(const string &S)
{
	int N = (int)S.size();
	vector<int> res(N);
	res[0] = N;
	int i = 1, j = 0;
	while (i < N)
	{
		while (i + j < N && S[j] == S[i + j]) ++j;
		res[i] = j;
		if (j == 0) { ++i; continue; }
		int k = 1;
		while (i + k < N && k + res[k] < j) res[i + k] = res[k], ++k;
		i += k, j -= k;
	}
	return res;
}


int main()
{
	int n; cin >> n;
	string s; cin >> s;
	int res = 0;
	rep(i, n - 1)
	{
		string tmp = s.substr(i);
		vector<int> Z = Zalgo(tmp);
		rep(j, Z.size())
		{
			res = max(res, min(j, Z[j]));
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3680
#include<iostream>
#include <algorithm>
#include<vector>
using namespace std;
int main(void){
  vector<int> v;
  int a,b,c;
  int s;
  cin >> a >> b >> c;
  v = {a,b,c};
  sort(v.begin(),v.end());
  cout<< (v.at(2) * 10 + v.at(1) + v.at(0));
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    double d, t, s;
    cin >> d >> t >> s;

    string ans = "Yes";

    if(d / s > t) {
        ans = "No";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3748
s=input()
t=input()
if s+'a'==t or s+'b'==t or s+'c'==t or s+'d'==t or s+'e'==t or s+'f'==t or s+'g'==t or s+'h'==t or s+'i'==t or s+'j'==t or s+'k'==t or s+'l'==t or s+'m'==t or s+'n'==t or s+'o'==t or s+'p'==t or s+'q'==t or s+'r'==t or s+'s'==t or s+'t'==t or s+'u'==t or s+'v'==t or s+'w'==t or s+'x'==t or s+'y'==t or s+'z'==t:
    print('Yes')
else:
    print('No')

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

sys.setrecursionlimit(10**7)

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

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

N = I()
A = LI()

A.sort(reverse=True)
half, isOdd = divmod(len(A),2)

ans = A[0]
for i in range(1,half):
    ans += 2 * A[i]

if isOdd == 1:
    ans += A[half]

print(ans)

Measured memory_bytes: 31704
#include <iostream>
#include <map>
using namespace std;
int N, M;
int A[200005], B[200005];
map <int, int> X;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> A[i];
        X[A[i]]++;
    }
    cin >> M;
    for(int i = 1; i <= M; i++)
    {
        int val;
        cin >> val;
        if(X.find(val) == X.end() || X[val] <= 0)
        {
            cout << "NO\n";
            return;
        }
        X[val]--;
    }
    cout << "YES\n";
}
int main()
{
    Read();

    return 0;
}


Measured memory_bytes: 10368
N = int(input())
A = list(map(int, input().split()))

B = []
temp = 0
for i in range(N):
    if A[i] != temp:
        B.append(A[i])
        temp = A[i]

N = len(B)
A = [float("inf")] + B + [0]

money, stock = 1000, 0
for i in range(1, N + 1):
    if A[i - 1] > A[i] and A[i] < A[i + 1]:
        x = money // A[i]
        money -= A[i] * x; stock += x
    if A[i - 1] < A[i] and A[i] > A[i + 1]:
        x = stock
        money += A[i] * x; stock -= x

print(money)


Measured memory_bytes: 9164