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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
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; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	// 1-0-1-0-1を作りたい, 1スタートにしたいからnow = 1 ; にする
	vector<int> Nums;
	int now = 1; // 今見ている数
	int cnt = 0; // now がいくつ並んでいるか
	rep(i, n) {
		if(s[i] == char('0' + now)) cnt ++;
		else {
			Nums.push_back(cnt);
			now = 1 - now;
			cnt = 1; // 新しいのをカウントし始めるk
		}
	}
	if(cnt != 0) Nums.push_back(cnt);
	//1-0-1-0-1 つまり要素数は奇数
	//1-0-1-0　みたいに0で終わってたら適当に1つ足す
	if(Nums.size() % 2  == 0) Nums.push_back(0);
	// どこまで見るか
	int Add = 2 * k + 1; 
	int ans = 0;
	for (int i = 0; i < Nums.size(); i+= 2)
	{
		int tmp = 0;
		int left = i; 
		int right = min(i + Add, (int)Nums.size());
		for (int j = left; j < right ; j++) {
			tmp += Nums[j];
		}
		ans = max(tmp,ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q;
  string s;
  cin>>n>>q>>s;
  vector<int> ac(n,0);
  vector<int> count(n,0);
  for(int i=0;i<n-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){ac[i+1]=1;}
    count[i+1]+=count[i]+ac[i+1];
  }
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<count[r-1]-count[l-1]<<endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

#define ing long long

int n, m;
int xx[4] = {0, -1, 0, +1};
int yy[4] = {-1, 0, +1, 0};

bool in(int x, int y) {
  return (x >= 0 && y >= 0 && x < n && y < m);
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  char mat[n][m];
  for (int i = 0; i < n; i++) cin >> mat[i];
  queue < pair <pair <int, int>, int > > q;
  int cnt = 0;
  bool used[n][m];
  memset(used, 0, sizeof used);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == '#') {
        q.push({{i, j}, 0});
        used[i][j] = 1;
        cnt++;
      }
    }
  }
  if (cnt == n * m) {
    cout << 0 << endl;
    return 0;
  }
  while (!q.empty()) {
    int x = q.front().first.first, y = q.front().first.second, w = q.front().second; q.pop();
    if (mat[x][y] == '.') {
      cnt++;
      mat[x][y] = '#';
    }
    used[x][y] = 1;
    if (cnt == n * m) {
      cout << w << endl;
      return 0;
    }
    for (int j = 0; j < 4; j++) {
      int nx = x + xx[j];
      int ny = y + yy[j];
      if (!in(nx, ny)) continue;
      if (used[nx][ny]) continue;
      used[nx][ny] = 1;
      if (mat[nx][ny] == '.') {
        q.push({{nx, ny}, w + 1});
      }
    }
  }
  return 0;
}


Measured memory_bytes: 14352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
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);
        BBounding solver = new BBounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBounding {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt(), x = s.nextInt();
            int count = 1, curr = 0;
            for (int i = 0; i < n; i++) {
                curr += s.nextInt();
                if (curr <= x)
                    count++;
            }
            w.println(count);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;

inline int get(int val, int ans = 0)
{
	for(; val; val /= 10) ans += (val % 10);
	return ans;
}

int n, ans = 1e9;
int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; ++i)
		ans = min(ans, get(i) + get(n - i));
	printf("%d", ans);
}

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


      string s;
      long long q;
      cin>>s>>q;
      long long r=0;
      while(q--)
      {
         long long p;
         cin>>p;
         if(p==1)
         {
           r++;
         }
         else
         {
           long long n;
           char c;
           cin>>n>>c;
           if((n==1 && r%2==0) || ((n==2) && r%2==1))
            s=c + s;
           else
            s+=c;
         }
      }
      if(r%2==1)
      {
        reverse(s.begin(),s.end());
      }

      cout<<s<<endl;

}


Measured memory_bytes: 4636
#include <iostream>
using namespace std;
int f[55],e[55][55];
inline int ff(int a)
{
	if(f[a]==a)
		return a;
	return f[a]=ff(f[a]);
}
int main(int argc, char** argv) {
	int n,m,ans=0;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin >> u >> v;
		e[u][v]=1;
		e[v][u]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(!e[i][j])
				continue;
			e[i][j]=0;
			for(int k=1;k<=n;k++)
				f[k]=k;
			for(int k=1;k<=n;k++)
			{
				for(int l=k+1;l<=n;l++)
				{
					if(e[k][l])
						f[ff(l)]=ff(k);
				}
			}
			for(int k=2;k<=n;k++)
			{
				if(ff(k)!=ff(k-1))
				{
					++ans;
					break;
				}
			}
			e[i][j]=1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
using namespace std;
 
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
 
#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

const double EPS = 1e-8;
 
typedef long long ll;
typedef pair<int, int> pii;

int n;
vector<double> sx, sy, sz;
int m;

set<int> ans;

#define POW(x) ((x)*(x))

void rotate(double &x, double &y, double theta)
{
	double sx, sy;
	const double C = cos(theta), S = sin(theta);
	sx = C * x - S * y;
	sy = S * x + C * y;

	x = sx;
	y = sy;
}

bool in_circle(double cx, double cy, double cz, double r, double x, double y, double z)
{
	double dist = (POW(x-cx)+POW(y-cy)+POW(z-cz));
	return dist <= POW(r);
}

void cnt()
{
	double tx, ty, tz, phi;
	cin >> tx >> ty >> tz >> phi;

	const double theta = atan2(tz, tx);
	rotate(tx, tz, -theta);

	const double theta2 = atan2(ty, tx);
	rotate(tx, ty, -theta2);

	const double height = tx * tan(phi);

	rep(i, n) {
		double x, y, z;
		x = sx[i]; y = sy[i]; z = sz[i];
		rotate(x, z, -theta);
		rotate(x, y, -theta2);

		if (x * tx < 0) continue;
		//if (abs(x) > abs(tx)) continue;

		double yp = (tx / x) * y;
		double zp = (tx / x) * z;
		if (in_circle(tx, 0, 0, height, tx, yp, zp))
			ans.insert(i);
	}
}

int main()
{
	while (cin >> n, n) {
		sx = vector<double>(n);
		sy = vector<double>(n);
		sz = vector<double>(n);
		rep(i, n)
			cin >> sx[i] >> sy[i] >> sz[i];

		cin >> m;
		ans.clear();
		rep(i, m)
			cnt();
		cout << ans.size() << endl;
	}
	return 0;
}

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

          using namespace std;
          typedef long long ll;
          string s;
          int n, ar[2323];
          bool p(int l, int r)
          {
            for(int i = l; i < r; i++)
              if(s[i] != s[r-i-1])
                return 0;
            return 1;    
          }
          int main()
          {
            cin >> s;
            n = s.size();
            if(p(0, ((n-1)/2)) && p(((n+3)/2)-1, n) && p(0, n))
              cout << "Yes";
            else cout << "No";              
          }

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


int sumW[300002];
int sumE[300002];
int sumWrev[300002];
int sumErev[300002];


int main(void)
{
	int N;
	string S;
	cin >> N;
	cin >> S;

	sumE[0] = sumW[0] = 0;
	for (int i = 1; i <= N; i++) {
		if (S[i-1]=='W') {
			sumW[i] = sumW[i-1]+1;
			sumE[i] = sumE[i-1];
		} else { // 'E'
			sumW[i] = sumW[i-1];
			sumE[i] = sumE[i-1]+1;
		}
	}
	sumWrev[N+1] = sumErev[N+1] = 0;
	for (int i = N; i >= 1; i--) {
		if (S[i-1]=='W') {
			sumWrev[i] = sumWrev[i+1]+1;
			sumErev[i] = sumErev[i+1];
		} else { // 'E'
			sumWrev[i] = sumWrev[i+1];
			sumErev[i] = sumErev[i+1]+1;
		}
	}

	int ans = N;

	for (int leader_pos = 1; leader_pos <= N; leader_pos++) {
		ans = std::min(ans, sumW[leader_pos-1] + sumErev[leader_pos+1]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5380
#include<stdio.h>
#include<stdlib.h>

#define MAX_APPLE 200

int main(void){
    
    int N,L,i,apple[MAX_APPLE],min_taste,result = 0;

    scanf("%d %d",&N,&L);

    for(i = 0;i < N;i++){
        apple[i] = L + i;
    }

    min_taste = abs(apple[0]);

    //printf("first_min_taste:%d\n",min_taste);

    for(i = 0;i < N;i++){
        //printf("taste:%d taste_abs:%d\n",apple[i],abs(apple[i]));
        if(min_taste > abs(apple[i])){
            min_taste = abs(apple[i]);
        }
    }

    //printf("min_taste:%d\n",min_taste);

    for(i = 0;i < N;i++){
        if(abs(apple[i]) != min_taste){
            result += apple[i];
        }
    }

    printf("%d",result);
    return 0;
}

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

template <typename T>
T gcd(T m, T n) {
    T r; while (r = m % n) m = n, n = r; return n;
}

template <typename T>
T lcm(T m, T n) {
    return m / gcd(m, n) * n;
}

int N;
long long answer = 1;

int main() {
    scanf("%d", &N);
    for (int i = 0; i != N; ++i) {
        long long T; scanf("%lld", &T);
        answer = lcm(answer, T);
    }
    printf("%lld\n", answer);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  char ch;

  while(1){
    
    scanf("%c",&ch);

    if (ch >= 'A' && ch <= 'Z'){

      ch += 0x20;

    } else if (ch >= 'a' && ch <= 'z'){

      ch -= 0x20;

    } else if (ch == '\n'){

      break;

    }

    printf("%c",ch);

  }

  printf("\n");

  return 0;

}

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

#define fastio iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int main(){
	fastio;

	long long n, m;
	cin >> n >> m;

	vector<pair<long long,long long>> vec(n, make_pair(0, 0));
	for (int i = 0; i < n; i++)
		cin >> vec[i].first >> vec[i].second;

	sort(vec.begin(), vec.end());

	long long ans = 0;
	for (int i = 0; i < n && m > 0; i++){
		ans += min(m, vec[i].second) * vec[i].first;
		m -= vec[i].second;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,k;
  cin>>n>>k;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  if(n<10){
    vector<int> v(n);
    iota(v.begin(),v.end(),0);
    do{
      vector<int> used(n,0),th;
      int ng=0;
      for(int i=0;i<n;i++){
        if(i){
          int pos=0,lst=0;
          for(int j=0;j<k;j++){
            int x=s[v[i]][j]-'A';
            if(!used[x]){
              lst=1;
              continue;
            }
            if(lst) pos=th.size();
            while(pos<(int)th.size()&&th[pos]!=x) pos++;
          }
          if(pos==(int)th.size()){
            ng=1;
            break;
          }
        }
        for(int j=0;j<k;j++){
          int x=s[v[i]][j]-'A';
          if(used[x]) th.erase(find(th.begin(),th.end(),x));
          th.insert(th.begin(),x);
          used[x]=1;
        }
      }
      if(ng) continue;
      for(int i=0;i<n;i++) cout<<char('A'+v[i]);
      cout<<endl;
      break;
    }while(next_permutation(v.begin(),v.end()));
    return 0;
  }

  vector<vector<int> > G(n+1);
  for(int i=0;i<n;i++) G[n].emplace_back(i);
  int cnt=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j) continue;
      int ng=0;
      for(int a=0;a<k;a++)
        for(int b=a+1;b<k;b++)
          for(int c=0;c<k;c++)
            for(int d=c+1;d<k;d++)
              ng|=(s[i][a]==s[j][c]&&s[i][b]==s[j][d]);
      if(!ng) G[i].emplace_back(j);
      cnt+=!ng;
    }    
  }
  //cout<<cnt<<endl;

  vector<int> us(n,0);
  for(int i=0;i<n;i++){
    for(int j=0;j<k;j++){
      int x=s[i][j]-'A';
      us[i]|=(1<<x);
    }
  }

  using T = tuple<int, int, int, int, vector<int> >;
  set<T> fs;
  vector<int> ans(n,-1);
  function<void(int, int, int, int)> dfs=
    [&](int b, int d, int v, int used){
      if(d==n){
        for(int i=0;i<n;i++) cout<<char('A'+ans[i]);
        cout<<endl;
        exit(0);
      }
      
      int vi=0;
      vector<int> th;
      for(int i=d-1;i>=0;i--){
        if((vi|us[ans[i]])==vi) continue;
        for(int j=k-1;j>=0;j--){
          int x=s[ans[i]][j]-'A';
          if((~vi>>x)&1) th.emplace_back(x);
        }
        vi|=us[ans[i]];
      }              
            
      if(fs.count(T(b,d,v,used,th))) return;
      
      for(int u:G[v]){
        if((~b>>u)&1) continue;
        if(used){
          int pos=0,lst=0;
          for(int j=0;j<k;j++){
            int x=s[u][j]-'A';
            if((~used>>x)&1){
              lst=1;
              continue;
            }
            if(lst) pos=th.size();
            while(pos<(int)th.size()&&th[pos]!=x) pos++;
          }
          if(pos==(int)th.size()) continue;
        }                   
        ans[d]=u;
        dfs(b^(1<<u),d+1,u,used|us[u]);
        ans[d]=-1;
      }

      fs.emplace(b,d,v,used,th);
    };
  
  dfs((1<<n)-1,0,n,0);
  return 0;
}



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

#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
long double pi = 3.14159265358979323;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int max(int b,int a){if(b>a)return b;else return a;}
int min(int b,int a){if(b<a)return b;else return a;}
int Abs(int b){return max(b,-b);}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){return a.second<b.second;}

int32_t main()
{   
    int n,x,y;
    cin>>n>>x>>y;
    if(y<x)swap(x,y);
    int sum=0;
    int k=n-1;
    map<int,int>m;
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            if(i!=j){
                int d=Abs(j-i);
                int b=Abs(x-i)+Abs(y-j)+1;
                if(b<d){
                    m[b]++;
                }
                else
                    m[d]++;
            }
        }
    }
    for(int i=1;i<n;i++){
        if(m.find(i)!=m.end())cout<<m[i]<<endl;
        else cout<<0<<endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <unordered_map>
#include <sstream>

using namespace std;

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

	vector< vector<int> > str_data(n, vector<int>(26));
	for(int i = 0; i < n; ++i)
	{
		string s = "";
		cin >> s;
		for(auto& c : s)
		{
			str_data[i][(int)(c - 'a')] += 1;
		}
	}

	unordered_map<string, long> str_bin(n);
	for(auto& s : str_data)
	{
		stringstream ss;
		for(auto& i : s)
		{
			ss << i;
		}
		str_bin[ss.str()] += 1;
	}

	long ans = 0;
	for(auto& bin : str_bin)
	{
		if (bin.second > 1)
		{
			ans += bin.second * (bin.second - 1) / 2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 25344
#include <stdio.h>
#include <string.h>

int main () {
    char s[2000001];
    gets(s);
    int n = strlen(s), ans=0;
	char t[n];
	for(int i = 0; i < n; i++) {
		scanf("%c", &t[i]);
	if( s[i] != t[i] )
        ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    while(true){
        bool ok = true;
        for(int i=2;i*i<=X;i++){
            if(X%i==0){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << X << endl;
            return 0;
        }
        X++;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var l = new List<long>();
            for (int i = 0; i < 5; i++)
                l.Add(long.Parse(Console.ReadLine()));

            long b = l.Min();
            long a = 4 + (n % b == 0 ? (n / b) : (n / b + 1));
            Console.WriteLine("{0}", a);
        }
    }
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,ans=0;
    cin >> n;
    vector<ll> s(n);
    rep(i,n){
        cin >> s[i];
        ans += s[i];
    }
    if(ans%10 != 0){
        cout << ans << "\n";
    }else{
        sort(all(s));
        rep(i,n){
            ans -= s[i];
            if(ans%10 != 0){
                cout << ans << "\n";
                return 0;
            }else{
                ans += s[i];
                REP(j,i+1,n){
                    ans -= s[j];
                    if(ans%10 != 0){
                        cout << ans << "\n";
                        return 0;
                    }
                    ans += s[j];
                }
            }
        }
        cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    string s;
    cin >> s;
    int g = 0, p = 0;
    for(char c : s){
        if (c == 'g') g++;
        else if(c == 'p') p++;
    }
    if((g + p) % 2 == 0){
        cout << (g - p) / 2 << endl;
    }else{
        cout << g - (g + p + 1)/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 512
import Control.Applicative
import Debug.Trace

f a b c = do
  let xs = [a, b, c]
  let p = if all odd xs || all even xs then 0 else 1
  let xs' = case length $ filter id $ map odd xs of
        0 -> xs
        1 -> map (\i -> if even i then succ i else i) xs
        2 -> map (\i -> if odd i then succ i else i) xs
        _ -> xs
  let xs = map (`div` 2) xs'
  let m = maximum xs
  p + (sum $ map (m - ) xs)

main = do
  [a, b, c] <- map read <$> words <$> getLine :: IO [Int]
  --let [a, b, c] = [2,6,3]
  print $ f a b c


Measured memory_bytes: 508
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int const MAXN=3010;
#define ll long long
ll n, v[MAXN];
ll memo[MAXN][MAXN];
bool vis[MAXN][MAXN];
ll dp(int i, int j){
	if(i==j)	return v[i];
	if(i>j)	return 0;
	if(vis[i][j])
		return memo[i][j];
	vis[i][j]=true;
	ll l=v[i]-dp(i+1,j), r=v[j]-dp(i,j-1);
	return memo[i][j]=max(l,r);
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>v[i];
	cout<<dp(0,n-1);
}

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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int solve(int N, int A, int B) {
  return min(N * A, B);
}

int main(int argc, char* argv[]) {
  int N, A, B;
  cin >> N >> A >> B;
  cout << solve(N, A, B) << '\n';
  return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)

	for i:=0; i<3; i++ {
		if s[i] == s[i+1] {
			fmt.Println("Bad")
			return
		}
	}
	fmt.Println("Good")

}

Measured memory_bytes: 512
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    ll x;
    cin>>x;
    if(x<=6){
        cout<<1<<endl;return 0;
    }else if(x<=11){
        cout<<2<<endl;return 0;
    }else{
        if(x%11==0){
            cout<<(2*(x/11))<<endl;
            
        }else{
            ll xx=x%11;
            if(xx<=6){
           cout<<(2*(x/11))+1<<endl;
            }else{
                cout<<(2*(x/11))+2<<endl;
                
            }
        }
        
    
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  for(int i = 0;i<3;i++){
    int b;
    cin >> b;
    a.at(i) = b;
  }
  sort(a.begin(),a.end());
  cout << a.at(0) + a.at(1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
vector<int> g[100100];
int a,b;
int d[2][100100];

void dfs(int v, int p, int j) {
  if (p!=0) d[j][v] = d[j][p]+1;
  for (int w:g[v]) {
    if (w==p) continue;
    dfs(w,v,j);
  }
}

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

  cin>>N;
  cin>>a>>b;
  for(int i=0;i<N-1;i++) {
    int u,v;cin>>u>>v;
    g[u].pb(v); g[v].pb(u);
  }

  dfs(a,0,0);
  dfs(b,0,1);

  int res=0;
  for (int v=1;v<=N;v++) {
    if (g[v].size() != 1) continue;
    if (d[0][v] < d[1][v]) res=max(res, d[1][v]-1);
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> t(n), x(n), y(n);
    for(int i = 0; i < n; ++i)  cin >> t[i] >> x[i] >> y[i];
    int nx = 0, ny = 0, time = 0;
    for(int i = 0; i < n; ++i){
        int dist = abs(nx - x[i]) + abs(ny - y[i]);
        int hoge = t[i] - time;
        if(hoge < dist){
            cout << "No\n";
            return 0;
        }
        if((hoge - dist) % 2 != 0){
            cout << "No\n";
            return 0;
        }
        nx = x[i], ny = y[i], time = t[i];
    }
    cout << "Yes\n";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <vector>	

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long long> vl;

typedef pair<int,int> pi;
typedef pair<double,double> pd;

#define pb push_back
#define mp make_pair

#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int uint;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

int INF = 1e9+7;

int main(){
	fastio();
	int a,b;
	cin>>a>>b;
	bool flag = 0;
	for(int i=0;i<=1500;++i){
		int x = 2*i/25;
		int y = i/10;
		if (x==a && y==b){
			flag = 1;
			cout<<i<<endl;
			break;
		}
	}
	if (!flag)
		cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#define mod 998244853 
using namespace std;
struct d{
  int b[4];
  char c;
};
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x, y;
    cin >> y >> x;
    d a[x][y];
    for(int i = 0; i < y; i++)
    {
        for(int j = 0; j < x; j++)
            cin >> a[j][i].c;
        cin.ignore();
    }
    for(int i = 0; i < x; i++)
    {
        if(a[i][y-1].c=='#')
            a[i][y-1].b[0]=-1;
        else
            a[i][y-1].b[0]=0;
        for(int j = y-2; j>=0; j--)
        {
            if(a[i][j].c=='#')
                a[i][j].b[0]=-1;
            else
               a[i][j].b[0]=a[i][j+1].b[0]+1;
        }
        if(a[i][0].c=='#')
            a[i][0].b[1]=-1;
        else
            a[i][0].b[1]=0;
        for(int j = 1; j < y; j++)
        {
            if(a[i][j].c=='#')
                a[i][j].b[1]=-1;
            else
               a[i][j].b[1]=a[i][j-1].b[1]+1;
        }
    }
    for(int i = 0; i < y; i++)
    {
        if(a[0][i].c=='#')
            a[0][i].b[2]=-1;
        else
            a[0][i].b[2]=0;
        for(int j = 1; j < x; j++)
        {
            if(a[j][i].c=='#')
                a[j][i].b[2]=-1;
            else
               a[j][i].b[2]=a[j-1][i].b[2]+1;
        }
        if(a[x-1][i].c=='#')
            a[x-1][i].b[3]=-1;
        else
            a[x-1][i].b[3]=0;
        for(int j = x-2; j >= 0; j--)
        {
            if(a[j][i].c=='#')
                a[j][i].b[3]=-1;
            else
               a[j][i].b[3]=a[j+1][i].b[3]+1;
        }
    }
    int m=0, cu=0;
    for(int i = 0; i < x; i++)
    {
        for(int j = 0; j< y; j++)
        {
            cu = 0;
            for(int k = 0; k < 4; k++)
                cu+=a[i][j].b[k];
            m=max(m, cu+1);
        }
    }
    cout << m << '\n';
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

long double l;

signed main() {
    cin >> l;
    long double a = l/3.0;
    cout << setprecision(20) << a*a*a << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = [int(a) for a in input().split()]
d = defaultdict(int)
for a in A:
    d[a] += 1
Q = int(input())
S = sum(A)
ans = []
for _ in range(Q):
    B, C = map(int, input().split())
    S += d[B] * (C - B)
    ans.append(S)
    d[C] += d[B]
    d[B] = 0
for a in ans:
    print(a)

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

int main(void) {
  int a,b;
  cin >> a >> b;
  cout << a * b << "\n";
  return 0;
}



Measured memory_bytes: 3632
// ABC165A - 

#include <bits/stdc++.h>
using namespace std;

int main() {
	int K, A, B;
	cin >> K >> A >> B;

	int t = (B / K) * K;

	if ((A <= t)&&(t <= B)) {
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
N,L = map(int,input().split())
a = list()
ans = 0
wa = 0
for i in range(1,N+1):
    a.append(L+i-1)
    ans += L+i-1
mi = 10**7
for i in range(N):
    if abs(a[i]) < mi:
        mi = abs(a[i])
        wa = a[i]
print(ans-wa)

Measured memory_bytes: 3064
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll N,M,L;
int main() {

	cin>>N>>M>>L;
	if(N+M>=L)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=200010;
int n,tr[maxn][2],bg[maxn],tot=1;ll L;
bool num[100];
char s[maxn];
int lowbit(ll x){
    int r=0;
    for(;!(x&1);r++,x>>=1);
    return r;
}
void ins(int v,int id,int d,int len){
    if(tr[v][s[bg[id]+d-1]-'0']==0) tr[v][s[bg[id]+d-1]-'0']=++tot;
    if(d!=len) ins(tr[v][s[bg[id]+d-1]-'0'],id,d+1,len);
}
void dfs(int v,int d){
    for(int k=0;k<=1;k++)
        if(tr[v][k]==0) {if(L-d>0) num[lowbit(L-d)]^=1;}
        else dfs(tr[v][k],d+1);
}
int main(){
    scanf("%d%lld",&n,&L);
    int top=0;
    for(int i=1;i<=n;++i){
        bg[i]=top+1;
        scanf("%s",s+bg[i]);
        top+=strlen(s+bg[i]);
        ins(1,i,1,strlen(s+bg[i]));
    }
    dfs(1,0);
    for(int i=0;i<=60;++i) if(num[i]) {return puts("Alice"),0;}
    puts("Bob");
    return 0;
}

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;++i)
int main(){int n,a=0;cin>>n;vector<string>g(n),h(n);r(i,n)cin>>g[i];r(i,n){r(j,n)h[(j+i)%n]=g[j];int f=1;
r(p,n){r(q,p){if(h[p][q]!=h[q][p])f=0;}}if(f)a+=n;}
cout<<a<<endl;return 0;}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INFINT = numeric_limits<int>::max();
const ll INFLL = numeric_limits<long long>::max();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;


int main() {

	ll n, k;

	cin >> n >> k;

	ll r = n / k;
	ll ans = r * r * r;

	if (!(k & 1) && n - k / 2 >= 0) {
		r = (n - k / 2) / k + 1;
		ans += r * r * r;
	}

	cout << ans NL;


	return 0;

}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

if a <= c and  d <= b:
    print(d-c)
elif c <= a and b <= d :
    print(b-a)

elif b <= c :
    print(0)
elif a <= c and c <= b :
    print(b-c)
elif a <= d and d <= b :
    print(d-a)
elif d <= a :
    print(0)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int N,A,B;
    int z1,z2;

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

    if(A > B) z1 = B;
    else z1 = A;
    z2 = A + B - N;
    if(z2 < 0 )z2 = 0;
    printf("%d %d\n",z1, z2);
    return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        w: usize,
        v: [[usize; 2]; n],
    }

    let mut dp = vec![vec![0; 100001]; 101];

    for i in 1..(n+1) {
        let k = i - 1;
        for j in 1..(w+1) {
            if j >= v[k][0] {
                dp[i][j] = cmp::max(dp[i-1][j-v[k][0]] + v[k][1], dp[i-1][j]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

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

}


Measured memory_bytes: 106748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int inf = 1e9;
const int nax = 207;
int n, m;
vector<vector<int>>a(nax, vector<int>(nax));
vector<vector<int>>dp(11, vector<int>(11));
void floydwarshall() {
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (dp[i][j] > dp[i][k] + dp[k][j]) {
					dp[i][j] = dp[i][k] + dp[k][j];
				}
			}
		}
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> dp[i][j];
		}
	}
	floydwarshall();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] == -1)continue;
			ans += dp[a[i][j]][1];
		}
	}
	cout << ans << endl;
}

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

int main(){
    int a,b,c,t;
    cin>>a>>b>>c;
    
    if (a>b) {t=a;a=b;b=t;}
    if (b>c) {t=b;b=c;c=t;}
    if (a>b) {t=a;a=b;b=t;}
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3108
# coding: utf-8

num = int(input())
l_cre = list(map(int, input().split()))
l_cre.sort()

counter = 0
now_size = 0

for i in range(len(l_cre) - 1):
    now_size += l_cre[i]
    if now_size * 2 >= l_cre[i + 1]:
        counter += 1
    else:
        counter = 0

counter += 1

print(counter)

Measured memory_bytes: 14320
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//(*'ω'*)ACほちぃ...
int main(){
    int n;cin>>n;
    vector<pair<double,double>> vec1(n,pair<double,double>(0.0,0.0)),vec2(n,pair<double,double>(0.0,0.0));
    for(int i=0;i<n;i++)cin>>vec1[i].first>>vec1[i].second;
    for(int i=0;i<n;i++){
        vec2[i].first=vec1[i].second;
        vec2[i].second=vec1[i].first;
    }
    sort(all(vec1));sort(all(vec2));
    if(n%2==1){
        int x=(n+1)/2;
        double smallest=vec1[x-1].first;
        double largest=vec2[x-1].first;
        cout<<int(largest-smallest)+1<<endl;
    }
    else{
        int x1=n/2,x2=n/2+1;
        double smallest=(vec1[x1-1].first+vec1[x2-1].first)/2;
        double largest=(vec2[x1-1].first+vec2[x2-1].first)/2;
        int ans=(largest-smallest)/0.5+1;
        cout<<ans<<endl;
    }
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
   string S;
   string ans = "CODEFESTIVAL2016";
   cin >> S;
   int cnt = 0;
   for(int i = 0; i < ans.size(); i++){
     if(S[i] != ans[i])cnt++;
   }
   cout << cnt << endl;
}


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

int main()
{
	int N = 0, ans = 0;
	std::cin >> N;
	
	std::vector<int> P(N);
	for (int i = 0; i < N; i++){
		std::cin >> P[i];
	}

	for (int i = 1; i < N- 1; i++){
		bool chk = false;
		if(((P[i] > P[i - 1]) && (P[i] <= P[i + 1])) || ((P[i] <= P[i - 1]) && (P[i] > P[i + 1])))
		{
			chk = true;
		}
		ans += (chk) ? 1 : 0;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const r = n.split("\n");

    r.forEach(x => sp(x));

});

function sp(str) {

    const r = str.split(" ");

    const num1 = Number(r[0]);
    const num2 = Number(r[2]);
    if (r[1]==="+"){
        const k = num1+num2;
        console.log(k);
    }else if (r[1]==="-"){
        const k = num1-num2;
        console.log(k);
    }else if (r[1]==="/"){
        const k = num1/num2;
        console.log(Math.floor(k));
    }else if (r[1]==="*"){
        const k = num1*num2;
        console.log(k);
    }else{
        return false;
    }

}


Measured memory_bytes: 16008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int h,w;
char fie[103][103];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void solve(int x,int y,char a){
  fie[x][y]=0;
  for(int i=0;i<4;i++){
    if(x+dx[i]<0 || x+dx[i]>=w || y+dy[i]<0 || y+dy[i]>=h) continue;
    if(fie[x+dx[i]][y+dy[i]]==a)
      solve(x+dx[i],y+dy[i],a);
  }
}
main(){
  while(1){
    int res=0;
    cin >> h >> w;
    if(!h && !w) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++) cin >> fie[j][i];
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(fie[j][i]){ solve(j,i,fie[j][i]); res++;}
      }
    }
    cout << res <<endl;
  }

}

Measured memory_bytes: 0
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, m, k;
        cin >> n >> m >> k;
        vector<int> a(n + 1, 0), b(m + 1, 0);
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            a[i] += a[i - 1];
        }
        for(int i = 1; i <= m; i++) {
            cin >> b[i];
            b[i] += b[i - 1];
        }

        int ans = 0;
        for(int i = 0; i <= n; i++) {
            int rem = k - a[i];
            if(rem < 0)
                break;
            auto pos = --upper_bound(b.begin(), b.end(), rem) - b.begin();
            if(pos < 0)
                pos = 0;
            // cout << i << ' ' << rem << ' ' << pos << '\n';
            ans = max(ans, i + pos);
        }

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



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

int main() {
	int N;
    double x1,y1,x2,y2,x3,y3,x4,y4;
    cin >> N;
    for (int n = 0; n != N; ++n) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if ((y2-y1)/(x2-x1) == (y4-y3)/(x4-x3)) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int main(){
    int n;
    double d=0;
    cin>>n;
    vector<int> x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    rep(i,n){
        for(int j=i+1;j<n;j++){
            d += sqrt((double)((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
        }
    }
    printf("%.10lf\n",2*d/n);
}


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

using namespace std;

int main() {
    vector<int> inputs = vector<int>(3);

    // input
    for (int i = 0; i < 3; i++){
        cin >> inputs[i];
    }

    // process
    vector<int> outputs(inputs);
    sort(outputs.begin(), outputs.end());

    // output
    for (int i = 0; i < 3; i++){
        if (i > 0){
            cout << " ";
        }
        cout << outputs[i];
    }
    cout << endl;

    return 0;
}




Measured memory_bytes: 3100
import sys
input = sys.stdin.buffer.readline
n,m=map(int,input().split())
*h,=map(int,input().split())
con=[[] for _ in range(n)]
for _ in range(m):
	s,t=map(int,input().split())
	con[s-1]+=t-1,
	con[t-1]+=s-1,

def check(s):
	co=h[s]
	for ad in con[s]:
		if co<=h[ad]:
			return False
	return True

print(sum(check(i) for i in range(n)))

Measured memory_bytes: 29616
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

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

const ll INF = 1e15;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(void) {
	int N; cin >> N;
	vector<ll> B(N + 1);
	B[0] = B[N] = MAX;
	ll ans = 0;
	for (int i = 1; i <= N - 1; i++)cin >> B[i];
	for (int i = 0; i < N; i++) ans += min(B[i], B[i + 1]);
	cout << ans << endl;
}



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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

using ll = long long;

int sum(int n) {
  int r = 0;
  while (n > 0) {
    r += n % 10;
    n /= 10;
  }
  return r;
}

int main() {
  int n;
  cin >> n;
  int r = sum(1) + sum(n - 1);
  for (int a = 1; a < n; ++a) {
    int b = n - a;
    r = min(r, sum(a) + sum(b));
  }
  cout << r << '\n';
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<ll> ans(10,0);
ll h,w,n;
map<pair<ll,ll>,ll> g;

void insert(ll x,ll y){
    if(x<2 || x>h-1 || y<2 || y>w-1) return;
    if(!(g.count(mk(x,y)))) g[mk(x,y)]=0;
    g[mk(x,y)]++;
    ans[g[mk(x,y)]-1]--;
    ans[g[mk(x,y)]]++;
}

int main(){
    cin>>h>>w>>n;
    ans[0]=(h-2)*(w-2);
    rep(i,n){
        ll a,b; cin>>a>>b;
        for(int j=-1;j<=1;j++)for(int k=-1;k<=1;k++){
            insert(a+j,b+k);
        }
    }
    rep(i,10) cout<<ans[i]<<endl;
}

Measured memory_bytes: 56448
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int k, int[] a) {
    long ans = long.max;
    for (int i = 0; i < a.length; i++) {
        if (i + k - 1 >= a.length) break;

        int lo = i;
        int hi = i + k - 1;
        // 0 -> lo -> hi の順に火をつける
        ans = min(ans, abs(a[lo]) + abs(a[hi] - a[lo]));
        // 0 -> hi -> lo の順に火をつける
        ans = min(ans, abs(a[hi]) + abs(a[hi] - a[lo]));
    }
    return ans;
}

void main() {
    auto nk = readints;
    int k = nk[1];
    auto a = readints;
    writeln(calc(k, a));
}


Measured memory_bytes: 4092