akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
	
	int N,A,B,i,j,k,l,sum=0;
	scanf("%d%d%d",&N,&A,&B);
	
	
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			for(k=0;k<10;k++){
				for(l=0;l<10;l++){
				
				if(1000*i+100*j+10*k+l<=N&&A<=i+j+k+l&&i+j+k+l<=B){
					sum=sum+1000*i+100*j+10*k+l;
				
				}
			}
		}
	}
	}
	
	if(N==10000){
		sum=sum+10000;
		
	}
	
	
	
	printf("\n%d\n\n",sum);
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>
#include <vector>
#include <array>

using std::cout;
using std::cin;
using std::string;


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

  std::vector<int> h(n);
  for(size_t i = 0; i < n; ++i)
  {
    cin >> h[i];
  }

  int num = 1;
  for(size_t i =1; i < h.size(); ++i)
  {
    bool error = false;
    for(size_t j = 0; j < i; ++j)
    {
      if(h[i] < h[j]){error  = true; break;}
    }
    if(!error) {num++;}
  }

  cout << num << "\n";
  return 0;
}


Measured memory_bytes: 256
s=int(input())
a=[0]*10**6
a[0]=s
def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n+1
for i in range(1,10**6):    
    a[i]=f(a[i-1])
    if a[i] in a[:i]:
        ans=i+1
        break
print(ans)

Measured memory_bytes: 10868
n = gets.to_i
def manhattan(a, b)
  (a[0] - b[0]).abs + (a[1] - b[1]).abs
end
xn = []
yn = []
points = n.times.map do
  x, y = gets.chomp.split(' ').map(&:to_i)
  xn << x + y
  yn << x - y
end
diam = [xn.max - xn.min, yn.max - yn.min].max
p diam


Measured memory_bytes: 19312
A, B, C, X, Y = gets.split(' ').map(&:to_i)
cand = [A * X + B * Y, 2 * C * [X, Y].max]
if X < Y
  cand.push(2 * C * X + B * (Y - X))
else
  cand.push(2 * C * Y + A * (X - Y))
end
puts cand.min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int H,W;
  cin>>H>>W;
  
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>vec[i][j];
    }
  }
  
  vector<bool> V(H,false);
  vector<bool> S(W,false);
  
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(vec[i][j]=='#'){
        V[i]=true;
        S[j]=true;
      }
    }
  }
  
  for(int i=0;i<H;i++){
    if(V[i]){
      for(int j=0;j<W;j++){
        if(S[j]){
          cout<<vec[i][j];
        }
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 3584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
	using namespace std;

	int main() {
		int K, X;
        cin >> K >> X; 
		if (500 * K >= X) {
			cout << "Yes" << endl;
		}

		else {
			cout << "No" << endl;
		}
	}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	
	for (int i = 0; i < n; i++) {
		int kp = 0;
		for (char c = 'a'; c <= 'z'; c++) {
           bool x = false, y = false;
		   for (int j = 0; j < i; j++) {
			   if (s[j] == c)x = true;
		    }
		   for (int k = i; k < n; k++) {
			   if (s[k] == c)y = true;
		   }
					if (x&&y)kp++;
	   }
		if (kp > ans)ans = kp;	
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  
  cin >> H >> W;
  
  vector<string> S(H);
  
  // マスの読み込み
  for (int i = 0; i < H; i++) {
    cin >> S.at(i);
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S.at(i).at(j) == '.') {
        int counter = 0;
        for (int k = i - 1; k <= i + 1; k++) {
          for (int l = j - 1; l <= j + 1; l++) {
            if (k < 0 || k >= H)
              continue;
            if (l < 0 || l >= W)
              continue;
            if (S.at(k).at(l) == '#')
              counter++;
          }
        }
        S.at(i).at(j) = counter+'0';
      }
    }
  }
  
  for (int i = 0; i < H; i++)
    cout << S.at(i) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,i,j,p=0;
    string s;
    cin>>s;
    l=s.size();
    for(i=1; i<l; i++)
    {
        if(s[i]!=s[i-1])
        {
            p++;
        }
    }
    cout<<p<<endl;

    return 0;

}


Measured memory_bytes: 3736
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;

  if (s[s.size() - 1] == 's') {
    cout << s << "es";
  } else {
    cout << s << "s";
  }

  return 0;
}


Measured memory_bytes: 3592
N=int(input())
l,r=[],[]
for i in range(N):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
l.sort()
r.sort()
if N%2:
  print(r[N//2]-l[N//2]+1)
else:
  a=(l[N//2]+l[N//2-1])/2
  b=(r[N//2]+r[N//2-1])/2
  print(int((b-a)*2)+1)

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define test            int t; cin>>t; while(t--)
#define io             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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


int32_t main(){
  io ; 

      int ans = INT_MIN;
      int cnt = 0;

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

      int i = 0; 
      while(i<n){
        if(str[i]=='R'){
            cnt++;
            if(i==n-1){
                ans = max(ans, cnt); 
            } 
        }else{
            ans = max(ans, cnt);
            cnt = 0; 
        }
        i++;
    }
    cout << ans << "\n"; 
}

Measured memory_bytes: 3584
#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long int LLI;

int main()
{
    int n;
    cin >> n;
    LLI tmp, ans = 0;
    unordered_map <LLI, LLI> arr;
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        arr[tmp]++;
    }
    for(auto x: arr)
    {
        if( x.first <= x.second )
            ans += x.second - x.first;
        else
            ans += x.second;
    }
    cout << ans;
}

Measured memory_bytes: 7392
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
const int N = 1e5 + 7;

int n, m, a[N], in[N], f[N], ans; vector <int> e[N];

int dfs(int u, int fa) {
//	cout << u << ' ';
	if (f[u]) return f[u];
	for (auto v : e[u]) if (v != fa) {
		f[u] = max(f[u], dfs(v, u));
	}
	ans = max(ans, f[u] + 1);
	return ++f[u];
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	rep(i, 1, m) { int x, y;
		cin >> x >> y;
		e[x].push_back(y);
		in[y]++;
	}
	rep(i, 1, n) if (!in[i]) {
		dfs(i, 0); //cout << '\n';
	}
	cout << ans - 1 << '\n';
	return 0;
}


Measured memory_bytes: 11264
//**************************
//*** author  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n,m;
vi graph[100010];
int ans[100010],in[100010];
queue<int> q;

int main()
{
	cin>>n>>m;
	rept(i,1,n+m)
	{
		int x,y;
		cin>>x>>y;
		graph[x].pb(y);
		in[y]++;
	}
	rept(i,1,n+1)
	{
		if (!in[i])
		{
			q.push(i);
			break;
		}
	}
	while (!q.empty())
	{
		int cnt=q.front();
		q.pop();
		for (auto y:graph[cnt])
		{
			in[y]--;
			if (!in[y])
			{
				q.push(y);
				ans[y]=cnt;
			}
		}
	}
	rept(i,1,n+1) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 7040
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  while (x >= 0){
    x -= b;
  }
  cout << x + b << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def dfs(v, p, c):
    res[v] = c
    for next in link[v]:
        if next[0] == p:
            continue
        if next[1] % 2:
            dfs(next[0], v, 1-c)
        else:
            dfs(next[0], v, c)


N = int(input())
link = [[] * N for _ in range(N)]
res = [0] * N
for i in range(N-1):
    u, v, w = map(int, input().split())
    link[u-1].append([v-1, w])
    link[v-1].append([u-1, w])

dfs(0, -1, 1)

for i in range(N):
    print(res[i])


Measured memory_bytes: 85212
#include<iostream>
#include<cstring>
#define MAX_N 101
int main(){
   int a[MAX_N];
  int n,i;
   std::cin>>n;
   for(i=0;i<n;i++)
      std::cin>>a[i];
   while(--i>0){
      std::cout<<a[i]<<" ";
}
   std::cout<<a[0]<<std::endl;
   return 0;
}

Measured memory_bytes: 3112
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int k;
	cin>>k;
	ll ans=0;
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			for(int l=1; l<=k; l++){
				ans+=gcd(gcd(i, j), l);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S;
    cin >> S;
    int N = S.size();
    FOR(i, 2, N + 1, 2) {
        int j = (N - i) / 2;
        if (S.substr(0, j) == S.substr(j, j)) {
            cout << N - i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n,m = map(int,input().split())

allconbi = (n+m)*(n+m-1)//2
minus = n*m

ans = allconbi-minus
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum,ans, dp[10000][2], a[110000],b[110000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<LL>v;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	cnt -= 5000;
	while (true) {
		if (cnt + n == m * 2)
			break;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  vector<ll> b(N);
  rep(i,N) cin >> a[i];
  rep(i,N) cin >> b[i];
  vector<ll> v(N);
  rep(i,N) v[i] = i + 1;
  ll s = 0, t = 0;
  ll cnt = 0;
  do{
    cnt++;
    if( a == v ) s = cnt;
    if( b == v) t = cnt;
  }while(next_permutation(v.begin(), v.end()));

  cout << abs(t - s) << endl;

}


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

using namespace std;

const int N = 510;

string a[N], r[N], b[N];

int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> a[i];
    r[i] = b[i] = a[i];
  }
  for (int i = 0; i < w; i++) {
    r[0][i] = b[h - 1][i] = '#';
  }
  for (int i = 1; i < h - 1; i++) {
    for (int j = 0; j < w; j++) {
      if (j % 2 == 0) {
        r[i][j] = '#';
      } else {
        b[i][j] = '#';
      }
    }
  }
  for (int i = 0; i < h; i++) {
    cout << r[i] << endl;
  }
  for (int i = 0; i < h; i++) {
    cout << b[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	ll x;
	cin >> x;
	x -= 399;
	ll res = (x % 200 == 0);
	x /= 200;
	cout << 8 - x + (res);
}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int[][] map = new int[3][3];
		for (int i = 0; i < 9; i++) {
			map[i / 3][i % 3] = sc.nextInt();
		}
		
		for (int a1 = 0; a1 <= 100; a1++) {
			int b1 = map[0][0] - a1;
			int b2 = map[0][1] - a1;
			int b3 = map[0][2] - a1;
			int a2 = map[1][0] - b1;
			int a3 = map[2][0] - b1;
			if (map[1][1] == a2 + b2 && map[1][2] == a2 + b3 && map[2][1] == a3 + b2 && map[2][2] == a3 + b3) {
				System.out.println("Yes");
				return;
			}	
		}
		
		System.out.println("No");
	}
}

Measured memory_bytes: 25044
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S;
	scan(N);scan(S);
	int la=0,ra=0,pea=0;
	rep(i,N){
		if(S[i]=='('){
			la++;
		}
		else{
			if(la>0){
				la--;
				pea++;
			}
			else{
				ra++;
			}
		}
	}
	rep(i,ra){
		printf("(");
	}
	printf("%s",S.c_str());
	rep(i,la){
		printf(")");
	}
	kaigyo;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<map>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<utility>
#include<string.h>
#include<string>
#define n 200000
#define loop(i, a, b) for(int i=a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
bool visit[n + 50];
int arr1[n + 50], arr2[n + 50], a, b, c, d, e, f;
string str1, str2;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
}

////////////////////////////////////////

void solve()
{
	cin >> a;
	int ans = 0;
	loop(i, 0, a - 1) cin >> arr1[i];
	loop(i, 0, a - 1)
	{
		int temp;
		cin >> temp;
		ans += temp; 
	}
	loop(i, 1, a - 1) cin >> arr2[i];
	loop(i, 0, a - 2)
	{
		if(arr1[i] == arr1[i + 1] - 1)
			ans += arr2[arr1[i]	]; 
	}
	cout << ans;
}
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 0, times - 1)
	{
		solve();
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 6400
#include <iostream>
using namespace std;
int main(){
  string S;
  while(cin >> S, S != "#"){
    if(S.length() <= 2){
      cout << 0 << endl;
      continue;
    }
    int ans = 0;
    int f[2] = {S[0],S[1]}, m = 1;
    for(int i = 1; i < S.length(); ++i){
      if((m == 1 && (S[i]-'0'-1)%3 > (f[1-m]-1)%3)){
	++ans;
	f[1-m] = S[i] - '0';
      }else if((m == 0 && (S[i]-'0'-1)%3 < (f[1-m]-1)%3)){
	++ans;
	f[1-m] = S[i] - '0';
      }else{
	f[m] = S[i] - '0';
	m = 1-m;
      }
    }
    int t = 0;
    f[0] = S[1];
    f[1] = S[0];
    m = 0;
    for(int i = 1; i < S.length(); ++i){
      if((m == 1 && (S[i]-'0'-1)%3 > (f[1-m]-1)%3)){
	++t;
	f[1-m] = S[i] - '0';
      }else if((m == 0 && (S[i]-'0'-1)%3 < (f[1-m]-1)%3)){
	++t;
	f[1-m] = S[i] - '0';
      }else{
	f[m] = S[i] - '0';
	m = 1-m;
      }
    }
    //cout << ans << endl;
    //cout << t << endl;
    ans = min(ans,t);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for(i=0;i<n;i++) cin >> a[i];
  int min = 200001;
  int cnt = 0;
  for(i=0;i<n;i++){
    if(min > a[i]){
      min = a[i];
      cnt++;
    }
  }
  cout << cnt << "\n";
  return 0;
}



Measured memory_bytes: 1024
N = gets.chomp.to_i
A = gets.split

a = []
minus = 0

a[0] = A[0].to_i
if a[0] <= 0
  a[0] *= (-1)
  minus += 1
end
minabs = a[0]
sum = a[0]

for x in 1...N
  a[x] = A[x].to_i
  if a[x] <= 1
    a[x] *= (-1)
    minus += 1
  end
  if a[x] < minabs
    minabs = a[x]
  end
  sum += a[x]
end

if minus % 2 == 1
  sum -= minabs * 2
end

puts sum

Measured memory_bytes: 8788
(* Vicfred
 * https://atcoder.jp/contests/abc138/tasks/abc138_c
 * sorting, greedy
 * *)

let main =
    Scanf.scanf "%d\n" (fun n ->
        Array.init n (fun _ -> Scanf.scanf " %f" (fun f -> f))
        |> Array.to_list
        |> List.sort compare
        |> (fun arr -> List.fold_left (fun x y -> (x +. y) /. 2.0) (List.hd arr) arr)
        |> Printf.printf "%.9f\n"
)


Measured memory_bytes: 3928
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h,w,k;
	cin>>h>>w>>k;
	char ar[h][w];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++) cin>>ar[i][j];
	int ans = 0;
	for(int mask1 = 0; mask1 < (1<<h); mask1++){
		for(int mask2 = 0; mask2 < (1<<w) ; mask2++){
			int c = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(((mask1 >> i)& 1) && ((mask2 >> j) & 1) && (ar[i][j] == '#'))
						++c;
				}
			}
			if(c == k) ++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define N 1000123
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define pb emplace_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007LL
#define M 10000123
 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(0);
    ll a;
    cin >> a;
    a = a + a * a + a * a * a;
    cout << a << '\n';
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main(){

	int h,w,k;
	cin >> h >> w >> k;

	char ar[h][w];

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> ar[i][j];
		}
	}
	
	int total = 0;

	for (int i = 0; i < (1 << h); i++){
		for (int j = 0; j < (1 << w); j++){

			int black = 0;
			for (int a = 0; a < h; a++){
				for(int b = 0; b < w; b++){
					if (  !((i>>a) & 1) && !((j>>b) & 1) && ar[a][b] == '#'){ black++; }
				}
			}

			if (black == k) total++;
		}
	}

	cout << total << endl;

    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

ll W,h;
void solve(vector<vector<int>> &m,int x,int y,int b){
  rep(i,4){
    int nx = dx[i] + x,ny = dy[i] + y;
    if(value(nx,ny,W,h) && !(m[nx][ny] & b)){
      m[nx][ny] += b;
      solve(m,nx,ny,b);
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> W >> h,W+h){
    vector<vector<char>> w(51,vector<char>(51));
    vector<vector<int>> v(51,vector<int>(51));
    rep(j,h){
      rep(i,W){
        cin >> w[i][j];
        if(w[i][j] == '.'){
          v[i][j] = 0;
        }
        if(w[i][j] == 'W'){
          v[i][j] = 11;
        }
        if(w[i][j] == 'B'){
          v[i][j] = 7;
        }
      } }
    rep(i,W){
      rep(j,h){
        if(v[i][j] == 11)
        solve(v,i,j,1);
        if(v[i][j] == 7)
        solve(v,i,j,2);
      }
    }
    /* rep(j,h){                 */
    /*   rep(i,W){               */
    /*     cout << v[i][j] ;     */
    /*   }                       */
    /*   std::cout << std::endl; */
    /* }                         */
    ll bc = 0,wc = 0;
    rep(i,W){
      rep(j,h){
        if(v[i][j] == 1){
          wc += 1;
        }
      }
    }
    rep(i,W){
      rep(j,h){
        if(v[i][j] == 2){
          bc += 1;
        }
      }
    }
    cout << bc << ' ' << wc << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
result = 'No'

n = int(input())
for i in range(n):
	In = int(input())
    
	a1 = ['' if a1[j] == In else a1[j] for j in range(3)]
	a2 = ['' if a2[j] == In else a2[j] for j in range(3)]
	a3 = ['' if a3[j] == In else a3[j] for j in range(3)]
    
# tate
for i in range(3):
	if a1[i] == '' and a2[i] == '' and a3[i] == '':
		result = 'Yes'
		break
# yoko
if a1.count('') == 3:
		result = 'Yes'
if a2.count('') == 3:
		result = 'Yes'
if a3.count('') == 3:
		result = 'Yes'

# naname
if a1[0] == '' and a2[1] == '' and a3[2] == '':
		result = 'Yes'
    
if a1[2] == '' and a2[1] == '' and a3[0] == '':
		result = 'Yes'
print(result)

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1
 
void testCase() {
    int n;
    cin >> n;
    int ans[n+3];
    for (int i=1; i<=n; i++) {
        ans[i] = 0;
    }
    for (int i=1; i<=n; i++) {
        for (int j=i; j<=n; j+=i) {
            ans[j]++;
        }
    }
    ll fans = 0;
    for (int i=1; i<n; i++)
        fans += ans[i];
    cout << fans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 7416
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if(a == 0)
        cout << 0 << endl;
    else if(b == 0)
        cout << n << endl;
    else{
        ll temp = n/(a + b);
        ll flag = n%(a + b);
        cout << (temp*a) + min(a,flag) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    long long i, n, t = 0;
    
    cin >> n;
	long long a[n+1], s[n+1] = {0};
    for (i = 1; i <= n; i++) cin >> a[i];
	s[1]=0;
	s[2]=abs(a[2]-a[1]);
    for (i = 3; i <= n; i++) s[i] = min(abs(a[i-1]-a[i])+s[i-1],abs(a[i-2]-a[i])+s[i-2]);
    cout << s[n];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
using D = double;

const D EPS = 1e-8;

struct Point {
  D x, y, z;
  Point(D x, D y, D z) : x(x), y(y), z(z) {}
};

Point operator-(Point A, Point B){
  A.x -= B.x;
  A.y -= B.y;
  A.z -= B.z;
  return A;
}

D dot(Point A, Point B){
  return A.x*B.x + A.y*B.y + A.z*B.z;
}

D dist(Point A, Point B){
  Point dd = A - B;
  D d = sqrt(dot(dd,dd));
  return d;
}

using L = pair<Point,Point>;

D dist(L l, Point p){
  D d = min(dist(l.first,p),dist(l.second,p));
  if(dot(l.second-l.first,p-l.first) > -EPS and dot(l.first-l.second,p-l.second) > -EPS){
    D ll = sqrt(dot(l.second-l.first,l.second-l.first));
    D lp = sqrt(dot(p-l.first,p-l.first));
    D theta = acos(dot(l.second-l.first,p-l.first)/ll/lp);
    d = min(d,lp*sin(theta));
  }
  return d;
}

int main(){
  using S = pair<Point,D>;
  int N, M, R;
  while(cin >> N >> M >> R, N||M||R){
    vector<S> V;
    for(int i = 0; i < N; ++i){
      D x, y, z, r;
      cin >> x >> y >> z >> r;
      Point p(x,y,z);
      V.emplace_back(p,r);
    }
    vector<S> T;
    for(int i = 0; i < M; ++i){
      D x, y, z, d;
      cin >> x >> y >> z >> d;
      Point p(x,y,z);
      T.emplace_back(p,d);
    }
    D x, y, z;
    cin >> x >> y >> z;
    Point E(x,y,z);
    D ans = 0;
    for(int i = 0; i < (1<<M); ++i){
      D t = 0;
      int c = 0;
      for(int k = 0; k < M; ++k){
        if((i>>k)&1) continue;
        t += T[k].second/dist(E,T[k].first)/dist(E,T[k].first);
      }
      if(t < ans) continue;
      for(int j = 0; j < N; ++j){
        for(int k = 0; k < M; ++k){
          if((i>>k)&1) continue;
          if(dist(L(T[k].first,E),V[j].first) <= V[j].second+EPS and
             (dist(T[k].first,V[j].first) > V[j].second-EPS or
              dist(E,V[j].first) > V[j].second-EPS)){
            ++c;
            break;
          }
        }
        if(c > R) break;
      }
      if(c <= R){
        ans = max(ans,t);
      }
    }
    printf("%.12f\n",ans);
  }
}



Measured memory_bytes: 3608
def void(arg_num):
    return arg_num

def get_input_list(func=void):
    inp_str = input()
    return list(map(func, inp_str.split(" ")))


N = int(input())
a_list = get_input_list(int)

ans_list = [0 for i in range(N)]

for a in a_list:
    ans_list[a - 1] += 1

for ans in ans_list:
    print(ans)


Measured memory_bytes: 33340
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest061-B
#  https://atcoder.jp/contests/abc061/tasks/abc061_b

def  solveProblem(cityNumber,roadList):
	cityPassList = [0 for _ in range(0,cityNumber,+1)]
	for fromToList in roadList:
		fromCity = fromToList[0]-1
		toCity = fromToList[1]-1
		cityPassList[fromCity]=cityPassList[fromCity]+1
		cityPassList[toCity]=cityPassList[toCity]+1

	answer = cityPassList
	return answer


if __name__ == '__main__':
	N,M=map(int,input().strip().split(' '))
	roadRange = range(0,M,+1)
	roadList=[]
	for _ in roadRange:
		roadList.append(list(map(int,input().strip().split(' '))))
	solution=solveProblem(N,roadList)
	for cityCount in solution:
		print("{}".format(cityCount))

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <unordered_map>
#include <queue>
#include <math.h>
using namespace std;

int main(){
	double N;
	cin >> N;
	double res = sqrt(N);
	int r = floor(res);
	r = r*r;
	cout << r;
	return 0;
}
	

Measured memory_bytes: 256
Dice = Struct.new(:top, :front, :right, :left, :back, :bottom) do
    def roll(x)
        case x
        when "E"
            k = self.top
            self.top = self.left
            self.left = self.bottom
            self.bottom = self.right
            self.right = k
        when "N"
            k = self.top
            self.top = self.front
            self.front = self.bottom
            self.bottom = self.back
            self.back = k
        when "S"
            k = self.top
            self.top = self.back
            self.back = self.bottom
            self.bottom = self.front
            self.front = k
        when "W"
            k = self.top
            self.top = self.right
            self.right = self.bottom
            self.bottom = self.left
            self.left =k
        end
    end
    
    def twist
        k = self.front
        self.front = self.right
        self.right = self.back
        self.back = self.left
        self.left = k
    end
end

dice1 = Dice.new
dice2 = Dice.new
dice_tmp = Dice.new

dice1.top, dice1.front, dice1.right, dice1.left, dice1.back, dice1.bottom = gets.split
dice2.top, dice2.front, dice2.right, dice2.left, dice2.back, dice2.bottom = gets.split

founded = false

ary = ["","N","W","E","S","NN"]

for c in ary 
    break if founded
    dice_tmp = dice1.dup
    if c != "" then
        for x in c.split("")
            dice_tmp.roll(x)
        end
    end
    4.times{
        dice_tmp.twist
        flag = (dice_tmp == dice2 ? "true" : "false")
        if dice_tmp == dice2 then
            founded = true
            puts "Yes"
            break
        end
    }
end

puts "No" if !founded


Measured memory_bytes: 8900
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 110000
ll MOD=1e9+7;
const int MAX_ROW = N; // to be set appropriately
const int MAX_COL = 64; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}
main(){
    int n=in();
    vecll v;
    rep(i,n){
        v.pb(lin());
    }
    ll sum=0;
    rep(i,n){
        sum^=v[i];
    }
    //cout<<sum<<endl;
    int m=0;
    ll ans=0;
    vector<ll> mem;
    rep3(i,59,0){
        ll t=(1ll<<i);
        if((t&sum)==0){
            mem.pb(t);
            m++;
            //cout<<t<<endl;
        }
        else{
            ans+=t;
        }
    }

    BitMatrix bm(n,m);
    rep(i,n)rep(j,m){
        if(v[i]&mem[j])bm[i][j]=1;
    }
    GaussJordan(bm);
    int pre=0;
    rep(j,m){
        bool f=0;
        rep(i,n){
            f^=bm[i][j];
        }
        if(f)ans+=mem[j]*2ll;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2036
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,i,j;
	char a[8],b[8],t;
	scanf("%d\n",&n);
	for(n;n>0;n--)
	{
		for(i=0;i<8;i++)
		{
			scanf("%c",&t);
			for(j=i;j>0&&t>a[j-1];j--)
				a[j]=a[j-1];
			a[j]=t;
		}
		for(i=0;i<8;i++)
			b[7-i]=a[i];
		printf("%d\n",atoi(a)-atoi(b));
		scanf("\n");
	}
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

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

int main()
{
    string ss;
    cin >> ss;
    for(ll i = 0; i < ss.size(); i++)
    {

        if(i%2==0) cout << ss[i];
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=4e2+10,mod=1e9+7;
int n;
vector<ll> a,Pre;
vector<vector<ll> >dp;

ll solve(int L,int R){
    if(L>=R)return 0;
    ll &ret=dp[L][R];
    if(ret+1)return ret;
    ret = oo;
    for(int i=L;i<=R;i++){
        ret = min(ret,solve(L,i)+solve(i+1,R));
    }
    ret += Pre[R]-(L?Pre[L-1]:0);
    return ret;
}

int main()
{
    FASTIO
    cin >> n;
    a.resize(n);
    dp.resize(n,vector<ll>(n,-1));
    Pre.resize(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        Pre[i] = (i ? Pre[i-1]:0)+a[i];
    }
    cout << solve(0,n-1) << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int x[]={6,4,3,2};
	for(int i=0;i<4;i++){
		int a,b; cin >> a >> b;
		cout << x[a-1]*1000*b << endl;
	}
}


Measured memory_bytes: 3096
n=int(input())
l=list(map(int,input().split()))
ans=[i+1 for i in range(n)]
ind=[i for i in range(n)]
cnt=0
for i in ind:
  if(l[i]!=ans[i]):
    cnt+=1
if(cnt<=2):
  print("YES")
else:
  print("NO")
  

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

int main()
{
	int n; 
	cin>>n;
	string s[n];
	for(int i=0; i<n; i++)
	{
		cin>>s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s, s+n);
	long long cnt=0, ans=0;
	string last=s[0];
	for(int i=1; i<n; i++)
	{
		if(s[i]==last) cnt++;
		else ans+=(cnt+1)*cnt/2, last=s[i], cnt=0;
	}
	ans+=(cnt+1)*cnt/2;
	cout<<ans;
}


Measured memory_bytes: 7296
from heapq import heappush, heappop

n, m = map(int, input().split())
A = list(map(int, input().split()))
H = []
for a in A:
    heappush(H, -a)
for i in range(m):
    b = heappop(H)
    b *= -1
    b //= 2
    heappush(H, -b)
goukei = sum(H)
print(-goukei)


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll; 
typedef unsigned long long ull;
 typedef unsigned int uint; 
typedef long double ld;
 
int main() { ios_base::sync_with_stdio(false); cin.tie(0);
 
int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout << (ll)ans;
return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string s; cin >> s;

	string res = "";
	rep (i, (int)s.length()){
		if (i % 2 == 0){
			res += s[i];
		} // end if
	} // end rep
	
	cout << res << endl;

	return 0;
}

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

using namespace std;



int main()
{
    int n, a[30], c = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 1; i < n - 1; i++){
        if(a[i] > a[i - 1] && a[i] < a[i + 1])
            c++;
        if(a[i] < a[i - 1] && a[i] > a[i + 1])
            c++;
    }
    cout << c;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in).useDelimiter("[,\\s]+");
        int total1 = 0;
        int total2 = 0;
        int counter = 0;
        while (scanner.hasNextInt()) {
            int price = scanner.nextInt();
            int amount = scanner.nextInt();
            total1 += price * amount;
            total2 += amount;
            counter++;
        }
        System.out.println(total1);
        System.out.println((int) ((double) total2 / counter + 0.5));
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define is insert
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
//set<int, Comparator> S;
int main() {
    string C;
    cin >>C;
    C[0]+=1;
    cout << (C) <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextInt()) {
				long d = sc.nextLong();
				long sum = 0;
				for (int i = 1; i * d < 600; i++) {
					sum += (i * d) * (i * d) * d;
				}
				System.out.println(sum);
			}
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 17200
//-----------------------------------------------------------
// すぐ使える
//-----------------------------------------------------------
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		int N = Integer.parseInt(br.readLine());
		String[] ss0 = br.readLine().trim().split(" ", 0);
		long[] l = new long[3*N];
		for(int i = 0; i < 3*N; i++){
			l[i] = Long.parseLong(ss0[i]);
		}


		Arrays.sort(l);
		//checkInput(l);
		
		long ans=0;
		for(int i = 0; i < N; i++){
			
			ans += l[3*N-1-1-(i*2)];
			//System.out.println(i + ", " +ans);
		}


        System.out.println(ans);
        return;
    }
    //-----------------------------------------------------------------
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認：リスト
	static void checkInput(List l) { System.out.println(l); }
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、float型
	//   ＜使い方＞
	//     float[] f = new float[N];
	//     checkInput(f);
	static void checkInput(float[] i1) {
		StringBuilder sb = new StringBuilder();
		for(float i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、int型
	//   ＜使い方＞
	//     int[] c = new int[N];
	//     checkInput(c);
	static void checkInput(int[] i1) {
		StringBuilder sb = new StringBuilder();
		for(int i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	static void checkInput(long[] i1) {
		StringBuilder sb = new StringBuilder();
		for(long i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(long[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(long[] i1: i2){
			for(long i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}

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


Measured memory_bytes: 83332
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class BMixJuice {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,k;
        in >> n >> k;
        vector<int> p(n);
        rep(i,n){
            in >> p[i];
        }
        sort(p.begin(),p.end());
        int su=0;
        rep(i,k){
            su+=p[i];
        }
        out << su << endl;
        return;
	}
};


int main() {
	BMixJuice solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int A;
cin>>A;
int B;
cin>>B;
int now=1;
A--;
long long ans=0;
for(int i=0;i>=0;i++){
    if((A*i+now)>=B){
        ans=i;
        break;
    }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    for (int i=0;i<=x;i++) {
        if (2*i+4*(x-i)==y) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3620