akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

struct edge
{
    int to;
    int cost;
    edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector< vector < edge > > Graph;

void dfs(Graph &G, int st, vector<llint> &dist){
    stack<int> S;
    int N = G.size();
    static vector<vector<edge>::iterator> itr(N);
    REP(i, N){ itr[i] = G[i].begin(); }
    static vector<int> done(N, 0);
    S.push(st);
    dist[st] = 0;
    while(!S.empty()){
        int u = S.top();
        if(itr[u] == G[u].end()){
            S.pop();
            done[u] = 2;
        }else{
            edge v = *itr[u]++;
            if(!done[v.to]){
                done[v.to] = 1;
                S.push(v.to);
                if(dist[v.to] == -1) dist[v.to] = dist[u] + v.cost;
            }
        }
    }
}

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

    int N;
    cin >> N;
    Graph G(N);
    REP(i, N-1){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].pb(edge(b, c));
        G[b].pb(edge(a, c));
    }
    vector<llint> dist(N, -1);
    int Q, K;
    cin >> Q >> K;
    K--;
    dfs(G, K, dist);
    REP(i, Q){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << dist[x]+dist[y] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 9588
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

ll d[55][55][5005];
ll getP(ll i, ll j, ll sum){
	if(sum < 0) return 0;
	if(j == 0 && sum == 0) return 1;
	if(j == 0 && sum > 0) return 0;
	return d[i][j][sum];
}

int main() {
	ll n,a;

	cin >> n >> a;
	ll x[n];
	rp(i,n) {
		cin >> x[i];
	}
	d[0][0][0] = 1;
	rep(i,1,n+1) rep(j,1,n+1) rp(sum,4000){
		d[i][j][sum] = getP(i-1,j,sum) + getP(i-1,j-1,sum-x[i-1]);
	}
	ll ans = 0;
	rep(i,1,n+1){
		ans += d[n][i][i*a];
	}
	std::cout << ans << '\n';
	cout << endl;
	return 0;
}


Measured memory_bytes: 108800
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<int> a;

int main()
{
    cin >> N;
    a.resize(N);
    cin >> a;
    long double sum = 0;
    REP(i, N) sum += a[i];
    sum /= N;
    long double diff_min = 10000;
    REP(i, N) diff_min = min(diff_min, abs(sum - a[i]));
    REP(i, N) if (abs(sum - a[i]) - diff_min < 1e-5)
    {
        cout << i << endl;
        return 0;
    }
}


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

using namespace std;

void __start__() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MY
    freopen("/home/ainur/CLionProjects/wow/input.txt", "r", stdin);
    freopen("/home/ainur/CLionProjects/wow/output.txt", "w", stdout);
#else
#define endl '\n'
    //freopen("search.in", "r", stdin);
    //freopen("search.out", "w", stdout);
#endif
}

#define sz(x) (int)x.size()
#define yes cout<<"Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ft first
#define sd second
#define read(a) for(auto &qwqw:a)cin >> qwqw;
#define print(a) for(auto qwqw:a)cout<<qwqw<<' ';
#define print_plus(a) for(auto qwqw:a)cout<<qwqw+1<<' ';
//#define FOR(i, b, n) for(int i=b;i<n;i++) #define FOR(i, n) FOR(i, 0, n) #define FOR(n) FOR(i, 0, n)
mt19937_64 rnd(time(0));
#define int long long
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vb = vector<bool>;
using pii = pair<int, int>;
using vd = vector<long double>;


int log2(int q) {
    int c = 0;
    while (q) {
        q >>= 1;
        c++;
    }
    return c;
}


void test_case() {

}


signed main() {
    __start__();
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ll c(ll n)
{
	map<ll,ll> wow;
	while(n>1)
	{
		wow[spf[n]]++;
		n/=spf[n];	
	}	
	map<ll,ll> :: iterator it;
	ll ans=1;
	mloop(it,wow)
	ans*=(it->se+1);
	return ans;
}	
int main()
{
	floop(i,0,1e6+1)
	spf[i]=i;
	ll n;
	cin>>n;
	sieve(1e6);
	ll ans=0;
	floop(i,1,n)
	{
		ll temp=c(n-i);
		//cout<<temp<<" ";
		ans+=max(0ll,(temp));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 11428
using System;
using System.Collections.Generic;
using System.Text;

namespace CSharpTest
{
    class B_Battle
    {
        static void Main(string[] args)
        {
            string[] Status = Console.ReadLine().Split();
            double A = double.Parse(Status[0]);
            double B = double.Parse(Status[1]);
            double C = double.Parse(Status[2]);
            double D = double.Parse(Status[3]);
            if (Math.Ceiling(C / B) <= Math.Ceiling(A / D))
            {
                Console.WriteLine("Yes");
            }
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 27548
#include<stdio.h>
typedef long long int lli;
int main(void)
{
    lli ans=0;
    int a,b,c;
    int x;

    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&x);
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x==500*i+100*j+50*k)ans++;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;

	static	ArrayList<TreeNode> tree;
	static HashSet<Integer> set;
	static int[] ans;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] data = {a+b,a-b,a*b};
		Arrays.sort(data);
		System.out.println(data[2]);
	}





	static int upperbond(int k,ArrayList<Integer> data){		//k以下で最大の値をdataの中から探し、返す二分探索
		if(data == null){
			return -1;
		}
		int max = data.size();
		int min = -1;
		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) <= k){
				min = mid;
			}else{
				max = mid;
			}
		}

		
//		if(min != -1){
//			min = data.get(min);
//		}
		
//		System.out.println(max);
		return min;					//indexを返している
	}

	static int lowerbond(int k,ArrayList<Integer> data){		//k以上で最小の値をdataの中から探し、返す二分探索
		if(data == null){
			return -1;
		}
//		System.out.println("lo");
//		System.out.println("lo");
		int max = data.size();
		int min = -1;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;			//indexを返している
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



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




}

class TreeNode{
	int value;
	int sum;
	ArrayList<TreeNode> childlen;

	public TreeNode(int v,int s) {
		this.value = v;
		this.sum = s;
		this.childlen = new ArrayList<TreeNode>();
	}


}


class Edge  implements Comparable{

	int index;
	HashSet<Integer> hen;
	HashSet<Integer> used;
	HashMap<Integer, Integer> map;
	int size;


	public Edge(int index) {
		// TODO 自動生成されたコンストラクター・スタブ
		this.index = index;
		hen = new HashSet();
		used = new HashSet<Integer>();
		map = new HashMap<Integer,Integer>();
	}

	public int compareTo(Object other) {
		Edge otherpair = (Edge)other;

		return   otherpair.hen.size() - hen.size();
	}
}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int from,int end) {
		this.from = from;
		this.end = end;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  from - otherpair.from;
	}








}






Measured memory_bytes: 25172
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    double n,ans=0;
    cin>>n;
    vector<double>a(1000000);
    vector<string>s(1000000);

    for(int i=0;i<n;i++){
       cin>>a[i]>>s[i];
       if(s[i]=="JPY"){
           ans+=a[i];
       }
       else{
           ans+=a[i]*380000;
       }
    }

    cout<<fixed << setprecision(16)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a>b) swap(a,b);
  rep(i,b){
    cout<<a;
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int main(){
        int a,b;cin>>a>>b;
        int res;
        if(a>12)res = b;
        else if(a<=12 && a>=6)res = b/2;
        else res = 0;
        cout<<res;
    }
    


Measured memory_bytes: 256
import time
start = time.time()

n = int(input())
a = list(map(int, input().split()))
# # a = [i for i in range(n)]
# st = set()
# for i in range(n):
#     st.add(a[i])
# if len(st) == n: print("YES")
# else: print("NO")

# print(time.time() - start)

a.sort()
for i in range(n-1):
    if a[i] == a[i+1]:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 26800
import java.util.Scanner;
 
public class Main {
  void run() {
    Scanner sc = new Scanner(System.in);

    int min = 1000;
    int max = 0;
    int n = sc.nextInt();
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      min = Math.min(min, a);
      max = Math.max(max, a);
    }
    System.out.println(max - min);
  }

  public static void main(String[] args) {
    new Main().run();
  }
}


Measured memory_bytes: 23124
A, B, C, K = map(int, input().split())


count = 0
if K - A >= 0:
    count += A
    K = K - A
    if K - B >= 0:
        count += 0
        K = K - B
        if K - C >= 0:
            count -= C
            print(count)
        else:
            count -= K
            print(count)
    else:
        count += 0
        print(count)
else:
    count += K
    print(count)


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

int main() {
    int n;
    string x;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x == "Y") {
            cout << "Four" << endl;
            break;
        } else if(i == (n -1)) {
            cout << "Three" << endl;
        }
    }
    return 0; 
}

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

using ll=long long;
#define rng(i,l,r) for(int i=int(l);i<int(r);i++)
#define rep(i,r) rng(i,0,r)
#define rrng(i,l,r) for(int i=int(r)-1;i>=int(l);i--)
#define rrep(i,r) rrng(i,0,r)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#define inf INT_MAX/2-100
#define infl LLONG_MAX/3
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<' '<<#x<<' '<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u>void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u>void chmin(t&a,u b){if(b<a)a=b;}

template<class t>using vc=vector<t>;
template<class t>using vvc=vector<vector<t>>;

using pi=pair<int,int>;
using pl=pair<ll,ll>;
using vi=vc<int>;
using vl=vc<ll>;


ll readl(void){
	ll x;
	cin>>x;
	return x;
}
int readi(void){
	int x;
	cin>>x;
	return x;
}

string readstr(){
	string s;
	cin>>s;
	return s;
}
vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=readi(),v[i]+=off;
	return v;
}

vl readvl(int n,int off=0){
	vl v(n);
	rep(i,n)v[i]=readl(),v[i]+=off;
	return v;
}

template<class t>
void print(t x,int suc=1){
	cout<<x;
	if(suc==1)cout<<"\n";
	if(suc==2)cout<<" ";
}

template<class t>
void print(const vc<t>&v,int suc=1){
	rep(i,si(v))print(v[i],i==int(si(v))-1?1:suc);
}

template<class t>
bool inc(t a,t b,t c){
	return !(c<b||b<a);
}

template<class t>
void compress(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}

template<class t>
struct Compress{
	vc<t>v;
	Compress()=default;
	Compress(const vc<t>&x){
		add(x);
	}
	Compress(const initializer_list<vc<t> >&x){
		for(auto &p:x)add(p);
	}
	void add(const t&x){
		v.eb(x);
	}
	void add(const vc<t>&x){
		copy(all(x),back_inserter(v));
	}
	void build(){
		compress(v);
	}
	int get(const t&x)const{
		return lwb(v,x);
	}
	vc<t>get(const vc<t>&x)const{
		vc<t>res(x);
		for(auto &p:res)p=get(p);
		return res;
	}
	const t &operator[](int x)const{
		return v[x];
	}
};
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
}
void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
}
void orYes(bool x,bool ex=true){
	if(x)Yes(ex);
	else No(ex);
}
void orYES(bool x,bool ex=true){
	if(x)YES(ex);
	else NO(ex);
}
void Possible(bool ex=true){
	cout<<"Possible\n";
	if(ex)exit(0);
}
void POSSIBLE(bool ex=true){
	cout<<"POSSIBLE\n";
	if(ex)exit(0);
}
void Impossible(bool ex=true){
	cout<<"Impossible\n";
	if(ex)exit(0);
}
void IMPOSSIBLE(bool ex=true){
	cout<<"IMPOSSIBLE\n";
	if(ex)exit(0);
}
void orPossible(bool x,bool ex=true){
	if(x)Possible(ex);
	else Impossible(ex);
}
void orPOSSIBLE(bool x,bool ex=true){
	if(x)POSSIBLE(ex);
	else IMPOSSIBLE(ex);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(0);
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&b==c)||(a!=b&&b!=c&&c!=a))No();
	Yes();
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	char a, b;
	cin >> a >> b;

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


}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void)
{
  int h,w;
  char a[101][101];
  scanf("%d%d",&h,&w);
  for(int i=0; i<h; i++)
    scanf("%s",a[i]);
  
  for(int i=0; i<w+2; i++)
    printf("#");
  puts("");
  
  for(int i=0; i<h; i++)
    printf("#%s#\n",a[i]);
  
  for(int i=0; i<w+2; i++)
    printf("#");
  puts("");
  
  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();
		
		System.out.println(n / 2 + (n % 2 == 0 ? -1 : 0));
		
		sc.close();
	}
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 10;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int N, a[MAXN], ti[MAXN], flag, tim;
int prime[MAXN], vis[MAXN], tot;
void sieve(int N) {
	vis[1] = 1;
	for(int i = 2; i <= N; i++) {
		if(!vis[i]) prime[++tot] = i; 
		for(int j = 1; j <= tot && 1ll * i * prime[j] <= N; j++) {
			vis[i * prime[j]] = 1;
			if(!(i % prime[j])) break;
		}
	}
}
void solve(int x) {
	int lim = sqrt(x) + 1;
	for(int j = 1; 1ll * prime[j] * prime[j] <= x && j <= tot; j++) {
		int i = prime[j];
		if(x % i == 0) {
			ti[i]++;
			if(ti[i] == 2) {flag = 1; return ;}
			while(x % i == 0) x /= i;
		}
	}
	if(x != 1) {
		ti[x]++;
		if(ti[x] == 2) {
			flag = 1; return ;
		}
	}
}

int main() {
//	freopen("a.in", "r", stdin);
	//freopen("b.out", "w", stdout);
	N = read();
	sieve(N);
//	for(int i = 1; i <= tot; i++) cout << prime[i] << ' ';
	for(int i = 1; i <= N; i++ ) {
		a[i] = read();
		solve(a[i]);
	}
	if(!flag) {puts("pairwise coprime"); return 0;}
	int g = a[1];
	for(int i = 2; i <= N; i++) {
		g = __gcd(g, a[i]);
	}	
	if(g == 1)  {puts("setwise coprime"); return 0;}
	puts("not coprime");

	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli a , b , c , m ;
    cin >> a >> b >> c ;
    m = max ({a , b , c}) ;
    (a + b + c - m == m ? Yes : No ) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N, K;
    cin >> N >> K;

    vector<int> h(N);
    rep(i, N) cin >> h[i];

    int dp[100010];
    memset(dp, 0, sizeof(dp));

    dp[1] = abs(h[0] - h[1]);

    for (int i = 2; i < N; i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 2; j <= K; j++) {
            if (i - j >= 0) {
                chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }

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


Measured memory_bytes: 1024
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))


count = 0
for t in T:
    bottom = 0
    top = n  
    while top - bottom > 0:
        middle = (top + bottom) // 2
        
        if t == S[middle]:
            count += 1
            break

        if t > S[middle]:
            bottom = middle + 1
        if t < S[middle]:
            top = middle

print(count)


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

typedef long long ll;

const int inf = 1000000;

int main() {
    int X;
    double ans;
    cin >> X;
    ans = 360.0/(double)X;
    int i = 1;
    while (true) {
        ans = 360.0*i/(double)X;
        if (ans == (int)ans) {
            cout << ans << endl;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int a,b;char op;cin>>a>>op>>b;
    cout<<((op=='+')?a+b:a-b)<<endl;
}

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

int main(void)
{
    int N;
    string s;
    cin >> N;
    cin >> s;

    int R{0};
    int B{0};
    for(int i{0}; i<N; ++i){
        if(s[i]=='R')
            ++R;
        else if(s[i]=='B')
            ++B;
    }
    if(R>B)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)
#define pb push_back
#define ll long long
#define sfi(a) scanf("%d", &a)
#define sfii(a, b) scanf("%d%d", &a, &b)
#define sfiii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sfl(a) scanf("%lld", &a)
#define sfll(a, b) scanf("%lld%lld", &a, &b)
#define pf printf
#define mp make_pair
#define ff first
#define ss second
#define mem(a, v) memset(a, v, sizeof(a))
#define pii pair<int, int>
#define PLL pair<ll, ll>

int main()
{
    int n;
    while(sfi(n) == 1){
        vector<int> value;
        vector<int> cost;
        for(int i=0; i<n; i++){
            int x;
            sfi(x);
            value.pb(x);
        }
        for(int i=0; i<n; i++){
            int x;
            sfi(x);
            cost.pb(x);
        }
        int ans  = 0;
        for(int i=0; i<n; i++){
            int a = value[i] - cost[i];
            if(a > -1) ans += a;
        }
        cout << ans << "\n";
    }
    return 0;
}


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

int main(){
    
    string s;
    cin>>s;
    int n = s.size(), ans=0;
    for(int i=0;i<n;i++){
        int cnt=0;
        while((s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i] =='T') && i<n){
            cnt++;
            i++;
        }
        ans=max(ans, cnt);
    }
    
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string s;
	cin >> s;
	if (count(all(s), 'N') || count(all(s), 'S')) {
		if ((count(all(s), 'N') && !count(all(s), 'S')) || !(count(all(s), 'N') && count(all(s), 'S'))) {
			cout << "No\n";
			return 0;
		}
	}
	if (count(all(s), 'W') || count(all(s), 'E')) {
		if ((count(all(s), 'W') && !count(all(s), 'E')) || !(count(all(s), 'W') && count(all(s), 'E'))) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

namespace ABC171
{
  class E
  {
  public:
    E() = default;
    ~E() = default;


    void Run()
    {
      int N = {};
      std::cin >> N;

      static int X[200001] = {};
      static int A[200001] = {};
      int sum = {};
      for (int i = 0; i < N; ++i)
      {
        std::cin >> A[i];
        sum ^= A[i];
      }

      for (int i = 0; i < N; ++i)
      {
        int answer = sum ^ A[i];
        std::cout << answer << std::endl;
      }

    }
  };


}

int main()
{

  ABC171::E prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3872
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r,reverse=True)
answer=p[:X]+q[:Y]
sum=0
answer=sorted(answer)
i=0

while i<=min(X+Y-1,C-1) and answer[i]<r[i]:
    answer[i]=r[i]
    i+=1

for a in answer:
    sum+=a

print(sum)

Measured memory_bytes: 22720
#include<bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int main()
{
    int a,b,c,d,e,f,g,h,j,i;
    cin>>a;
    int ar[a];
    vector<pair<int,int> >v;
    for(i=0; i<a; i++)
    {
        cin>>ar[i];
        v.push_back(make_pair(i+1,ar[i]));


        }
        sort(v.begin(),v.end(),sortbysec);
        for(i=0;i<v.size();i++)
        {
            cout<<v[i].first<<" ";
        }
        cout<<endl;
        return 0;


}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)
int main() {
	int n,k;

	cin >>n>>k;
	vector<int>p(n);
	int tmp=0;
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	for(int i=0;i<k;i++){
		tmp+=p[i]+1;
	}
	int mx=tmp;
//	cout << "mx=" << mx << endl;
	for(int i=k;i<n;i++){
		tmp = tmp+p[i]-p[i-k];
//		cout << "new=" << tmp << endl;
		if (tmp >mx){
			mx=tmp;
		}
	}

	double ans;
	ans =mx/2.0;
	printf("%.12f\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int a, b; cin >> a >> b;
	if( a < b ) swap(a, b);
	// a > b;
	for( int i = 0; i < a; ++i ){
		cout << b;
	} cout << endl;
}

Measured memory_bytes: 384
from sys import stdin
import itertools
N,M,Q=list(map(int, (stdin.readline().strip().split())))
q=[]
num_list=[]
number=[]
score=[0]
for i in range(1,M+1):number.append(i)
for _ in range(Q):
    a,b,c,d=list(map(int, (stdin.readline().strip().split())))
    q.append([a,b,c,d])
def dfs(num_list,i):
    if i==M and len(num_list)<N:
        return
    if len(num_list)!=N:
        a=num_list.copy()
        num_list.append(number[i])
        dfs(num_list,i)
        dfs(num_list,i+1)
        dfs(a,i+1)
    else:
        ans=0
        for a,b,c,d in q:
            if num_list[b-1]-num_list[a-1]==c:
                ans+=d
        score[0]=max(ans,score[0])



dfs(num_list,0)
print(score[0])


Measured memory_bytes: 9252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll bit[200010];
ll n;
void add(ll i,ll x){
  while(i<=n+1){
    bit[i]+=x;
    i+=i&(-i);
  }
}
ll summ(ll i){
  ll ret=0;
  while(i>0){
    ret+=bit[i];
    i-=i&(-i);
  }
  return ret;
}
int main(){
  ll k;cin>>n>>k;
  ll a[n];
  ll sum[n+1];
  fill(bit,bit+n+4,0);
  sum[0]=0;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    sum[i+1]=sum[i]+a[i]-k;
  }
  ll num[n+1];
  vector<pll> v;
  ll b[n+1];
  for(ll i=0;i<n+1;i++)v.push_back(make_pair(sum[i],i));
  sort(v.begin(),v.end(),greater<pll>());
  for(ll i=0;i<n+1;i++){
    b[v[i].second]=i;
  }
  for(ll i=0;i<n+1;i++)b[i]++;
  //for(ll i=0;i<n+1;i++)cout<<b[i]<<" ";
  ll ans=0;
  for(ll i=1;i<n+2;i++){
    add(b[i-1],1);
    ans+=b[i-1]-summ(b[i-1]);
    //cout<<b[i-1]<<" "<<summ(b[i-1])<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11120
def resolve():
    a,b,c=map(int, input().split())
    if a==b==5 and c==7:
        print('YES')
    elif a==c==5 and b==7:
        print('YES')
    elif b==c==5 and a==7:
        print('YES')
    else:
        print('NO')
resolve()

Measured memory_bytes: 3060
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val array = IntArray(n)
    for (i in 1..n) {
        val a = scanner.nextInt()
        array[a-1] = i
    }
    println(array.joinToString(separator = " "))
}

Measured memory_bytes: 53932
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll q;

	cin >> q;

	REP(i, q) {
		ll a, b;
		cin >> a >> b;
		ll x = (ll)sqrt(a*b);
		ll ans = x * 2 - 1;

		if (x > a) {
			ans--;
		}

		if (x > b) {
			ans--;
		}

		if (x*x == a*b) {
			ans--;

			if (x != a && x + 1 != b && x*(x + 1) < a*b) {
				ans++;
			}

			if (x != b && x + 1 != a && x*(x + 1) < a*b) {
				ans++;
			}
		}
		else {
			if (x != a && x + 1 != b && x != b && x + 1 != a && x*(x + 1) < a*b) {
				ans++;
			}

			if (x == a && x + 1 == b && x*(x + 1) == a*b) {
				ans--;
			}

			if (x == b && x + 1 == a && x*(x + 1) == a*b) {
				ans--;
			}
		}

		cout << ans << endl;
	}
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int N;
    cin >> N;

    int max_n=0;
    REP(i, N){
        int k;
        cin >> k;
        if(max_n - k > 1){
            cout << "No" << endl;
            return 0;
        }
        max_n = max(max_n, k);
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=20000;

int n;
int p[MAXN];
int a[MAXN];
int b[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&p[i]),--p[i];
	REP(i,n) a[i]=1+i*n,b[i]=1+(n-i-1)*n;
	REP(i,n) a[p[i]]+=i;
	REP(i,n) { if(i!=0) printf(" "); printf("%d",a[i]); } puts("");
	REP(i,n) { if(i!=0) printf(" "); printf("%d",b[i]); } puts("");
}

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


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    for (int i = 0; i < b; i++)
    {
        cout<<a;
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli t,n,i,j,k,m;
                cin>>n>>k;
                vector<lli> v(n);
                vector<lli> ans(n,LLONG_MAX);
                for(i=0;i<n;i++)cin>>v[i];
                ans[0]=0;
                for(i=1;i<n;i++){
                    for(j=i-1;j>=max(0ll,i-k);j--){
                        if(ans[j]!=LLONG_MAX){
                            ans[i]=min(ans[i],ans[j]+abs(v[j]-v[i]));
                        }
                    }
                }

                cout<<ans[n-1]<<endl;
                return 0;



            }


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

ll factorial(ll n){
    if(n ==0) return 1;
    else return n * factorial(n-1);
}

vector<int> make_map(string s){
    vector<int> c(26);
    for(int i=0;i<s.size();i++){
        int n = s.at(i) - 'a';
        c.at(n)++;
    }
    return c;
}

int main(){
    int n;
    cin >> n;
    map<string,ll> m;
    ll count = 0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        if(m.count(s)){
            m[s]++;
        }else{
            m[s] = 1;
        }
    }

    for(auto p:m){
        //cout << p.second << endl;
        if(p.second>1){
            count += p.second * (p.second - 1) / 2;
        }
    }
    cout << count << endl;    
}

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

const int N = 100010;

int n, a[N];

bool check(int mid){
	ll sum = a[mid];
	for (int i = 0; i < n; ++ i){
		if (i == mid){
			continue;
		}
		if (2 * sum < a[i]){
			return false;
		}
		sum += a[i];
	}
	return true;
}

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	std::sort(a, a + n);
	int left = 0, right = n - 1;
	while (left < right){
		int mid = left + right >> 1;
		if (check(mid)){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	return printf("%d\n", n - left), 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int p,q;
  cin >> q >> p;
  string s,t;
  cin >> s >> t;

  int pos=p, cur=p;
  rep(i,n){
    if(s[i]=='R'){
      cur++;
      pos = max(pos,cur);
    }
    if(t[i]=='L'&&1<cur) cur--;
  }
  if(w<pos){ cout << "NO" << endl; return 0; }

  pos=p, cur=p;
  rep(i,n){
    if(s[i]=='L'){
      cur--;
      pos = min(pos,cur);
    }
    if(t[i]=='R'&&cur<w) cur++;
  }
  if(pos<=0){ cout << "NO" << endl; return 0; }

  pos=q, cur=q;
  rep(i,n){
    if(s[i]=='D'){
      cur++;
      pos = max(pos,cur);
    }
    if(t[i]=='U'&&1<cur) cur--;
  }
  if(h<pos){ cout << "NO" << endl; return 0; }

  pos=q, cur=q;
  rep(i,n){
    if(s[i]=='U'){
      cur--;
      pos = min(pos,cur);
    }
    if(t[i]=='D'&&cur<h) cur++;
  }
  if(pos<=0){ cout << "NO" << endl; return 0; }
  cout << "YES" << endl;
  return 0;
}

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

#define LL long long

const int maxN = 2e5 + 10;

struct Node
{
	int from, to;
	LL value;
	Node(int X = 0, int Y = 0, LL Z = 0) { from = X; to = Y; value = Z; }
}edge[maxN * 25 + 1];

int n, D, cnt;
int a[maxN + 1], pa[maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline void solve(int l, int r)
{
	if(l == r) return;
	
	int mid = (l + r) >> 1;
	solve(l, mid); solve(mid + 1, r);
	
	int ml = 0, mr = 0;
	LL fl = 1e18, fr = 1e18;
	for(int i = l; i <= mid; i++)
		if(a[i] - 1ll * D * i < fl) fl = a[i] - 1ll * D * i, ml = i;
	for(int i = mid + 1; i <= r; i++)
		if(a[i] + 1ll * D * i < fr) fr = a[i] + 1ll * D * i, mr = i;
	
	for(int i = l; i <= mid; i++) edge[++ cnt] = Node(i, mr, 1ll * (mr - i) * D + a[i] + a[mr]);
	for(int i = mid + 1; i <= r; i++) edge[++ cnt] = Node(ml, i, 1ll * (i - ml) * D + a[ml] + a[i]);
}

inline bool comp(Node a, Node b) { return a.value < b.value; }

inline int find(int x) { return pa[x] == x ? x : pa[x] = find(pa[x]); }

int main()
{
	n = read(), D = read();
	for(int i = 1; i <= n; i++) a[i] = read();

	solve(1, n);

	sort(edge + 1, edge + cnt + 1, comp);

	for(int i = 1; i <= n; i++) pa[i] = i;

	LL ans = 0;
	for(int i = 1; i <= cnt; i++)
	{
		int x = find(edge[i].from), y = find(edge[i].to);
		if(x == y) continue;
		ans += edge[i].value;
		pa[x] = y;
	}

	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
char a[4];
int main()
{
	int i,f=0;
	scanf("%s",a);
	for(i=0;i<3;i++)
	{
		if(a[i]=='a'||a[i]=='b'||a[i]=='c'||a[i]=='A'||a[i]=='B'||a[i]=='C')
		{
		     if(a[0]!=a[1]&&a[0]!=a[2]&&a[1]!=a[2])
		         f=1;
		     else
			 {
				printf("No");
				return 0;
			 }  
		}
		else
		{
			printf("No");
			return 0;
		}    
	}
	if(f)
	  printf("Yes");
	return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll N;
	cin >> N;
	vector<ll> a(N),s(N+1,0);
	for(int i=0;i<N;++i){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	ll res = 0;
	for(int i=1;i<N;++i){
		s[i] = s[i-1]+a[i-1];
		if(2*s[i] < a[i]) res = i;
	}
	cout << N-res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
int n,i,k,x,y;
struct arr
{
	int x,l,r;
	bool operator <(const arr &a) const
	{
		return 1LL*(k-x)*r+1LL*x*l>1LL*(k-a.x)*a.r+1LL*a.x*a.l;
	}
}a[maxn];
ll sum1[maxn],sum2[maxn],s,l=0,r,mid,ans;
int main()
{
	scanf("%d%d",&n,&k);
	r=1LL*n*k;
	for (i=1;i<=n;i++)
		scanf("%d%d%d",&a[i].x,&a[i].l,&a[i].r);
	sort(a+1,a+n+1);
	for (i=1;i<=n;i++)
		sum1[i]=sum1[i-1]+1LL*(k-a[i].x)*a[i].r;
	for (i=n;i;i--)
		sum2[i]=sum2[i+1]-1LL*a[i].x*a[i].l;
	for (mid=(l+r)>>1LL;l<=r;mid=(l+r)>>1LL)
	{
		x=mid/k;
		y=mid%k;
		for (i=1;i<=n;i++)
		{
			s=sum1[x]+sum2[x+1];
			if (y)
			{
				if (i<=x) s-=1LL*(k-a[i].x)*a[i].r,s+=1LL*(k-a[x+1].x)*a[x+1].r+1LL*a[x+1].x*a[x+1].l;
					else s+=1LL*a[i].x*a[i].l;
				if (y>a[i].x) s+=1LL*(y-a[i].x)*a[i].r;
					else s+=1LL*(y-a[i].x)*a[i].l;
			}
			if (s>=0) break;
		}
		if (i<=n)
		{
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	int x[n],y[n];
	for(int i=0;i<n;i++)
	{
		x[i]=0;
		y[i]=0;
	}
	for(int i=1;i<n;i++)
	{
		x[i]=x[i-1];
		if(s[i-1]=='W')
		x[i]++;
	}
	for(int i=n-2;i>=0;i--)
	{
		y[i]=y[i+1];
		if(s[i+1]=='E')
		y[i]++;
	}
	int a=n;
	for(int i=0;i<n;i++)
	{
		int c=x[i]+y[i];
		a=min(c,a);
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, d, x;
    cin >> r >> d >> x;
    for(int i = 1;i <= 10;i++) {
        cout << r*x-d << endl;
        x = r*x-d;
    }
    return 0;
}

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

int main() {
   int M1,D1,M2,D2;
   cin >> M1 >> D1;
   cin >> M2 >> D2;
   if(M1 != M2){
     cout << 1 << endl;
   }
   else{
     cout << 0 << endl;
   }
}


Measured memory_bytes: 256
def main():
  n = int(input())
  plist = list(map(int, input().split()))
  sc = 0
  for i, p in enumerate(plist):
    if i+1 != p:
      sc += 1
  if sc == 2 or sc == 0:
    print('YES')
  else:
    print('NO')


if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let n = s.len();
    for i in 0..(n / 2) {
        if s[i] != s[n - 1 - i] {
            return "No".to_string();
        }
    }
    for i in 0..(n / 4) {
        if s[i] != s[n / 2 - 1 - i] {
            return "No".to_string();
        }
        if s[n / 2 + 1 + i] != s[n - 1 - i] {
            return "No".to_string();
        }
    }

    return "Yes".to_string();
}


Measured memory_bytes: 4352