akhauriyash/Code-Regression huggingface dataset:
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
//end of libraries ;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , h[N] , dp[N];
int main(){
fcin;
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		 cin >> h[i];
		 dp[i] = INF;
	}
	dp[1] = h[1];
	dp[2] = abs(h[2] - h[1]);
	dp[3] = abs(h[3] - h[1]);
	for(int i = 4 ; i <= n ; i++){
		dp[i]=dp[i-1] + abs(h[i-1] - h[i]);
		dp[i] = min(dp[i], dp[i-2] +  abs(h[i-2] - h[i]));
	}
	cout << dp[n] << "\n";

}

Measured memory_bytes: 2688
#include <iostream>
using namespace std;
int main()
{

int n,sum=0;
char s[1000];
cin>>n;
cin>> s;
if (n%2==1)
cout <<"No";
else 
{
    {
    for (int i=0;i<n/2;i++)
     {if (s[i]==s[i+n/2])
      sum++;
      }
  
    }
if (sum==n/2)cout <<"Yes";
else cout <<"No";
}

    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			System.out.println(dfs(N, 1, 0));
		}
	}

	static int dfs(int cur, int prev, int d) {
		if (cur == 0) return 1;
		if (d == 4) return 0;
		int ret = 0;
		for (int i = prev;; ++i) {
			int sq = i * i;
			if (sq > cur) break;
			ret += dfs(cur - sq, i, d + 1);
		}
		return ret;
	}

}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> d;
    d.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }
    uint64_t ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

ll ans = 1e10;

ll divide(ll h, ll w){
	for (int i = 0; i <= h; i++) {
		ll a = i * w;
		ll mid = (h - i) / 2;
		ll b = mid * w, c = (h - i - mid)*w;
		ll d = (h - i)*(w / 2), e = (h - i)*(w - w / 2);

		ll mxarea1 = max(a, max(b, c));
		ll mnarea1 = min(a, min(b, c));
		ans = min(ans, mxarea1 - mnarea1);

		ll mxarea2 = max(a, max(d, e));
		ll mnarea2 = min(a, min(d, e));
		ans = min(ans, mxarea2 - mnarea2);
	}
	return ans;
}

int main() {
	ll h, w; cin >> h >> w;

	ans = min(divide(h, w), divide(w, h));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str;
		final int x=600;
		while((str=br.readLine())!=null){
			int d=Integer.parseInt(str);
			int circle=x/d;
			
			int s=0;
			for(int i=1;i<circle;i++){
				int ux=d*i;
				int hight=ux*ux;
				/*System.out.println(ux);*/
				s+=hight*d;
			}
			System.out.println(s);
		}
	}

}

Measured memory_bytes: 24000
#include <bits/stdc++.h>
using namespace std;
int main() {
  //入力
  int h, w;
  cin >> h >> w;
  //一つの文字列に
  string s; 
  for(int i = 0; i < h; i++) {
    string f;
    cin >> f;
    s += f;
  }
  //数えて出力 s.at(i*w+j)が基本
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      int count = 0;
      if(s.at(i*w+j) == '#') {
        cout << '#';
        continue;
      }
      if(i!=0   && j!=0   && s.at((i-1)*w+j-1)=='#') count++;
      if(i!=0   &&           s.at((i-1)*w+j)  =='#') count++;
      if(i!=0   && j!=w-1 && s.at((i-1)*w+j+1)=='#') count++;
      if(          j!=0   && s.at( i   *w+j-1)=='#') count++;
      if(          j!=w-1 && s.at( i   *w+j+1)=='#') count++;
      if(i!=h-1 && j!=0   && s.at((i+1)*w+j-1)=='#') count++;
      if(i!=h-1 &&           s.at((i+1)*w+j)  =='#') count++;
      if(i!=h-1 && j!=w-1 && s.at((i+1)*w+j+1)=='#') count++;
      cout << count;
    }
    cout << endl;
  }
}


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

int N;
int A[MAX_N];
int B[MAX_N];

int main() {
    cin>>N;
    rep(i,N-1)  cin>>B[i];
    B[N-1]=1000001;
    int sum=0;

    for(int i=1;i<N;i++)  {
        A[i]=min(B[i-1],B[i]);
        sum=sum+A[i];
    }
    sum=sum+B[0];
    cout<<sum;

 return 0;
}

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

int main(){
    ll n;
    ll n2;
    int k2=0;
    
    cin >> n;
    //n=pow(5,18);
    n2=n;
    queue <int> q;
    rep(i,1000001){
        while(n%(i+2)==0){
            n/=i+2;
            if(i+2==2){
                k2++;
                
            }
            else{
            q.push(i+2);
            }
            if(n==0){
                break;
            }
        }
    }

    q.push(1);
    int l;
    l=q.size();

    
vector <int> in(l);
int k;
rep(i,l){
    k=q.front();
    in[i]=k;
    q.pop();
}

ll seki;
ll ans=1001001001001;



rep(i,pow(2,l)-1){
    rep(g,k2+1){

    seki=pow(2,g);

    rep(j,l){
        if((((i+1)>>j)&1)==1){
            seki*=in[j];
        }
        
    }
    
    ans=min(ans,seki+(n2/seki)-2);
    
    }
}
cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
kr :: [Int] -> [Int]
kr [x] = [x]
kr (x:x':xs) = if x < x' then x:kr ((x'-1):xs) else x:kr(x':xs)

masu :: [Int] -> String
masu [x] = "Yes"
masu (x:x':xs) = if x < x' then "No" else masu (x':xs)

main = do
    _ <- getLine
    h <- map read . words <$> getLine :: IO [Int]
    putStrLn $ masu . kr $ reverse h


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define GOOGLE 0
#define MULTIPLE_TC 0

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

int n; string s;

void solve(){
  int i, j, k;
  cin >> n >> s;
  int ans = 0, red = 0;

  for (i = 0; i < n; i++) {
    red += (s[i] == 'R');
  }
  n = red;
  for (i = 0; i < n; i++) {
    red -= (s[i] == 'R');
  }
  cout << red << '\n';
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1, T;

  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}


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

using namespace std;

int main()
{
	int cnt=0;
	string s;

	while(cin>>s){
		int len=s.length();
		bool b=true;
		for(int i=0;i<len/2;i++)
			if(s[i]!=s[len-i-1])	b=false;
		if(b)	cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0] and b[b.size()-1]==c[0]) cout<<"YES";
	else cout<<"NO";
	
	return 0;
}

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

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pii pair<int,ll>
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 1000000007
#define pai acos(-1)
#define mx 1000000000
#define N 2005


int main ()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    ll n,k,x,y;
    cin>>n>>k;
    x=n/k;
    cout<<min(abs(x*k-n),abs((x+1)*k-n))<<endl;
    return 0;
}



Measured memory_bytes: 256
S = input()

blocks = []

R_cnt = 0
L_cnt = 0
prev = 'R'
for s in S:
    if s == 'R':
        if prev == 'L':
            blocks.append((R_cnt, L_cnt))
            L_cnt = 0
            R_cnt = 0
        R_cnt += 1
    else:
        L_cnt += 1
    prev = s
blocks.append((R_cnt, L_cnt))

ans = []
for block in blocks:
    (r, l) = block
    if abs(r-l) % 2 == 0:
        ans.append(' '.join(map(str, [0]*(r-1) + [(r+l)//2]*2 + [0]*(l-1))))
    else:
        mid_r = (r+1)//2+l//2
        mid_l = r//2+(l+1)//2
        ans.append(' '.join(map(str, [0]*(r-1) + [mid_r, mid_l] + [0]*(l-1))))
print(' '.join(ans))


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

using namespace std;

int main()
{
    string s;
    int sum=0;
    
    cin>>s;
    
    for(int i=0; i<s.length(); i++)
    sum+=(s[i]-48);
    
    
    if((sum%9)==0)
    cout<<"Yes"<<endl;
    
    else
    cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
/*template code starts*/
typedef unsigned long long ULL;
typedef long long LL;
template<typename T>
void LOG(T const& t) {
	std::cout << t<<endl;
}
template<typename First, typename ... Rest> 
void LOG(First const& first, Rest const& ... rest) {
	std::cout << first<<" "; LOG(rest ...);
}
int a[300009];
int b[300009];
int N;
string str;
int main() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cin >> N;
	cin >> str;
	a[0] = (str[0] == 'E')?0:1;
	b[0] = a[0];
	for(int i = 1;i<str.length();i++) {
		a[i] = (str[i] == 'E')?0:1;
		b[i] = b[i-1] + a[i];
	}
	int ans = 1e9;
	for(int i = 0;i<N;i++) {
		int r = (i<N-1)? (N - i - 1) - (b[N-1] - b[i]) : 0;
		int l = (i>0)? b[i-1] : 0;
		//LOG("i = ",i," r = ",r," l = ",l);
		ans = min(ans,r+l);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	// your code goes here
	int N;
	
	while(cin >> N && N){
	int p=0,d1=0,d2=0,mp=0,md1=0,md2=0;
	for(int i=0;i<N;i++){
		cin >> p >> d1 >> d2;
		if(d1+d2>md1+md2){
			mp=p;
			md1=d1;
			md2=d2;
		}
	}
		
		cout << mp << " " << md1+md2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == string(s.size(), s[0])) { // 全て同じ文字
        cout << s.size() << endl;
        return 0;
    }
    vector<int> cnt(26); // 文字ごとの出現頻度を記録
    for (char c : s) {
        cnt[c - 'a']++;
    }
    priority_queue<int> pq;
    for (auto num : cnt) {
        if (num) {
            pq.push(-num);
        }
    }
    int ans = 0;
    while(pq.size() > 1) {
        int x = pq.top();
        pq.pop();
        int y = pq.top();
        pq.pop();
        ans -= x + y;
        pq.emplace(x + y);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3352
package main

import (
	"fmt"
)

func main() {
	var a,b,c int
	fmt.Scanf("%d%d%d",&a,&b,&c)

	if a+b  > c {
		fmt.Println("No")
	}else{
		var d int64 = int64(c -a -b )
		d = d * d
		var e = int64(a)*int64(b)*4

		if d > e {
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int count = 1;
    
    for(int i = 0; i < n ; i++){
        list.add(sc.nextInt());
    }

    int max = list.get(0);

    for(int i = 1; i < n ; i++){
            if(list.get(i) >= max){
                count++;
                max = list.get(i);
            }
    }

    System.out.println(count);


}
}

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

int main(){
	string str;
	int sum=0;
	while(cin>>str){
		str+="#";
		int tmp=0;
		for(int i=0;i<str.size();i++){
			if('0'<=str[i]&&str[i]<='9'){
				tmp*=10;
				tmp+=(str[i]-'0');
			}
			else{
				sum+=tmp;
				tmp=0;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    ll T;
    vector<ll> ans;
    cin >> T;
    for(int t=0;t<T;t++){
        ll N;
        cin >> N;
        ll tmp_ans = 0;
        vector<vector<ll>> v_right(N);
        vector<vector<ll>> v_left(N);
        for(int n=0;n<N;n++){
            ll k,l,r;
            cin >> k >> l >> r;
            if(l>r) v_left[k-1].push_back(l-r);
            else v_right[k-1].push_back(r-l);
            tmp_ans += min(l,r);
        }
        priority_queue<ll,vector<ll>,greater<ll>> pq;
        for(int i=0;i<N;i++){
            for(auto &e : v_left[i]){
                pq.push(e);
            }
            while(pq.size() > i+1) pq.pop();
        }
        while(!pq.empty()){
            tmp_ans += pq.top();
            pq.pop();
        }
        for(int i=N-2;i>=0;i--){
            for(auto &e : v_right[i]){
                pq.push(e);
            }
            while(pq.size() > N - i - 1) pq.pop();
        }
        while(!pq.empty()){
            tmp_ans += pq.top();
            pq.pop();
        }
        ans.push_back(tmp_ans);
    }
    for(auto &e : ans) cout << e << endl;
    return 0;
}

Measured memory_bytes: 18352
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N[5];
    int ans = 0;
    for (int i=0;i<5;i++){
    cin >> N[i];
    if(N[i] == 0){
        ans = i + 1;
        break;
    }
    }
    cout << ans <<endl;
    
}


Measured memory_bytes: 3628
# import numpy as np
#N=int(input().strip())
#x=[0]*N
#y=[0]*N
#
#for i in range(N):
#    x[i],y[i]=list(map(int,input().strip().split()))

import sys

A,B=list(map(int,input().strip().split()))

if A>9 or B>9:
    print(-1)
    sys.exit()
else:
    print(A*B)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, v,b, w, t;
  cin >> a >> v >> b >> w >> t;
  ll d = abs(a-b);
  d += w * t;
  if(v * t >= d) cout << "YES" << endl;
  else cout << "NO" << endl;

}


Measured memory_bytes: 3640
#!/usr/bin/env python3
k = int(input())
ans = 1
p = 7
used = {p: True}
while True:
    if p % k == 0:
        print(ans)
        exit()
    p = (p * 10 + 7) % k
    if p in used:
        print(-1)
        exit()
    used[p] = True
    ans += 1


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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  for (auto &e : v) {
    cin >> e;
    e = abs(e - x);
  }
  int r = v.front();
  for (auto e : v) {
    r = gcd(r, e);
  }
  cout << r << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

ll a[50];

int main(void) {
    int i, j, n;
    cin >> n;
    REP (i,n) cin >> a[i];

    ll ans = 0;
    bool found = true;
    while (found) {
        found = false;
        REP (i,n) if (a[i] >= n) {
            long long x = a[i] / n;
            REP (j,n) if (j != i) a[j] += x;
            a[i] %= n;
            ans += x;
            found = true;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int64_t get_lucas_number(int num)
{
  int64_t x = 2;
  int64_t y = 1;
  for (int i = 1; i < num; i++)
  {
    int64_t sum = x + y;
    x = y;
    y = sum;
  }
  return (y);
}

int main()
{
  int num;
  cin >> num;
  cout << get_lucas_number(num) << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll a,b;
    cin >> a >> b;
    cout << a*b;
}

Measured memory_bytes: 3636
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
template<class T>void mini(T &a,T b){a=min(a,b);}
template<class T>void maxi(T &a,T b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
void addin(){}template<class Head,class...Tail>void addin(vector<Head>&vechead,Tail&&...tail){in(Head,head);vechead.emb(head);addin(forward<Tail>(tail)...);}
template<class C>void vecout(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}

// #define int int64_t
// #define double long double


signed main(){
  IOS;

  in(int,a,b);
  int x=max(a,b);
  out((x>8) ? ":(" : "Yay!");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    long long X; cin >> X;
    long long money = 100;
    int i = 0;
    while(money < X){
        i += 1;
        money = money*1.01;
//        cout << money << endl;
    }
    cout << i << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
#define N 100
int main(){
  int A[N],n,i,j,count=0,sirusi=1,t;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    }
  for(i=0;sirusi;i++){
    sirusi=0;
    for(j=n-1;j>=i+1;j--){
      if (A[j]<A[j-1]){
        t = A[j];
        A[j]=A[j-1];
        A[j-1]=t;
        sirusi=1;
        count++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 2100
n, k = map(int, input().split())
a = list(map(int, input().split()))
for j in range(min(k, 41)):
  b = [0]*n
  for i in range(n):
    l = max(0, i-a[i])
    r = min(n, i+a[i]+1)
    b[l] += 1
    if r < n:
      b[r] -= 1
  for i in range(1, n): 
    b[i]+=b[i-1]
  a = b

print(" ".join(list(map(str, a))))
      
  


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n, m;
    cin >> m >> n;
    int q;
    cin >> q;
    vector<int> a(q);
    for(auto& x : a){
        cin >> x;
        --x;
    }

    auto rev = a;
    reverse(rev.begin(), rev.end());
    for(int i = 0; i < n; ++i)
        rev.emplace_back(i);
    unordered_set<int> s;
    vector<int> final;
    for(auto& x : rev)
        if(s.find(x) == s.end()){
            s.insert(x);
            final.emplace_back(x);
        }
    rev.resize(rev.size() - n);

    vector<int> inv(n);
    for(int i = 0; i < n; ++i)
        inv[final[i]] = i;

    vector<int> dp(n + 1, 0);
    dp[0] = m;
    int t = 0;
    for(auto& x : rev){
        if(t < inv[x]){
            cout << "No" << endl;
            return 0;
        }
        if(dp[inv[x]]){
            --dp[inv[x]];
            ++dp[inv[x] + 1];
        }
        t = max(t, inv[x] + 1);
    }

    int c;
    int ma = MOD;
    for(c = n - 1; c >= 0; --c){
        if(ma < final[c])
            break;
        ma = final[c];
    }
    c++;

    /*
    cout << c << endl;

    for(int i = 0; i < n; ++i)
        cout << final[i] + 1 << " \n"[i == n - 1];

    for(int i = 0; i <= n; ++i)
        cout << dp[i] << " \n"[i == n];
        */

    cout << (accumulate(next(dp.begin(), c), dp.end(), 0) == m ? "Yes" : "No") << endl;
}


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

Measured memory_bytes: 128
s=input()
ans1=[]
ans1.append(0)
now=0
for i in s:
    if i == "<":
        now+=1
    else:
        now=0
    ans1.append(now)
ans2=[]
ans2.append(0)
now=0
for i in reversed(s):
    if i == ">":
        now+=1
    else:
        now=0
    ans2.append(now)

ans=[]
for i in range(len(ans1)):
    ans.append(max(ans1[i],ans2[len(ans1)-i-1]))
print(sum(ans))

Measured memory_bytes: 99600
N = int(input())
S = str(input())

r = S.count("R")
g = S.count("G")
b = S.count("B")

ct = r*g*b

for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k<=N-1:
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ct-=1
print(ct)


Measured memory_bytes: 9200
#include<iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX+1];

void Maxheap(int i){
int l,r,max;
l=2*i;
r=2*i+1;

if(l<=H&&A[l]>A[i])max=l;
else max=i;
if(r<=H&&A[r]>A[max])max=r;

if(max!=i){
swap(A[i],A[max]);
Maxheap(max);
}
}

main(){
cin >> H;

for(int i=1;i<=H;i++)cin >> A[i];
for(int i=H/2;i>=1;i--)Maxheap(i);
for(int i=1;i<=H;i++)cout <<" "<<A[i];
cout << endl;

return 0;
}

Measured memory_bytes: 5024
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int r;
int main(){
	cin>>r;
	cout<<3*r*r;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath> 
#include <queue>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <cstdio>
#include <set>
using namespace std;
int n,l;
string a[100];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>l;
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for (int i=0;i<n;i++)
		cout<<a[i];
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    string prev;
    string current;
    for (int i = 0; i < (int)s.size(); i++) {
        current += s.at(i);
        
        if (prev != current && current != "") {
            cnt++;
            prev = current;
            current = "";
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 644
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int n,d;
    cin >> n >> d;
    int people = n / (d*2 + 1);
    if (n % (d*2 + 1) != 0){
        ++people;
    }
    cout << people << endl;

}

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

int main(){
 vector<int> ans(6);
  int a;
  for(int i=1;i<=5;i++){
  	cin >> ans.at(i);
  }
  
  for(int i=1;i<=5;i++){
  	if(ans.at(i) == 0){
    	a = i;
      break;
    }
  }
  
  cout << a << endl;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  int t[n];for(int i=0;i<n;i++)cin>>t[i];
  int m;cin>>m;
  int p,x,hoge;
  for(int i=0;i<m;i++){
    cin>>p>>x;
    hoge=0;
    for(int i=0;i<n;i++)i==p-1 ? hoge+=x : hoge+=t[i];
    cout<<hoge<<endl;
  }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] ans = new int[N];
		for(int i=0;i<N;i++) ans[i] = A[i];
		
		ans[0] = 0;
		
		HashSet<int>[] XE = new HashSet<int>[N];
		for(int i=0;i<N;i++){
			XE[i] = new HashSet<int>();
		}
		
		for(int i=1;i<N;i++){
			XE[A[i]].Add(i);
		}
		
		int[] depth = new int[N];
		int[] parent = new int[N];
		for(int i=1;i<N;i++){
			parent[i] = A[i];
		}
		
		var Q = new Queue<int>();
		depth[0] = 0;
		Q.Enqueue(0);
		while(Q.Count > 0){
			var now = Q.Dequeue();
			foreach(var nxt in XE[now]){
				depth[nxt] = depth[now] + 1;
				Q.Enqueue(nxt);
			}
		}
		
		Pair[] P = new Pair[N];
		for(int i=0;i<N;i++) P[i] = new Pair(i, depth[i]);
		Array.Sort(P, (p, q) => p.Depth.CompareTo(q.Depth));
		Array.Reverse(P);
		
		
		int[] dp = new int[N];
		foreach(var p in P){
			int now = p.Idx;
			int m = 0;
			foreach(var nxt in XE[now]){
				m = Math.Max(m, dp[nxt] + 1);
			}
			dp[now] = m;
			if(m == K - 1){
				XE[parent[now]].Remove(now);
				ans[now] = 0;
			}
		}
		
//Console.WriteLine(String.Join(" ",A));
//Console.WriteLine(String.Join(" ",ans));
//Console.WriteLine(String.Join(" ",dp));
		
		int cnt = 0;
		for(int i=0;i<N;i++) if(ans[i] != A[i]) cnt++;
		Console.WriteLine(cnt);
		
	}
	
	class Pair{
		public int Idx, Depth;
		public Pair(int idx, int depth){
			Idx = idx; Depth = depth;
		}
	}
	
	int N, K;
	int[] A;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = ria();
		for(int i=0;i<N;i++) A[i]--;
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 45520
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <random>
#include <stack>
#include <ctime>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

int main() {
    int num[3], k;
    cin >> num[0] >> num[1] >> num[2] >> k;

    sort(num, num + 3);

    cout << num[2] * pow(2, k) + num[0] + num[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	REP(i,s.size()){
		if(s==t){
			cout<<"Yes"<<endl;
			return 0;
		}
		s=s.back()+s.substr(0,s.size()-1);
	}
	cout<<"No"<<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[] A = new int[n];
   int max = 0; 
   for(int i = 0;i < n;i++){
      A[i] = sc.nextInt();
      if(A[i] > max) max = A[i];
   }
   int k = max;
   int[] B = new int[n];  
   int[] C = new int[k + 1];

   for(int i = 0;i < k;i++) C[i] = 0;
   /**/for(int j = 0;j < n;j++) C[A[j]]++;
   for(int i = 1;i < k + 1;i++){
     C[i]+=C[i - 1];
   }
   for(int j = n - 1;j >= 0;j--){/*j > 0 to j>= 0 */
     B[C[A[j]] - 1] = A[j];
     C[A[j]]--;
   }
   StringBuilder sb = new StringBuilder();
   for(int i = 0;i < n - 1;i++){
    sb.append(B[i]+" ");
  }
  System.out.println(sb.append(B[n - 1]));
  }
}





Measured memory_bytes: 579104
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);
struct three{
	ll a,b,c;

};

int main(){
	ll n,q;
	IOS
	cin>>n>>q;
	std::vector<three> v;
	ll aa,bb,cc;
	auto compare=[&](three a,three b){
		return a.a<b.a;

	};
	fo(i,n){
		three tmp;
		cin>>aa>>bb>>cc;
		tmp.a=cc;
		ll hi,lo;
		if(bb-1>=cc){
			hi=bb-1-cc;

		}
		else hi=-1;
		lo=max((ll)0,aa-cc);
		tmp.b=lo;
		tmp.c=hi;
		v.pb(tmp);



	}
	map<ll,ll> d;
	sort(all(v),compare);
	set<ll> st;
	fo(i,q){
		cin>>aa;
		d[aa]=-1;

		st.insert(aa);
	}
	for(auto kk:v){
		//dbg3(kk.a,kk.b,kk.c);
		std::vector<ll> out;
		auto it=st.lower_bound(kk.b);
		while(it!=st.end()){
			ll our=*it;
			if(our>=kk.b&&our<=kk.c){
				out.pb(our);


			}
			else break;
			it++;
		}
		for(auto pp:out){
			d[pp]=kk.a;

			st.erase(pp);

		}
	}
	for(auto ii:d){
		cout<<ii.second<<endl;
	}

}




Measured memory_bytes: 32108
while True:
    w,h=map(int,raw_input().split())
    if w==h==0:break
    mv=((0,1),(1,0),(0,-1),(-1,0))
    pos=0
    nx=ny=1
    while True:
        command=raw_input()
        if command=="STOP":
            break
        if command[-1].isdigit():
            d,l=command.split()
            if d=="FORWARD":
                nx+=mv[pos][0]*int(l)
                ny+=mv[pos][1]*int(l)
            elif d=="BACKWARD":
                nx-=mv[pos][0]*int(l)
                ny-=mv[pos][1]*int(l)
            nx=min(nx,w)
            nx=max(nx,1)
            ny=min(ny,h)
            ny=max(ny,1)
        else:
            if command=="LEFT":
                pos=pos-1 if pos!=0 else 3
            elif command=="RIGHT":
                pos=(pos+1)%4
    print nx,ny

Measured memory_bytes: 4280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		double count = 0;

		for(int i = 1;i<=num;i++) {
			if(i % 2 == 1) {
				count++;
			}
		}


		System.out.println(count / num);
	}


}

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

namespace ABC141D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            string[] Ainput = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
            long[] A = new long[N];
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                A[i] = long.Parse(Ainput[i]);
                ans += A[i];
            }
            List<long> list = new List<long>();
            for(int i = 0; i < N; i++)
            {
                while (A[i] > 0)
                {
                    list.Add(A[i]-(A[i] / 2));
                    A[i] /= 2;
                }
            }
            list.Sort();
            int max = list.Count();
            int m = Math.Min(max, M);
            for(int i = 0; i < m; i++)
            {
                ans -= list[max - i - 1];
            }            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 95100
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    a = string(a.rbegin(), a.rend());
    reverse(ALL(b));
    reverse(ALL(c));
    char now = 'a';
    while (true) {
        if (now == 'a') {
            if (!a.empty()) {
                now = a.back();
                a.pop_back();
            } else {
                cout << "A\n";
                return 0;
            }
        } else if (now == 'b') {
            if (!b.empty()) {
                now = b.back();
                b.pop_back();
            } else {
                cout << "B\n";
                return 0;
            }
        } else if (now == 'c') {
            if (!c.empty()) {
                now = c.back();
                c.pop_back();
            } else {
                cout << "C\n";
                return 0;
            }
        }
    }
}


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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      w: usize,
      wvs: [(usize, usize); n],
    }
    debug!(n, w, wvs);
    let mut dp = vec![vec![0; w+1]; n];
    dp[0][0] = 0;
    dp[0][wvs[0].0] = wvs[0].1;
    for i in 1..n {
        let &(wi, vi) = &wvs[i];

        for ww in 0..w+1 {
            if ww >= wi {
                dp[i][ww] = dp[i-1][ww-wi] + vi;
            }
            dp[i][ww] = max(dp[i][ww], dp[i-1][ww]);
        }
    }
    println!("{}", dp[n-1].iter().max().unwrap());
}


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

int main(){
    int n,d;
    cin >> n >> d;
    int x[n][d];
    int res = 0;

    for (int p = 0; p < n; p++){
	for (int s = 0; s < d; s++){
	    cin >> x[p][s];
	}
    }

    for (int i = 0; i < n-1; i++){
	for (int j = i+1; j < n; j++){
	    double distance = 0;
	    for (int k = 0; k < d; k++){
		distance += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
	    }
	    double dist = sqrt(distance);
	    int dist_int = floor(dist);
	    if (dist == dist_int){
		res += 1;
	    }
	}
    }
    
    cout << res << endl;

    return 0;
}


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

struct node{
    int key;
    struct node *left,*right,*par;
};
typedef struct node* node_pointer; 

node_pointer nil,root;

void insert(int);
void Preorder(node_pointer);
void Inorder(node_pointer);

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

    for(i=0; i<n; i++){
        char order[7];
        int num;
        scanf(" %s",order);

        if(strcmp(order,"insert") == 0 ){
            scanf("%d",&num);
            insert(num);
        }

        else if(strcmp(order,"print") == 0){
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }

    return 0;
}

void insert(int num){
    node_pointer a,b,c;
    a = root;
    b = nil;
    c = (node_pointer)malloc(sizeof(struct node));
    c->key = num;
    c->right = nil;
    c->left = nil;

    //どの葉の子になるかを決める
    while(a != nil){
        b = a;       
        if(c->key < a->key) a = a->left;
        else a = a->right;
    }

    c->par = b;

    //決めた葉の右の子か左の子かを決める
    
    if(b == nil) root = c;
    else if(c->key < b->key) b->left = c;
    else b->right = c;
}

void Preorder(node_pointer a){
    if(a == nil) return;
    printf(" %d",a->key);
    if(a->left != nil) Preorder(a->left);
    if(a->right != nil) Preorder(a->right);
}

void Inorder(node_pointer a){
    if(a == nil) return;
    if(a->left != nil) Inorder(a->left);
    printf(" %d",a->key);
    if(a->right != nil) Inorder(a->right);
}



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

int main() {
    long long int a, b;
    cin >> a >> b;

    long long int k = (a + b) / 2;

    long long int ans = abs(a-k);

    if (ans == abs(b-k)) cout << k << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

string s;
int n;

int mpar()
{
	vi v;
	v.push_back(s[0] - '0');
	FOR(i, 1, s.size())
	{
		if (s[i] == '+') v.push_back(s[i+1] - '0');
		else v.back() *= s[i + 1] - '0';
		i++;
	}
	int ans = 0;
	REP(i, v.size()) ans += v[i];
	return ans;
}

int lpar()
{
	int ans = s[0]-'0';
	FOR(i, 1, s.size())
	{
		int t = s[i + 1] - '0';
		if (s[i] == '+') ans += t;
		else ans *= t;
		i++;
	}
	return ans;
}

int main()
{
	cin >> s >> n;
	int l = lpar();
	int m = mpar();
	char c;
	if (l==n&&m==n) c = 'U';
	else if (l == n) c = 'L';
	else if (m == n) c = 'M';
	else c = 'I';
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3228