akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong b[MXN], n, ans, cnt;

int main(){
	ios;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> b[i];
		cnt += b[i];
		if(b[i] == 0){
			ans += cnt / 2;
			cnt = 0;
		}
	}
	cout << ans + cnt / 2; 
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

using LL = long long;

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.setf(std::ios_base::fixed);
    cout.precision(24);
    // freopen("input.txt", "r+", stdin);
    int n, a;
    cin >> n;
    map < int, int > cnt;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        cnt[a]++;
    }
    int res = 0;
    for (auto p : cnt) {
        if (p.first == p.second) {
            continue;
        }
        if (p.second > p.first) {
            res += p.second - p.first;
        } else {
            res += p.second;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 4736
n = int(input())
sp = []
for i in range(n):
    s = input().split()
    s[1] = int(s[1])
    s.append(i+1)
    sp.append(s)

sp2 = sorted(sp, key=lambda x:(x[0],-x[1]),reverse=False)

for i in sp2:
    print(i[2])



Measured memory_bytes: 3060
import copy
N, A, B = list(map(int, input().split()))
total = 0
for i in range(1, N+1):
    tmp_i = copy.deepcopy(i)
    digits_sum = 0
    while tmp_i > 0:
        digits_sum += tmp_i % 10
        tmp_i = tmp_i // 10
    if A <= digits_sum <= B:
        total += i
print(total)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==1){
        cout<<b-a<<endl;
    }
    else{
        cout<<a-b<<endl;
    }
    return(0);
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define l first
#define r second

int main(){
	int n,w,h,p;
	while(cin>>n>>w>>h){
		p=w*2+h*2;
		vector<pii> rng(n);
		rep(i,n){
			int x,y,v; char c;
			cin>>x>>y>>c;
			rng[i].l=[=]{return (int[]){x-h+y,x+h-y,w*2+h+y-x,w*2+h-y-x}["NEWS"s.find(c)];}();
			rng[i].r=[=]{return (int[]){x+h-y,w*2+h-y-x,w*2+h+y+x,w*2+h+y-x}["NEWS"s.find(c)];}();
		}
		sort(all(rng),[](pii a,pii b){return a.r<b.r;});
		
		int ans=1e8;
		rep(i,n) {
			sort(all(rng),[](pii a,pii b){return a.r<b.r;});
			int a=1,b=rng[0].r;
			range(j,1,n){
				if(rng[j].l>b){
					a++;
					b=rng[j].r;
				}
			}
			ans=min(ans,a);
			rng[0].l+=p, rng[0].r+=p;
		}
		cout<<ans<<endl;
	}
	return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  int i;
  for (i=0;i<N;i++) {
    cin >> card[i];
  }
  sort(card.begin(),card.end(),greater<int>());
  int Alice = 0, Bob = 0;
  int k,j;
    for (k=0;2*k<N;k++) {
      Alice += card[2*k];
    }
    for (j=0;2*j+1<N;j++) {
      Bob += card[2*j+1];
    }
 cout << Alice - Bob <<endl;
}


Measured memory_bytes: 3628
mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def cmb(a,b):
    r=min(b,a-b)
    if(r==0):
        return 1
    ue=1
    sita=1
    for i in range(r):
        ue*=a-i
        ue%=mod
        sita*=r-i
        sita%=mod
    return div(ue,sita)

def div(a, b):
    return mul(a, power(b, mod-2))


n,a,b=map(int,input().split())

zen=power(2,n)-1

dame=cmb(n,a)
kirai=cmb(n,b)

ans=(mod*2+zen-dame-kirai) % mod
print(ans)

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

using ll =long long;
using ull = unsigned long long;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

int main(void){

    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i, a) cin >> p.at(i);
    rep(i, b) cin >> q.at(i);
    rep(i, c) cin >> r.at(i);

    //答え用
    ll sum = 0;

    sort(p.rbegin(), p.rend());  
    sort(q.rbegin(), q.rend());     //rverseイテレータを使うと短い
    sort(r.rbegin(), r.rend());

    vector<ll> d;
    //d配列を作る（X＋Yの答え候補のみの配列）
    rep(i, x) d.push_back(p.at(i));
    rep(i, y) d.push_back(q.at(i));
    rep(i, c) d.push_back(r.at(i));
    //降順にソート
    sort(d.rbegin(), d.rend());
    //大きい方から答えとする。
    rep(i, x + y)
         sum += d.at(i);

         cout << sum << endl;

         return 0;
}


Measured memory_bytes: 8432
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = Integer.parseInt(in.next());
		int b = Integer.parseInt(in.next());
		
		int area = a * b;
		int length = a * 2 + b * 2;
		
		System.out.println(area + " " + length);
	}
}	


Measured memory_bytes: 26028
import math

N, K = map(int,input().split())
#N, K = 100000, 5

ans = 0
total = 0
for i in range(0,N):
	if i < K:
	#dice_times = math.ceil(math.log2(K/(i+1)))
		dice_times = math.ceil(math.log2(K/(i+1)))
		total = total + (0.50000000000**dice_times)
		#print(total)
	else:
		total += 1

print(total/N)


Measured memory_bytes: 2940
import sys 
import numpy as np

N, K = list(map(int, input().split()))

h = np.zeros(N)

for n in range(N):
    h[n] = int(input())

h = np.sort(h)

m = h[N-1] - h[0]

for n in range(0,N-K+1):
    d = h[n+K-1] - h[n]
    if d < m:
        m = d

print(int(m))


Measured memory_bytes: 14016
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1000000007;

struct point {
  int r;
  int c;
  int d;
  point(int r, int c, int d) : r(r), c(c), d(d) {}
};

int32_t dfs(vector<vector<char>>& maize, point s, int32_t gr, int32_t gc, int32_t H, int32_t W) {
  queue<point> q;
  vector<vector<bool>> visited(H, vector<bool>(W, false));
  q.push(s);
  int32_t res = 0;
  while (!q.empty()) {
    point cur = q.front();
    q.pop();
    if (cur.r == gr && cur.c == gc) {
      res = cur.d;
      break;
    }
    if (visited[cur.r][cur.c] == true) {
      continue;
    } else {
      visited[cur.r][cur.c] = true;
    }
    if (cur.r > 0 && maize[cur.r -1][cur.c] != '#' && visited[cur.r-1][cur.c] == false) {
      q.push(point(cur.r - 1, cur.c, cur.d + 1));
    }
    if (cur.r < H - 1 && maize[cur.r+1][cur.c] != '#' && visited[cur.r+1][cur.c] == false) {
      q.push(point(cur.r + 1, cur.c, cur.d + 1));
    }
    if (cur.c > 0 && maize[cur.r][cur.c - 1] != '#' && visited[cur.r][cur.c-1] == false) {
      q.push(point(cur.r, cur.c-1, cur.d + 1));
    }
    if (cur.c < W - 1 && maize[cur.r][cur.c+1] != '#' && visited[cur.r][cur.c+1] == false) {
      q.push(point(cur.r, cur.c + 1, cur.d + 1));
    }
  }
  return res;
}

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

  int32_t H, W;
  cin >> H >> W;
  vector<vector<char>> maize(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maize[i][j];
    }
  }

  int32_t max_step = 0;
  for (int sr = 0; sr < H; sr++) {
    for (int sc = 0; sc < W; sc++) {
      if (maize[sr][sc] == '#') {
        continue;
      }
      point start(sr, sc, 0);
      for (int gr = 0; gr < H; gr++) {
        for (int gc = 0; gc < W; gc++) {
          if (maize[gr][gc] == '#') {
            continue;
          }
          int32_t step = dfs(maize, start, gr, gc, H, W);
          max_step = max(max_step, step);
        }
      }
    }
  }
  cout << max_step << endl;
  return 0;
}


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

int main()
{
  string s;
  int ans=0;
  cin>>s;
  for(int i=0;i<4;i++)
  {
    if(s.at(i)=='+')
      ans++;
    else
      ans--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3568
#pragma GCC optimize ("Ofast")
using llong = long long;
using ullong = unsigned long long;
using ulong = unsigned long;
#include <bits/stdc++.h>
#define PROBLEMNAME ""
#define DEBUG1(key, x) cerr << #key": " << x << endl;
#define DEBUG(x) cerr << #x": " << x << endl;
#define DEBUG_CONTAINER(x) {cerr << #x":" << endl; for (const auto & xx : x) cerr << xx << " "; cerr << endl;}
#define REPORT cerr << "Ok here" << endl;
#ifndef AduMaster
#define endl '\n'
#undef DEBUG
#undef DEBUG1
#undef DEBUG_CONTAINER
#undef REPORT
#define DEBUG(x)
#define DEBUG1(key, x)
#define REPORT
#define DEBUG_CONTAINER(x)
#endif
using namespace std;
//ifstream fin(PROBLEMNAME".INP");
//ofstream fout(PROBLEMNAME".OUT");
#ifdef AduMaster
//#define cin fin
//#define fout cout
#endif

struct Edge
{
	int V, A, B;
};

struct Counter
{
	llong C, D;
};


const int MaxSilver = 5000 + 1;

vector<vector<llong>> Dijkstra(int S, const vector<vector<Edge>> & Adj, const vector<Counter> & Counters)
{
	S = min(S, MaxSilver);
	
	const int N = Adj.size() - 1;
	
	vector<vector<llong>> DP(N + 1, vector<llong>(MaxSilver, LLONG_MAX));
	
	struct Record
	{
		llong Time;
		int Position;
		llong Money;
		
		bool operator>(const Record & r) const
		{
			return (Time != r.Time) ? Time > r.Time : 
				  ((Position != r.Position) ? Position > r.Position : Money > r.Money);
		}
	};
	
	priority_queue<Record, vector<Record>, greater<Record>> Q;
	
	DP[1][S] = 0;
	Q.push({0, 1, S});
	
	while (Q.size())
	{
		auto [time, position, money] = Q.top();
		Q.pop();
		
		if (time > DP[position][money]) continue;
				
		if (money + Counters[position].C < MaxSilver)
		{
			llong newMoney = money + Counters[position].C;
			llong newTime = time + Counters[position].D;
			
			if (DP[position][newMoney] > newTime)
			{
				DP[position][newMoney] = newTime;
				Q.push({newTime, position, newMoney});
			}
		}
				
		for (const auto & x : Adj[position])
		{
			if (money < x.A) continue;
			int newPos = x.V;
			llong newMoney = money - x.A;
			llong newTime = time + x.B;
			
			if (DP[newPos][newMoney] > newTime)
			{
				DP[newPos][newMoney] = newTime;
				Q.push({newTime, newPos, newMoney});
			}
		}
	}
	
	return DP;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
		
	int N, M, S;
	cin >> N >> M >> S;
		
	vector<vector<Edge>> Adj(N + 1);
	while (M--)
	{
		static int U, V, A, B;
		cin >> U >> V >> A >> B;
		Adj[U].push_back({V, A, B});
		Adj[V].push_back({U, A, B});
	}
	
	vector<Counter> Counters(N + 1);
	for (int i = 1; i <= N; ++i)
	{
		cin >> Counters[i].C >> Counters[i].D;
	}
	
	vector<vector<llong>> Result = Dijkstra(S, Adj, Counters);
		
	for (int v = 2; v <= N; ++v)
	{
		DEBUG(v);
		llong result = *min_element(Result[v].begin(), Result[v].end());
		DEBUG(min_element(Result[v].begin(), Result[v].end()) - Result[v].begin());
		cout << result << endl;
	}
	
	exit(0);
		
	return 0;
}


Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k,h[200010];
signed main(){
    cin>>n>>k;
    rep(i,n)cin>>h[i];
    if(n<=k){
        puts("0");
        return 0;
    }
    sort(h,h+n);
    int ans=0;
    rep(i,n-k)ans+=h[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, W;
	scanf("%d%d", &n, &W);
	vector<vector<int> > v(4);
	int mn;
	for (int i = 0, w, val; i < n; ++i) {
		scanf("%d%d", &w, &val);
		if (!i)
			mn = w;
		v[w - mn].push_back(val);
	}
	for (int i = 0; i < 4; ++i) {
		sort(v[i].begin(), v[i].end());
		v[i].push_back(0);
		reverse(v[i].begin(), v[i].end());
		for (int j = 1; j < v[i].size(); ++j)
			v[i][j] += v[i][j - 1];
	}
	int res = 0;
	for (int a = 0; a < v[0].size(); ++a)
		for (int b = 0; b < v[1].size(); ++b)
			for (int c = 0; c < v[2].size(); ++c) {
				ll rem = W - (ll)a*mn - (ll)b*(mn + 1) - (ll)c*(mn + 2);
				if (rem < 0)
					break;
				int can = rem / (mn + 3);
				can = min(can, (int)v[3].size() - 1);
				res = max(res, v[0][a] + v[1][b] + v[2][c] + v[3][can]);
			}
	printf("%d\n", res);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int cnt = 0;
  for (int i = 1; i < n - 1; i++) {
    if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
      cnt++;
    }
    if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3624
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
//#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {
	
	ll N = 0;
	ll A = 0;
	ll X = 0;
	ll Y = 0;
	ll x[10] = {};
	//string w;
	int count = 0;
	int sum = 0;
	
	cin >> N;
	A = N;
	int i = 0;
	while (true) {

		x[i] = N % 10;
		N /= 10;
		sum += x[i];
			i++;
			if (N < 1)break;
	}

	if(A%sum == 0)
	cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
	
}


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

static char M[1010][1010];

bool sol(int n,int m,int a,int b)
{
  if(m==1){
    if(a>0||b>n/2){
      return 0;
    }
    for(int i=0;i<b;i++){
      M[2*i][0]='^';
      M[2*i+1][0]='v';
    }
    return 1;
  }
  int G=0,cc;
  if(m%2==1){
    G=(n%2);
    int c=min(b,n/2);
    cc=c;
    for(int i=0;i<c;i++){
      M[2*i][m-1]='^';
      M[2*i+1][m-1]='v';
    }
    b-=c;
    m--;
  }
  int k=(b+m-1)/m,c=b-(k-1)*m;
  if(2*k>n)return 0;
  for(int i=0;i<k;i++){
    for(int j=0;j<(i==k-1?c:m);j++){
      M[2*i][j]='^';
      M[2*i+1][j]='v';
    }
  }
  G=(G+(m-c)%2)/2;
  int L=(n-2*k)*(m/2)+2*((m-c)/2)+G;
  if(L<a)return 0;
  int t=min(a,2*((m-c)/2)+G);
  for(int i=0;i<t;i++){
    M[2*k-2+(i%2)][c+2*(i/2)]='<';
    M[2*k-2+(i%2)][c+2*(i/2)+1]='>';
  }
  if(G==1&&t==2*((m-c)/2)+G){
    M[2*k-2][m-1]='<';
    M[2*k-2][m]='>';
    int l=max(0,cc-(k-1));
    for(int i=0;i<l;i++){
      M[2*k-1+2*i][m]='^';
      M[2*k-1+2*i+1][m]='v';
    }
  }
  a-=t;
  for(int i=0;i<a;i++){
    int l=i/(m/2),s=i%(m/2);
    M[2*k+l][2*s]='<';
    M[2*k+l][2*s+1]='>';
  }
  return 1;
}

int main()
{
  int n,m,a,b;
  scanf("%d%d%d%d",&n,&m,&a,&b);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      M[i][j]='.';
    }
  }
  bool F=sol(n,m,a,b);
  if(!F){
    puts("NO");
  }
  else{
    puts("YES");
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	putchar(M[i][j]);
      }
      putchar('\n');
    }
  }
  return 0;
}


Measured memory_bytes: 2176
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

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

const ll maxn = 610;

ll N, K, P[maxn], dp[maxn][maxn], cpair[maxn];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // ifstream cin(".in");

    cin >> N >> K;
    memset(P, -1, sizeof P);
    fori (i, K) {
        ll a, b; cin >> a >> b; --a, --b;
        P[a] = b, P[b] = a;
    }
    N *= 2, K *= 2;
    cpair[0] = 1;
    forifrom (i, 2, N + 1) cpair[i] = 1LL * cpair[i - 2] * (i - 1) % MOD;
    ll ans = 0;
    for (ll t = 2; t <= N; t += 2) {
        for (ll l = 0; l + t <= N; ++l) {
            ll r = l + t;
            bool valid = true;
            ll used = 0;
            forifrom (i, l, r) {
                if (P[i] != -1) {
                    ++used;
                    if (P[i] < l || P[i] >= r) valid = false;
                }
            }
            if (!valid) continue;
            dp[l][r] = cpair[t - used];
            ll used2 = P[l] != -1;
            for (ll i = l + 1; i + 1 < r; ++i) {
                if (P[i] != -1) ++used2;
                Add(dp[l][r], MOD - 1LL * dp[l][i + 1] * cpair[(r - i - 1) - (used - used2)] % MOD);
            }
            Add(ans, 1LL * dp[l][r] * cpair[N - t - (K - used)]);
        }
    }
    cout << ans << '\n';


}


Measured memory_bytes: 5012
#include<bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long n,a[100009],b[100009]={0};
    cin>>n;
    rep(i,1,n+1) cin>>a[i];
    b[1]=0;
    b[2]=abs(a[2]-a[1]);
    rep(i,3,n+1)
        b[i]=min(abs(a[i]-a[i-1])+b[i-1],abs(a[i]-a[i-2])+b[i-2]);
    //rep(i,1,n+1)
    //    cout<<b[i]<<" ";
    //cout<<"\n";
    cout<<b[n];
}

Measured memory_bytes: 1792
while 1:
    m,d = map(int,input().split())
    if m == 0:
        break
    w = ["Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"]
    day = [0,31,60,91,121,152,182,213,244,274,305,335]
    print(w[(day[m-1]+d)%7])


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

int main(void){
    int h, w;
    vector <string> s;
    string str;
    int i, j;
    
    cin >> h >> w;
    for(i = 0; i < h; i++){
        cin >> str;
        s.push_back(str);
    }
    
    for(i = 0; i < w + 2; i++){
        cout << "#";
    }
    cout << endl;
    
    for(i = 0; i < h; i++){
        cout << "#";
        for(j = 0; j < w; j++){
            cout << s[i][j];
        }
        cout << "#" << endl;
    }
    
    for(i = 0; i < w + 2; i++){
        cout << "#";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int n;
	cin>>n>>s;
	for(int i=0;i<s.size();i++)
	{
		s[i]=(s[i]-'A'+n)%26+'A';
	}
	cout<<s;
	return 0;
}


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

using ll = long long;
//typedef long long ll;

#define INF ((1LL << 31) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int h, w;
string s[52];
int ans[52][52];

int vx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, vy[8] = {0, -1, -1, -1, 0, 1, 1, 1};

int main() {
    init();
    cin >> h >> w;
    rep(i,h) {
        cin >> s[i];
    }


    rep(i,h) {
        rep(j,w) {
            if (s[i][j] == '#') {
                ans[i][j] = -1;
                continue;
            }
            rep(k,8) {
                int nx = i + vx[k], ny = j + vy[k];
                if (0 <= nx and nx < h and 0 <= ny and ny < w) {
                    if (s[nx][ny] == '#') {
                        ans[i][j]++;
                    }
                }
            }
        }
    }

    rep(i,h) {
        rep(j,w) {
            if (ans[i][j] == -1) {
                cout << '#';
            }
            else {
                cout << ans[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def xor(data):
    if not data:
        return 0
    res = data[0]
    for i in range(1,len(data)):
        res ^= data[i]
    return res

A,B = map(int,input().split())
if A == B:
    print(A)
    exit()
num = B-A+1
data = []
cut = 0
if A % 2 == 0:
    cut = (num) // 2
    if cut % 2 == 1:
        data.append(1)
    if num % 2 == 1:
        data.append(B)
else:
    data.append(A)
    cut = (num-1) // 2
    if cut % 2 == 1:
        data.append(1)
    if (num-1) % 2 == 1:
        data.append(B)
ans = xor(data)
print(ans)

Measured memory_bytes: 3064
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b) = in.readLine.split(" ").map(_.toInt)
  val ans = a match {
    case x if x <= 5 => 0
    case x if x <=12 => b / 2
    case _ => b
  }
  println(ans)
}

Measured memory_bytes: 25552
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(b >= a){
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF 114514810
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)

using namespace std;

int n;
bool p[100000], flg = 1;

int prime(){
	FOR(i, 2, 100000) p[i] = 1;
	REP(i, 100000) {
		if (p[i])
			for (int j = 2; i*j < 100000; j++) p[i*j] = 0;
	}
}

int main(){
	prime();
	cin >> n;
	int k = 2;
	cout << n << ":";
	while (k < 100000){
		if (n == 1) break;
		if (p[k])
			while (true){
				if (!(n%k)) {
					cout << " " << k;
					flg = 0;
					n /= k;
				}
				else break;
			}
		k++;
	}
	if (flg) cout << " " << n;
	cout << endl;
}

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = (y); x <= (z); x++)
#define REPP(x, y, z) for(int x = (y); x >= (z); x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure
struct Item
{
	ll idx, l;

	bool operator <(const Item& rs) const
	{
		if(idx+l == rs.idx+rs.l)
		{
			return idx-l < rs.idx-rs.l;
		}

		else
		{
			return idx+l < rs.idx+rs.l;
		}
	}
};
//declaration
int n;
vector<Item> v;
//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	cin >> n;
	ll x, y;

	REP(i, 1, n)
	{
		cin >> x >> y;
		v.EB((Item){x, y});
	}

	sort(all(v));

	ll r = v[0].idx+v[0].l;
	int ans = 0;
	REP(i, 1, n-1)
	{
		if(r > v[i].idx-v[i].l)
		{
			ans++;
		}
		else
		{
			r = v[i].idx+v[i].l;
		}
	}

	cout << n-ans << '\n';

	return 0;
}

Measured memory_bytes: 2420
# は？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？


_ = gets.to_i # 素直にnにしたら./Main.rb:1: warning: assigned but unused variable - nって言われるんだけど、なぜか8つ中5つはACになる。意味不明
arr = gets.chomp.split.map(&:to_i)
# collection = Array.new(8, 0)
collection = Array.new(8, false)

over = 0
arr.each do |a|
  c = a/400
  if c >= 8
    over += 1
  else
    # if collection[c].zero?
    #   collection[c] = 1
    # end
    collection[c] = true
  end
end
# なんかいろいろ条件を忘れていたので仕方なく愚直に書いてやる
# if collection.inject(:+).zero?
if collection.select{|x| x}.size.zero?
  # puts "#{1} #{[8, over].min}"
  puts "#{1} #{over}"
else
  minimum = collection.select{|x| x}.size # collection.inject(:+)
  # maximum = [minimum+over, 8].min
  maximum = minimum+over
  puts "#{minimum} #{maximum}"
end

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>

using namespace std;
int main()
{
    char str[4];
    bool isBad=false;
    cin>>str;
    for(int i = 0;i<3;i++)
    {
        if(str[i]==str[i+1])
        {
            isBad=true;
        }
    }
    if(isBad)
    {
        cout<<"Bad"<<endl;
    }
    else
    {
        cout<<"Good"<<endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	B=B+A;
	int x=0;
	
	do{
		B=B-A;
		if(x == C){
			break;
		}
		if(B < A){
			break;
		}
		x++;
	}while(B/A!=0);
	
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

ll gcd (ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}

int main()
{
	fast
	ll t, sum=0;
	cin>>t;
	for(ll i=1; i<=t; i++)
	{
		for(ll j=1; j<=t; j++)
		{
			for(ll k=1; k<=t; k++)
			{
				sum+=gcd(gcd(i,j),k);
			}
		}
	}	
	cout<<sum<<endl;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringBuilder sb = new StringBuilder(br.readLine());

		System.out.println(sb.reverse());


	}

}

Measured memory_bytes: 24080
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
//*/


using namespace std;
static const int _ = []() {
	ios::sync_with_stdio(false);
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	return 0;
}();
#define ll long long
#define ull unsigned long long
#define rep(i,a) for(ll i=0;i<(a);i++)
#define rng(i,a,b) for(ll i=(a);i<=(b);i++)
#define rev(i,a) for(ll i=(a)-1;i>=0;i--)
#define S size()
#define all(a) (a).begin(),(a).end()
#define any(i,a) for(auto& i:a)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define X first
#define Y second
#define V vector
#define VL V<ll>
#define VVL V<VL>
#define VS V<string>
template<class T> inline vector<T> rv(ll n) { vector<T> v(n); rep(i, n) cin >> v[i]; return v; }
template<class T> inline void pv(const vector<T>& v) { rep(i, v.size()) cout << v[i] << " "; cout << endl; }
template<class T> inline void amax(T& a, const T& b) { if (a < b) a = b; }
template<class T> inline void amin(T& a, const T& b) { if (a > b) a = b; }
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}
	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};



int main() {
	vector<ll> v(3); rep(i, 3) cin >> v[i];
	cout << (v[0] * v[1] / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S[0:2] > "12":
    if "01" <= S[2:4] <= "12":
        print("YYMM")
    else:
        print("NA")

elif "01" <= S[0:2] <= "12":
    if "01" <= S[2:4] <= "12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif S[0:2] == "00":
    if "01" <= S[2:4] <= "12":
        print("YYMM")
    else:
        print("NA")

else:
    print("NA")


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    rep(i, N) cin >> s[i] >> t[i];
    string X;
    cin >> X;
    int a=0, ans=0;
    rep(i, N) {
        ans += t[i] * a;
        if (X == s[i]) a = 1;
    }
    cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 200007
using namespace std;
long long a[MAXN];
int main()
{
	int n; cin>>n;
	long long sum=0;
	for(int i=0;i<n;i++) {cin>>a[i]; sum+=a[i];}
	long long parc=0,res=1000000000000000000LL;
	for(int i=0;i<n-1;i++) {parc+=a[i]; res=min(res,max(parc,sum-parc)-min(parc,sum-parc));}
	cout<<res;
}

Measured memory_bytes: 1792
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0
    const A = lines[1].split(' ').map(Number)
    const Q = lines[2] - 0
    const B = []
    const C = []
    for (let i = 0; i < Q; i++) {
        const row = lines[i + 3].split(' ').map(Number)
        B[i] = row[0]
        C[i] = row[1]
    }

    const dp = []
    let sum = 0
    for (let i = 0; i < A.length; i++) {
        if (dp[A[i]]) {
            dp[A[i]]++
        } else {
            dp[A[i]] = 1
        }
        sum += A[i]
    }

    for (let i = 0; i < Q; i++) {
        if (!dp[B[i]]) {
            console.log(sum)
            continue
        }
        if (!dp[C[i]]) {
            dp[C[i]] = 0
        }
        dp[C[i]] += dp[B[i]]
        sum += (C[i] - B[i]) * dp[B[i]]
        dp[B[i]] = 0

        console.log(sum)

    }

})(input)


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  map<int, vector<vector<char>>> to;
  to[3] = {
    {'a', 'a', 'b'},
    {'c', '.', 'b'},
    {'c', 'd', 'd'}
  };
  to[4] = {
    {'a', 'a', 'c', 'd'},
    {'b', 'b', 'c', 'd'},
    {'g', 'h', 'e', 'e'},
    {'g', 'h', 'f', 'f'},
  };
  to[5] = {
    {'a', 'a', 'b', 'x', 'x'},
    {'c', '.', 'b', 'y', 'y'},
    {'c', 'd', 'd', 'z', 'z'},
    {'e', 'f', 'g', '.', '.'},
    {'e', 'f', 'g', '.', '.'},
  };
  to[7] = {
    {'a', 'b', 'b', '.', '.', '.', 'm'},
    {'a', '.', 'd', '.', '.', '.', 'm'},
    {'c', 'c', 'd', '.', '.', '.', 'n'},
    {'.', '.', '.', 'e', 'e', 'f', 'n'},
    {'.', '.', '.', 'h', '.', 'f', 'o'},
    {'.', '.', '.', 'h', 'g', 'g', 'o'},
    {'x', 'x', 'y', 'y', 'z', 'z', '.'},
  };
  if(n == 2) {
    cout << -1;
    return 0;
  }
  vector<int> pos;
  if(n % 3 == 0) {
    for(int i = 0; i < n / 3; i++) pos.push_back(3);
  } else {
    for(int x = 0; x <= n; x += 4) {
      for(int y = 0; y + x <= n; y += 5) {
        for(int z = 0; x + y + z <= n; z += 7) {
          if(x + y + z == n) {
            for(int i = 0; i < x / 4; i++) pos.push_back(4);
            for(int i = 0; i < y / 5; i++) pos.push_back(5);
            for(int i = 0; i < z / 7; i++) pos.push_back(7);
            break;
          }
        }
        if(!pos.empty()) break;
      }
      if(!pos.empty()) break;
    }
  }
  assert(!pos.empty());
  vector<vector<char>> res(n, vector<char>(n, '.'));
  int cur = 0;
  for(int sz : pos) {
    for(int i = 0; i < sz; i++) {
      for(int j = 0; j < sz; j++) {
        res[cur + i][cur + j] = to[sz][i][j];
      }
    }
    cur += sz;
  }
  for(auto i : res) {
    for(auto j : i) cout << j;
    cout << endl;
  }
  return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> a;
    if (s[0] == '0')
        a.push_back(0);
    s.push_back('2');
    int i = -1, j = 0, ans = 0;
    char c = '0', d = '1';

    while (i < n + 1)
    {
        if (s[i + 1] == c)
        {
            i++;
            j++;
            continue;
        }
        if (i != -1 || c == '1')
            a.push_back(j);
        swap(c, d);
        j = 0;
        if (s[i + 1] == '2')
            break;
    }
    if (s[n - 1] == '0')
        a.push_back(0);
    n = a.size();

    rep(i, max(1, n - 2 * k))
    {
        int sum = 0;
        rep(j, min(n, 2 * k + 1)) sum += a[i + j];
        ans = max(ans, sum);
        i++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    int a[m]={};
    int x=0;
    for(int i=0;i<n;i++){
        int ans=c;
        for(int j=0;j<m;j++){
            cin>>a[j];
            ans+=a[j]*b[j];
        }
        if(ans>0) x++;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(input())
arr1 = [int(n) for n in input().split()]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1) for key in arr2]))



Measured memory_bytes: 6556
n = int(input())
A = [int(i)-1 for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

out = 0
before = n

for i in range(n):
  out += B[A[i]]
  if A[i] == before+1:
    out += C[A[i]-1]
  before = A[i]
print(out)

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

int main(){
	int N;
	cin >> N;
	ll A[N];
	ll tot = 0;
	rep(i,N) {
		cin >> A[i];
		tot += A[i];
	}
	ll left = 0;
	int k = 0;
	while (left < tot/2) {
		left += A[k];
		k++;
	}
	ll right = tot - left;
	ll ans = left -right;
	left -= A[k-1];
	right = tot - left;
	ans = min(ans, right-left);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5172
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }

int count(int x)
{
   if (x == 0)
      return 0;
   return (x & 1) + count(x >> 1);
}

int main()
{
   int n, a[15] = {}, x[15][15] = {}, y[15][15] = {}, ans = 0;
   cin >> n;
   FOR(i, 0, n)
   {
      cin >> a[i];
      FOR(j, 0, a[i])
      {
         cin >> x[i][j] >> y[i][j];
         x[i][j]--;
      }
   }
   FOR(i, 0, (1 << n))
   {
      bool flag = true;
      FOR(j, 0, n)
      {
         if ((i >> j) & 1)
         {
            FOR(k, 0, a[j])
            {
               if (((i >> x[j][k]) & 1) != y[j][k])
               {
                  flag = false;
                  break;
               }
            }
         }
      }
      ans = max(ans, (flag ? count(i) : 0));
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut unko = Vec::new();
    let mut unti = Vec::new();
    for _ in 0..n {
        let a: usize = itr.next().unwrap().parse().unwrap();
        let b: usize = itr.next().unwrap().parse().unwrap();
        unko.push(a);
        unti.push(b);
    }
    unko.sort();
    unti.sort();

    let mut un;
    let mut ko;
    if n % 2 == 0 {
        un = unko[n / 2] + unko[(n - 1) / 2];
        ko = unti[n / 2] + unti[(n - 1) / 2];
    } else {
        un = unko[n / 2];
        ko = unti[n / 2];
    }
    println!("{}", ko - un + 1);
}


Measured memory_bytes: 9704
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

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


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Graph g = new Graph(n+1);
        for(int i=0; i<m; i++)
            g.add(in.nextInt(), in.nextInt());
        System.out.println(g.getAns());
        in.close();
    }
    
    static class Graph {
        int V;
        ArrayList<Integer> list[];
        
        Graph(int v) {
            this.V = v;
            list = new ArrayList[V];
            for(int i=0; i<V; i++)
                list[i] = new ArrayList<>();
        }
        
        void add(int u, int v) {
            list[u].add(v);
            list[v].add(u);
        }
        
        int getAns() {
            boolean[] visited = new boolean[V];
            int ans = 0;
            for(int i=1; i<V; i++) {
                if(!visited[i])
                    ans = Math.max(ans, dfs(i, visited));
            }
            return ans + 1;
        }
        
        int dfs(int s, boolean[] visited) {
            if(visited[s])
                return 0;
            visited[s] = true;
            int count = 0;
            for(int i : list[s]) {
                if(!visited[i])
                    count += 1 + dfs(i, visited);
            }
            return count;
        }
    }
}

Measured memory_bytes: 96312
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		HashMap<String, Integer> mapplus = new HashMap<String, Integer>();
		HashMap<String, Integer> mapminus = new HashMap<String, Integer>();
		int N = sc.nextInt();
		String[] s1 = new String[N];
		for(int i = 0;i < N;i++) {
			s1[i] = sc.next();
		}
		int M = sc.nextInt();
		String[] s2 = new String[M];
		for(int i = 0;i < M;i++) {
			s2[i] = sc.next();
		}
		sc.close();
		
		//bluecard
		int plus;
		for(int i = 0;i < N ;i++) {
			plus = 0;
			plus++;
			for(int k = i + 1;k < N;k++) {
				if(s1[i].equals(s1[k])) plus++;
			}
			if(mapplus.containsKey(s1[i])) {
				if(mapplus.get(s1[i]) < plus) mapplus.put(s1[i],plus);
			}
			else mapplus.put(s1[i],plus);
		}
		
		//redcard
		int minus;
		for(int i = 0;i < M ;i++) {
			minus = 0;
			minus--;
			for(int k = i + 1;k < M;k++) {
				if(s2[i].equals(s2[k])) minus--;
			}
			if(mapminus.containsKey(s2[i])) {
				if(mapminus.get(s2[i]) > minus) mapminus.put(s2[i],minus);
			}
			else mapminus.put(s2[i],minus);
		}

		int ans = Integer.MIN_VALUE;
		for(int i = 0;i < N ;i++) {
			int sum1 = 0;
			int sum2 = 0;
			for(int k = 0;k < M;k++) {
				sum1 = mapplus.get(s1[i]);
				if(s1[i].equals(s2[k])) {
					sum2 = mapminus.get(s2[k]);	
					if(-(sum2) > sum1) sum1 = 0;
					else sum1 += sum2;
					break;
				}
			}
			if(ans < sum1) ans = sum1;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n, a[1001000];
multiset <int> rem;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(int i = 0; i < (1 << n); i++) {
		cin >> a[i];
		rem.insert(a[i]);
	}
	sort(a, a  + (1 << n) , greater<int>());
	// dbg_v(a, (1 << n));

	vector <int> v;
	v.push_back(a[0]);
	rem.erase(rem.find(a[0]));
	for(int i = 0; i < n; i++) {
		sort(v.begin(), v.end(), greater<int>());
		vector <int> v2;
		for(auto i : v) {
			auto it = rem.lower_bound(i);
			if(it == rem.begin())
				return cout << "No\n", 0;
			// dbg(*it);
			it--;
			// dbg(*it, i);
			if(*it >= i)
				return cout << "No\n", 0;
			v2.push_back(*it);
			rem.erase(it);
		}
		for(auto i : v2)
			v.push_back(i);
		// dbg(i, rem.size());
	}
	// dbg(v);
	cout << "Yes\n";
}	

	

Measured memory_bytes: 15036
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	int i,gakuseki,tmp=-1;
	double W,L;
	double BMI;
	while(scanf("%d,%lf,%lf",&gakuseki,&W,&L)){
		if(tmp==gakuseki)break;
        tmp=gakuseki;
		BMI=W/L/L;
	  
		if(BMI>=25)
		cout<<gakuseki<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++){
        if(i%c==0){
            d++;
        }
    }
    cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    string S; cin >> S; bool can = true;
    int N=S.size();
    if(N==2){
        if(S[0]==S[1]) cout << 1 << " " << 2 << endl;
        else cout << -1 << " " << -1 << endl;
        return 0; 
    }
    rep(i,N-2){
        char a,b,c; map<char,int> m;
        a=S[i]; b=S[i+1]; c=S[i+2];
        m[a]++; m[b]++; m[c]++;
        for(auto p:m){
            if(p.second>=2){
                cout << i+1 << " " << i+3 << endl;
                can = false; break;
            }
        }
        if(!can) break;
    }
    if(can) cout << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())
b = list(map(int,input().split()))
a = b.copy()
l = []
for idx,num in enumerate(b):
    for i in range(len(b)-idx-1,-1,-1):
        #print(b[i] ,i)
        if a[i] == i+1:
            l.append(a.pop(i))
            break
if len(l) == N:
    print("\n".join(map(str,reversed(l))))
else:
    print(-1)

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

int main(){
    string s;
    int ans = 0;
    
    cin >> s;
    
    if (s[0] == '1')
        ans++;
    if (s[1] == '1')
        ans++;
    if (s[2] == '1')
        ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
from copy import deepcopy
N = int( input())
Path = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b = map( int, input().split())
    a, b = a-1, b-1
    Path[a].append(b)
    Path[b].append(a)
Mass = [-1 for _ in range(N)]
F = deque([0])
S = deque([N-1])
while len(F) != 0 or len(S) != 0:
    KF = deque([])
    while len(F) != 0:
        f = F.pop()
        for x in Path[f]:
            if Mass[x] == -1:
                Mass[x] = 1
                KF.append(x)
    F = deepcopy(KF)
    KS = deque([])
    while len(S) != 0:
        s = S.pop()
        for y in Path[s]:
            if Mass[y] == -1:
                Mass[y] = 0
                KS.append(y)
    S = deepcopy(KS)
if sum(Mass) >= N//2+1:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 22644
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
#define MAX_H 60
#define MAX_W 60

int h, w;
char maze[MAX_H][MAX_W];
ll cost[MAX_H][MAX_W];

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int num_white = 0;

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

  cin >> h >> w;
  rep(i, 0, h) rep(j, 0, w) {
      cin >> maze[i][j];
      if(maze[i][j] == '.') num_white++;
      cost[i][j] = -1;
  }

  num_white -= 1;

  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  cost[0][0] = 0;

  while(!q.empty()) {
      pair<int, int> p = q.front(); q.pop();
      if(p.first == w - 1 && p.second == h - 1) break;

      rep(i, 0, 4) {
          ll nx = p.first + dx[i], ny = p.second + dy[i];
          if(!(0 <= nx && nx < w && 0 <= ny && ny < h)) continue;
          if(maze[ny][nx] == '#') continue;
          if(cost[ny][nx] != -1) continue;

          cost[ny][nx] = cost[p.second][p.first] + 1;
          q.push(make_pair(nx, ny));
      }
  }

  if(cost[h - 1][w - 1] == -1) cout << "-1" << endl;
  else {
      ll rsl = num_white - cost[h - 1][w - 1];
      cout << rsl << endl;
  }
}


Measured memory_bytes: 256