akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    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;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MOD 1000000000
#define MAX 10000005
#define ll long long
#define slld(t) scanf("%I64d",&t)
#define sd(t) scanf("%d",&t)
#define ss(x) scanf("%s",x)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%I64d\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define rep(I, N) for (int I = 0; I < (N); ++I)
#define repp(I, A, B) for (ll I = (A); I <= (B); ++I)
#define t1(x)                cout<<#x<<": "<<x<<endl
#define t2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
ll pwr(ll base, ll p, ll mod = MOD)
{
    ll ans = 1;
    while(p)
    {
        if(p & 1)   ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        p /= 2;
    }
    return ans;
}
// for inverse modulo : if (1/b)%mod then ans is (b^(mod-2))%mod
ll gcd(ll a, ll b)
{
    if(b == 0)  return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
    return (a*b) / gcd(a, b);
}
/*bool isPrime[MAX];
void sieve(int n) 
{
    for(int i = 0; i <= n;++i) 
    {
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i * i <= n; ++i) 
    {
         if(isPrime[i] == true) 
         {
             for(int j = i * i; j <= n ;j += i)
                 isPrime[j] = false;
        }
    }
}*/
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.first > b.first);
}
const ll N = 2e5 + 5 ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    //freopen("A.in", "r", stdin); 
    //freopen("A.out", "w", stdout);

    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
    {
        cout<<c<<endl;
    }
    else if(b==c)
    {
        cout<<a<<endl;
    }
    else cout<<b<<endl;

    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: usize = read();
  let mut ans = 0;
  for _ in 0..n {
    let v: Vec<usize> = read_vec();
    ans += (v[1] - v[0] + 1);
  }
  println!("{}", ans);
}




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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0]!=s[1] or s[1]!=s[2] or s[0]!=s[2]){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	t := make([]int, n)
	tmax := 0
	for i := 0; i < n; i++ {
		t[i] = nextInt()
		tmax += t[i]
	}
	m := nextInt()
	for i := 0; i < m; i++ {
		p := nextInt()
		x := nextInt()
		fmt.Println(tmax - t[p-1] + x)
	}

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#include<iostream>
#include<cmath>
#include<algorithm>
#include<fstream>
using namespace std;

const int MAX = 100000;
int N;
int C[MAX]; //C[i]:i番目の出現回数

void input()
{
	//fstream in("test.txt");
	//memset(C, 0, sizeof(C));
	cin >> N;
	for (int i = 0; i < N; i++) {
		int j;
		// scanf("%d", &j);
		cin >> j;
		C[j]++;
	}
}

void solve()
{
	int coun = 0;
	//偶数人並んでいる場合
	if (N % 2 == 0) {
		//矛盾していないかチェック
		for (int i = 1; i < N; i=i+2) {
			if (C[i] != 2) {
				cout << 0 << endl;
				return;
			}
		}
			coun = N / 2;
	}
	else { //奇数個の場合
		if (C[0] != 1) {
			cout << 0 << endl;
			return;
		}
		for (int i = 2; i < N; i= i + 2) {
			if (C[i] != 2) {
				cout << 0 << endl;
				return;
			}
		}
			coun = (N - 1) / 2;
	
	}
	int ans = 1;
	for (int i = 1; i <= coun; i++) {
		ans = (ans * 2) % 1000000007;
	}
	//ans = ans%M;
	// int ans = (int)(1<<(coun) % 1000000007);
	cout << ans << endl;
}

int main()
{
	/*fstream out("test.txt");
	for (int i = 1; i < 100000; i=i+2) {
		out << i << " " << i << " ";
	}*/
	input();
	solve();
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
int main(){
    int n,nn,x,y,ans;
    scanf("%d",&n);
    scanf("%d",&nn);
    for(int i=0;i<nn;i++){
        scanf("%d%d",&x,&y);
        if(n/2<x)
            x=1+(n-x);
        if(n/2<y)
            y=1+(n-y);
        if(x>y)
            x=y;
        ans=x%3;
        if(ans==0)
            ans=3;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll x = c - a - b;
  if (x < 0) {
    cout << "No";
  } else {
    x * x > 4 * a * b ? cout << "Yes" : cout << "No";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a,b,c,n;
ll sum;
int main(){
	cin>>n;
   cin>>a;
   for(int i=1;i<=n-1;i++)
   {
   	cin>>b;
   	if(b<=a) sum+=a-b;
   	else a=b;
   }
   cout<<sum;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector < long long > vll;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vii;

const int N = 1e5 + 5;
const ll mod = 1e9 + 7;

int main(){
int a;
scanf("%d",&a);
int L = a/100; // it will divide the first part of the string
int R = a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)printf("AMBIGUOUS\n");
else printf("MMYY\n");
}else{
if(1<=R&&R<=12)printf("YYMM\n");
else printf("NA\n");
}
}










Measured memory_bytes: 3756
n,m = gets.split.map(&:to_i)
s=gets.chomp
t=gets.chomp
k = n.lcm(m)

a = k / n
b = k / m
i = 0
j = 0
ok = true
while i < s.size and j < t.size
  if s[i] != t[j]
    ok = false
    break
  end
  i += b
  j += a
end
if ok
  p k
else
  p -1
end


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

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

int main() {
  int N, W;
  std::cin >> N >> W;
  std::vector<int> w(N);
  std::vector<int> v(N);
  for (int i = 0; i < N; ++i)
    std::cin >> w[i] >> v[i];

  int K = N * 1000;
  long long inf = 1LL << 60;
  std::vector<std::vector<long long>> dp(
      N + 7, std::vector<long long>(2 * K + 7, inf));
  // dp[i][k] = i 個目までみて価値の合計が k 以上となる場合の重さの最小値

  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int k = 0; k <= K; ++k) {
      chmin(dp[i + 1][k], dp[i][k]);
      chmin(dp[i + 1][k + v[i]], dp[i][k] + w[i]);
    }
    for (int l = 0; l < v[i]; ++l)
      chmin(dp[i + 1][l], dp[i][0] + w[i]);
  }

  long long res = -1;
  for (int k = 0; k <= K; ++k) {
    if (dp[N][k] <= W)
      res = k;
  }
  std::cout << res << std::endl;
}


Measured memory_bytes: 169216
#include<bits/stdc++.h>
using namespace std;
int a[100001][3];
int dp[100001][3];
int n;

int func(int ind, int flag) {

	if (ind == n) return 0;

	if (dp[ind][flag] != -1) return dp[ind][flag];

	int maxi = 0;
	if (flag == 0) {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 1) {
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 2) {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
	}

	return dp[ind][flag] = maxi;
}

int main() {

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

	memset(dp, -1, sizeof dp);

	cout << func(0, 0);

	return 0;
}


Measured memory_bytes: 13776
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  string s;
  cin >> n >> s;

  int red = 0, blue = 0;
  rep(i, 0, n) {
    if (s[i] == 'R')
      red++;
    else
      blue++;
  }

  if (red > blue)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long int N, a, b;
    cin >> N >> a >> b;
    long long int complete_block = N / (a+b);
    long long int last_block = N % (a+b);
    long long int rest = min(a, last_block);

    cout << complete_block*a + rest << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll n, res=0L;
    cin >> n;
    vector<ll> p(n);
    rep(i, n){
        ll x;
        cin >> x;
        p[x-1] = i;
    }
    set<ll> st;
    st.insert(p[n-1]);
    for(int i=n-2;i>=0;i--){
        ll now = p[i], disl, disr;
        st.insert(now);
        auto l = st.lower_bound(now);
        if(l!=st.begin()&&l!=++st.begin()){
            disl = *(--l) - *(--l);
        }else{
            if(l!=st.begin()){
                disl = *(--l) + 1;
            }else{
                disl = 0;
            }
        }
        auto r = st.upper_bound(now);
        if (r != st.end()) {
            disr = *r - *(--r);
        } else {
            disr = n - *(--r);
        }
        res += disl * disr * (i+1);
        // cout << disl << " " << disr << " " << res << endl;

        l = st.lower_bound(now);
        if (l != st.begin()) {
            disl = *l - *(--l);
        } else {
            disl = *l + 1;
        }
        r = st.upper_bound(now);
        if (r != st.end() && r != --st.end()) {
            disr = *(++r) - *(--r);
            // cout << *(--r) << " " << *(++r) << endl;
        } else {
            if (r != st.end()) {
                disr = n - *r;
            } else {
                disr = 0;
            }
        }
        res += disl * disr * (i+1);
        // cout << disl << " " << disr << " " << res << endl;
    }

    cout << res << endl;
    return 0;
}

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

#define MOD 1000000007

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

  vi a(n);
  vi b(n);

  rep(i, n) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  int ans = 0;
  if (n % 2 == 0) {
    // 偶数
    int check_i_down = n/2 - 1;
    int check_i_up = n/2;
    int down_min_x = a[check_i_down];
    int down_max_x = b[check_i_down];
    int up_min_x = a[check_i_up];
    int up_max_x = b[check_i_up];
    ans = (down_max_x + up_max_x) - (down_min_x + up_min_x) + 1;
  } else {
    // 奇数
    int check_i = (n + 1) / 2 - 1;
    int min_x = a[check_i];
    int max_x = b[check_i];
    ans = max_x - min_x + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4756
n=int(input())
v=list(map(int,input().split()))
w=[]
for i in range(n//2):
    w.append(v.pop(i))

import collections
cv = collections.Counter(v)
cw = collections.Counter(w)
scv = sorted(cv.items(), key=lambda x:-x[1])
scw = sorted(cw.items(), key=lambda x:-x[1])

v1=scv[0][0]
w1=scw[0][0]

if v1==w1:
    if len(scv)==1:
        v2=0
    else:
        v2=scv[1][1]
    if len(scw)==1:
        w2=0
    else:
        w2=scw[1][1]
        
    print(min(n-scv[0][1]-w2, n-scw[0][1]-v2))
        
else:
    print(n-scv[0][1]-scw[0][1])

Measured memory_bytes: 21092
#include<iostream>

using namespace std;

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

	if (a > b)
		cout << "a > b" << "\n";
	else if (a < b)
		cout << "a < b" << "\n";
	else
		cout << "a == b" << "\n";
}

Measured memory_bytes: 3068
import heapq
from sys import stdin
input = stdin.readline
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d


n,m,s,t = map(int,input().split())

y_edge = [[] for i in range(n)]
s_edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(m):
    x,y,yen,strc = map(int,input().split())
    y_edge[x-1].append([yen,y-1])
    y_edge[y-1].append([yen,x-1])
    s_edge[x-1].append([strc,y-1]) 
    s_edge[y-1].append([strc,x-1])

y_dis = dijkstra_heap(s-1,y_edge)
s_dis = dijkstra_heap(t-1,s_edge)
m = 0
ans = []
for y,s in zip(y_dis[::-1], s_dis[::-1]):
    t = 10**15-y-s
    m = max(m,t)
    ans.append(m)

print(*ans[::-1], sep="\n")


Measured memory_bytes: 128620
#pragma region
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 1e5 + 5;
ll n, W, w[maxn], val[maxn], dp[maxn];
int main() {
    IO;
    cin >> n >> W;
    rep(i, 1, n) cin >> w[i] >> val[i];
    rep(i, 1, n) for (int t = W; t >= w[i]; --t) dp[t] = max(dp[t], dp[t - w[i]] + val[i]);
    cout << dp[W] << endl;
}

Measured memory_bytes: 4408
// abc166_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif
    
    int N, K;
    cin >> N >> K;
    
    vector<bool> A(N, true);
    REP(i, K){
        int d;
        cin >> d;
        REP(j, d){
            int a;
            cin >> a;
            a--;
            A[a] = false;
        }
    }
    
    int ans = 0;
    REP(i, N){
        if (A[i]) ans++;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3648
import java.util.*;

class Main{
	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int m=s.nextInt(),d=s.nextInt();

		int r=0;
		for(int i=1;i<=m;++i) {
			for(int j=10;j<=d;++j) {
				if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)
					++r;
			}
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
typedef  long long ll;

int main() {
	std::string str;
	int a;
	std::cin >> str;
	a = str.length()-1;
	std::cout << str[0] << str.length() - 2 << str[a] <<std::endl;
}

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

int main()
{
	string s, t;
	bool yes = true;
	cin >> s >> t;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i])
			yes = false;
	}
	cout << (yes ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define INF 200005
#define MOD 1000000007

int main()
{
    //freopen("output.txt","r",stdin);
    //freopen("input.txt","r",stdin);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n;
    cin >> n;
    int a[n+5]={0};
    for(int i=0;i<n;i++) cin >> a[i];
    long long tot=0;
    for(int i=0;i<n;i++)
    {
        for(int k=i+1;k<n;k++)
        {
            tot=tot+(a[i]*a[k]);
        }
    }
    cout << tot << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
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);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
const lli N = pow(2, 21) + 2;
lli dp[N];
lli calc(lli mask, vector<vll>& S){
    lli n = S.size();
    if(mask == 0)
        return 1;
    else if(dp[mask] != -1)
        return dp[mask];
    lli ans = 0;
    lli sum = __builtin_popcountll(mask);
    loop(i, 0, n){
        if(!(mask & (1<<i)))
            continue;
        if(S[sum-1][i] == 1){
            ans += calc(mask ^ (1<<i), S);
            ans = ans % M;
        }
    }
    dp[mask] = ans;
    return ans;
}
lli solve(){
    lli n;
    cin>>n;
    vector<vll> S(n, vll(n));
    loop(i, 0, n)
        loop(j, 0, n)
            cin>>S[i][j];
    lli num = pow(2, n)-1;
    memset(dp, -1, sizeof(dp));
    cout<<calc(num, S)<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 20372
n=int(input())
a=list(map(int,input().split()))

ans = 0
a_xor = 0
a_sum = 0
r=-1

for l in range(n):
    while a_xor == a_sum:
        if r>=n-1:
            r = n
            break
        r += 1
        a_xor ^= a[r]
        a_sum += a[r]
        
    ans += r-l
    a_xor ^= a[l]
    a_sum -= a[l]
print(ans)
    
    

Measured memory_bytes: 24424
import math

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

bit = [0 for _ in range(41)]

for a in A:
    for i in range(41):
        bit[i]+= 1 if (a & (0b1<<i))>0 else 0

ans = 0
x = 0
bit.reverse()

for i,b in zip(range(40, -1, -1), bit):
#    print(N, K, i, b, ans, x, 2**i)

    if b<(N-b) and x+2**i <= K:
        ans += (N-b)*2**i
        x += 2**i                        
    else:
        ans += b*2**i

print(ans)




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

#define MAX_N 100
#define MAX_W 50000

int N, W;
int v[MAX_N];
int w[MAX_N];

int dp[MAX_W + 1];

int main()
{
	cin >> N >> W;
	for( int i = 0; i < N; i++ ) {
		cin >> v[i] >> w[i];
	}

	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j <= W; j++ ) {
			if( j >= w[i] ) {
				dp[j] = max( dp[j], dp[j - w[i]] + v[i] );
			}
		}
	}
	int ans = dp[W];

	cout << ans << endl;

	return 0;
}



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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;


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



int main() {

  cout<<fixed<<setprecision(10);

  string w; cin>>w;
  string ti;

  cin>>ti;
  ll ans = 0;
  while( ti != "END_OF_TEXT" ){
    transform(ti.begin(), ti.end(), ti.begin(), ::tolower);
    ans += w==ti;

    cin>>ti;
  }

  cout<<ans<<endl;

}




//






Measured memory_bytes: 3216
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn join<S:ToString> (l: Vec<S>, sep: &str) -> String{
    l.iter().fold("".to_string(),
                  |a,b| if a.len()>0 {a+sep} else {a} + &b.to_string()
                  )
}

struct TwoPointers<F>
  where F: Fn(usize, usize) -> bool
{
    range: std::ops::Range<usize>,
    pred: F,
    left: usize,
    right: usize,
}

impl<F> TwoPointers<F>
  where F: Fn(usize, usize) -> bool
{
    pub fn new( range: std::ops::Range<usize>, pred: F) -> Self{
        Self{
            range: range.clone(),
            pred: pred,
            left: range.start,
            right: range.start,
         }
    }
}

impl<F> Iterator for TwoPointers<F>
  where F: Fn(usize, usize) -> bool
{
    type Item = (usize, usize);
   fn next(&mut self) -> Option<( usize, usize )> {
       if self.left >= self.range.end{
           return None;
       }
       self.right = {
           let mut r = std::cmp::max(self.left + 1, self.right);
           while (r <= self.range.end) && (self.pred)(self.left, r){
                r += 1;
           }
           r - 1
       };
       self.left += 1;
       Some((self.left - 1, self.right))
   }
}

fn main(){
    input!{
        n: usize,
        q: usize,
        a: [usize; n],
        xs: [usize; q],
    }
    let mut v = Vec::with_capacity(q);
    let mut cumsum = vec![0; n + 2];
    for i in 0..n{
        cumsum[i+1] = cumsum[i] + a[i];
    }
    for x in xs{
        let tp = TwoPointers::new( 0..n, |l, r| cumsum[r] - cumsum[l] <= x);
        let ans = tp.map(|(l, r)| r - l).fold(0, |a, b| a+b);
        v.push(ans);
    }
    println!("{}", join(v, "\n"));
}


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

  int sum(int x){
    int sum,dig;
    while(x){
      dig = x%10;
      sum += dig;
      x = x/10;
    }
    return sum;
  }
int main(){
  int N,S;
  cin >> N;
  S = sum(N);
  if(N%S == 0)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 256
s = input()
g, p = 0, 0
ans = 0
for e in s:
    if e == "g":
        if p+1 <= g:
            p += 1
            ans += 1
        else:
            g += 1
    else:
        if p+1 <= g:
            p += 1
        else:
            g += 1
            ans -= 1

print(ans)


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  char b;
  cin>>b;
  if(b=='A')cout<<'T'<<endl;
  else if(b=='C')cout<<'G'<<endl;
  else if(b=='G')cout<<'C'<<endl;
  else cout<<'A'<<endl;

return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;

vector<pair<int, int> >adj[MAX];

void dijkstra(){
  priority_queue<pair<int ,int > >PQ;
  int color[MAX];
  int d[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;
  
  while(!PQ.empty()){
    pair<int ,int> f=PQ.top();
    PQ.pop();
    int u= f.second;
    color[u]=BLACK;
    
    if(d[u]<f.first*(-1)) continue;
    
    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK) continue;
      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	PQ.push(make_pair(d[v]*(-1),v));
	color[v]=GRAY;
      }
    }
  }
  
  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
  }
}

int main(){
  int k,u,v,c;
  
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }

  dijkstra();
  return 0;
}
		     
		      



Measured memory_bytes: 3116
k,t=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a, reverse=True)

if len(a)>1:
    x=a[0]-sum(a[1:])
    if x>0:
        print(x-1)
    else:
        print(0)
else:
    print(a[0]-1)

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

int main() {
  int a, b, c, d;
  cin >> a >> b;

  if (b / 100 == 1)
    c = a * 1000 + b;
  else if (b / 10 >= 1)
    c = a * 100 + b;
  else
    c = a * 10 + b;

  for (int i = 0; i <= sqrt(c); i++) {
    if (i * i == c) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>

#define PI 3.1415926

using namespace std;

int main(){

	double a, b, c, s, l, h;

	cin >> a >> b >> c;

	c = c * PI / 180;

	s = a * b * sin(c) / 2.0;

	h = s * 2.0 / a;

	l = sqrt(pow(a, 2) + pow(b, 2) - 2.0 * a * b * cos(c)) + a + b;

		cout << setprecision(8) << s << endl << l << endl << h << endl;

	return 0;
}


Measured memory_bytes: 3476
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;
const int N = 1e5 + 7; 

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(a, res);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int k;
vector<int> g[N];

int ans = 1;

void dfs(int cur, int p) {
	int c = k - 2;
	if (p == -1) {
		c = k - 1;
	}
	for (auto t : g[cur]) {
		if (t != p) {
			ans = mul(ans, c);
			c--;
			dfs(t, cur);
		}
	}
}

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

	int n;
	cin >> n >> k;
	for (int i = 0; i + 1 < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0, -1);
	ans = mul(k, ans);
	cout << ans << endl;
}


Measured memory_bytes: 10368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        for(int i = 0; i < n; i++){
            String[] tmpStr = br.readLine().split(" ");
            int[] linesq = new int[3];

            for(int j = 0; j < 3; j++){
                linesq[j] = Integer.parseInt(tmpStr[j]);
                linesq[j] *= linesq[j];
            }

            Arrays.sort(linesq);

            if(linesq[2] == linesq[1] + linesq[0] ){
                System.out.println("YES");
            }
            else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 26200
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int n;

int check(int num,int start, string w[40]){
  int count = start;
  bool flag = true;
  while(flag){
    if(count >= n){
      flag = false;
      break;
    }
    else if(num - w[count].size() == 0){
      count++;
      break;
    }
    else if(num - w[count].size() > 0){
      num -= w[count].size();
      count++;
      continue;
    }
    else {
      flag = false;
      break;
    }
  }
  if(flag) return count;
  else return -1;
}

int main(){
  string w[40];
  while(true){
    cin >> n;
    //cout << "n="<<n << endl;
    if(n == 0) break;

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

    for(int i = 0; i < n - 4; i++){
      int point = i;

      point = check(5, i, w);
      if(point == -1) continue;
      point = check(7, point, w);
      if(point == -1) continue;
      point = check(5, point, w);
      if(point == -1) continue;
      point = check(7, point, w);
      if(point == -1) continue;
      point = check(7, point, w);
      if(point != -1){
         cout << i+1 << endl;
         break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n-1;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll l=-1;
  ll r=-1;
  for(int i=n-1;i>0;i--){
    if(l==-1&&a[i]==a[i-1]){
      l=a[i];
      i--;
      continue;
    }
    if(l!=-1&&a[i]==a[i-1]){
      r=a[i];
      break;
    }
  }
  if(l!=-1&&r!=-1){
  COUT(l*r);
  }
  else{
COUT(0);
  }
}


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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}


const int MAX_N = 1e4 + 10;
vector<int> es[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        es[a].pb(b);
        es[b].pb(a);
        d[a]++;
        d[b]++;
    }
    vector<ll> c(n);
    rep(i, n) cin >> c[i];
    sort(all(c));

    queue<int> q;
    vector<int> v(n, INF);
    if (n == 1) v[0] = 0;
    int cnt = 0;
    rep(i, n) if (d[i] == 1) {
        v[i] = cnt++;
        q.push(i);
    }
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        for (auto && i : es[p])  {
            d[i]--;
            if(d[i] == 1) {
                v[i] = cnt++;
                q.push(i);
            }
        }
    }
    assert(cnt == n);
    // dumpV(v);
    auto& id = v;
    // dumpV(id);
    ll ans = 0LL;
    rep(i, n) for (auto && j : es[i]) if (i < j) {
            ans += min(c[id[i]], c[id[j]]);
            // cout << " " << i << " " << j << " " << c[id[i]] << " " << c[id[j]] << endl;
        }
    ll tmp = 0LL;
    rep(i, n - 1) tmp += c[i];
    // ans /= 2;
    assert(ans == tmp);
    cout << tmp << '\n';
    rep(i, n) {
        cout << c[id[i]] << (i + 1 == n ? '\n' : ' ');
    }
    // dumpV(c);
    return 0;
}

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

int main()
{
	int x, i = 1;
	
	while(1)
	{
		cin >> x;
		if(x == 0) break;
		cout << "Case" << " " << i << ":" << " " << x << endl;
		i = i + 1;
	}
	return 0;
}

Measured memory_bytes: 1156
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 

 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
 
 
 
const int N = 2e5 + 10;
const int LG = 20;
const int mod = 998244353;

// int arr[N];
int n, k, p, x, y;
int arr[] = {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};
void solve()
{
	int k;
	cin >> k;
	cout << arr[k - 1] << endl;
} 

int32_t main() 
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int t;
    t = 1;
    // cin >> t;
    while(t--)
    	solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define pb emplace_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

int main(){
    fastio;
		
	lli n, w; cin >> n >> w;
	lli dp[w+1][n+1]; memset(dp, 0, sizeof(dp));
	lli weight[n+1], value[n+1];
	for(int i=1; i<n+1; i++){
		cin >> weight[i] >> value[i];
	}
	
	for(int i=1; i<w+1; i++){
		for(int j=1; j<n+1; j++){
			if(weight[j] <= i){
				dp[i][j] = max(dp[i-weight[j]][j-1]+value[j], dp[i][j-1]);
			}else{
				dp[i][j] = dp[i][j-1];
			}
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	
	cout << dp[w][n] << endl;
	return 0;
}


Measured memory_bytes: 79232
# https://atcoder.jp/contests/abc103/tasks/abc103_d

# ToDo not yet

# biについて昇順にソートする
# それぞれのbiについて、
# 1: すでに分断されているなら何もしない
# 2: 分断されていないならbi - 1番目の橋を切断する

N, M = map(int, input().split())
demand_list = []
for _ in range(M):
    ai, bi = map(int, input().split())
    demand_list.append([ai, bi])

# ソート
demands = sorted(demand_list, key=lambda d: d[1])

# 分断開始 切断されている橋は1で表現される
# cut_bilagge_list = [0 for _ in range(N)]
cnt = 0
cut_max_len = -1

for demand in demands:
    a, b = demand
    # すでに分断されているのかをチェックする
    if a < cut_max_len:
        continue
    # if len([1 for i in cut_bilagge_list[demand[0] - 1:demand[1] - 1] if i == 1]) > 0:
    #     continue

    # 分断されていないので bi - 2の橋を切断する
    # cut_bilagge_list[demand[1] - 2] = 1
    cut_max_len = b
    cnt += 1

# print(sum(1 for bilagge in cut_bilagge_list if bilagge == 1))
print(cnt)


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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18+9
#define sz(a) ((int)a.size())

void solve(){
  int n; cin>>n; 
  vector<int> h(n),dp(n+1); 
  for(int i=0;i<n;i++){
    cin>>h[i]; 
  }
  h.push_back(h.back()); 
  for(int i=n-2;i>=0;i--){
    dp[i]=min(dp[i+1]+abs(h[i+1]-h[i]),dp[i+2]+abs(h[i+2]-h[i])); 
  }
  cout<<dp[0]<<endl; 
}

int main(){
	fast_io;
	clock_t beg=clock();
  int t; 
  t=1; 
  //cin>>t; 
  while(t--){
	  solve();
  }
	clock_t end=clock();
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

N = inp()
p = [0] + list(map(float, input().split()))
dp = [[0] * (N + 1) for i in range(N + 1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(0, i+1):
        if j > 0:
            dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i]
        else:
            dp[i][j] = dp[i-1][j] * (1 - p[i])
ans = 0
for j in range(N//2 + 1, N + 1):
    ans += dp[N][j]
print(ans)

Measured memory_bytes: 206308
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const double pi = acos(-1.0);

int main() {
    int n;
    cin >> n;
    VD x(n), y(n);
    REP(i,n){
        x[i] = in();
        y[i] = in();
    }
    int m = 1e6;
    double ans = 0.0;
    REP(i,m){
        double theta = pi * i / m;
        double ex = cos(theta), ey = sin(theta);
        double sx = 0, sy = 0, gx = 0, gy = 0;
        // cout << ex << " " << ey << endl;
        REP(j,n){
            double v = ex * x[j] + ey * y[j];
            if (v > 0){
                sx += x[j];
                sy += y[j];
            }else if (v < 0){
                gx += x[j];
                gy += y[j];
            }
        }
        chmax(ans, sx * sx + sy * sy);
        chmax(ans, gx * gx + gy * gy);
    }
    ans = sqrt(ans);
    printf("%.15f\n", ans);

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int n,k[112345],sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k[i];
    sum+=k[i];
  }
  if(sum%2==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 640
n,k=map(int,raw_input().split())
a=[0]*(n+1)
for i in range(k):
    d=input()
    b=map(int,raw_input().split())

    for j in range(d):
        a[b[j]]=1

    
a[0]=1
c=0
for i in range(len(a)):
    if a[i]==0:
        c+=1
print c

Measured memory_bytes: 69816