akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if(S.at(i) == '+') ans++;
    else ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int N; cin >> N;
	V v(N); input(v);
	int sum = 0;
	rep(i, N) sum += v[i];
	int S = N * (N + 1) / 2;
	int K = sum / S;
	bool ok = sum % S == 0;
	int ts = 0;
	rep(i, N) {
		int sa = v[i] - v[(i + 1) % N];
		if ((sa + K) % N) ok = false;
		int t = (sa + K) / N;
		if (t < 0) ok = false;
		ts += t;
	}
	cout << (ok && ts == K ? "YES" : "NO") << endl;
	system("pause");
}

Measured memory_bytes: 1272
def main():
    from collections import Counter
    n = int(input())
    As = list(map(int,input().split(" ")))
    
    cnts = Counter()
    dp = [0]*n
    cnts[As[0]+1]+=1
    for i in range(1,n):
        dp[i] =dp[i-1] + cnts.get(i+1-As[i],0)
        cnts[As[i]+i+1]+=1
    print(dp[n-1])
main()

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

typedef long long ll;
const int INF = 1e9+5;

int main(){
	int n, k;
	scanf("%d", &n);
	scanf("%d", &k);
	vector<	int> dp(n + 1, INF);
	vector<int> hs(n + 1);
	for(int i = 1; i <= n; i++){
		scanf("%d", &hs[i]);
	}
	
	dp[1] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= i + k; j++){
			if(j <= n){
				dp[j] = min(dp[j], dp[i] + abs(hs[i] - hs[j]));  				
			}
		}
	}
	
	printf("%d\n", dp[n]); 
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int a, b; cin >> a >> b;
	int i;

	if (b == 1)
	{
		cout << 0 << endl;
	}
	else
	{
		for (i = 1; i < 100; i++)
		{
			if (a + (i - 1) * (a - 1) >= b) break;
		}
		cout << i << endl;
	}
}

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

#define MAX_N 1000
#define MAX_E 10000

int N,E;
int par[MAX_N+1],rank[MAX_N+1];
 
struct edge{
    int from,to,cost;
};
 
bool cmp(const edge& e1,const edge& e2){
    return e1.cost < e2.cost;
}
 
void init(int n){
    for(int i = 0 ; i < n ; i++){
	par[i] = i;
	rank[i] = 0;
    }
}
 
int find(int x){
    if (par[x] == x) {
	return x;
    } else {
	return par[x] = find(par[x]);
    }
}
 
void unite(int x,int y){
    x = find(x);
    y = find(y);
 
    if(x == y) return;
    if (rank[x] < rank[y]) {
	par[x] = y;
    } else {
	par[y] = x;
	if (rank[x] == rank[y]) {
	    rank[x]++;
	}
    }
}
 
bool same(int x,int y){
    return find(x) == find(y);
}
 
edge es[MAX_E+1];
 
void kruskal(vector<int> &v){
    sort(es ,es + E ,cmp);
    init(N);
 
    for(int i = 0 ; i < E ; i++){
	edge e = es[i];
	if (!same(e.from,e.to)) {
	    unite(e.from,e.to);
	    v.push_back(e.cost);
	}
    }
 
}
 
 
int main(){
    int a,b,c;
    while(cin >> N >> E , N | E){
	for(int i = 0 ; i < E ; i++){
	    cin >> a >> b >> c;
  
	    es[i].from = --a;
	    es[i].to = --b;
	    es[i].cost = c;
	}
 
	vector<int> v;
	kruskal(v);
 
	int size = (int)v.size();
	cout << v[size/2] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1356
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
char s[10];
int main()
{
	scanf("%s",s+1);
	if (s[3]==s[4] && s[5]==s[6]) printf("Yes\n");else printf("No\n");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";


int main(){
  cout << fixed << setprecision(10);
  double n, x, g;
  cin >> n;
  std::priority_queue<double, std::vector<double>, std::greater<double>> v;
  
  rep(i, 0, n){
    cin >> x;
    v.push(x);
  }
  
  rep(i, 0, n-1){
    g = v.top();
    v.pop();
    g += v.top();
    v.pop();
    v.push(g / 2);
  }
  
  print(v.top());
  
  return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            Set<Integer> set = new HashSet<Integer>();
            set.add(a);
            set.add(b);
            set.add(c);
            System.out.println(set.size());
        }
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", min(c, b/a));
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  int ans1 = 0, ans2 = 0;
  REP(i, N)
  {
    if (i % 2 == 0)
    {
      if (S[i] == '0')
        ans1++;
      else
        ans2++;
    }
    else
    {
      if (S[i] == '1')
        ans1++;
      else
        ans2++;
    }
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*

*/

ll n,m,root,dp[100010],par[100010]={};
vector<ll> v[100010],rev[100010];

ll f(ll p){
	if(dp[p]!=-1)return dp[p];
	ll ans=0;
	for(ll q : v[p]){
		ans = max(ans,f(q));
	}
	return dp[p]=ans+1;
}

int main(void){
	cin>>n>>m;
	rep(i,n-1+m){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		rev[b].push_back(a);
	}
	//
	reg(i,1,n)dp[i]=-1;
	//
	reg(i,1,n){
		if(rev[i].size()==0){
			root=i;
			break;
		}
	}
	f(root);
	//
	queue<ll> Q;
	reg(i,1,n){
		if(v[i].size()==0)Q.push(i);
	}
	while(!Q.empty()){
		ll p = Q.front();Q.pop();
		if(p==root)continue;
		if(par[p]!=0)continue;
		ll max_id=0;
		rep(i,rev[p].size()){
			if(dp[rev[p][max_id]]>dp[rev[p][i]])max_id=i;
		}
		par[p]=rev[p][max_id];
		Q.push(rev[p][max_id]);
	}
	//
	par[root]=0;
	reg(i,1,n)cout<<par[i]<<endl;
	return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std ;
char c;bool fl1=0,fl2=0;

int main(){
    while(cin >> c){
        if(c=='C'&&fl1==0)
            fl1=1;
        if(fl1==1&&c=='F')
            fl2=1;}
    if(fl1&&fl2)
        cout << "Yes" << endl ;
    else
        cout << "No" << endl ;
    return 0 ;
}

Measured memory_bytes: 256
a,b,k = list(map(int, input().split()))
for i in range(k):
  if i%2 == 0:
    if a%2==1: a-=1
    b += a//2
    a //= 2
  else:
    if b%2==1: b-=1
    a += b//2
    b //= 2
print(a, b)

Measured memory_bytes: 3060
N, L = map(int, input().split())
a = []
b = []

#ringo goto aji dasu
for i in range(N):
  a.append(L+ i+1 -1)

if max(a) < 0:
  print(sum(a)-max(a))
elif max(a) >= 0 and min(a) <= 0:
  print(sum(a))
else:
  print(sum(a)-min(a))

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

int main(){
  int addtional, regulation, T;
  cin >> addtional >> regulation >> T;

  string ans= (T <= regulation           ) ? "delicious"
             :(T <= regulation+ addtional) ? "safe"
                                           : "dangerous";
  cout << ans << endl;
}


Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let ds = stdin.ReadLine().Split() |> Array.map int
let modu = 998244353L

let sPown (x:int64) y = [1..y] |>  Seq.fold (fun total _ -> total * x % modu) 1L

if ds.[0]<>0 then
    0L
else
    let countbyArray = ds.[1..] |> Array.countBy(fun x -> x) |> Array.sort
    if countbyArray.Length <> (countbyArray|> Array.last |> fst) then
        0L
    else
    countbyArray
    |> Seq.map (snd >> int64) |> Seq.fold (fun (before,total) x ->
        (x, total * (sPown before (int x)) % modu )) (1L,1L)
    |> snd 
|> stdout.WriteLine

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int ln2 = 0;
vector<vector<int>> adj;
vector<vector<ll>> par;
vector<ll> rnk;
 
void calc_parent(int n) { rep(i,ln2) rep(j,n) if (rnk[j]>=powl(2,i+1)) par[j][i+1] = par[par[j][i]][i]; }
void calc_rnk(int n=0, int p=-1) { if (p==-1) rnk[n]=0; for (auto x: adj[n]) { if (x!=p) { rnk[x] = rnk[n]+1; par[x][0] = n; calc_rnk(x,n); } } }
void init_lca() { int n=adj.size();  while(n>=(1<<ln2)) ln2++; par.resize(n,vector<ll>(ln2,-1)); rnk.resize(n); calc_rnk(); calc_parent(n); }
bool large(int u, int v) { if (rnk[u]<rnk[v]) swap(u,v); int diff = rnk[u]-rnk[v]; int b_pos = 0; while(diff>=(1ull<<b_pos)) { if (diff&(1ull<<b_pos)) u = par[u][b_pos]; b_pos++; } return u>v; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  int N; cin >> N;
  ll x[N]; rep(i,N) cin >> x[i];
  ll L; cin >> L;
  adj.resize(N);
  repr(i,1,N) {
    auto par = lower_bound(x,x+N,x[i]-L);
    adj[par-x].push_back(i);
    // cout << x[i] << " " << parp-x << endl;
  }

  init_lca();
  // debug(all(rnk));

  int Q; cin >> Q;
  rep(i,Q) {
    int a, b; cin >> a >> b; a--; b--;
    if (a<b) swap(a,b); 
    int result = large(a,b) ? rnk[a]-rnk[b]+1 : rnk[a]-rnk[b];
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 30464
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

vector<vector<ll>> dp;

int main(){
  int n, m, R;
  cin >> n >> m >> R;
  dp.assign(n, vector<ll>(n, LINF));
  vector<int> r(R);
  for(int i = 0; i < R; ++i){
  	cin >> r[i];
  	--r[i];
  }
  for(int i = 0; i < m; ++i){
  	int a, b;
  	ll c;
  	cin >> a >> b >> c;
  	--a;
  	--b;
  	dp[a][b] = c;
  	dp[b][a] = c;
  }

  for(int k = 0; k < n; ++k){
  	for(int i = 0; i < n; ++i){
  		for(int j = 0; j < n; ++j){
  			dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  		}
  	}
  }

  sort(r.begin(), r.end());
  ll ans = LINF;
  do{
  	ll tmp = 0;
  	for(int i = 0; i < R - 1; ++i){
  		tmp += dp[r[i]][r[i + 1]];
  	}
  	ans = min(ans, tmp);
  }while(next_permutation(r.begin(), r.end()));

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=70005;

int main() {
ll a,b,c,d;
cin>>a>>b>>c>>d;
if(b<=0)
{
	    if(c>=0)
	   {
	   	cout<<b*c<<endl;
		   }
	  	 else   cout<<a*c<<endl;	
}
else if(a>=0)
{
	if(d<=0) cout<<a*d<<endl;
	else cout<<b*d<<endl;
}
else
{
	if(d<=0)cout<<a*c<<endl;
	else if(c>=0)cout<<b*d<<endl;
	else cout<<max(a*c,b*d)<<endl;

}
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int n;
char bef[36], af[36];
int m;
char c;

int main(void)
{
	int i;
	
	while(1) {
		
		scanf( "%d", &n );
		
		if ( n == 0 ) break;
		
		for( i=0; i<n; i++ ) {
			scanf( " %c %c", &bef[i], &af[i] );
		}
		
		scanf( "%d", &m );
		
		while ( m-- ) {
			scanf( " %c", &c );
			
			for	( i=0; i<n; i++ ) {
				if ( c == bef[i] ) {
					c = af[i];
					break;
				}
			}
			
			putchar(c);
		}
		putchar( '\n' );
		
	}
	
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,q;
	string s;
	cin>>n>>s>>q;
	set<int> pos[30];
	for (int i = 0; i < n; ++i)
	{
		pos[s[i]-'a'].insert(i);
	}
	for (int i = 0; i < q; ++i)
	{
		int a;
		cin>>a;
		if (a==1)
		{
			int b;
			char c;
			cin>>b>>c;
			--b;
			pos[s[b]-'a'].erase(b);
			s[b]=c;
			pos[s[b]-'a'].insert(b);
		}
		else
		{
			int b,c;
			cin>>b>>c;
			--b;
			--c;
			int ans=0;
			for (int j = 0; j < 30; ++j)
			{
				if (pos[j].lower_bound(b)!=pos[j].upper_bound(c))
				{
					++ans;
				}
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}


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

using namespace std;

int main(int argc, char* argv[])
{
  vector<string> str(3);
  for (int i = 0; i < 3; i++) {
    cin >> str[i];
  }

  cout << str[0][0] << str[1][1] << str[2][2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=2e5+11;
const int M=1e5+1;
const int inf=2e9+1;
const ld EPS=1e-6;
const ll INF=1e18;
const ll mod=/*998244353*/1e9+7;
const int dx[8]={0,0,-1,1,-1,1,1,-1};
const int dy[8]={-1,1,0,0,1,-1,1,-1};

vector<int>g[N];
int used[N];
int sz;

void dfs(int v){
  used[v]=1;
  sz++;
  for(int to:g[v]){
    if(!used[to]){
      dfs(to);
    }
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    int u,v;
    cin>>u>>v;
    g[u].pb(v);
    g[v].pb(u);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(!used[i]){
      sz=0;
      dfs(i);
      ans=max(ans,sz);
    }
  }
  cout<<ans;
}


Measured memory_bytes: 21620
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const string YES = "Yes";
const string NO = "No";

void solve(ll A, ll B, ll C, ll K) {
  int cnt(0);
  while (B <= A) {
    B *= 2;
    cnt++;
  }
  while (C <= B) {
    C *= 2;
    cnt++;
  }
  cout << (cnt <= K ? YES : NO) << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  ll K;
  cin >> K;

  solve(A, B, C, K);

  return 0;
}


Measured memory_bytes: 3668
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    if(n%k != 0){
      System.out.println(1);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
vector<int> v[100100];
vector<int> e(100100); //0:uncolored 1:white -1:black
bool flag;
P dfs(int color, int node)
{ //P.first:1 P.decond:-1
    P res = P(0, 0);
    for (auto i : v[node])
    {
        if (e[i] == 0)
        {
            e[i] = -color;
            P p = dfs(-color, i);
            res.first += p.first;
            res.second += p.second;
        }
        else if (e[i] == color)
        {
            flag = true;
        }
    }
    if (color == 1)
    {
        res.first++;
    }
    else
    {
        res.second++;
    }
    return res;
}
int dp[100100];
int main()
{
    ll n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<P> ans;
    for (int i = 1; i <= n; i++)
    {
        if (e[i] == 0)
        {
            e[i] = 1;
            P p = dfs(1, i);
            ans.push_back(p);
        }
    }
    int mx = 0;
    int mn = 0;
    dp[0] = 1;
    for (auto i : ans)
    {
        int tmn = dp[mn] + i.first;
        int tmx = tmn;
        for (int j = n; j >= 0; j--)
        {
            if (dp[j])
            {
                dp[j] = 0;
                dp[j + i.first] = 1;
                dp[j + i.second] = 1;
                tmx = max(tmx, dp[j + i.first]);
                tmx = max(tmx, dp[j + i.second]);
                tmn = min(tmn, dp[j + i.first]);
                tmn = min(tmn, dp[j + i.second]);
            }
        }
        mx = tmx;
        mn = tmn;
    }
    if (flag)
    {
        cout << -1 << endl;
    }
    else
    {
        ll ans = 0;
        for(ll i = 1;i<=n;i++){
            if(dp[i]){
                ans = max(ans,i*(n-i));
            }
        }
        cout << ans - m << endl;
    }
    return 0;
}


Measured memory_bytes: 9540
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



signed main() {
	int N; cin >> N;
	print(180 * (N - 2));
}


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

int main(){
	string s;
	int n;
	map<string,vector<int> > word;
	while(cin>>s>>n){
		word[s].push_back(n);
	}
	for(map<string,vector<int> >::iterator it=word.begin();it!=word.end();++it){
		vector<int> &v=it->second;
		cout<<it->first<<endl;
		sort(v.begin(),v.end());
		cout<<v[0];
		for(int i=1;i<v.size();i++)cout<<' '<<v[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, n;
    cin >> h >> n;
    int sum = 0;
    rep(i, n){
        int tmp;
        cin >> tmp;
        sum += tmp;
    };
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()

{

   int a,b,c,d;

   cin >>a;

   cin >>b;

   c=(a*b);

   d=(c%2);

   if (d==0)

   {

     cout << "Even"<< endl;

   }

   else 

   {

     cout << "Odd"<< endl;

   }

   return 0;

}

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

const string YES = "Yes";
const string NO = "No";

long long digit_sum(long long n)
{
    int a = 0;
    int sum = 0;
    while (n)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

void solve(long long N)
{
    if (N % digit_sum(N) == 0)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(void)
{
  int N, T, A;
  cin >> N >> T >> A;
  vector< int > H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  int ans = -1;
  int ans_temp_diff = 1000000;
  for (int i = 0; i < N; i++) {
    int temp_diff = abs(T * 1000 - H[i] * 6 - A * 1000);
    if (temp_diff < ans_temp_diff) {
      ans = i;
      ans_temp_diff = temp_diff;
    }
  }
  
  cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) (x)*(x)
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(c-a-b>0&&4*a*b<sqr(c-a-b))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int mul = 1;
    f(m) {
        mul *= 2;
    }
    ll tot = n * 100 + m * 1800;
    cout << tot * mul << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a, b, x;
        while(true){
            a = sc.nextInt();
            b = sc.nextInt();
            
            if(a == 0 && b == 0) break;
            if(b < a){
                x = a;
                a = b;
                b = x;
            }
            System.out.println(a +" "+ b); 
        }
        
    }
}


Measured memory_bytes: 34496
#include <bits/stdc++.h>
using namespace std;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
const int INF = 1e9;

int main() {
	int h, w, k, x1, y1, x2, y2; cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;
	--x1, --y1, --x2, --y2;
	char MP[h][w] = {};
	int dis[h][w] = {};
	for (int i = 0; i < h; i++) 
		for (int j = 0; j < w; j++)
			cin >> MP[i][j], dis[i][j] = INF;
	queue<pair<int, int>> que;
	dis[x1][y1] = 0;
	que.push({x1, y1});
	while (!que.empty()) {
		int x = que.front().first;
		int y = que.front().second;
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = x, ny = y;
			int nd = dis[x][y] + 1;
			for (int j = 1; j <= k; j++) {
				nx += dir[i][0];
				ny += dir[i][1];
				if (nx < 0 or ny < 0 or nx >= h or ny >= w or MP[nx][ny] == '@' or dis[nx][ny] < nd)
					break;
				if (dis[nx][ny] > nd) {
					dis[nx][ny] = nd;
					que.push({nx, ny});
				}
			}
		}
	}
	int ans = dis[x2][y2];
	cout << (ans == INF ? -1 : ans);
}

Measured memory_bytes: 8968
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

const int MAXN = 200000;

struct edge {
    int v;
    ll w;
    edge() {}
    edge(int v, ll w) : v(v), w(w) {};
};

vector<ll> dijkstra(int n, vector<vector<edge> >& G, int s) {
    vector<ll> d(n, LLONG_MAX/10); d[s] = 0;
    priority_queue<pair<ll, int> > que;
    que.push(make_pair(0ll, s));
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int u = p.second;
        ll dist = -p.first;
        if (dist > d[u]) continue;
        for (edge e : G[u]) {
            if (d[e.v] > d[u]+e.w) {
                d[e.v] = d[u] + e.w;
                que.push(make_pair(-d[e.v], e.v));
            }
        }
    }
    return d;
}

bool visit[MAXN];
int C[MAXN];
int dfs(int v, const vector<vector<edge> >& G) {
	visit[v] = true;
	int ans = 1;
	for (edge e : G[v]) {
		int u = e.v;
		if (!C[u] || visit[u]) continue;
		ans += dfs(u, G);
	}
	return ans;
}

int main() {
	int N;
	cin >> N;
	vector<vector<edge>> G(N);
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].emplace_back(b, 1);
		G[b].emplace_back(a, 1);
	}
	auto d = dijkstra(N, G, 0);
	vector<int> path;
	int now = N-1;
	while (now != 0) {
		path.push_back(now);
		for (edge e : G[now]) {
			int v = e.v;
			if (d[v]+1 == d[now]) {
				now = v;
				break;
			}
		}
	}
	path.push_back(0);
	reverse(path.begin(), path.end());
	memset(C, -1, sizeof(C));
	int size = path.size();
	for (int i = 0; i < (size+1)/2; ++i) {
		C[path[i]] = 1;
	}
	for (int i = (size+1)/2; i < size; ++i) {
		C[path[i]] = 0;
	}
	int black = dfs(0, G);
	if (black > N-black) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}


Measured memory_bytes: 11772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 5003
#define MAXM 200
#define MAXV 1000000009

int n, ans;
map<int, int> mp;

int main()
{
    cin >> n;
    REP(i, 0, n){
        int a;
        cin >> a;
        if(mp[a])mp[a]--;
        else mp[a]++;
    }
    map<int, int>::iterator ite;
    for(ite = mp.begin(); ite != mp.end(); ++ite){
        ans += ite->se;
    }
    printf("%d\n", ans);

    return 0;
}
/*

bcdea
4

*/















Measured memory_bytes: 4992
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int MOD = 1000000007;
const int MAX_N = 1000000;
const int MAX_Ai = 1000000;


int A[MAX_N];
int cnt[MAX_Ai+1];
int solve(int N){
	FOR(i,N)	++cnt[A[i]];

	for (int a = 1; a <= MAX_Ai; ++a){
		for (int ma = 2*a; ma <= MAX_Ai; ma += a){
			cnt[ma] += cnt[a];
		}
	}

	int ret = 0;
	FOR(i,N) if(cnt[A[i]] == 1)	++ret;

	return ret;
}

int main(){
	int N;	cin >> N;
	FOR(i,N)	cin >> A[i];

    int ans = solve(N);
    printf("%d\n",ans);
}





Measured memory_bytes: 8416
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define MAP map<int,int>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e17;

void ANS(bool flag){
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Ans(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void ans(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}



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

	int sum = 0;
	bool flag = false;
	if (N[0] != '1'){
		for(int i = 1; i < N.size(); i++) if (N[i] != '9') flag = true;
		if(flag){
			sum += int(N[0] - '0') - 1;
			for (int i = 1; i < N.size(); i++) sum += 9;
		}
		else{
			sum += int(N[0] - '0');
			for (int i = 1; i < N.size(); i++) sum += 9;
		}
	}
	else{
		for (int i = 1; i < N.size(); i++) if (N[i] != '9') flag = true;
		if (flag) {
			for (int i = 1; i < N.size(); i++) sum += 9;
		}
		else {
			sum += int(N[0] - '0');
			for (int i = 1; i < N.size(); i++) sum += 9;
		}
	}
	cout << sum << endl;
	//cin >> N;







	return 0;
}


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

//ここで関数を定義

int my_abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main() {
    int N,L;
    cin >> N >> L;
    int apple = 0;
    int aaple = 0;
    int small = 999;
    int perfectAPie = 0;
    int oneApple = 0;
  	int aapple = 0;

    for(int i=1;i<N+1;i++){
        apple = i + L - 1;
        perfectAPie = apple + perfectAPie;
        aapple = my_abs(apple);
        if(small >= aapple){
            small = aapple;
            oneApple = apple;
        }
        apple = 0;
    }

    cout << perfectAPie - oneApple << endl;





}

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

int comparingDice(std::vector<std::vector<int>>& dice, int numberOfDice, int j, int k);
void goNorth(std::vector<std::vector<int>>& dice, int k);
void goEast(std::vector<std::vector<int>>& dice, int k);

int main(){


	std::vector<std::vector<int>> dice;
	

	int numberOfDice;
	std::cin >> numberOfDice;

	std::vector<int> a = { 0, 0, 0, 0, 0, 0 };

	for (int i = 0; i < numberOfDice; ++i){
			dice.emplace_back(a);
		}

	for (int i = 0; i < numberOfDice; ++i){
		for (int j = 0; j < 6; ++j){
			std::cin >> dice[i][j];
		}
	}

	
	
	bool isSame = false;

	for (int j = 0; j < numberOfDice; ++j){
		for (int k = j + 1; k < numberOfDice; ++k){

			int ans;
			ans = comparingDice(dice, numberOfDice, j, k);


			if (ans == 1){
				isSame = true;
				break;

			}
			else{
				for (int i = 0; i < 77; ++i){
					char command[] = "NESNESNESNESENESNESNESNESNNESNESNESNESNNESNESNESNESNNESNESNESNESENESNESNESNES";
					if (command[i] == 'N'){
						goNorth(dice, k);
					}
					else if (command[i] == 'E'){
						goEast(dice, k);
					}
					else if (command[i] == 'S'){
						for (int j = 0; j < 3; ++j){
							goNorth(dice, k);
						}
					}
					ans = comparingDice(dice, numberOfDice, j, k);
					if (ans == 1){
						isSame = true;
						break;
					}
				}
			}
		}
	}




	if (isSame == true){
		std::cout << "No" << std::endl;
	}
	else{
		std::cout << "Yes" << std::endl;
	}

	return 0;
}



int comparingDice(std::vector<std::vector<int>>& dice, int numberOfDice, int j, int k){

	if (dice[j][0] == dice[k][0] && dice[j][1] == dice[k][1]){

		if (dice[j][2] == dice[k][2] && dice[j][3] == dice[k][3] && dice[j][4] == dice[k][4] && dice[j][5] == dice[k][5]){
			return 1;
		}
		else{
			return 0;
		}
	}
	else{
		return 0;
	}

}

void goNorth(std::vector<std::vector<int>>& dice, int k){
	int tmp = dice[k][0];
	dice[k][0] = dice[k][1];
	dice[k][1] = dice[k][5];
	dice[k][5] = dice[k][4];
	dice[k][4] = tmp;
}
void goEast(std::vector<std::vector<int>>& dice, int k){
	int tmp = dice[k][0];
	dice[k][0] = dice[k][3];
	dice[k][3] = dice[k][5];
	dice[k][5] = dice[k][2];
	dice[k][2] = tmp;
}


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

using namespace std;

const int N = 510;
int h, w;
char p[N][N], b[N][N], r[N][N];

int main() {
    scanf("%d %d", &h, &w);
    for (int i = 0; i < h; i++) {
        scanf("%s", p[i]);
    }

    for (int i = 0; i < h; i++) {
        fill_n(b[i], w, '.');
        fill_n(r[i], w, '.');
        b[i][0] = '#';
        r[i][w - 1] = '#';
        if (i % 2 == 0) {
            fill_n(b[i], w - 1, '#');
        } else {
            fill_n(r[i] + 1, w - 1, '#');
        }
        for (int j = 0; j < w; j++) {
            if (p[i][j] == '#') {
                b[i][j] = r[i][j] = '#';
            }
        }
    }

    for (int i = 0; i < h; i++) printf("%s\n", b[i]);
    printf("\n");
    for (int i = 0; i < h; i++) printf("%s\n", r[i]);
    return 0;
}

Measured memory_bytes: 1536
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  string s;
  char p[H][W];
  for(int i=0;i<H;i++){
    cin >> s;
    for(int j=0;j<W;j++){
      p[i][j] = s[j];
    }
  }

  int L[H][W];
  int R[H][W];
  int U[H][W];
  int D[H][W];

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j == 0){
        if(p[i][j] == '.') L[i][j] = 1;
        else L[i][j] = 0;

        if(p[i][W-1-j] == '.') R[i][W-1-j] = 1;
        else R[i][W-1-j] = 0;
      }
      else{
        if(p[i][j] == '.') L[i][j] = L[i][j-1] + 1;
        else L[i][j] = 0;

        if(p[i][W-1-j] == '.') R[i][W-1-j] = R[i][W-j] + 1;
        else R[i][W-1-j] = 0;
      }

      if(i == 0){
        if(p[i][j] == '.') U[i][j] = 1;
        else U[i][j] = 0;

        if(p[H-1-i][j] == '.') D[H-1-i][j] = 1;
        else D[H-1-i][j] = 0;
      }
      else{
        if(p[i][j] == '.') U[i][j] = U[i-1][j] + 1;
        else U[i][j] = 0;

        if(p[H-1-i][j] == '.') D[H-1-i][j] = D[H-i][j] + 1;
        else D[H-1-i][j] = 0;
      }

    }
  }


  int count = 3;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      count = max(count,L[i][j]+R[i][j]+U[i][j]+D[i][j]);
    }
  }

  cout << count - 3 << endl;

  return 0;
}

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

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int ms = 1005;
const int inf = 0x3f3f3f3f;

int arr[ms][ms];

main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  int x = 0, y = 0;
  while(a > 0) {
    for(int i = y; i < b+y; i++) {
      arr[i][x] = 0;
      arr[i][x+1] = 1;
    }
    for(int i = b+y; i < h; i++) {
      arr[i][x] = 1;
      arr[i][x+1] = 0;
    }
    a--;
    x += 2;
  }
  while(b > 0) {
    for(int i = x; i < a+x; i++) {
      arr[y][i] = 0;
      arr[y+1][i] = 1;
    }
    for(int i = a+x; i < w; i++) {
      arr[y][i] = 1;
      arr[y+1][i] = 0;
    }
    b--;
    y += 2;
  }
  for(int i = y; i < h; i++) {
    for(int j = x; j < w; j++) {
      arr[i][j] = 0;
    }
  }
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cout << arr[i][j];
    }
    cout << '\n';
  }
}

Measured memory_bytes: 5120
import math
n = int(input())
ans = 9999999999999
for i in range(1, math.ceil(math.sqrt(n+1))):
    x1 = i
    x2 = n // x1
    if x1 * x2 == n and x1 + x2 < ans:
        ans = x1-1 + x2 -1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    if(n%2==1){
        vector<ll> dp1(n/2+1), dp2(n/2+1);
        dp1[0]=0;
        dp2[0]=0;
        ll sum = a[0];
        for(int i=1; i<=n/2; i++){
            dp1[i] = a[i*2]+max(dp1[i-1],dp2[i-1]);
            dp2[i] = max(sum, a[i*2-1]+dp2[i-1]);
            sum+=a[2*i];
        }
        cout<<max(dp1[n/2],dp2[n/2])<<endl;
    }else{
        ll ans = -INF;
        vector<ll> sum1(n/2+1,0),sum2(n/2+1,0);
        for(int i=0; i<n/2; i++){
            sum1[i+1]=sum1[i]+a[2*i];
            sum2[i+1]=sum2[i]+a[2*i+1];
        }
        for(int i=0; i<=n/2; i++){
            ll a = sum1[i]+(sum2[n/2]-sum2[i]);
            ans = max(a,ans);
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 6376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
    	int a = ni();
    	int b = ni();

    	if (a<=0 && b>=0) {
    		out.println("Zero");
    	} else if (b<0) {
    		if ((b-a+1)%2 == 0) {
    			out.println("Positive");
    		} else {
    			out.println("Negative");
    		}
    	} else {
    		out.println("Positive");
    	}
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


Measured memory_bytes: 8020
n = input()
x = input().split()
y = input().split()

h = (int(x[0])-int(x[1]))/0.006

lag = 1000000
rec = 0
for i in y:
    if lag > abs(int(i)-h):
        lag = abs(int(i)-h)
        rec = i

num = y.index(rec)
print(int(num)+1)

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

//macro
#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, n, m) for(int i = m; i < n; ++i)
#define LL long long

using namespace std;

typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(){
        int n;
        int a[1001];

        cin >> n;
        int max = 0, min = 1000;
        REP(i, n){
        int x;
        cin >> x;

        if(max < x){ max = x;}
        if(min > x){ min = x;}

        }

        cout << max - min << endl;

        return 0;
}


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

int main()
{
    int h, a, c = 0;
    scanf("%d %d", &h, &a);
    while (h > 0)
    {
        h = h - a;
        c++;
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(a) for a in input().split()]

A.sort(reverse=True)
x = 0
y = 0
prev = 0
cnt = 0
for e in A:
    if e == prev:
        cnt += 1
        if x == 0:
            x = e
        elif e != x or cnt >= 4:
            y = e
            break
    else:
        cnt = 0
    prev = e

print(x*y)

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 998244353; //1e9+7;
const int MAXN = 1e6+1;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,m;
    cin >> n >> m;
    cout << (n*(n-1)/2 + m*(m-1)/2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}


int main(){
    ll N;
    cin>>N;
    vl vec(N);
    map<int,int> a;
    rep(i,N){
        cin>>vec.at(i);
        a[vec.at(i)]++;
    }
    ll ans=0;
        for(auto p: a){
            ll b=p.second;
            ans+=nCr(b,2);
        }
        rep(i,N){
            cout<<ans-a[vec.at(i)]+1<<endl;
        }
    }


Measured memory_bytes: 9088
def main():
    n = int(input())
    G = {}
    for i in range(n):
        G[i+1] = []
    for _ in range(n-1):
        a,b,c = map(int,input().split())
        G[a] += [[b,c]]
        G[b] += [[a,c]]
    q,k = map(int,input().split())
    dist = [-1]*n
    dist[k-1] = 0
    que = [k]
    while len(que) > 0:
        s = que.pop(0)
        for [nv,c] in G[s]:
            if dist[nv-1] != -1:
                continue
            dist[nv-1] = dist[s-1]+c
            que.append(nv)
    for _ in range(q):
        x,y = map(int,input().split())
        print(dist[x-1]+dist[y-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 57524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr int mod = 1000000007;
constexpr int inf = 1e9;
string s;
int main(){
	cin>>s;
	if(s == "ABC")cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	
	return 0;
}


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

int main (void) {
    int i;
    char buf[1001], *ch;
    const char *words[] = {
        "apple",
        "peach"
    };

    while (gets(buf) != NULL) {
        ch = buf;
        while (*ch != '\0') {
            for (i = 0; i < 2; i++) {
                if (strncmp(ch, words[i], 5) == 0) {
                    printf("%s", words[i^1]);
                    ch += 5;
                    break;
                }
            }
            if (i == 2) {
                putc(*ch, stdout);
                ch++;
            }
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 524
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

n = ni()
nn = n
mn = 10**12
nums = [1]

i=2
while i<=math.ceil(math.sqrt(n)+1):
  if n%i==0:
    nums.append(i)
  i+=1

for num in nums:
  other = nn//num
  mn = min(mn, num+other-2)

print(mn)

Measured memory_bytes: 40428
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

signed main() {
	IOS;	
	int X,A,B;
	cin>>X;
	for(int i=-2000;i<=2000;i++){
		for(int j=-2000;j<=2000;j++){
			if(i>j && X%(i-j)==0){
				if(i*i*i*i*i-j*j*j*j*j==X){
					A=i;
					B=j;
					break;
				}
				
			}
		}
	}
	cout<<A<<" "<<B<<endl;
	return 0;
				

}


Measured memory_bytes: 3636
// 0143
#include <iostream>
using namespace std;

bool cross_p(int x1, int y1, int x2, int y2, int xp, int yp){
	if((x2-x1)*(yp-y1) < (y2-y1)*(xp-x1))
		return true;
	else
		return false;
}

int main(){

	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		int x1, y1, x2, y2, x3, y3, xk, yk, xs, ys;
		bool altair, vega;

		cin>>x1>>y1>>x2>>y2>>x3>>y3>>xk>>yk>>xs>>ys;

		if((cross_p(x1, y1, x2, y2, xk, yk) == cross_p(x2, y2, x3, y3, xk, yk)) && (cross_p(x2, y2, x3, y3, xk, yk) == cross_p(x3, y3, x1, y1, xk, yk)))
			altair = true;
		else
			altair = false;

		if((cross_p(x1, y1, x2, y2, xs, ys) == cross_p(x2, y2, x3, y3, xs, ys)) && (cross_p(x2, y2, x3, y3, xs, ys) == cross_p(x3, y3, x1, y1, xs, ys)))
			vega = true;
		else
			vega = false;

		if(altair != vega)
			cout<<"OK"<<endl;
		else
			cout<<"NG"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1152