akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int cnt[101];
int main() {
	int N;
	cin >> N;
	int M = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
		M = max(M, a);
	}
	if (N == 2) {
		if (cnt[1] != 2) cout << "Impossible" << endl;
		else cout << "Possible" << endl;
		return 0;
	}
	if (cnt[1] > 0) {
		if (cnt[2] != N - 1) cout << "Impossible" << endl;
		else cout << "Possible" << endl;
		return 0;
	}
	bool ok = 1;
	if (M % 2) {
		int m = (M + 1) / 2;
		for (int i = M; i > m; i--) {
			if (cnt[i] < 2) ok = 0;
		}
		for (int i = 1; i < m; i++) {
			if (cnt[i] > 0) ok = 0;
		}
		if (cnt[m] != 2) ok = 0;
	}
	else {
		int m = M / 2;
		for (int i = M; i > m; i--) {
			if (cnt[i] < 2) ok = 0;
		}
		for (int i = 1; i < m; i++) {
			if (cnt[i] > 0) ok = 0;
		}
		if (cnt[m] != 1) ok = 0;
	}
	if (ok) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	char c;
	cin >> c;
	switch (c)
	{
	case 'a':
	case'i':
	case 'u':
	case'e':
	case'o':
		cout << "vowel";
			break;
	default:
		cout << "consonant";
		break;
	}

	return 0;
}

Measured memory_bytes: 256
R=range(9)
def f1(M):
  global F
  for y in R:
    A=M[y]
    for x in R:
      if A.count(A[x])>=2: F[y][x]="*"
  return
def f2(M):
  global F
  for x in R:
    A=[M[y][x] for y in R]
    for y in R:
      if A.count(A[y])>=2: F[y][x]="*"
  return
def f3(M):
  global F
  for i in R:
    x=i%3*3
    y=i/3*3
    A=M[y][x:x+3]+M[y+1][x:x+3]+M[y+2][x:x+3]
    for j in R:
      if A.count(A[j])>=2: F[y+j/3][x+j%3]="*"
  return

n=input()
while n:
  M=[]
  F=[[" " for _ in [0]*9] for _ in [0]*9]
  M=[map(int,raw_input().split()) for _ in [0]*9]
  f1(M)
  f2(M)
  f3(M)
  for i in R:
    s=zip(F[i],map(str,M[i]))
    print "".join([a+b for a,b in s])
  if n>1: print
  n-=1

Measured memory_bytes: 4304
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define all(a) (a.begin(),a.end())
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e10 ;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1 ;
  //cin>>t ;
  while(t--)
  {
     char ch ;
     cin>>ch;
     ll y = ch ;
     if(y>=65 && y<=91) cout<<"A\n";
     else cout<<'a';
  }
  return 0;

}


Measured memory_bytes: 3592
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int lis[100000];
int main(){
    for(int i=2;i<100000;i++)lis[i]=1;
    for(int i=2;i<330;i++){
        if(lis[i]){
            for(int j=2;;j++){
                if(100000<=i*j)break;
                lis[i*j]=0;
            }
        }
    }
    int a;
    while(cin>>a){
        for(int i=-1;;i--){
            if(lis[a+i]){
                cout<<a+i;
                break;
            }
        }
        cout<<" ";
        for(int i=1;;i++){
            if(lis[a+i]){
                cout<<a+i;
                break;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1544
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3fffffff
using std::min;
struct node
{
    int l,r,v;//维护区间最小值
    node(int l,int r)
    {
        this->l=l;
        this->r=r;
        v=inf;
    }
    node()
    {
        v=inf;
    }
}t[2010000];
void build(int k,int l,int r)
{
    t[k]=node(l,r);
    if(l==r)
        return;
    int mid=(l+r)>>1;
    build(ls,l,mid);
    build(rs,mid+1,r);
}
void change(int k,int p,int x)
{
    if(t[k].l==t[k].r)
    {
        t[k].v=x;
        return;
    }
    int mid=(t[k].l+t[k].r)>>1;
    if(p<=mid)
        change(ls,p,x);
    else
        change(rs,p,x);
    t[k].v=min(t[ls].v,t[rs].v);
}
int ask(int k,int l,int r)
{
    if(r<t[k].l||l>t[k].r)
        return inf;
    if(l<=t[k].l&&r>=t[k].r)
        return t[k].v;
    return min(ask(ls,l,r),ask(rs,l,r));
}
struct edge
{
    int n,nxt;
    edge(int n,int nxt)
    {
        this->n=n;
        this->nxt=nxt;
    }
    edge(){}
}e[1010000];
int in[1010000],head[1010000],ecnt=-1;
void add(int from,int to)
{
    e[++ecnt]=edge(to,head[from]);
    head[from]=ecnt;
    ++in[to];
}
int a[500500],b[500500];
int heap[500500],l=0;
void Push(int x)
{
    heap[++l]=x;
    int i=l;
    while(i>1&&heap[i]<heap[i>>1])
    {
        int tmp=heap[i];
        heap[i]=heap[i>>1];
        heap[i>>1]=tmp;
        i>>=1;
    }
}
void pop()
{
    heap[1]=heap[l--];
    int i=1;
    while(i<<1<=l&&(heap[i]>heap[i<<1]||heap[i]>heap[i<<1|1]))
    {
        if(heap[i<<1]<heap[i<<1|1]||i<<1==l)
        {
            int tmp=heap[i];
            heap[i]=heap[i<<1];
            heap[i<<1]=tmp;
            i<<=1;
        }
        else
        {
            int tmp=heap[i];
            heap[i]=heap[i<<1|1];
            heap[i<<1|1]=tmp;
            i=i<<1|1;
        }
    }
}
int ans[500500],cnt=0;
int main()
{
    memset(head,-1,sizeof(head));
    int n,m,u;
    scanf("%d%d",&n,&m);
    build(1,1,n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&u);
        a[u]=i;
    }
    for(int i=n;i;--i)
    {
        int tmp=ask(1,a[i]+1,a[i]+m-1);
        if(tmp!=inf)
            add(a[i],a[tmp]);
        tmp=ask(1,a[i]-m+1,a[i]-1);
        if(tmp!=inf)
            add(a[i],a[tmp]);
        change(1,a[i],i);
    }
    for(int i=1;i<=n;++i)
        if(!in[i])
            Push(i);
    while(l)
    {
        int x=heap[1];
        ans[x]=++cnt;
        pop();
        for(int i=head[x];~i;i=e[i].nxt)
        {
            --in[e[i].n];
            if(!in[e[i].n])
                Push(e[i].n);
        }
    }
    for(int i=1;i<=n;++i)
        printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 50688
import java.util.Scanner;
public class Main{
	int x;
	
	public void solve(){
	    Scanner sc = new Scanner(System.in);
		x=sc.nextInt();
    	System.out.println(x*x*x);
	
	
}

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

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

int64_t lucas(int N){
  if(N == 0){
    return 2;
  }
  
  if(N == 1){
	return 1;
  }
  
  int64_t a = 2, b = 1;
  int i = 2;
  int64_t c = 1;
  while(i <= N){
    if(i%2 == 0){
	  c += a;
      a = c;
    }
    else{
	  c += b;
      b = c;
    }
    i++;
  }
  return c;
}

int main(){
  int N;
  cin >> N;
  /*
  if(N == 0){
    return 2;
  }
  
  if(N == 1){
	return 1;
  }
  
  int64_t a = 2, b = 1;
  int i = 2;
  int64_t c = 1;
  while(i <= N){
    if(i%2 == 0){
	  c += a;
      a = c;
    }
    else{
	  c += b;
      b = c;
    }
    i++;
  }*/
  
  /*int64_t a = 2000000000;
  int64_t c = a*2;*/
  
  cout << lucas(N) << endl;
  
}
  

Measured memory_bytes: 256
def aaa(a, b):
    return abs((a // 3 * b) - ((a // 3 + 1) * b))


def bbb(a, b):
    ret = 1000 * 100
    for x in range(1, a):
        xx = a - x
        i = x * b
        j = xx * (b // 2)
        k = xx * (b // 2 + (b % 2))
        tmp = max(abs(i - j), abs(j - k), abs(k - i))
        ret = min(ret, tmp)
    return ret


H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    a = aaa(H, W)
    b = aaa(W, H)
    c = bbb(H, W)
    d = bbb(W, H)
    print(min(a, b, c, d))


Measured memory_bytes: 3064
def main():
    N, K = map(int, input().split())

    if (N - 1) * (N - 2) // 2 < K:
        print(-1)
        return

    graph = []
    for i in range(2, N + 1):
        graph.append((1, i))

    n = (N - 1) * (N - 2) // 2

    i = 2
    while K < n and i < N:
        j = i + 1
        while K < n and j < N + 1:
            graph.append((i, j))
            n -= 1
            j += 1
        i += 1

    print(len(graph))
    for p, v in graph:
        print(p, v)


main()


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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 (a>b) { a=b; return 1; } return 0; }



int main() {
    //string S; cin>>S;
    //int A,B; cin>>A>>B;
    int N; cin>>N;

    int k[]={100,101,102,103,104,105};
    vector<bool> pos(N+1,false);
    pos[0]=true;
    for (int i = 0; i <=N; ++i) {
        if (!pos[i]) continue;
        for (int j = 0; j < 6; ++j) {
            if (i + k[j] <= N) pos[i + k[j]] = true;
        }
    }
    cout<<((pos[N])?1:0)<<endl;
    return 0;
}


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

int main(){
    string n;cin>>n;
    bool all_nine = true;
    if (n.size() == 1){
        cout << n[0] << endl;
        return 0;
    }
    for (int i=1;i<n.size();i++){
        if (n[i] != '9'){
            all_nine = false;
            break;
        }
    }

    if (n.size() == 1){
        cout << n[0] << endl;
    } else {
        if (all_nine){
            int acc = 0;
            for (int i=0;i<n.size();i++){
                acc += (int)n[i] - 48;
            }
            cout << acc << endl;
        } else {
            cout << 9 * (n.size() - 1) + (int)n[0] - 49 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる

#pragma endregion

// ABC085 A-  Already 2018
int main(void) {
	char s[11];
	
	
	scanf("%s",s);
	s[3] = '8';
	printf("%s\n",s);

	return 0;
}

Measured memory_bytes: 1660
n = int(input())

def dfs(s):
    count = 0
    sub_count = 0
    
    if int(s) > n:
        return 0
    
    for i in '753':
        if s.count(i) > 0:
            sub_count += 1
        if sub_count == 3:
            count += 1
        if i == '3':
            sub_count = 0
    
    for i in '753':
        count += dfs(s + i)
    
    return count

print(dfs('0'))

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

using namespace std;


int main(){
  int k;
  int a,b;
  int i=1;

  cin >> k;
  cin >> a;
  cin >> b;
  int bai=1;
  int flag=0;
  int t=k;

  while(1){
    t = k*bai;
    if(a<=t &&  t<=b){
      cout << "OK";
      flag =1;
      break;
    }

    bai ++;
    
    if(t>b){
      break;
    }
  }

  if(flag==0){
    cout << "NG" << endl;
  }
  
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,d;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        double x,y;
        cin>>x>>y;
        double a=sqrt(x*x+y*y);
        if(a<=d) ans++;
    }
    cout<<ans;
    return 0;
}

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


def mod(x):
    return x%(10**9+7)


sum_num = 0
ans = 0
for i in range(len(a)-1):
    idx = len(a)-i-1
    sum_num += a[idx]
    sum_num = mod(sum_num)
    ans += sum_num*a[idx-1]
    ans = mod(ans)
print(ans)


Measured memory_bytes: 31436
#include<stdio.h>
int main(){
char S[10];
gets(S);
switch(S[0]){

case 'S':
    printf("Cloudy");
    break;
case 'C':
    printf("Rainy");
    break;
case 'R':
    printf("Sunny");
    break;
    default:
    break;

}
return 0;

}


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

const int INF = 1e9;
using ll = long long;

int n,m;

vector<pair<ll,ll>> es;

map<ll,ll> s;
int k = 0;
ll id(int v, int c){
    ll x = (ll)v<<32|c;
    if(s.count(x)) return s[x];
    s[x] = k++;
    return s[x];
}

set<int> cs[100010];

struct edge { int dst, wgt; };

vector<vector<edge>> g;

void ae(int a, int b, int w){
    g[a].push_back({b,w});
    g[b].push_back({a,w});
}

deque<int> q;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(cin >> n >> m){
        rep(i,n) cs[i].insert(id(i,0));
        rep(i,m){
            int a,b,c;
            cin >> a >> b >> c;
            --a; --b;
            ll x = id(a,c);
            ll y = id(b,c);
            es.emplace_back(x,y);
            cs[a].emplace(x);
            cs[b].emplace(y);
        }
        int k = 0;
        map<ll,int> idid;
        for(auto &p : s){
            idid[p.second] = k++;
        }
        g.assign(k,{});
        for(auto &e : es){
            ll a,b;
            tie(a,b) = e;
            int x = idid[a];
            int y = idid[b];
            ae(x,y,0);
        }

        rep(i,n){
            int h = idid[id(i,0)];
            for(auto &c : cs[i]) if(c != h) ae(h,idid[c],1);
        }

        int ans = -2;

        int src = idid[id(0,0)];
        int dst = idid[id(n-1,0)];
        int *dist = new int[k];
        fill(dist, dist+k, INF);
        dist[src] = 0;
        q.push_back(src);
        while(q.size()){
            int v = q.front();
            q.pop_front();

            if(v == dst){
                ans = dist[v];
                break;
            }

            for(auto &e : g[v]){
                if(dist[e.dst] != INF) continue;
                dist[e.dst] = dist[v] + e.wgt;
                if(e.wgt == 0) q.push_front(e.dst);
                else q.push_back(e.dst);
            }
        }

        // rep(i,k) cout << dist[i] << ' ';
        // cout << endl;

        cout << ans/2 << endl;
        delete[] dist;
    }
}


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

using namespace std;
#define int long long
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim>
struct rge {
    c b, e;
};

sim> rge<c> range(c i, c j) { return rge<c>{i, j}; }

sim> auto dud(c *x) -> decltype(cerr << *x, 0);

sim> char dud(...);

struct debug {
#ifndef LOCAL

    ~debug() {
        cerr << endl;
    }

    eni(!=) cerr << boolalpha << i;
        ris;
    }

    eni(==) ris << range(begin(i), end(i));
    }

    sim, class b dor(pair<b, c> d) {
        ris << "(" << d.first << ", " << d.second << ")";
    }

    sim dor(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
    }

#else
    sim dor(const c &)
    {
        ris;
    }
#endif
};

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void solve();

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    test
    solve();
    return 0;
}

const int mxn = 1 << 20;
int hh[mxn], ww[mxn];

void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    set<pair<int, int>> s;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        s.insert({x, y});
        hh[x]++, ww[y]++;
    }
    int mah = *max_element(hh, hh + h + 1);
    int maw = *max_element(ww, ww + w + 1);
    int ans = mah + maw - 1;
    vector<int> hd, wd;
    for (int i = 1; i <= h; ++i) if (hh[i] == mah) hd.push_back(i);
    for (int i = 1; i <= w; ++i) if (ww[i] == maw) wd.push_back(i);
    for (auto x: hd) {
        for (auto y: wd) {
            if (s.count({x, y}) == 0) {
                cout << ans + 1 << "\n";
                return;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 34968
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		String b = sc.next();
		String c = null ;
		switch(b) {
		case "A":
			c = "T";
			break;
		case "C":
			c = "G";
			break;
		case "G":
			c = "C";
			break;
		case "T":
			c = "A";
			break;
		}
		
		System.out.println(c);


	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int lim = 100100;
int N,W;


signed main(){
  cin>>N>>W;
  int w[N], v[N];
  rep(i,N) cin>>w[i]>>v[i];
  ll dp[N+1][N+1][N*3+1]; memset(dp,-1,sizeof(dp));
  dp[0][0][0] = 0;
  ll ans = 0;
  rep(i,N){
    rep(j,N){
      int d = w[i]-w[0];
      rep(k,N*3+1){
        if(dp[i][j][k]==-1) continue;
        dp[i+1][j][k] = max(dp[i][j][k], dp[i+1][j][k]);
        ll next_w = j*w[0]+k+w[i];
        if(next_w>W) continue;
        dp[i+1][j+1][k+d] = max(dp[i+1][j+1][k+d],dp[i][j][k]+v[i]);
        ans = max(ans,dp[i+1][j+1][k+d]);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  char a,b;
  cin>>s;
  a=s[0];
  b=s[s.size()-1];
  cout<<a<<s.size()-2<<b<<endl;
}
///////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int N;
  ll Y;
  cin >> N >> Y;
  REP(i, N + 1) {
    REP(j, N + 1) {
      int k = N - i - j;
      if (k < 0) continue;
      ll z = Y - 10000 * i - 5000 * j;
      if (1000 * k == z) {
        cout << i << " " << j << " " << k << endl;
        return;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
using System;
using static System.Console;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = ReadLine().ToCharArray();
            Write(S[0] ==S[1] || S[1] == S[2] || S[2] == S[3] ? "Bad" : "Good");
        }
    }
}

Measured memory_bytes: 11092
import sys
line = sys.stdin.readline()
while line:
	H,W = map(int,line.split())
	if H == 0 and W == 0:
		break;
	print "#"*W
	for i in range(0,H-2):
		print "#"+"."*(W-2)+"#"
	print "#"*W
	print ""
	line = sys.stdin.readline()

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

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

  if(a >= c * 2 && b >= c * 2){
    cout << max(x,y) * c * 2 << endl;
    return 0;
  }

  if(a + b < c * 2){
    cout << a * x + b * y << endl;
    return 0;
  }
  
  int ans;
  ans = c * min(x,y) * 2;

  if(min(x,y) == x){
    if(b >= c * 2)
      ans+=c*2*(y-x);
    else
      ans+=b*(y-x);
  } else {
    if(a >= c * 2)
      ans+=c*2*(x-y);
    else
      ans+=a*(x-y);
  }
  cout << ans << endl;
  
  return 0;
}


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

#define int long long
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; }

int x[200010], y[200010];
char u[200010];
signed main(){
	int n;
	cin >> n;

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

	int ans = LLONG_MAX;

	{
		map<int, int> dp; 
		map<int, int> up; 
		typedef pair<pair<int, int>, char> P;
		priority_queue<P> que;
		for(int i = 0;i < n;i++){
			if(u[i] != 'R'){
				que.push(make_pair(make_pair(x[i], y[i]), u[i]));
			}
		}

		while(!que.empty()){
			int xx = que.top().first.first;
			int yy = que.top().first.second;
			int cc = que.top().second;
			que.pop();
			if(cc == 'U' || cc == 'D'){
				if(cc == 'D' && dp.find(xx+yy) != dp.end()){
					chmin(ans, abs(dp[xx+yy]-xx)*10);
				}

				if(cc == 'U' && up.find(yy-xx) != up.end()){
					chmin(ans, abs(up[yy-xx]-xx)*10);
				}
			}else{
				dp[xx+yy] = xx;
				up[yy-xx] = xx;
			}
		}
	}

	{
		map<int, int> dp; 
		map<int, int> up; 
		typedef pair<pair<int, int>, char> P;
		priority_queue<P, vector<P>, greater<P>> que;
		for(int i = 0;i < n;i++){
			if(u[i] != 'L'){
				que.push(make_pair(make_pair(x[i], y[i]), u[i]));
			}
		}

		while(!que.empty()){
			int xx = que.top().first.first;
			int yy = que.top().first.second;
			int cc = que.top().second;
			que.pop();
			if(cc == 'U' || cc == 'D'){
				if(cc == 'D' && dp.find(yy-xx) != dp.end()){
					chmin(ans, abs(dp[yy-xx]-xx)*10);
				}

				if(cc == 'U' && up.find(xx+yy) != up.end()){
					chmin(ans, abs(up[xx+yy]-xx)*10);
				}
			}else{
				dp[yy-xx] = xx;
				up[xx+yy] = xx;
			}
		}
	}


	{
		map<int, int> mp;
		typedef pair<pair<int, int>, char> P;
		priority_queue<P, vector<P>, greater<P>> que;
		for(int i = 0;i < n;i++){
			if(u[i] == 'D' || u[i] == 'U'){
				que.push(make_pair(make_pair(y[i], x[i]), u[i]));
			}
		}

		while(!que.empty()){
			int val = que.top().first.first;
			int key = que.top().first.second;
			int c = que.top().second;
			que.pop();
			if(c == 'U'){
				mp[key] = val;
			}else{
				if(mp.find(key) != mp.end()){
					chmin(ans, abs(mp[key]-val)*10/2);
				}
			}
		}
	}

	{
		map<int, int> mp;
		typedef pair<pair<int, int>, char> P;
		priority_queue<P, vector<P>, greater<P>> que;
		for(int i = 0;i < n;i++){
			if(u[i] == 'R' || u[i] == 'L'){
				que.push(make_pair(make_pair(x[i], y[i]), u[i]));
			}
		}

		while(!que.empty()){
			int val = que.top().first.first;
			int key = que.top().first.second;
			int c = que.top().second;
			que.pop();
			if(c == 'R'){
				mp[key] = val;
			}else{
				if(mp.find(key) != mp.end()){
					chmin(ans, abs(mp[key]-val)*10/2);
				}
			}
		}
	}
	if(ans != LLONG_MAX){
		cout << ans << endl;
	}else{
		cout << "SAFE" << endl;
	}

	return 0;
}


Measured memory_bytes: 22116
<?php
fscanf(STDIN, "%d", $n);
for ($i = 0; $i < $n; $i++) {
	fscanf(STDIN, "%d %d", $a[], $b[]);
}
asort($b);
$t = 0;
foreach ($b as $i => $p) {
	$t += $a[$i];
	if ($t > $p) exit('No');
}
echo 'Yes';

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

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,x) for(auto a:x)
vector<int> v[200];
 bool choose[200];
vector<pair<int,int> >edges;
int main(){
  int n;
  cin>>n;
  //rep(n,3,101){
  int sum=(n*(n+1))/2;
  int d=0;
  if(n%2==1)d=(n+1)/2;
  else d=n/2;
  
  //rep(i,0,d)v[i].clear();
      rep(i,0,n)choose[i]=false;
      rep(j,0,d){
	int div=sum/d;
	for(int i=n;i>0;i--){
	  if(!choose[i] && div>=i){
	    div-=i;
	    choose[i]=true;
	    v[j].push_back(i);
	  }
	}
      }
      /*int edges=1;
      //rep(j,0,d)edges=edges*v[j].size();
      cout<<edges<<endl;
      rep(j,0,d){
	trav(a,v[j])cout<<a<<" ";
	cout<<endl;
	}*/
      edges.clear();
      rep(j,0,d){
	rep(k,j+1,d){
	  trav(a,v[j]){
	    trav(b,v[k]){
	      edges.push_back(pair<int,int>(a,b));
	    }
	  }
	}
      }
      cout<<edges.size()<<endl;
      int cnt[n];
      rep(i,0,n)cnt[i]=0;
      trav(a,edges){
	cnt[a.first-1]+=a.second;
	cnt[a.second-1]+=a.first;
	cout<<a.first<<" "<<a.second<<endl;
      }
      int S=cnt[0];
      rep(i,0,n){
	if(cnt[i]!=S){
	  //cout<<i<<endl;
	  rep(h,0,1000000000);
	  return 0;
	}
      }
      //return 0;
    
      //}
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

using namespace std;

int main(void){
  vector<ll> a(2), c(2);
  for (int i = 0; i < 2; i++){
    cin >> a[i];
  }
  for (int i = 0; i < 2; i++){
    cin >> c[i];
  }

  ll ans = -INF;

  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 2; j++){
      ans = max(ans, a[i]*c[j]);
    }
  }
  cout << ans << endl;
  
  

  return 0;
}


Measured memory_bytes: 3616
import math
a, b, x = map(int, input().strip().split())

# 箱の体積
V = (a**2) * b

if x/V <= 0.5:
    print(math.degrees(math.atan(a*(b**2)/(2.0*x))))

else:
    print(math.degrees(math.atan(2*(V-x)/(a**3))))


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

#define INF (1LL<<60)

int main(){
	long long n;	cin>>n;
	long long a=0;
	long long ans=n;

	while(a<=sqrt(n)){
		++a;
		if(a*(n/a)!=n)continue;

		long long tmp=a+(n/a);
		if(ans>tmp){
			//printf("%d:%d\n",a,n/a);
			ans=tmp;
		}
	}
	if(ans==n){
		cout<<ans-1<<endl;
	}else{
		cout<<ans-2<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <sstream>

using namespace std;
typedef long long ll;
int d[200001];
ll b[200001];
ll c[200001];
ll cnt2, cnt3;

int go(int x) {
	if (x == 0)return d[x] = 0;
	else if (x == 1)return d[x] = 1;
	else if (x == 2)return d[x] = 1;
	int tmp = x;
	int cnt = 0;
	while (tmp > 0) {
		if (tmp & 1)cnt += 1;
		tmp /= 2;
	}
	d[x] = d[x % cnt] + 1;
	return d[x];
}


int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);	
	int n; cin >> n;
	for (int i = 1; i <= 200000; i++) {
		d[i] = go(i);
	}
	string s; cin >> s;

	ll cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1')cnt += 1;
	}

	ll cnt2 = cnt + 1;
	b[0] = 1 % cnt2;
	ll t = 2;

	for (int i = 1; i < n; i++) {
		b[i] = t % cnt2;
		t *= 2; t %= cnt2;
	}

	cnt3 = cnt - 1;
	if (cnt3 > 0) {
		c[0] = 1 % cnt3;
		t = 2;
		for (int i = 1; i < n; i++) {
			c[i] = t % cnt3; 
			t *= 2; t %= cnt3;
		}
	}

	int sum = 0, sum1 = 0;
	int R = 1, R1 = 1;

	for (int i = s.size() - 1; i >= 0;i--) {
		if (s[i] == '1') {
			sum += R; sum %= cnt2;
			if (cnt3 > 0) {
				sum1 += R1; sum1 %= cnt3;
			}
		}
		R *= 2; R %= cnt2;
		if (cnt3 > 0) {
			R1 *= 2; R1 %= cnt3;
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			int ans = sum + b[n - i - 1]; ans %= cnt2;
			cout << d[ans] + 1 << '\n';
		}
		else {
			if (cnt3 == 0) {
				cout << 0 << '\n';
			}
			else {
				int ans = sum1 - c[n - i - 1];
				while (ans < 0)ans += cnt3;
				cout << d[ans] + 1 << '\n';
			}
		}
	}

	// s[i] == 0이면 1로 만들어줘야해서 그냥 더해주면 됨 i부분을

	// s[i] == 1이면 0으로 만들어줘야하기 때문에 전체 값에서 빼주면 됨 i부분을



}


Measured memory_bytes: 7224
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    string s1,s2;
    int cnt=0;
    cin>>s1>>s2;
    int l=s1.length();
    for(int i=0;i<l;i++)
    {
        if(s1[i]!=s2[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


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

int main()
{
	long long int a,b,c,k;
	cin>>a>>b>>c>>k;
	long long int sum=0;
	if(k<=a)
	{
		cout<<k;
		return 0;
	}
	sum+=a;
	k-=a;
	if(k<=b)
	{
		cout<<sum;
		return 0;
	}
	k-=b;
	sum-=k;
	cout<<sum;
}

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

#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     precision(a,b)  fixed<<setprecision(a)<<b
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n"
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     sfl(a)          scanf(" %lld", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     ALL(a)          a.begin(),a.end()
#define     pb(a)           push_back(a)
#define     pi              2*acos(0.0)

typedef long long int ll;
typedef unsigned long long int ull;

const int sz=1e5+9 , infP=INT_MAX , infN=INT_MIN ,mod=1e9+7, eps=1e-9;


void ini(){

    return;
}

ll dp[sz][3];

void solve(){
    ll n , m, k, l, r, ans=0;
    cin>>n;
    int a[n][3];
    for(auto &i:a){
        for(auto &j:i)cin>>j;
    }
    dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
    for(int i=1;i<n;i++){
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<Endl;

}

int main(){
    FasterIO;
    #ifndef ONLINE_JUDGE
        freopen("input.in","r",stdin);
        freopen("output.in","w",stdout);
    #endif
    ini();
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    int right = v.size() / 2;
    int left = right - 1;
    cout << (v[right] - v[left]) << endl;
}

Measured memory_bytes: 3760
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

    int tmp;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> tmp;
        p.at(i) = tmp;
    }

    int tmp_min = 2*100000 + 1;
    int ans = 0;
    for(int i=0; i<n; i++){
        if(tmp_min > p.at(i)){
            ans += 1;
            tmp_min = p.at(i);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define PI acos(-1)

int main()
{
    ll m,n,sum=0;
    cin>>m>>n;
    while(n--)
    {
        ll a;
        cin>>a;
        sum+=a;
    }
    if(sum>m)cout<<-1<<'\n';
    else
        cout<<m-sum<<'\n';

    return 0;
}



Measured memory_bytes: 3624
import           Control.Monad
import           Data.Functor
import           Data.List
import qualified Data.Map.Strict as Map
import           Debug.Trace

--main :: IO ()
main = do
  n <- readLn
  am <- replicateM n $ map read . words <$> getLine :: IO([[Int]])
  --print $ toAdjList am
  forM_ (Map.toList . solve . toAdjList $ am) (\(node, distance) -> putStrLn $ show node ++ " " ++ show distance)

type Node = Int
type Weight = Int
type AdjList = [Map.Map Node Weight]
toAdjList :: [[Int]] -> [Map.Map Node Weight]
toAdjList [] = []
toAdjList (a:as) = (adjacents a):(toAdjList as)
  where
    adjacents :: [Int] -> Map.Map Node Weight
    adjacents (i:n:bs) = Map.fromList $ toPair bs
    toPair :: [Int] -> [(Node, Weight)]
    toPair [] = []
    toPair (x:y:zs) = (x, y):toPair zs


solve :: AdjList -> Map.Map Node Int
--solve _ = Map.fromList [(1,2), (3,4)]
solve al = dijkstra al $ Map.singleton 0 0
  where
    dijkstra :: AdjList -> Map.Map Node Int -> Map.Map Node Int
    dijkstra al ss
      | length al <= Map.size ss = ss
      | otherwise = dijkstra al $ Map.insert i d ss
      -- | otherwise = trace ("adj = " ++ show adjacents) dijkstra al $ Map.insert i d ss
      where
        adjacents = join [[(j, ss Map.! i + (al !! i) Map.! j) | j <- Map.keys (al !! i), j `notElem` Map.keys ss]
            | i <- [0..(length al - 1)], i `elem` Map.keys ss]
        (i, d) = minimumBy (\x y -> compare (snd x) (snd y)) adjacents



Measured memory_bytes: 6820
#include <cstdio>

int main(int argc, const char * argv[]) {
    
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    int diff = b-a;
    
    int tmp = 0;
    for(int i=1;i<=diff;i++)tmp+=i;
    
    printf("%d\n",tmp-b);
    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if(a>c) cout<<"NO"<<endl;
  else if((a+b)>=c) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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


/// 2 <= N <= 10^5
/// dp[i]: 足場iまでに支払うコストの総和の最小値
fn main() {
    let n = read_one::<usize>();
    let hn = read::<isize>();

    let mut dp = vec![::std::isize::MAX; n];
    dp[0] = 0;
    dp[1] = (hn[1] - hn[0]).abs();

    for i in 2..n {
        dp[i] = cmp::min(
            (hn[i - 1] - hn[i]).abs() + dp[i - 1],
            (hn[i - 2] - hn[i]).abs() + dp[i - 2],
        );
    }

    println!("{}", dp[n - 1]);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 6396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int a, b, cnt = 0, ans = 0;
	string s;
	cin >> a >> b >> s;
	rep(i, a + b + 1) {
		if (s[i] == '-') {
			cnt++;
			ans = i;
		}
	}
	if (cnt == 1 && ans == a) cout << "Yes" << endl;
	else cout << "No" <<  endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  string W, T;
  cin >> W;
  int cnt = 0;
  while(cin >> T){
    for(int i = 0; i < T.size(); i++){ 
      if(!(T.at(i) >= 'a' && T.at(i) <= 'z')) T.at(i) = T.at(i) - ('A' - 'a');
    }
    if(T == W) cnt++;
  }
  cout << cnt << endl;
}


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

int main(){
    cout << fixed << setprecision(5);
    double PI = acos(-1);
    double a,b,c,rad;
    cin >> a >> b >> c;
    rad = c*PI/180;
    cout << a*b*sin(rad)/2 << endl;
    cout << a+b+ sqrt(a*a + b*b - 2*a*b*cos(rad)) << endl;
    cout << b*sin(rad) << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    ll i,cnt=0;
    for(i=1;;i++){
        cnt+=i;
        if(cnt>=n)  break;   
    }
    for(ll j=i;n>0;j--){
        if(n>=j){
                n-=j;
                cout << j << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 3000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, k, ans = INT_MAX;
int x[N];

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) x[i] = read();
    for (int l = 1, r = k; r <= n; l++, r++) {
        ans = std::min(ans, std::abs(x[l]) + std::abs(x[r] - x[l]));
        ans = std::min(ans, std::abs(x[r]) + std::abs(x[r] - x[l]));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] 
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

X,Y=map(int,input().split())

wa = X+Y
if (wa)%3!=0 or not (wa//3 <= X <= wa-wa//3):
    print(0)
else:
    MOD = 10**9 + 7
    fac, ifac = make_tables(MOD, wa // 3)
    ans = cmb(wa // 3, X - wa // 3, MOD, fac, ifac)
    print(ans)


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  // Failed to predict input format
  int H, W; cin >> H >> W;
  vec<string> grid(H);
  rep(h,H){
    cin >> grid[h];
  }
  vector<bool> fr(H,true), fc(W,true);
  rep(h,H){
    for(char c : grid[h]){
      if(c!='.'){
        fr[h] = false;
        break;
      }
    }
  }
  rep(w,W){
    rep(h,H){
      if(grid[h][w]!='.'){
        fc[w] = false;
        break;
      }
    }
  }
  //dump(fr, fc);
  rep(h,H){
    if(fr[h]) continue;
    rep(w,W){
      if(!fc[w]) cout << grid[h][w];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(void){
    int n; cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int sum_a = accumulate(a.begin(),a.end(),(int)0);
    int ans = 1e15;
    int tmp = 0;
    for(int i=0;i<n-1;i++){
        tmp += a[i];
        sum_a -= a[i];
        if(abs(tmp-sum_a) < ans){
            ans = abs(tmp-sum_a);
        }
    }
    cout << ans << endl;
    return 0;
}

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

bool state[55][55];
int dis[55][55];
int h, w;
int mx[] = {-1, 0, 1, 0};
int my[] = {0, -1, 0, 1};

void set_dis() {
  rep(i, h)rep(j, w) dis[i+1][j+1] = -1;
  dis[1][1] = 0;
}

int bfs() {
  queue<P> que;
  que.push(P (1,1));
  while (!que.empty()) {
    P tmp = que.front(); que.pop();
    int x, y;
    x = tmp.first; y = tmp.second;
    rep(i, 4) {
      int tx, ty;
      tx = x + mx[i]; ty = y + my[i];
      if (state[tx][ty] && dis[tx][ty] < 0) {
        dis[tx][ty] = dis[x][y] + 1;
        que.push(P (tx,ty));
      }
    }
  }
  return dis[h][w];
}

int main() {
  cin >> h >> w;
  int cnt = 0;
  rep(i, h) {
    rep(j, w) {
      char c;
      cin >> c;
      if (c == '.') {
        state[i+1][j+1] = true;
        ++cnt;
      }
    }
  }
  set_dis();
  int ans = bfs();
  cout << (ans < 0 ? -1 : cnt-ans-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll N; cin >> N;
    string ans = "";
    while (N > 0) {
        if (N%26) {
            ans = (char)(N%26-1+'a') + ans;
            N /= 26;
        }
        else {
            ans = 'z' + ans;
            N /= 26;
            N--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632