akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

const int size=10e5+2;
int sizeC;
int arr[size];
int state[size];

int main(){

  int k;
  scanf("%d",&sizeC);
  scanf("%d",&k);
  for(int i=0;i<sizeC;i++)
    scanf("%d",&arr[i]);

  state[0]=0;
  state[1]=abs(arr[0]-arr[1]);
  for(int i=2;i<=k;i++){
  }

  for(int i=2;i<sizeC;i++){
    state[i]=state[i-1]+abs(arr[i]-arr[i-1]);
    for(int j=2;j<=k && (i-j)>=0;j++){
      state[i]=min(state[i],state[i-j]+abs(arr[i-j]-arr[i]));
    }
  }

  cout<<state[sizeC-1]<<endl;

  return 0;
}


Measured memory_bytes: 4736
#include<iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(((a-c)<=d)&&((a-c)>=-d))
        cout << "Yes";
    else if(((a-b)<=d)&&((a-b)>=-d)){
        if(((b-c)<=d)&&((b-c)>=-d))
            cout << "Yes";
        else 
            cout << "No";
    }
    else 
        cout << "No";
    return 0;    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;

int main(){
  int n; cin>>n;
  int v[10][10];
  bool res=false;
  FOR(i,1,10){
    FOR(j,1,10){
      int a=i*j;
      if(a==n){
        res=true;
        break;
      }
    }
  }
if(res==true)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

class UnionFind {
private:
	int n, s;
	vector<int> p_id;
	vector<vector<int>> v;
public:
	UnionFind(int n = 0) { init(n); }
	void init(int arg_n) {
		n = s = arg_n;
		p_id.clear();
		v.clear();
		inc(i, n) { p_id.PB(i); v.EB(1, i); }
	}
	int id(int i) { return p_id.at(i); }
	bool same(int x, int y) { return (id(x) == id(y)); }
	bool unite(int x, int y) {
		x = id(x);
		y = id(y);
		if(x == y) { return false; }
		if(v[x].size() < v[y].size()) { swap(x, y); }
		for(auto & e: v[y]) { v[x].PB(e); p_id[e] = x; }
		v[y].clear();
		s--;
		return true;
	}
	const vector<int> & operator[](int i) { return v[id(i)]; }
	int size() { return s; }
	int get_n() const { return n; }
	const vector<vector<int>> & get_v() const { return v; }
};
ostream & operator<<(ostream & os, const UnionFind & uf) {
	inc(i, uf.get_n()) { os << i << ": "; for(auto & e: uf.get_v()[i]) { os << e << " "; } os << "\n"; }
	return os;
}

// ---- ----

int n, m;

int main() {
	cin >> n >> m;
	UnionFind uf(n);
	inc(i, m) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		uf.unite(x, y);
	}
	
	cout << SI(uf) << endl;
	
	return 0;
}


Measured memory_bytes: 10032
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll h;
    cin >> h;
    map<ll, ll> dp;
    function<ll(ll)> dfs = [&](ll x) {
        if (dp.count(x) != 0)
            return dp[x];
        if (x == 1)
            return 1LL;
        else
            return dp[x] = 2LL * dfs(x / 2) + 1LL;
    };
    cout << dfs(h) << "\n";
    return 0;
}

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

bool a = false,b= false,c= false,d=false;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	REP(i,4){
	int N;
	cin >> N;
	if(N ==1){
		a = true;
	}else if(N==9){
		b = true;
	}else if(N == 4){
		c= true;
	}else if(N == 7){
		d = true;
	}
}

if(a & b & c & d){
	cout << "YES" << endl;
}else{
	cout << "NO" << endl;
}

}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public static double r = 6378.1;
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			String[] tmp = line.split(" ");
			
			double hp1 = Double.parseDouble(tmp[0]);
			double ep1 = Double.parseDouble(tmp[1]);
			double hp2 = Double.parseDouble(tmp[2]);
			double ep2 = Double.parseDouble(tmp[3]);
			
			
			if(hp1==-1.0 && ep1==-1.0 && hp2==-1.0 && ep2==-1.0) break;
			
			hp1 = 2.0 * Math.PI * hp1 / 360.0;
			ep1 = 2.0 * Math.PI * ep1 / 360.0;
			hp2 = 2.0 * Math.PI * hp2 / 360.0;
			ep2 = 2.0 * Math.PI * ep2 / 360.0;
			
			
			
			double cosd = Math.sin(hp1) * Math.sin(hp2) + Math.cos(hp1) * Math.cos(hp2) * Math.cos(ep1 - ep2);
			double dp = Math.acos(cosd);
			double dist = Math.abs(r * dp);
			
			System.out.println((int)(dist+0.5));
		}
	}
}

Measured memory_bytes: 9812
#include <stdio.h>
int main()
{
  int i, j, k, tmp, n, A[1000];
   
 
  scanf("%d", &n);
   
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
   
   
  for(i=1;i<=n;i++){
 
    for(k=0; k<n; k++){
      printf("%d",A[k]); 
      if(k<n-1)printf(" ");
    }
 
    printf("\n");
    tmp=A[i];  
    j=i-1;
    while(j>=0 && A[j]>tmp){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=tmp;
  }
  return 0;
}
 
  

Measured memory_bytes: 608
from bisect import bisect_left as bs
while True:
  d = int(input())
  if not d: break
  n = int(input())
  m = int(input())
  d_lst = [int(input()) for _ in range(n - 1)]
  k_lst = [int(input()) for _ in range(m)]
  d_lst.extend([0,d])
  d_lst.sort()
  ans = 0
  for k in k_lst:
    ind = bs(d_lst,k)
    ans += min(abs(k - d_lst[ind]), abs(k - d_lst[ind - 1]))
  print(ans)


Measured memory_bytes: 10744
def solve():
  a,b,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  b = list(int(i) for i in input().split())
  ans = min(a)+ min(b)
  for i in range(m):
    x,y,c = (int(i) for i in input().split())
    tmp = a[x-1]+b[y-1]-c
    ans = min(ans,tmp)
    
  print(ans)
solve()

Measured memory_bytes: 18736
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

vector<bool> sosuu; // ←これをグローバル変数にして１度だけ実行する
void searchSosuu(ll N) {
	for (ll i = 0; i < N; i++) {
		sosuu.emplace_back(true);
	}
	sosuu[0] = false;
	sosuu[1] = false;
	for (ll i = 2; i < N; i++) {
		if (sosuu[i]) {
			for (ll j = 2; i * j < N; j++) {
				sosuu[i * j] = false;
			}
		}
	}
}

int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	ll N;
	cin >> N;


	searchSosuu(55555);

	vll base1;
	for (int i = 1; i <= 55555; i++)
	{
		if (i % 5 == 1 && sosuu[i])
		{
			base1.emplace_back(i);
		}
	}


	for (int i = 0; i < N; i++)
	{
		cout << base1[i] << " ";
	}






}





Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vll A(N);
    REP(i,N) cin >> A[i];


    //本文
    vll ans(N,0);
    for(int i = 1;i <N ; i++){
      if(A[i]<A[i-1]){
        ans[i]=A[i-1]-A[i];
        A[i]=A[i-1];
      }
    }
    
    ll ans2 = 0;
    REP(i,N){
      ans2 += ans[i];
    }

    //出力
    cout << ans2 << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  // cin >> a >> b;
  cin >> b >> a;
  string tmp = "";
  int l = 100;
  rep(i, l) tmp += ".";
  vector<string> v(l, tmp);

  for (int i = 0; i < l; i+=2) {
    for (int j = 0; j < l/2-1; j+=2) {
      if(a > 1) v[i][j] = '#';
      a--;
    }
  }

  for (int i = 0; i < l; i++) {
    for (int j = l/2; j < l; j++) {
      v[i][j] = '#';
    }
  }

  for (int i = 0; i < l; i+=2) {
    for (int j = l-1; j > l/2; j-=2) {
      if(b > 1) v[i][j] = '.';
      b--;
    }
  }

  cout << l << ' ' << l << endl;

  rep(i, l) cout << v[i] << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  vll cost(2);
  vll sum(2);
  rep(i, n) {
    vll s(2);
    vll c(2);

    s[0] = sum[1] + a[i];
    c[0] = cost[1];
    if (s[0] <= 0) {
      c[0] += abs(1 - s[0]);
      s[0] = 1;
    }

    s[1] = sum[0] + a[i];
    c[1] = cost[0];
    if (s[1] >= 0) {
      c[1] += abs(-1 - s[1]);
      s[1] = -1;
    }

    cost = c;
    sum = s;
  }

  cout << *min_element(all(cost)) << endl;

  return 0;
}


Measured memory_bytes: 3944
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;


int main(void){
	int n,m;
	cin>>n;
	map<int,int>c;
	vector<int>d(n);
	for(int i=0;i<n;i++){
		cin>>d[i];
		c[d[i]]++;
	}
	cin>>m;
	vector<int>t(m);
	for(int i=0;i<m;i++)cin>>t[i];
	for(int i=0;i<m;i++){
		if(c[t[i]]==0){
			cout<<"NO"<<endl;
			return 0;
		}
		else c[t[i]]--;
	}
	cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 11136
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	g := make([][]int, n*3)
	for i := 0; i < n*3; i++ {
		g[i] = make([]int, 0)
	}

	for i := 0; i < m; i++ {
		u := getNextInt(scanner) - 1
		v := getNextInt(scanner) - 1
		g[u] = append(g[u], v+n)
		g[n+u] = append(g[n+u], v+n*2)
		g[n*2+u] = append(g[n*2+u], v)
	}

	s := getNextInt(scanner) - 1
	t := getNextInt(scanner) - 1

	nodes := &Nodes{}
	heap.Init(nodes)
	heap.Push(nodes, Node{
		i:    s,
		cost: 0,
	})
	dd := make([]int, n*3)
	for i := 0; i < n*3; i++ {
		dd[i] = math.MaxInt32
	}
	visited := make([]int, n*3)
	for nodes.Len() > 0 {
		p := heap.Pop(nodes).(Node)
		if dd[p.i] < p.cost || visited[p.i] == 1 {
			continue
		}
		dd[p.i] = p.cost
		visited[p.i] = 1
		for _, to := range g[p.i] {
			if visited[to] == 1 {
				continue
			}
			heap.Push(nodes, Node{
				i:    to,
				cost: p.cost + 1,
			})
		}
	}

	ans := -1
	if dd[t] < math.MaxInt32 {
		ans = dd[t] / 3
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type Node struct {
	i, cost int
}

type Nodes []Node

func (h Nodes) Len() int           { return len(h) }
func (h Nodes) Less(i, j int) bool { return h[i].cost < h[j].cost }
func (h Nodes) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *Nodes) Push(x interface{}) {
	*h = append(*h, x.(Node))
}
func (h *Nodes) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll n,l;cin>>n>>l;
  vector<ll>a(n);
  buf=INF;
  for(i=0;i<n;i++){
    a[i]=l+i;
    sum+=a[i];
    if(buf>=abs(a[i])){
      buf2=a[i];
      buf=abs(a[i]);
    }
  }
  cout<<sum-buf2<<endl;


  return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
public class Main{
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer,Integer>hm = new HashMap<Integer,Integer>();
		
		int n = sc.nextInt();
		int p = 1000000007;
		
		for(int i = 1 ; i <= n ; i++) {
			hm.put(i, gcd(n,i));
		}
		long ans = 1;
		for(int i = 1 ; i <= n ; i++) {
			ans *= (hm.get(i)+1);  
			if(ans >= p) {
				ans = ans % p;
			}
		}
		System.out.println(ans);
	}
	private static int gcd (int n, int m ) {
		if(m == 1 || !prime(m))
			return 0;
		int count = 1;
		for(int i = m+1 ; i <= n ;i++) {
			int temp = i;
			while(temp % m == 0) {
				count++;
				temp = temp/m;
			}
		}
		return count;
	}
	
	private static boolean prime(int n) {
		if(n == 1)
			return false;
		
		if(n == 2 || n == 3) {
			return true;
		}
		double p = Math.sqrt(n);
		int temp = -1;
		
		for(int i = 2 ; i <= p ; i++) {
			if(n % i == 0) {
				temp = 0;
				break;
			}
		}
		if(temp == 0) {
			return false;
		}
		return true;
		}
	
	}



Measured memory_bytes: 22868
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	if (n < 1000)
	{
		println("ABC");
	}
	else
	{
		println("ABD");
	}
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int ans[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ans[i][j]=INT_MAX;
        }
    }
    if(s[0][0]=='#'){
        ans[0][0]=1;
    }
    else ans[0][0]=0;
    set<pair<int,pii>>s1;
    s1.insert({ans[0][0],{0,0}});
    //cout<<ans[0][0]<<endl;
    
    while(!s1.empty()){
        auto i=*s1.begin();
        s1.erase(s1.begin());
        if(i.se.se!=m-1){
            if(s[i.se.fi][i.se.se]==s[i.se.fi][i.se.se+1]||s[i.se.fi][i.se.se+1]=='.'){
                if(i.fi<ans[i.se.fi][i.se.se+1]){
                    s1.erase({ans[i.se.fi][i.se.se+1],{i.se.fi,i.se.se+1}});
                    ans[i.se.fi][i.se.se+1]=i.fi;
                    s1.insert({ans[i.se.fi][i.se.se+1],{i.se.fi,i.se.se+1}});
                }
            }
            else{
                if(i.fi+1<ans[i.se.fi][i.se.se+1]){
                    s1.erase({ans[i.se.fi][i.se.se+1],{i.se.fi,i.se.se+1}});
                    ans[i.se.fi][i.se.se+1]=i.fi+1;
                    s1.insert({ans[i.se.fi][i.se.se+1],{i.se.fi,i.se.se+1}});
                }
            }
        }
        if(i.se.fi!=n-1){
            if(s[i.se.fi][i.se.se]==s[i.se.fi+1][i.se.se]||s[i.se.fi+1][i.se.se]=='.'){
                if(i.fi<ans[i.se.fi+1][i.se.se]){
                    s1.erase({ans[i.se.fi+1][i.se.se],{i.se.fi+1,i.se.se}});
                    ans[i.se.fi+1][i.se.se]=i.fi;
                    s1.insert({ans[i.se.fi+1][i.se.se],{i.se.fi+1,i.se.se}});
                }
            }
            else{
                if(i.fi+1<ans[i.se.fi+1][i.se.se]){
                    s1.erase({ans[i.se.fi+1][i.se.se],{i.se.fi+1,i.se.se}});
                    ans[i.se.fi+1][i.se.se]=i.fi+1;
                    s1.insert({ans[i.se.fi+1][i.se.se],{i.se.fi+1,i.se.se}});
                }
            }
        }
    }
    //cout<<ans[1][1]<<endl;
    cout<<ans[n-1][m-1];
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for (int i = 0; i < M; i++) {
    cin >> L.at(i) >> R.at(i);
  } 
  int LI = L.at(0);
  int RE = R.at(0);
  for (int i = 0; i < M; i++) {
     LI = max(LI,L.at(i));
     RE = min(RE,R.at(i));
  } 
  cout << ((RE-LI+1 > 0) ? RE-LI+1 : 0)<< endl;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }

    let mut ret = vec![];
    for i in 0..s.len() {
        if i%2==0 {
            ret.push(s[i]);
        }
    }
    println!("{}", ret .iter().cloned().collect::<String>());
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> V(N),rsum(N+1,0),lsum(N+1,0);
  for(int i=0;i<N;i++){
    cin>>V[i];
  }
  for(int i=1;i<=N;i++){
    lsum[i]=lsum[i-1]+V[i-1];
  }
  int ans=0;
	for(int left=0;left<=min(N,K);left++){
		for(int right=0;right<=min(N,K)-left;right++){
			int gain=0;
			vector<int> loss;
			for(int i=0;i<left;i++){
				gain+=V[i];
				if(V[i]<0) loss.push_back(V[i]);
			}
			for(int i=0;i<right;i++){
				gain+=V[N-1-i];
				if(V[N-1-i]<0) loss.push_back(V[N-1-i]);
			}
			sort(loss.begin(),loss.end());
			for(int i=0;i<min(K-left-right,int(loss.size()));i++){
				gain-=loss[i];
			}
			ans=max(ans,gain);
		}
	}
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        if(x >= k) ans++;
    }
    cout << ans << endl;
	return 0;
}


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

#define INF 1000000

int main()
{
	int N;
	int ans = 0;
	cin >> N;

	vector<int> P(N + 5), lowest_math(N + 5);
	int lowest_now = INF;
	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
		if (P[i] < lowest_now)
		{
			lowest_now = P[i];
		}
		lowest_math[i] = lowest_now;
	}

	for (int j = 0; j < N; j++)
	{
		if (P[j] == lowest_math[j])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, n):
    if i == p[i - 1]:
        p[i - 1], p[i] = p[i], p[i - 1]
        cnt += 1
if p[-1] == n:
    cnt += 1
print(cnt)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007ll
using namespace std;
ll ara[300005], cnt[2];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    scanf("%lld", &ara[i]);
    ll res= 0;
    for(int i=0; i<60; i++)
    {
        cnt[0]= cnt[1]= 0;
        for(int j=0; j<n; j++)cnt[ (ara[j]&(1ll<<(i)))!=0 ]++;
        for(int j=0; j<n; j++)
        {
            cnt[ (ara[j]&(1ll<<(i)))!=0 ]--;
            res+= ((1ll<<(i))%mod)*cnt[ (ara[j]&(1ll<<(i)))==0 ];
            res%= mod;
        }
    }
    printf("%lld\n", res);
    return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, m, x, left = 0, right = 0, tmp;
    cin >> n >> m >> x;
    rep(i, m) {
        cin >> tmp;
        if (tmp < x)
            left++;
        else
            right++;
    }

    cout << min(left, right) << endl;
    return 0;
}

Measured memory_bytes: 3556
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
r = n-1
l = 0
r_sum = as[-1]
l_sum = as[0]
while l + 1 != r
  if r_sum > l_sum
    l += 1
    l_sum += as[l]
  else
    r -= 1
    r_sum += as[r]
  end
end
puts (r_sum - l_sum).abs


Measured memory_bytes: 18308
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time


def get_int(): return int(stdin.readline().strip())


def get_tuple(): return map(int, stdin.readline().split())


def get_list(): return list(map(int, stdin.readline().split()))

n = get_int()
ls = []
for _ in range(n):
    x,y = get_tuple()
    ls.append([x,y])

one,two,three = False,False,False
one = True if ls[0][0]==ls[0][1] else False
two = True if ls[1][0]==ls[1][1] else False
three = True if ls[2][0]==ls[2][1] else False
flag = 0
for i in range(3,n):
    one = two; two=three
    three = True if ls[i][0]==ls[i][1] else False
    if one and two and three:
        flag = 1
        break
if one and two and three:
        flag = 1
if flag: print("Yes")
else: print("No")

Measured memory_bytes: 75112
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	int res = 0;
	map<int, int> m;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		auto it = m.lower_bound(a);
		if (m.size() == 0 || it == m.begin()) {
			m[a]++;
			res++;
		} else {
			it--;
			m[it->first]--;
			if (m[it->first] == 0) {
				m.erase(it->first);
			}
			m[a]++;
		}
	}
	cout << res << endl;
}


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

#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << endl;
#define all(a)      (a).begin(),(a).end()
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define scl1(a)             scanf("%lld", &a)
#define scl2(a, b)          scanf("%lld %lld", &a, &b)

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
const int N=(int)3e3+5;
int32_t main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll i,j,z,k,ns,nt;
string s,t,p="";
cin>>s>>t;
ns=s.size();
nt=t.size();
ll dp[nt+1][ns+1];
Fill(dp,0);
rep(i,1,nt+1,1){
	rep(j,1,ns+1,1){
		if(s[j-1]==t[i-1]){
			dp[i][j]=1+dp[i-1][j-1];
		}
		else{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			// dp[i][j]=max(dp[i][j],dp[i-1][j-1]);
		}
	}
}
i=nt,j=ns;
ll mx=dp[i][j];



while(i>0 && j>0){
	if(t[i-1] == s[j-1])
        {   
            p = t[i-1] + p;
            i--,j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
}

cout<<p;
}


Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

int main() {
	int h, w; cin >> h >> w;
	vector<string>s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		cout << s[i] << endl << s[i] << endl;
	}
}


    

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] R;
	int max,min;
	
	public void input() {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	}
	
	public void compute() {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.compute();
	}
}



Measured memory_bytes: 102044
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
#define INF ((ll)1e17)
using namespace std;

ll n, ans = -INF;
ll a[MAX], sum[MAX][3], mx[MAX], ss[MAX];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    if(!(n&1)){
        ll s = 0;
        for(int i = 1; i <= n; i += 2) s += a[i];
        ans = max(ans, s);
        s = 0;
        for(int i = 2; i <= n; i += 2) s += a[i];
        ans = max(ans, s);
        for(int i = 1; i <= n; i += 2){
            ss[i] = ss[max(i-2, 0)]+a[i];
        }
        for(int i = n; i >= 2; i -= 2){
            ss[i] = ss[i+2]+a[i];
        }
        for(int i = 1; i <= n; i += 2){
            ans = max(ans, ss[i]+ss[i+3]);
        }
        cout << ans << endl;
        return 0;
    }
    for(int i = 1; i <= n; i += 2) sum[i][1] = sum[max(i-2, 0)][1]+a[i];
    ll s = 0;
    for(int i = n-1; i >= 2; i -= 2) s += a[i+1], sum[i][0] = sum[i+2][0]+a[i], mx[i] = s-sum[i][0];
    for(int i = n-1; i >= 2; i -= 2){
        mx[i] = max(mx[i], mx[i+2]);
    }
    for(int i = 1; i <= n; i += 2){
        ans = max(ans, sum[max(i-2, 0)][1]+sum[i+1][0]+mx[i+1]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11480
import sys


def input():
    return sys.stdin.readline().strip()


N, M = map(int, input().split())

A = list(map(int, input().split()))
A.sort(reverse=True)
all = sum(A)

for i in range(M):
    if A[i] < all / (4 * M):
        print("No")
        sys.exit()

print("Yes")


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>


int main()
{
    char S[105];
    int N,i,j,k=1,l;
    scanf("%d",&N);
    scanf("%s",S);

    if(N%2==1)
        printf("No\n");
    else
    {
        for(i=0;i<N/2;i++)
        {
            if(S[i]==S[N/2+i])
                k=1;
            else
            {
                k=0;
                break;
            }
        }
    
    if(k==1)
        printf("Yes\n");
    else
        printf("No\n");}
    return 0;
}


Measured memory_bytes: 1648
N = int(input())
TA = list(map(int, input().split(' ')))
T = TA[0]
A = TA[1]
heights = list(map(int, input().split(' ')))
diff_temps = []
for height in heights:
    diff_temps.append(abs(A - (T - height * 0.006)))
res = diff_temps.index(min(diff_temps)) + 1
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if((4*i+7*j)==n) {
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a,n)   FOR(i,0,n)
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
//typedef pair<LL, LL> P;
//typedef pair<P, P> PP;

int n, m, a;
int dp[1 << 20], s[101010][25], li[25];
int main() {
	cin >> n >> m;
	REP(i, 0, n) {
		cin >> a;
		s[i + 1][a - 1]++;
		li[a - 1]++;
	}

	REP(i, 0, n) REP(j, 0, m) s[i + 1][j] += s[i][j];

	REP(i,0, 1 << 20)dp[i] = INF;
	dp[0] = 0;
	REP(i, 0, (1 << m)) {
		int pos = 0;
		REP(j, 0, m) if ((i >> j) & 1) pos += li[j];
		REP(j, 0, m) {
			if ((i >> j) & 1) continue;
			dp[i + (1 << j)] = min(dp[(i + (1 << j))], dp[i] + li[j] - (s[pos + li[j]][j] - s[pos][j]));
		}
	}

	cout << dp[(1 << m) - 1] << endl;
	return 0;
}

Measured memory_bytes: 16912
#include <bits/stdc++.h>
#define B bitset<500>
using namespace std;
int n,m;
int x[200000],y[200000];
bool die[500];
B a[500];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=n;i++)
	{
		a[i][i]=1;
		for(int j=m;j;j--)
		if(a[i][x[j]] && a[i][y[j]])
		{
			die[i]=1;
			break;
		}
		else
		if(a[i][x[j]])
			a[i][y[j]]=1;
		else
		if(a[i][y[j]])
			a[i][x[j]]=1;
	}
	int ans=0;
	for(int i=1;i<n;i++)
	if(!die[i])
		for(int j=i+1;j<=n;j++)
		if(!die[j] && (a[i]&a[j]).none())
			++ans;
	printf("%d\n",ans);
	return 0;
}

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


int main() {

    int n, d, x;
    cin >> n >> d >> x;
    int ans = x;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        int tmp = 1 + (d - 1) / a;
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

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

long long N;
string S;
int P;

long long solve() {
    if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) if ((S[N-i-1]-'0') % P == 0) res += N-i;
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}

int main() {
    cin >> N >> P >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int a,b;
   cin>>a>>b;
   if(a<b)cout<<0<<endl;
   else cout<<10<<endl;
   return 0;
}


Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100+10;

int n,a[N],o[N];

int main() {
    n=read();
    for (re int i=1;i<=n;++i) ++o[a[i]=read()];
    int d=0;
    for (re int i=1;i<=n;++i) d=max(d,a[i]);
    if (d&1) {
        int flag=1;
        for (re int i=d;i>(d+1)/2;--i) if (o[i]<2) flag=0;
        if (o[(d+1)/2]!=2) flag=0;
        for (re int i=(d-1)/2;i;--i) if (o[i]) flag=0;
        puts(flag?"Possible":"Impossible");
    } else {
        int flag=1;
        for (re int i=d;i>d/2;--i) if (o[i]<2) flag=0;
        if (o[d/2]!=1) flag=0;
        for (re int i=d/2-1;i;--i) if (o[i]) flag=0;
        puts(flag?"Possible":"Impossible");
    }
    return 0;
}


Measured memory_bytes: 256
//by The_One_Solver
#include<bits/stdc++.h>
using namespace std;
long long v,o,p,n,m,c,h,a,b,d;
int main()
{
  cin>>a>>b>>c;
  if(a%2||b%2||c%2)return cout<<0,0;
  while(m<10000)
  {    n=a,d=b,h=c;
      a=(d/2)+(h/2);
      b=(n/2)+(h/2);
      c=(d/2)+(n/2);
      m++;
      if(a%2==1||b%2==1||c%2==1)break;

  }
  if(m<10000)
  cout<<m;
  else cout<<-1;
    return 0;
}


Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;

typedef pair<long long, long long> pl;

#define ll long long


long long A[100005] = {};


/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, k, a, b, c, d, e, H, W;
long long B[2][100005] = {};
bool f;
bool ff;
string S;
set <long long>sll;
pl buf;
vector <long long>vl;

struct ST
{
	long long group;
	long long rank;
	long long tugi=-1;
	int siro;
};

vector <ST> vst;
ST st[100004];

double fl, fll;


int main() {

	cin >> a>>b>>A[0];
	

	for (int i = 0; i < 10; i++) {
		A[i + 1] = A[i] * a - b;
		cout << A[i + 1] << endl;
	}

	return 0;

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    ll min = 0;
    ll max = N;
    ll ans = 0;
    for(ll i = 1; i <= N + 1; i++){
        if (i == 1){
            if (K == 1){
                ans += (N + 1);
                ans = ans % 1000000007;
            }
        }
        else{
            min += (i - 1);
            max += (N + 1 - i);
            if (i >= K){
                ans += (max - min + 1) % 1000000007;
                ans = ans % 1000000007;
            }
        }
    }
    cout << ans << endl;
}



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

int main(){
//srandom((unsigned long)time(NULL));

int a,b,c,d;
cin>>a>>b>>c>>d;
bool takaWin = true;
while(a>0 && c>0){
   
    c-=b;
    if(c<=0) break;
     a-=d;
    if(a<=0) takaWin=false;
}

if(takaWin) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}



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

#define ll long long int
#define mod 1000000007

/*
cout<<"\ndebugging\n";
*/

int main()
{
	ios_base::sync_with_stdio(false); 	//Fast I/O
    cin.tie(NULL);
    
	ll t,n,i,j;
	cin>>n;
	vector<ll> a;
	ll x;
	for(i=0;i<n;i++)
	{
		cin>>x;
		a.push_back(x);
	}
	ll sum=0,sumall=0;
	for(i=n-2;i>=0;i--)
	{
		sumall=(sumall + a[i+1])%mod;
		sum= (sum + (a[i]*sumall)%mod)%mod;
	}	
	cout<<sum;
	return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  i64 a,b,c;
  cin >> a >> b >> c;
  cout << min(b / a, c) << endl;
}


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

int main(void) {
	int N;
	int ans = 0;
	cin >> N;
	if (N % 2 == 0)
		cout << N << endl;
	else
		cout << N * 2 << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){
  var n int
  fmt.Scan(&n)
  
  if n==1{
    fmt.Println("Hello World")
  }else if n==2{
    var a,b int
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Println(a+b)
  }
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  string s;
  
  cin >> n;
  m=0;
  rep(i,n){
    cin >> a[i];
    if(m>a[i]){
      result += m-a[i];
      //cout << m-a[i] << endl;
      a[i] = m;
    }
    m = max(m,a[i]);
  }
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 5580
s = input()

a = int(s[0:2])
b = int(s[2:4])

if a >= 1 and a <= 12:
    if b >= 1 and b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif b >= 1 and b <= 12:
    if a >= 1 and a <= 12:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060