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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    const int INF = 1 << 30;
    int dis[10][10];
    fill_n((int*)dis, 10 * 10, INF);
    for (int i = 0; i < 10; i++) {
      dis[i][i] = 0;
    }
    int m = -1;
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      dis[a][b] = dis[b][a] = c;
      m = max(m, max(a, b) + 1);
    }
    for (int k = 0; k < m; k++) {
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          if (dis[i][k] == INF || dis[k][j] == INF) continue;
          dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
        }
      }
    }
    int p = -1, q = 1 << 30;
    for (int i = 0; i < m; i++) {
      int sum = 0;
      for (int j = 0; j < m; j++) {
        sum += dis[i][j];
      }
      if (sum < q) p = i, q = sum;
    }
    cout << p << " " << q << endl;
  }

  return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
ll gen_num (ll a,ll b ){
    ll gen_num = 0;
    for(int i = 0; i < b;i++){
        gen_num *= 10;
        gen_num += a;
    }
    return gen_num;
}
int main(){
    ll a,b;
    cin >> a >> b;
    if(a>b){
        cout << gen_num(b,a) << endl;
    }else{
        cout << gen_num(a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}


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

int main() {
  ll X,Y;
  cin >> X >>Y;
  if(Y-2*X>=0 && (Y-2*X)%2==0 && 4*X-Y>=0 && (4*X-Y)%2==0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int main() {
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1 != m2){
    cout << '1' << endl;
  }
  else {
    cout << '0' << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	1000000000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

ll dp[20001][256];
int c[16];
int x[20000];

int main(){
	int n,m;
	while(scanf("%d%d", &n, &m),n||m){
		rep(i,20001) rep(j,256) dp[i][j] = INF;
		dp[0][128] = 0;
		rep(i,m) scanf("%d", &c[i]);
		rep(i,n) scanf("%d", &x[i]);
		for(int i = 1; i <= n; i++){
			for(int j = 0; j < 256; j++){
				for(int k = 0; k < m; k++){
					if(0 > j+c[k]) dp[i][0] = min(dp[i][0],dp[i-1][j]+x[i-1]*x[i-1]);
					else if(j+c[k] >= 256) dp[i][255] = min(dp[i][255],dp[i-1][j]+(255-x[i-1])*(255-x[i-1]));
					else dp[i][j+c[k]] = min(dp[i][j+c[k]],dp[i-1][j]+(j+c[k]-x[i-1])*(j+c[k]-x[i-1]));
				}
			}
		}
		ll ans = INF;
		rep(i,256){
			ans = min(ans,dp[n][i]);
		}
		cout << ans << endl;
	}
}

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

using namespace std;

const ll mod = 998244353; 
const int N = 500200; 

int n; 
int a[N], t[N]; 
int mx[N], mn[N]; 
ll F[N]; 

int main() {


  scanf("%d", &n); 
  for (int i = 1; i <= n; i++)
    scanf("%1d", &a[i]);
  for (int i = 1; i <= (n << 1); i++) {
    if ((n << 1) % i != 0 || !(((n << 1) / i) & 1)) 
      continue ; 
    for (int j = 1; j <= (n / (i / 2)); j++) 
      for (int k = 1; k <= i / 2; k++) {
        t[(j - 1) * (i / 2) + k] = (j % 2 == 1) ? a[k] : a[k] ^ 1;
    }
    ll C = 0; 
    for(int j = 1; j <= i / 2; j++) {
      C = (C * 2 % mod + t[j]) % mod; 
    }
    F[i] = C + (vector <int>(t + 1, t + n + 1) <= vector <int>(a + 1, a + n + 1)); 
  }
  ll ans = 0; 
  for (int i = 1; i <= 2 * n; i++) {
    if((2 * n % i == 0) && ((2 * n / i) & 1)) {
      ans = (ans + F[i] * i % mod) % mod; 
      for (int j = i + i; j <= 2 * n; j += i) {
        if((2 * n % j == 0) && ((2 * n / j) & 1))
          F[j] = (mod + (F[j] - F[i]) % mod) % mod; 
      }
    }
  }
  printf("%lld\n", ans); 
  return 0; 
}

Measured memory_bytes: 8328
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = [-1] * N

for i in range(M):
    s = sc[i][0] - 1
    c = sc[i][1]
    if ans[s] is -1:
        ans[s] = c
    elif not ans[s] == c:
        print(-1)
        exit()

if N!=1 and ans[0] == 0:
    print(-1)
    exit()

a = 0
for i in range(N):
    if ans[i] is -1:
        if i == 0 and N!= 1:
            ans[i] = 1
        else:
            ans[i] = 0
    a += ans[i]*10**(N-i-1)

print(a)


Measured memory_bytes: 3064
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main(){
	ll n,d,a,y,z;
	cin>>n>>d>>a;
	vector<ll> x(n);
	vector<pair<ll,ll>> v(n);
	for(int i=0;i<n;i++){
		cin>>y;
		cin>>z;
		v[i]={y,z};
	}
	sort(v.begin(), v.end());
	vector<ll> times(n);
	for(int i=0;i<n;i++){
		x[i] = v[i].fi;
		times[i] = (v[i].se+a-1)/a;
	}
	vector<ll> far(n,0);
	for(int i=0;i<n;i++){
		far[i] = upper_bound(x.begin(), x.end(), x[i]+2*d) - x.begin();
	}

	ll ans = 0;
	vector<ll> damage(n+2,0);
	for(int i=0;i<n;i++){
		if(!i){
			damage[i]=times[i];
			ans+=times[i];
			damage[far[i]]-=times[i];
		} else {
			damage[i]+=damage[i-1];
			if(times[i]<=damage[i]){
				continue;
			} else {
				ll temp=times[i]-damage[i];
				damage[i]+=temp;
				ans+=temp;
				damage[far[i]]-=temp; 
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9600
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7


n,k = MAP()
s = input()
k*=2

lst = [0]
for i in range(n-1):
    if s[i]!=s[i+1]:
        lst.append(i+1)

r = len(lst)
lst += [n]
ans=[]
for i in range(r):
    if s[lst[i]]=="0":
        ans.append(lst[min(i+k,r)] - lst[i])
    else:
        ans.append(lst[min(i+k+1,r)] - lst[i])

print(max(ans))

Measured memory_bytes: 11128
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
import std.array;

int readInt(){
  return readln.chomp.to!int;
}

int[] readInts(){
  return readln.chomp.split.to!(int[]);
}

void main(){
  int n = readInt(), i;
  int[] h = readInts();
  
  for(i = 0; h.count(0) != h.length; i++){
    bool f = false;
    foreach(ref e; h){
      if(e != 0 && !f) f = true;
      if(e == 0 && f) break;
      if(f) e--;
    }
  }
    
  writeln(i);
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long a = cin.Long();
			long b = cin.Long();

			var ap = GetPrimeFactor(a);
			var bp = GetPrimeFactor(b);

			var set = new HashSet<long>();
			foreach (long app in ap) {
				if (bp.Contains(app)) {
					set.Add(app);
				}
			}

			Console.WriteLine(set.Count() + 1);
		}

		public static HashSet<long> GetPrimeFactor(long value)
		{
			long max = (long)Math.Ceiling(Math.Sqrt(value));
			var factors = new HashSet<long>();
			for (int i = 2; i <= max; ++i) {
				if (value % i == 0) {
					factors.Add(i);
					while (value % i == 0) {
						value /= i;
					}
				}
			}

			if (value != 1) {
				factors.Add(value);
			}

			return factors;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<math.h>

int main(void)
{
    int N;
    int M, i, t_d=0;

    scanf("%d", &N);
    scanf("%d", &M);
    int A[M];

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

    if(N < t_d) {
        printf("-1\n");
    } else {
        printf("%d\n", N-t_d);
    }
    

    return 0;
}


Measured memory_bytes: 1720
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let y: usize = iter.next().unwrap().parse().unwrap();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let squares: Vec<Vec<char>> = (0..y)
        .map(|_| {
            let str: String = iter.next().unwrap().parse().unwrap();
            str.chars().collect::<Vec<char>>()
        })
        .collect();

    let mut can_paint = true;
    'outer: for (i, line) in squares.iter().enumerate() {
        for (j, &square) in line.iter().enumerate() {
            if square == '#' {
                // before line
                if i != 0 {
                    if squares[i - 1][j] == '#' {
                        continue;
                    }
                }
                // same line
                if j != 0 {
                    if squares[i][j - 1] == '#' {
                        continue;
                    }
                }
                if j < x - 1 {
                    if squares[i][j + 1] == '#' {
                        continue;
                    }
                }
                // next line
                if i < y - 1 {
                    if squares[i + 1][j] == '#' {
                        continue;
                    }
                }
                //  when the proces reaches here, this squres can't fill.
                can_paint = false;
                break 'outer;
            }
        }
    }
    println!("{}", if can_paint { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
K, N = map(int, input().split(' '))
A_n = list(map(int, input().split(' ')))
tmp = A_n[0] + K - A_n[-1]
for i in range(1, len(A_n)):
    if abs(A_n[i] - A_n[i-1]) > tmp:
        tmp = abs(A_n[i] - A_n[i-1])
print(K-tmp)

Measured memory_bytes: 26444
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
char _;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#ifdef _getchar_nolock
#define getchar _getchar_nolock
#endif
#ifdef _putchar_nolock
#define putchar _putchar_nolock
#endif
#ifdef getchar_unlocked
#define getchar getchar_unlocked
#endif
#ifdef putchar_unlocked
#define putchar putchar_unlocked
#endif
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
void scan(pii &x) {scan(x.first); scan(x.second);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MN = 1e5+2, MM = 1e6+2, MOD = 1e8, BASE = 131;
int fpow (int base, int ex) {int res = 1;while (ex) {if (ex&1) res = res*1LL*base%MOD;base = base*1LL*base%MOD;ex>>=1;}return res;}
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
int moddiv (int a, int b) {return a*1LL*fpow(b,MOD-2)%MOD;}
int a[MN], b[MN];
int main () {
    int n,sum=0;
    scan(n);
    b[0] = b[n] = INT_MAX;
    for (int i = 1; i < n; i++) scan(b[i]);
    for (int i = 1; i <= n; i++) {
        sum += min(b[i],b[i-1]);
    }
    printf ("%d\n",sum);
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>)
{
    val (a, b, c) = readNInts()

    val x = b + c - a

    println(if (x > 0) x else 0)
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!


Measured memory_bytes: 37808
function main(input){
    let lines = input.split("\n");
    const int = parseInt;
    const length = int(lines[0]);
    const nums = (lines[1].split(" "));
    
    for(let i=1;i<length;i++){
        let put="";
        for(let k=0;k<length;k++){
            put+=nums[k]+" ";
        }
        console.log(put.trim());
        let current = int(nums[i]);
        let j=i-1;
        while(j>=0 && int(nums[j])>current){
            nums[j+1]=int(nums[j]);
            j--;
            
        }
        nums[j+1]=current;


        
    }
    let put="";
    for(let k=0;k<length;k++){
        put+=nums[k]+" ";
    }
    console.log(put.trim());
    
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 18160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,k,x;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i < n;i++)
    {
        cin >> v.at(i);
        if(v.at(i)==1){
            x=i;
        }
    }
    cout << 1+((n-k+k-2)/(k-1)) << endl;
}
/*最後は全て１になる*/



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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int main() {
  int x,y,z;
  cin >> x >> y >> z;

  x -= z;
  x = x/(y+z);
  pout(x);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
an = [0]*n
for i in range(0, n):
    an[i] = int(input())
dp = [-1] * n

len = 1
dp[0] = an[0]
for i in range(1,n):
    if dp[len-1] >= an[i]:
        dp[len] = an[i]
        len += 1
        continue
    
    idx = len // 2
    r = len-1
    l = 0
    while(True):
        if dp[idx] >= an[i]:
            if r == idx+1:
                dp[r] = an[i]
                break
            else:
                l = idx
                idx = idx + (r - idx) // 2
        else:
            if l == idx:
                dp[l] = an[i]
                break
            else:
                r = idx
                idx = l + (idx - l) // 2
    
print(len)


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

void solver() {
  int k, n;
  cin >> k >> n;
  vector<int> as;

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    as.push_back(a);
  }

  int d_min = k;
  for (int i = 0; i < as.size(); i++) {
    int d = 0;
    if (i + 1 >= as.size()) {
      d = k - (k + as[0] - as[i]);
    } else {
      d = k - (as[i + 1] - as[i]);
    }
    if (d_min > d) {
      d_min = d;
    }
  }
  cout << d_min << "\n";
  return;
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 1400
from fractions import gcd
from functools import reduce

def gcdli(xl):
    #xlはlist
    return reduce(gcd , xl)

def monsters_battle_royale(n, al):

    ans = gcdli(al)

    return ans

def main():
    n = int(input())
    al = list(map(int, input().split()))
    print(monsters_battle_royale(n, al))

if __name__ == '__main__':
    main()

Measured memory_bytes: 16324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int x,a,b;
    ll sum;
    cin >>x;

    for(int i=-200; i<=200; i++){
        for(int j=-200; j<=200; j++){
            sum = pow(i,5) - pow(j,5);
        if(sum == x){
            a=i;
            b=j;
        }
      }
    }
    cout << a << " " <<b << endl;
}
    

Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2 * 1e5 + 5)
#define MAXL 20
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if (0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int, int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int main(){
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  lli d;
  cin >> d;
  d *= 2;

  cout << PI*d << endl;


  return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>

int main(void){
    int a,b,c,d,e;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    if (a < 40){
        a = 40;
    }
    if (b < 40){
        b = 40;
    }
    if (c < 40){
        c = 40;
    }
    if (d < 40){
        d = 40;
    }
    if (e < 40){
        e = 40;
    }
    printf("%d\n",(a + b + c + d + e) / 5);
    return 0;
}

Measured memory_bytes: 600
n=int(input())
a=list(map(int,input().split()))
A=[]
for i in range(n):
    if a[i]%2==1:
        A.append(1)
    else:
        A.append(2)
ans=3**n
cnt=1
for i in range(n):
    cnt*=A[i]
print(ans-cnt)


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

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

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int m,d;
	cin>>m>>d;
	int cnt=0;
	FOR(i,1,m+1){
		FOR(j,1,d+1){
			if((j/10)>=2 && (j%10)>=2 && j>10){
				if((j/10)*(j%10)==i){
					cnt++;
					//cout<<i<<" "<<j<<endl;
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> vc(n);
  for(int i = 0 ; i < n ; i++ ) cin >> vc[i];
  int ans = 0,q,a;
  cin >> q;
  sort(vc.begin(),vc.end());
  while(q--){
    cin >> a;
    if(binary_search(vc.begin(),vc.end(),a)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1532
import java.util.*;
public class Main{
	static int[] list1 = new int[180];
	static int[] list2 = new int[45];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		makeList();
		int[] dp1 = new int[1000000];
		int[] dp2 = new int[1000000]; 
		

		Arrays.fill(dp1, 2 << 27);
		Arrays.fill(dp2, 2 << 27);

		dp1[0] = dp2[0] =  0;

		for(int i = 0; i < 180; i++) {
			for(int j = 0; j < 1000000; j++) {
				if(j + list1[i]  >= 1000000) break;
				dp1[j + list1[i]] = Math.min(dp1[j+list1[i]], dp1[j] + 1);
				if(list1[i] % 2 == 1) dp2[j + list1[i]] = Math.min(dp2[j+list1[i]], dp2[j]+1);
			}
		}
		
		while(true) {
			int a = sc.nextInt();
			if(a == 0) break;
			System.out.println(dp1[a] + " " + dp2[a]);
		}
	}
	
	static void makeList() {
		int count1 = 0;
		int count2 = 0;
		for(int i = 1; i < 1000001; i++) {
			int sum = i*(i+1)*(i+2)/6;
			if(sum > 1000001) break;
			if(sum % 2 == 1) {
				list1[count1++] = sum;
				list2[count2++] = sum;
			}
			else {
				list1[count1++] = sum;
			}
		}
	}
	

	
}

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


int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double Ha, Ma; //角度
  double pi = acos(-1);

  Ha = 360 * (H + M/60) / 12;
  Ma = 360 * M / 60;

  double l;
  l = A*A + B*B -2*A*B*cos(2*pi*(Ha-Ma)/360);
  cout << fixed << setprecision(11) << sqrt(l) << endl;
}


Measured memory_bytes: 4256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 1000010;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
const ll ainf = 998244353;

struct cell {
	int x, y;
	int deep;
	cell(int x, int y, int deep) : x(x), y(y), deep(deep) {}
};

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

int W, H, N;
int X1[500], X2[500], Y1[500], Y2[500];

bool fld[500 * 6][500 * 6];
int compress(int* x1, int* x2, int w) {
	vector<int> xs;
	for (int i = 0; i < N; i++)
	{
		for (int d = -1; d <= 1; d++)
		{
			int tx1 = x1[i] + d, tx2 = x2[i] + d;
			if (1 <= tx1 && tx1 <= W) xs.push_back(tx1);
			if (1 <= tx2 && tx2 <= W) xs.push_back(tx2);
		}
	}

	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	for (size_t i = 0; i < N; i++)
	{
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size();
}
const int MAX_N = 1 << 17;

void solv() {

	ll a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split().Select(i => double.Parse(i)).OrderBy(i => i).ToArray();

            var value = v[0];
            for(var i = 1; i < v.Length; i++){
                value = (value + v[i]) / 2.0;
            }

            Console.WriteLine(string.Format("{0:f10}",value));
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 
 
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
// Constants //
 
 
/*** Template Ends ***/
ll cache[100005];
std::vector<ll> adj[100005];
ll dfs(ll src)
{
  if(adj[src].size()==0)
    return 0;
  if(cache[src]!=-1)
    return cache[src];
  for(auto nei : adj[src])
  {
    cache[src] = max(1+dfs(nei),cache[src]);
  }
  return cache[src];
}
void solve()
{
  ll n,m;
  cin>>n>>m;
  ll i,a,b;
  for(i=1;i<=m;i++)
  {
    cin>>a>>b;
    adj[a].push_back(b);
  }
  for(i=1;i<=n;i++)
    cache[i]=-1;
  for(i=1;i<=n;i++)
    if(cache[i]==-1)
      dfs(i);
  ll ans=0;
  for(i=1;i<=n;i++)
    ans=max(ans,cache[i]);
  cout<<ans;         
}
 
int main(){ 
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
 
  return 0;
}

Measured memory_bytes: 7936
#include <stdio.h>
int main(void){
   int i, j;
   int H, W;
   
   while(1){
   
   scanf("%d %d", &H, &W);
   if(H == 0 && W == 0 )  {
   break; 
   }

   1 <= H, W <= 300;
   
   for(i = 1; i <= H; i++){
       for(j = 1; j <= W; j++){
       putchar('#');
       }
       putchar('\n');
   }
     putchar('\n');
   }
   
    return (0);
    
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    string s;
    int k;
    cin >> s >> k;
    set<string> st;
    int cnt = 0;
    for(int num = 0; num < k; num++){
        for(int i = 0; i < s.size(); i++){
            string sub = "";
            for(int j = 0; j <= cnt; j++){
                if (i+j < s.size()) sub += s[i+j];
            }
            st.insert(sub);
        }
        cnt++;
    }
    cnt = 0;
    for(auto x : st){
        cnt++;
        if (cnt != k) continue;   
        cout << x << endl;
        return 0;
    }
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double md = 360.0 / 60 * m;
    double hd = 360.0 / 12 * h + 360.0 / 12 / 60 * m;

    double c = abs(md - hd);
    double d = min(c, 360.0 - c);

    double rad = d * PI / 180;

    double ff = a * a + b * b - 2 * a * b * cos(rad);

    double f = sqrt(ff);

    printf("%.20f\n", f);


}


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

int main() {

    string s;

    cin >> s;
    int len = s.length();


    for(int i = 0;i < len;i++){

       if(i % 2 == 0){
         if(s.at(i) == 'L'){
           cout << "No";
           return 0;
         }
    }else{
        if(s.at(i) == 'R'){
           cout << "No";
           return 0;
         }
    }
    
    }
    cout << "Yes";
}

   

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main (void) {
    char w[11];
    char t[1001];
    int res=0;

    scanf ("%s", w);
    for (;;) {
        scanf ("%s", t);
        if (strcmp (t, "END_OF_TEXT")==0) break;
        for (int i=0; i<strlen(t); i++) {
            t[i]=tolower(t[i]);
        }
        if (strcmp (t, w)==0) res++;
    }

    printf ("%d\n", res);

    return 0;
}


Measured memory_bytes: 2052
import math

K = input()

D = int(K) / 2

f, i = math.modf(D)

if f == 0: # K = グウスウ
    answer =  i * i
else: # K = キスウ
    p1 = i
    p2 = i + 1
    answer = p1 * p2

print(int(answer))


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 2019;

int main() {
    string s; cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());

    vector<int> a(n+1);
    int p = 1;
    rep(i,n) {
        int di = s[i]-'0';
        a[i+1] = (a[i] + di*p%mod) % mod;
        p *= 10;
        p %= mod;
    }
    int ans = 0;
    map<int,int> mp;
    for (int i = 0; i<=n; ++i) {
        ans += mp[a[i]];
        ++mp[a[i]];
    }
    cout << ans << endl;
    return 0;
}












Measured memory_bytes: 4356
#include <stdio.h>
#include <stdlib.h>
c;
int main(i)
{
  char s[999];
  for(;;printf("%d\n",c-1))
    {
      fgets(s,999,stdin); 
      if(strstr(s,"END OF INPUT"))
	exit(0);
      for(c=i=0;s[i]!='\0';c++)
	if(s[i++]==' ')
	  printf("%d",c),c=-1;
      
    }
  
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

string s;

signed main(void) {
	cin >> s;
	int n = s.size() - 1; //size of bit
	int ans = 0;
	for (int bit = 0; bit < (1 <<n); bit++) {
		int buf = s[0] - '0';
		rep(i, n) {
			if (bit & (1 << i)) {
				ans += buf;
				buf = s[i + 1]-'0';
			}
			else {
				buf *= 10;
				buf += s[i + 1] - '0';
			}
		}
		ans += buf;
	}
	print(ans);
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010;

int s, k, res;

int main()
{
    cin >> k >> s;
    for(int i = 0; i <= k; i++)
        for(int j = 0; j <= k; j++)
        {
            int c = s - i - j;
            if(c <= k && c >= 0) res++;
        }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M,Q;
  cin >> N >> M >> Q;
  char S[N][M];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> S[i][j];
    }
  }
  //R : 青と青のつながりの数
  //BR : 青マスの数
  int R[2100][2100];
  int BR[2100][2100];
  //LineX : 線上のつながりの数
  //LineY : 線上のつながりの数
  int LineX[2100][2100];
  int LineY[2100][2100];

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      R[i][j] = 0;
      BR[i][j] = 0;
    }
  }
  for (int i = 0; i < M-1; i++) {
    for (int j = 0; j <= N; j++) {
      LineX[i][j] = 0;
    }
  }
  for (int i = 0; i < N-1; i++) {
    for (int j = 0; j <= M; j++) {
      LineY[i][j] = 0;
    }
  }
  //累積和で上の配列を埋める
  
  for (int i = 0; i < M-1; i++) {
    for (int j = 1; j <= N; j++) {
      LineX[j][i] = LineX[j-1][i];
      if (S[j-1][i] == '1' && S[j-1][i+1] == '1') {
        LineX[j][i]++;
      }
    }
  }
  for (int i = 0; i < N-1; i++) {
    for (int j = 1; j <= M; j++) {
      LineY[i][j] = LineY[i][j-1];
      if (S[i][j-1] == '1' && S[i+1][j-1] == '1') {
        LineY[i][j]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      ll res = R[i-1][j] + R[i][j-1] - R[i-1][j-1];
      if (i != 1) {
        res += LineY[i-2][j] - LineY[i-2][j-1];
      }
      if (j != 1) {
        res += LineX[i][j-2] - LineX[i-1][j-2];
      }
      R[i][j] = res;
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      BR[i][j] = BR[i-1][j] + BR[i][j-1] - BR[i-1][j-1];
      if (S[i-1][j-1] == '1') {
        BR[i][j] = BR[i][j]+1;
      }
    }
  }

  // クエリ処理
  for (int i = 0; i < Q; i++) {
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int a,b;
    a = R[x2][y2] - R[x2][y1-1] - R[x1-1][y2] + R[x1-1][y1-1];
    if (x1 != 1) {
      a -= (LineY[x1-2][y2] - LineY[x1-2][y1-1]);
    }
    if (y1 != 1) {
      a -= (LineX[x2][y1-2] - LineX[x1-1][y1-2]);
    }
    b = BR[x2][y2] - BR[x2][y1-1] - BR[x1-1][y2] + BR[x1-1][y1-1];
    cout << b-a << endl;
  }
  return 0;
}

Measured memory_bytes: 73204
s = input()
s_length = len(s)

keep = '01' * 100000
keep_1 = keep[:s_length]
keep_2 = keep[1:s_length + 1]


ans_1 = 0
ans_2 = 0
for i in range(s_length):
    if s[i] != keep_1[i]:
        ans_1 += 1
    else:
        ans_2 += 1
print(min(ans_1, ans_2))


Measured memory_bytes: 9356
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;
  deque<char> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  int r = 0;
  int l = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') r++;
    if (s[i] == ')') {
      if (r > 0) {
        r--;
      } else {
        l++;
      }
    }
  }

  while (l > 0) {
    s.push_front('(');
    l--;
  }

  while (r > 0) {
    s.push_back(')');
    r--;
  }

  for (int i = 0; i < s.size(); i++) {
    cout << s[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong(), k = scanner.nextLong();
		long ans = k;
		for (long i = 1; i < n; i++) {
			ans *= (k-1);			
		}
		System.out.println(ans);
		scanner.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main()
{
	int S, A, B;
	cin >> A >> B;
	S = A + B;
	if (S%2==0)
	{
		cout << S / 2 << endl;
	}
	else
	{
		cout << "IMPOSSIBLE "<< endl;
	}
   
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;

void main()
{
    auto N = readln.chomp.to!long;
    long r;
    foreach (i; 1..N+1) {
        auto d = N/i;
        r += d * (d+1) / 2 * i;
    }
    writeln(r);
}

Measured memory_bytes: 2744
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int mini = 0;
    ll sum = 0;
    for(int i = 0;i<n;i++){
        mini = max(mini,a[i]);
        sum += mini - a[i];
    }
    cout << sum << endl;

}

Measured memory_bytes: 3984
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;

    int max = a + b;

    int minus = a - b;
    int multiplied = a * b;

    if(max < minus) max = minus;
    if(max < multiplied) max = multiplied;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		int[] p = new int[N];
		Arrays.setAll(p, i -> sc.nextInt());
		Arrays.sort(p);
		for(int i = 0; i < K; i++)
			ans += p[i];
		System.out.println(ans);
	}

}

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

long long fibodp(int n){
    long long fibodp[200]={0};
    fibodp[0]=1;
    fibodp[1]=1;
    for(int i=2; i<=n; i++){
        fibodp[i]=fibodp[i-1]+fibodp[i-2];
    }
    return fibodp[n];
}

int main(void){
    int n;
    cin>>n;
    cout<<fibodp(n)<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;

int n;
bool Era[123456*2+1];
int main() {
    Era[0] = Era[1] = false;
    for(int i=2; i<=123456*2+1; ++i) Era[i]=true;
    
    for(int i=2; i*i < 123456*2+1; ++i){
        if(Era[i]){
            for(int j=0; i*(j+2)< 123456*2+1; j++){
                Era[i*(j+2)]= false;
            }
        }
    }   
    while(cin >> n, n){
        int cnt=0;
        for(int i=n+1; i<=2*n; ++i){
            if(Era[i]) cnt++;
        }
        cout << cnt << endl;
    }
        
    return 0;
}


Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool a[6][6];
int row[6], col[6];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, k, black = 0;
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) {
        string s;
        int b = 0;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '#')
                a[i][j] = true, b++, col[j]++;
        }
        row[i] = b;
        black += b;
    }
    int ans = 0;
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            int cnt = 0;
            vector<int> r, c;
            for (int x = 0; x < h; x++) {
                if (i & (1 << x))
                    cnt += row[x], r.push_back(x);
            }
            for (int y = 0; y < w; y++) {
                if (j & (1 << y))
                    cnt += col[y], c.push_back(y);
            }
            for (int ni : r)
                for (int nj : c)
                    if (a[ni][nj])
                        --cnt;
            if (black - cnt == k)
                ++ans;
        }
    }

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

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

int main(){
    int N,M,C;
    int number_correct_inequation=0;

    cin>>N>>M>>C;
    cin.ignore();
    vector<int> B(M);
    for (int i=0; i<M;i++){
        cin >> B[i];
    }

    vector<vector<int>> A(N,vector<int>(M));
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    for(int i=0;i<N;i++){
        int out=0;
        for(int j=0;j<M;j++){
            out+=A[i][j]*B[j];
        }
        if(out+C>0){
            number_correct_inequation+=1;
        }
    }
    cout<<number_correct_inequation<<endl;
}

Measured memory_bytes: 256
n=int(input())
l=[0]+list(map(int,input().split()))+[0]
s=sum(abs(l[i+1]-l[i]) for i in range(n+1))
for i in range(n):
  a,b,c=l[i:i+3]
  print(s-abs(b-a)-abs(c-b)+abs(c-a))

Measured memory_bytes: 14048