akhauriyash/Code-Regression huggingface dataset:
import math

s = input()
list = list(s)


num = math.floor(len(s)/2)
count = 0


if len(s) == 3:
    if list[0] == list[2]:
        print("Yes")
    else:
        print("No")


else:
    
    for i in range(num):
        if list[i] == list[num+1+i]:
            count += 1
        else:
            print("No")
            break

if len(s) == 3:
    None
else:
    if count == num:
        print("Yes")
    else:
        None


Measured memory_bytes: 3064
#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) unique(v.begin(), 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> >
#define INF 10000000
#define MAX_V 50
typedef long long ll;
typedef pair<int, int> P;

int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;
/*struct edge {
	int to, cost;
};*/
//vector<edge> G[MAX_V];

// O(|V^2|)
void dijkstra(int s) {
	fill(d, d + V, INF);
	fill(used, used + V, false);
	d[s] = 0;

	while(true) {
		int v = -1;
		rep(u, 0, V) {
			if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if(v == -1) break;
		used[v] = true;
		rep(u, 0, V) d[u] = min(d[u], d[v] + cost[v][u]);
	}
}

// O(ElogV)
/*
void dijkstra(int s) {
	fill(d, d + V, INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(make_pair(0, s)); // distance, index)

	while(!q.empty()) {
		P p = q.top();
		q.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		rep(i, 0, G[V].size()) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
}
*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M;
	cin >> V >> M;
	int res = 0;
	P p[M];
	rep(i, 0, V) rep(j, 0, V) cost[i][j] = INF;

	rep(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		cost[a][b] = 1;
		cost[b][a] = 1;
		p[i] = make_pair(a, b);
	}

	rep(i, 0, M) {
		int a = p[i].first;
		int b = p[i].second;
		cost[a][b] = INF;
		cost[b][a] = INF;
		dijkstra(0);
		rep(k, 1, V) {
			if(d[k] == INF) {
				res++;
				break;
			}
		}
		cost[a][b] = 1;
		cost[b][a] = 1;
	}
	cout << res << endl;


}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

i64 extgcd(i64 a,i64 b,i64 &x,i64 &y){
	i64 d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	} else {
		x=1; y=0;
	}
	return d;
}

i64 mod_inverse(i64 a,i64 m){
	i64 x,y;
	if(extgcd(a,m,x,y)==1) return (x+m)%m;
	return 0;
}

vector<i64> fact(200000);

i64 mod_comb(i64 n,i64 k,i64 p){
    if(n<0 or k<0 or n<k) return 0;
    i64 num=fact[n]*mod_inverse(fact[n-k],p)%p,den=fact[k];
    /*
    for(i64 i=0; i<k; ++i){
        num=num*((n-i)%p)%p;
        den=den*(i+1)%p;
    }
    return num*mod_inverse(den,p)%p;
    */
    return num*mod_inverse(den,p)%p;
}

void solve(){
    i64 mod=1000000007;
    fact[0]=1;
    rep(i,1,200000) fact[i]=fact[i-1]*i%mod;

    i64 n;
    cin >> n;
    vector<i64> a(n+2);
    vector<int> pos(n+1,-1);
    int x,y;
    rep(i,1,n+2){
        cin >> a[i];
        if(pos[a[i]]!=-1){
            x=pos[a[i]];
            y=i;
        }else pos[a[i]]=i;
    }
    rep(k,1,n+2) cout << (mod_comb(n+1,k,mod)-mod_comb(n+1-y+(x-1),k-1,mod)+mod)%mod << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define ll  long long
#define ld	long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"

const ll MOD2 = 998244353;
const ll MOD = 1000*1000*1000 + 7;	
const ll N  = 1000*1000+5;
const double PI  = 3.14159265;

int main()
{
	ll n,k;
	cin>>n>>k;
	std::vector<pii> v;
	ll total = n*(n-1);
	total/=2;
	for (int i = 2; i <=n; ++i)
	{
		v.pb(mp(1,i));
		total--;
	}
	if(k>total)
	{
		cout<<-1;
		return 0;
	}	
	else if(k==total)
		goto y;
	else
	{
		for (int i = 2; i < n; ++i)
		{
			for (int j = i+1; j <= n; ++j)
			{
				v.pb(mp(i,j));
				total--;
				if(k==total)
					goto y;			
			}
		}
	}
	y:
	cout<<v.size()<<endl;
	for(auto x: v)
		cout<<x.ff<<" "<<x.ss<<endl;
	return 0 ;
}

Measured memory_bytes: 512
from collections import Counter

S = list(map(int,list(input())))
S.reverse()
N = len(S)
L = [0]
power = 1
for i in range(N):
    L.append((L[-1] + S[i] * power) % 2019)
    power *= 10
    power %= 2019
count = Counter(L)
ans = 0
for value in count.values():
    ans += value * (value - 1) // 2
print(ans)

Measured memory_bytes: 96548
(let ((n (read))
    (l (make-array 87)))
    (setf (aref l 0) 2)
    (setf (aref l 1) 1)
    (loop for i from 2 to n do
        (setf (aref l i) (+ (aref l (- i 2)) (aref l (- i 1))))
    )
    (princ (aref l n))
)

Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    
    int arr[3];
    arr[0]=a+b;
    arr[1]=a-b;
    arr[2]=a*b;
    sort(arr,arr+3);
    cout<<arr[2];
}

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

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

    for(int i = 1; i <= b; i++) {
        int amari = i*a%b;
        if(amari == c) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   vector<int> a(3); 
   cin >> a[0] >> a[1] >> a[2];
   sort(a.begin(), a.end());
   cout << a[0] << " " << a[1] << " "  << a[2] << endl;
   return 0;
}


Measured memory_bytes: 3140
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int K = Integer.parseInt(sc.next());
        long sum = 0;
        for (int i = 1; i <= K; i++)
            for (int j = 1; j <= K; j++)
                for (int m = 1; m <= K; m++)
                    sum += gcd(i,j,m);
        out.println(sum);
        
        out.flush();
    }
    public static int gcd(int x, int y, int z) {
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }
        while ((tmp = y % z) != 0) {
            y = z;
            z = tmp;
        }
        return z;
    }
}

Measured memory_bytes: 35856
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e9;
const int Bmax=2e5;
const int Nd=61;


int main(){
  int n,k; cin>>n>>k;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];

  for(int i=k; i<n;i++){
    if(a[i-k]<a[i]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 4788
s=input()
t=input()
n=len(s)
word="abcdefghijklmnopqrstuvwxyz"
data_s=[[] for i in range(26)]
data_t=[[] for i in range(26)]
for i in range(26):
    a=word[i]
    for j in range(n):
        if s[j]==a:
            data_s[i].append(j)
        if t[j]==a:
            data_t[i].append(j)
data_s.sort()
data_t.sort()
if data_s==data_t:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 66748
n,m=map(int,input().split())
h=list(map(int,input().split()))
g=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>=h[b-1]:
        g[b-1]=0
    if h[b-1]>=h[a-1]:
        g[a-1]=0
print(sum(g))

Measured memory_bytes: 20116
// *3 or /2

#include <iostream>

using namespace std;

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

	int res = 0;

	while(1){
		bool missflag = true;
		for (int i = 0; i < N; ++i){
			if (a[i] % 2)
				continue;
			else{
				a[i] /= 2;
				res++;
				missflag = false;
			}
		}
		if (missflag)
			break;
	}

	cout << res << endl;

	return 0;
}

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

int main(){
    int a, b , c;
    cin >> a >> b >> c;
    if (a != b && a != c && b != c){
        cout << 3 << endl;
    }
    else if (a == b && b == c){
        cout << 1 << endl;
    }
    else {
        cout << 2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int H,W;
    cin >> H >> W;
    vector<string> s(H);
    REP(i, H){
        cin >> s[i];
    }

    int dx[8]={-1,1,0,0,1,1,-1,-1}, dy[8]={0,0,-1,1,1,-1,-1,1};
    REP(i, H){
        REP(j, W){
            if(s[i][j] == '#') {
                cout << '#';
                continue;
            }
            int ans = 0;
            REP(k, 8){
                int x = i + dx[k];
                int y = j + dy[k];
                if(0 <= x && x < H && 0 <= y && y < W){
                    if(s[x][y] == '#') ans++;
                }
            }
            cout << ans;
        }
        cout << endl;
    }
}

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

using namespace std;

using ll = long long int;

ll a[100000];
ll sum[200001];
int n;

inline ll modloop(int a_, int b_)
{
	return (a_ >= 0) ? (a_ % b_) : ((a_ % b_) + b_);
}

inline ll piece(int a_)
{
	return a[modloop(a_, n)];
}

inline ll width(int a_,int b_)
{
	a_ = modloop(a_, n);
	b_ = modloop(b_, n);
	if (a_ < b_ + 1)
	{
		return sum[b_ + 1] - sum[a_];
	}
	else
	{
		return sum[n] - sum[b_ + 1] + sum[a_];
	}
}

bool cir(int cut,ll x)
{
	int seccut = lower_bound(sum + cut, sum + n + n, sum[cut] + x) - sum;
	int thrcut = lower_bound(sum + seccut, sum + n + n, sum[seccut] + x) - sum;
	if (sum[cut + n] - sum[thrcut] >= x)return true;
	return false;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)scanf("%lld", a + i);
	sum[0] = 0;
	for (int i = 0; i < n; ++i)sum[i + 1] = sum[i] + a[i];
	for (int i = n; i < 2 * n;++i)sum[i + 1] = sum[i] + a[i - n];
	ll ans = 0;
	for (int cut = 0; cut < n; ++cut)
	{
		ll min = 1;
		ll max = sum[n] / 3 + 1;
		for (int i = 0; i < 100; ++i)
		{
			ll mid = (min + max) / 2;
			if (cir(cut,mid))
			{
				min = mid;
			}
			else
			{
				max = mid;
			}
		}
		ans = (ans > min) ? ans : min;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll t=0ll, ans =0ll;
	string s;
	cin >> s;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		if(s[i]=='B'){
			++t;
		}else{
			ans += t;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int n, rem;

    cin >> n;

    rem = n % 10;

    if (rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9)
    {
        cout << "hon" << endl;
    }
    else if (rem == 0 || rem == 1 || rem == 6 || rem == 8)
    {
        cout << "pon" << endl;
    }
    else if (rem == 3)
    {
        cout << "bon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define int  long long
using namespace std;
const int Mod=1e9+7,maxn=1e5+10;
char s[maxn];
int p[30],ans,n;
int dfs(int x,int y,int z,int s)
{
	if(!s)
		return 0;
	if(y==z)
		return s;
	int sum=0;
	sum=dfs(x+1,y+1,z,s*p[x]%Mod);
	if(26-x+1>z-y)
		sum+=dfs(x+1,y,z,s);
	return sum%Mod;
}
signed main()
{
	scanf("%lld%s",&n,s+1);
	for(register int i=1;i<=n;i++)
		p[s[i]-'a'+1]++;
	for(register int i=1;i<=26;i++)
		(ans+=dfs(1,0,i,1))%=Mod;
	printf("%lld",ans%Mod);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main (){
    int x=0;
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i]=='+'){
            x+=1;
        }else if(s[i]=='-'){
            x-=1;
        }
    }
    cout << x;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W = MI()
    N=10
    def warshall_floyd(d, N):
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    d[i][j]=min(d[i][j], d[i][k] + d[k][j])

    d=[[float("inf")] * N for i in range(N)]
    for i in range(N):
        d[i][i] = 0
    
    #-------辺入力------
    for i in range(N):
        C = LI()
        for j in range(N):
            d[i][j] = min(d[i][j], C[j])
    warshall_floyd(d, N)

    to = 1
    ans = 0
    for i in range(H):
        wall = LI()
        for j in range(W):
            num = wall[j]
            if num==-1:
                continue
            # print(num,d[num][to])
            ans += d[num][to]
    # print(*d,sep="\n")
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,a[100];
    cin>>n;
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=n;i++)
        a[i]=a[i-1]+a[i-2];
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
H[0] += -1

ans = "Yes"

for i in range(N-1):
  if H[i] > H[i+1]:
    ans = "No"
    break
  if H[i] < H[i+1]:
    H[i+1] += -1
    
print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,ss;
	cin>>s;
	ss=s;
	int len=s.length();
	for(int i=0;i<len/2;i++)
		swap(s[i],s[len-i-1]);
	for(int i=0;i<len;i++)
		switch(s[i])
		{
			case'b':s[i]='d';break;
			case'd':s[i]='b';break;
			case'p':s[i]='q';break;
			case'q':s[i]='p';break;
		}
	if(ss==s)cout<<"Yes";
		else cout<<"No";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,m,i,j,l,ans=0;
  cin>>n>>m;
  vector<int64_t> a(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  for(i=29;i>=0;i--){
    l=distance(a.begin(),lower_bound(a.begin(),a.end(),(1L<<i)));
    if(m>=n-l){
      for(j=l;j<n;j++) a.at(j)/=2;
      m-=n-l;
    }
    else break;
  }
  sort(a.begin(),a.end());
  for(i=max(0L,n-m);i<n;i++) a.at(i)/=2;
  for(i=0;i<n;i++) ans+=a.at(i);
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

using Graph = vector<vector<int>>;
Graph G;
int dfs(int u, int p=-1) {
  int g = 0;
  for (auto v : G[u]) {
    if (v == p) continue;
    g ^= (dfs(v, u) + 1);
  }
  return g;
}

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

  G = Graph(N);
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  cout << ((dfs(0) != 0) ? "Alice" : "Bob") << endl;
  return 0;
}


Measured memory_bytes: 10368
n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a } 
def cb(i);	i==1 ? 1 : -1;end
sum_cakes, ans = 0, 0
for i in 0..7 do
  sum_cakes = cakes.map { |cake|  cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
  ans = sum_cakes if sum_cakes &.> ans
end
puts ans

Measured memory_bytes: 2168
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete


main = getInts >>= putStrLn . cond "yes" "no" . (>=2) . length . filter (apply2 (==)) . splitRec 2 . sort



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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n;
    cin >> n;
    int ans[n];
    int a[n];
    map<int,int> mp;
    for(int i=1;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
    }

    for(int i=1;i<=n;i++){
        cout << mp[i] << endl;
    }
}

Measured memory_bytes: 13784
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

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


int H[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	REP(i, N) {
		cin >> H[i];
	}
	int ans = 0;
	int cnt = 0;
	for (int i = N - 2; i >= 0; i--) {
		if (H[i] >= H[i + 1]) {
			cnt++;
		}
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	print(ans);
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>

void transferToGengo(int, int, int);

int main(void)
{
    int year, month, day;
    
    while (scanf("%d%d%d", &year, &month, &day) != EOF) {
        transferToGengo(year, month, day);
    }
    
    return 0;
}

void transferToGengo(int year, int month, int day)
{
    //年月日をくっつけて、大小を比較する。
    //intが16bitだと死ぬので32bitで指定する。
    int32_t year_month_day = year * 10000 + month *100 + day;
    
    if (year_month_day < 18680908) {
        printf("pre-meiji\n");
    } else if (year_month_day <= 19120729) {
        printf("meiji %d %d %d\n", year-1868+1, month, day);
    } else if (year_month_day <= 19261224) {
        printf("taisho %d %d %d\n", year-1912+1, month, day);
    } else if (year_month_day <= 19890107) {
        printf("showa %d %d %d\n", year-1926+1, month, day);
    } else {
        printf("heisei %d %d %d\n", year-1989+1, month, day);
    }

}

Measured memory_bytes: 1036
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int k = sc.nextInt(), n = sc.nextInt();
        int[] ds = new int[n];
        for (int i = 0; i < n; i++) {
            ds[i] = sc.nextInt();
        }

        int max = k - ds[n - 1] + ds[0];
        for (int i = 0; i < n - 1; i++) {
            max = Math.max(max, ds[i + 1] - ds[i]);
        }

        out.println(k - max);
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

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

dp=[-1 for _ in range(N+1)]
def Lu(n):
    if n==0:
        rec=2
    elif n==1:
        rec=1
    elif dp[n]!=-1:
        return dp[n]
    else:
        rec=Lu(n-1)+Lu(n-2)
    dp[n]=rec
    return rec
print(Lu(N))


Measured memory_bytes: 3060
import java.util.*;

class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str = sc.next();
      
      if(str.matches("[A-Z]")){
	      System.out.println("A");
      }else if(str.matches("[a-z]")){
        System.out.println("a");
      }
	}
}

Measured memory_bytes: 35724
def main():
    N = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    Alice = 0
    Bob = 0
    for i in range(N):
        if(i%2==0):
            Alice = Alice + a[i]
        else:
            Bob = Bob + a[i]
    ans = Alice - Bob
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	int p[3],j[2],min=3000,f;
	for(int i=0;i<3;i++) scanf("%d",&p[i]);
	for(int i=0;i<2;i++) scanf("%d",&j[i]);
	for(int i=0;i<3;i++) for(int k=0;k<2;k++) if(min>p[i]+j[k]-50) min= p[i]+j[k]-50;
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = 1e15;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "03"
const int mxN = 1e5+5;
int n,m,ss,t;
vii G[mxN];
int cnt1[mxN], cnt2[mxN];
int dist1[mxN], dist2[mxN];
bool visited[mxN];
int Pow(int val)
{
	return val*val%mod;
}
void djikstra(int s, int* dist, int* cnt)
{
	priority_queue<pii,vii,greater<pii>> pq;
	pq.push(mp(0,s));
	for(int i=0;i<=n;i++)
	{
		dist[i]=mx;
		visited[i]=false;
	}
	cnt[s]=1;
	dist[s]=0;
	while(!pq.empty())
	{
		int u=pq.top().se;
		int d=pq.top().fi;
		pq.pop();
		if(visited[u] or d!=dist[u])
			continue;
		visited[u]=true;
		for(auto v:G[u])
		{
			if(!visited[v.fi] and dist[v.fi]>dist[u]+v.se)
			{
				cnt[v.fi]=cnt[u];
				dist[v.fi]=dist[u]+v.se;
				pq.push(mp(dist[v.fi],v.fi));
			}
			else if(dist[v.fi]==dist[u]+v.se)
			{
				cnt[v.fi]+=cnt[u];
				cnt[v.fi]%=mod;
			}
		}
	}
}
signed main()
{
//    freopen(file".inp","r",stdin);
//    freopen(file".out","w",stdout);
//    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>m>>ss>>t;
    for(int i=0,u,v,w;i<m;i++)
	{
		cin>>u>>v>>w;
		G[u].eb(v,w);
		G[v].eb(u,w);
	}
//	cout<<"here";
	djikstra(ss,dist1,cnt1);
	djikstra(t,dist2,cnt2);
//	cout<<"here";
//	cout<<cnt1[t]<<" "<<cnt2[s]<<endl;
	int Dist=dist1[t], ans=cnt1[t]*cnt2[ss]%mod;
	if(Dist%2==0)
		for(int i=1;i<=n;i++)
			if(dist1[i]*2==Dist and dist1[i]+dist2[i]==Dist)
				ans = (ans-Pow(cnt1[i]*cnt2[i]%mod)%mod+mod)%mod;
	for(int u=1;u<=n;u++)
	{
		for(auto v:G[u])
		{
			if(dist1[u]+dist2[v.fi]+v.se==Dist and dist1[u]*2<Dist and dist2[v.fi]*2<Dist)
//				cout<<u<<" "<<v.fi<<endl;
				ans = (ans-Pow(cnt1[u]*cnt2[v.fi]%mod)%mod+mod)%mod;
		}
	}
	while(ans<0) ans+=mod;
	cout<<ans%mod;
}


Measured memory_bytes: 21824
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,k;
	cin>>n>>k;
	vector<int>height;
	for(int i=0;i<n;i++)
	{
	    int x;
	    cin>>x;
	    height.push_back(x);
	}
	vector<int>dp(n,INT_MAX);
	dp[0]=0;
// 	cout<<k<<endl;
	for(int i=0;i<n;i++)
	{
	   // cout<<i+1<<"  "<<k+i<<endl;
	    for(int j=i+1;j<=k+i;j++)
	    {
	        if(j<n)
	        {
	            dp[j]=min(dp[j],dp[i]+abs(height[i]-height[j]));
	        }
	    }
	}
// 	for(int i=0;i<n;i++)
// 	    cout<<dp[i]<<"  ";
// 	  cout<<endl;
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4036
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String O = sc.nextLine();
        String E = sc.nextLine();
        int cunt = 0;

        String[] ansO =  O.split("");
        String[] ansE =  E.split("");

        if(O.length() < E.length()){
            cunt = E.length();
        }else{
            cunt = O.length();
        }

        for(int i=0; i<cunt; i++){
            if(i < E.length() && i < O.length()){
                System.out.print(ansO[i] + ansE[i]);
            }else if(i == E.length()){
                System.out.print(ansO[i]);
            }else if(i == O.length()){
                System.out.print(ansE[i]);
            }
        }
    }
}

Measured memory_bytes: 21844
n = int(input())
D = {}
for _ in range(n):
  str = "".join(sorted(input()))
  if str in D:
    D[str] += 1
  else:
    D[str] = 1
ans = 0
for i in D.values():
  ans += i * (i-1) // 2
print(ans)


Measured memory_bytes: 17852
#include<stdio.h>
int main(void){
  int n,i,sub;
  int max=0,end=0;
  int count=0;
  scanf("%d",&n);
  int maxnum=n;

  for(i=n;i>0;i--){
    sub=i;
    do{
      if(sub%2==0){
        count++;
        sub=sub/2;
      }else end=1;
    }while(end==0);
    
    if(max<count){
      max=count;
      maxnum=i;
    }
    end=0;
    count=0;
  }
  printf("%d",maxnum);
   
  return 0;
  
}

Measured memory_bytes: 128
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}

signed main(){
    int n;
    cin >> n;
    
    vint d;
    d.resize(n);
    in(d);
    sort(all(d));
    
    cout << d[n / 2] - d[n / 2 - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a=ss()

if 65<= ord(a) <=90:
    print("A")
else:
    print("a")

Measured memory_bytes: 37432
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e5+5;

int32_t main(){
    int n, W; cin >> n >> W;
    // ll dp[n+1][W+1];
    vc < vc<ll> > dp(n+1, vc <ll> (W+1, 0));
    vc <ll> w(n);
    vc <ll> val(n);
    for(int i=0; i<n; i++) {
        cin >> w[i] >> val[i];
    }
    for(int i=0; i<=n; i++) {
        for(int wt=0; wt<=W; wt++) {
            if(!i || !wt) dp[i][wt] = 0;
            else if(w[i-1] > wt) {
                dp[i][wt] = dp[i-1][wt];
            } else {
                dp[i][wt] = max(dp[i-1][wt], val[i-1] + dp[i-1][wt-w[i-1]]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max()/100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
vector<LL>rest;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000],dp[300000];
string str;
bool f;
char c[1100][1100];
LL dfs(LL cur,LL par,LL num) {
	LL ret = k - num, sum = 1;
	if (ret < 0)ret = 0;
	if (par != -1)sum++;
	rep(i, g[cur].size()) {
		LL v = g[cur][i];
		if (v == par)continue;
		ret*=dfs(v, cur, sum);
		sum++;
		ret %= MOD;
	}
	dp[cur] = ret;
	return dp[cur]%MOD;
}
int main() {
	cin >> n>>k;
	g.resize(n);
	rep(i, n-1) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cout << dfs(0, -1, 0) << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;

class Problem
{
private:
	// Variables
	int x, a, b;
	
public:
	// Methods
	void input ()
	{
		cin >> x >> a >> b;
	}
	
	void process ()
	{
		
	}
	
	void output ()
	{
		cout << ( b <= a+x ? ( b <= a ? "delicious" : "safe" ) : "dangerous" ) << endl;
	}
};

int main ()
{
	Problem problem;
	problem.input();
	problem.process();
	problem.output();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3005;
const int S = 3002;
const int mod = 998244353;

ll n,s,a[N];
ll dp[N][S],inv2;

ll fp(ll x,ll y){
    if(!y) return 1;
    ll p = fp(x,y/2);
    p = (p*p)%mod;
    if(y&1) p = (p*x)%mod;
    return p;
}

ll minv(ll x){
    return fp(x,mod-2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    inv2 = minv(2);
    cin >> n >> s;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[0][0] = fp(2,n);
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= s; j++){
            dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
            if(j >= a[i]){
                dp[i][j] = (dp[i][j]+(inv2*dp[i-1][j-a[i]])%mod)%mod;
            }
        }
    }
    cout << dp[n][s] << endl;
}


Measured memory_bytes: 74028
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }
  int ans = 0;
  rep(i, N) {
    if (A[A[i]] == i)
      ans++;
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define mod 1000000007
#define size_f 100002
int main()
{
   int x,a;
   cin>>x>>a;

   if(x<a)
      cout<<"0\n";
   else
     cout<<"10\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

int arr[400];
int main(void)
{
    int n;
    cin >> n;
    bool color[8] = {0};
    int cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        int s;
        cin >> s;
        s /= 400;
        if (s < 8)
            color[s] = true;
        else
            cnt++;
    }
    int cnt_c = 0;
    for (int i = 0; i < 8; ++i)
        if (color[i])
            cnt_c++;
    cout << max(1, cnt_c) << " " << cnt_c + cnt << endl;
    return 0;
}

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


int main() {
  int n,m;
  string s,t;
  getline(cin, s);
  getline(cin, t);
  int S = s.size();
  int T = t.size();
  int all_count = 1000;
  int count = 0;
  string r;
  char x,y;
  for(int i = 0; i<S-T+1; i++){
    r = s.substr(i,T);
    count = 0;
    for(int j=0; j<T; j++){
      x = r.at(j);
      y = t.at(j);
      if(x != y){
        count++;
      }
    }
    if(all_count > count){
      all_count=count;
    }
  }
  cout << all_count << endl;
}

Measured memory_bytes: 3632
'use strict'

function main(s) {

  let nums = s.split('\n')[1].split(' ').map(e => Number(e));

  let canDivide = true;
  let count = 0;

  while(canDivide) {
      for (var i = 0; i < nums.length; i++) {
        if (nums[i] % 2 === 0) {
          nums[i] = nums[i] / 2;
        } else {
          canDivide = false;
        }
      }
      if (canDivide) count++;
  }

  console.log(count);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
const double pi = 3.14159265358979323846;

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

	int r;
	cin >> r;
	printf("%.10f\n", 2 * pi * r);
}

Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var s = ReadInts();
            

            var m = ReadInt();
            for (int i = 0; i < m; i++)
            {
                var list = new List<int>(s);
                var px = ReadInts();
                list[px[0] - 1] = px[1];
                WriteLine(list.Sum());
            }

        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13268