akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long A, long long B)
{
  for (int i = 1; i < 1000000; i++)
  {
    int a = i * 8 / 100;
    int b = i * 10 / 100;
    if (a == A && b == B)
    {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main()
{
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


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

bool isKaibunn(string s)
{
    if (s.size() == 1)
    {
        return true;
    }
    if (s.size() < 3)
    {
        return false;
    }

    bool result = true;
    int i = 0;
    int j = s.size() - 1;
    while (i + 1 < j)
    {
        if (s[i] != s[j])
        {
            result = false;
            break;
        }

        i++;
        j--;
    }

    return result;
}

int main()
{
    string S;
    cin >> S;

    int len = S.size();

    // cout << S.substr(0, (len - 1) / 2) << endl;
    // cout << S.substr((len + 3) / 2 - 1) << endl;
    bool a = isKaibunn(S.substr(0, (len - 1) / 2));
    bool b = isKaibunn(S.substr((len + 3) / 2 - 1));
    bool c = isKaibunn(S);

    if (a && b && c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var p = nexts(n);
  var ans1 = Array(n).fill().map((a,i)=>i*20000+1);
  var ans2 = Array(n).fill().map((a,i)=>9e8-i*20000);
  for(var i = 0; i < n; i++){
    ans2[p[i]-1] += i;
  }
  console.log(ans1.join(" "));
  return ans2.join(" ");
}

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

string in;
vector < string > v;

void dfs(int idx, int used, string s)
{
	if (idx == in.size())
	{
		v.push_back(s);
		return ;
	} 
	char c = in[idx];
	int alpha_idx = c-'a';

	if (used & (1 << alpha_idx)) // ?????£?????§
	{
		dfs(idx+1, used, s + c);
	}

	int next_alpha_idx = (alpha_idx+1);
	if (c != 'z' && !(used & (1 << next_alpha_idx))) //???????????????????????§
	{
		dfs(idx+1, used | (1 << next_alpha_idx), s + (char)(c + 1));
	}
}

int main(int argc, char const *argv[])
{
	while (cin >> in && in != "#") {
		v.clear();
		dfs(0, 1, "");
		cout << v.size() << endl;
		sort(v.begin(),v.end());
		if (v.size() <= 10)
		{
			for (auto &a: v){
				cout << a << endl;
			}
		} else {
			for (int i = 0; i < 5; ++i)
			{
				cout << v[i] << endl;
			}
			for (int i = 0; i < 5; ++i)
			{
				cout << v[v.size()-1-(4-i)] << endl;
			}
		}

	}
	return 0;
}

Measured memory_bytes: 4240
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	double sum=0,a;
	char b[4];
	int n;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%lf%s",&a,&b);
		if(b[0]=='J')
			sum+=a;
		else
			sum+=a*380000;
	}
	printf("%.8f\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

string S;
ll dp[100010][4];

ll solve(){
    dp[0][0] = 1;
    REP(i, S.length()){
        if(S[i] == '?'){
            REP(j, 4) dp[i + 1][j] = 3 * dp[i][j] % MOD;
        }else{
            REP(j, 4) dp[i + 1][j] = dp[i][j];
        }
        if(S[i] == 'A' || S[i] == '?'){
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % MOD;
        }
        if(S[i] == 'B' || S[i] == '?'){
            dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % MOD;
        }
        if(S[i] == 'C' || S[i] == '?'){
            dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % MOD;
        }
    }
    return dp[S.length()][3];
}

signed main(){
    cin >> S;
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 6880
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String ans = "NG";
    for(int i = A; i<=B; i++){
            if(i%K == 0){
                ans = "OK";
            }
    }
    System.out.println(ans);
  }
}

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

int a[101];

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

    int ma = 0;
    int mi = 1000;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        ma = max(ma, a[i]);
        mi = min(mi, a[i]);
    }
    cout << ma - mi << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int> > g(n);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u - 1].push_back(v - 1);
  }
  vector<int> dp(n, -1);
  function<int(int)> dfs = [&](int u) {
    if (dp[u] != -1)
      return dp[u];
    dp[u] = 0;
    for (int v : g[u])
      dp[u] = max(dp[u], dfs(v) + 1);
    return dp[u];
  };
  int ans = 0;
  for (int i = 0; i < n; ++i)
    ans = max(ans, dfs(i));
  printf("%d\n", ans);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

signed main(){
	string S; cin>>S;
	set<char> se;
	int N=S.size();
	for(int i=0;i<N;i++)se.insert(S[i]);
	string ans="";
	for(char c='a';c<='z';c++){
		if(not se.count(c)){
			ans+=c;
			break;
		}
	}
	cout<<(ans.size()==0 ? "None" : ans)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
   //    #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------



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


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

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int A,B,C;
  cin>>A>>B>>C;
  int x=max(A,max(B,C));
  if ((3*x-(A+B+C))%2==0) {
    cout<<(3*x-(A+B+C))/2<<endl;
  } else {
    x++;
    cout<<(3*x-(A+B+C))/2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    char o[51], e[51];
    scanf("%s%s", o, e);

    int eoo = 0;
    int eoe = 0;
    for (int i = 0; i < 51; i++) {
        if (o[i] != '\0' && eoo == 0) {
            printf("%c", o[i]);
        } else {
            eoo = 1;
        }

        if (e[i] != '\0' && eoe == 0) {
            printf("%c", e[i]);
        } else {
            eoe = 1;
        }

        if (eoo == 1 && eoe == 1) {
            break;
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s; cin >>s; int N = s.length();
    for(char a='a'; a<='z'; ++a)
    {
        int i;
        for(i=0; i<N; ++i)
            if(a==s[i]) break;
        if(i==N)
        {
            cout << a << endl;
            return 0;
        }
    }
    puts("None");
}

Measured memory_bytes: 512
N = gets.to_i
A = N.times.map { gets.to_i }

def bsearch(ng:, ok:, &is_ok)
  while (ok - ng).abs > 1
    mid = (ok + ng) / 2
    if is_ok.call(mid)
      ok = mid
    else
      ng = mid
    end
  end
  ok
end

list = []
A.each do |a|
  i = bsearch(ng: list.size, ok: -1) do |j|
    list[j] < a
  end
  if i == -1
    list.unshift(a)
  else
    list[i] = a
  end
end
puts list.size

Measured memory_bytes: 4740
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstring>
#include <cmath>
#include <sstream>
#include <random>
#include <ctime>
#include <chrono>
#include <iomanip>
 
#define fi first
#define se second
#define LL(x) (x << 1)
#define RR(x) ((x << 1) + 1)
#define mp make_pair
 
using namespace std;
const int N = 3005;
const int M = 30000;
 
const int Bases = 2;
const long long base[] = {137, 37};
const long long mod = 1000000007LL;
 
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<int, iii> iiii;

long long addi(long long a, long long b, long long m = mod) { a += b; if (a < 0) a += m; if (a >= m) a -= m; return a; }
long long subt(long long a, long long b, long long m = mod) { a -= b; if (a < 0) a += m; if (a >= m) a -= m; return a; }
long long mult(long long a, long long b, long long m = mod) { return a * b % m; }
long long power(long long a, long long b, long long m = mod) 
{
    long long tmp = 1;
    for (; b > 0; b >>= 1)
    {
        if (b & 1LL) tmp = mult(tmp, a, m);
        a = mult(a, a, m);
    }
    return tmp;
}
long long inv(long long a, long long m = mod) { return power(a, m - 2, m); }
unsigned replaceByte(unsigned x, int i, char b)
{
    x = x & ~(0xff << (i * 4));
    // return x;
    unsigned y = 0xff & (unsigned)b;
    // return y;
    x = x | (y << (i * 4));
    return x;
}

/* ------------------------------------------ template end here ------------------------------------------ */

long long n, a[N], F[N][N];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) F[i][i] = a[i];
    for (int len = 2; len <= n; ++len)
    {
        for (int i = 1; i <= n - len + 1; ++i)
        {
            int j = i + len -1;
            F[i][j] = max(a[i] - F[i + 1][j], a[j] - F[i][j - 1]);
        }
    }
    cout << F[1][n];
    return 0;
}
/*
1
acbba
*/

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
vector<vector<int>>v;
vector<int> temp;
int n, m, k[12], p[12], s[12][12], ans = 0;
void solve(int idx){
    if(idx >= n){
        v.push_back(temp);
        return;
    }
    temp[idx] = 1;
    solve(idx + 1);
    temp[idx] = 0;
    solve(idx + 1);
}
int main(){
    Hello
    cin >> n >> m;
    for(int i = 0; i < n; i++) temp.push_back(0);
    for(int i = 0; i < m; i++){
        cin >> k[i];
        for(int j = 0; j < k[i]; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for(int i = 0; i < m; i++) cin >> p[i];
    solve(0);
    for(int cur = 0; cur < v.size(); cur++){
        int allbulbs = 0;
        for(int i = 0; i < m; i++){
            int lighted = 0;
            for(int j = 0; j < k[i]; j++){
                if(v[cur][s[i][j]])
                    lighted++;
            }
            if(lighted % 2 == p[i] % 2)
                allbulbs++;
        }
        if(allbulbs == m)
            ans++;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

long long dp[100000];

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 1; i < n; i++)
		dp[i] = 1e9;
	for (int i = 1; i < n; i++)
		for (int j = 1; j <= k && -1 < i - j; j++)
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
	cout << dp[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define size_t int

using namespace std;
typedef long l;
typedef long long ll;

size_t mod(size_t a, size_t b) {
    return ((b + (a % b)) % b);
}

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

  int N, A;
  std::cin >> N >> A;
  vector<int> x(N,0);

  for (size_t i = 0; i < N; i++) {
    std::cin >> x[i];
    x[i] -= A;
  }

  vector<vector<ll>> dp(51, vector<ll>(4902, 0));
  dp[0][0] = 1;
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j <= 4901; j++) {
      dp[i+1][j] += dp[i][j];
      dp[i+1][j] += dp[i][mod(j - x[i], 4902)];
    }
  }

  std::cout << dp[N][0] - 1 << '\n';

  return 0;
}


Measured memory_bytes: 2304
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int N = 13, inf=1e18;
int n,m,x;

int cost[N] = {0};
int mat[N][N] = {0};

int func(int cur,vector<int> vec,int c){
	if(cur==n){
		int i=0;
		for(;i<m;i++) if(vec[i]<x) break;
		if(i==m) return c;
		else return inf;
	}
	int res = func(cur+1,vec,c);
	for(int i=0;i<m;i++){
		vec[i] += mat[cur][i];
	}
	res = min(res,func(cur+1,vec,c+cost[cur]));
	return res;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>cost[i];
		for(int j=0;j<m;j++) cin>>mat[i][j];
	}
	vector<int> vec(m,0);
	int ans = func(0,vec,0);
	if(ans==inf) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int n;
  cin>>n;
  vector<int> v(n);
  int sum=0;
  int c=0;
  rep(i,n){
    cin>>v[i];
    if(v[i]%10==0)c++;
    sum+=v[i];
  }
  sort(v.begin(),v.end());
  if(c==n)cout<<0<<endl;
  else if(sum%10!=0){
    cout<<sum<<endl;
  }else{
    rep(i,n){
      if(v[i]%10!=0){
	cout<<sum-v[i]<<endl;
	break;
      }
    }
  }

return 0;
}


Measured memory_bytes: 256
N = int(input())
dices = [map(int, input().split()) for _ in range(N)]

cnt = 0
flag = False
for d1, d2 in dices:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62504
from functools import reduce

x,y=list(map(int,input().split()))
mod = 10 ** 9 + 7

if (2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0:
  print("0")
  exit()
  
a,b = (2 * y - x) // 3, (2 * x - y) // 3 

r = min(a,b)

if r == 0:
  print("1")
elif r < 0:
  print("0")
else:
  numerator = reduce(lambda x, y: x * y % mod, range(a + b - r + 1, a + b + 1))
  denominator = reduce(lambda x, y: x * y % mod, range(1,r + 1))
  print(numerator * pow(denominator, mod - 2, mod) % mod)

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

int main() {
    
	    int n,k;
	cin>>n>>k;
	int a[n],dp[n];
	for(int i=0;i<n;i++)cin>>a[i];
	dp[0]=0,dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {  int j=i-1;
    int x=INT_MAX,c=0;
        while(j>=0)
        {
            x=min(x,dp[j]+abs(a[i]-a[j]));
            j--;
            c++;
            if(c>=k)break;
        }
        dp[i]=x;
    }
    cout<<dp[n-1]<<endl;
	

}


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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        pq.push(a);
    }
    for (int i = 0; i < m; ++i) {
        int k = pq.top(); pq.pop();
        pq.push(k / 2);
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += pq.top(); pq.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 3932
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;
bool ans=false;

vector<vec> G;

pii dfs(int x,int p){
    int cnt=0,sum=0,res=0;
    for(auto e:G[x]){
        if(e==p)continue;
        pii d=dfs(e,x);
        if(d.first){
            cnt++;
            sum+=d.first;
            res=0;
        }
        res|=d.second;
        if(res&&cnt>1)res=0;
    }
    if(G[x].size()-1>cnt){
        sum+=G[x].size()-2-cnt;
        if(G[x].size()!=2)
        res|=1;
    }
    if(res>1){
        sum+=res-1;
        res=1;
    }
    //cout<<x<<" "<<sum<<" "<<res<<endl;
    return {sum,res};
}
main(){
    int n=in();
    G.resize(n);
    rep(i,n-1){
        int a=in(),b=in();
        G[a].pb(b);
        G[b].pb(a);
    }
    pii d=dfs(0,-1);
    cout<<max(d.first+d.second,1);
}




Measured memory_bytes: 13440
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
t=[0 for i in range(D)]


for day in range(D):
    t[day]=s[day].index(max(s[day]))+1

for ts in t:
    print(ts)


Measured memory_bytes: 9524
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

s = input()
l = len(s)
MOD = 10**9+7

dp = [0]*13
dp[0] = 1
for i in s:
    new = [0]*13
    if i == "?":
        for i in range(10):
            for j in range(13):
                new[(10*j+i)%13] += dp[j]
    else:
        i = int(i)
        for j in range(13):
            new[(i+10*j)%13] += dp[j]
    
    for i in range(13):
        new[i] %= MOD
    dp,new = new,dp
#    print(dp)

print(dp[5]%MOD)

Measured memory_bytes: 43420
#include <iostream>

using namespace std;

int main(void) {
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B) {
        if(B != C) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if(B == C || A == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=1e5+10;

int n,m;
char s[N];
int main() {
    R(s,m);
    n=strlen(s);
    REP(i,n) {
        if ( s[i]!='a' && 'z'-s[i]+1<=m ) {
            m-='z'-s[i]+1;
            s[i]='a';
        }
    }
    m%=26;
    s[n-1]+=m;
    if ( s[n-1]>'z' ) s[n-1]-=26;
    W(s);
    return 0;
}


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

int main(){long A, B, C;
cin >> A >> B >> C;
string ans = "NO";
rep(i, B){
    if(A % B * i % B == C) ans = "YES";
}


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




Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)


int main() {
	int h, a;
	cin >> h >> a;
	if (h % a == 0)cout << h / a << endl;
	else cout << (h / a) + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    s = int(input())
    i = 1
    l = [s]
    flag = 0
    while flag == 0:
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3*s + 1
        i += 1
        if s in l:
            print(i)
            return
        else:
            l.append(s)
main()  

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

                                    typedef long long ll;
                                    typedef  double ld;
                                    #define rep(i,a,n) for(ll i=(a); i<(n); i++)
                                    #define per(i,a,n) for(ll i=(n-1); i>=(a); i--)
                                    #define F first
                                    #define S second
                                    #define maxx(a,b) a=max(a,b)
                                    #define minn(a,b) a=min(a,b)
                                    #define db(x) cerr<<#x<<" = "<<x<<endl
                                    #define N 1111111
                                    #define mod 1000000007
                                    #define rt return
                                    #define inf 12345678908761

                                    using namespace std;

                                    int a[N],b[N],c[N];
                                    int ans[N][3];

                                    int main(){

                                        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

                                        //freopen("Ulug'bek","r",stdin);
                                        //freopen("Abdimanabov","w",stdout);

                                        int n; cin>>n;
                                        rep(i,1,n+1)cin>>a[i]>>b[i]>>c[i];
                                        rep(i,1,n+1)
                                        ans[i][0]=max(ans[i-1][1],ans[i-1][2])+a[i],
                                        ans[i][1]=max(ans[i-1][0],ans[i-1][2])+b[i],
                                        ans[i][2]=max(ans[i-1][0],ans[i-1][1])+c[i];

                                        cout<<*max_element(ans[n],ans[n]+n+1);

                                    rt 0;
                                    }



















Measured memory_bytes: 7552
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		Integer[] item = new Integer[n];
		
		double sum = 0;
		for(int i = 0 ; i < n ; i++) {
			item[i] = Integer.parseInt(sc.next());
			sum += item[i];
		}

		Arrays.sort(item, Collections.reverseOrder());

		String ans = "Yes";
		if((double)item[m-1] < (double)sum / (double)(4 * m)) {
			ans = "No";
		}

		System.out.println(ans);

	}
}


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

constexpr int64_t MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<string> s(2);
    cin >> s[0] >> s[1];
    vector<int64_t> dp(n);
    dp[0] = s[0][0] == s[1][0] ? 3 : 6;
    for (int64_t i = 0; i+1 < n; i++) {
        if (s[0][i] == s[0][i+1]) dp[i+1] = dp[i];
        else if (s[0][i] == s[1][i]) dp[i+1] = dp[i] * 2 % MOD;
        else if (s[0][i+1] == s[1][i+1]) dp[i+1] = dp[i];
        else dp[i+1] = dp[i] * 3 % MOD;
    }
    cout << dp.back() << endl;
}


Measured memory_bytes: 256
// ABC142 B

#include <bits/stdc++.h>
#define RI register int
typedef long long LL;


using namespace std;

int main() {

  int n; cin >> n;
  int m; cin >> m;
  int ans = 0;
  for (RI i = 1, x; i <= n; ++i)
    cin >> x, ans += (x >= m);
  cout << ans;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
a.sort()
bc = [inpl() for _ in range(m)]
bc.sort(key = lambda x:x[1], reverse = True)
lm = sum(x[1] for x in bc)
now = 0
alt = 0
while now < n and alt < m:
    c,b = bc[alt]
    if a[now] > b:
        break
    else:
        a[now] = b
    bc[alt][0] -= 1
    if bc[alt][0] == 0:
        alt += 1
    now += 1
print(sum(a))


Measured memory_bytes: 34916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    vector<pair<ll,ll>> A(N);
    for (int i = 0; i < N; ++i) {
        ll tmp;
        cin >> tmp;
        A[i] = make_pair(tmp,i);
    }
    sort(A.begin(),A.end());
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        if(i % 2 == 0 && A[i].second % 2 == 1){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	a := nextInt()
	b := nextInt()

	sum := 0
	for i := 1; i <= n; i++ {
		tmp := sumKeta(i)
		if a <= tmp && tmp <= b {
			sum += i
		}
	}

	fmt.Println(sum)

}

// 各桁の和
func sumKeta(n int) int {
	keta := 0
	for n > 0 {
		keta += n % 10
		n /= 10
	}
	return keta
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll a,b,c; cin>>a>>b>>c;
    if((a==b&&b!=c)||(b==c&&b!=a)||(c==a&&c!=b))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long tc;
	scanf("%lld",&tc);
	char huruf[100];
	int count = 0,i = 0;	
	while(tc)
	{
		long long k = tc / 26;
		long long z = tc % 26;
		if(z == 0)
		{
			k--;
			z += 26;
		}
		huruf[i] = z+'a'-1;
		tc = k;
		count++;
		i++;
	}
	for(int i = count-1;i>=0;i--)
	{
		printf("%c",huruf[i]);
	}
return 0;
}



Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
double factorial(int n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

double dist(pair<int,int> a,pair<int,int> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,n2=0;
    cin>>n;
    n2=n;
    vector<ll>a(n+1);
    vector<ll>b;
    for(ll i=1;i<n+1;i++){
        cin>>a[i];
    }
    bool flag=true;
    ll i=0;
    while(i!=n2){
        cout<<a[n]<<" ";
        if(flag){
            n-=2;
            if(n==0){
                n=1;
                flag=false;
            }
            else if(n==-1){
                n=2;
                flag=false;
            }
        }
        else{
            n+=2;
        }
        i++;
    }
    cout<<endl;
}


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

int main(){
	ll N;
	cin >> N;
	ll ans = 10010010010010;
	for(ll a=1; a*a<=N; a++){
		if(N%a) continue;
		ll b = N/a;
		ans = min(ans, a+b-2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str="";
        for(int i=0;i<6;i++){
            str+=sc.next();
        }
        if(str.replaceAll("1","").length()>=4&&str.replaceAll("2","").length()>=4&&str.replaceAll("3","").length()>=4&&str.replaceAll("4","").length()>=4){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
        

    }

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}
bool prime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
 
bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

bool vis[100005];
vl v[100005];
bool c=0;
void dfs(ll u,ll par){
	vis[u]=1;
	for(int child: v[u]){
		if(vis[child]==0 ){
			dfs(child,u);
		}
		else{
			if(child!=par){
				c=1;
			}
		}
	}
}

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
	string s;
	cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7'){
		cout<<"Yes";
	}
	else cout<<"No";
    return 0; 
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
	int m;
	while (cin >> m) {
		if (m == 0) {
			break;
		}
		vector<int> dp(7010, 0);
		vector<int> dp2(7010, 0);
		vector<P> data(m);
		for (int i = 0; i < m; i++) {
			cin >> data[i].first >> data[i].second;
		}
		for (int i = 0; i < m; i++) {
			vector<int> d;
			for (int j = 0; j < 7010; j++) {
				if (dp[j] > 0) {
					d.push_back(j);
				}
			}
			for (int j = 0; j < data[i].second; j++) {
				dp2[(data[i].first)*(j+1)]++;
			}
			for (int j = 0; j < d.size(); j++) {
				for (int k = 0; k < data[i].second; k++) {
					dp2[d[j]+(data[i].first)*(k+1)] += dp[d[j]];
				}
			}
			for (int j = 0; j < 7010; j++) {
				dp[j] = dp2[j];
			}
		}
		int g;
		cin >> g;
		int n;
		for (int i = 0; i < g; i++) {
			cin >> n;
			cout << dp[n] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1276
import scala.io.StdIn.readLine

object Main extends App {
  val arr = readLine.split(" ").map(_.toInt)
  var b = arr.sorted
  val team1 = b(0) + b(3)
  val team2 = b(1) + b(2)
  println(Math.abs(team1 - team2))
}



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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int
main()
{
  ull L, R; cin >> L >> R;

  int ans = 2019;
  if (R - L + 1 >= 2019) {
    ans = 0;
  } else if (R - L + 1 >= 673) {
    ans = 0;
  } else {
    ans = 2019;
    for (ull i = L; i < R; i++) {
      for (ull j = i+1; j <= R; j++) {
	if (ans > (i * j) % 2019) {
	  ans = (i * j) % 2019;
	  //	  cout << i << "," << j << "->" << ans << endl;
	}
      }
    }
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>s) {
		cout<<s.substr(0, 3)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3036
n, d, a = [int(s) for s in input().strip().split()]
X, H = [0] * n, [0] * n
for i in range(n):
    X[i], H[i] = [int(s) for s in input().strip().split()]

result = 0
monsters = sorted(zip(X, H))
q = []
ptr = 0
delta = 0
for x, h in monsters:
    while ptr < len(q) and q[ptr][0] < x:
        delta += q[ptr][1]
        ptr += 1
    h += delta
    if h <= 0:
        continue
    result += (h + a - 1) // a
    delta -= (h + a - 1) // a * a
    q.append((x + 2 * d, (h + a - 1) // a * a))
print(result)

Measured memory_bytes: 71588
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
  

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    X, Y, _ = map(int, input().split())
    X -= 1
    Y -= 1
    uf.union(X, Y) 
print(uf.group_count())

Measured memory_bytes: 7856
import Data.IORef
import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Int
  k <- readLn :: IO Int
  score <- newIORef 1
  replicateM_ n $ do
    now <- readIORef score
    let next = min (now + k) (now * 2)
    writeIORef score next

  print =<< readIORef score


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    sort(h.begin(), h.end());
    int odp = h[n - 1] - h[0];
    for (int i = 0; i + k - 1 < n; ++i)
        odp = min(odp, h[i + k - 1] - h[i]);
    cout << odp;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[10000000],c=0,d=0;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>c;
    if(c%2==0) b[d]=c,d++;
  }
  c=0;
  int i=0,r=0;
  for(int i=0;i<d;i++){
    while(true){
      if(b[i]%2==1) break;
      b[i]/=2;
      c++;
    }
  }
  cout<<c<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  string S;
  int res=INF;

  int L[310000]={0};
  int R[310000]={0};

  cin >> N >> S;

  int w=0, e=0;
  L[0]=0;
  for(int i=1;i<N;i++) {// #west on the left of the leader at i                 
    if(S[i-1]=='W') w++;
    L[i]=w;
  }

  R[N-1]=0;
  for(int i=N-2;i>=0; i--){// #east on the right of the leader at i             
    if(S[i+1]=='E') e++;
    R[i]=e;
  }

  rep(i,N){//i as leader's position                                             
    int num = L[i] + R[i];
    res = min(res, num);
  }

  cout << res << endl;
}

Measured memory_bytes: 3332