akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){

	int n;
	int i,j;	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
	
		if(i%3==0){printf(" %d",i); continue;}	//3????????°
		if(i%10==3){printf(" %d",i); continue;} //????????????3
		
		j=i;
		while(1){
			j/=10;
			if(j==0){break;}
			if(j%10==3){printf(" %d",i);break;}		//3??????????
		}
	
	}

	printf("\n");
	return 0;

}

Measured memory_bytes: 600
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    int c;
    if(op=='+') c=a+b;
    if(op=='-') c=a-b;
    if(op=='*') c=a*b;
    if(op=='/') c=a/b;
    cout << c << endl;
    cin >> a >> op >> b;
  }
  return 0;
}


Measured memory_bytes: 3112
(N,M,P),*E=[list(map(int,s.split()))for s in open(0).readlines()]
D=[0]*2+[-9e9]*N
def f():
    for _ in D:
        for (a,b,c)in E:D[b]=max(D[b],D[a]+c-P)
    return D[N]
s=f()
print([max(s,0),-1][s<f()])

Measured memory_bytes: 53180
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll n,m;
    cin>>n>>m;
    V key(m,0);
    V cost(m,0);
    rep(i,m){
        ll b;
        cin>>cost[i]>>b;
        rep(j,b){
            ll c;
            cin>>c;
            c--;
            key[i]+=(1<<c);
        }
    }
    V dp((1<<n),1e9);
    dp[0]=0;
    rep(i,m){
        rep(j,(1<<n)){
            dp[j|key[i]]=min(dp[j|key[i]],dp[j]+cost[i]);
        }
    }
    if(dp[(1<<n)-1]==1e9)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char x = sc.next().charAt(0);
        char y = sc.next().charAt(0);

        String result = "<";
        if (x > y) {
            result = ">";
        } else if (x == y) {
            result = "=";
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 35568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int main(){
	int n,m;
	cin >> n;
	cin >> m;
	if(n==m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main ()
 {
   int n, one, ten, hund, thou;
   cin >> n;
   thou = n / 1000;
   hund = (n - 1000 * thou) / 100;
   ten = (n - 1000 * thou - 100 * hund) / 10;
   one = n - 1000 * thou - 100 * hund -  10 * ten;
   if (ten == hund && (ten == one || hund == thou)) {
     cout << "Yes" << endl;
   }
   else {
     cout << "No" << endl;
   }
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 3001;
int n, s;
ll DP[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  DP[0] = 1;
  FOR(_, 0, n){
    int a;
    cin >> a;
    FORR(i, s, 0){
      DP[i] *= 2;
      if(i >= a) DP[i] += DP[i-a];
      DP[i] %= MOD;
    }
  }
  cout << DP[s] << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n]={0};
	float sum=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sum=round(sum/n);
	//cout<<sum<<endl;
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		ans=ans+pow((sum-a[i]),2);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
//https://atcoder.jp/contests/abc127/tasks/abc127_f
#include<bits/stdc++.h>
using namespace std;

struct median
{
private:
    priority_queue<int> firstHalf;
    priority_queue<int, vector<int>, greater<int> > secondHalf;
    long long int firstHalfSum = 0LL, secondHalfSum = 0LL;

public:
    void addValue(int num)
    {
        if(firstHalf.size() == 0 || firstHalf.top() >= num)
        {
            firstHalf.push(num);
            firstHalfSum += num;
        }
        else
        {
            secondHalf.push(num);
            secondHalfSum += num;
        }

        while(firstHalf.size() < secondHalf.size())
        {
            secondHalfSum -= secondHalf.top();
            firstHalfSum += secondHalf.top();
            firstHalf.push(secondHalf.top());
            secondHalf.pop();
        }

        while(firstHalf.size() - 1 > secondHalf.size())
        {
            firstHalfSum -= firstHalf.top();
            secondHalfSum += firstHalf.top();
            secondHalf.push(firstHalf.top());
            firstHalf.pop();
        }
    }

    long long int getMedian()
    {
        return firstHalf.top() * 1LL;
    }
    long long int getFirstHalfSum()
    {
        return firstHalfSum * 1LL;
    }
    long long int getSecondHalfSum()
    {
        return secondHalfSum * 1LL;
    }
    long long int getFirstHalfSize()
    {
        return firstHalf.size() * 1LL;
    }
    long long int getSecondHalfSize()
    {
        return secondHalf.size() * 1LL;
    }
};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;

    median m;
    long long int bSum = 0;
    while(n--)
    {
        int type;
        cin >> type;
        if(type == 1)
        {
            int a, b;
            cin >> a >> b;
            bSum += b;
            m.addValue(a);
        }
        else
        {
            long long int medianValue = m.getMedian();
            long long int firstHalfSize = m.getFirstHalfSize() - 1;
            long long int secondHalfSize = m.getSecondHalfSize();
            long long int firstHalfSum = m.getFirstHalfSum() - medianValue;
            long long int secondHalfSum = m.getSecondHalfSum();
            long long int ans = ((medianValue * firstHalfSize) - firstHalfSum) + (secondHalfSum - (medianValue * secondHalfSize));
            cout << medianValue << " " << ans + bSum << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const ll LINF=4000000000000000010;
vector<P> v[100010];
P ans[100010];
int digits(ll n){
    int dig=0; 
    while(n>0){
        n/=10;
        dig++;
    }
    return dig;
}

int main(){
	int n,m;cin>>n>>m;
	for(int i=0;i<m;i++){
		int p,y;cin>>p>>y;
		v[p].push_back(P(y,i));
	}
	for(int i=1;i<=n;i++)sort(all(v[i]));
	for(int i=1;i<=n;i++){
		for(int j=0;j<v[i].size();j++){
			ans[v[i][j].second]=P(j+1,i);
		}
	}
	for(int i=0;i<m;i++){
		int d1=digits(ans[i].first),d2=digits(ans[i].second);
		for(int j=0;j<6-d2;j++)cout<<0;
		cout<<ans[i].second;
		for(int j=0;j<6-d1;j++)cout<<0;
		cout<<ans[i].first<<endl;
	}
}	


Measured memory_bytes: 7808
import sys
input = sys.stdin.readline
from collections import deque

N,m = map(int,input().split())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

##### Settings
unit = 1
merge = lambda a, b: a * b % m
adj_bu = lambda a, i: a + 1
adj_td = lambda a, i, p: a + 1
adj_fin = lambda a, i: a
#####

ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in R[1:][::-1]:
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_fin(ME[R[0]], R[0])

for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])

    ac = unit
    for j in reversed(X[i]):
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_fin(merge(ME[j], TD[j]), j)

print(*XX, sep = "\n")

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,j,n) for(int i=j; i<n; i++)
#define INF 1000000000000000000 // If you use it, make sure not to put in "int" type variable ;(, use long long int
void optimizeIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); }
const ll mod=1000000007;

int main()
{
    optimizeIO();
    int nT; nT=1;
	while(nT--)
	{
		int a; cin>>a;
		string s; cin>>s;
		if(!(a<3200)) cout<<s;
		else cout<<"red";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 1e9+7;
struct UnionFind {
vector<int> d;
UnionFind(int n): d(n, -1) {}
int root(int x) {
if(d[x] < 0) return x;
return d[x] = root(d[x]);
}
bool unite(int x, int y) {
x = root(x); y = root(y);
if(x == y) return false;
if(d[x] > d[y]) swap(x, y);
d[x] += d[y];
d[y] = x;
return true;
}
bool same(int x, int y) {return (root(x) == root(y));}
int size(int x) {return -d[root(x)];}
};

signed main(){
    int n,m;
    cin >> n>> m;
    vector<pair<int,int> > p;
    vector<int> ans(m);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        p.push_back(make_pair(a, b));
    }
    ans[m-1]=n*(n-1)/2;
    UnionFind uf(n);
    RFOR(i,m-1,1) {
        pair<int,int> pp = p[i];
        if(uf.same(pp.first,pp.second)) {
            ans[i-1]=ans[i];
        }else{
            ans[i-1]=ans[i]-(uf.size(pp.first)*uf.size(pp.second));
        }
        uf.unite(pp.first, pp.second);
    }
    rep(i,m) {
        cout << ans[i] << endl;
    }
    return 0;

}


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

using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int NMAX = 100010;

char ubound[NMAX];

ll pow2[NMAX], pow3[NMAX];

int main() {
	pow2[0] = pow3[0] = 1;
	for (int i = 1; i < NMAX; ++i) {
		pow2[i] = (pow2[i-1] * 2) % MOD;
		pow3[i] = (pow3[i-1] * 3) % MOD;
	}
	scanf("%s", ubound);
	int n = strlen(ubound);
	ll ans = 0;
	// printf("starting with ")
	int setInPrefix = 0;
	for (int i = 0; i < n; ++i) {
		if (ubound[i] == '1') {
			ans = (ans + pow2[setInPrefix] * pow3[n-1-i] % MOD) % MOD;
			// printf("%lld ways if diverger is %d\n", pow2[setInPrefix] * pow3[n-1-i] % MOD, i);
			++setInPrefix;
		}
	}
	// printf("adding more %lld\n", pow2[setInPrefix]);
	ans = (ans + pow2[setInPrefix]) % MOD;
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int a , b ;
    cin >> a >> b ;
    if((a + b) % 2)
        cout << "IMPOSSIBLE\n";
    else
         cout << (a + b) / 2 ;
    return 0 ;
}

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

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

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

  int n; cin >> n;
  unordered_map<ll, ll> unmp;
  ll a;
  rep(i, n) {
    cin >> a;
    unmp[a]++;
  }

  ll ans = 0;
  for(auto elem : unmp) {
    if(elem.first != elem.second) {
      if(elem.second < elem.first) {
        ans += elem.second;
      } else {
        ans += elem.second-elem.first;
      }
    }
  }

  cout << ans << '\n';
  return 0;
}


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

using namespace std;
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

long long  gcd(long long  a, long long b) {
	if (a < b) return gcd(b, a);
	long long  r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {
	long long N, K, sum = 0;
	cin >> N >> K;
	vector<long long> H(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> H.at(i);
	}
	sort(H.begin(), H.end(), greater<int>());
	for (size_t i = 0; i < min(K,N); i++)
	{
		H.at(i) = 0;
	}
	for (size_t i = 0; i < N; i++)
	{
		sum += H.at(i);
	}
	cout << sum;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using PIII = pair<int, PII>;
using PLL = pair<ll, ll>;
using PLLL = pair<ll, PII>;

const double eps = 1e-10;

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;}

int N, M;
int S, T;
vector<PLLL> G[114514];
vector<PII> edge;
ll ue[2][214514] = {}, uv[2][114514] = {};
ll d[114514] = {}, d2[114514] = {};

const ll mod = 1e9+7;

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

	cin >> N >> M;
	cin >> S >> T; S--; T--;
	REP(i, M){
		int u, v, d;
		cin >> u >> v >> d; u--; v--;
		G[u].push_back({d, {v, i}});
		G[v].push_back({d, {u, i}});
		edge.push_back({u, v});
	}
	fill(d, d+114514, INF_LL);
	priority_queue<PLL, vector<PLL>, greater<PLL> > pq;
	d[S] = 0;
	pq.push({0, S});
	while(pq.size()){
		ll dd = pq.top().fs, v = pq.top().sc; pq.pop();
		if(dd > d[v]) continue;
		REP(i, G[v].size()){
			if(d[G[v][i].sc.fs] > d[v]+G[v][i].fs){
				d[G[v][i].sc.fs] = d[v]+G[v][i].fs;
				pq.push({d[G[v][i].sc.fs], G[v][i].sc.fs});
			}
		}
	}
	uv[0][T] = 1;
	pq.push({0, T});
	fill(d2, d2+114514, INF_LL);
	d2[T] = 0;
	while(pq.size()){
		ll dd = pq.top().fs, v = pq.top().sc; pq.pop();
		REP(i, G[v].size()){
			if(d[G[v][i].sc.fs] == d[v]-G[v][i].fs){
				ue[0][G[v][i].sc.sc] += uv[0][v];
				uv[0][G[v][i].sc.fs] += uv[0][v];
				ue[0][G[v][i].sc.sc] %= mod;
				uv[0][G[v][i].sc.fs] %= mod;
				if(d2[G[v][i].sc.fs] == INF_LL)
					pq.push({dd+G[v][i].fs, G[v][i].sc.fs});
				d2[G[v][i].sc.fs] = dd+G[v][i].fs;
			}
		}
	}
	uv[1][S] = 1;
	pq.push({0, S});
	fill(d, d+114514, INF_LL);
	d[S] = 0;
	while(pq.size()){
		ll dd = pq.top().fs, v = pq.top().sc; pq.pop();
		REP(i, G[v].size()){
			if(d2[G[v][i].sc.fs] == d2[v]-G[v][i].fs){
				ue[1][G[v][i].sc.sc] += uv[1][v];
				uv[1][G[v][i].sc.fs] += uv[1][v];
				ue[1][G[v][i].sc.sc] %= mod;
				uv[1][G[v][i].sc.fs] %= mod;
				if(d[G[v][i].sc.fs] == INF_LL)
					pq.push({dd+G[v][i].fs, G[v][i].sc.fs});
				d[G[v][i].sc.fs] = dd+G[v][i].fs;
			}
		}
	}

	ll res = (uv[0][S]*uv[0][S])%mod;
	REP(i, N){
		if(d[i] == d2[i]){
			ll mul = uv[0][i]*uv[1][i]%mod;
			res = (res-mul*mul%mod+mod)%mod;
		}
	}
	REP(i, M){
		long double dd = (long double)d[T]/2;
		int u = edge[i].fs, v = edge[i].sc;
		if(min((ld)d[u], (ld)d[v]) < dd && dd < max((ld)d[u], (ld)d[v])){
			ll mul = ue[0][i]*ue[1][i]%mod;
			res = (res-mul*mul%mod+mod)%mod;
		}
	}
	cout << res << endl;
}


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

using namespace std;

const int M = 3e3 + 3;
int n;
double t[M];
double dp[M][M];	

double solve (int i, int h) {
    if (i == n) {
        if (h > n-h) return 1.0;
        else return 0.0;
    }
    double &ret = dp[i][h];
    if (ret != -1.0) return ret;
    ret = 1;
    ret = solve (i+1, h+1) * t[i] + solve(i+1, h) * (1-t[i]);
    return ret;
}

int main () {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) cin >> t[i];
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) dp[i][j] = -1.0;
    }
    cout << fixed << setprecision(10) << solve (0, 0);
}


Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
#include<string.h>
int main()
{

    char a[110];
    char b[110];
    int i,j,la,lb;
    scanf("%s",a);
    scanf("%s",b);
    la=strlen(a);
    lb=strlen(b);
    sort(a,a+la);
    sort(b,b+lb);
    char c[110];
    for(i=0,j=lb-1; i<lb; i++,j--)
    {
        c[i]=b[j];
    }
    c[i]='\0';
    int term;
    if(la<=lb)
    {
        term=la;
    }
    else
    {
        term=lb;
    }
    int ok;
    for(i=0; i<term; i++)
    {

        if(a[i]<c[i])
        {
            ok=1;
            break;
        }
        if(a[i]>c[i])
        {
            ok=0;
            break;
        }
        if(a[i]==c[i])
        {
            ok=-1;

        }


    }
    if(ok==-1)
    {
        if(la==lb)
        {
            printf("No\n");
        }
       else  if(la<lb)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }

    }

    else if(ok==1)
   {
       printf("Yes\n");
   }
   else
   {
       printf("No\n");
   }

  return 0;



}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
  int f[N2];
  int space;
  string path;

  bool operator < ( const Puzzle &p ) const {
    for ( int i = 0; i < N2; i++ ) {
      if ( f[i] == p.f[i] ) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p) {
  for ( int i = 0; i < N2; i++ )
    if ( p.f[i] != (i + 1) ) return false;
  return true;
}

string bfs(Puzzle s) {
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u, v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while ( !Q.empty() ) {
    u = Q.front(); Q.pop();
    if ( isTarget(u) ) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for ( int r = 0; r < 4; r++ ) {
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
      v = u;
      swap(v.f[u.space], v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if ( !V[v] ) {
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }

  return "unsolvable";
}

int main() {
  Puzzle in;

  for ( int i = 0; i < N2; i++ ) {
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2;  // set space
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}


Measured memory_bytes: 30536
#include <stdio.h>
#define white 0
#define gray 1
#define black 2

int n, a[100][100], color[100], d[100], f[100], tt;


void dfs_visit(int u) {
    int v;
    color[u] = gray;
    d[u] = ++tt;
    
    
    for (v = 0; v < n; ++v) {
        if (a[u][v] == 1){
            if(color[v] == white) dfs_visit(v);
        }
    }
    color[u] = black;
    f[u] = ++tt;
    
}

void dfs() {
    int u;
    for (u = 0; u < n; ++u) {
        color[u] = white;
    }
    tt = 0;
    
    for (u = 0; u < n; ++u) {
        if (color[u] == white) dfs_visit(u);
    }
    
    for (u = 0; u < n; ++u) {
        printf("%d %d %d\n", u+1, d[u], f[u]);
    }
    
}

int main() {
    int i, j, u, k, b;
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            a[i][j]  = 0;
        }
    }
    
    for (i = 0; i < n; ++i) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; ++j) {
            scanf("%d", &b);
            a[u-1][b-1]  = 1;
        }
    }
    dfs();
    
    return 0;
    
}

Measured memory_bytes: 1812
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll N,i,ans,scount;
    cin>>N;
    vector<ll>A(N),S(N+1);
    for(i=0;i<N;i++)cin>>A[i];
    for(i=1;i<N+1;i++)S[i]=S[i-1]+A[i-1];
    sort(S.begin(),S.end());

    ans=0;
    for(i=0;i<N+1;i++){
        if(i==0){
            scount=1;
        }else if(S[i]==S[i-1]){
            scount++;
        }else{
            ans+=(scount*(scount-1))/2;
            scount=1;
        }
    }
    ans+=(scount*(scount-1))/2;
    cout<<ans<<'\n';
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N,0), B(M,0);
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];
    vector<ll> A_sum(N+1,0), B_sum(M+1,0);
    
    ll a_max_index = -1;
    ll b_max_index = -1;

    for ( ll i = 0; i < N; i++){
        A_sum[i+1] = A_sum[i] + A[i];
    }
    
    for (ll i = 0; i < M; i++){
        B_sum[i+1] = B_sum[i] + B[i];
    }

    ll ans = 0;
    rep(i,N+1){
        if (A_sum[i] > K) continue;
        ll index = upper_bound(B_sum.begin(), B_sum.end(), K-A_sum[i])-B_sum.begin()-1;
        ans = max(ans, i+index);
    }
    


    cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    map<char, int> mp;
    for(int i = 0; i < s.size(); i++){
        mp[s[i]]++;
    }
    bool f = true;
    if(mp['N'] and mp['S'] and !(mp['E']) and !(mp['W']));
    else if(!(mp['N']) and !(mp['S']) and mp['E'] and mp['W']);
    else if(mp['N'] and mp['S'] and mp['E'] and mp['W']);
    else f = false;

    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,j,a = 0,n;
    cin >> n;
    for (i = 1; i <= 20; i++){
        if(a != 0){
            break;
        }
        if(i*4 == n){
            cout << "Yes";
            a++;
            break;
        }
        else{
            if(i*7 == n){
                cout << "Yes";
                a++;
                break;
            }
            else{
                for (j = 0; j <= 15; j++){
                    if(i*4 + j*7 == n){
                        cout << "Yes";
                        a++;
                        break;
                    }
                }
            }
        }
    }
    if(a == 0){
        cout << "No";
    }
}

Measured memory_bytes: 256
// Author : Rifayat Samee (Sanzee)
// Problem :
// Algorithm:

/*

*/
#include <bits/stdc++.h>
using namespace std;
double memo[301][301][301];
int done[301][301][301],cc=1;
double dp(int a,int b,int c,const int &n){
    if(a < 0 || b<0 || c<0)return 0;
    if(!a && !b && !c){
        return 0;
    }
    if(done[a][b][c] == cc)
        return memo[a][b][c];
    double res = 0;
    double tot = a + b + c;
    double emp = n - tot;
    res = emp/tot;
    res = res + (a/tot)*(dp(a-1,b,c,n)+1) + (b/tot)*(dp(a+1,b-1,c,n)+1) + (c/tot)*(dp(a,b+1,c-1,n)+1);
    done[a][b][c] = cc;
    memo[a][b][c] = res;
    return res;
}
int main(){

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
    int n;
    scanf("%d",&n);
    int a,b,c;
    a = 0;
    b = 0;
    c = 0;
    for(int i = 0;i<n;i++){
        int val;
        scanf("%d",&val);
        if(val == 1) a++;
        else if(val == 2) b++;
        else
            c++;
    }
    printf("%.10lf\n",dp(a,b,c,n));
	return 0;
}


Measured memory_bytes: 319744
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lst = [i+1 for i in range(N)]
a = 0
b = 0
for i, l in enumerate(list(itertools.permutations(lst))):
    if (list(l) == P):
        a = i + 1
    if (list(l) == Q):
        b = i + 1
print(abs(a-b))

Measured memory_bytes: 46448
N=int(input())
A=map(int,input().split())

cnt = 0

for a in A:
	itemCnt = 0
	while a % 2 == 0:
		a /= 2
		itemCnt += 1

	# print( str(a) + "=" + str(itemCnt))
	cnt += itemCnt

print(cnt)


Measured memory_bytes: 3828
//write for s26

#include<bits/stdc++.h>
using namespace std;
int main() {
	int k;
	cin>>k;
	string s;
	cin>>s;
	for(int i=0;i<min(k,(int)s.size());i++) {
		cout<<s[i];
	}
	if(s.size()>k) {
		cout<<"..."<<endl;
	}
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 305;

int n,ans;

char s[MAXN][MAXN];

bool check(int v)
{
	for (int i = 0;i < n;i++)
		for (int j = 0;j < n;j++)
			if (s[i][(j + v) % n] != s[j][(i + v) % n])
				return 0;
	return 1;
}

int main()
{
	scanf("%d",&n);
	for (int i = 0;i < n;i++)
		scanf("%s",s[i]);
	for (int i = 0;i < n;i++)
		if (check(i))
			ans += n;
	printf("%d\n",ans);
	return 0;
}

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

const int N=100;
const long long INF=(1LL<<32);

int main(){
	int V, E;
	long long d[N][N];
	
	scanf(" %d %d", &V, &E);
	
	//?????????
	for(int i=0; i<V; ++i){
		for(int j=0; j<V; ++j){
			d[i][j] = ((i==j) ? 0 : INF);		
		}
	}
	
	//????????\???
	for(int i=0; i<E; ++i){
		int s, t;
		long u;
		scanf(" %d %d %ld", &s, &t, &u);
		d[s][t]=u; //????????????????????§??????????????????
	}
	
	//Warshall-Floyd???
	for(int k=0; k<V; ++k){
		for(int i=0; i<V; ++i){
			if(d[i][k]==INF) continue; //?????????????????????
			for(int j=0; j<V; ++j){
				if(d[k][j]==INF) continue; //?????????????????????
				d[i][j] = min(d[i][j], d[i][k]+d[k][j]);		
			}
		}
	}
	
	bool negative=false;
	for(int i=0; i<V; ++i)
		if(d[i][i]<0) negative=true;
		
	if(negative) printf("NEGATIVE CYCLE\n");
	else{
		for(int i=0; i<V; ++i){
			for(int j=0; j<V; ++j){
				if(j>0) printf(" ");	
				
				if(d[i][j]==INF) printf("INF");
				else cout<<d[i][j];
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 1300
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const a: string[] = tmp.shift().split(" ")[0].split("");
    const x = a[a.length - 1];
    switch (x) {
      case "2":
      case "4":
      case "5":
      case "7":
      case "9":
        return "hon";
      case "0":
      case "1":
      case "6":
      case "8":
        return "pon";
      default:
        return "bon";
    }
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v.at(i);
  }
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(v.begin(), v.end());
  vector<int> d(m - 1);
  for (int i = 0; i < m - 1; i++) {
    d.at(i) = abs(v.at(i) - v.at(i + 1));
  }
  sort(d.rbegin(), d.rend());
  int ans = accumulate(d.begin(), d.end(), 0);
  for (int i = 0; i < n - 1; i++) {
    ans -= d.at(i);
  }
  cout << ans << endl;

}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n * 2);
	for (int i = 0; i < n * 2; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//AnkitCode99
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define vl vector<ll>
#define all(v) (v.begin(),v.end())
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
using namespace std;
int main()
{
	fast;
 //   #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll c=0;
	rep(i,0,n-2)
	{
		if(s.substr(i,3)=="ABC")
			c++;	
	}
	cout<<c<<endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,q,l,r,pos=0,num;cin>>n>>q;string s;cin>>s;
  vector<ll> ac(n+1,0),ans(q,0);
  while(pos<n) {
    ac[pos+1]+=ac[pos];
    if(s[pos]=='A'&&s[pos+1]=='C') ac[pos+1]+=1;
    pos++;
  }
  rep(i,q) {
    cin>>l>>r;
    ans[i]+=ac[r-1]-ac[l-1];
  }
  rep(i,q) print(ans[i]);
  return 0;
}

Measured memory_bytes: 2640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	char x;
	for (int i=1; i<=n; i++)
	{
		cin >> x;
		if (i==m) x+=32;
		cout << x;
	}
	cout << endl;
	return 0; 
} 

Measured memory_bytes: 256
from itertools import product
s = input()
ans = 0
#opで+の候補生成
for op in product(["", "+"], repeat=len(s)-1):
    
    op = list(op)
    op.append("")
    #op=('', '+')の場合，1+""+2+"+"+5になる
    ans += eval(''.join( a + b for a, b in zip(s, op)))
print(ans)

Measured memory_bytes: 39792
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<math.h>
#include<queue>
using namespace std;

struct data_Node{
	int x,y,time;
};

char dataSet[1001][1001];
bool visited[1001][1001];
int H,W,N;

int total_time,total_storage,cnt_storage,cnt_time;
int start_row,start_cell;
int control_x[4] = {0,0,-1,1};
int control_y[4] = {-1,1,0,0};



void Find_Short_Path (int x,int y)
{
	memset(visited,false,sizeof(visited));
	data_Node temp_data;
	temp_data.x = x;
	temp_data.y = y;
	temp_data.time = 0;
	visited[x][y] = true;
	cnt_time = 0;
	queue<data_Node> temp_queue;
	temp_queue.push(temp_data);
	while (temp_queue.empty() != true)
	{
		data_Node u = temp_queue.front();
		temp_queue.pop();
		if ((int)(dataSet[u.x][u.y] - '0') == total_storage)
		{
			start_row = u.x;
			start_cell = u.y;
			cnt_time = u.time;
			break;
		}
		for (int i=0;i<4;i++)
		{
			int dx = u.x + control_x[i];
			int dy = u.y + control_y[i];
			if (dataSet[dx][dy] != 'X' && dx >= 0 && dx< H && dy >= 0 && dy < W)
			{
				data_Node v;
				v.x = dx;
				v.y = dy;	
				v.time = u.time + 1;//此?有坑
				if (visited[dx][dy] == false)
				{
					visited[dx][dy] = true;
					temp_queue.push(v);
				}
			}
		}
	}
}

int main ()
{

		cin>>H>>W>>N;
		memset(dataSet,'X',sizeof(dataSet));
		total_storage = 1;
		total_time = 0;
		for (int i=0;i<H;i++)
		{
			for (int j=0;j<W;j++)
			{
				cin>>dataSet[i][j];
				if (dataSet[i][j] == 'S')
				{
					start_row = i;
					start_cell = j;
				}
			}
		}
		int ans = 0;
		for (int i=1;i<=N;i++)
		{
			total_storage = i;
			Find_Short_Path(start_row,start_cell);
			ans += cnt_time;
		}
		cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll SUM(vector<ll>&& vec){return accumulate(all(vec),0LL);} // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
bool isPrime(ll n); // 素数か
vector<ll> primes(ll n); // 素因数分解
int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100); // combinationの最大値
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
void comb_init(); // 初期化
ll comb(ll n,ll k); // nCk

int main() { 

  //cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  print(n*n);
  return 0;
}

void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


/* 二分探索の時に使う
template<typename T>bool isOk(T key,T value){
  return key <= value;
}
template<typename T>T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
*/

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
 
using Graph = vector< vector< int > > ;
 
const int64_t smax = 1001001 * 3; 
vector<int64_t> seen(100002*3, smax);

 
int main() {
  int N,M,S,T;
  cin >> N >> M;
 
  Graph G(N*3);
  for (int i=0;i<M;++i ) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    G[3*a].push_back(3*b+1);
    G[3*a+1].push_back(3*b+2);
    G[3*a+2].push_back(3*b);
  }
  cin >> S >> T;
  --S; --T;
  queue<int> q;
  q.push(S*3);
  seen[S*3] = 0;
  while( !q.empty() ) {
    int v = q.front();
    q.pop();
    for( auto next_v : G[v] ) {
      if (seen[next_v] != smax) continue;
      seen[next_v] = seen[v] + 1;
      q.push(next_v);
    }
  }
  if (seen[T*3] != smax) cout << seen[T*3]/3 << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k,s;cin>>n>>k>>s;
    ll t = s+1;
    if(t>1000000000)t=1;
    for(int i=0; i<n; i++){
        if(i<k)cout<<s;
        else cout<<t;
        cout<<" ";
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


template<int d> int nearest(vector<INT> &l, INT pos)
{
	int begin = 0, end = l.size() - 1;

	while (1) {
		int half = (begin + end) / 2;
		if (pos < l[half])
		{
			end = half;
		}
		else
		{
			begin = half;
		}
		if (end - begin < 2)
		{
			if (d == 0)
			{
				return pos - l[begin] > l[end] - pos ? end : begin;
			}
			else if (d == 1)
			{
				return begin;
			}
			else
			{
				return end;
			}
		}
	}
}

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

	char* s = new char[n+1];

	cin >> s;

	int *an = new int[n];

	an[0] = 0;

	for (size_t i = 0; i < n-1; i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'C')
		{
			an[i + 1] = an[i] + 1;
		}
		else
		{
			an[i + 1] = an[i];
		}
	}

	vector<int> l(q), r(q);
	for (size_t i = 0; i < q; i++)
	{
		cin >> l[i] >> r[i];
	}

	for (size_t i = 0; i < q; i++)
	{
		cout << an[r[i] - 1] - an[l[i] - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

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

  if(a >= 13){
      cout << b << endl;
  }else if( a >= 6){
      cout << b / 2 << endl;
  }else{
      cout << "0" << endl;
  }
}


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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << " end.\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 2e5+5;
const int mod = 998244353;

int dp[N];
int sum[N];

LL get(int l, int r){
    if(l <= 1) l = 1;
    if(l > r) return 0;
    return ((sum[r] - sum[l-1])%mod + mod)%mod;
}

void solve(){
    int n, k;
    cin >> n >> k;

    vi L(k), R(k);
    vi st;
    for(int i = 0; i < k; ++i){
        cin >> L[i] >> R[i];
    }

    dp[1] = 1;
    sum[1] = 1;
    for(int i = 2; i <= n; ++i){
        for(int j = 0; j < k; ++j){
            dp[i] = (dp[i] + get(i-R[j], i-L[j])) % mod;
        }
        sum[i] = (sum[i-1] + dp[i])%mod;
    }

    cout << dp[n] << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 5208
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch, cw, dh, dw = ch-1, cw-1, dh-1, dw-1
s = [list(input()) for _ in range(h)]

def bfs(sy, sx):
    que = deque([])
    que.append([sy, sx])

    while que:
        y, x = que.popleft()
        dx, dy = [0,1,0,-1], [1,0,-1,0]
        for i in range(4):
            ny, nx = y+dy[i], x+dx[i]
            if ny < 0 or ny >= h or nx < 0 or nx >= w: continue
            if s[ny][nx] == '#': continue
            if seen[ny][nx] != -1: continue
            
            seen[ny][nx] = seen[y][x]
            que.append([ny, nx])
            wp.append([ny, nx])

            
dq = deque([])
dq.append([ch, cw])
seen = [[-1]*w for _ in range(h)]
seen[ch][cw] = 0
wp = deque([])
while dq:
    while dq:
        y, x = dq.popleft()
        wp.append([y, x])
        bfs(y, x)

    ok = False
    while wp:
        y, x = wp.popleft()
        for dy in range(-2, 3):
            for dx in range(-2, 3):
                if dy == 0 and dx == 0: continue
                ny, nx = y+dy, x+dx
                if ny < 0 or ny >= h or nx < 0 or nx >= w: continue
                if s[ny][nx] == '#': continue
                if seen[ny][nx] >= 0: continue

                ok = True
                seen[ny][nx] = seen[y][x] + 1
                dq.append([ny, nx])

    if not ok: break

if seen[dh][dw] >= 0:
    print(seen[dh][dw])
else:
    print(-1)

Measured memory_bytes: 143996
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    
    string S;
    int Q;
    
    cin >> S;
    cin >> Q;
    
    bool direction = true; //文字列を読む向き

    for(int i = 0; i < Q; i++){
        int task;

        cin >> task;
        
        if(task == 1){
            direction = !(direction);
            continue;
        }
        
        else{
            int F; char tuika;
            cin >> F >> tuika;
            
            if(direction == true){
                if(F == 1){
                    S.insert(S.begin(), tuika);
                }
                else{
                    S.insert(S.end(), tuika);
                }
            }
            else{
                if(F == 1){
                    S.insert(S.end(), tuika);
                }
                else{
                    S.insert(S.begin(), tuika);
                }    
            }
        }
    }
    
    if(!direction){
        reverse(S.begin(), S.end());
    }

    cout << S << endl;
    
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int maxn = 100010;
int nxt[20][maxn];

int main() {
    int n;
    cin >> n;
    V<int> x(n);
    rep(i, n) cin >> x[i];
    int L, Q;
    cin >> L >> Q;

    rep(i, n) {
        int p = upper_bound(ALL(x), x[i] + L) - x.begin();
        nxt[0][i] = p - 1;
    }

    rep(i, 19) {
        rep(j, n) {
            nxt[i + 1][j] = (nxt[i][j] == n - 1 ? n - 1 : nxt[i][nxt[i][j]]);
        }
    }

    while (Q--) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a > b) swap(a, b);
        int ans = 0;
        for (int j = 19; j >= 0; --j) {
            if (nxt[j][a] < b) {
                ans |= (1 << j);
                a = nxt[j][a];
            }
        }
        cout << ans + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin>> a[i];
    sort(a.begin(),a.end());
    ll sum =0;
    rep(i,n)
    {
        int cnt=1;
        while(a[i]==a[i+1])
        {
            cnt++; i++;
        }
        if(cnt>=a[i]) sum += cnt-a[i];
        else sum += cnt;
    }

    cout<< sum <<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1e6 + 10;
int n;
int a[N];
int p[N];
int s[N];

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		p[i + 1] = max(p[i], a[i]);
	}
	for (int i = n - 1; i > 0; --i) {
		s[i - 1] = max(s[i], a[i]);
	}
	for (int i = 0; i < n; ++i) {
		cout << max(p[i], s[i]) << " ";
	}
	cout << "\n";
	return 0;
}


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

vector<pair<ll, int> > comp;

void factorize(ll n) {
  ll cfp = 0;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      ll expo = 0;
      while (n % i == 0) {
        n /= i;
        expo++;
      }
      comp.emplace_back(make_pair(i, expo));
    }
  }
  if (n > 1) {
    comp.emplace_back(make_pair(n, 1));
  }
}

int main() { // claudio van
  ll a, b; cin >> a >> b;
  ll g = __gcd(a, b);
  factorize(g);
  cout << (int) comp.size() + 1 << endl;
  return 0;
}

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

ll gcd(ll a, ll b) {
	ll p = max(a,b);
	ll q = min(a,b);
	if (q == 0) return p;
	else return gcd(q, p%q);
}

ll lcm(ll a, ll b) {
	return a / gcd(a,b) * b;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> t(n);
	rep(i,n) cin >> t[i];
	ll ans;
	if (n==1) ans = t[0];
	else {
		ans = lcm(t[0],t[1]);
		for(ll i=2;i<n;i++) {
			ans = lcm(ans,t[i]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256