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

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

using T = double;
int n;
T x[110], y[110], z[110];
T sq(T x) { return x * x; }
T ssq(T a, T b, T c) { return sq(a) + sq(b) + sq(c); }

pair<int, T> far(T px, T py, T pz) {
	int r = -1;
	T f = -1;
	for (int i = 1; i <= n; i++) {
		T dis = ssq(px - x[i], py - y[i], pz - z[i]);
		if (f < dis) f = dis, r = i;
	}
	return { r, f };
}

int main() {
	while (scanf("%d", &n) == 1 && n) {
		for (int i = 1; i <= n; i++) scanf("%lf%lf%lf", x + i, y + i, z + i);
		auto g = [](T l, T r) {
			return l + (r - l) * (T)0.5;
		};
		T ans = 1e9;
		rep(a, 1) {
			T px = g(*min_element(x + 1, x + 1 + n), *max_element(x + 1, x + 1 + n));
			T py = g(*min_element(y + 1, y + 1 + n), *max_element(y + 1, y + 1 + n));
			T pz = g(*min_element(z + 1, z + 1 + n), *max_element(z + 1, z + 1 + n));
			T d = far(px, py, pz).Se * 0.1;
			rep(t, 100000) {
				int i; T r;
				tie(i, r) = far(px, py, pz);
				T vx = x[i] - px, vy = y[i] - py, vz = z[i] - pz;
				T lp = d / sqrt(r);
				px += vx * lp; py += vy * lp; pz += vz * lp;
				d = d * 0.9995;
			}
			ans = min(ans, sqrt(far(px, py, pz).Se));
		}
		printf("%.5lf\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
int cnt = 1;
int n;
int A[200000];
int32_t main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	int ans = n;
	for(int i = 0; i < n; i++){
		if(A[i] == cnt){
			cnt++;
			ans--;
		}
	}
	if(ans == n){
		cout << -1;
	}else{
		cout << ans;
	}
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
string s;
int ans = 0;
/**********************************************/

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

    cin >> s;
    int t_num = 0, s_num = 0;
    REP(i, s.size()){
        if(s[i] == 'T'){
            if(s_num > 0) s_num--;
            else t_num++;
        }else{
            s_num++;
        }
    }
    cout << s_num + t_num << endl;
}


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




int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);


    int a,b,s;
    cin>>a>>b;
    
    s = a+b;
    if(s==3) cout<<"3\n";
    else if(s==4) cout<<"2\n";
    else cout<<"1\n";
    

    return 0;
}


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

int main(){
  long long int N,M;
  cin>>N>>M;
  
  priority_queue<long long int> pq;
  
  for(int i=0; i<N; i++){
    long long int a;
    cin>>a;
    pq.push(a);
  }
  
  for(int i=0; i<M; i++){
    long long int tmp= pq.top()/2;
    pq.pop();
    pq.push(tmp);
  }
  
  long long int ws=0; 
  while(!pq.empty()){
    ws +=pq.top(); 
    pq.pop();
  }
  
  cout<<ws<<endl;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <cstdio>
int a[15][15],f[1<<15][15],g[1<<15];
int main(){
	int n,m,sum=0;
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=m;i++){
		int x,y,z;
		scanf("%d%d%d\n",&x,&y,&z);
		x--;y--;sum+=z;
		a[x][y]=a[y][x]=z;
	}
	int L=1<<n;
	for (int i=0;i<L;i++){
		for (int j=0;j<n;j++) f[i][j]=-1e9;
		for (int j=0;j<n;j++)
		if ((i>>j)&1){
			g[i]=g[1<<j^i];
			for (int k=j+1;k<n;k++)
				if ((i>>k)&1) g[i]+=a[j][k];
			break;
		}
	}
	f[1][0]=0;
	for (int i=1;i<L;i++)
		for (int j=0;j<n;j++)
		if ((i>>j)&1){
			int x=1<<j^i;
			for (int k=0;k<n;k++)
				if ((i>>k)&1 && a[k][j]) f[i][j]=std::max(f[i][j],f[x][k]+a[k][j]);
			for (int k=x;k;k=(k-1)&x)
				f[i][j]=std::max(f[i][j],f[i^k][j]+g[1<<j^k]);
		}
	printf("%d\n",sum-f[L-1][n-1]);
}

Measured memory_bytes: 2304
import sys
input = sys.stdin.readline


class Solution:
    def main(self):
        n = int(input())
        a = list(map(int, input().split()))

        a.sort()

        ans = 1
        for v in a:
            ans *= v;
            if ans > 10 ** 18:
                print(-1)
                return
        print(ans)

# Run main
if __name__ == '__main__':
    Solution().main()

Measured memory_bytes: 21644
#include <stdio.h>

#define NUM_OF_CITY	( 6 )

#define A_CITY	(  0 )
#define B_CITY	(  1 )
#define X_CITY	(  2 )
#define Y_CITY	(  3 )
#define Z_CITY	(  4 )
#define W_CITY	(  5 )

#define DESERT	(  6 )

int nowCity;
int nextCity[ NUM_OF_CITY + 1 ][2];
int getNextCity( char road );
void setNextCity( void );

int main( void )
{
	char road;
	int result;
	
	
	setNextCity();
	
	while( 1 )
	{
		nowCity = A_CITY;
		scanf( "%c", &road );
		if( road == '#' )
		{
			break;
		}
		else
		{
			while( 1 )
			{
				if( road != '\n' )
				{
					nowCity = getNextCity( road  - '0' );
				}
				else
				{
					if( nowCity == B_CITY )
					{
						printf( "Yes\n" );
					}
					else
					{
						printf( "No\n" );
					}
					break;
				}
				scanf( "%c", &road );
			}
		}
	}
	
	return (0);
}

int getNextCity( char road )
{
	return ( nextCity[ nowCity ][ road ] );
}

void setNextCity( void )
{
	nextCity[ A_CITY ][ 0 ] = X_CITY;
	
	nextCity[ A_CITY ][ 1 ] = Y_CITY;
	
	nextCity[ B_CITY ][ 0 ] = Y_CITY;
	
	nextCity[ B_CITY ][ 1 ] = X_CITY;
	
	nextCity[ X_CITY ][ 0 ] = DESERT;
	
	nextCity[ X_CITY ][ 1 ] = Z_CITY;
	
	nextCity[ Y_CITY ][ 0 ] = X_CITY;
	
	nextCity[ Y_CITY ][ 1 ] = DESERT;
	
	nextCity[ Z_CITY ][ 0 ] = W_CITY;
	
	nextCity[ Z_CITY ][ 1 ] = B_CITY;
	
	nextCity[ W_CITY ][ 0 ] = B_CITY;
	
	nextCity[ W_CITY ][ 1 ] = Y_CITY;
	
	nextCity[ DESERT ][ 0 ] = DESERT;
	
	nextCity[ DESERT ][ 1 ] = DESERT;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;

ll cumSum[200100];
int main(void) {
    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        ll r;
        cin >> r;
        sum += r;
        cumSum[i] = sum;
    }

    ll minDiff = 2100000000;
    for (int i = 0; i < N - 1; i++) {
        ll d = abs(sum - 2 * cumSum[i]);
        minDiff = min(minDiff, d);
    }

    cout << minDiff << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


class Main {

    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static boolean isPalindrome(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }*/
    public static void main(String[] args)
        {
            Scanner sc=new Scanner(System.in);



           int n=sc.nextInt();
           int x=sc.nextInt();
           if((n*500)>=x)
               System.out.println("Yes");
           else
               System.out.println("No");
        }
    }



Measured memory_bytes: 21840
from itertools import permutations

n, m = map(int, input().split())
L = [set() for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    L[a-1].add(b-1)
    L[b-1].add(a-1)
lst = [i for i in range(1, n)]
ans = 0
for v in permutations(lst, n-1):
    case = [0] + list(v)
    for i in range(n-1):
        next = case[i+1]
        if next not in L[case[i]]:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 9164
from itertools import permutations

N,M = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(M)]

graph = [[False]*(N+1) for _ in range(N+1)]

for i,j in l:
    graph[i][j] = True
    graph[j][i] = True

pattern = permutations(range(1,N+1))

cnt = 0
for i in pattern:
    flag = True
    if i[0] != 1:
        continue
    for j in range(N-1):
        if graph[i[j]][i[j+1]] == False:
            flag = False
            break
    
    if flag:
        cnt += 1

print(cnt)


Measured memory_bytes: 9224
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cout << #x << ": " << x << endl
#define ALL(x) (x).begin(),(x).end()
 
const int INF = 1e9;
const ll LINF = 1e16;
 
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
 
    int H;
    int c = 0;
    while (1) {
        cin >> H;
        if (H == 0) break;
        vector<vector<int>> yama(H + 2, vector<int>(7, INF));
        for (int i = H; i >= 1; i--) {
            for (int j = 1; j <= 5; j++) {
                cin >> yama[i][j];
            }
        }
        //cout << "hello" << endl;
        int ret = 0;
        bool f = false;
        do {
 
            f = false;
            for (int i = 1; i <= H; i++) {
                int count = 0;
                int n = -1;
                for (int j = 1; j <= 6; j++) {
                    if (yama[i][j] != n) {
                        if (count >= 3) {
                            if (n != INF) {
                                ret += (count*n);
                                f = true;
                                for (int k = j - count; k < j; k++) {
                                    yama[i][k] = INF;
                                }
                            }
                            break;
                        }
                        count = 1;
                        n = yama[i][j];
                    }
                    else {
                        count++;
                    }
                }
            }
         
 
            for (int i = 1; i <= H; i++) {
                for (int j = 1; j <= 5; j++) {
                    if (yama[i][j] == INF) {
                        for (int k = i + 1; k <= H; k++) {
                            if (yama[k][j] != INF) {
                                yama[i][j] = yama[k][j];
                                yama[k][j] = INF;
                                break;
                            }
                        }
                    }
                }
            }
 
        } while (f);
        cout << ret << endl;
        c++;
    }
 
    return 0;
}

Measured memory_bytes: 3116
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define G() Cr=getchar()
int Xr;char Cr;
inline int  rd(){
	Xr=0;G();
	while(Cr<'0'||Cr>'9')G();
	while(Cr>='0'&&Cr<='9')Xr=(Xr<<1)+(Xr<<3)+Cr-'0',G();
	return Xr;
}
int n,Ma,Mb,ans=99999999;
int dp[405][405];
int a[100],b[100],c[100];
int suma[100],sumb[100];
int main(){
	n=rd(),Ma=rd(),Mb=rd();
	for(int i=1;i<=n;i++)
		a[i]=rd(),b[i]=rd(),c[i]=rd(),suma[i]=suma[i-1]+a[i],sumb[i]=sumb[i-1]+b[i];
	
	for(int i=0;i<=suma[n];i++)
		for(int j=0;j<=sumb[n];j++)
			dp[i][j]=99999999;
	dp[0][0]=0;	
	
	for(int k=1;k<=n;k++)
		for(int i=suma[k];i>=a[k];i--)
			for(int j=sumb[k];j>=b[k];j--)
				dp[i][j]=min(dp[i][j],dp[i-a[k]][j-b[k]]+c[k]);		
	
	int aa=Ma,bb=Mb;
	while(Ma<=suma[n]&&Mb<=sumb[n]){
		ans=min(ans,dp[Ma][Mb]);
		Ma+=aa,Mb+=bb;
	}
	
	printf("%d\n", (ans==99999999)?-1:ans );		
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
int A,B;
if(a>b) A=b;
else A=a;
if(c>d) B=d;
else B=c;
cout<<A+B<<endl;
return 0;
}

Measured memory_bytes: 256
import math
a, b = map(str, input().split())

A = int(a+b)
N = int(math.sqrt(A)) + 3

#print (N)
flag = False
for i in range(1,N):
    if A //i == i and A%i == 0:
        flag = True

if flag:
    print ('Yes')
else:
    print ('No')

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

vector<pair<char, int>> RLE(const string &S) {
    vector<pair<char, int>> res;
    int N = (int)S.size();
    for(int i = 0; i < N; ++i) {
        int j = i;
        while(j < N && S[i] == S[j]) j++;
        res.push_back(make_pair(S[i], j - i));
        i = j - 1;
    }
    return res;
}

void solve() {
    int N;
    string S;
    cin >> N >> S;
    auto A = RLE(S);
    cout << A.size() << '\n';
}

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


Measured memory_bytes: 1480
#include <stdio.h>

using namespace std;


int main(){
	int a,b,count,s;

	while(scanf("%d %d",&a,&b)!=EOF){
		count=0;
		s=a+b;
		while(s!=0){
			s/=10;
			count++;
		}
		printf("%d\n",count);
	}

    return 0;
}


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

using namespace std;

const int N = 200020;

int a[N], L[N], R[N];
long long sum[N];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	//cut L[i], L[i] + 1
	int nowl = 1;
	for(int i = 2; i < n; i++)
	{
		while(nowl < i - 1 && abs(sum[i] - sum[nowl + 1] - sum[nowl + 1]) < abs(sum[i] - sum[nowl] - sum[nowl]))nowl++;
		L[i] = nowl;
	}
	//cut R[i], R[i] - 1
	int nowr = n;
	for(int i = n - 1; i > 1; i--)
	{
		while(nowr > i + 1 && abs(sum[n] - sum[nowr - 2] - (sum[nowr - 2] - sum[i - 1])) < abs(sum[n] - sum[nowr - 1] - (sum[nowr - 1] - sum[i - 1])))nowr--;
		R[i] = nowr;
	}
	//cut i, i + 1
	long long ans = 0x3f3f3f3f3f3f3f3fll;
	for(int i = 2; i < n - 1; i++)
	{
		long long a = sum[i] - sum[L[i]], b = sum[L[i]], c = sum[n] - sum[R[i + 1] - 1], d = sum[R[i + 1] - 1] - sum[i];
		ans = min(ans, 0ll + max(max(a, b), max(c, d)) - min(min(a, b), min(c, d)));
	}
	printf("%lld\n", ans);
}

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


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


int main(){
long long  H,W;
cin>>H>>W;
if(H%3==0 || W%3==0){
    cout<<"0"<<endl;
    return 0;
}
long long ans=10000000000;

for(long long  i=1;i<H;i++){
    long long squ=H*W;
    long long M=i*W;
    squ-=M;
    long long m;
    if(squ%2==0){
        m=squ/2;
    }
    else{
        m=(H-i)*(W/2);
        if(m>M){
            m=(W-i)*(H/2+1);
        }
    }
    
    ans=min(ans,abs(M-m));
}

for(long long  i=1;i<W;i++){
    long long squ=H*W;
    long long M=i*H;
    squ-=M;
    long long m;
    if(squ%2==0){
        m=squ/2;
    }
    else{
        m=(W-i)*(H/2);
        if(m>M){
            m=(W-i)*(H/2+1);
        }
    }
    ans=min(ans,abs(M-m));
}
cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ABC064 =
    let private RGBCards () = 
        ReadListOf int 3
        |> Seq.fold (fun r c -> r * 10 + c) 0
        |> (fun c -> if c % 4 = 0 then "YES" else "NO")
        |> printfn "%s"

    let Entry = RGBCards

ABC064.Entry ()

Measured memory_bytes: 14044
package main

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

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var N int
	fmt.Scan(&N)
	dp := make([]int, 20*N)
	sq := 0
	for i := 0; i <= N; i++ {
		if i*i >= N {
			sq = i
			break
		}
	}
	for x := 1; x <= sq; x++ {
		for y := x; y <= sq; y++ {
			for z := y; z <= sq; z++ {
				s := (x + y + z)
				su := (s*s + x*x + y*y + z*z) / 2
				if x == y && y == z {
					dp[su] += 1
				} else if x == y {
					dp[su] += 3
				} else if y == z {
					dp[su] += 3
				} else {
					dp[su] += 6
				}
			}
		}
	}
	for i := 1; i <= N; i++ {
		fmt.Println(dp[i])
	}

}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


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

using namespace std;

void solve() {
    long long X, K, D;
    cin >> X >> K >> D;
    if (X < 0)
    {
        X = -X;
    }

    long long ans;
    if (K <= X/D)
    {
        ans = X - K * D;
    }
    else
    {
        K -= X/D;
        if (K % 2 == 0)
        {
            ans = X % D;
        }
        else
        {
            ans = D - (X%D);
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int a,s;
	int i,n,x;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		s=0;
		for(i=0;i<9;i++){
			scanf("%d",&a);
			s+=a;
		}
		x=n-s;
		printf("%d\n",x);
	}
	return 0;
}
	



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

int main(){
  long long n, a[200005];
  map<long long, long long> mp;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }

  long long ans = 0;
  for(int i=1;i<=n;i++){
    ans += mp[i]*(mp[i]-1)/2;
  }
  // cout << "ans:" << ans << endl;

  for(int i=0;i<n;i++){
    cout << ans-mp[a[i]]+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 17848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int k;
    cin >> k;
    vector<ll> a;
    for(int i=1; i<=9; i++) a.push_back(i);
    while(1){
        if(k<=a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(old,a);
            for(ll x: old){
                for(int i=-1; i<=1; i++){
                    int d= x%10 + i;
                    if(d<0 || d>9) continue;
                    ll nx = x*10 + d;
                    a.push_back(nx);
                }
            }
        }
    }


Measured memory_bytes: 4648
#include <stdio.h>
#include <memory.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
    char s[256], t[256];
    int a, b;
    char u[256];
    scanf("%s %s", s, t);
    scanf("%d %d", &a, &b);
    scanf("%s", u);
    if (strcmp(t,u)){
        a = a - 1;
    }
    else{
        b = b - 1;
    }
    printf("%d %d\n", a, b);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  unsigned long long n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    if(i%15==0){
      continue;
    }
    else if(i%3==0){
      continue;
    }
    else if(i%5==0){
      continue;
    }
    else{
      ans+=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
string s, t;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << E;
    //system("pause");
    return 0;
}

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

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

int main(void){
    int n;
    cin >> n;
    vector<vector<int>> d(n);
    vector<vector<bool>> space(n);
    rep(y,n) {
        d[y] = vector<int>(n);
        space[y] = vector<bool>(n);
    }
    rep(y,n) rep(x,n) {
        d[y][x] = min({y, n-y-1, x, n-x-1});
    }
    ll sum = 0;
    rep(i,n*n) {
        int p;
        cin >> p;
        p--;
        int y = p/n;
        int x = p%n;
        sum += d[y][x];
        space[y][x] = true;
        using P = pair<int,int>;
        queue<P> qu;
        qu.push({y,x});
        while(qu.size()) {
            int cy = qu.front().first;
            int cx = qu.front().second;
            qu.pop();
            int cost = space[cy][cx] ? 0 : 1;
            rep(dir,4){
                int ny = cy + dy[dir];
                int nx = cx + dx[dir];
                if (ny >= n || nx >= n || ny < 0 || nx < 0) continue;
                if (d[ny][nx] > d[cy][cx] + cost) {
                    d[ny][nx] = d[cy][cx] + cost;
                    qu.push({ny, nx});
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4596
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	vector<int> a;
	vector<int> b;
	vector<int> c;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		a.push_back(d);
	}
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		b.push_back(d);
	}
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		c.push_back(d);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	long long int sum = 0;
	for (int i = 0; i < b.size(); i++) {
		auto iterue = lower_bound(a.begin(),a.end(), b[i]);
		auto itersita = upper_bound(c.begin(), c.end(), b[i]);
		long long int k = (iterue - a.begin());
		long long int f = (c.end() - itersita);
		sum = sum + k * f;
	}
	cout << sum;
}

Measured memory_bytes: 1784
N = int(input())
A = list(map(int, input().split()))
M = 0
for i in range(N):
    for j in range(i + 1, N):
        if (max(A[i], A[j]) - min(A[i], A[j])) > M:
            M = (max(A[i], A[j]) - min(A[i], A[j]))
print(M)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	loops(i,a,b+1)
	{
		if (c%i == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3116
#include<cstdio>

int a, b, c;

int main(void){
	scanf("%d %d %d", &a, &b, &c);

	int cnt = 0;
	for( int i = a; i <= b; i++){
		if( c % i == 0) cnt++;
	}

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

Measured memory_bytes: 2728
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    string s;
    cin >> s;
    FOR(i, 0, s.size()){cout << 'x';}
    cout << '\n';
}


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

using namespace std;

#define pb(x) push_back(x)
#define fr(i, n) for(int i=0; i<n; i++)
#define ll long long

int main() {
    ll t, d, s;
    cin>>d>>t>>s;
    if(d%s == 0)
    {
        int x = d/s;
        if(x <= t)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
    {
        int x = d/s;
        if(x < t)
            cout<<"Yes";
        else
            cout<<"No";
    }
	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define TP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define int long long
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

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

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int d[101][101];
bool used[101];

int N, T, F, M, S, G;
int freezer[101];

int memo[101][101];

int dfs(int depth, int from, int t)
{
    if (~memo[depth][from]) return memo[depth][from];

    int mi = inf;

    rep(i, F) {
        int frzr = freezer[i];

        if (used[frzr] || d[from][frzr] > T) continue;

        int cost = d[from][frzr];

        if (d[from][frzr] > t) {
            cost += d[from][frzr] - t;
        }

        if (d[frzr][G] <= T) {
            int now_t = max(t - d[from][frzr], 0ll);
            int heal = max(d[frzr][G] - now_t, 0ll);
            chmin(mi, cost + heal + d[frzr][G]);
        } else {
            used[frzr] = true;

            chmin(mi, cost + dfs(depth + 1, frzr, max(t - d[from][frzr], 0ll)));

            used[frzr] = false;
        }
    }

    return memo[depth][from] = mi;
}

signed main()
{
    int cnt = 0;
    while (cin >> N >> T >> F >> M >> S >> G, N || T || F || M || S || G) {
        memset(memo, -1, sizeof(memo));
        rep(i, F) cin >> freezer[i];

        rep(i, N) rep(j, N) d[i][j] = i == j ? 0 : inf;

        rep(i, M) {
            int x, y, t;
            cin >> x >> y >> t;
            d[x][y] = d[y][x] = t;
        }

        rep(k, N) {
            rep(i, N) {
                rep(j, N) {
                    chmin(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }

        if (d[S][G] <= T) {
            cout << d[S][G] << endl;
        } else {
            int a = dfs(0, S, T);

            if (a == inf) cout << "Help!\n";
            else cout << a << endl;
        }
    }
}

Measured memory_bytes: 1332
n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
sPY = sorted(PY, key=lambda x:(x[0], x[1]))

ans = {}
key, cnt = 1, 1
for p, y in sPY:
    if p != key:
        key = p
        cnt = 1
    ans[y] = cnt
    cnt += 1

for p, y in PY:
    a = str(p).zfill(6)
    b = str(ans[y]).zfill(6)
    print("{}{}".format(a, b))

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

using namespace std;

const int Nmax = 105;
typedef long long ll;

struct
{
    int weight;
    ll cost;
} a[Nmax];

int N,W;

const inline ll Max(ll a, ll b)
{
    return (a > b) ? a : b;
}

int main()
{
    cin >> N >> W;
    for(int i = 1; i <= N; ++i)
        cin >> a[i].weight >> a[i].cost;

    vector<ll> dp(W + 1,0),dp0(W + 1,0);

    for(int i = 1; i <= N; ++i)
    {
        if(a[i].weight > W)
            continue;
        for(int j = a[i].weight; j <= W; ++j)
            dp[j] = Max(dp0[j],dp0[j - a[i].weight] + a[i].cost);
        dp0 = dp;
    }
    cout << dp0[W];
    return 0;
}


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

#define repeat(i, x) for (int64_t i = 0; (i) < (int64_t)(x); (i)++)

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

    int n;
    cin >> n;

    vector<int> a(n);
    repeat (i, n) {
        cin >> a[i];
    }

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

    int best = 0;
    repeat (i, n - 1) {
        if (max(a[i], a[n - 1] - a[i]) < max(a[best], a[n - 1] - a[best])) {
            best = i;
        }
    }

    cout << a[n - 1] << " " << a[best] << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = [9,900,90000]
order = len(str(n))
if order == 1:
    print(n)
elif order == 2:
    print(9)
elif order == 3:
    print(n-100+1 + 9)
elif order == 4:
    print(909)
elif order == 5:
    print(n-10000+1 + 909)
else:
    print(90909)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

/**
 * Prediction and Restriction
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int R = sc.nextInt();
            int S = sc.nextInt();
            int P = sc.nextInt();
            char[] T = sc.next().toCharArray();

            boolean[] win = new boolean[N];
            Arrays.fill(win, 0, K, true);

            for (int i = K; i < N; i++) {
                if (T[i] != T[i - K] || win[i - K] == false) {
                    win[i] = true;
                }
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (win[i]) {
                    if (T[i] == 'r') {
                        ans += P;
                    } else if (T[i] == 's') {
                        ans += R;
                    } else if (T[i] == 'p') {
                        ans += S;
                    }
                }
            }

            System.out.println(ans);
        }
    }

}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

template <int mod>
struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = 1LL * x * p.x % mod; return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        ll a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(ll n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
};
const int mod = 1000000007;
using mint = ModInt<mod>;

int main(){
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    sort(rall(c));

    mint res = 0;
    for (int i = 0; i < n; ++i) {
        res += mint(c[i]) * mint(4).pow(n-1) * mint(i+2);
    }
    cout << res << endl;
}

Measured memory_bytes: 3992
n=int(input())
s=input()
ans=0
for i in range(n-2):
    if s[i]=="R":
        a,b="G","B"
    elif s[i]=="G":
        a,b="B","R"
    else:
        a,b="R","G"
    cnt=[None]*(n-i-1)
    acnt=0
    bcnt=0
    for j in range(i+1,n):
        if s[j]==a:
            acnt+=1
            cnt[j-i-1]=a
        elif s[j]==b:
            bcnt+=1
            cnt[j-i-1]=b
    tmp=acnt*bcnt
    for j in range((n-i-1)//2):
        if cnt[j]==a and cnt[(j+1)*2-1]==b:
            tmp-=1
        elif cnt[j]==b and cnt[(j+1)*2-1]==a:
            tmp-=1
    ans+=tmp
print(ans)

Measured memory_bytes: 74072
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b); }

vector<ll> divisor(ll n){
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0){
      ret.push_back(i);
      if(i!=n/i) ret.push_back(n/i);
    }
  }
  return ret;
}

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

  vector<ll> va = divisor(A);
  vector<ll> vb = divisor(B);
  map<ll,int> m;
  rep(i,va.size()) m[va[i]]++;
  rep(i,vb.size()) m[vb[i]]++;
  vector<ll> v;
  FOR(it,m) if(it->second == 2) v.push_back(it->first);

  int ret = 0;
  rep(i,v.size()){
    if(v[i] != 0){
      ret++;
      REP(j,i+1,v.size()){
        if(v[j] == 0) continue;
        if(gcd(v[i], v[j]) != 1) v[j] = 0;
      }
    }
  }
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
vector<vector<double>> dp(3010,vector<double>(3010,-1));
vector<double> x;
double n,a;

double ans(int curr , int k){
    if(curr == n){
        if(k >= n/2 + 0.5){
            return 1;
        }
        return 0;
    }
    if(dp[curr][k] != -1){
        return dp[curr][k];
    }
    double ret = 0;
    ret += ans(curr+1,k+1)*x[curr];
    ret += ans(curr+1,k) * (1-x[curr]);
    dp[curr][k] = ret;
    return ret;
}

int main()
{
    cin >> n;
    for(int i = 0 ; i < n ; i += 1){
        cin >> a;
        x.push_back(a);
    }
    cout << setprecision(10) << fixed;
    cout << ans(0,0);
}

Measured memory_bytes: 73524
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n,m,vis[100005],cnt;
vector<int>vec[100005];
void dfs(int i)
{
	vis[i]=1;
	forn(j,vec[i].size())
		if(!vis[vec[i][j]])dfs(vec[i][j]);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	forn(i,m)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		vec[x].pb(y);
		vec[y].pb(x);
	}
	forn(i,n)
	{
		if(!vis[i])
		{
			dfs(i);
			cnt++;
		}
	}
	cout<<cnt-1<<endl;
	return 0;
}


Measured memory_bytes: 10012
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void yesno(bool f) { cout << (f ? "Yes" : "No") << endl; }

//

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << H * W - h * W - w * H + h * w << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  double c;
  cin >> c;
  cout << fixed << setprecision(6) << c * c * M_PI << " " << c * 2 * M_PI << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> P, Q;
    int P_num = 0, Q_num = 0;
    for (int i = 0; i < N; i++) {
        int p;cin >> p;
        P.push_back(p);
        P_num = P_num * 10 + p;
    }
    for (int i = 0; i < N; i++) {
        int q;cin >> q;
        Q.push_back(q);
        Q_num = Q_num * 10 + q;
    }
    int cnt = 0;
    if (P_num < Q_num) do{
        bool ok = true;
        for (int i = 0; i < N; i++) if (P[i] != Q[i]) {
           ok = false;
           break;
        }
        if (ok) break;
        cnt++;
    } while (next_permutation(P.begin(), P.end()));
    else do{
        bool ok = true;
        for (int i = 0; i < N; i++) if (P[i] != Q[i]) {
           ok = false;
           break;
        }
        if (ok) break;
        cnt++;
    } while (next_permutation(Q.begin(), Q.end()));
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3572
package main

import(
    "fmt"
)



func main() {
    var n,a int
    fmt.Scan(&n,&a)
    ans := n * n - a
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int[][] X = new int[N][D];
		int ans = 0;
		for(int i = 0; i < N; i++) 
			for(int j = 0; j < D; j++)
				X[i][j] = sc.nextInt();
		for(int i = 0; i < N; i++) {
			for(int j = i+1; j < N; j++) {
				int d = 0;
				for(int k = 0; k < D; k++) {
					d += Math.pow(X[j][k]-X[i][k], 2);
				}
				if(Math.sqrt(d) - (int)Math.sqrt(d) == 0)
					ans++;
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 22356
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {

    int mod ;
    //
    int[][] dp = new int[1001][1001];
    void solve(int n, int k , int[] arr) {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

}


Measured memory_bytes: 36796
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e4+10, M = 1e6+10;

int main() {
	int x;
	cin>>x;
	if(x) cout<<"0";
	else cout<<"1";
	return 0;
} 

Measured memory_bytes: 3620
n, m = [int(_) for _ in input().split()]


def factorial(x):
    ans = 1
    for i in range(2, x+1):
        ans = (ans * i) % (10**9+7)
    return ans


if abs(n-m) == 1:
    print((factorial(n)*factorial(m)) % (10**9+7))
elif n == m:
    print((factorial(n)*factorial(m)*2) % (10**9+7))
else:
    print(0)

Measured memory_bytes: 3064
import sys
fe = ["A","B","C"]
for line in sys.stdin:
	num = line[:-1].split(",")
	if num[0] == "A":
		if num[1] == "B":
			tako = fe[0]
			fe[0] = fe[1]
			fe[1] = tako
		else:
			tako = fe[0]
			fe[0] = fe[2]
			fe[2] = tako

	elif num[0] == "B":
		if num[1] == "A":
			tako = fe[1]
			fe[1] = fe[0]
			fe[0] = tako
		else:
			tako = fe[1]
			fe[1] = fe[2]
			fe[2] = tako

	elif num[0] == "C":
		if num[1] == "A":
			tako = fe[0]
			fe[0] = fe[2]
			fe[2] = tako
		else:
			tako = fe[1]
			fe[1] = fe[2]
			fe[2] = tako
		
if fe.index("A") == 0: print "A"
elif fe.index("A") == 1: print "B"
else:	print "C"

Measured memory_bytes: 6280