akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int a,i,k,W,H;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)break;
        for(i=1;i<=H;i++){
            if(i%2==1){
                a=1;
            }
            else{
                a=2;
            }
            for(k=1;k<=W;k++){
                if(a==1){
                    if(k%2==1){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                    
                }
                else{
                    if(k%2==1){
                        printf(".");
                    }
                    else{
                        printf("#");
                    }
                    
                }
            }
            printf("\n");
        }
        printf("\n");
    }
            
    return 0;
}

Measured memory_bytes: 1820
#include<stdio.h>
int main(){
int x,n,i,j,k,cnt;
while(1){
	cnt = 0;
	scanf("%d%d", &n, &x);

	if(n==0 && x==0)
		break;
	
	for(i=1; i<=n; i++){
		for(j=i+1; j<=n; j++){
			for(k=j+1; k<=n; k++){
				if(i+j+k==x)
					cnt++;
			}
		}
	}


	printf("%d\n", cnt);
				
}

return 0;

}

			

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int linearSearch(int *A, int key, int n){
    for(int i = 0; i < n; i++){
        if(A[i] == key) return i;
    }
    return -1;
}

int main(){
    int n, q, i, j, count = 0;
    cin >> n;
    int S[n];
    for(i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    int T[q];
    for(i = 0; i < q; i++) cin >> T[i];
    for(i = 0; i < q; i++){
        if(linearSearch(S, T[i], n) != -1) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3100
//don't go gentle into
// the goodnight.

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

#define int       long long
#define ll        long long
#define fr        first
#define sec       second
#define pi        3.141592653589793
#define M         1000000007
#define mod       998244353
#define maxint    2147483647
#define minint    -2147483648
#define maxll     9223372036854775807
#define minll     -9223372036854775808
#define meme0(a)  memset(a,0,sizeof(a));
#define meme1(a)  memset(a,-1,sizeof(a));
#define i_m_speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open      freopen("input.txt","r",stdin);
#define close     freopen("output.txt","w",stdout);
#define v_int     vector<int >
#define v_ll      vector<long long >
#define pb        push_back
#define mk        make_pair
//upper_bound(begin(),end(),key)
//lower_bound(begin(),.end(),key);

ll expo(ll x , ll n , ll m){
    if(n==0)
        return 1;
    else if(n%2==0)
        return expo((x*x)%m , n/2 , m);
    else
        return (x*expo((x*x)%m,(n-1)/2,m))%m;

}
string toBinary(ll n)
{
    std::string r;
    while(n!=0){
        r=(n%2==0 ?"0":"1")+r;
        n/=2;
    }
    return r;
}
void solve(){
    int a;
    cin >> a;
    int x = a;
    vector <int> v;
    for(int i=2;i*i<=x;i++){
        if(x%i==0){
            int count = 0;
            while(x%i==0){
                x /= i;
                count++;
            }
            v.push_back(count);
        }
    }
    if(x>1)
        v.push_back(1);
    int ans = 0;
    for(int i=0;i<v.size();i++){
        //cout << v[i] << " " ;
        int x = v[i];
        double k = sqrt(1+8*x);
        k += -1;
        k = k/(double)(2);
        int v = k;
        //cout << v << endl;
        ans += v;
    }
    cout << ans << endl;
    return;
}
int32_t main(){
    i_m_speed
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }

    return 0;
}


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

int divide(vector<int> &A){
  int a;
  for (int i = 0; i < A.size(); i++){
    if (A.at(i) % 2 != 0){
      a = 0;
      return a; 
    }
    A.at(i) = A.at(i) / 2;
    a = 1;
  }
  return a;
}

int count(vector<int> X){
  int ans = 0;
  while (divide(X) == 1){
    ans++;
  }
  return ans;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  cout << count(A) << endl;
}

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

int main(){
int n;
cin >> n;
vector<int> v;
copy_n(istream_iterator<int>(cin), n, back_inserter(v));
cout << (*max_element(begin(v), end(v)) -
*min_element(begin(v), end(v)));
return 0; }

Measured memory_bytes: 256
#include <iostream>
#define LL long long
using namespace std;

LL N,p[20100],a[20100],b[20100];

int main(){
    cin >> N;

    int i;
    for (i=1; i<=N; i++) cin >> p[i];

    for (i=1; i<=N; i++) a[p[i]]=i;

    LL s=0;
    for (i=2; i<=N; i++){
        a[i]+=s,b[i]-=s;
        if (a[i]<=a[i-1]){
            s+=(a[i-1]-a[i]+1);
            b[i]-=(a[i-1]-a[i]+1);
            a[i]=a[i-1]+1;
        }

        if (b[i]>=b[i-1]){
            s+=(b[i]-b[i-1]+1);
            a[i]+=(b[i]-b[i-1]+1);
            b[i]=b[i-1]-1;
        }
    }

    LL x=0;
    for (i=1; i<=N; i++)
        x=max(x,max(1-a[i],1-b[i]));

    for (i=1; i<=N; i++)
        cout << a[i]+x << " ";
    cout << "\n";
    for (i=1; i<=N; i++)
        cout << b[i]+x << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int n,t,tsum=0;
    cin>>n>>t;
    int ti[n];
    for(int i=0;i<n;i++)
        cin>>ti[i];
    for(int i=0;i<n-1;i++)
    {
        if(ti[i+1]-ti[i]<t)
            tsum+=ti[i+1]-ti[i];
        else if(ti[i+1]-ti[i]>=t)
            tsum+=t;
    }
    cout<<tsum+t;


    return 0;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = X + 1;
		for(int i = 0; i < N; i++) {
			Z = Math.max(Z, sc.nextInt() + 1);
		}
		boolean flag = true;
		for(int i = 0; i < M; i++) {
			flag = flag && sc.nextInt() >= Z;
		}
		flag = flag && Y >= Z;
		if(flag) {
			System.out.println("No War");
		} else {
			System.out.println("War");
		}
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int N; 
long long h[100010];
long long dp[100010];
int main(){
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i] ;
    for (int i = 0; i < N; ++i) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < N; ++i){
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1){
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
cout << dp[N - 1] << endl;    
    
    
    
    
}


Measured memory_bytes: 1792
// Date: 2020-06-13

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3);

    return 0;
}

Measured memory_bytes: 3624
package main

import (
  "bufio"
  "fmt"
  "os"
  "strings"
  "strconv"
)

type stack struct {
  data []int
}

func (s *stack) push(d int) {
  s.data = append(s.data, d)
}

func (s *stack) pop() int {
  l := len(s.data)
  d := s.data[l-1]
  s.data = s.data[:l-1]
  return d
}

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()

  a := strings.Fields(sc.Text())

  var d []int
  s := &stack{
    data: d,
  }
  for _, v := range a {
    switch v {
    case "+":
      d2 := s.pop()
      d1 := s.pop()
      s.push(d1 + d2)
    case "-":
      d2 := s.pop()
      d1 := s.pop()
      s.push(d1 - d2)
    case "*":
      d2 := s.pop()
      d1 := s.pop()
      s.push(d1 * d2)
    default:
      tmp, _ := strconv.Atoi(v)
      s.push(tmp)
    }
  }
  fmt.Println(s.pop())
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li res = INF;
    string s;
    cin >> s;
    rep(i, sz(s) - 2) {
        li x = stoi(s.substr(i, 3));
        res = min(res, abs(753 - x));
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,ans=0;
  cin>>N;
  for(int i=105;i<=N;i+=2){
    int cnt=0;
    for(int j=1;j<=i;j++)
      if(i%j==0)cnt++;
    if(cnt==8)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3548
import java.util.*;
import java.lang.Math; 

public class Main{
    public static void main(String[] args) {
        long count = 0;
        double quo = 1;
        int quo_max_n = 0;
        Scanner scan = new Scanner(System.in);
        double t = 0;
        t = scan.nextLong();
        
        for(int n=0;;n++){
            if(t < (Math.pow(3,n) - Math.pow(3,n-1) - 2)){
                quo_max_n = n-2;
                break;
            }
        }
        
        count = quo_max_n + 1;
        quo = Math.pow(3,quo_max_n);
        for( double tmp = t - (Math.pow(3,count)-1) / 2; tmp > 0; count++){
            if(tmp >= (quo - 1) * 3 / 2){
                tmp = tmp - quo;
                continue;
            }
            if(tmp < (quo - 1) * 3 / 2){
                quo = quo / 3;
                tmp = tmp - quo;
                continue;
            }
       }
       if(t == 0){
           count = 0;
       }
        System.out.println(count);
        scan.close();
    }
}


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

namespace AtCoder118C
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            List<int> A = new List<int>();
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            for (var i = 0; i < N; i++)
            {
                A.Add(int.Parse(input[i]));
            }
            int count = -1;
            while (count != 1)
            {
                int min = A.Min();
                int index_min = A.IndexOf(min);
                for (var j = 0; j < A.Count; j++)
                {
                if (j == index_min)
                    {
                    continue;
                    } else
                    {
                    A[j]=A[j] % min;
                    }
                }
                while (A.Contains(0))// 0をリストから削除する
                {
                    A.Remove(0);
                }
                count = A.Count;
            }
            //foreach(int member in A)
            //{
            //    Console.Write(member);
            //}
            Console.WriteLine(A.First());
        }
    }
}


Measured memory_bytes: 21472
using System;

public class Program
{
	public static void Main(string[] args)
	{
		string str = Console.ReadLine();
		string strOfq = Console.ReadLine();
		int q = int.Parse(strOfq);

		for (int i = 0; i < q; i++)
		{
			string order = Console.ReadLine();
			string[] orderAB = order.Split(null);
			if (orderAB[0] == "print")
			{
				int a = int.Parse(orderAB[1]);
				int b = int.Parse(orderAB[2]);
				Console.WriteLine(str.Substring(a, b - a + 1));
			}
			else if (orderAB[0] == "reverse")
			{
				int a = int.Parse(orderAB[1]);
				int b = int.Parse(orderAB[2]);
				char[] split = str.ToCharArray();
				char[] chrStr = str.ToCharArray();
				for (int j = 0; j < Math.Abs(a - b) + 1; j++)
				{
					chrStr[a + j] = split[b - j];
				}
				str = new string(chrStr);

			}
			else
			{
				int a = int.Parse(orderAB[1]);
				int b = int.Parse(orderAB[2]);

				char[] split = str.ToCharArray();
				char[] replace = orderAB[3].ToCharArray();

				for (int j = 0; j <=Math.Abs(a-b); j++)
				{
					split[a + j] = replace[j];
				}
				str = new string(split);
			
			}
		}


		//var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????


		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

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

int g[13];

int main() {
    g[2] = 2; g[4] = 1; g[6] = 1; g[9] = 1; g[11] = 1;
    int x, y;
    cin >> x >> y;
    if (g[x] == g[y]) cout << "Yes" << endl;
    else cout << "No" << endl; 
}   

Measured memory_bytes: 256
a,b,c,d=input()
lst_1=[]
lst_2= ["+","-"]
for i in lst_2:
  for j in lst_2:
    for k in lst_2:
      lst_1.append(a+i+b+j+c+k+d)
for l in lst_1:
  if eval(l)==7:
    print(l+"=7")
    break

Measured memory_bytes: 3060
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))


def solve():
    return

def main():
    n = get_int()
    ls = get_list()
    ans = []
    xor = 0
    for val in ls:
        xor ^= val
    for val in ls:
        ans.append(xor^val)
    print(*ans)


TestCases = False

if TestCases:
    for i in range(get_int()):
        main()
else:
    main()


Measured memory_bytes: 31980
#include <bits/stdc++.h>
using namespace std;
struct pos{
	int x,y;
};
double dis(int x1,int y1,int x2,int y2)
{
	return sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 )  );
}
int main()
{
	int i,n;
	cin>>n;
	int d[n];
	double s=0;
	long long tot=0;
	for(i=0;i<n;i++)
	{
		d[i]=i;
	}
	struct pos a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i].x>>a[i].y;
	}
	do{	
		for(i=1;i<n;i++)
		{
			s+=dis(a[d[i]].x,a[d[i]].y,a[d[i-1]].x,a[d[i-1]].y);
		}
		tot++;
	}while(next_permutation(d,d+n));
	printf("%.10f",s/tot);
	return 0;
}


 

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 int v[109],n,i,j,x;

int main()
{


   cin>>n;

   for (int i=1;i<=n;i++)
    {
        cin>>x;

        if (x<=399)
            v[1]++;

            else
         if (x<=799)
            v[2]++;

            else
                 if (x<=1199)
            v[3]++;

            else
             if (x<=1599)
            v[4]++;

            else
             if (x<=1999)
            v[5]++;
            else
                 if (x<=2399)
            v[6]++;
            else
             if (x<=2799)
            v[7]++;
            else
             if (x<=3199)
            v[8]++;
            else
            if (x>=3200)
            v[9]++;

    }

  int mini=0,maxi=0;
   for (int i=1;i<=8;i++)
   {
       if (v[i])
        mini++;
   }
   if (mini==0)
    cout<<1<<" "<<v[9]<<endl;
   else

    cout<<mini<<" "<<mini+v[9]<<endl;




    return 0;
}


Measured memory_bytes: 256
def main():
    n, k = map(int,input().split())
    h = list(map(int,input().split()))

    dp = [-1] * n
    dp[0] = 0
    for i in range(n):
        lmt = min(i+k+1,n)
        for j in range(i+1,lmt):
            tmp = dp[i] + abs(h[i]-h[j])
            if dp[j] == -1 or dp[j] > tmp:
                dp[j] = tmp
    print(dp[n-1])
    
if __name__=='__main__':
    main()


Measured memory_bytes: 52448
#include <cstdio>

void process() {
    int x, y;

    do {
        scanf(" %d %d", &x, &y);
        if( x == 0 && y == 0 ) return;

        if( x < y ) printf("%d %d\n", x, y);
        else printf("%d %d\n", y, x);
    } while( true );
}

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



Measured memory_bytes: 2568
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define mod 1000000007

lli maxProfit(lli weight[], lli price[], lli c, lli n){
	
	lli dp[n + 1][c + 1], i, j;
	for(i = 0; i <= n; i++) dp[i][0] = 0;
	for(j = 0; j <= c; j++) dp[0][j] = 0;

	for(i = 1; i <= n; i++){
		for(j = 1; j <= c; j++){
			lli op1 = INT_MIN, op2 = INT_MIN;
			op1 = dp[i - 1][j];
			if(j - weight[i] >= 0)
			op2 = price[i] + dp[i - 1][j - weight[i]];
			dp[i][j] = max(op1, op2);
		}
	}
	return dp[n][c];

}


void solve(){
	lli n, c;
	cin >> n >> c;
	lli i, weight[n + 1], price[n + 1];
	for(i = 1; i <= n; i++){
		cin >> weight[i] >> price[i];
	}
	cout << maxProfit(weight, price, c, n);
}

int main(){
	solve();
}

Measured memory_bytes: 79104
#include<stdio.h>

void swap(int A[],int a,int b){
int temp;

temp=A[a];
A[a]=A[b];
A[b]=temp;

return;
}





void bubblesort(int A[],int n){
 int i,j;

 for(i=0;i<4;i++){
  for(j=1;j<5-i;j++){
     if(A[j]>A[j-1])swap(A,j,j-1);
  }
 }

return;
}




int main(){
 int n,i;
 int A[5];

 for(i=0;i<5;i++)scanf("%d",&A[i]);

 bubblesort(A,5);

 for(i=0;i<4;i++)printf("%d ",A[i]);

 printf("%d\n",A[4]);

 return 0;
}


Measured memory_bytes: 2048
$|=1;
sub input {
  chomp (my ($n, $m) = split / /, readline ARGV);
  ($n, $m);
}

sub main {
  my ($n, $m) = @_;
  my $t = 0;
  my $p = (1/2) ** $m;
  my $q = 1 - $p;
  my $ans = $p * (($n - $m) * 100 + 1900 * $m);
  for my $i (2 .. 1000) {
    $ans += $i * $q ** ($i - 1) * $p * (($n - $m) * 100 + 1900 * $m);
  }
  print int($ans + .5), "\n";
}

main(input());

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  i64 a, b, x;
  cin >> a >> b >> x;
  if(a > 0) cout << (b / x) - ((a - 1) / x) << endl;
  else cout << b / x + 1 << endl;
}


Measured memory_bytes: 256
words = gets.chomp.split('').to_a
odd_words = words.select.with_index { |_, i| i.even? }
even_words = words.select.with_index { |_, i| i.odd? }

if odd_words.include?("L")
  puts "No"
elsif even_words.include?("R")
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 1788
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        c: [usize; 5],
        k: usize
    };

    let mut flag = false;

    for i in 0..4 {
        for j in i..5 {
            let x = c[j] - c[i];
            if x > k {
                flag = true;
                break;
            }
        }
    }

    if flag {
        println!(":(")
    } else {
        println!("Yay!")
    }
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
    #define int long long
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int l=0,r=1000000000;
    while(r-l>1){
        long long cut=0;
        int mid=(l+r)/2;
        for(int i=0;i<n;i++)cut+=(a[i]-1)/mid;
        if(cut<=k)r=mid;
        else l=mid;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 5176
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  vector<string> cards(3);
  cin >> cards[0] >> cards[1] >> cards[2];
  vector<int> positions(3, 0);
  int player = 0;
  while (true) {

    if (player == 0) {
      if (positions[0] >= cards[0].size()) break;
      else player = cards[0][positions[0]] - 'a';
      positions[0]++;
    } else if (player == 1) {
      if (positions[1] >= cards[1].size()) break;
      else player = cards[1][positions[1]] - 'a';
      positions[1]++;
    } else if (player == 2) {
      if (positions[2] >= cards[2].size()) break;
      else player = cards[2][positions[2]] - 'a';
      positions[2]++;
    }
    // cerr(player << " ");

    // if (cards[player].size() == positions[player]) {
    //   cout << (char)('A' + player) << endl;
    //   return;
    // }
    // player = cards[player][positions[player]] - 'a';
    // positions[player]++;
  }
  cout << (char) ('A' + player) << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,a,b; 
    cin>>n>>a>>b; 
    int c=n/(a+b),ans=0,rem=n%(a+b);
    if (rem) {
        if (rem>a) ans=a;
        else ans=rem;
    }
    ans += c*a;
    cout << ans << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3592
from itertools import accumulate
n,m = [int(a) for a in input().strip().split(' ')]
As = accumulate([int(a)%m for a in input().strip().split(' ')])
As = [0] + [i%m for i in As]
As = sorted(As)
count = 0
ba = None
Bs = []
for a in As:
    if a == ba:
        count += 1
    elif ba != None:
        Bs.append(count*(count+1))
        count = 0
    ba = a
if count != 0:
    Bs.append(count*(count+1))
print(int(sum(Bs)/2))


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

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 200000 + 50;
const int INF = 1 << 30;
int vis[MAXN];
int main(){
    int n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        if(x==1){
            vis[y]++;
        }else if(y==1){
            vis[x]++;
        }
        if(x==n){
            vis[y]++;
        }else if(y==n){
            vis[x]++;
        }

    }
    for (int i = 1; i <=n; ++i)
    {
        if(vis[i]>=2){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define int             long long
const int N = 2e5 + 5, mod = 1e9+7;
int a[N],n,sum,ans;
int32_t main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }

    for(int i=0;i<n-1;i++){
        sum=(sum+mod-a[i])%mod;
        ans = ans + (sum*a[i])%mod;
        ans%=mod;
    }

    cout<<ans;
}


Measured memory_bytes: 5128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define ll long long int
using namespace std;

int main(void){
    ll N,M,ans=0;
    cin >> N >> M;

    if(N > M) swap(N,M);
    if(N == 1 && M == 1) ans = 1;
    else if(N == 1 && M != 1) ans = M-2;
    else if(N >= 2 && M >= 2) ans = (N-2)*(M-2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
#define PI 3.14159265
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {
  // x1, x2を座標圧縮し、座標圧縮した際の幅を返す 
  int r;
  cin >> r;
  cout << r * r << endl;

  return 0;
}

Measured memory_bytes: 888
N, x = map(int, input().split())
a = [int(i) for i in input().split()]

count = 0
for i in range(N-1):
    tmp = a[i] + a[i+1]
    if tmp > x:
        count += tmp - x
        a[i+1] = x - a[i]
        if a[i+1] < 0:
            a[i] -= -1 * a[i+1]
            a[i+1] = 0
print(count)

Measured memory_bytes: 14540
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define pll pair<ll,ll>
#define inf 1000000000000000000
using namespace std;

int n;
string s;

ll dp[3001][3001], cumulative[3001][3001];

ll fun(int pos, int ele){
	if(pos == n - 1){
		if(ele != 1){
			return 0;
		}
		return 1;
	}
	if(ele <= 0 || ele > n - pos){
		return 0;
	}
	if(dp[pos][ele] != -1){
		return dp[pos][ele];
	}
	if(ele == 1){
		if(s[pos] == '<'){
			dp[pos][ele] = cumulative[pos + 1][n - (pos + 1)];
		}
		else{
			dp[pos][ele] = 0;
		}
	}
	else if(ele == n - pos){
		if(s[pos] == '<'){
			dp[pos][ele] = 0;
		}
		else{
			dp[pos][ele] = cumulative[pos + 1][n - (pos + 1)];
		}
	}
	else{
		if(s[pos] == '<'){
			dp[pos][ele] = cumulative[pos + 1][n - (pos + 1)] - cumulative[pos + 1][ele - 1];
		}
		else{
			dp[pos][ele] = cumulative[pos + 1][ele - 1];
		}
	}
	dp[pos][ele] %= mod;
	dp[pos][ele] += mod;
	dp[pos][ele] %= mod;

	return dp[pos][ele];
}

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

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

	for(int i = n - 1; i >= 0; i--){
		for(int j = 1; j <= n - i; j++){
			dp[i][j] = fun(i, j);
			cumulative[i][j] = cumulative[i][j - 1] + dp[i][j];
			cumulative[i][j] %= mod;
		}
	}
	cout<<cumulative[0][n]<<endl;
	return 0;
}

Measured memory_bytes: 140928
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=0; i<(int)(n-1); ++i)
#define lp3(j, n)  for(int j=1; j<=(int)(n); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main(){

int a,b,c;
cin>>a>>b>>c;
 if(a+b+c>=22)
    cout<<"bust";
 else
    cout<<"win";


go;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int n;
    vector<string>s;
    cin>>n;
    s.resize(n);
    REP(i,0,n){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    map<string, int>SS;
    for(int i=0;i<n;i++){
        SS[s[i]]++;
    }
    int ans=0;
    for(auto g:SS){
        int ct=g.S;
        ans=ans+ct*(ct-1)/2;
    }
    cout<<ans<<"\n";



    return 0;
}

Measured memory_bytes: 16640
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		if(n == 22){
			System.out.println("Christmas Eve Eve Eve");
		}
		if(n == 23){
			System.out.println("Christmas Eve Eve");
		}
		if(n == 24){
			System.out.println("Christmas Eve");
		}
		if(n == 25){
			System.out.println("Christmas");
		}
		
		//System.out.println(ans);
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string ans = "";
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	rep(i,sx,tx){
		ans += "R";
	}
	rep(i,sy,ty){
		ans += "U";
	}
	rep(i,sx,tx){
		ans += "L";
	}
	rep(i,sy,ty){
		ans += "D";
	}
	ans += "D";
	rep(i,sx,tx+1){
		ans += "R";
	}
	rep(i,sy,ty+1){
		ans += "U";
	}
	ans += "L";
	ans += "U";
	rep(i,sx,tx+1){
		ans += "L";
	}
	rep(i,sy,ty+1){
		ans += "D";
	}
	ans += "R";
	cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio, std.container;

enum T {start = 0, end};

struct User {
  int weight;
  long time;
  T type;
  long opCmp(ref User u) {
    if (this.time == u.time) return  this.type - u.type;
    return this.time - u.time;
  }
}

void main() {
  for(int t; readf("%d\n", &t), t != 0;) {
    User[] users;
    foreach(i; 0..t) {
      int weight;
      long s_time, e_time;
      readf("%d %d %d\n", &weight, &s_time, &e_time);
      users ~= User(weight, -s_time, T.start);
      users ~= User(weight, -e_time, T.end);
    }
    auto h = heapify(users);
    bool ans = true;
    int curr = 0;
    while(!h.empty) {
      User u = h.front;
      switch(u.type) {
      case T.start:
        curr += u.weight;
        if (curr > 150) {ans = false; break;}
        break;
      case T.end:
        curr -= u.weight;
        break;
      default:
        break;
      }
      h.removeFront;
    }
    writeln(ans ? "OK" : "NG");
  }
}

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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

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

    int maxv = a[n-1];

    int x = maxv/2;

    int b = -1, c = 0;
    for(int i = 0; i < n-1; i++) {
        if(a[i] >= x){
            b = a[i];
            c = a[i-1];
            break;
        }
    }

    if(b != -1){
        int up = b - x;
        int down = x - c;
        if( up > down ){
            cout << maxv << " " << c;
        }
        else{
            cout << maxv << " " << b;
        }
    }
    else{
        cout << maxv << " " << a[n-2];
    }

    return 0;

}






Measured memory_bytes: 640
from collections import Counter

def factorials(n,m):
    # 0~n!のリスト
    f = [1,1]
    for i in range(2,n+1):
        f.append(f[-1]*i%m)

    # 0~n!の逆元のリスト
    g = [1]
    for i in range(n):
        g.append(pow(f[i+1],m-2,m))

    return f,g


n = int(input())
a = list(map(int, input().split()))

m = 10**9+7

f,g = factorials(n,m)

counter = Counter(a)

for x in a:
    if counter[x] == 2:
        b = x
        break

l,r = [i for i, x in enumerate(a) if x == b]

if r-l == 1:
    renzoku = True
else:
    renzoku = False

if n == 1:
    print(1)
    print(1)
    exit()

if renzoku:
    print(n)
    for k in range(2,n):
        x = f[n-1]*g[n-k-1]*g[k]
        y = f[n-1]*g[n-k]*g[k-1]
        z = f[n-1]*g[n-k+1]*g[k-2]
        print((x+y+z)%m)
    print(n)
    print(1)
else:
    print(n)
    for k in range(2,n):
        x = f[n-1]*g[n-k-1]*g[k]
        y = f[n-1]*g[n-k]*g[k-1] * 2
        z = f[n-1]*g[n-k+1]*g[k-2]
        if n-r + l >=k-1:
            y -= f[n-r+l]*g[n-r+l-k+1]*g[k-1]
        print((x+y+z)%m)
    print(n+1)
    print(1)



Measured memory_bytes: 66796
a,b,c,d=map(int,input().split())
ans=[0 for j in range(101)]
for i in range(a,b):
  ans[i]+=1
for j in range(c,d):
  ans[j]+=1
cnt=0
for k in range(101):
  if ans[k]==2:
    cnt+=1
print(cnt)

Measured memory_bytes: 3064
a, b, c, d = map(int, input().split())
if a<=c and d<=b:
    print(d-c)
elif c<=a and b<=d:
    print(b-a)
elif c<=a and a<=d<=b:
    print(d-a)
elif a<=c<=b and b<=d:
    print(b-c)
else:
    print(0)

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

int main(){
  int a[4];
  int m,mx=0,sum=0;
  rep(i,5){
    cin>>a[i];
    if(a[i]%10==0)m=0;
	else m = 10-a[i]%10;
    mx = max(mx,m);
    sum += a[i]+m;
  }
	cout<<sum-mx;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int a,b,c;
    cin >>a>>b>>c;
 
    if(a<=c&&b>=c){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int x,y,z; 
    cin>>x>>y>>z;
    x-=y+2*z;
    cout<<1+x/(y+z)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define abs(x) ((x)<0 ? -(x) : (x))

int main(){
  int n;  scanf("%d", &n);
  int plan[100005] = {0};
  long sum = 0;
  for(int i=1; i<=n; i++){
    scanf("%d", plan+i);
    sum = sum + (long)abs(plan[i] - plan[i-1]);
  }
  sum = sum + (long)abs(plan[n+1] - plan[n]);

  for(int i=1; i<=n; i++){
    long ans = sum - abs(plan[i]-plan[i-1]) - abs(plan[i+1]-plan[i]) + abs(plan[i+1]-plan[i-1]);
    printf("%ld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    
    std::cin >> a >> b;
    
    if(a > b) {
        std::cout << a-1 << std::endl;
    }
    else{
        std::cout << a << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
from itertools import accumulate as acc
import operator as op
import copy as cp
import math 

n=ri()
s=input()
cnt=n
if n==1:
  print(1)
  
else:
  for i in range(n-1):
    if s[i]==s[i+1]:
      cnt-=1
  print(cnt)


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 2e9 + 9;
const ll LINF = 1e18;
using namespace std;

int main(){
	int n, x,d;
	int ans = 0;
	cin >> n >> d >> x;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	for (int i = 0; i < n; i++) {
		b.at(i) =( d -1)/ (a.at(i)) + 1;
	}
	for (int i = 0; i < n; i++) {
		ans += b.at(i);
	}

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


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
	int A;
	int B;
	cin>>A;
	cin>>B;
	if(13>=A>=1&&13>=B>=1){
	if((A>B||A==1)&&B!=1)
		cout<<"Alice";
		else if(B>A||B==1&&A!=1)
		cout<<"Bob";
		else if(A==B)
		cout<<"Draw";
			}
			else
			cout<<"wrong input";
		return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

    int a, b, add, sub, mul, max;
    scanf("%d %d", &a, &b);

    add = a + b;
    sub = a - b;
    mul = a * b;
    max = add;
    if (add < sub) max = sub;
    if (max < mul) max = mul;
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int w=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    sc.close();
    int d=0;
    if(Math.abs(a-b)>w){
      d=Math.abs(a-b)-w;
    }
    System.out.println(d);
  }
}

Measured memory_bytes: 23764
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        ulong result = 0;
        var march = new ulong[]{ 0, 0, 0, 0, 0 };
        var num1 = new[] { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
        var num2 = new[] { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
        var num3 = new[] { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };
        for (var i = 0; i < num; i++)
        {
            var n = ReadLine();
            var initial = n.Substring(0, 1);
            if (initial == "M") march[0]++;
            if (initial == "A") march[1]++;
            if (initial == "R") march[2]++;
            if (initial == "C") march[3]++;
            if (initial == "H") march[4]++;
        }
        for(var i = 0; i < Combination(5, 3); i++)
        {
            result += march[num1[i]] * march[num2[i]] * march[num3[i]];
        }
        WriteLine(result);
    }
    
    private static int Combination(int num1,int num2)
    {
        var p1 = num1;
        var p2 = num2;
        for(var i = 1; i < num2; i++)
        {
            p1 *= num1 - i;
            p2 *= num2 - i;
        }
        return p1 / p2;
    }
}


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

int main()
{
    int n, d;

    cin >> n;

    unsigned long long int sum = 0;
    for( int i = 0; i < n; i++ )
    {
        cin >> d;
        sum += d;
    }

    if( sum == 0 || n == 0 )
        cout << 0 << endl;
    else
        cout << sum / n << endl;

    return 0;
}


Measured memory_bytes: 2984
use std::io::*;
use std::str::FromStr;
use std::num::*;
use std::vec::*;
use std::option::*;

fn main() {
    let mut n: i64 = read();
    let mut a: i64 = read();
    let mut b: i64 = read();
    let mut c: i64 = read();
    let mut d: i64 = read();
    let mut e: i64 = read();
    let mut x:Vec<i64> = [a,b,c,d,e].to_vec();
    let mut min: i64 = *x.iter().min().unwrap();
    let ans: i64 = ((n+(min-1))/min) + 4;
    println!("{}", ans);
}
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

Measured memory_bytes: 4352
N=int(input())
count = 0
point = 0
runner = 0
out = 0
while 1:
    n = input()
    if n=="HIT":
        runner +=1
        if runner==4:
            point +=1
            runner -=1
    elif n=="OUT":
        out +=1
        if out==3:
            count +=1
            print(point)
            point = runner = out = 0
            if count == N:break
    elif n=="HOMERUN":
        runner +=1
        point +=runner
        runner = 0


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
int c[5][5];
int main()
{
	for(int i=0; i<3; i++) for(int j=0; j<3; j++) cin >> c[i][j];
	int ok=1;
	for(int i=1; i<3; i++)
	{
		if(c[i][1]-c[i][0] == c[i-1][1]-c[i-1][0] && c[i][2]-c[i][0] == c[i-1][2]-c[i-1][0]
		&& c[i][2]-c[i][1] == c[i-1][2]-c[i-1][1]);
		else ok=0;
		if(c[1][i]-c[0][i] == c[1][i-1]-c[0][i-1] && c[2][i]-c[0][i] == c[2][i-1]-c[0][i-1]
		&& c[2][i]-c[1][i] == c[2][i-1]-c[1][i-1]);
		else ok=0;
	}
	cout << (ok?"Yes":"No");
	return 0;
}


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

int main() {
  int N,sumA,sumB;
  cin>>N;
  sumA=0;
  sumB=0;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    if(i%2==0){
      sumA+=vec.at(i);
    }
    else{
      sumB+=vec.at(i);
    }
  }
  cout<<sumA-sumB<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n,k,ans=1;
	scanf("%d %d",&n,&k);
	rep(i,n){
		if(i==0)
			ans *=k;
		else
			ans *= k-1;
	}
	    
	    
	
	printf("%d",ans);
	return 0;
}

	


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


using namespace std;

int main()
{
    string s;
    ll t, n, m, sum = 0 ;
    cin>>n;
    sum = pow(n, 1) + pow(n, 2) + pow(n, 3);
    cout<<sum<<"\n";
    return 0;
}


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

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

int mod = 1000000007;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    UnionFind uf(N);
    int A[N]; rep(i, N) cin >> A[i];
    rep(i, M){
        int x, y; cin >> x >> y;
        uf.merge(x-1, y-1);
    }
    int pos[N];
    rep(i, N){
        pos[A[i]-1] = i;
    }
    int ans = 0;
    rep(i, N){
        if(uf.issame(A[i]-1, pos[A[i]-1])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

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

Measured memory_bytes: 256