akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int;
const LL mod = 1000000007;
 
const int MAX_N = 705;

int N, M;
bool Edge[MAX_N][MAX_N];

vector<int> edgeList[MAX_N];

vector<int> S[2];

int color[MAX_N];

void coloring(int pos, int c = 1) {
    if(color[pos] == 0 || color[pos] == c)
        color[pos] = c;
    else {
        color[pos] = -1;
        return;
    }
        
    int nextColor = (c == 1 ? 2 : 1);
    for(int i = 0; i < edgeList[pos].size(); i++) {
        int next = edgeList[pos][i];
        if(color[next] == nextColor) {
            continue;
        }
        coloring(next, nextColor);
    }
}

bool used[MAX_N];
int counter(int pos, int c = 1) {
    int ret = 0;
    used[pos] = true;
    if(color[pos] == c) {
        ret++;
    }

    for(int i = 0; i < edgeList[pos].size(); i++) {
        int next = edgeList[pos][i];
        if(!used[next]) {
            ret += counter(next, c);
        }
    }

    return ret;
}

bitset<MAX_N> bitDp[MAX_N];

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--; b--;
        Edge[a][b] = Edge[b][a] = true;
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(Edge[i][j] || i == j) {
                continue;
            }
            edgeList[i].push_back(j);
        }
    }
 
    memset(color, 0, sizeof(color));
    for(int i = 0; i < N; i++) {
        if(color[i] == 0) {
            coloring(i);
            memset(used, 0, sizeof(used));
            S[0].push_back(counter(i, 1));
            memset(used, 0, sizeof(used));
            S[1].push_back(counter(i, 2));
        } else if(color[i] == -1) {
            cout << -1 << endl;
            return 0;
        }
    }

    // for(int i = 0; i < S[0].size(); i++) {
    //     cerr << S[0][i] << " ";
    // }
    // cerr << endl;
    // for(int i = 0; i < S[1].size(); i++) {
    //     cerr << S[1][i] << " ";
    // }
    // cerr << endl;
    // cerr << endl;
    // for(int i = 0; i < N; i++) {
    //     cerr << color[i] << " ";
    // }
    // cerr << endl;

    bitDp[0].set(0);
    for(int i = 0; i < S[0].size(); i++) {
        bitDp[i+1] = (bitDp[i] << S[0][i]) | (bitDp[i] << S[1][i]); 
    }

    //cerr << bitDp[S[0].size()] << endl;

    int ans = 1145141919;
    for(int i = 0; i < MAX_N; i++) {
        if(bitDp[S[0].size()].test(i)) {
            ans = min(ans, i*(i-1)/2 + (N-i)*(N-i-1)/2);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    double a, b;
    cin >> a >> b;
    if (a == b)
    {
        cout << "EQUAL" << endl;
    }
    else if (a > b)
    {
        cout << "GREATER" << endl;
    }
    else
    {
        cout << "LESS" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if(a==c&&a!=b)cout<<"Yes";
	else if(b==c&&a!=b)cout<<"Yes";
	else if(a==b&&b!=c)cout<<"Yes";
	else cout<<"No"; 
	RE 0;
}



Measured memory_bytes: 256
from itertools import product
N = input()
X = []

for i in range(4):
  X.append(int(N[i]))

for ops in product((1,-1), repeat=3):
  calc = X[0] + X[1]*ops[0] + X[2]*ops[1] + X[3]*ops[2]
  if calc == 7:
    opstr = [""] * 3
    for i in range(3):
      opstr[i] = '+' if ops[i] == 1 else '-'
    print(N[0] + opstr[0] + N[1] + opstr[1] + N[2] + opstr[2] + N[3] + "=7")
    break


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << '#' << vec.at(i) << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
}

Measured memory_bytes: 3636
N, W = map(int, input().split())
VW = [list(map(int, input().split())) for i in range(N)]
dp = [0] * (W + 1)
for i, (v, w) in enumerate(VW):
    for j in range(W, w - 1, -1):
        dp[j] = max(dp[j], dp[j - w] + v)
print(dp[-1])



Measured memory_bytes: 5920
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	}
}


Measured memory_bytes: 28824
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int keta_Sum(int num){
    
    int sum = 0;
    
    // 各桁の計算
    while(num != 0){
        sum += num % 10;
        num /= 10;
    }
    
    return sum;
}


int main(){
    
    int N;
    cin >> N;
    
    int sum = keta_Sum(N);
    
    // ハーシャッド数かどうか判定
    if(N % sum == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3104
N, W = map(int, input().split())

items = [list(map(int, input().split())) for _ in range(N)]

dp = [[10**10] * (10**5+1)  for _ in range(N+1)]
dp[0][0] = 0

for i in range(1, N+1):
    for j in range(10**5+1):
        dp[i][j] = dp[i-1][j]
        if j >= items[i-1][1]:
            dp[i][j] = min(dp[i][j], dp[i-1][j-items[i-1][1]] + items[i-1][0])

res = 0
for i in range(10**5+1):
    if dp[N][i] <= W:
        res = i

print(res)

Measured memory_bytes: 119916
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  std::string s;
  cin >> s;
  int count = 0;
  for (auto c : s) {
    if (c == 'o') {
      count++;
    }
  }
  count += (15 - s.size());
  if (count >= 8) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
ll mod = 1e9+7, INF = 1e18;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
ll digit(ll x){ll c=0;while(x>0){x=x/10;c++;}return c;}
// for (ll i = 0; i < n; i++) {
// sort(.begin(), .end());
int main(){
  ll n;
  cin >> n;
  vll a(n);
  long double x = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    x += 1.0/a[i];
  }
  cout << fixed << setprecision(6);
  cout << 1.0/x << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int ans=0;
  for(int i=0;i<S.size();i++){
    int tmp=0;
    for(int j=i;j<S.size();j++){
      if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T') tmp++;
      else break;
    }
    ans = std::max(ans, tmp);   
  }
  cout << ans << endl;
}

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

int main(){
  int n, ans=0;
  cin >> n;
  vector<int> v(n+1);
  for(int i=1;i<=n;i++){
    cin >> v[i];
  }
  for(int i=1;i<=n;i++){
    if (v[i] == i){
      swap(v[i], v[i+1]);
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int money = 700;

        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == 'o') {
                money += 100;
            }
        }
        System.out.println(money);
    }

}




Measured memory_bytes: 21844
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int manth = Integer.parseInt(sc.next());
    int day = Integer.parseInt(sc.next());
    int takahasi = 0;
   
    if(manth<=day) takahasi = manth;
    else takahasi = manth-1;
    
    System.out.println(takahasi);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define FINISH cout<<0<<endl;return 0
#define MOD 1000000007

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N), B(N), C(N, 0);
	for (int i = 0;i < N;i++)cin >> A[i];
	for (int i = 0;i < N;i++)cin >> B[i];

	C[0] = A[0];
	for (int i = 1;i < N;i++) {
		if (A[i] != A[i - 1])C[i] = A[i];
	}
	if (C[N - 1] > 0 && C[N - 1] != B[N - 1]) {
		FINISH;
	}
	else {
		C[N - 1] = B[N - 1];
	}
	for (int i = N - 2;i >= 0;i--) {
		if (B[i] != B[i + 1]) {
			if (C[i] > 0 && C[i] != B[i]) {
				FINISH;
			}
			else {
				C[i] = B[i];
			}
		}
	}
	
	ll mx = 0;
	for (int i = 0;i < N;i++) {
		mx = max(mx, C[i]);
		if (mx != A[i]) { FINISH; }
	}
	mx = 0;
	for (int i = N - 1;i >= 0;i--) {
		mx = max(mx, C[i]);
		if (mx != B[i]) { FINISH; }
	}

	ll ans = 1;
	for (int i = 0;i < N;i++) {
		if (C[i])continue;
		ans *= min(A[i], B[i]);
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2688
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

vector<int> P;
//Nまでの素数を列挙する
void eratosthenes( const int N ) {
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ ) {
        is_prime[ i ] = true;
    }
    for( int i = 2; i <= N; i++ ) {
        if( is_prime[ i ] ) {
            for( int j = 2 * i; j <= N; j += i ) is_prime[ j ] = false;
            P.emplace_back( i );
        }
    }
}


int main(void){
    ll n;
    cin >> n;
    if(n==1) {
        cout << 0 << endl;
        return 0;
    }
    int limit = ceil(sqrt(n));
    eratosthenes(limit);
    set<ll> s(ALL(P));
    int size = P.size();
    REP(i, size) {
        ll x = P[i];
        while(x <= limit) {
            s.insert(x);
            x *= P[i];
        }
    }
    
    int count = 0;
    for(auto itr = s.begin(); itr != s.end(); ++itr) {
        if((n % *itr) == 0) {
            n /= *itr;
            count++;
        }
    }
    if(n>=limit) count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 7420
conb_list = [ [ 1 for i in range(51) ] for j in range(51) ]
for i in range(1,51):
    for j in range(1,51):
        conb_list[i][j] = conb_list[i-1][j] + conb_list[i][j-1]


n, a, b = [ int(v) for v in input().split() ]
num_list = sorted([ int(v) for v in input().split() ], reverse = True)

def mean(inlist):
    return sum(inlist) / len(inlist)

ans = 0
for i in range(a,b+1):
    if i == a:
        min_element = num_list[i-1]
        min_element_count = num_list.count(min_element)
        min_element_index = num_list.index(min_element)
        max_mean = mean(num_list[:i])

        ans += (conb_list[min_element_count - i + min_element_index][i - min_element_index])
    else:
        if max_mean > mean(num_list[:i]):
            break
        else:
            ans += (conb_list[min_element_count - i + min_element_index][i - min_element_index])

print(max_mean)    
print(ans)


Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;

vector<int>a(n);

for(int i = 0;i < n;i++){
  cin >> a[i];
}

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


cout << a[n-1]-a[0] <<endl;
}

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

using namespace std;

int main() {
	string s, t, u;
	cin >> s;
	int digit = s.size() - 2;
	t = s[0];
	u = to_string(digit);
	t = t + u;
	t = t + s[digit + 1];
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
LR = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    L, R = map(int, input().split())
    LR[L - 1][R - 1] += 1

for i in range(1, N):
    LR[0][i] += LR[0][i - 1]
    LR[i][0] += LR[i - 1][0]

for i in range(1, N):
    for j in range(1, N):
        LR[i][j] = LR[i - 1][j] + LR[i][j - 1] + LR[i][j] - LR[i - 1][j - 1]


for i in range(Q):
    p, q = map(int, input().split())
    p -= 2
    q -= 1
    if p != -1:
        ans = LR[q][q] - LR[q][p] - LR[p][q] + LR[p][p]
    elif p == -1:
        ans = LR[q][q]
    print(ans)


Measured memory_bytes: 13404
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
using namespace std;

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

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 1) {
            int count = 0;
            for (int j = 1; j <= i; j++) {
                if (i % j == 0)
                    count++;
            }
            if (count == 8) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int func(int i, int K) {
    return ceil((double)log(K/(double)i)/log(2));
}

int main() {
    int N, K;
    cin >> N >> K;
    double ans = 0;
    rep(i, N) {
        int tmp = max(func(i + 1, K), 0);
        ans += pow(0.5, tmp)/(double)N;
    }
    printf("%.10f\n", ans);
    return 0;
}

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

int main(){
    int x,y;
    while(true){
        cin>>x>>y;
        if (x==0 && y==0)break;
        if (x>y){
            cout<<y<<" "<<x<<endl;
        }
        else{
            cout<<x<<" "<<y<<endl;
        }
    }
return 0;
}


Measured memory_bytes: 3012
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
    int N,M;
    cin>>N>>M;
    int a[M];
    int b[M];
    for(int i=0;i<M;i++){
        int tmp_a,tmp_b;
        scanf("%d %d",&tmp_a,&tmp_b);
        tmp_a--;tmp_b--;
        a[i] = tmp_a;
        b[i] = tmp_b;
    }
    int cnt=0;
    for(int i=0;i<M;i++){
        UnionFind tree(N);
        for(int j=0;j<M;j++){
            if(i!=j){
                tree.merge(a[j],b[j]);                
            }
        }
        if(tree.size(0)!=N)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int i;
double b,c;
while(scanf("%lf\n",&b)!=EOF){
c=b;
for(i=2;i<=10;i++){
if(i%2==0){
c=c+b*2;
b=b*2;
}
else{
c=c+b/3;
b=b/3;
}
}
printf("%lf\n",c);
}
return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
#define long long long
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

long N,M;

long combination(long n, long r) {
  if ( r * 2 > n ) r = n - r;
  long dividend = 1;
  long divisor  = 1;
  for ( long i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}


int main(){
	cin >> N >> M;
	long M_ans, N_ans;
	if (M > 1){
		M_ans = combination(M, 2);
	}else{
		M_ans = 0;
	}
	if (N > 1){
		N_ans = combination(N, 2);
	}else{
		N_ans = 0;
	}



	cout << N_ans + M_ans<< endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);

	vector<int> arr(n);
	vector<int> mod(m);
	map<int, int> count;

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

		mod[arr[i] % m]++;
		count[arr[i]]++;
	}	
	
	vector<int> eqpair(m);

	for (auto& c : count)
		eqpair[c.xx % m] += c.yy / 2;

	int ans = 0;

	for (int i = 0; i <= m - i; i++)
	{
		if (i == 0 || i == m - i)
		{
			ans += mod[i] / 2;
			continue;
		}

		int maxp = 0;
		for (int j = 0; j <= eqpair[i]; j++)
		{
			int mr = mod[i] - j * 2;
			int p = j;

			if (mr >= mod[m - i])
				p += mod[m - i];
			else
			{
				int maxe = min(eqpair[m-i], (mod[m - i] - mr) / 2);
				p += maxe;
				int mir = mod[m - i] - maxe * 2;
				p += min(mir, mr);
			}

			maxp = max(p, maxp);
		}

		ans += maxp;
	}

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

	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pi acos(-1.0)

int main()
{
    ll i, j, a, b, k, n, m, cnt = 0;
    cin >> a >> b >> k;
    if(k - a >= 0){
        k -= a;
        cout << 0 << " ";
        if(k - b >= 0)
        {
            cout << 0 << endl;
            return 0;
        }
        else
            cout << abs(k - b) << endl;
    }
    else
        cout << abs(k - a) << " " << b << endl;
        

    return 0;
}


Measured memory_bytes: 3604
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[] for i in range(N)]
count = 0
for i in range(N):
    A[i] = list(map(int, input().split()))
for i in range(N):
    y = 0
    for j in range(M):
        y += B[j]*A[i][j] 
    if y+C > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
a, b, k = map(int, input().split())
if b-a+1 > 2*k:
    for i in range(k):
        print(a)
        a += 1
    for i in range(k):
        print(b-k+1)
        b += 1
else:
    for i in range(b-a+1):
        print(a)
        a += 1

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)

int N;
int count = 0;

int main() {
    cin >> N;

    long long res = 0;

     vector<vector<long long>> num(10, vector<long long>(10, 0));   for (int i = 1; i <= N; i++) {
        vector<int> d;
        int nn = i;
        while (nn) {
            d.push_back(nn % 10);
            nn /= 10;
        }
        int a = d[0];
        int b = d.back();
        if (!a || !b) continue;
        num[a][b]++;
    }
    for (int a = 1; a < 10; a++) {
        for (int b = 1; b < 10; b++) {
            res += num[a][b] * num[b][a];
        }
    }

    cout << res << endl;

    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  string A;
  cin >> A;
int N;
  N = A.size();

  int val = N/2;
  int ans = 0;
  REP(i, val){

    string mp1, tm;
   mp1 = A[i];
  tm = A[N - i - 1];
  if (mp1 != tm){ans++;}

  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N, A, B, C = list(map(int, input().split()))
s = [0] * (N+1)

for i in range(N):
    s[i] = input()
s[N] = 'AB'

ans = [0] * N
for i in range(N):
    if s[i] == 'AB':
        if A > B:
            A -= 1
            B += 1
            ans[i] = 'B'
        elif A < B:
            A += 1
            B -= 1
            ans[i] = 'A'
        else:
            if s[i+1] == 'BC':
                A -= 1
                B += 1
                ans[i] = 'B'
            else:
                A += 1
                B -= 1
                ans[i] = 'A'
    elif s[i] == 'AC':
        if A > C:
            A -= 1
            C += 1
            ans[i] = 'C'
        elif A < C:
            A += 1
            C -= 1
            ans[i] = 'A'
        else:
            if s[i+1] == 'AB':
                A += 1
                C -= 1
                ans[i] = 'A'
            else:
                A -= 1
                C += 1
                ans[i] = 'C'
    elif s[i] == 'BC':
        if B > C:
            B -= 1
            C += 1
            ans[i] = 'C'
        elif B < C:
            B += 1
            C -= 1
            ans[i] = 'B'
        else:
            if s[i+1] == 'AB':
                B += 1
                C -= 1
                ans[i] = 'B'
            else:
                B -= 1
                C += 1
                ans[i] = 'C'

    if A < 0 or B < 0 or C < 0:
        print('No')
        sys.exit()
print('Yes')
for i in range(N):
    print(ans[i])


Measured memory_bytes: 17064
#include <stdio.h>
#include <string.h>
 
int main() {
	char c[4];
  	scanf("%s",&c);
  	if(strcmp(c,"SAT")==0) printf("1");
  	if(strcmp(c,"FRI")==0) printf("2");
  	if(strcmp(c,"THU")==0) printf("3");
  	if(strcmp(c,"WED")==0) printf("4");
  	if(strcmp(c,"TUE")==0) printf("5");
  	if(strcmp(c,"MON")==0) printf("6");
  	if(strcmp(c,"SUN")==0) printf("7");
  	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N,M,Q;
	cin >> N >> M >> Q;
	vector<tuple<int,int,int,int>>v(Q);
	REP(i,Q){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		--a;--b;
		v[i] = {a,b,c,d};
	}
	int ans = 0;
	auto dfs = [&](auto&&f,int n,vector<int>&a){
		if(n == N){
			int sum = 0;
			//REP(i,a.size())cout << a[i] << " \n"[i+1 == a.size()];	
			REP(i,Q){
				auto[A,B,C,D] = v[i];
				if(a[B] - a[A] == C)sum += D;
			}
			CHMAX(ans,sum);
			return;
		}
		int now = 0;
		if(n)now = a[n-1];
		FOR(i,now,M){
			a[n] = i;
			f(f,n + 1,a);
		}
	};
	vector<int>a(N);
	dfs(dfs,0,a);
	out(ans);
}

Measured memory_bytes: 3632
#include <iostream>
#include <set>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    #define _CRT_SECURE_NO_WARNINGS
    #pragma warning(disable:4996)
#endif

#define ll long long
#define vi vector<ll>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;



int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    vi dp1(n), dp2(n), dp3(n);
    dp1[0] = a[0];
    dp2[0] = b[0];
    dp3[0] = c[0];
    for (int i = 1; i < n; i++)
    {
        dp1[i] = max(dp2[i - 1], dp3[i - 1]) + a[i];
        dp2[i] = max(dp1[i - 1], dp3[i - 1]) + b[i];
        dp3[i] = max(dp1[i - 1], dp2[i - 1]) + c[i];
    }
    cout << max(dp1[n - 1], max(dp2[n - 1], dp3[n - 1]));
}

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

int main(void){
    int n,t,a;
    cin >> n >> t >> a;
    vector<int> vec(n);
    for (int i = 0; i < n; i++){
        cin >> vec.at(i);
    }

    vector<int> vec2(n);
    int min=1000000000;
    int ans=0;
    for (int i = 0; i < n; i++){
        vec2.at(i) = abs(a*1000-(t*1000-vec.at(i)*6));
        if (vec2.at(i) < min){
            min = vec2.at(i);
            ans = i;
            // cout << min << endl;
            // cout << ans << endl;
            // cout << endl;
        }
    }
    
    cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define acc(v) accumulate(v.begin(), v.end(),0);
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int a = (int)(s[0]-48);
  int b = (int)(s[1]-48);
  int c = (int)(s[2]-48);
  int d = (int)(s[3]-48);

  for(int bit = 0; bit < (1 << 3); bit++) {
    //cout << bitset<3>(bit) << endl;
    //bitが立つと引き算
    if(bit & (1 << 2)) b *= -1;
    if(bit & (1 << 1)) c *= -1;
    if(bit & (1 << 0)) d *= -1;

    int sum = a + b + c + d;

    if(sum == 7) {
      cout << a;
      cout << (b < 0 ? "-" : "+") << abs(b);
      cout << (c < 0 ? "-" : "+") << abs(c);
      cout << (d < 0 ? "-" : "+") << abs(d);
      cout << "=" << sum << endl;
      return 0;
    }
      b = abs(b);
      c = abs(c);
      d = abs(d);

  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int n;
    cin >> n;
    vector<int> vec(n+5);
    for(int i = 1; i <= n; ++i)
    {
        cin >> vec[i];
    }
    vector<vector<ll>> dp(n+5, vector<ll>(n+5));
    for(int len = 1; len <= n; ++len)
    {
        for(int left = 1; left+len-1 <= n; ++left)
        {
            int right = left+len-1;
            ll takeLeft = vec[left] - dp[left+1][right];
            ll takeRight = vec[right] - dp[left][right-1];
            dp[left][right] = max(takeLeft, takeRight);
        }
    }
    cout << dp[1][n] << "\n";
    return 0; 
}


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

const long long mod = 1e9+7;

int main(void){
    int n, m;
    std::cin >> n >> m;

    std::vector<bool> out(n+1, true);
    for(int i = 0; i < m; i++){
        int a;
        std::cin >> a;
        out.at(a) = false;
    }

    std::vector<long long int> dp(n+1);
    dp[0] = 1;

    for(int i = 0; i < n; i++){
        for(int j = i+1; j <= std::min(n, i+2); j++){
            if(out.at(j)){
                dp[j] += dp[i];
                dp[j] %= mod;
            }
        }
    }

    std::cout << dp[n] << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
const int MAXN=100005;
int n,a[MAXN];
LL sum,b[MAXN];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),sum+=a[i];
	sum/=2;
	for(int i=2;i<=n;i+=2)
		sum-=a[i];
	b[1]=sum;
	for(int i=1;i<=n-1;i++)
		b[i+1]=a[i]-b[i];
	for(int i=1;i<n;i++)
		printf("%lld ",b[i]*2);
	printf("%lld\n",b[n]*2);
}

Measured memory_bytes: 2432
#include <iostream>

using namespace std;

inline int ab(int x) { return (x < 0 ? -x : x); }

int n, k, i, j;
const int maxn = 1e5+5, inf = 0x3f3f3f3f;

int v[maxn], d[maxn];

int main()
{
    cin >> n >> k;
    cin >> v[1];
    for(i = 2; i <= n; i ++) {
        cin >> v[i];
        int mn = inf;
        for(j = max(1, i - k); j <= i-1; j ++) {
            mn = min(mn, d[j] + ab(v[i] - v[j]));
        }
        d[i] = mn;
    }
    cout << d[n] << '\n';
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
numbers = list(map(int,input().split()))
count = 0
for i in range(1,n-1,1):
    if (numbers[i]>=numbers[i-1] and numbers[i]<=numbers[i+1]) or (numbers[i]>=numbers[i+1] and numbers[i]<=numbers[i-1]):
        count += 1

print(count)


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

#define all(v)  begin(v), end(v)
#define endl    '\n';
#define int     long long
#define pii     pair<int, int>
#define sz(x)   (int) x.size()

void test_case() {
    int x;
    cin >> x;
    cout << !x << endl;
}

int32_t main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) { 
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll L, R, D;
    cin >> L >> R >> D;
    ll ans = 0;
    for(ll i=L;i<=R;i++){
        ans += (i%D == 0);
    }
    cout << ans<<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3224
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val L = readLine().split(" ").map(_.toInt)

  def solve() = {
    var ans = 0
    for {
      i <- 0 until n
      j <- i until n
      k <- j until n
    } {
      val list = Seq(L(i), L(j), L(k))
      list.sum
      list.toSet
      val max = Math.max(Math.max(L(i), L(j)), L(k))
      val isTriangle = max < (L(i)+L(j)+L(k)) - max
      val isUnique = L(i) != L(j) && L(i) != L(k) && L(j) != L(k)
      if(isTriangle && isUnique) ans += 1
    }
    ans
  }

  println(solve())

}



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

int main(){
    int W,H,x,y,r;

    cin >> W >> H >> x >> y >> r;

    if (x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H) {
    cout << "Yes" << endl;
    }
    if (x-r < 0 || y-r < 0 || x+r > W||y+r > H) {
    cout << "No" << endl;
    }

    return 0;

    }



Measured memory_bytes: 3120
/**
 *      ABC 56 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 02:25:49
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a, b; cin >> a >> b;
    if (a == 'H'){
        b == 'H' ? cout << 'H' : cout << 'D'; return 0;
    }
    else {
        b == 'H' ? cout << 'D' : cout << 'H'; return 0;
    }
    
}


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

int gcd(int a, int b){
	while(b){
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int p[101], q[101], r[101], b[101];

int func(int x){
	if( x == 0 ) return 1;

	int t = func(r[x]) * q[x];
	int u = func(b[x]) * p[x];
	int g = gcd(t, u);
	int lcm = t / g * u;

	return lcm / q[x] + lcm / p[x];
}

int main(){
	int n;
	while( scanf("%d", &n), n != 0 ){
		bool ref[101] = {};

		for(int i = 1; i <= n; ++i){
			scanf("%d%d%d%d", &q[i], &p[i], &r[i], &b[i]);
			ref[r[i]] = ref[b[i]] = true;
		}
		
		for(int i = 1; i <= n; ++i){
			if( !ref[i] ){
				printf("%d\n", func(i));
				break;
			}
		}
	}
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    string s;
    cin>>s;
    ll A[500001],n=s.size()+1,ans=0;
    rep(i,n) A[i]=-1;
    if(s[0]=='<') A[0]=0;
    if(s[n-2]=='>') A[n-1]=0;
    rep(i,n-1) if(s[i]=='>'&&s[i+1]=='<') A[i+1]=0;
    rep(i,n){
        if(A[i]==0){
            ll k=0;
            for(int j=i;s[j]=='<'&&j<n-1;j++) k++,A[j+1]=max(A[j],k);
            k=0;
            for(int j=i-1;s[j]=='>'&&j>=0;j--) k++,A[j]=max(A[j],k);
        }
    }
    rep(i,n) ans+=A[i];
    cout<<ans;
}

Measured memory_bytes: 4740
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    L = nl()
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j] and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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


Measured memory_bytes: 7848
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		for(long i=m/n; i>=1; i--){
			if(m%i==0){
				System.out.println(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 23764
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy

INF = 10 ** 20


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

def dijkstra(s):
    hq=[(0,s)]
    dist=[INF]*n
    dp=[0]*n
    dp[s]=1
    dist[s]=0
    checked=[0]*n
    while hq:
        min_dist,u=heappop(hq)
        if checked[u]:
            continue
        checked[u]=1
        for v,c in G[u]:
            if dist[u]+c<dist[v]:
                dist[v]=dist[u]+c
                dp[v]=dp[u]
                heappush(hq,(dist[v],v))
            elif dist[u]+c==dist[v]:
                dp[v]+=dp[u]
                dp[v]%=mod
    return dp, dist

n, m = LI()
s, t = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    a,b, d = LI()
    G[a - 1] += [(b - 1, d)]
    G[b - 1] += [(a - 1, d)]

dp1,dist1=dijkstra(s-1)
dp2,dist2=dijkstra(t-1)
total=dist1[t-1]
ans=dp1[t-1]*dp2[s-1]%mod
for i in range(n):
    if dist1[i]==dist2[i]==total/2:
        ans-=pow(dp1[i]*dp2[i]%mod,2,mod)

for j in range(n):
    for k, ci in G[j]:
        if dist1[j]+dist2[k]+ci==total and dist1[j]<total/2 and dist2[k]<total/2:
            ans-=pow(dp1[j]*dp2[k]%mod,2,mod)

print(ans%mod)








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

#define lli long long int
#define endl "\n"
#define debug(n) cout<<n<<endl
#define debug2(a, b) cout<<a<<" "<<b<<endl;
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

lli n;
vector<lli> cola;
vector< vector< vector<lli> > > dp(    3010, vector<vector<lli>> (  3010, vector<lli>(2, -1)  )    );
//lli dp[3010][3010][2];


lli f(lli l, lli r, lli estado) //estado 0-> max, 1-> min
{
    //debug2(l,r);
    lli size = r - l + 1;
    if(size<=0) return 0;
    if(dp[l][r][estado] != -1) return dp[l][r][estado];
    if(estado == 0)
    {
        lli uno = f(l+1, r, !estado) + cola[l] ;
        lli dos = f(l, r-1, !estado) + cola[r];
        return dp[l][r][estado] = max(uno,dos);
    }
    else
    {
        lli uno = f(l+1, r, !estado) - cola[l];
        lli dos = f(l, r-1, !estado) - cola[r];
        return dp[l][r][estado] = min(uno,dos);
    }
    
}





int main()
{
    fastIO();
    //memset(dp, -1, sizeof(dp));
    cin>>n;
    cola.resize(n);
    for(auto &x: cola)
    {
        cin>>x;
    }
    cout<<f(0,n-1,0)<<endl;

    return 0;
}

Measured memory_bytes: 496128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
int32_t main()
{
    fast;
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double w1 = 0.5;
    double pi = 3.14159265358;
    double w2 = 6;
    int t = h * 60 + m;
    double ana = w1 * t ;
    double anb = w2 * t ;
    while (ana > 360) {
        ana -= 360;
    }
    while (anb > 360) {
        anb -= 360;
    }
    double diff = abs(ana - anb);
    double ans = a * a + b * b - 2 * a * b * cos(pi * diff / 180);
    cout << setprecision(15) << sqrt(ans);




}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/*⁽⁽(ી₍₍⁽⁽(ી( ˆεˆ )ʃ)₎₎⁾⁾ʃ)₎₎*/
int main(){
	int N,M,r;
	while(cin >> N >> M){
		if ((N==0) and (M==0)) break;
		cin >> r;

		vector<tuple<int,int,int,int> > R;
		REP(i,r){
			int t,n,m,s;
			cin >> t >> n >> m >> s;
		    tuple<int,int,int,int> Rs(t,n,m,s);
		    R.PB(Rs);
		}
		int q; cin >> q;
		REP(i,q){
			int ans = 0;
			int ts,te,m;
			cin >> ts >> te >> m;
			int prevlog = -1;
			set<int> login;

			REP(j,r){
				tuple<int,int,int,int> Nowc = R[j];
				int& T = get<0>(Nowc);
				int& N = get<1>(Nowc);
				int& S = get<3>(Nowc);
				int& M = get<2>(Nowc);
				if (M != m) continue;
				if (T > te) break;
				if (S == 0){ //logout
					login.erase(N);
					if (login.size() == 0){
						if (T < ts) continue;
						ans += min(T,te) - max(ts,prevlog);
					}
				}else{//login
					if (login.size() == 0){
						prevlog = T;
					}

					login.insert(N);
				}
			}

			if (login.size() > 0){
				if (prevlog == -1) break;
				ans += te - max(ts,prevlog);
			}

			cout << ans << "\n";

		}


	}
    return 0;
}



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

int main() {
  string s;
  cin >> s;
  int ans = 999;
  rep(i, s.length()-2) {
    int num = (s[i] - '0')*100 + (s[i+1] - '0')*10 + s[i+2] - '0';
    ans = min(ans, abs(num - 753));
  }
  cout << ans << endl;
  return 0;
}

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

void b_palace(void) {
	int n, t, a;
	int h[10000];
	cin >> n;
	cin >> t >> a;
	for (int i = 0; i < n; i++) cin >> h[i];

	// h[i] = (t-a)/0.006
	double diff = (t - a) / 0.006;
	double diff_min = 100000.000;
	int min_index = 0;
	for (int i = 0; i < n; i++) {
		double diff_tmp = abs(h[i] - diff);
		if (diff_tmp < diff_min) {
			diff_min = diff_tmp;
			min_index = i;
		}
	}
	cout << min_index + 1 << endl;

}

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

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main()
{
    int h,w,n;
    int c = 0;
    
    cin >> h >> w >> n;
    
    int t = max(h,w);
    
    while(n>0){
        n -= t;
        c++;
    }
    cout << c << endl;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	run := 0
	ans := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T' {
			run++
			ans = max(ans, run)
		} else {
			run = 0
		}
	}

	fmt.Println(ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- 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 <iostream>
#include <vector>
#include <cmath>
using namespace std;

bool isPrime(int n){
	if(n <= 1)return false;
	if(n == 2)return true;
	if(n % 2 == 0)return false;
	int sq = sqrt(n) + 1;
	for(int i=3;i<=sq;i+=2){
		if(n % i == 0)return false;
	}
	return true;
}

int main() {
	int n, p;
	vector< int > factor;
	
	cin >> n;
	cout << n << ":";
	
	if(isPrime(n)){
		factor.push_back(n);
	}else{
		p = 2;
		while(n != 1){
			if(n % p == 0){
				n /= p;
				factor.push_back(p);
				
				if(isPrime(n)){
					factor.push_back(n);
					break;
				}
			}else{
				++p;
			}
		}		
	}
	

	
	for(int i=0;i<factor.size();++i){
		cout << " " << factor[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

   int k;
   cin>>k;
   int ans=0;
   for(int i=1;i<=k;i++)
   {
	   for(int j=1;j<=k;j++)
	   {
		   for(int l=1;l<=k;l++)
		   {
			   ans+=gcd(i,gcd(j,l));
		   }
	   }
   }
   cout<<ans;
}


Measured memory_bytes: 3652
A,B,C = map(int,input().split())
ans = 0
flag = 0
while flag == 0 :
    if (A == B == C) and (A % 2) == 0 :
        ans = -1
        flag = 1
        break
    if (A%2 != 0) or (B%2 != 0) or (C%2 != 0) :
        flag = 1
        break
    else :
        ans += 1
        p = A//2
        q = B//2
        r = C//2
        A = (q+r)
        B = (r+p)
        C = (p+q)
print(ans)


Measured memory_bytes: 3064