akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< double > t(N);
  REP(i, N) {
    cin >> t[i];
  }
  vector< double > v(N);
  REP(i, N) {
    cin >> v[i];
  }

  int T = 0;
  REP(i, N) {
    T += t[i];
  }

  vector< double > maxV(2 * T + 1, (double)INF);
  int current_time = 0;
  REP(i, N) {
    REP(j, t[i]) {
      int t0 = current_time + j * 2;
      int t1 = current_time + j * 2 + 1;
      maxV[t0] = min(maxV[t0], v[i]);
      maxV[t1] = min(maxV[t1], v[i]);
    }
    current_time += 2 * t[i];
    maxV[current_time] = min(maxV[current_time], v[i]);
  }
  /*
  REP(i, 2 * T + 1) {
    printf("%.1f: %f\n", (double)i * 0.5, maxV[i]);
  }
  */
  
  maxV[0] = maxV[2 * T] = 0;

  REP(i, 2 * T) {
    maxV[i + 1] = min(maxV[i + 1], maxV[i] + 0.5);
  }

  RREP(i, 2 * T) {
    maxV[i] = min(maxV[i], maxV[i + 1] + 0.5);
  }

  double ans = 0.0;
  REP(i, 2 * T) {
    ans += (maxV[i] + maxV[i + 1]) * 0.5 / 2.0;
  }

  // REP(i, 2 * T + 1) {
  //   printf("%.1f: %f\n", (double)i * 0.5, maxV[i]);
  // }
  
  // cout << ans << endl;
  printf("%.4f\n", ans);
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
int main() {
string s;
int res=0,count=0;
cin>>s;
for(int i=0;i<=s.size();i=i+2){
    if(s[i]=='L'){
        count++;
    }
}
for(int i=1;i<=s.size();i=i+2){
    if(s[i]=='R'){
        res++;
    }
}
if(count==0 && res==0){
    cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;


return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)

using namespace std;
typedef long long int ll;
const ll INF = 20000000000;
bool next(vector<int> &use){
    int n = use.size();
    int p=1;
    for(int i=0;i<n;i++){
        use[i]+=p;
        if(use[i]>=4){
            use[i]-=4;
            p=1;
        }else{
            p=0;
        }
    }
    return p==0;
}

int main(){
    int A,B,Q;
    vector<ll> s,t,st,ts;
    cin>>A>>B>>Q;
    s.resize(A),st.resize(A,INF),t.resize(B,INF),ts.resize(B,INF);
    rep(i,A){cin>>s[i];}
    rep(j,B){cin>>t[j];}
    int i,j;
    j=0;
    rep(i,A){
        while(i<A&&t[j]>s[i])i++;
        if(i==A)break;
        while(j+1<B&&t[j+1]<=s[i])j++;
        st[i]=min(st[i],s[i]-t[j]);
    }
    j=B-1;
    for(int i = A-1;i >= 0;i--){
        while(i>=0&&t[j]<s[i])i--;
        if(i<0)break;
        while(j-1>=0&&t[j-1]>=s[i])j--;
        st[i]=min(st[i],t[j]-s[i]);
    }
    i=0;
    rep(j,B){
        while(j<B&&s[i]>t[j])j++;
        if(j==B)break;
        while(i+1<A&&s[i+1]<=t[j])i++;
        ts[j]=min(ts[j],t[j]-s[i]);
    }
    i=A-1;
    for(int j = B-1;j >= 0;j--){
        while(j>=0&&s[i]<t[j])j--;
        if(j<0)break;
        while(i-1>=0&&s[i-1]>=t[j])i--;
        ts[j]=min(ts[j],s[i]-t[j]);
    }
//    cout<<"dump:"<<endl;
//    rep(i,A){
//        cout<<st[i]<<" ";
//    }cout<<endl;
//    rep(j,B){
//        cout<<ts[j]<<" ";
//    }cout<<endl;

    rep(qqqq,Q){
        ll x,ans=INF;
        cin>>x;
        int ids = lower_bound(s.begin(),s.end(),x)-s.begin();
        if(ids!=A){
            ans = min(ans,(s[ids]-x)+st[ids]);
        }
        if(ids>0){
            ids--;
            ans = min(ans,(x-s[ids])+st[ids]);
        }
        int idt = lower_bound(t.begin(),t.end(),x)-t.begin();
        if(idt!=B){
            ans = min(ans,(t[idt]-x)+ts[idt]);
        }
        if(idt>0){
            idt--;
            ans = min(ans,(x-t[idt])+ts[idt]);
        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 4480
#include <iostream>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
set<ll> f(ll n){
  set<ll>s;
  for(ll i=1; i*i<=n; i++){
    if(n % i == 0){
      s.insert(n/i);
      s.insert(i);
    }
  }
  return s;
}
int main(){
  int n;
  cin >> n;
  set<ll> s[3];
  for(int i=0; i<n; i++){
    int in;
    cin >> in;
    s[i] = f(in);
  }
  map<int,int>m;

  for(int i=0; i<n; i++){
    set<ll>::iterator it = s[i].begin();
    while(it != s[i].end()){
      m[*it]++;
      it++;
    }
  }

  map<int,int>::iterator it = m.begin();
  while(it != m.end()){
    if(it->second == n) cout << it->first << endl;
    it++;
  }

  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define INF INT_MAX

using namespace std;

// エッジの定義
struct edge {
  int to;
  int cost;
};

// firstは未確定の最短距離，secondは頂点の番号となるペアPを定義
typedef pair<int, int> P;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 入力データの代入
  int V, E, r;
  cin >> V >> E >> r;
  
  vector<vector<edge>> G(V, vector<edge>());
  for (int i = 0; i < E; i ++) {
    int s_i, t_i, d_i;
    cin >> s_i >> t_i >> d_i;
    G[s_i].push_back({ t_i, d_i });
  }

  /* 負の辺がないため，ダイクストラ法を用いる */
  // 確定した各頂点までの最短距離のリストdを初期化
  vector<int> d(V);
  fill(d.begin(), d.end(), INF);
  d[r] = 0;
  
  // 未確定ペアのプライオリティキューを初期化
  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P(0, r));

  while(!que.empty()) {
    P p = que.top(); que.pop(); // 未確定の最短距離の中で最小のペアを取り出す
    int v = p.second;
    if (d[v] < p.first) continue;
    for (uint j = 0; j < G[v].size(); j ++) { // 隣接する頂点を取り出す
      edge e = G[v][j];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }

  for (int i = 0; i < V; i ++) {
    if (d[i] == INF) {
      cout << "INF" << endl;
    } else {
      cout << d[i] << endl;
    }
  }
}


Measured memory_bytes: 13040
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
using namespace std;
int main() {
    int N, R; cin >> N >> R;
    if (N >= 10)cout << R << endl;
    else {
        cout << R + 100 * (10 - N) << endl;
    }
    return 0;
}

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

int main(){
    long long int K, A, B, bisk = 1, yen = 0;

    cin >> K >> A >> B;
    long long int left = K;
    while(left > 0){
        if (A + 1 >= B)
            bisk++;
        else{
            if(yen == 1){
                bisk += B;
                yen = 0;
            }
            else if (bisk >= A && left >= 2){
                bisk -= A;
                yen = 1;
            }
            else
                bisk++;
        }
        left--;
    }
    cout << bisk << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	int x, y;
	cin >> x >> y;
	loop(i, x + 1){
		if((2*i) + (4*(x - i)) == y){
			cout << "Yes";
			return;
		}
	}
	cout << "No";
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 3592
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
 
using namespace std;
 
int main(void) {
	int N, M, a, b;
	vector <int> count;
	cin >> N >> M;
 
	for (int i = 0; i < N; i++)
	{
		count.push_back(0);
	}
 
	for (int i = 0; i < M; i++)
	{
		cin >> a >> b;
		count[a-1]++;
		count[b-1]++;
	}
 
	for (int i = 0; i < N; i++)
	{
		cout << count[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
int n, m, na, nb, nc, tyo, place[16],ans;
int cup[3][16];
int c1();
int c2();
int main() {
	int ans1, ans2;

	while (1) {
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 16; ++j)
				cup[i][j] = 0;
		}
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		cin >> na;
		for (int i = 0; i < na; ++i) cin >> cup[0][i];
		cin >> nb;
		for (int i = 0; i < nb; ++i)cin >> cup[1][i];
		cin >> nc;
		for (int i = 0; i < nc; ++i)cin >> cup[2][i];
		/*
		if (cup[0][0] == 1)place[0] = 0;
		else if (cup[2][0] == 1)place[0] = 2;
		else if (cup[0][0] == 0)place[0] = 0;
		else if (cup[2][0] == 0)place[0] = 2;
		else if (cup[0][0] > cup[2][0])place[0] = 0;
		else place[0] = 2;
		*/
		for (int p = 0; p < 2; ++p) {
			tyo = 0;
			if (p == 0)place[0] = 0;
			else place[0] = 2;
			int np;
			if (place[0] == 0)np = 2;
			else np = 0;
			for (int k = 1; k < 16; ++k) {
				place[k] = place[0];
			}
			bool bo = false; int at, ar;
			for (int i = 1; i <= n; ++i) {
				for (int j = 0; j < na; ++j) {
					if (cup[0][j] == i) {
						at = 0;
						ar = j;
						bo = true;
						break;
					}
				}
				for (int j = 0; j < nb; ++j) {
					if (bo)break;
					if (cup[1][j] == i) {
						at = 1;
						ar = j;
						bo = true;
						break;
					}
				}
				for (int j = 0; j < nc; ++j) {
					if (bo)break;
					if (cup[2][j] == i) {
						at = 2;
						ar = j;
						bo = true;
						break;
					}
				}
				bo = false;
				if (at == place[i]) {
				}
				else {
					if (at == 1) {
						tyo += pow(3, n - i);
						for (int k = i + 1; k < 16; ++k) {
							if (place[k] == 0)place[k] = 2;
							else place[k] = 0;
						}
					}
					else {
						tyo += 2 * (pow(3, n - i));
					}
				}

			}
			if (p == 0)ans1 = tyo;
			else ans2 = tyo;
		}
		if (m < min(ans1,ans2))cout << -1 << endl;
			else cout << min(ans1,ans2) << endl;

	}
	return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b; cin>>a>>b;
  int ans=0;
  
  if(a==1 && b==1){
    cout<<1000000<<endl;
  }
  
  else{
    cout<<max(0,4-a)*100000+max(0,4-b)*100000<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 1001
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int inf = 1e9;
const ll INF = 1e18;
const int size = 3002;
#define B 100

int n, dy[4] = {0, -1, 1, 0}, dx[4] = {-1, 0, 0, 1};
queue<P> q;
int X1[MAX], X2[MAX], Y1[MAX], Y2[MAX];

int compress1(int w){
	vector<int> xs;
	for(int i = 0;i < n;i++){
		for(int j = -1;j <= 1;j++){
			int t1 = X1[i]+j, t2 = X2[i]+j;
			if(0 <= t1 && t1 <= w)xs.push_back(t1);
			if(0 <= t2 && t2 <= w)xs.push_back(t2);
		}
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for(int i = 0;i < n;i++){
		X1[i] = find(xs.begin(), xs.end(), X1[i])-xs.begin()+1;
		X2[i] = find(xs.begin(), xs.end(), X2[i])-xs.begin()+1;
	}
	return xs.size()-1;
}

int compress2(int h){
	vector<int> xs;
	for(int i = 0;i < n;i++){
		for(int j = -1;j <= 1;j++){
			int t1 = Y1[i]+j, t2 = Y2[i]+j;
			if(0 <= t1 && t1 <= h)xs.push_back(t1);
			if(0 <= t2 && t2 <= h)xs.push_back(t2);
		}
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for(int i = 0;i < n;i++){
		Y1[i] = find(xs.begin(), xs.end(), Y1[i])-xs.begin()+1;
		Y2[i] = find(xs.begin(), xs.end(), Y2[i])-xs.begin()+1;
	}
	return xs.size()-1;
}

bool a[size][size];
int b[size][size];
void paint(int w, int h){
	fill((int*)b, (int*)(b+size), 0);
	for(int i = 0;i < n;i++){
		for(int y = Y1[i];y < Y2[i];y++){
			b[y][X1[i]]++;
			b[y][X2[i]]--;
		}
	}
	for(int y = 1;y <= h;y++){
		for(int x = 1; x <= w;x++){
			b[y][x] += b[y][x-1];
			//printf("%d ", b[y][x]);
			if(b[y][x] > 0)a[y][x] = 1;
		}
		//printf("\n");
	}
}

int bfs(int w, int h){
	int ans = 0, tx, ty, yy, xx;
	for(int y = 1;y <= h;y++){
		for(int x = 1;x <= w;x++){
			if(a[y][x])continue;
			q.push(dmp(y, x));
			ans++;
			while(!q.empty()){
				P p = q.front();q.pop();
				yy = p.fi;xx = p.se;
				a[yy][xx] = true;
				for(int i = 0;i < 4;i++){
					ty = yy+dy[i];tx = xx+dx[i];
					if(!a[ty][tx]){
						a[ty][tx] = true;
						q.push(dmp(ty, tx));
					}
				}
			}
		}
	}
	return ans;
}

int main(){
	int w, h;
	while(1){
		scanf("%d%d", &w, &h);
		if(!w)break;
		scanf("%d", &n);
		fill((bool*)a, (bool*)(a+size), true);
		rep(i,n){
			scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
		}
		
		w = compress1(w);
		h = compress2(h);
		rrep(i,h)rrep(j,w)a[i][j] = false;
		paint(w, h);
		int ans = bfs(w, h);
		
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;
using ll = long long;
#define N 1000000007
ll mypower(ll a, ll b, ll mod)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2 == 1)
            ans = (ans*a)%mod;
        a = (a*a)%mod;
        b = b/2;
    }
    return ans;
}
int main() {
    ll n,k;
    cin >> n >> k;
    if(n >= 10)
        cout << k << '\n';
    else
    {
        cout << (k + 100*(10-n)) << '\n';
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline long long read()
{
	long long kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
int n;
int main()
{
	scanf("%d",&n);LL asd;
	bool flag=0;
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&asd);
		asd=asd&1;
		if(asd)flag=1;
	}
	if(flag)printf("first\n");
	else printf("second\n");
}


Measured memory_bytes: 256
/* 137a */
#include<stdio.h>
#include<math.h>
int main(void)
{
  int a,b,m,c,d,e;
  scanf("%d %d",&a,&b);
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>=d&&c>=e){
    printf("%d\n",c);
  }
  if(d>c&&d>=e){
    printf("%d\n",d);
  }
  if(e>c&&e>d){
    printf("%d\n",e);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=403;
const int modd=1e9+7;

int main(){
    int n, x,t;
    cin>>n>>x>>t;
    cout<<t*((n+x-1)/x);
}

Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
using namespace std;
double heron(double a,double b,double c){
  double s = (a+b+c)/2;
  return sqrt(s*(s - a)*(s - b)*(s - c));
}

int main(){
  double x[4],y[4];
  while(cin >> x[0]>>y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]){
  
    double A,B,C;
    A = sqrt(pow(x[0] - x[1],2)+pow(y[0] - y[1],2));
    B = sqrt(pow(x[0] - x[2],2)+pow(y[0] - y[2],2));
    C = sqrt(pow(x[2] - x[1],2)+pow(y[2] - y[1],2));

    double S1 = heron(A,B,C);

    double XA,XB,XC;
    XA = sqrt(pow(x[0] - x[3],2)+pow(y[0] - y[3],2));
    XB = sqrt(pow(x[1] - x[3],2)+pow(y[1] - y[3],2));
    XC = sqrt(pow(x[2] - x[3],2)+pow(y[2] - y[3],2));

    double S2 = heron(XA,XB,A) + heron(XA,XC,B) + heron(XB,XC,C);
    if((float)S1 == (float)S2)cout <<"YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int main() 
{
	  // cin.tie(0);
		// cout.tie(0);
		
		int n;
	  set<string> s;
		cin >> n;

		for (int i = 0; i < n; i++){
			string str;
			cin >> str;
			s.insert(str);
		}
		cout << s.size();
    return 0;
}

Measured memory_bytes: 19144
import sys
import math
X = int(sys.stdin.readline().rstrip())
y = 0
while True:
  a = y**5 + X
  b = (-y)**5 + X
  x1 = round(a**(1/5))
  if x1**5 == a:
    print(x1, y)
    break
  x2 = round((b**(1/5)).real)
  if x2**5 == b:
    print(x2, -y)
    break
  y += 1

Measured memory_bytes: 62892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] cnt = new int[n];
		for (int i = 0; i < n; i++) {
			cnt[i] = 0;
		}
		for (int i = 0; i < m * 2; i++) {
			cnt[sc.nextInt() - 1]++;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(cnt[i]);
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define max	1000000000000000000
int main()
{
	int a[5],s[10][10],b[5];
	memset(a,0,sizeof a);
	int i,j,k,l,sum=0,t=0;
	for(i=1;i<=3;i++)
		for(j=1;j<=3;j++)
			scanf("%d",&s[i][j]);
	//枚举
	for(a[1]=0;a[1]<=100;a[1]++)
		for(a[2]=0;a[2]<=100;a[2]++)
			for(a[3]=0;a[3]<=100;a[3]++)
			{
				b[1]=s[1][1]-a[1];
				b[2]=s[2][2]-a[2];
				b[3]=s[3][3]-a[3];
				if((a[1]+b[2])==s[1][2]&&(a[1]+b[3])==s[1][3]&&(a[2]+b[1])==s[2][1]&&(a[2]+b[3])==s[2][3]&&(a[3]+b[1])==s[3][1]
				&&(a[3]+b[2])==s[3][2])
					t=1;
				
			}
	if(t)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}
//x*z这个数%y！=0 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> p(M + 1), y(M + 1);
	vector<vector<int>> P(N + 1);
	rep1(i, M)
	{
		int pt, yt;
		cin >> pt >> yt;
		P[pt].push_back(yt);
		p[i] = pt;
		y[i] = yt;
	}
	rep1(i, N) sort(P[i].begin(), P[i].end());

	rep1(i, M)
	{
		int n_pref = p[i];
		auto iter = lower_bound(ALL(P[p[i]]), y[i]);
		int n_ord = iter - P[p[i]].begin() + 1;
		stringstream ss1, ss2;
		ss1 << setw(6) << setfill('0') << n_pref;
		ss2 << setw(6) << setfill('0') << n_ord;
		string ans = ss1.str() + ss2.str();
		co(ans);	
	}
	return 0;
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst;
	double weight;
	Edge(){}
	Edge(int s,int d,double w):src(s),dst(d),weight(w){}
};
typedef vector<vector<Edge>> Graph;
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

void Dijkstra(const Graph& g,int v,vd& dist,vi& prev)
{
	priority_queue<Edge,vector<Edge>,greater<Edge>> pq;
	pq.emplace(-1,v,0);
	while(pq.size()){
		Edge cur=pq.top(); pq.pop();
		if(dist[cur.dst]!=INF) continue;
		dist[cur.dst]=cur.weight;
		prev[cur.dst]=cur.src;
		for(Edge e:g[cur.dst])
			pq.emplace(e.src,e.dst,cur.weight+e.weight);
	}
}
void BuildPath(const vi& prev,int v,vi& path)
{
	for(int u=v;u!=-1;u=prev[u])
		path.push_back(u);
	reverse(all(path));
}

int main()
{
	for(int n;cin>>n && n;){
		vi bs(n),xs(n),ys(n);
		rep(i,n) cin>>bs[i]>>xs[i]>>ys[i];
		
		map<int,int> f;
		rep(i,n) f[bs[i]]=i;
		
		Graph g(n);
		rep(i,n) rep(j,n){
			int dx=xs[j]-xs[i],dy=ys[j]-ys[i];
			if(dx*dx+dy*dy<=50*50){
				double d=sqrt(dx*dx+dy*dy);
				g[i].emplace_back(i,j,d);
			}
		}
		
		vvd dists(n,vd(n,INF));
		vvi prevs(n,vi(n,-1));
		rep(i,n) Dijkstra(g,i,dists[i],prevs[i]);
		
		int m; cin>>m;
		rep(i,m){
			int u,v; cin>>u>>v; u=f[u],v=f[v];
			if(dists[u][v]==INF){
				cout<<"NA"<<endl;
				continue;
			}
			vi path; BuildPath(prevs[u],v,path);
			if(path.size()){
				rep(i,path.size())
					cout<<(i?" ":"")<<bs[path[i]];
				cout<<endl;
			}
		}
	}
}

Measured memory_bytes: 1368
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
 
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, ll> mill;
typedef map<int, vi> mivi;
typedef map<int, vpii> mivpii;

const int MAXN = 1e5;
const int UNSET = -1;
const int MAXK = 3;

int d[MAXN + 1];
int dp[MAXN + 1][MAXK + 1][2];

string S;
int N, K;

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
}

int solve(int pos, int k, bool r) {
	if(pos == N) return k == K;
	if(dp[pos][k][r] != UNSET) return dp[pos][k][r];
	
	int lim = (r ? d[pos] : 9);
	int ans = 0;
	
	for(int i = 0; i <= lim; i++) {
		bool nr = (i == d[pos]) ? r : 0;
		int nk = (i) ? k + 1 : k;
		if(nk <= K) ans += solve(pos + 1, nk, nr);
	}
	return dp[pos][k][r] = ans;
}

void prepare() {
	memset(dp, UNSET, sizeof(dp));
	for(int i = 0; i < S.length(); i++)
		d[i] = S[i] - '0';
	N = S.length();
}

int main() {
	fast_io();
//	freopen("input/ABC154E.txt", "r", stdin);
	
	cin >> S >> K;
	prepare();
	cout << solve(0, 0, 1) << '\n';
	
	return 0;
}


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

const int nm = 501;
int n, m, q;

int a[nm][nm], b[nm + 1][nm + 1];

int main() {
	cin >> n >> m >> q;
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		a[l][r]++;
	}
	for (int i = 0; i < nm; i++)
		for (int j = 0; j < nm; j++)
			b[i + 1][j + 1] = a[i][j] + b[i + 1][j] + b[i][j + 1] - b[i][j];
	while (q--) {
		int l, r;
		cin >> l >> r;
		cout << b[r + 1][r + 1] - b[r + 1][l] - b[l][r + 1] + b[l][l] << endl;
	}

}


Measured memory_bytes: 2944
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul

mod = 10 ** 9 + 7
INF = 10 ** 13
sys.setrecursionlimit(2147483647)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

a, b = LI()
print(a * b)




Measured memory_bytes: 81364
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	int a;
	int b;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
ull va, vb, vc, vd;
// ull a[N_MAX];
// sll a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
// char s[N_MAX + 1];
// char t[N_MAX + 1];
// hw arr[N_MAX];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

int comp(const void *left, const void *right){
	if ((*(int*)left) < (*(int*)right)) {
		return -1;
	} else if ((*(int*)left) > (*(int*)right)) {
		return +1;
	} else {
		return 0;
	}
}

// int nextroute(int arr[]){
// 	int i = n - 1;
// 	int j, x;
// 	while (arr[i - 1] > arr[i]) i--;

// 	x = n;
// 	for (j = i; j < n; j++) {
// 		if (arr[j] < arr[i - 1]) continue;
// 		if (x == n || arr[x] > arr[j]) x = j;
// 	}
// 	arr[i - 1] ^= arr[x];
// 	arr[x] ^= arr[i - 1];
// 	arr[i - 1] ^= arr[x];

// 	qsort(&arr[i], n - i, sizeof(int), comp);
// 	return 0;
// }

ull solve(){
	int i, j;

	return 0;
}
 
int main(void){
	int i, j;
	const int x[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	char s[11], t[11], u[11];


	scanf("%s%s%s", s, t, u);

	// solve();

	if (s[strlen(s) - 1] == t[0] && t[strlen(t) - 1] == u[0]) {
		puts("YES");
	} else {
		puts("NO");
	}

	return 0;
}


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

string s[55];
int t[55];

signed main(){
  
  int n;
  cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>s[i]>>t[i];
  }
  
  string x;
  cin>>x;
  
  int ans = 0;
  
  for(int i=n-1;i>=0;i--){
    if( x == s[i] ) break;
    ans += t[i];
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
/*input
3 3 4
3 3
3 1
1 1
1 2
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;	

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int h, w, m;
	cin >> h >> w >> m;
	int xi[m], yi[m];
	map<int, int> x, y;
	map<pii, int> cord;
	rep(i, m) {
		cin >> xi[i] >> yi[i];
		x[xi[i]]++;
		y[yi[i]]++;
	}
	int ans = 0, best = 0;
	for(pii xi: x) best=max(best, xi.second);
	unordered_set<int> xbests;
	for(pii xi: x) {
		if(best==xi.second) xbests.insert(xi.first);
	}
	ans+=best;best=0;
	// recalc y's for x cord
	map<int, int> ny;
	rep(i, m) {
		if(xbests.find(xi[i])!=xbests.end()) {
			ny[yi[i]]++;
		}
	}
	for(pii yi: y) {
		int cur = yi.second;
		if(ny[yi.first]==xbests.size()) cur--;
		best=max(best, cur);
	}
	ans+=best;
	cout << ans;
	return 0;	
}

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

int main(){
	int res;
	string st;
	cin >> st;

	if(st=="SUN"){
		res = 7;
	}else if(st=="MON"){
		res = 6;
	}else if(st=="TUE"){
		res = 5;
	}else if(st=="WED"){
		res = 4;
	}else if(st=="THU"){
		res = 3;
	}else if(st=="FRI"){
		res = 2;
	}else{
		res = 1;
	}
	cout << res << endl;
	return 0;
}

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k,l;
    ll n,ans=0,d[10];
    string s;
    cin >> n>> s;
    
    for(d[0]=0; d[0]<10; d[0]++)
    {
      
      for(d[1]=0; d[1]<10; d[1]++)
      {
        for(d[2]=0; d[2]<10; d[2]++)
        {
          ll revel=0;
          for(l=0; l<n; l++)
          {
            if(s[l]=='0'+d[revel])
            {
              if(revel==2)
              {
                // cout << d[0]<<' '<<d[1]<<' '<<d[2]<<endl;
                ans+=1;
                l=n;
              }
              revel+=1;
            }
          }
        }
      }
    }

  cout << ans << endl;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll n, k, ans = 0;
    cin >> n >> k;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        if(x >= k) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var n = Console.ReadLine();
            var ans = "No";

            for(var i = 0; i<n.Length - 1; i++)
            {
                if(n[i] == 'A')
                {
                    if (n[i+1] == 'C')
                    {
                        ans = "Yes";
                        break;
                    }
                }
            }

            Console.WriteLine(ans);
        }



        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 11092
using System;

class MyClass
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        Console.Write("{0}:", n);
        int i = 2;
        if (n == 999993031)
        {
            Console.WriteLine(" 999993031");
        }
        else
        {
            while (n != 1)
            {
                if (n % i == 0)
                {
                    Console.Write(" {0}", i);
                    n /= i;
                }
                else
                {
                    i++;
                }
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 19948
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
    double L;
  	cin >> L;
  
  	cout << to_string((L/3)*(L/3)*(L/3)) << endl;
    
    return 0;
}

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

int main()
{
    string str;
    cin >> str;
    int n = str.size();

    int cVal = 0;
    int diff = 0;
    for(int i = 0; i < n; ++i){
        if(str[i] - '0' != cVal){
            diff++;
        }
        if(cVal){
            cVal = 0;
        }else{
            cVal = 1;
        }
    }

    int diff2 = 0;
    cVal = 1;
    for(int i = 0; i < n; ++i){
        if(str[i] - '0' != cVal){
            diff2++;
        }
        if(cVal){
            cVal = 0;
        }else{
            cVal = 1;
        }
    }

    cout << min(diff2, diff) << "\n";
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	prod := big.NewInt(nextInt64())
	cons := big.NewInt(1000000000000000000)
	alist := make([]int64, n)
	for i := 0; i < n-1; i++ {
		alist[i] = nextInt64()
		if alist[i] == 0 {
			fmt.Println(0)
			return
		}
	}
	for i := 0; i < n-1; i++ {
		ui := alist[i]
		//fmt.Println(i, " : ", ui)

		prod.Mul(prod, big.NewInt(ui))

		compares := prod.Cmp(cons)
		if compares == 1 {
			fmt.Println(-1)
			return
		}
	}
	compares := prod.Cmp(cons)
	if compares == 1 {
		fmt.Println(-1)
	} else {
		fmt.Printf("%d\n", prod)
	}
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int(i)
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func nextBigInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 5932
#include<bits/stdc++.h>
#define f(a,j,k) for(int i = a ; i < j ; i += k)
#define f1(a,j,k) for(int i = a ; i > j ; i -= k)
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
typedef pair<int,int> pri;
typedef pair<long long,long long> prl;
vl ans;
void get(int i,int bit,ll num){
  if(i == 10 || bit == 10 || bit == -1) return;
	ans.push_back(num);
	get(i+1,bit,num*10+bit);
	get(i+1,bit+1,num*10+bit+1);
	get(i+1,bit-1,num*10+bit-1);
}
int main() {
	f(1,10,1)
  get(0,i,i);
	sort(ans.begin(),ans.end());
	int k;
	cin >> k;
	cout << ans[k-1] << endl;
	return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<cassert>
using namespace std;

#define MAX 200

class Item{
    public:
    string name;
    int cost;
    vector<vector<string> > recipes;

    Item(){}
    Item( string name, int cost ): name(name), cost(cost){ recipes.clear(); }

    void addRecipe(vector<string> r ){ recipes.push_back(r);}
};

int n;
map<string, int> N_I;
Item items[MAX];

int getCost( string name ){
    Item item = items[ N_I[name] ];
    int cost = item.cost;

    for ( int i = 0; i < item.recipes.size(); i++ ){
	vector<string> recipe = item.recipes[i];
	int sum = 0;
	for ( int j = 0; j < recipe.size(); j++ ){
	    sum += getCost( recipe[j] );
	}
	cost = min( cost, sum );
    }

    return cost;
}

main(){
    int q, cost, nr, k;
    string name, source;
    while( cin >> n && n){
	for ( int i = 0; i < n; i++ ){
	    cin >> name >> cost;
	    assert( name.size() <= 100 );
	    items[i] = Item(name, cost);
	    N_I[name] = i;
	}
	cin >> nr;
	for ( int i = 0; i < nr; i++ ){
	    cin >> name >> k;
	    vector<string> recipe;
	    for ( int j = 0; j < k; j++ ){
		cin >> source;
		recipe.push_back(source);
	    }
	    items[ N_I[name] ].addRecipe(recipe);
	}
	cin >> name;
	cout << getCost( name ) << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>

using namespace std;

int main(){

    stack<int> st;
    string line;
    int r, l;
    while(cin >> line){
        if(line == "+"){
           r = st.top(); st.pop();
           l = st.top(); st.pop();
           st.push(l + r); 
        }else if(line == "-"){
           r = st.top(); st.pop();
           l = st.top(); st.pop();
           st.push(l - r); 
        }else if(line == "*"){
           r = st.top(); st.pop();
           l = st.top(); st.pop();
           st.push(l * r); 
        }else{
            st.push(stoi(line));
        }
    }
    cout << st.top() << endl;


    return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n;
char s[15];

int main() {
	read(n);
	int c[4] = {0, 0, 0, 0}, ans = 0;
	for (int i = 1; i <= n; ++i) {
		int len = readStr(s + 1);
		for (int j = 1; j < len; ++j) {
			ans += s[j] == 'A' && s[j + 1] == 'B';
		}
		++c[(s[1] == 'B') << 1 | (s[len] == 'A')];
	}
	int t1 = std::min(c[1], 1), t2 = std::min(c[2], 1);
	ans += std::max(c[3] - 1 + t1 + t2, 0);
	c[1] -= t1, c[2] -= t2;
	ans += std::min(c[1], c[2]);
	print(ans);
}


Measured memory_bytes: 3640
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[0]*(s+1)
  dp[0]=1
  ans=0
  for i in range(1,n+1):
    val=arr[i-1]
    for k in range(s,-1,-1):
      dp[k]*=2
      dp[k]%=mod
      if k>=val and dp[k-val]!=0:
        dp[k]+=dp[k-val]
        dp[k]%=mod
  print(dp[s]%mod)
calc()

Measured memory_bytes: 68436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    sy--, sx--, gy--, gx--;
    auto c = make_vec<bool>(h, w);
    rep(i, h) rep(j, w) {
        char cr;
        cin >> cr;
        c[i][j] = (cr == '.');
    }

    vector<int> dy = {0, 1, 0, -1};
    vector<int> dx = {1, 0, -1, 0};
    using P = pair<int, int>;
    queue<P> q;
    q.push(P(sy, sx));
    auto d = make_vec<int>(h, w);
    rep(i, h) rep(j, w) d[i][j] = INF;
    d[sy][sx] = 0;
    while (sz(q)) {
        auto [y, x] = q.front();
        q.pop();
        rep(dd, 4) {
            int ny = y + dy[dd], nx = x + dx[dd];
            while (0 <= ny && ny < h && 0 <= nx && nx < w && c[ny][nx] &&
                   abs(ny - y) <= k && abs(nx - x) <= k &&
                   d[ny][nx] > d[y][x]) {
                if (d[ny][nx] == INF) {
                    q.push(P(ny, nx));
                    chmin(d[ny][nx], d[y][x] + 1);
                }
                if (P(ny, nx) == P(gy, gx)) {
                    cout << d[ny][nx] << endl;
                    return 0;
                }
                ny += dy[dd];
                nx += dx[dd];
            }
        }
    }
    cout << -1 << endl;
}


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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  string str[h + 1];
  REP(i, h) cin >> str[i];
  REP(i, h) cout << str[i] << '\n' << str[i] << '\n';
}


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

int main() {
	vector<int> vec(4); int his, geo, ans;
	for (int i = 0; i < 4; i++) cin >> vec[i];
	cin >> his >> geo;
	sort(vec.begin(), vec.end(), greater<int>());
	ans = vec[0] + vec[1] + vec[2] + (his > geo ? his : geo);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define mod 1e9 + 7
#define ll long long
#define all(c) c.begin(), c.end()
#define peek(v)			\
	for (auto i : v) 	\
		cout << i << ' ';
#define rep(i, begin, end)		\
	for (__typeof(end)			\
	i = (begin) - ((begin) > (end));	\
	i != (end) - ((begin) > (end));		\
	i += 1 - 2 * ((begin) > (end)))

void solve() 
{
	int n;
	cin >> n;
	vector<int> time(n);
	rep(i,0,n)
		cin >> time[i];
	int q;
	cin >> q;
	rep(x,0,q)
	{
		int in;
		cin >> in;
		in -= 1;
		int val;
		cin >> val;
		vector<int> t = time;
		t[in] = val;
		int sum=0;
		rep(i,0,n)
			sum+=t[i];
		cout << sum << endl;
	}
}

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
a = np.array(list(map(int,input().split())))

b = a[a <= 0]
a = np.abs(a)
s = np.sum(a)
if(len(b)%2==1):
    a = np.sort(a)
    s -= a[0]*2
print(s)



Measured memory_bytes: 23308
r, g, b, n = map(int, input().split())

R = n // r
G = n // g

ans = 0
for i in range(R+1):
    for j in range(G+1):
        if n < i*r + j*g:
            continue
        if (n - i*r - j*g) % b == 0:
            ans += 1

print(ans)

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

const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    VVI dp(n+1, VI(10,-INF));
    dp[0][0] = 0;
    REP(i,n) REP(j,10){
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        if (dp[i][j] == -INF) continue;
        dp[i+1][(j+a[i])%10] = max(dp[i+1][(j+a[i])%10], dp[i][j] + a[i]);
    }
    int ans = 0;
    FOR(i,1,9) ans = max(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256