akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main(){
    ll K, S;
    cin >> K >> S;
    ll cnt = 0;
    for(int X=0; X<=K; ++X){
      for (int Y = 0; Y<=K; Y++){
          ll Z = S - X - Y;
          if (Z >= 0 && Z <= K) cnt++;
      }
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  long long n, m;
  cin >> n >> m;

  long long ans;
  if (n == 1 && m == 1){
    ans = 1;
  } else if ( n == 1 || m == 1){
    ans = max(n, m) - 2;
  } else {
    ans = (n-2) * (m-2);
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


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



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

int N, Q;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> Q;
    string S;
    cin >> S;
    int l[Q], r[Q], mat[N];
    REP(i, 0, Q){
        cin >> l[i] >> r[i];
        l[i] -= 1;
        r[i] -= 1;
    }
    bool flag = false;
    if(S[0] == 'A') flag = true;
    mat[0] = 0;
    REP(i, 1, N){
        if(flag && S[i] == 'C'){
            mat[i] = mat[i-1] + 1;
            flag = false;
        }else if(S[i] == 'A'){
            flag = true;
            mat[i] = mat[i-1];
        }else{
            flag = false;
            mat[i] = mat[i-1];
        }
    }
    REP(i, 0, Q){
        cout << mat[r[i]] - mat[l[i]] << endl;
    }
}


Measured memory_bytes: 2256
/*input
4 6
0 1 2
1 2 3
1 3 9
2 0 1
2 3 6
3 2 4
*/


#include <bits/stdc++.h>
#define MAX 20
#define INF LLONG_MAX
using namespace std;

typedef long long int ll;

ll wt[MAX][MAX];

// O based indexing is being used for ease
// Node 1 will be represented at the Lowest Significant bit of the number
// Simply subtract one from each Node number incase the nodes are one based
// n is the number of cities

// Logic in short:
// Suppose we have some elements in the Set A (i)
// We see all the cities (in set A only) at which ending is possible
// Let the possible ending be j
// Since we have already calculated all these values for the present set i.e dp[i][j]
// We see other cities which have not been included in the set A
// Let these non included cities be k
// Let a new set B = set A U {k} 
// Let set B be called p
// dp[p][k] = min(dp[p][k], dp[i][j] + wt[j][k]);



ll dp[(1 << MAX) + 5][MAX];
ll n, m;
ll u,v,w;
ll p;

void initialize(){

	for(ll i = 0; i < n; i++)
		for(ll j = 0; j < n; j++){
			wt[i][j] = INF;
		}
	for(ll i = 0; i < ( 1 << n); i++)
		for(ll j = 0; j < n; j++)
			dp[i][j] = -1;
	dp[1][0] = 0;
}

void tsp()
{
	for(ll i = 1; i < (1 << n); i++){ 
		// This loop represents the current state, i.e the contents of the set
		for(ll j = 0; j < n; j++){
			// j variable tells the ending city
			// during the current state, the last station is j
			if(dp[i][j] == -1)
			{
				continue;// Incase its impossible to start at 0 and end at j, for eg dp[anyNumber][0], 
				//Since you cant start at 0 and end at 0
			} 
			for(ll k = 1; k < n; k++){
				//cout<<k<<endl;
				// This indicates the new city which is going to be included
				if(((i & (1 << k)) != 0) || wt[j][k] == INF) // Note that relational op > bitwise op
				{
					continue; // i.e. the city was already in the set
				}
				p = i | (1 << k); // the new state(join k)
				//cout<<i<<" "<<j<<" "<<k<<endl;
				if(dp[p][k] == -1)
					dp[p][k] = dp[i][j] + wt[j][k];
				else
					dp[p][k] = min(dp[p][k], dp[i][j] + wt[j][k]);
			}
		}
	}
}

ll minimum_cost()
{
	ll ans = INF;
	for(ll i = 1; i < n; i++)
	{
		if(dp[(1 << n) - 1][i] == -1 || wt[i][0] == INF) continue;
		ans = min(ans, dp[(1 << n) - 1][i] + wt[i][0]);
	}
	return ans;
}

int main()
{
	cin>>n; // number of cities
	cin>>m; // number of edges
	initialize();
	for(ll i = 0; i < m; i++)
	{
		cin>>u>>v>>w;
		wt[u][v] = w;
		//wt[v][u] = w;
	}
	//floyd_warshall();
	tsp();
	ll ans = minimum_cost();
	if(ans != INF) 
		cout<<ans<<endl;
	else cout<<-1<<endl;
	/*for(ll i = 0; i < n; i++)
	{
		for(ll j = 0; j < n; j++)
			cout<<wt[i][j]<<" ";
		cout<<endl;
	}
	cout<<n<<endl;
	for(ll i = 0; i < (1 << n); i++)
	{
		for(ll j = 0 ; j < n; j++)
			cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
}

Measured memory_bytes: 8208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

ll A[10005] = {};
ll Md;
ll MP[20005] = {};

void dp(ll x) {
  MP[0] = 0;
  for (int i = 1; i <= x; i++) {
    ll s = mod;
    for (int j = 1; j <= Md; j++) {
      if (A[j] != 0) {
        if (i - j < 0) {
          s = min(s, A[j]);
        }
        else {
          s = min(s, MP[i - j] + A[j]);
        }
      }
    }
    MP[i] = s;
  }
  return;
}
  
int main() {
  ll h, n;
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    Md = max(Md, a);
    if (A[a] == 0) {
      A[a] = b;
    }
    else {
      A[a] = min(A[a], b);
    }
  }
  dp(h + Md);
  ll damage = MP[h];
  for (int i = h + 1; i < h + Md; i++) {
    damage = min(damage, MP[i]);
  }
  /*for (int i = 0; i < h + Md; i++) {
    cout << i << ' ' << MP[i] <<endl;
  }*/
  printf("%lld\n", damage);
} 


Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 105;

int n, A[MAXN];
double ans;

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    for (int i = 0; i < n; i++) {
        ans += 1.0 / A[i];
    }

    printf("%lf\n", 1 / ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[3][3];
int n;
int b[10];

int main()
{
    for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    scanf("%d",&a[i][j]);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    scanf("%d",&b[i]);

    bool memo[3][3]={};
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        for(int k=0;k<3;k++)
        if(a[j][k]==b[i])memo[j][k]=true;
    }
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(memo[i][j]==false)
            {
                break;
            }
            if(j==2)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(memo[j][i]==false)
            {
                break;
            }
            if(j==2)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    for(int i=0;i<3;i++)
    {
        if(memo[i][i]==false)
        {
            break;
        }
        if(i==2)
        {
            printf("Yes\n");
            return 0;
        }
    }
    for(int i=0;i<3;i++)
    {
        if(memo[i][2-i]==false)
        {
            break;
        }
        if(i==2)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
typedef struct{
	int x,y;
}Pos;
int comp(const void* a,const void* b){
	Pos p=*(Pos*)a,q=*(Pos*)b;
	if(p.x!=q.x) return p.x-q.x;
	else return p.y-q.y;
	
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
Pos pos[900000];
int cnt[10];
int s=0;
int main(void)
{
	int h,w,n,a,b,sum=0,i,j,k;
	Pos p;
	scanf("%d%d%d",&h,&w,&n);
	FOR(i,0,n){
		scanf("%d%d",&a,&b);
		FOR(j,0,3){
			FOR(k,0,3){
				int nx=b-j,ny=a-k;
				if(nx>=1&&ny>=1&&nx<=w-2&&ny<=h-2){
					pos[s].x=nx;
					pos[s++].y=ny;
				}
			}
		}
	}
	qsort(pos,s,sizeof(Pos),comp);
	/*FOR(i,0,s){
		printf("%d %d\n",pos[i].x,pos[i].y);
	}*/
	for(i=0;i<s;){
		j=0,p=pos[i];
		while(i<s&&p.x==pos[i].x&&p.y==pos[i].y) i++,j++;
		cnt[j]++;
		sum++;
	}
	printf("%lld\n",(ll)(w-2)*(h-2)-sum);
	FOR(i,1,10) printf("%d\n",cnt[i]);
	return 0;
}
    

Measured memory_bytes: 14332
N = int(input())
list1 = list(map(int, input().split()))
list2 = list1.copy()
check_l = []
for i in range(len(list1)):
    if (i+1) != list1[i]:
        check_l.append(i)
if len(check_l) <= 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"

int main()
{
    fast
  int x,n;
  cin>>x>>n;
  vector<int>arr;
  int ele;
  vector<int>mark(105,false);
  for(int i=0;i<n;i++)
  {
   cin>>ele;
   mark[ele]=true;
  }
  int i=x;
  int j=x;
  int ans=-1;
  while(i>=0 && i<=j){

      if(mark[i]==false|| mark[j]==false)
      {
        //   cout<<i<<" "<<j<<endl;
          if(mark[i]==false)
          {
              ans=i;
              break;
          }
          else if(mark[j]==false)
          {
              ans=j;
              break;
          }
      }
      i--;
      j++;
  }
  cout<<ans<<endl;
    bye
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a);
  for (auto&& e : p) {
    cin >> e;
  }
  vector<int> q(b);
  for (auto&& e : q) {
    cin >> e;
  }
  vector<int> r(c);
  for (auto&& e : r) {
    cin >> e;
  }
  sort(rbegin(p), rend(p));
  sort(rbegin(q), rend(q));
  sort(rbegin(r), rend(r));
  vector<int> v;
  v.insert(end(v), begin(p), begin(p) + x);
  v.insert(end(v), begin(q), begin(q) + y);
  v.insert(end(v), begin(r), end(r));
  sort(rbegin(v), rend(v));
  long long res = accumulate(begin(v), begin(v) + x + y, 0LL);
  cout << res << '\n';
}


Measured memory_bytes: 3232
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
priority_queue <int,vector<int>,less<int> > p;
int a[100005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        p.push(a[i]);
    }
    while(m--)
    {
        int x=p.top();
        x/=2;
        p.pop();
        p.push(x);
    }
    long long sum=0;
    for(int i=0;i<n;i++)
    {
        int y=p.top();
        p.pop();
        sum+=y;
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

typedef unsigned long long ull;

inline ull in()
{
	ull ret = 0, w = 0;
	char ch;
	while (!isdigit(ch))
	{
		w |= (ch == '-');
		ch = getchar();
	}
	while (isdigit(ch))
	{
		ret = (ret << 3) + (ret << 1) + (ch ^ 48);
		ch = getchar();
	}
	return w ? -ret : ret;
}

inline void out(ull x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9)
		out(x / 10);
	putchar(x % 10 + 48);
}

int main()
{

  ios::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
  
  int n;
  string s;
  cin >> n >> s;
  if (n < 3200) puts("red");
  else cout << s << endl;
	  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
using namespace std;
int main(){
    long int N,p,i,j,a;
    cin >> N;
    a = 0;
    long int A[2][N];
    for(i = 0;i < 2;i++){
        for(j = 0;j < N;j++){
            cin >> p;
            A[i][j] = p;
        }
    }
    for(i = 0;i < N;i++){
        p = 0;
        for(j = 0;j <= i;j++){
            p += A[0][j];
        }
        for (j = i; j < N; j++)
        {
            p += A[1][j];
        }
        if(a < p){
            a = p;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long



int main() {
	string S;
	cin >> S;
	char a = S[0], b = S[1];
	if (a == b) {
		b = S[2];
		if (a != b && b == S[3])
			cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if ((a == S[2] || a == S[3]) && (b == S[2] || b == S[3])) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vll A;
//***********//
int main() {
	cin >> N >> K;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = K; i < N; i++) {
		if (A[i - K] < A[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

int main(void){
    int n,t;
    float s;
    string q = "No";
    cin >> n;

    for(int i=1; i<=9; i++){
        s = n / i;
        t = n % i;
        if(t == 0){
            if(s <= 9){
                q = "Yes";
                break;
            } 
        }
    }
    cout << q << endl;

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,raw_input().split())
arr = []
for _ in range(m):
	a,b = map(int,raw_input().split())
	arr.append((b,a))
arr.sort()
mr = -1
ans = 0
for i in range(m):
	if mr > arr[i][1]:
		continue
	else:
		mr = arr[i][0]
		ans += 1
print ans

Measured memory_bytes: 40732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if((A < C && C < B) || (B < C && C < A)){
  	cout << "Yes" << endl; 
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
string key = "keyence";

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

	int i = 0;
	while (i < 7 && key[i] == s[i]) {
		i++;
	}

	int j = 6;
	while (j >= 0 && key[j] == s[n - 1 - (6 - j)]) {
		j--;
	}

	if (i + 6 - j >= 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int l = s.size();

  vector<int> number(26, 0);
  for (int i = 0; i < l; i++) {
    number[s[i] - 'a']++;
  }
  
  for (int i = 0; i < 26; i++) {
    if (number.at(i) == 0) {
      cout << (char)(i + 'a') << endl;
      break;
    }
    if (i == 25) cout << "None" << endl;
  }

}

Measured memory_bytes: 512
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
    x := getStdinIntArr()
    ans := 1
    for x[ans-1] != 0 {
        ans++
    }
    fmt.Println(ans)
}

// slice[start:end+1] = val
func fill(slice []int, val, start, end int) ([]int, error) {
    if len(slice) < start || len(slice) < end {
        return nil, fmt.Errorf("Error")
    }
    for i := start; i < end; i++ {
        slice[i] = val
    }
    return slice, nil
}

func getStdin() string {
    return readLine()
}
func getStdinInt() int {
    str := getStdin()
    res, _ := strconv.Atoi(str)
    return res
}
func getStdinIntArr() []int {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.Atoi(v)
    }
    return res
}
func getStdinArr() []string {
    str := getStdin()
    list := strings.Split(str, " ")
    return list
}
func getStdinIntArr64() []int64 {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int64, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.ParseInt(v, 10, 64)
    }
    return res
}
func readLine() string {
    buf := make([]byte, 0, 0)
    for {
        l, p, e := sc.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

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

int main()
{
    map<string, int> mp;
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    mp[s] = a;
    mp[t] = b;
    string u;
    cin >> u;
    mp[u]--;
    cout << mp[s] << " " << mp[t] << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[1000];
  int k;
  bool ans = true;
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  cin >> k;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(abs(a[i]-a[j])>k){
        ans = false;
        break;
      }
    }
  }
  if(ans == true){
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}


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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();
    let d: usize = iterator.next().unwrap().parse().unwrap();
    let e: usize = iterator.next().unwrap().parse().unwrap();
    let f: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans_water = 0;
    let mut ans_sugar = 0;
    for i in 0..=30 {
        for j in 0..=30 {
            let water = a * 100 * i + b * 100 * j;
            if water > f {
                continue;
            }
            // eprintln!("water = {:?}", water);

            let sugar_max = min(f - water, e * water / 100);
            // eprintln!("sugar_max = {:?}", sugar_max);
            for x in 0..=3000 {
                let s1 = c * x;
                if s1 > sugar_max {
                    break;
                }
                let s2 = d * ((sugar_max - s1) / d);
                let sugar = s1 + s2;
                // eprintln!("sugar = {:?}", sugar);
                if ans_sugar == 0 {
                    ans_water = water;
                    ans_sugar = sugar;
                } else {
                    if sugar * (ans_sugar + ans_water) > ans_sugar * (sugar + water) {
                        ans_water = water;
                        ans_sugar = sugar;
                    }
                }
            }
        }
    }
    format!("{} {}", ans_water + ans_sugar, ans_sugar)
}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)



int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  REP(i,n)cin >> vec[i];
  int c = 0;
  string ans = "YES";
  REP(i,n) if (vec[i] != i+1) c+=1; 
  if (c > 2) ans = "NO";
  cout << ans << endl;
}

Measured memory_bytes: 3628
import heapq
n,m=map(int,input().split())
a=list(map(lambda x: x*(-1),map(int,input().split())))
heapq.heapify(a)

for _ in range(m):
    k = heapq.heappop(a)*(-1) // 2
    heapq.heappush(a,k*(-1))
print(sum(a)*(-1))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
using P = pair<int, int>;
int main()
{
    int n; cin >> n;
    vector<P> s(n);
    rep(i, n) cin >> s[i].second >> s[i].first;
    sort(ALL(s));

    int t=-1, cnt = 0;
    rep(i, n){
        // printf("%d %d\n", s[i].second, s[i].first);
        if(t < s[i].second){
            cnt++;
            t = s[i].first;
        }
    }
    pr(cnt);
    return 0;}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	long double p[200010];
	for(ll i=0;i<n;i++){
		long double x;
		cin>>x;
		p[i]=x;
	}
	long double ch[200010]={};
	for(ll i=0;i<n;i++){
		long double now=(p[i]+1.0)/2;
		if(p[i]==1){
			now=1.0;
		}
		ch[i]=now;
		//printf("%.10Lf\n",now);
	}
	long double ans=0;
	for(ll i=0;i<k;i++){
		ans+=ch[i];
	}
	long double now=ans;
	for(ll i=0;i<n-k+1;i++){
	//printf("%.10Lf\n",now);		
		now-=ch[i];
		now+=ch[i+k];
		ans=max(now,ans);
	}
	printf("%.10Lf",ans);
	// your code goes here
	return 0;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N;
    cin >> N;
    Vec<i32> A(N, -1);
    u32 index = 0;
    for (u32 i = 0; i < N; i++) {
        u32 t;
        cin >> t;
        if (t % 2 == 0) A[index++] = t;
    }
    string res = "APPROVED";
    for (u32 i = 0; i < index; i++) {
        if (A[i] % 3 != 0 && A[i] % 5 != 0) res = "DENIED";
    }
    cout << res << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	string t;
	cin >> s >> t;
	map<char,char> str;
	map<char, ll> cnt;
	rep(i, s.size()) {
		if (cnt[t[i]] != 0 && str[t[i]] != s[i]) {
			cout << "No" << endl;
			return 0;
		}
		str[t[i]] = s[i];
		cnt[t[i]]++;
	}
	map<char, char> str2;
	map<char, ll> cnt2;
	rep(i, s.size()) {
		if (cnt2[s[i]] != 0 && str2[s[i]] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
		str2[s[i]] = t[i];
		cnt2[s[i]]++;
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 776
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;

vector <vector <int> > v;

int sol (int ind) {
	int d = v[ind].size();

	vector<int> s;
	for (int i=0;i<v[ind].size();i++) {
		s.push_back(sol(v[ind][i]));
	}
	sort(s.begin(),s.end());
	reverse(s.begin(),s.end());

	for (int i=0;i<s.size();i++) {
		d = max(d, s[i]+i+1);
	}

	return d;
}

int main () {
	int n, a;
	scanf ("%d", &n);
	v.resize(n);

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

	printf ("%d\n", sol(0));

	return 0;
}

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

using namespace std;

#define MOD 12
typedef vector<int> Vec;

int N,M;

bool rec(int idxT,int idxS,Vec &T,Vec &S){
    if(idxT == N && idxS == M) return 1;
    if(idxT == N || idxS == M) return 0;
    bool res = false;
    if(idxT+1 <= N && T[idxT] == S[idxS]){
        res |= rec(idxT+1,idxS+1,T,S);
    }
    if(idxT+2 <= N && (T[idxT]+1)%MOD == S[idxS]){
        res |= rec(idxT+2,idxS+1,T,S);
    }
    if(idxT-1 >= 0 && (T[idxT]-1+MOD)%MOD == S[idxS]){
        res |= rec(idxT-1,idxS+1,T,S);
    }
    return res;
}

int main(){
    int Tc;
    map<string,int> mp = {
        {"A",0},{"A#",1},
        {"B",2},
        {"C",3},{"C#",4},
        {"D",5},{"D#",6},
        {"E",7},
        {"F",8},{"F#",9},
        {"G",10},{"G#",11},
    };
    string in;
    cin >> Tc;
    while(Tc--){
        cin >> N >> M;
        Vec T(N);
        for(int i = 0 ; i < N ; i++){
            cin >> in;
            T[i] = mp[in];
        }
        reverse(T.begin(),T.end());
        Vec S(M);
        for(int i = 0 ; i < M ; i++){
            cin >> in;
            S[i] = mp[in];
        }
        reverse(S.begin(),S.end());
        bool can = rec(0,0,T,S) | rec(1,0,T,S);
        cout << (can ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 5504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
      
      	if((a*b)%2==1){
          System.out.println("Odd");
        }else{
          System.out.println("Even");
        }
	}
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long A, long long B, long long C){
    cout<<max(0LL,C-(A-B))<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    func(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>

using namespace std;

int a[3], b[3];
int cnt1, cnt2, cnt3, cnt4;

int main(){
  for(int i = 0; i < 3; ++i){
    cin >> a[i] >> b[i];
    if(a[i] == 1){
      cnt1++;
    }
    if(b[i] == 1){
      cnt1++;
    }
    if(a[i] == 2){
      cnt2++;
    }
    if(b[i] == 2){
      cnt2++;
    }
    if(a[i] == 3){
      cnt3++;
    }
    if(b[i] == 3){
      cnt3++;
    }
    if(a[i] == 4){
      cnt4++;
    }
    if(b[i] == 4){
      cnt4++;
    }
    
  }
  if(cnt1 > 2 || cnt2 > 2 || cnt3 > 2 || cnt4 > 2 ){
      cout << "NO" << endl;
    }else{
      cout << "YES" << endl;
    }

}

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

using namespace std;

typedef long long ll;

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

	ll n, k;
	cin >> n >> k;

	ll a, b;
	map<ll, ll> freq;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		freq[a] += b;
	}
	
	for (auto it : freq) {
		k -= it.second;
		if (k <= 0) {
			cout << it.first << endl;
			break;
		}
	}

    return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>

int main(void)
{
	int x,y,tmp;
	
	while(1){
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0) break;
		if(x > y) tmp = x,x = y,y = tmp;
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        if(n >= 10) {
          System.out.println(r);
          return;
        } else {
          System.out.println(r + 100*(10-n));
        }

    }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var ab = IO.RSInt;
            if (ab[0] + ab[1] == 15) WriteLine("+");
            else if (ab[0] * ab[1] == 15) WriteLine("*");
            else WriteLine("x");
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19060
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  FOR(i,0,1000000000){
    if(i%2==0){
      n*=3;
    }
    else{
      n/=3;
    }
  }
  co(3*n*n)
}

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

int main()
{
  int N, ac_count=0, wa_count=0, tle_count=0, re_count=0 ;
  string j;
  cin >> N;
  
  while(cin>>j){
    if(equal(j.begin(), j.end(), "AC")==true){
      ac_count++;
    }else if(equal(j.begin(), j.end(), "WA")==true){
      wa_count++;
    }else if(equal(j.begin(), j.end(), "TLE")==true){
      tle_count++;
    }else if(equal(j.begin(), j.end(), "RE")==true){
      re_count++;
    }
  }
  
  cout << "AC x " << ac_count << endl;
  cout << "WA x " << wa_count << endl;
  cout << "TLE x " << tle_count << endl;
  cout << "RE x " << re_count << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
//const int m=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}



int32_t main(){
	
	//FIO();
	int n,m,x;cin>>n>>m>>x;
	int c[n];
	int a[n][m];
	for(int i=0; i<n; i++){
		cin>>c[i];
		for(int j=0; j<m; j++)
			cin>>a[i][j];
	}
	int mini=INF;
	for(int i=1; i<=(1<<n); i++){
		int cost=0,t[m]={};
		for(int j=0; (1<<j)<=i; j++){
			if(i&(1<<j)){
				cost+=c[j];
				for(int k=0; k<m; k++){
					t[k]+=a[j][k];
				}
			}
		}
		bool good=true;
		for(int k=0; k<m; k++){
			if(t[k]<x)
				good=false;
		}
		if(good)
			mini=min(mini,cost);
	}
	if(mini==INF)
		cout<<"-1\n";
	else
		cout<<mini<<"\n";
	return 0;
		
}
		
		



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

using namespace std;

typedef int in;
#define int long long

in main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0 ; i < n - 1 ; i ++){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        else if(i < n - 2){
            if(s[i] == s[i + 2]){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1\n";
    return 0;
}


Measured memory_bytes: 512
def main():
    import sys
    n = int(input())
    a = list(map(int, input().split()))

    try:
        if a.index(0):
            print(0)
            sys.exit()
    except ValueError:
        pass

    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10 ** 18:
            print(-1)
            sys.exit()

    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a+b+1)/2<<"\n";
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
//#include <unordered_map>
//#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 1000, MAX_X = 5000;
int N;
int P[MAX_N];
int X[MAX_N];
int dp[MAX_N][MAX_X+1];
vector<int> child[MAX_N];

int memo_dp(int n, int k, vector<Pii> vp) {
  if (n == -1) return 0; 
  if (dp[n][k] >= -1) return dp[n][k];
  int ma = -1;
  if (k >= vp[n].fi) {
    int tmp = memo_dp(n-1, k-vp[n].fi, vp);
    if (tmp >= 0) ma = tmp + vp[n].fi;
  }
  if (k >= vp[n].sc) {
    int tmp = memo_dp(n-1, k-vp[n].sc, vp);
    if (tmp >= 0) ma = max(ma, tmp + vp[n].sc);
  }
  return dp[n][k] = ma;
}

Pii rec(int v) {
  if (child[v].size() == 0) return Pii(X[v], 0);

  vector<Pii> vp;
  int sum = 0;
  for (int i = 0; i < child[v].size(); ++i) {
    Pii pii = rec(child[v][i]);
    if (pii.fi < 0) return Pii(-1, 0);
    sum += pii.fi + pii.sc;
    vp.push_back(pii);
  }

  for (int i = 0; i <= child[v].size(); ++i) {
    for (int j = 0; j <= X[v]; ++j) {
      dp[i][j] = -2;
    }
  }
  int ma = memo_dp(child[v].size()-1, X[v], vp);

  if (ma < 0) return Pii(-1, 0);
  else {
    return Pii(X[v], sum-ma);
  }
}


int main() {

  cin >> N;
  for (int i = 1; i < N; ++i) {
    cin >> P[i]; --P[i];
  }
  for (int i = 0; i < N; ++i) cin >> X[i];

  if (N == 1) {
    cout << "POSSIBLE" << endl;
    return 0;
  }

  for (int i = 1; i < N; ++i) {
    child[P[i]].push_back(i);
  }

  Pii pii = rec(0);

  if (pii.fi <= 0) cout << "IMPOSSIBLE" << endl;
  else cout << "POSSIBLE"  << endl;

  return 0;
}



Measured memory_bytes: 25288
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();

        solver.call(in,out);
        out.close();
    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            int[] arr = new int[5];
            for(int i=0;i<arr.length;i++){
                arr[i] = in.nextInt();
                if(arr[i]==0)
                    out.println(i+1);
            }



        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }


    }
}

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

 long long int LCM(long long int arr[], int n)
{

    int max_num = 0;
    for (int i=0; i<n; i++)
        if (max_num < arr[i])
            max_num = arr[i];


     long long int res = 1;

    int x = 2;
    while (x <= max_num)
    {
        vector<int> indexes;
        for (int j=0; j<n; j++)
            if (arr[j]%x == 0)
                indexes.push_back(j);

        if (indexes.size() >= 2)
        {

            for (int j=0; j<indexes.size(); j++)
                arr[indexes[j]] = arr[indexes[j]]/x;

            res = res * x;
        }
        else
            x++;
    }


    for (int i=0; i<n; i++)
        res = res*arr[i];

    return res;
}

int main(){


    int n;

    int cs = 1;



        cin>>n;
        long long int arr[n],abb[n];

        long long int mul = 1;

        for(int i=0;i<n;i++){
            cin>>arr[i];
            abb[i] = arr[i];
            //mul *=arr[i];
        }

        long long int g = 0;

        /*for(int i=0;i<n;i++){
            g = __gcd(g,arr[i]);
        }*/

        long long int lcm = LCM(arr,n);


        long long int sum = 0;

        for(int i=0;i<n;i++){
            sum+=(lcm/abb[i]);
        }

        lcm *=1;


        double anGcd = __gcd(sum,lcm);

        double d = (lcm/anGcd)/(sum/anGcd);
        printf("%.14f\n", d);



}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int N, M;
    scanf("%d %d",&N, &M);
    M = M +1;
    int K[N];
    int A[N][M];
    for(int i = 0; i < N; i++){
        scanf("%d", &K[i]);
        for(int j = 0; j < K[i]; j++){
            scanf("%d",&A[i][j]);
        }
    }
    int check[M];
    for(int i = 0; i < M; i++){
        check[i] = 0;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < K[i]; j++){
            check[A[i][j]]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++){
        if(check[i] == N) ans ++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128