akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

int W, BIT[200001] = {};

void add_BIT(int i, int k)
{
	while (i <= W) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(A - 1);
		if (sum_BIT(B) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		L = A;
		R = B++;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(M) > tmp) R = M;
			else L = M + 1;
		}
		
		left[B] = left[L];
		right[left[L]] = B;
		if (s[B] < 0) add_BIT(B, 1);
		for (j = L; j < B; j = right[j]) {
			s[B] = (s[j] > s[B])? s[j]: s[B];
			s[j] = -1;
			add_BIT(j, -1);
		}
		if (j != B) {
			left[j] = B;
			right[B] = j;
		}
		if (B <= W) {
			d.key = B - s[B];
			d.id = B;
			push(d, &h);
		}
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6596
S = gets.split("")
flag = false
flag = true if S[0] == S[1] && S[2] == S[3] && S[0] != S[2]
flag = true if S[0] == S[2] && S[1] == S[3] && S[0] != S[1]
flag = true if S[0] == S[3] && S[1] == S[2] && S[0] != S[1]

if flag
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n;
	cin >> n;
	int x = pow(n, (double)0.5);
	cout << x*x << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};

signed main() {
  int n;cin>>n;deque<int> d;
  rep(i,n){
    int a;cin>>a;
    if(!(i%2)){
      d.push_back(a);
    }else{
      d.push_front(a);
    }
  }
  if(!(n%2)){
    rep(i,n)cout << d[i] << (i == n ? "\n" : " ");
  }else{
    rep(i,n)cout << d[n-i-1] << (i == n ? "\n" : " ");
  }
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#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 namespace std;
const long long INF=1e9+5;
typedef long long ll;

int main() {
  ll N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if(N<=K){
    cout<<N*X<<endl;
  }
  else{
    cout<<K*X+(N-K)*Y<<endl;
  }
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

void solve() {
	ll N; cin >> N;
	vll A(N); cin >> A;
	string S; cin >> S;

	vll base;
	auto addBase = [](vll &base, ll val) {
		int n = base.size();
		for (int i = 0; i < n; i++) {
			if ((val^base[i]) < val) {
				val ^= base[i];
			}
		}
		if (!val) return;
		for (int i = 0; i < n; i++) {
			if ((val^base[i]) < base[i]) {
				base[i] ^= val;
			}
		}
		base.push_back(val);
		sort(rbegin(base), rend(base));
	};

	auto containBase = [](vll &base, ll val) {
		int n = base.size();
		for (int i = 0; i < n; i++) {
			if ((val^base[i]) < val) {
				val ^= base[i];
			}
		}
		if (val) return (false);
		return (true);
	};

	for (int i = (int)A.size()-1; i >= 0; i--) {
		if (S[i] == '0') {
			addBase(base, A[i]);
		} else {
			if (!containBase(base, A[i])) {
				cout << 1 << endl;
				return;
			}
		}
	}
	cout << 0 << endl;
}

void Main() {
	ll T; cin >> T;
	while (T--) solve();
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(100)
from collections import *

def dfs(now):
    global ans
    
    if len(now)==N:
        cnt = 0
        
        for a, b, c, d in abcd:
            if now[b-1]-now[a-1]==c:
                cnt += d
        
        ans = max(ans, cnt)
        return
    
    for nex in range(now[-1], M+1):
        now.append(nex)
        dfs(now)
        now.pop()

N, M, Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0

for i in range(1, M+1):
    dfs(deque([i]))

print(ans)

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

int main() {

    int i, a, b, c, now;
    cin >> a >> b >> c;
    now = 0;
    for(i = 0; now < c; i++){
        now += a;
        if(i % 7 == 6)now += b;
    }
    cout << i << endl;

}





Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

// /////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// ////////////////////////////////

#define int long long
const int N = 2e3 + 10;
int n , x , y;
int ans[N];
vector<int> v[N];
void bfs(int s , int *lev){

	bool vis[N];
	memset(vis , false , sizeof vis);

	queue<int> q;
	q.push(s);
	lev[s] = 0;
	vis[s] = true;
	while(!q.empty()){

		int node = q.front();
		q.pop();
		for(int it : v[node]){

			if(!vis[it]){

				vis[it] = true;
				q.push(it);
				lev[it] = lev[node] + 1;
			}
		}
	}


}

void solve(){

	string s;
	cin>>s;

	int n = s.size();

	if(n!=6){

		cout<<"No\n";
		return ;
	}

	if(s[2]==s[3] && s[4]==s[5]){

		cout<<"Yes\n";
		return ;
	}
	cout<<"No\n";
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}




Measured memory_bytes: 256
N = int(input())

al = 'abcdefghijk'


def next(digits, kind, cur):
    if digits == N:
        print(cur)
        return
    for i in range(kind+1):
        if i == kind:
            next(digits+1, kind+1, cur+al[i])
        else:
            next(digits+1, kind, cur+al[i])


next(1, 1, 'a')


Measured memory_bytes: 4404
#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;
 
typedef tree<int, null_type,
		less_equal<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
		
typedef tree<int, null_type,
		less<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	
 
const int mx=1e5+5;
const ll inf=1e15;

ll w[105],v[105],dp[mx];

void solve()
{
	int n;
	ll weight;
	cin>>n>>weight;
	
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	
	for(int i=1;i<mx;i++) dp[i]=inf;
	
	for(int j=1;j<=n;j++)
	{
		for(int i=mx-1;i>=v[j];i--)
		{
			dp[i]=min(dp[i],dp[i-v[j]]+w[j]);
		}
	}
	
	int ans=-1;
	
	for(int i=0;i<mx;i++)
	{
		if(dp[i]<=weight) ans=max(ans,i);
	}
	
	cout<<ans;
}
	
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		for (int i = 1; i < n + 1; i++)
			a[i] = sc.nextInt(); //出席番号iの生徒が入室したときに教室にいる人数
		sc.close();

		int[] ans = new int[n + 1];

		for (int i = 1; i < n + 1; i++)
			ans[a[i]] = i;
		for (int i = 1; i < n + 1; i++)
			System.out.print(ans[i] + " ");

	}
}

Measured memory_bytes: 60224
#include<iostream>

using namespace std;

int main(){
	long long n, k, sum = 0, min = 0, max = 0;
    cin >> n >> k;
    long long s[n+2];
    s[0] = 0;
    for(int i = 1; i <= n+1; i++){
    	s[i] = i + s[i-1];
    }
    for(int j = k; j <= n+1; j++){
    	if(n+1-j > 0){
    		min = s[j-1] - s[0];
            max = s[n] - s[n-j];
            sum += (max - min + 1)%1000000007;
            max = min = 0;
        /*} else if(n+1-j == 1) {
        	sum += n + 1;
            */
        } else {
        	sum++;
        }
        sum %= 1000000007;
    }
    cout << sum << endl;
}

Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,f[100100],val[100100],s[100100],a,b,ff[100100],d[100100],cnt;
vector<int>v[100100];
inline int sf(int x){return f[x]==x?x:f[x]=sf(f[x]);}
inline void dfs(int x,int fa,int wh){
	s[x]=val[x]=wh;ff[x]=fa;
	for(int i=0;i<v[x].size();i++)
	  if(v[x][i]!=fa)dfs(v[x][i],x,-wh),s[x]+=s[v[x][i]];  
}
signed main(){
    int i,j,k,ans=0;
    scanf("%lld%lld",&n,&m);
    for(i=1;i<=n;i++)f[i]=i;
    for(i=1;i<=m;i++){
      int x,y;
      scanf("%lld%lld",&x,&y);
      if(sf(x)==sf(y))a=x,b=y;
        else f[sf(x)]=sf(y),v[x].push_back(y),v[y].push_back(x);
    }
    if(!a)a=1;dfs(a,0,1);
    if(!b){
      if(s[a]){puts("-1");return 0;}
      for(i=1;i<=n;i++)ans+=abs(s[i]);
      printf("%lld\n",ans);return 0;
    }
    if(val[a]==val[b]){
      if(s[a]%2!=0){puts("-1");return 0;}
      k=s[a]/2;for(i=b;i;i=ff[i])s[i]-=k;ans=abs(k);
      s[a]=0;for(i=1;i<=n;i++)ans+=abs(s[i]);
      printf("%lld\n",ans);return 0;
    }
    if(s[a]){puts("-1");return 0;}
    for(i=1;i<=n;i++)ans+=abs(s[i]);
    d[++cnt]=0;
    for(i=b;i!=a;i=ff[i])d[++cnt]=s[i],ans-=abs(s[i]);
    sort(d+1,d+cnt+1);
    for(i=1;i<=cnt;i++)ans+=abs(d[i]-d[(cnt+1)/2]);
    printf("%lld\n",ans);return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, K;
int A[1010];

signed main(){
    cin >> N >> K;
    REP(i, N) cin >> A[i];
    sort(A, A + N);
    int ans = 0;
    REP(i, K) ans += A[i];
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long H = scanner.nextInt();
		long W = scanner.nextInt();

		long x = H * W;
		long y = 0;

		if (H == 1 || W == 1) {
			y = 1;
		} else if (x % 2 == 0) {
			y = x / 2;
		} else {
			y = x / 2 + 1;
		}
		System.out.println(y);
	}
}

Measured memory_bytes: 21204
import math

a, b, h, m = map(int, input().split())

agh = 30*h + (m*360)/720
agm = 6*m
diff = abs(agh - agm) #単純に引いた角度
diff0 = min(diff, 360 - diff) #角度が小さい方

if 5*h == m: #短針と長針が重なっている場合
    ans = abs(a - b)
if diff == 180: #短針と長針が逆向きの場合
    ans = a + b
if diff0 <= 90:
    ref = max(a, b)*math.sin(math.radians(diff0))
    ref1 = max(a, b)*math.sin(math.radians(90 - diff0)) - min(a, b)
    ans = (ref**2 + ref1**2)**0.5
else:
    diff0 = 180 - diff0
    ref = max(a, b)*math.sin(math.radians(diff0))
    ref1 = max(a, b)*math.sin(math.radians(90 - diff0)) + min(a, b)
    ans = (ref**2 + ref1**2)**0.5

print(ans)

Measured memory_bytes: 9564
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int cnt = 0;
    rep(i,n){
        if((i+1) %2 != 0 && v[i]%2 != 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){

    int N, X, min = 1000000, count;
    cin >> N >> X;
    vector<int> m(N);
    for(int i = 0; i < N; i++){
        cin >> m[i];
        if(min > m[i]) min = m[i];
        X -= m[i];
    }

    count = N;
    while(true){
        if(X - min < 0) break;
        X -= min;
        count++;
    }

    cout << count << endl;

    return 0;
}

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

long long int a[1000000];

int main(){

  long long int n;

  for(long long int i=2;i*i<1000000;i++){

    if(a[i]==0){
      for(long long int j=i+i;j<1000000;j+=i) a[j]=1;
    }
  }

  while(cin >> n){

    long long int count=0;

    for(long long int i=2;i<=n;i++){
      if(a[i]==0) count++;
    }

    cout << count << endl;

  }
}

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
//Coded by Charlieyan
//版权所有，翻印必究

long long dp[200005];
int l,n;
int pos[200005];

int main(){
	scanf("%d%d",&l,&n);
	long long mx=0;
	for(int i=1;i<=n;i++){
		scanf("%d",pos+i);
	}
	for(int i=1;i<=n;i++){
		if(i%2){
			dp[i]=dp[i-1]+l-(pos[i/2+1]-pos[i/2])-2*(pos[i]-pos[i/2+1]);
		}else{
			dp[i]=dp[i-1]+l-2*(pos[i]-pos[i/2]);
		}
		//cerr<<i<<' '<<dp[i]<<endl;
	}
	for(int i=1;i<=n;i++){
		mx=max(mx,dp[i]);
	}
	reverse(pos+1,pos+n+1);
	for(int i=1;i<=n;i++){
		pos[i]=l-pos[i];
	}
	for(int i=1;i<=n;i++){
		if(i%2){
			dp[i]=dp[i-1]+l-(pos[i/2+1]-pos[i/2])-2*(pos[i]-pos[i/2+1]);
		}else{
			dp[i]=dp[i-1]+l-2*(pos[i]-pos[i/2]);
		}
		//cerr<<i<<' '<<dp[i]<<endl;
	}
	for(int i=1;i<=n;i++){
		mx=max(mx,dp[i]);
	}
	printf("%lld\n",mx);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n],z[n];
  for(int i=0;i<n;i++)  cin >> a[i];
  z[n-1] = a[n-1]==0 ? 1 : 0;
  for(int i=n-2;i>=0;i--) z[i] = (a[i]==0? 1 + z[i+1] : 0);
  long long int ans = n;
  for(int i=0;i<n;i++){
    int xr = a[i], sum = a[i];
    int k=0;
  	for(int j=1;i+j+k<n&&xr>=sum/*&&j<=100*/; j++){
      if(a[i+j+k] == 0){
        if(xr==sum){
          ans = ans + z[i+j+k];
        }
        k += z[i+j+k]-1;
      }else{
      	xr ^= a[i+j+k];
      	sum += a[i+j+k];
      	if(xr == sum) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,count;
  cin>>A>>B;
  count=0;
  for(int i=A;i<=B;i++){   
    if(i/10000*10000+i%10000/1000*1000+i%1000/100*100+i%10000/1000*10+i/10000==i){count++;}
}
  cout<<count<<endl;
}


Measured memory_bytes: 256
n=int(input())
ans=0
for i in range(1,n+1):
  ans+=i*(n-i+1)
for _ in range(n-1):
  u,v=map(int,input().split())
  if u>v:
    u,v=v,u
  ans-=u*(n-v+1)
print(ans)

Measured memory_bytes: 9048
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int f(ll n) {
  vector<pair<ll, ll>> res;
  for (ll p = 2; p * p <= n; p++) {
    if (n % p != 0) {
      continue;
    }
    int num = 0;
    while (n % p == 0) {
      num++;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) {
    res.push_back(make_pair(n, 1));
  }
  int ans = 1;
  for (auto itr = res.begin(); itr != res.end(); itr++) {
    ans *= (itr->second + 1);
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i+=2) {
    int nums = f(i);
    if (nums == 8) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline

a, b = map(int, input().split())
if(a % 2 == 0):
    if(b % 2 == 0):
        print((b-a)//2 % 2 ^ b)
    else:
        b += 1
        print((b-a)//2 % 2)
else:
    a += 1
    if(b % 2 == 0):
        print((b-a)//2 % 2 ^ b ^ (a-1))
    else:
        b += 1
        print((b-a)//2 % 2 ^ (a-1))

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

using namespace std;

const int maxn = 310;
string s[maxn];

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int ans = 0;
    for (int k = 0; k < n; k++) {
        int b = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (s[(i + k) % n][j] != s[(j + k) % n][i]) {
                    b = 0;
                }
            }
        }
        ans += b * n;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

for (int i = 1; ; i++) {
int x = sc.nextInt();
if (x == 0) break;
    System.out.printf("Case %d: %d\n" ,i ,x);
}
}
}



Measured memory_bytes: 62296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,D;cin >> N >> D;
  D*=2;
  ++D;
  int ans = N/D;
  if(N%D!=0)++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll a, b, flag;
  scanf("%lld%lld", &a, &b);
  char s[a + b + 2];
  scanf("%s", s);
  if (s[a] == '-')
  {
    flag = 1;
    for (int i = 0; i < a + b + 1; i++)
    {
      if (i == a)
        continue;
      if (s[i] < '0' || s[i] > '9')
      {
        flag = 0;
      }
    }
  }
  else
    flag = 0;

  puts(flag ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
typedef pair<int, int> pint;
int N, K, L;

struct UnionFind {
    vector<int> par;

    UnionFind(int n)
        : par(n, -1)
    {
    }
    void init(int n) { par.assign(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);
        }
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x)
    {
        return -par[root(x)];
    }
};

signed main()
{
    cin >> N >> K >> L;
    UnionFind uf1(N), uf2(N);
    rep(i, K)
    {
        int p, q;
        cin >> p >> q;
        --p, --q;
        uf1.merge(p, q);
    }
    rep(i, L)
    {
        int r, s;
        cin >> r >> s;
        --r, --s;
        uf2.merge(r, s);
    }
    map<pint, int> mp;
    rep(i, N)
    {
        pint p(uf1.root(i), uf2.root(i));
        ++mp[p];
    }
    rep(i, N)
    {
        pint p(uf1.root(i), uf2.root(i));
        cout << mp[p] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 13568
import java.util.Scanner;


public class Main{
	static int dfs(int a) {
		if(a%2==1 || a==0) {
			return 0;
		}
		return dfs(a/2)+1;
	}
    public  static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int m=1000000000;
    		int N=sc.nextInt();
    		for(int i=0; i<N; i++) {
    			int A=sc.nextInt();
    			m=Math.min(m, dfs(A));
    		}
    		System.out.println(m);
    	}
    }
}

Measured memory_bytes: 21972
#include<stdio.h>

int main(){
  int n,k,i,a,b;
  long cnt=0;
  scanf("%d %d",&n,&k);
  
  for(b=k+1;b<=n;b++){
    cnt+=(n/b)*(b-k);
    if(n%b>=k){
      cnt+=n%b-k+1;
      if(k==0) cnt--;
    }
  }
  printf("%ld\n",cnt);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN=100005;
bool judge(int t0,int x0,int y0, int t,int x, int y)
{
    int tx=t-t0;
    int dist=abs(y0-y)+abs(x0-x);
    if(dist>tx)
        return false;
    else
    {
        if((dist^tx)&1)
            return false;
    }
    return true;
}
int main()
{
    int t, x, y, n;
    scanf("%d", &n);
    int flag=0;
    int t0=0,x0=0,y0=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%d %d %d", &t, &x, &y);
        if(!judge(t0,x0,y0,t,x,y))
            flag=1;
        x0=x,y0=y,t0=t;
    }
    if(flag)
        puts("No");
    else
        puts("Yes");
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" is: "<<x<<endl;
#define sout(x) cout<<#x<<" is: "<<x<<endl;
#define countBits(x) __builtin_popcount(x)
#define mt make_tuple
#define eb emplace_back
#define pob pop_back
#define star(x) cout<<"********** "<<x<<" **********"<<endl;
#define yes cout<<"Yes"<<endl; return;
#define no cout<<"No"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define prio priority_queue
#define greatPrio priority_queue <ll, vector<ll>, greater<ll>>
#define inf 1e9
#define mod 1000000007
#define N 200100

void solve(){
	ll x,y;
	cin>>x>>y;
	if(y%2==1){
		no
	}
	ll a=y-2*x;
	a/=2;
	ll b=x-a;
	if(a>=0 and b>=0){
		yes 
	}
	a=4*x-y;
	b=x-a;
	if(a>=0 and b>=0){
		yes 
	} else{
		no
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n\n";
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

const ll N = 5e5 + 5;
string s;
ll n,i,k;
ll ft[26][N];

ll query(ll fin , ll in){
	ll ans = 0;
	for(;in > 0; in -= in&-in)ans += ft[fin][in];
	return ans;
}

void add(ll fin, ll in, ll val){
	for(; in <= n; in += in&-in)ft[fin][in] += val;
}

void doit(){
	cin >> n >> s;
	rep(i,0,n){
		add(s[i] - 'a',i+1,1LL);
	}
	ll q;
	cin >> q;
	while(q--){
		ll qin;
		cin >> qin;
		if(qin == 1){
			ll sin;
			char ch;
			cin >> sin >> ch;
			add(s[sin-1]-'a',sin,-1LL);
			s[sin-1] = ch;
			add(s[sin-1]-'a', sin , 1LL);
		}
		else {
			ll l,r;
			cin >> l >> r;
			ll i,ans = 0,k = 0;
			rep(i,0,26){
				k = query(i,r) - query(i,l-1);
				if(k)ans++;
			}
			cout << ans << nl;
		}
	}

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 105372
object Main extends App {
  import scala.io.StdIn._
  val Array(a,b) = readLine().split(" ").map(_.toInt)
  val aString = Array.fill[String](b)(a.toString).mkString("")
  val bString = Array.fill[String](a)(b.toString).mkString("")
  println(List(aString,bString).min)
}

Measured memory_bytes: 25500
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<int> b;
    if (n % 2 == 0)
    {
        int cnt = 0;
        for (int i = 1; cnt < n; i += 2)
        {
            b.push_back(i);
            b.push_back(i);
            cnt += 2;
        }
    }
    else
    {
        int cnt = 1;
        b.push_back(0);
        for (int i = 2; cnt < n; i += 2)
        {
            b.push_back(i);
            b.push_back(i);
            cnt += 2;
        }
    }
    rep(i, n) if (a[i] != b[i])
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    rep(i, n / 2)(ans *= 2) %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    int v[100000] = {};
    int a[100001] = {};
    int b[100001] = {};
    int amax=0;
    int bmax=0;
    int amax2 = 0;
    int bmax2 = 0;
    int tmp=0;
    int ai;
    int ai2=-1;
    int bi;
    int bi2=-1;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int i=0;i<n;i+=2){
        a[v[i]]++;
    }
    for(int i=0;i<100001;i++){
        amax = max(amax,a[i]);
        if(amax == a[i]){
            ai = i;
        }
    }
    for(int i=0;i<100001;i++){
        if(i == ai){
            continue;
        }
        amax2 = max(amax2,a[i]);
        if(amax2 == a[i]){
            ai2 = i;
        }
    }
    for(int i=1;i<n;i+=2){
        b[v[i]]++;
    }
    for(int i=0;i<100001;i++){
        bmax = max(bmax,b[i]);
        if(bmax == b[i]){
            bi = i;
        }
    }
    for(int i=0;i<100001;i++){
        if(i == bi){
            continue;
        }
        bmax2 = max(bmax2,b[i]);
        if(bmax2 == b[i]){
            bi2 = i;
        }
    }

    if(ai == bi){
        cout << min(n - amax - bmax2, n - bmax - amax2) << endl;
    }else{
        cout << n - amax - bmax << endl;
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
int main()
{
fast_io
li k;
cin>>k;
li arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<arr[k-1];
return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
map<string, int>mp;
int n;
string s[224514];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	int ans = 0;
	rep(i, n)cin >> s[i];
	rep(i, n)mp[s[i]]++;
	for (auto x : mp)ans++;
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 26220
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    long long N, u, v, ans;
    cin >> N;
    ans = (N*(N+1)*(2*N+1)/6 + N*(N+1)/2) / 2;
    for(int i=0;i<N-1;++i) {
        cin >> u >> v;
        if(u < v) ans -= u*(N-v+1);
        else ans -= v*(N-u+1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
int main() {
	ios_base::sync_with_stdio(false);
	ll a,b; cin>>a>>b;
	if (a<=0&&0<=b) cout<<"Zero"<<endl;
	else {
		ll negs=max(0LL,-a)-max(0LL,-(b+1));
		if (negs%2) cout<<"Negative"<<endl;
		else cout<<"Positive"<<endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse).ToList();
        var ans = new List<long>();
        ans.Add(a.Sum());
        for (int i = 1; i < n; i = i + 2) ans[0] -= 2 * a[i];
        for (int i = 0; i < n - 1; i++) ans.Add(2 * a[i] - ans[i]);
        foreach (var item in ans) Console.Write("{0} ", item);
    }
}

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

const int MAX_N = 51;
int mp[MAX_N][MAX_N];
ll X[MAX_N], Y[MAX_N];
pair<ll, ll> dot[MAX_N];
int N, K;

int minmp(int i, int j) {
    if(i >= 0 && j >= 0) return mp[i][j];
    else return 0;
}

int main()
{
    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        cin >> dot[i].first >> dot[i].second;
        X[i] = dot[i].first, Y[i] = dot[i].second;
    }
    
    sort(X, X + N);
    sort(Y, Y + N);

    /*
    for(int i = 0; i < N; ++i) {
        cout << X[i] << " ";
    }
    cout << endl;
    for(int i = 0; i < N; ++i) {
        cout << Y[i] << " ";
    }
    cout << endl;
    */

    for(int i = 0; i < N; ++i) {
        int nx = lower_bound(X, X + N, dot[i].first) - X;
        int ny = lower_bound(Y, Y + N, dot[i].second) - Y;
        ++mp[nx][ny];
    }

    /*
    cout << endl;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            cout << mp[i][j] << " ";
        }
        cout << endl;
    }
    */

    //2次元累積和
    
    for(int i = 0; i < N; ++i) {
        for(int j = 1; j < N; ++j) 
            mp[i][j] += mp[i][j-1];
    }
    for(int i = 1; i < N; ++i) {
        for(int j = 0; j < N; ++j) 
            mp[i][j] += mp[i-1][j];
    }
    
    /*
    cout << endl;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            cout << mp[i][j] << " ";
        }
        cout << endl;
    }
    */

    ll res = LLONG_MAX;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            for(int k = i + 1; k < N; ++k) {
                for(int l = j + 1; l < N; ++l) {
                    //累積和の取り方か、使い方がミスっていたらしい...
                    
                    int num = minmp(k, l) - minmp(i-1, l)- minmp(k, j-1) + minmp(i-1, j-1);
                    
                    if(num >= K) {
                        /*
                        cout << i << " " << j << endl;
                        cout << k << " " << l << endl;
                        cout << endl;
                        */
                        ll S = 1LL * (X[k] - X[i]) * (Y[l] - Y[j]);
                        res = min(res, S);
                    }
                    
                    /*これだとAC
                    int num = 0;
                    ll lx = X[i], rx = X[k];
                    ll by = Y[j], uy = Y[l];
                    
                    for(int m = 0; m < N; ++m) {
                        if(lx <= dot[m].first && dot[m].first <= rx
                            && by <= dot[m].second && dot[m].second <= uy)
                                ++num;
                    }
                    if(num >= K) res = min(res, (rx - lx)*(uy - by));
                    */
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define P pair<int,int>
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
ll llmin(ll a,ll b){
  if(a>b) return b;
  else return a;
}

//cout << setprecision(123);
int main(){
  ll N,ans,A,B,C,D,E,X;
  cin>>N>>A>>B>>C>>D>>E;
  X=llmin(A,B);
  X=llmin(X,C);
  X=llmin(X,D);
  X=llmin(X,E);
  if(X==A) ans=4+(N+A-1)/A;
  if(X==B) ans=4+(N+B-1)/B;
  if(X==C) ans=4+(N+C-1)/C;
  if(X==D) ans=4+(N+D-1)/D;
  if(X==E) ans=4+(N+E-1)/E;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#include<algorithm>
#define maxn 1005
using namespace std;
int xs,ys,xt,yt,n,x[maxn],y[maxn],r[maxn];
double dist[maxn],g[maxn][maxn];
queue<int> q;
bool inq[maxn];
int main()
{
	scanf("%d%d%d%d%d",&xs,&ys,&xt,&yt,&n);
	x[0]=xs,y[0]=ys,x[n+1]=xt,y[n+1]=yt;
	for(int i=1;i<=n;i++) scanf("%d%d%d",&x[i],&y[i],&r[i]);
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			g[i][j]=max(0.0,sqrt(1.0*(x[i]-x[j])*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]);
	for(int i=1;i<=n+1;i++) dist[i]=1e16;
	q.push(0); inq[0]=true;
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		inq[u]=false;
		for(int v=0;v<=n+1;v++)
			if(dist[v]>dist[u]+g[u][v])
			{
				dist[v]=dist[u]+g[u][v];
				if(!inq[v]) { inq[v]=true; q.push(v); }
			}
	}
	printf("%.10f\n",dist[n+1]);
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>

constexpr int MAX_N = 100;
long N, dp[MAX_N + 1][21];
int num[MAX_N];

int main(){
    std::cin >> N;
    for(int i = 0; i < N; ++i) {
        std::cin >> num[i];
    }
    dp[0][num[0]] = 1;
    
    for(int i = 0; i < N - 2; ++i) {
        for(int j = 0; j <= 20; ++j) {
            if(j + num[i + 1] <= 20) dp[i + 1][j] += dp[i][j + num[i + 1]];
            if(j - num[i + 1] >= 0) dp[i + 1][j] += dp[i][j - num[i + 1]];
        }
    }
    
    std::cout << dp[N - 2][num[N - 1]] << std::endl;
    
    return 0;
}

Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();
        int a_count = 0;
        long ans = 0;
        for (int i = 0; i + 1 < s.Length; i++)
        {
            if (s[i] == 'A')
            {
                a_count++;
                continue;
            }
            if (s[i] == 'B' && s[i + 1] == 'C')
            {
                i += 1;
                ans += a_count;
                continue;
            }
            a_count = 0;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 14048
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

long long gcd(long long a, long long b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        long long r = a%b;
        a=b;
        b=r;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //xのn乗を計算するのにn乗を2進表記にして計算
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//答えに付加
        }
        x=(x*x)%mod;//2乗
        n=n/2;
    }
    return ret;
}


struct XX{
    int d=0;
    int a=0;
    int k=0;
    int t=0;
};

class xxIntu {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.a+riLeft.k) == (riRight.a+riRight.k)){
            return riLeft.a < riRight.a;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
        }
        //第1条件
        return (riLeft.a+riLeft.k) < (riRight.a+riRight.k);
    }
};
/*bool operator< (const XX &riLeft, const XX &riRight){
    return riLeft.d < riRight.d;
};*/


int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから

    string s;
    cin >> s;

    cout << s.substr(0,4)+" "+ s.substr(4,s.size())<< endl;
    
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  map<in,in> m;
  for(in i=2;i<=13;++i)
    m[i]=i;
  m[1]=20;
  in a,b;
  cin>>a>>b;
  if(m[a]>m[b])
    cout<<"Alice"<<endl;
  if(m[a]<m[b])
    cout<<"Bob"<<endl;
  if(m[a]==m[b])
    cout<<"Draw"<<endl;
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main() {
	
	char a;
	cin >> a;

	int x = a;

	if (x >= 65 && x <= 90) cout << 'A' << endl;
	else cout << 'a' << endl;

	return 0;
}

Measured memory_bytes: 3596
def additable_flood?(after_sections, dup)
  sim_dup = 0
  after_sections.size.times do |i|
    case after_sections[i]
    when '\\'
      sim_dup -= 1
    when '/'
      sim_dup += 1
      return false if sim_dup > 0
    end
  end

  true
end

sections = gets
down_steps = []
floods = []
area = 0
step = 0
dup = 0

sections.size.times do |i|
  step += 1
  case sections[i]
  when '\\'
    down_steps << step
    dup += 1

  when '/'
    if down_steps != []
      ds = down_steps.pop
      area += step - ds
      dup -= 1

      if dup != 0 && additable_flood?(sections[i+1..-1], dup)
        floods << area
        area = 0
        down_step = []
        step = 0
        next
      end
    end
  end

  if (dup == 0 && area != 0)
    floods << area
    area = 0
    down_step = []
    step = 0
  end
end

floods << area if area != 0

puts floods.sum
floods.size != 0 ? puts("#{floods.size} #{floods.join(' ')}") : puts('0')


Measured memory_bytes: 8864
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<set>
#define int long long
using namespace std;

signed main() {
	int ans = 0;
	int a; cin >> a;
	int b = 1;//使っていい最小値
	for (int c = 0; c < a; c++) {
		int d; cin >> d;
		if (c == 0) {
			ans += d - 1;
			b = 2;
		}
		else if (b >= d) {
			b = max(b, d + 1);
		}
		else {
			ans += (d-1) / b;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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() {
  int a, b, c; cin >> a >> b >> c;
  cout << a * b / 2 << endl;
  return 0;
}

Measured memory_bytes: 3120