akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

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

    if (k < a) {
        a -= k;
    }
    else if (k < (a + b)) {
        b -= (k - a);
        a = 0;
    }
    else {
        a = 0;
        b = 0;
    }
    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,m,x[100002],y[100002],ans=0;
    cin >> n >> m;
    rep(i,m) cin >> x[i];
    sort(x,x+m);
    rep(i,m-1) y[i] = x[i+1] -x[i];
    sort(y,y+m-1);
    reverse(y,y+m-1);
    rep(i,n-1) y[i] = 0;
    rep(i,m-1) ans += y[i];
    cout << ans << endl;
    // rep(i,m) cout << x[i] << endl;
    // cout << endl;
    // rep(i,m-1) cout << y[i] << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll sumXOR(ll x){
  ll n=(x+1)/2;
  ll ans=n%2;
  if(x%2==0) ans^=x;
  return ans;
}

int main(){
  ll A,B;
  cin>>A>>B;
  ll ans=sumXOR(A-1)^sumXOR(B);
  //cout<<sumXOR(A-1)<<endl;
  //cout<<sumXOR(B)<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int N,W;
   cin>>N>>W;
   vector<int> w(N),v(N);
   for(int i=0;i<N;i++){
      cin>>w[i]>>v[i];
   }
   vector<vector<long long>> dp(N+1,vector<long long>(100007));
   for(int i=0;i<=N;i++){
      for(int j=0;j<100007;j++){
         dp[i][j]=1000000007;
      }
   }
   dp[0][0]=0;
   for(int i=0;i<N;i++){
      for(int j=0;j<100007;j++){
         if(v[i]<=j){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
         }
         dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      }
   }
   int ans=-1;
   for(int i=0;i<=N;i++){
      for(int j=0;j<=100000;j++){
         if(dp[i][j]<=W){
            ans=j;
         }
      }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 80256
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("\n");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        String w = sc.next().toUpperCase();
        int ans = 0;
        while (true) {
            String t = sc.next();
            if (t.equals("END_OF_TEXT"))    break;
            if (t.toUpperCase().equals(w))    ans++;
        }
        out.println(ans);
        
        out.flush();
    }
}


Measured memory_bytes: 26144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<pair<pair<string,int>,int>> a(n);
    for(int i=0;i<n;i++){
        string s;cin >> s;
        int p;cin >> p;
        a[i]={{s,-p},i};
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout << a[i].second+1 << endl;
    }
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N , K;
    cin >> N >> K;
    ll ans = 0;
    if (K%2) {
        int a = N/K;
        ans += 1LL*a*a*a;
    } else {
        int a = N/K;
        int b = (N>=K/2 ? (N-K/2)/K + 1 : 0);
        ans += 1LL*a*a*a;
        ans += 1LL*b*b*b;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
  char s[100000]={0};
  int kai=0; 
  int i=0;
  scanf("%s",s);
  for(i=0;i<=100000;i++){
    if(s[i]=='1'&&i%2!=0){
      kai++;
    }
    if(s[i]=='0'&&i%2==0){
      kai++;
    }
    
    if(s[i]=='\0'){
      break;
    }
    
  }
  if(kai*2<i){
    printf("%d",kai);
  }
  else{
    printf("%d",i-kai);
  }
  return 0;
}

Measured memory_bytes: 256
import itertools

N,M=map(int,input().split())

X=[None]*N

for i in range(N):
    X[i]=list(map(int,input().split()))

Y_1=[None]*N
Y_2=[None]*N
Y_3=[None]*N
Y_4=[None]*N
Y_5=[None]*N
Y_6=[None]*N
Y_7=[None]*N
Y_8=[None]*N

for i in range(N):
    Y_1[i]=X[i][0]+X[i][1]+X[i][2]
    Y_2[i]=X[i][0]+X[i][1]-X[i][2]
    Y_3[i]=X[i][0]-X[i][1]+X[i][2]
    Y_4[i]=X[i][0]-X[i][1]-X[i][2]
    Y_5[i]=-X[i][0]+X[i][1]+X[i][2]
    Y_6[i]=-X[i][0]+X[i][1]-X[i][2]
    Y_7[i]=-X[i][0]-X[i][1]+X[i][2]
    Y_8[i]=-X[i][0]-X[i][1]-X[i][2]

Y_1.sort()
Y_2.sort()
Y_3.sort()
Y_4.sort()
Y_5.sort()
Y_6.sort()
Y_7.sort()
Y_8.sort()

score=max(sum(Y_1[N-M:]),sum(Y_2[N-M:]),sum(Y_3[N-M:]),sum(Y_4[N-M:]),sum(Y_5[N-M:]),sum(Y_6[N-M:]),sum(Y_7[N-M:]),sum(Y_8[N-M:]))

print(score)

Measured memory_bytes: 3700
def resolve():
    s = input()
    for bit in range(2 ** 3):
        _str = "".join(
            s[i] if i == 3 else s[i] + "+" if 1 << i & bit else s[i] + "-"
            for i in range(4)
        )
        if eval(_str) == 7:
            print(_str + "=7")
            return


if __name__ == "__main__":
    resolve()

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

int main(){
    ll h;
    cin>>h;
    ll at=0,mons=1;
    while(h>1){
        at+=mons;
        h/=2;
        mons*=2;
    }
    cout<<at+mons<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int N,X,T;
    cin >> N >> X >> T;
    int count = N/X;
    if(N%X!=0) count = count+1;
    printf("%d\n",count*T);
    return 0;
}

Measured memory_bytes: 3760
N = int(input())
px = []
py = []
cro1 = []
cro2 = []
for i in range(N):
    x,y = map(int,input().split())
    px.append((x,y))
    py.append((x,y))
    cro1.append(x+y)
    cro2.append(y-x)
"""
px.sort()
py.sort(key=lambda x:x[1])
"""
cro1.sort()
cro2.sort()
print(max(cro1[-1]-cro1[0],cro2[-1]-cro2[0]))

Measured memory_bytes: 135776
n,m = map(int,input().split())
x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  if a == 1:
    x[b] = 1
  if b == n:
    y[a] = 1
for i in range(1,n):
  if x[i] == 1 and y[i] == 1:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
 
    
  

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

using namespace std;

const int MAXN = 100005;

vector<int> G[MAXN];

int deg[MAXN];

int n, u, v;

int p[MAXN];

vector<int> dia;

int dis[MAXN], fa[MAXN], use[MAXN], s, t;

void dfs(int u, int p = 0)
{
	dis[u] = dis[p] + 1, fa[u] = p;
	if (dis[u] > dis[t])
		t = u;
	for (auto v : G[u])
		if (v != p)
			dfs(v, u);
}

void init()
{
	s = 0, t = 0;
	dfs(1);
	s = t, t = 0;
	dfs(s);
	int x = t;
	while (x)
		dia.push_back(x), use[x] = 1, x = fa[x];	
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> u >> v;
		G[u].push_back(v), deg[u]++;
		G[v].push_back(u), deg[v]++;
	}
	init();
	for (auto u : dia)
	{
		for (auto v : G[u])
		{
			if (!use[v] && deg[v] > 1)
			{
				cout << -1 << endl;
				exit(0);	
			}
		}
	}
	int sz = dia.size();
	for (int i = 0; i < sz - i - 1; i++)
	{
		if (deg[dia[i]] < deg[dia[sz - i - 1]])
			break;
		else if (deg[dia[i]] > deg[dia[sz - i - 1]])
		{
			reverse(dia.begin(), dia.end());
			break;
		}
	}
	int sum = 0, val = 0;
	for (int i = 0; i < sz; i++)
	{
		int u = dia[i];
		if (sz > 1)
		{
			if (i == 0 || i == sz - 1)
				deg[u] -= 1;
			else
				deg[u] -= 2;
		}
		p[sum + deg[u] + 1] = ++val;
		for (int j = 1; j <= deg[u]; j++)
			p[sum + j] = ++val;
		sum += deg[u] + 1;
	}
	for (int i = 1; i <= n; i++)
		cout << p[i] << " ";
	cout << endl;
	return 0;	
}


Measured memory_bytes: 13432
#include<bits/stdc++.h>
#define MAX 110
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n,m,t,ans=0;
  int a[MAX];

  cin>>n>>m>>t;
  FOR(i,0,n)cin>>a[i];
  ans+=a[0]-m;
  FOR(i,1,n){
    if(2*m<=a[i]-a[i-1])ans+=(a[i]-a[i-1])-2*m;
  }
  ans+=max(t-a[n-1]-m,0);
  cout<<ans<<endl;
  return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

struct UnionFind {
    vector<int> parrent;
    
    UnionFind(int N) : parrent(N) {
        REP(i, N) parrent[i] = i;
    }

    int root(int x) {
        if (parrent[x] == x) return x;
        return parrent[x] = root(parrent[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        parrent[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N), to(N);
    REP(i, N) cin >> P[i];

    UnionFind tree(N);

    REP(i, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        tree.unite(x, y);
    }

    int ans = 0;
    REP(i, N) {
        if (tree.same(i, P[i]-1)) ans++;
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n1,n2,n3,n4,ans;
    bool f1=false,f2=false,f3=false,f4=false;
    for(int i=0;i<4;i++){
        int n;
        cin >> n;
        if(n == 1){
            f1 =true;
        }else if(n== 9){
            f2 = true;
        }else if(n==7){
            f3 = true;
        }else if(n==4){
            f4=true;
        }
    }
    if(f1&&f2&&f3&&f4){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    cout<<endl;

}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> xy(m);
  for(int i=0;i<m;i++){
    cin >> xy.at(i).first >> xy.at(i).second;
  }
  vector<int64_t> ballnum(n);
  vector<int64_t> redflag(n);
  //initialization
  redflag.at(0) = 1;
  for(int i=0;i<n;i++){
    ballnum.at(i) = 1;
  }
  //
  for(int i=0;i<m;i++){
    ballnum.at(xy.at(i).first-1)--;
    ballnum.at(xy.at(i).second-1)++;
    if(redflag.at(xy.at(i).first-1) == 1){
      redflag.at(xy.at(i).second-1) = 1;
    }
    if(ballnum.at(xy.at(i).first-1) == 0){
      redflag.at(xy.at(i).first-1) = 0;
    }
  }
  int cnt = 0;
  for(int i=0;i<n;i++){
    if(redflag.at(i) == 1){
      cnt++;
    }
  }
  cout << cnt << endl;
}
      
    
      

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

class Edge{
public:
	long long cost;
	int from, to;
	Edge(long long c, int f, int t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void readGraph(Graph &g, int E, bool D, bool C){ // E:NumofEdges, D:Directed, C:Costed
	for(int i=0; i<E; ++i){
		Edge e(0, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		--e.from;
		--e.to;
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
int a[100010], ans;

int func(Graph &g, int p){
	if(a[p] != -1) return a[p];
	int res = 0;
	for(int i=0; i<g[p].size(); ++i)
		res = max(res, 1+func(g, g[p][i].to));
	return a[p] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	Graph g(n);
	readGraph(g, m, true, false);
	memset(a, -1, sizeof(a));
	for(int i=0; i<n; ++i) ans = max(ans, func(g, i));
	cout << ans << "\n";
}

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

using namespace std;

int main(){
    
  vector<int> vec(2);
  for (auto &i: vec) {
    cin >> i;
  }

  vector<int> vec2(vec[0]);
  for (auto &i: vec2) {
    cin >> i;
  }

  std::sort(vec2.begin(), vec2.end());
  
  int ans = 0;
  for(int i = 0; i< vec[1]; i++){
      ans += vec2[i];
  }
  
  cout << ans << endl;
   return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int mod=1000000007;
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}


inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    return fact[n]*inv[n-k]%mod;
}

int N;
int D[333];

int dp[2][666][333];

signed main(){
    cin>>N;
    rep(i,N)cin>>D[i];

    if(count(D,D+N,2)==N){
        cout<<fact[N-1]*inv[2]%mod<<endl;
        return 0;
    }

    dp[0][0][0]=1;
    rep(i,N){
        rep(j,2*N){
            rep(k,N){
                add(dp[(i+1)&1][j][k],dp[i&1][j][k]*inv[D[i]-1]%mod);
                if(D[i]>=2)add(dp[(i+1)&1][j+D[i]-2][k+1],dp[i&1][j][k]*inv[D[i]-2]%mod);
                dp[i&1][j][k]=0;
            }
        }
    }

    int ans=0;
    for(int i=1;i<2*N;i++){
        for(int j=3;j<N;j++){
            int tmp=dp[N&1][i][j];
            tmp=tmp*i%mod;
            tmp=tmp*fact[j-1]%mod;
            tmp=tmp*inv[2]%mod;
            tmp=tmp*fact[N-j-1]%mod;
            add(ans,tmp);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int i,N;
  cin >> N;
  vector<int> Array(N);
  int count = 0;
  int next;
  
  for(i=0; i<N ; i++){
    int a;
    cin >> a;
    Array.at(i) = a;
    //cout << Array.at(i) <<" ";
  } 
  next = Array.at(0);
  for(i=0; i<N ; i++){
    count++;
    if(next == 2){
      cout << count << endl;
      return(0);
    }
    next = Array.at(next-1);
    //cout << Array.at(next-1) <<" ";
  } 
  cout << -1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
void countingSort(int A[], int n, int B[], int range)
{
	int *cnt = new int[range + 1]{ 0 };
	for (int i = 1; i <= n; i++)
		cnt[A[i]]++;
	for (int i = 1; i <= range; i++)
		cnt[i] += cnt[i - 1];
	for (int i = n; i >= 1; i--)
	{
		B[cnt[A[i]]] = A[i];
		cnt[A[i]]--;
	}
	delete[] cnt;
}
int main()
{
	int n;
	cin >> n;
	int range = 10000;
	int *A = new int[n + 1];
	int *B = new int[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> A[i];
	countingSort(A, n, B, range);
	for (int i = 1; i <= n; i++)
		if (i != n)
			cout << B[i] << " ";
		else
			cout << B[i] << endl;
	delete[] A;
	delete[] B;
}


Measured memory_bytes: 18300
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};


void solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	map<pair<string, string>, ll> mo;
	for(int i = 0; i < (1 << n); i ++)
	{
		string k = "", q = "";
		for(int j = 0; j < n; j ++)
			if(i & (1 << j))
				k += s[j],
				q += "1";
		for(int j = 0; j < n; j ++)
			if(!(i & (1 << j)))
				k += s[j], q += "0";
		mo[M(k, q)]++;
	}
	ll ans = 0;
	for(int i = 0; i < (1 << n); i ++)
	{
		string k = "", q = "";
		for(int j = 0; j < n; j ++)
			if(i & (1 << j))
				k += s[j+n],
				q += "0";
		for(int j = 0; j < n; j ++)
			if(!(i & (1 << j)))
				k += s[j+n],
				q += "1";
//			deb(k);
//			deb(q);
		reverse all(k);
		reverse all(q);
		if(mo[M(k, q)])
			ans += mo[M(k, q)];
	}
	cout << ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	for(;t;t--)
	{
		solve();
	}





	





	getchar();
	getchar();
	return 0;
	
}

Measured memory_bytes: 106752
#include<bits/stdc++.h>
#define nl '\n'
#define dbg(a) cout<<#a<<"="<<a<<endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define vl vector<ll>
#define pll pair<ll, ll>
#define ii pair<ll,ll>
#define vi vector<ll>
#define MX 600000
#define MXX 1000000000
using namespace std;

void solve(){
    ll x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

int main()
{
    fast;
    solve();
    return 0;
}


Measured memory_bytes: 3604
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

Measured memory_bytes: 3588
#include <stdio.h>
int main(void)
{
	int A = 0;
	int B = 0;
	int K = 0;

	scanf("%d%d", &A, &B);

	K = A + B;

	if (K % 2 == 0) {
		K = (A + B) / 2;
		printf("%d", K);
	}
	else {
		printf("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python
import sys,heapq
if 'pypy' in sys.version.lower():
	import rpython.rlib.streamio
	stream=rpython.rlib.streamio.fdopen_as_stream(sys.stdin.fileno(),'r')
	raw_input=stream.readline
	def cmp_lt(x,y): return x < y
	heapq.cmp_lt=cmp_lt
	COMPILE=123456789012
	def compile(a,b,c):
		return ((a+COMPILE)<<18) | (b<<9) | c
	def decompile(a):
		return ((a>>18)-COMPILE,(a>>9)&511,a&511)
else:
	def compile(a,b,c):
		return (a,b,c)
	def decompile(a):
		return a
	if sys.version_info[0]>=3: raw_input=input

INF=1234567890123456789
def shortestPath(g,dist,prev):
	n = len(g)-1
	h = [INF]*n+[0]
	for k in range(n+1):
		for i in range(n+1):
			for e in g[i]:
				if h[e[1]]<INF and e[0]<INF and h[e[2]] > h[e[1]] + e[0]:
					h[e[2]] = h[e[1]] + e[0]
					if k==n: return False # negative cycle
	for i in range(n):
		for e in g[i]:
			e[0]+=h[i]-h[e[2]]
	for s in range(n):
		Q=[]
		heapq.heappush(Q,compile(0,s,s))
		while Q:
			e = decompile(heapq.heappop(Q))
			if prev[s][e[2]]!=-2: continue
			prev[s][e[2]] = e[1]
			for f in g[e[2]]:
				if e[0]<INF and f[0]<INF and dist[s][f[2]] > e[0] + f[0]:
					dist[s][f[2]] = e[0] + f[0]
					heapq.heappush(Q,compile(e[0]+f[0],f[1],f[2]))
		for u in range(n):
			if dist[s][u]<INF: dist[s][u] += h[u] - h[s]
	return True

def entry_point(argv):
	V,E=[int(e) for e in raw_input().rstrip().split(' ')]
	g=[[] for i in range(V+1)]
	dist=[[INF]*V for i in range(V)]
	prev=[[-2]*V for i in range(V)]
	for i in range(V): g[i].append([0,i,i])
	for i in range(V): g[V].append([0,V,i])
	for i in range(E):
		s,t,e=[int(e) for e in raw_input().rstrip().split(' ')]
		g[s].append([e,s,t])
	if not shortestPath(g,dist,prev):
		print("NEGATIVE CYCLE")
	else:
		for i in range(V):
			print(' '.join(["INF" if dist[i][j]>=INF else str(dist[i][j]) for j in range(V)]))
	return 0

def target(*args):
	return entry_point, None

if __name__ == '__main__': entry_point([])

Measured memory_bytes: 8464
using System;
					
public class Program
{
	public static void Main()
	{
		//°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸Kobato Love°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸
		string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
       	int a,b,c;
		a = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);
		if(a < c && b > c || a > c && b < c)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
ll num=1, ans=0, count=0, sum=0;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll K;
  cin >> K;
  rep2(i, K) rep2(j, K) rep2(k, K) {
    sum += gcd(gcd(i, j), k);
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 3648
import math

n = int(input())
xs = list(map(float, input().split()))
ys = list(map(float, input().split()))


def mink(p):
    return math.pow(sum([
        math.pow(math.fabs(xs[i] - ys[i]), p)
        for i in range(n)
    ]), 1 / p)


def mink_inf():
    return max([math.fabs(xs[i] - ys[i]) for i in range(n)])


def float_print(v):
    print('{:.5f}'.format(v))


float_print(mink(1))
float_print(mink(2))
float_print(mink(3))
float_print(mink_inf())


Measured memory_bytes: 5728
h,w = map(int,input().split())
s = [list(input().split()) for _ in range(h)]
ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
word = "snuke"
for i in range(h):
    for j in range(w):
        if s[i][j] == word:
            print(ch[j],i+1,sep = "")
            break

Measured memory_bytes: 9068
#include "bits/stdc++.h"

using namespace std;

// パースする文字列
string s;
// 次に読み始める位置
int pos;

// 二分木ノード
struct Node
{
    int val;
    Node *l, *r;
};

// tr := (tr)[num](tr)

// 整数
int number()
{
    int ret = 0;
    while (isdigit(s[pos]))
    {
        ret *= 10;
        ret += s[pos] - '0';
        pos++;
    }
    return ret;
}

// パースして二分木のノードを返す
Node *misawa()
{
    if (s[pos] == ')')
    {
        // 空ノード
        return nullptr;
    }
    pos++;             // (
    auto l = misawa(); // left child
    pos++;             // )
    pos++;             // [
    auto v = number();
    pos++;             // ]
    pos++;             // (
    auto r = misawa(); // right child
    pos++;             // )
    Node *node = new Node;
    node->val = v;
    node->l = l;
    node->r = r;
    return node;
}

// 二分木a, b を合成
Node *rec(Node *a, Node *b)
{
    Node *ret = new Node;
    ret->val = a->val + b->val;
    ret->l = nullptr;
    ret->r = nullptr;
    if (a->l && b->l)
    {
        ret->l = rec(a->l, b->l);
    }
    if (a->r && b->r)
    {
        ret->r = rec(a->r, b->r);
    }
    return ret;
}

// 二分木を文字列に変換
string recstr(Node *node)
{
    if (node == nullptr)
        return "";
    string ret = "";
    ret += "(" + recstr(node->l) + ")";
    ret += "[" + to_string(node->val) + "]";
    ret += "(" + recstr(node->r) + ")";
    return ret;
}

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

    string a, b;
    cin >> a >> b;
    s = a;
    pos = 0;
    auto at = misawa();
    s = b;
    pos = 0;
    auto bt = misawa();
    auto ret = rec(at, bt);
    cout << recstr(ret) << endl;
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a[3];
  REP(i,3){
    cin>>a[i];
  }
  
  int m=1000;
  int temp=0;
  REP(i,3){
    REP(j,3){
      temp+=abs(a[j]-a[i]);
    }
    m = min(m,temp);
    temp = 0;
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 256
constexpr bool isDebugMode = true;
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N, Q; cin >> N >> Q;
    dsu g(N);
    rep(i, Q){
        ll q, a, b; cin >> q >> a >> b;
        if(!q) g.merge(a, b);
        else pt(g.same(a, b));
    }
    return 0;
}

Measured memory_bytes: 4032
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll all[60], paty[60];
void set() {
	all[0] = 1;
	paty[0] = 1;
	for (int i = 1; i <= 50; i++) {
		all[i] = all[i - 1] * 2 + 3;
		paty[i] = paty[i - 1] * 2 + 1;
	}
}
ll dfs(ll eat, ll level) {
	ll ans = 0;
	if (level == 0) return 1;
	if (eat >= 1) {
		eat--;
	}
	if (eat >= 1) {
		if (eat >= all[level - 1]) {
			ans += paty[level - 1];
			eat -= all[level - 1];
		}
		else {
			ans += dfs(eat, level - 1);
			eat = 0;
		}
	}
	if (eat >= 1) {
		ans++;
		eat--;
	}
	if (eat >= 1) {
		if (eat >= all[level - 1]) {
			ans += paty[level - 1];
			eat -= all[level - 1];
		}
		else {
			ans += dfs(eat, level - 1);
			eat = 0;
		}
	}
	if (eat >= 1) {
		eat--;
	}
	return ans;
}
int main()
{
	int N;
	ll X;
	cin >> N >> X;
	set();
	cout << dfs(X, N) << endl;
}

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

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if (A == B && B == C && A == C) {
            System.out.println("No");
        } else if (A == B || B == C || A == C) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
h,w = map(int,input().split())
li,li2,li3 = [],[],[]
for i in range(h):
    li.append((input()))
li2.append("."*(w+2))
for i in range(h):
    li2.append("."+li[i]+".")
li2.append("."*(w+2))
cnt = 0
ans = [[0 for x in range(w)] for y in range(h)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if li2[i][j] == ".":
            if li2[i-1][j-1] == "#":
                ans[i-1][j-1] += 1
            if li2[i-1][j] == "#":
                ans[i-1][j-1] += 1
            if li2[i-1][j+1] == "#":
                ans[i-1][j-1] += 1
            if li2[i][j-1] == "#":
                ans[i-1][j-1] += 1
            if li2[i][j+1] == "#":
                ans[i-1][j-1] += 1
            if li2[i+1][j-1] == "#":
                ans[i-1][j-1] += 1
            if li2[i+1][j] == "#":
                ans[i-1][j-1] += 1
            if li2[i+1][j+1] == "#":
                ans[i-1][j-1] += 1
        elif li2[i][j] == "#":
            ans[i-1][j-1] = "#"
for i in range(h):
    ans[i] = [str(x) for x in ans[i]]
for i in range(h):
    print("".join(ans[i]))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,n,x,y,k,i,j,zx,xc;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b>>n;
	if(n>=b-1){
		cout<<(a*(b-1))/b;
	}else{
		cout<<(a*n)/b;
	}
	return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

//Text Justification
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int[] a = new int[1001], sum = new int[1001], dp = new int[1001];
		int INF = (1<<30)-1;
		for(int T=1;;T++){
			int n = sc.nextInt(), w = sc.nextInt();
			if((n|w)==0)break;
			for(int i=1;i<=n;i++){
				a[i] = sc.nextInt();
				sum[i] = sum[i-1]+a[i];
				dp[i] = INF;
			}
			for(int i=1;i<=n;i++)for(int j=0;j<i;j++)dp[i] = Math.min(dp[i], dp[j]+(Math.abs(sum[i]-sum[j]-w)));
			int res = INF;
			for(int i=1;i<=n;i++)res = Math.min(res, dp[i-1]+Math.max(0, sum[n]-sum[i-1]-w));
			System.out.printf("Case %d: %d\n", T, res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main()
{
    int p[8];
    while(cin >> p[0]){
        for(int i = 1; i < 8; ++i) cin >> p[i];
        int q[8] = {4,1,2,1,2,1,4,1};
        int min_ = 1 << 26;
        int ans[8];
        for(int i = 0; i < 8; ++i){
            int temp = 0;
            for(int j = 0; j < 8; ++j){
                temp += (p[j] - q[j] > 0 ? p[j] - q[j] : 0); 
            }
            
            if(min_ > temp){
                min_ = temp;
                for(int j = 0; j < 8; ++j){
                    ans[j] = q[j];
                }
            } else if(min_ == temp) {
                stringstream ss, tt;
                for(int j = 0; j < 8; ++j){
                    ss << ans[j];
                    tt << q[j];
                }
                int s, t;
                ss >> s;
                tt >> t;
                if(s > t){
                    for(int j = 0; j < 8; ++j){
                        ans[j] = q[j];
                    }
                }
            }
            
            rotate(q, q + 1, q + 8);
        }
        
        for(int i = 0; i < 8; ++i){
            if(i) cout << ' ';
            cout << ans[i];
        }
        cout << endl;
    }
}

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

int main(){
	int n;
	cin >> n;
	int sum=0,temp,max=0;
	for(int i=0;i<n;i++){
		cin >>temp;
		sum+=temp;
		if(temp>max){
			max=temp;
		}
	}
	if(max<(sum-max)){
		cout <<"Yes"<<endl;
	}
	else{
		cout <<"No"<<endl;
	}
	return 0;
}

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

long long gcd(long long a,long long b){
  if(b==0) return a;
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}
 
 
int main(int argc, char *argv[]){
  long long A,B;
  cin>>A>>B;
  long long res=lcm(A,B);
cout<<res<<endl;
}

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

int main(){
	int n, count, array[2001];
	fill(array, array + 2001, 0);
	for(int a = 0; a <= 1000; a++)
		for(int b = 0; b <= 1000; b++)
			array[a + b]++;
	
	while(scanf("%d", &n) != EOF){
		count = 0;
		for(int i = 0; i <= n; i++){
			if(n - i > 2000) continue;
			if(i > 2000) break;
			count += array[i] * array[n - i];
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    string S;
    cin >> S;
    rep(i, 3)
    {
        if (S[i] == S[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int a; cin >> a;
   cout << (a+a*a+a*a*a) << endl;
}

Measured memory_bytes: 3616
inf=float("inf")
n,k = map(int, input().split())
h = list(map(int, input().split()))
dp = [inf]*n
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k + 1, n - i)):
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])

Measured memory_bytes: 55008
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;

typedef long long ll;

vector<int> G[100005];
int dp[100005], MOD, ans[100005], father[100005];

void f(int v, int p) {
	dp[v] = 1;

	for(int u : G[v]) {
		if(u == p) continue;
		f(u, v);
		dp[v] = 1LL*dp[v]*(1+dp[u])%MOD;
	}
}

void g(int v, int p) {
	vector<int> pre, suf;
	int cur = 1;
	for(int u : G[v]) {
		if(u == p) {
			pre.push_back(cur);
			continue;
		}
		cur = 1LL*cur*(1+dp[u])%MOD;
		pre.push_back(cur);
	}

	cur = 1;
	for(int i = (int)G[v].size()-1; i >= 0; i--) {
		int u = G[v][i];
		if(u == p) {
			suf.push_back(cur);
			continue;
		}
		cur = 1LL*cur*(1+dp[u])%MOD;
		suf.push_back(cur);
	}
	reverse(suf.begin(), suf.end());

	for(int i = 0; i < G[v].size(); i++) {
		int u = G[v][i];
		if(u == p) continue;
		father[v] = v == 1 ? 1 : 1+father[p];

		if(i) father[v] = 1LL*father[v]*pre[i-1]%MOD;
		if(i < (int)G[v].size()-1) father[v] = 1LL*father[v]*suf[i+1]%MOD;

		ans[u] = 1LL*dp[u]*(1+father[v])%MOD;
		g(u, v);
	}
}

int main(){
	int n,a,b;

	scanf("%d%d", &n, &MOD);

	for(int i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}

	f(1,1);
	ans[1] = dp[1];
	g(1,1);

	for(int i = 1; i <= n; i++)
		printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 25028
import java.util.*;

public class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
      
        int d = sc.nextInt();
        if (d == 25) {
            System.out.println("Christmas");
        } else if (d == 24) {
        	System.out.println("Christmas Eve");
        } else if (d == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (d == 22) {
        	System.out.println("Christmas Eve Eve Eve");
        }
    }
}


Measured memory_bytes: 35724
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
typedef unsigned long long int llu;

int compare(const void* x, const void* y){
  if(*(int*)x<*(int*)y) return 1;
  else if(*(int*)x>*(int*)y) return -1;
  return 0;
}



int main(){
  int N,M;
  scanf("%d%d",&N,&M);
  int *A;
  int *Acost;
  int cost[10]={100,2,5,5,4,5,6,3,7,6};

  A=(int*)malloc(M*sizeof(int));
  Acost=(int*)malloc(M*sizeof(int));

  for(int i=0;i<M;i++){
   scanf("%d",&A[i]);
  }
  qsort(A,M,sizeof(int),compare);
  for(int i=0;i<M;i++) Acost[i]=cost[A[i]];

  int *dp;
  dp=(int*)malloc((N+1)*sizeof(int));
  dp[0]=0;
  for(int i=1;i<=N;i++){
    dp[i]=-10;
    for(int j=0;j<M;j++){
      if(i-Acost[j]>=0){
        if(dp[i-Acost[j]]!=-10){
          if(dp[i-Acost[j]]+1>dp[i]){
            dp[i]=dp[i-Acost[j]]+1;
          }
        }
      }
    }
  }
  /*for(int i=0;i<=N;i++){
    printf("dp[%2d]=%d\n",i,dp[i]);
  }
  for(int i=0;i<M;i++){
    printf("A[%d]=%d Acost[%d]=%d\n",i,A[i],i,Acost[i]);
  }*/

  while(N!=0){
    for(int i=0;i<M;i++){
      if(N-Acost[i]>=0){
        if(dp[N]==dp[N-Acost[i]]+1){
          printf("%d",A[i]);
          N=N-Acost[i];
          break;
        }
      }
    }
  }
  printf("\n");

  return 0;
}

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


fn main() {
    let (n, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut wn = Vec::new();
    let mut vn = Vec::new();

    for _ in 0..n {
        let (w_i, v_i) = {
            let i = read::<usize>();
            (i[0], i[1])
        };
        wn.push(w_i);
        vn.push(v_i);
    }

    let mut dp = vec![vec![0usize; w + 1]; n + 1];

    for i in (0..n).rev() { for j in 0..w + 1 {
        if j < wn[i] {
            dp[i][j] = dp[i + 1][j];
        } else {
            dp[i][j] = cmp::max(
                dp[i + 1][j],
                dp[i + 1][j - wn[i]] + vn[i]
            );
        }
    }}

    println!("{}", dp[0][w]);
}


#[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: 106748
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n ;
  cin >> n ;
  bool answer = true ;
  for(int i = 0 ; i < n; i++)
  {
    int t, x, y ;
    cin >> t >> x >> y ;
    
    if(answer == false)
    {
      continue ;
    }

    if(t < x + y)
    {
      answer = false ;
    }
    if(t % 2 == 0 && (x + y) % 2 != 0)
    {
      answer = false ;
    }
    if(t % 2 != 0 && (x + y) % 2 == 0)
    {
      answer = false ;
    }
  }

  if(answer)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> P(n);
    priority_queue<pii> tops;
    priority_queue<pii, vector<pii>, greater<pii>> bottoms;
    rep(i, 0, n) 
    {
        cin >> P[i];
        if (i < k)
        {
            tops.push(make_pair(P[i], i));
            bottoms.push(make_pair(P[i], i));
        }
    }

    vector<int> increasing(n, 1);
    rep(i, 1, n)
    {
        if (P[i-1] < P[i])
            increasing[i] = increasing[i-1]+1;
    }

    int ans = 1;
    int org_flag = true;
    vector<int> valid(n, 0);
    rep(i, k, n)
    {
        bool flag = false;
 
        int min_v = bottoms.top().first;
        if (min_v != P[i - k])
            flag = true;

        // update priority_queue
        while (bottoms.top().second <= i - k)
            bottoms.pop();
        tops.push(make_pair(P[i], i));
        bottoms.push(make_pair(P[i], i));
        while (tops.top().second <= i - k)
            tops.pop();
        
        if (P[i] != tops.top().first)
            flag = true;


        // cout << i << ' ' << increasing[i] << endl;
        if (increasing[i]>=k)
        {
            if (org_flag) org_flag = false;
            else flag = false;
        }

        if (flag) ++ans;
        // cout << i << ' ' << flag << endl;
        // cout << i << ' ' << P[i] << ' ' << max_v << ' ' << flag << endl;
        
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    ll W; cin >> W;
    vector<ll> w(N),v(N);
    rep(i,N) cin >> w[i] >> v[i];

    set<ll> st{0,W};
    rep(i,N){
        set<ll> tmp;
        for(const auto& v : st){
            tmp.insert(v+w[i]);
            if(v-w[i]>=0) tmp.insert(v-w[i]);
        }
        for(const auto& v : tmp) st.insert(v);
    }

    vector<ll> vs;
    map<ll,int> mp;
    for(auto& v : st) vs.emplace_back(v);
    for(int i=0;i<(int)vs.size();i++) mp[vs[i]] = i;


    int W2 = mp[W];

    vector<vector<ll>> dp(N+2,vector<ll>(W2+1,0));
    dp[0][0] = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=W2;j++){
            int real_w = vs[j];
            dp[i+1][j] = dp[i][j];
            if(vs[j]-w[i]>=0) dp[i+1][j] = max(dp[i+1][j],dp[i][ mp[real_w-w[i]] ]+v[i]);
        }
    }

    cout << dp[N][W2] << endl;
    /* cout << "W2 = " << W2 << endl; */

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


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define MAX_N 100000

vector<pii> adjlist[MAX_N];
vector<int> color(MAX_N, -1);

void dfs() {
    stack<int> s;
    s.push(0);
    color[0] = 0;
    while (!s.empty()) {
        int u = s.top(); s.pop();
        for (auto p: adjlist[u]) {
            int v = p.first; int w = p.second;
            if (color[v] >= 0) continue;
            s.push(v);
            if (w % 2 == 0) color[v] = color[u];
            else color[v] = (color[u] + 1) % 2;
        }
    }
}

int main() {
    int N; cin >> N;
    for (int i=0; i<N-1; i++) {
        int u, v, w; cin >> u >> v >> w;
        adjlist[u-1].push_back(pii(v-1, w));
        adjlist[v-1].push_back(pii(u-1, w));
    }
    dfs();
    for (int i=0; i<N; i++) {
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<ll> dp(n+1,INF);
    vector<ll> h(n,0);

    rep(i,n){
        cin >> h[i];
    }
    dp[0] = 0;
    
    for(int i=1;i<n;i++){
        if(i > 1) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
import operator
n,m = map(int,input().split())
list1 = [list(map(int,input().split())) for i in range(n) ]

list1.sort(key=operator.itemgetter(0))
count_drink = 0
count = 0
last = 0
i = 0
while m > count_drink:
    last = list1[i][1]
    while last > 0:
        if m <= count_drink:
            break
        count += list1[i][0]
        last -= 1
        count_drink += 1
    i += 1

print(count)
        

Measured memory_bytes: 64996
#include<iostream>
using namespace std;
int n;
int a[200000+5];
int main(){
	scanf("%d",&n);
	for(int i = 1; i <=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i = n;i >=1;i = i-2){
		printf("%d ",a[i]);
	}
	int i = 1;
	if(n%2==1)
		i =2;
	for(;i <= n;i=i+2){
		printf("%d ",a[i]);
	}
	//for(int i = 0;i<n;i++)
		
	printf("\n");
	return 0;
} 

Measured memory_bytes: 2944