akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

class Mod{
    static final int MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {
    public static String longer(String x, String y){
        if(x.length() > y.length()) return x;
        else return y;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        boolean[][] board = new boolean[H][W];
        for(int h=0; h<H; h++){
            String line = sc.next();
            for(int w=0; w<W; w++) board[h][w] = line.charAt(w)=='.';
        }
        long[][] dp = new long[H][W];


        for(int h=0;h<H;h++){
            if(board[h][0]) dp[h][0]=1;
            else break;
        }
        for(int w=0;w<W;w++){
            if(board[0][w]) dp[0][w]=1;
            else break;
        }

        for(int h=1;h<H;h++) for(int w=1;w<W;w++){
            if(board[h][w]) dp[h][w] = Mod.add(dp[h-1][w], dp[h][w-1]);
            else            dp[h][w] = 0;
        }
        System.out.println(dp[H-1][W-1]);



    }
}


Measured memory_bytes: 55488
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
	int c,d,i,j,k,f;
	vector<int> a,b;
	while(cin >> c >> d) {
		if (c+d==0) break;
		a.push_back(c); b.push_back(d);
		}
	k=a.size();
	for (i=0;i<k;i++) {
		if (i>0) cout << endl;
		j=(a[i] % 4 == 0) ? a[i] : (a[i]/4)*4+4;
		f=0; 
		for (j;j<=b[i];j+=4) {
			if (j % 100 ==0 && j % 400!=0) continue;
			cout << j << endl;
			f=1;
		}
		if (f==0) cout << "NA" << endl;
	}
   return 0;
}

Measured memory_bytes: 1216
n, m = gets.split.map(&:to_i)
x = []
x = gets.split.map(&:to_i)
# xを昇順ソート
x = x.sort

if n >= m
  puts 0
  exit
end

# pはxの区間の配列
p = []
# sumは区間pの合計（xの最大-最小）
sum = 0
(m-1).times do |i|
  p[i] = x[i+1] - x[i]
  sum += p[i]
end

# 区間長の上位n-1件を取り出して足す
if n > 1
  maxs = p.max(n-1).inject(:+)
else
  maxs = 0
end
puts sum - maxs


Measured memory_bytes: 10968
/////////////////////////////////TEST CASES////////////////////////////////////
/*
4
C D C D
C C D C
D D D D
C D D D
7
C D D C D D D
C D D C D D D
D D D D D D C
D C D C D D D
D D D C D C D
C D D C D C C
C D C D C C C
5
D C D C C
D D C C D
D D C C D
D D D C C
C D C C D
5
D C D C D
C C C D D
D D C C D
C D D D C
D C D C C
*/
/////////////////////////////////////CODE/////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 1000000000;
ll MOD = 1000000007;
void solve()
{
	IN(n);
	vl v;
	FOR(i, 0, n)
	{
		IN(in);
		v.push_back(in);
	}
	sort(all(v));
	ll cnt = 0;
	FOR(i, 0, n)
	{
		FOR(j, i + 1, n)
		{
			FOR(k, j + 1, n)
			{
				if (v[i] + v[j] > v[k] and v[i]!=v[j] and v[j]!=v[k] and v[i]!=v[k])
				{
					//what(i)what(j)what(k)
					cnt++;
				}
			}
		}
	}
	cout << cnt;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int n,a,b;

int main(){
	scanf("%d%d%d",&n,&a,&b);
	printf("%lld\n",max(1ll*(n-1)*b+1ll*a-1ll*(n-1)*a-1ll*b+1,0ll));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define DIM 6

typedef struct dice {
	int t;
	int n;
	int e;
	int s;
	int w;
	int b;
}dice;

int main(void) {
	int num;
	int top, front;
    dice buff;
	//init dice
	dice di;
	scanf("%d", &di.t);
	scanf("%d", &di.s);
	scanf("%d", &di.e);
	scanf("%d", &di.w);
	scanf("%d", &di.n);
	scanf("%d", &di.b);

	//number of order
	scanf("%d", &num);

	//operate
	for (int i = 0; i < num; i++)
	{
		int flag_t = 0;

		scanf("%d", &top);
		scanf("%d", &front);
		for (int j = 0; j < 4; j++)
		{
            buff=di;
			di.n = buff.b;
		    di.b = buff.s;
		    di.s = buff.t;
		    di.t = buff.n;
			if (di.t==top)
			{
				flag_t = 1;
				break;
			}
		}
		if (flag_t == 0) {
			for (int j = 0; j < 4; j++)
			{
                buff=di;
                di.w = buff.b;
		        di.t = buff.w;
		        di.e = buff.t;
		        di.b = buff.e;
				if (di.t == top) {
					break;
				}
			}
        }
        for(int j=0;j<4;j++){
            buff=di;
            di.n = buff.w;
		    di.e = buff.n;
		    di.s = buff.e;
		    di.w = buff.s;
            if(di.s==front){
                break;
            }
        }
        printf("%d\n", di.e);
	}
	return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int ct[9]={0};
	int h=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=1&&a[i]<=399)
		{
			ct[1]=1;
		}
		else if(a[i]>=400&&a[i]<=799)ct[2]=1;
		else if(a[i]>=800&&a[i]<=1199)ct[3]=1;
		else if(a[i]>=1200&&a[i]<=1599)ct[4]=1;
		else if(a[i]>=1600&&a[i]<=1999)ct[5]=1;
		else if(a[i]>=2000&&a[i]<=2399)ct[6]=1;
		else if(a[i]>=2400&&a[i]<=2799)ct[7]=1;
		else if(a[i]>=2800&&a[i]<=3199)ct[8]=1;
		else if(a[i]>=3200)h++;

	}
	int res=0;
	for(int i=1;i<=8;i++){if(ct[i])res++;}
	int left=8-res;
	if(res>0)cout<<res<<" "<<res+h;
	else if(res==0)cout<<1<<" "<<h;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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;

void solve() {
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return;
}

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

Measured memory_bytes: 3520
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    long long ans = k;
    for (int i = 1; i < n; i++)
    {
        ans *= k - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[] sum = new int[n];
		if (s.charAt(0) == '#') {
			sum[0] = 1;
		}
		for (int i = 1; i < n; i++) {
			if (s.charAt(i) == '#') {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}
		int min = n - sum[n - 1];
		for (int i = 0; i < n; i++) {
			min = Math.min(sum[i] + (n - i - 1) - (sum[n - 1] - sum[i]), min);
		}
		System.out.println(min);
	}
}

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

int main(){
    int x1=0,y1=0,x2=0,y2=0,x3=0,y3=0,x4=0,y4=0;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx12=0,dx23=0,dx34=0,dy12=0,dy23=0,dy34=0;
    dx12 = x2-x1;
    dy12 = y2-y1;
    dx23 = -dy12;dy23=dx12;
    x3 = x2 + dx23;
    y3 = y2 + dy23;
    dx34 = -dy23;dy34=dx23;
    x4 = x3 + dx34;
    y4 = y3 + dy34;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int sum=accumulate(a.begin(),a.end(),0);
  int ave=sum/N;
  if(ave*N==sum){
    int cnt=0;
    for (int i = 0; i < N; i++) {
      cnt+=(a.at(i)-ave)*(a.at(i)-ave);
    }
    cout << cnt << endl;
  }else{
    int cnt=0;
    for (int i = 0; i < N; i++) {
      cnt+=(a.at(i)-ave)*(a.at(i)-ave);
    }
    int cnt2=0;
    int ave2=ave+1;
    for (int i = 0; i < N; i++) {
      cnt2+=(a.at(i)-ave2)*(a.at(i)-ave2);
    }
    cout << min(cnt, cnt2) << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;


/**
 * 
 * @author DemonSong
 * 
 *         0525. Oscenbei
 * 
 * 
 *
 */
public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			int row = in.nextInt();
			int col = in.nextInt();
			if (row == 0 && col == 0)
				break;

			int[][] grid = new int[row][col];
			for (int i = 0; i < row; i++) {
				for (int j = 0; j < col; j++) {
					grid[i][j] = in.nextInt();
				}
			}
			System.out.println(solve(grid));
		}
		in.close();
	}
	
	private static void flip(int[][] grid, int row){
		for (int i = 0; i < grid[0].length; i++){
			grid[row][i] = grid[row][i] == 1 ? 0 : 1;
		}
	}
	
	private static int total(int[][] grid, int col){
		int n = grid.length;
		int count = 0;
		for (int i = 0; i < n; i++){
			if (grid[i][col] == 1) count ++;
		}
		return Math.max(count, n - count);
	}
	
	private static int solve(int[][] grid) {
		int n = grid.length;
		int m = grid[0].length;

		int nn = 1 << n;
		int max = Integer.MIN_VALUE;
		while (nn-- != 0) {
			String nns = Integer.toBinaryString(nn);
			char[] nnc = nns.toCharArray();
			for (int i = 0; i < nnc.length; i++){
				if (nnc[i] == '1'){
					flip(grid, i);
				}
			}
			int count = 0;
			for (int j = 0; j < m; j++){
				count += total(grid, j);
			}
			max = Math.max(max, count);
			
			for (int i = 0; i < nnc.length; i++){
				if (nnc[i] == '1'){
					flip(grid, i);
				}
			}
		}
		return max;
	}

//	private static int solve(int[][] grid) {
//		int n = grid.length;
//		int m = grid[0].length;
//
//		int nn = 1 << n;
//
//		int max = Integer.MIN_VALUE;
//		while (nn-- != 0) {
//			int[][] clone1 = clone(grid);
//			String nns = Integer.toBinaryString(nn);
//			char[] nnc = nns.toCharArray();
//			for (int i = nns.length() - 1; i >= 0; i--) {
//				if (nnc[i] == '1') {
//					rotate(clone1, i, true);
//				}
//			}
//			int nm = 1 << m;
//			while (nm-- != 0) {
//				int[][] clone2 = clone(clone1);
//				String nms = Integer.toBinaryString(nm);
//				char[] nmc = nms.toCharArray();
//				for (int i = nms.length() - 1; i >= 0; i--) {
//					if (nmc[i] == '1') {
//						rotate(clone2, i, false);
//					}
//				}
//				max = Math.max(max, total(clone2));
//			}
//		}
//		return max;
//	}
//
//	private static int[][] clone(int[][] grid) {
//		int n = grid.length;
//		int m = grid[0].length;
//		int[][] clone = new int[n][m];
//		for (int i = 0; i < n; i++) {
//			for (int j = 0; j < m; j++) {
//				clone[i][j] = grid[i][j];
//			}
//		}
//		return clone;
//	}
//
//	private static void rotate(int[][] grid, int x, boolean isRow) {
//		int n = grid.length;
//		int m = grid[0].length;
//		if (isRow) {
//			for (int i = 0; i < m; i++) {
//				grid[x][i] = grid[x][i] == 1 ? 0 : 1;
//			}
//		} else {
//			for (int i = 0; i < n; i++) {
//				grid[i][x] = grid[i][x] == 1 ? 0 : 1;
//			}
//		}
//	}
//	
//	private static int total(int[][] grid) {
//		int n = grid.length;
//		int m = grid[0].length;
//
//		int total = 0;
//		for (int i = 0; i < n; i++) {
//			for (int j = 0; j < m; j++) {
//				if (grid[i][j] == 1)
//					total++;
//			}
//		}
//		return total;
//	}

}

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


int main() {
    int N, X;
    std::cin >> N >> X;

    std::vector<int> L(N);
    for (int i = 0; i < N; i++) {
        std::cin >> L[i];
    }

    int count = 0;
    int pos = 0;
    while (count < N + 1 && pos <= X) {
        count++;
        pos = pos + L[count - 1];
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
int main(){

    int n, m;
    int a[100][100];
    int b[100][1];
    int c[100][1];
    int i, j;

    scanf("%d %d",&n, &m);
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(j = 0; j < m; j++){
        scanf("%d", &b[j][0]);
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            c[i][0] += a[i][j] * b[j][0];
        }
    }

    for(i = 0; i < n; i++){
        printf("%d\n",c[i][0]);
    }

    return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

struct UnionFind
{
	vector<ll> par, wei;
	UnionFind(ll n)
	{
		init(n);
	}

	void init(ll n)
	{
		par.assign(n, -1);
		wei.assign(n, 0);
	}

	ll root(ll x)
	{
		if (par[x] < 0) return x;
		else
		{
			ll r = root(par[x]);
			wei[x] += wei[par[x]];
			return par[x] = r;
		}
	}

	bool merge(ll x, ll y, ll w)
	{
		// rank(x) > rank(y)
		w += weight(x);
		w -= weight(y);

		x = root(x);
		y = root(y);
		
		if (x == y) return false;
		if (rank(x) < rank(y)) swap(x, y), w *= -1;
		par[x] += par[y];
		par[y] = x;

		wei[y] = w;
		return true;
	}

	ll weight(ll x)
	{
		root(x);
		return wei[x];
	}

	ll rank(ll x)
	{
		return -par[root(x)];
	}

	ll issame(ll x, ll y)
	{
		return root(x) == root(y);
	}

	ll diff(ll x, ll y)
	{
		return weight(y) - weight(x);
	}
};

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	UnionFind uf(N);

	REP(i, M)
	{
		ll l, r, d; cin >> l >> r >> d;
		--l, --r;

		if (uf.issame(l, r))
		{
			if (uf.diff(l, r) != d)
			{
				std::cout << "No" << std::endl;
				return 0;
			}
		}
		else
			uf.merge(l, r, d);
	}

	std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 1792
import numpy as np
A = [list(map(int, input().split())) for i in range(0,3)]
N = int(input())
b_list =list([int(input()) for i in range(0,N)])
count = np.zeros((3,3))
for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b_list:
            count[i][j] = count[i][j] + 1
if (count.sum(axis=1)  ==3).any():
    print('Yes')
elif (count.sum(axis=0) ==3).any():
    print('Yes')
elif count[0][0] + count[1][1] + count[2][2]==3:
    print('Yes')
elif count[2][0] + count[1][1] + count[0][2]==3:
    print('Yes')
else:
    print('No')

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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] sArray = S.toCharArray();
		Arrays.sort(sArray);
		String result = "No";
		if (sArray[0] == sArray[1] && sArray[0] != sArray[2] && sArray[2] == sArray[3]) {
			result = "Yes";
		}
		System.out.println(result);
		sc.close();
	}
}

Measured memory_bytes: 22608
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
    if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;





int main() {

	string s;
	cin >> s;

	int a;
	int b;
	a = 10 * (s[0] - '0') + s[1] - '0';

	b = 10 * (s[2] - '0') + s[3] - '0';
	if (min(a, b) > 12) {
		cout << "NA" << endl;
	}
	else if (max(a, b) < 13 && min(a, b) != 0) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (b == 0 && a > 12) {
		cout << "NA" << endl;
	}
	else if (a == 0 && b > 12) {
		cout << "NA" << endl;
	}
	else if (a == 0 && b == 0) {
		cout << "NA" << endl;
	}
	else if (a > 12 && b > 12) {
		cout << "NA" << endl;
	}
	else if (a == 0) {
		cout << "YYMM" << endl;
	}
	else if (a > 12) {
		cout << "YYMM" << endl;
	}
	else if (b == 0) {
		cout << "MMYY" << endl;
	}
	else if (b > 12) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "AMBIGUOUS" << endl;
	}

}

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

int main() {
  int n, sum=1;
  char p, c;
  string s;
  cin >> n >> s;
  p=s.at(0);
  for(char c:s) {
    if (c==p) continue;
    sum++;
    p=c;
  }
  cout << sum << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MOD 1e9+7
using namespace std;
#define  pp push_back
#define  po pop_back
#define  mp make_pair
#define clr(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,-1,sizeof(a))
#define fas(a) memset(a,false,sizeof(a))
#define debug(x) cout<<#x<<": "<<x<<endl
#define debug1(x) cout<<#x<<": "<<x<<" "
#define rev(x) reverse(x.begin(), x.end())
#define int long long 
#define F first
#define S second
//int a[2000];
void printvector(std::vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<""<<endl;}
void printarray(int a[],int n){for (int i = 0; i < n; ++i){cout<<a[i]<<" ";}cout<<""<<endl;}
 
 

 

void  solve()
{
  int s;cin>>s;
  int e=1e9;
  if(s==e*e)
  {
     cout<<0<<" "<<0<<" "<<0<<" "<<e<<" "<<e<<" "<<0<<endl;return;
  }
  cout<<e<<" "<<0<<" "<<s%e<<" "<<s/e+1<<" "<<0<<" "<<1<<endl;

}




 int32_t main() 
{

 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    
   solve();

return 0;

}

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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int h, w;
        cin >> h >> w;
        vector<int> cnt(26, 0);
        for (int i = 0; i < h; i ++) {
                string s;
                cin >> s;
                for (int j = 0; j < s.size(); j ++) {
                        cnt[s[j] - 'a'] ++;
                }
        }
        if (h % 2 == 0 && w % 2 == 0) {
                int need = h * w / 4;
                for (int i = 0; i < 26; i ++) {
                        while (cnt[i] >= 4 && need > 0) {
                                cnt[i] -= 4;
                                need --;
                        }
                }
                if (need == 0) cout << "Yes" << endl;
                else cout << "No" << endl;
        } else if ((h % 2 != 0 && w % 2 == 0) || (h % 2 == 0 && w % 2 != 0)) {
                if (w & 1) swap(h, w);
                int need = (h - 1) * w / 4;
                for (int i = 0; i < 26; i ++) {
                        while (cnt[i] >= 4 && need > 0) {
                                cnt[i] -= 4;
                                need --;
                        }
                }
                int need2 = w / 2;
                for (int i = 0; i < 26; i ++) {
                        while (cnt[i] >= 2 && need2 > 0) {
                                cnt[i] -= 2;
                                need2 --;
                        }
                }
                if (need == 0 && need2 == 0) cout << "Yes" << endl;
                else cout << "No" << endl;
        } else {
                int need = (h - 1) * (w - 1) / 4;
                for (int i = 0; i < 26; i ++) {
                        while (cnt[i] >= 4 && need > 0) {
                                cnt[i] -= 4;
                                need --;
                        }
                }
                int need2 = (h - 1) / 2 + (w - 1) / 2;
                for (int i = 0; i < 26; i ++) {
                        while (cnt[i] >= 2 && need2 > 0) {
                                cnt[i] -= 2;
                                need2 --;
                        }
                }
                if (need == 0 && need2 == 0) cout << "Yes" << endl;
                else cout << "No" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
import sys, math; from collections import deque; readline=sys.stdin.readline;

N = int(readline())
H = list(map(int, readline().split()))

c = 0
cmax = 0
H.append(10**10)
for i in range(1, len(H)):
    if H[i] <= H[i - 1]:
        c += 1
    else:
        cmax = max(cmax, c)
        c = 0

print(cmax)

Measured memory_bytes: 59632
#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;


int main() {
    int  a, b, c;
    string res = "NO";
    cin >> a >> b >> c;

    if (b -a == c - b) res = "YES";

    cout << res << endl;


    return 0;
}


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

using namespace std;

int main()
{
    int nr,i,j;
    cin >>nr;
    if(nr==1){
        cout<<"Hello World";
    }
    else {
        int a,b;
        cin >> a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  int sum = 0;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    sum += xs[i];
  }
  int a = (sum + n / 2) / n;
  int64 ans = 0;
  for (int x : xs) {
    ans += (x - a) * (x - a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

/*
author: Basel
*/

using namespace std;

int n;

multiset<double>ms;

double x;

int main()
{
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> x;
        ms.insert(x);
    }
    while(ms.sz()>1)
    {
        double y=*ms.begin();
        ms.erase(ms.begin());
        x=*ms.begin();
        ms.erase(ms.begin());
        ms.insert((x+y)/2.0);
    }
    cout << *(ms.begin()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}
 
int main()
{
  string a;
  cin >> a;
  if (a[0] == a[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		int o=0,a=0;
		for(int i=1;i<=k;i++) {
			if(i%2==0) {
				a++;
			}else {
				o++;
			}
		}
		System.out.println(a*o);

	}
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 500005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll f[N];
ll in[N];
ll bigmod(ll a,ll n)
{
    if(n==0)
        return 1LL;
    ll ans=bigmod(a,n/2);
    ans=(ans*ans)%M;
    if(n%2)
        ans=(ans*a)%M;
    return ans;
}
void siv()
{
    f[0]=1;
    for(int i=1;i<N;i++)
    {
        f[i]=f[i-1]*i%M;
    }
    for(int i=0;i<N;i++)
    {
        in[i]=bigmod(f[i],M-2);
    }
    return ;
}
ll C(int n,int r)
{
    return f[n]*in[r]%M *in[n-r]%M;
}
ll P(int n,int r)
{
    return f[n]*in[n-r]%M;
}
main()
{
    siv();
    int n,m;
    cin>>n>>m;
    ll ans=P(m,n);
    ll ex=0;
    for(int i=1;i<=n;i++)
    {
        ll now=C(n,i);
        //now=(now*P(m,i));
        now=(now*P(m-i,n-i))%M;
        if(i%2==0)
        {
            ex=ex-now;
            ex%=M;
            ex=(ex+M)%M;
        }
        else
        {
            ex=(ex+now)%M;
        }
    }
    ex=(P(m,n)-ex)%M;
    ex=(ex+M)%M;
    ans=(ans*ex)%M;
    cout<<ans;

}



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

using namespace std;
typedef long long ll;

#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))
#define all(v) v.begin(), v.end()
#define mp make_pair
#define ff first
#define ss second

const int mod = 1e9 + 7;

map<pair<int, int>, int> gm;
int grundi(int n, int k) {
    if (!gm.count(mp(n, k))) {
        int &ans = gm[mp(n, k)];
        set<int> gl;
        for (int y = 1; y <= (n / k); y++) {
            gl.insert(grundi(n - y, k));
        }
        ans = 0;
        for (; gl.count(ans); ans++);
    }
    return gm[mp(n, k)];
}

ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll g = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - a / b;
    return g;
}

ll minimal_ex(ll a, ll b, ll n) {
    ll x, y;
    ll g = gcd(a, b, x, y);
    if (n % g != 0)
        return -1;
    x = PYMOD(x, b / g);
    return 1ll * x * (n / g);
}

int grundi_fast(int n, int k) {
    while (n >= k && n % k > 0) {
        int d = n / k + 1;
        int l = n - (n % k);
        ll ns = minimal_ex(d, k, n);

        if (ns != -1 && l <= n - 1ll * ns * d) {
            n -= ns * d;
        } else if ((n - l) % d == 0) {
            n = l;
        } else {
            n -= ((n - l) / d + 1) * d;
        }  
    }
    if (n < k)
        return 0;
    if (n % k == 0)
        return n / k;
}


int main() {
    // Code here:

    /*
    for (int k = 1; k < 10; k++) {
        cout << "k = " << k << ": ";
        for (int n = 1; n < 100; n++)
            cout << grundi(n, k) << " ";
        cout << endl << endl;
        }*/
    /*
    for (int k = 1; k < 100; k++) {
        for (int n = 1; n < 1000; n++) {
            if (grundi(n, k) != grundi_fast(n, k))
                cout << n << " " << k << endl;
        }
    }
    */


    int n;
    cin >> n;
    int ans = 0;
    forn(i, n) {
        int a, k;
        cin >> a >> k;
        ans ^= grundi_fast(a, k);
    }

    if (ans == 0)
        cout << "Aoki" << endl;
    else
        cout << "Takahashi" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

long long cost[100005];
vector<int> g[100005], c[100005];

void dfs(int v, int pa, int ca){
    cost[v] = ca + cost[pa];
    for(size_t i = 0; i < g[v].size(); i++){
        if(g[v][i] != pa){
            dfs(g[v][i], v, c[v][i]);
        }
    }
}

int main(){
    int n;
    cin>>n;
    int u,v,w;
    for(int i = 1; i < n; i++){
        cin>>u>>v>>w;
        g[u].push_back(v);
        g[v].push_back(u);
        c[v].push_back(w);
        c[u].push_back(w);
    }
    cost[0] = 0;
    int q,k,x,y;
    cin>>q>>k;
    dfs(k,0,0);
    while(q--){
        cin>>x>>y;
        cout<<cost[x] + cost[y]<<endl;
    }
}


Measured memory_bytes: 19712
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
k = 0 
for i in range(N-1,-1,-1):
    A[i] += k
    if A[i] % B[i] == 0 :
        pass
    else :
        c = (B[i] - A[i] % B[i])
        k += c

print(k)

Measured memory_bytes: 56792
N=int(input())
L=list(map(int,input().split()))
ans=0
c=[0]*1001
for i in L:c[i]+=1
for i in range(1000):c[i+1]=c[i]+c[i+1]
for i in range(N-1):
    for j in range(i+1,N):
        l,r=abs(L[i]-L[j]),min(L[i]+L[j]-1,1000)
        ans+=c[r]-c[l]
        if l<L[i] and L[i]<=r:ans-=1
        if l<L[j] and L[j]<=r:ans-=1
print(ans//3)

Measured memory_bytes: 9304
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

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

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int contain(point p,vector<point>pol){
  bool in=false;
  for(int i=0;i<pol.size();i++){
    point a=curr(pol,i)-p,b=next(pol,i)-p;
    if(a.y>b.y)swap(a,b);
    if(a.y<=0 && 0<b.y && cross(a,b)<0)in=!in;
    if(cross(a,b)==0 && dot(a,b)<=0)return 1;
  }
  return in?2:0;
}

int main(void){

  int n;
  cin >> n;
  vector<point>pol(n);
  for(int i=0;i<n;i++)cin >> pol[i].x >> pol[i].y;

  int q;
  cin >> q;
  point a;
  while(q--){
    cin >> a.x >> a.y;
    cout << contain(a,pol) << endl;
  }

  return 0;
}

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

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

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

// https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
ll modPow(long long a, long long n) {
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	for(int i=1; i< p+1; i++) {
		a = (a * (n - i + 1)) % MOD;
		b = (b * i) % MOD;
	}
	return a * (modPow(b, MOD - 2)) % MOD;
}

// https://gist.github.com/ww24/5517384
int gcdf(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main() {
    // input, ready
    int K;
    cin >> K;

    ll ans = 0;
    for (int i=1; i<=K; i++) {
        for(int j=1; j<=K; j++) {
            int temp = gcdf(i,j);
            for (int k=1; k<=K; k++) {
                ans += gcdf(temp,k);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <random>
#include <vector>
using namespace std;

typedef long long ll;

vector< vector<double> > matmul(vector< vector<double> >& A, vector< vector<double> >& B) {
	int n = A.size();
	vector< vector<double> > C(n, vector<double>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				C[i][j] += A[i][k] * B[k][j];
	return C;
}

vector< vector<double> > matpow(vector< vector<double> > A, ll x) {
	int n = A.size();
	vector< vector<double> > B(n, vector<double>(n));
	for (int i = 0; i < n; i++) B[i][i] = 1;
	while (x > 0) {
		if (x % 2) B = matmul(B, A);
		x /= 2;
		A = matmul(A, A);
	}
	return B;
}

int main() {
	int S, N, K; cin >> S >> N >> K;
	if (S < 0) S *= -1;
	int n = N * K;
	vector<double> p(n + 1);
	p[0] = 1;
	while (K--) {
		vector<double> _p(n + 1);
		for (int i = 0; i <= n; i++)
			if (p[i])
				for (int j = 1; j <= N; j++)
					_p[i + j] += p[i] / N;
		p = _p;
	}
	vector<vector<double> > a(n + 1, vector<double>(n + 1));
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			int _i = abs(i - j);
			a[i][_i] += p[j];
		}
		a[i][n] = 1;
	}
	a[n][n] = 1;
	vector<vector<double> > b = matpow(a, 1e18);
	if (S <= n - 1) {
		printf("%.10f\n", b[S][n]);
		return 0;
	}
	a = vector<vector<double> >(n + 1, vector<double>(n + 1));
	for (int i = 0; i + 1 < n; i++)
		a[i][i + 1] = 1;
	for (int i = 0; i < n; i++)
		a[n - 1][i] = p[n - i];
	a[n - 1][n] = a[n][n] = 1;
	vector<vector<double> > c = matpow(a, S - (n - 1));
	double ans = 0;
	for (int i = 0; i < n; i++)
		ans += c[n - 1][i] * b[i][n];
	ans += c[n - 1][n];
	printf("%.10f\n", ans);
}

Measured memory_bytes: 3392
import math
a,b,h,m = map(int,input().split())

u = 360 * h / 12 + 30 * m / 60 
v = 360 * m / 60
z = abs(u - v)
if z > 180:
    z = 360 - z
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(z))

print(math.sqrt(c))


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

int main(){
  int A[3];
  for(int i = 0; i < 3; i++)cin >> A[i];
  sort(A, A + 3);
  int cnt = 0;
  while(A[1] < A[2]){
    A[0]++;
    A[1]++;
    cnt++;
  }
  while(A[0] < A[1]){
    A[0] += 2;
    cnt++;
  }
  if((A[0] - A[1]) % 2 == 0){
    cout << cnt << endl;
  }else{
    cout << cnt + 1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    string s;
    cin >> s;
    int ans = 99999;
    for(int i = 0; i < s.size()-2; i++){
        int t = stoi(s.substr(i,3));
        ans = min(ans, abs(t-753));
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
using namespace std;
#define ll long long int
#define INF (2147483647)
#define mod (1000000007)

vector<vector<ll>> dp;
vector<vector<bool>> flags;
vector<int> aa;

ll calc(int l, int r, bool first){
  ll tmp;
  if(flags[l][r]){
    return dp[l][r];
  }
  if(first){
    if(l==r){return aa[l];}
    tmp = max(calc(l,r-1,false)+aa[r],calc(l+1,r,false)+aa[l]);
  }else{
    if(l==r){return -aa[l];}
    tmp = min(calc(l,r-1,true)-aa[r],calc(l+1,r,true)-aa[l]);
  }
  dp[l][r] = tmp;
  flags[l][r] = true;
  return tmp;
}


int main(void){
  int N;
  cin >> N;
  aa.assign(N,0);
  for (size_t i = 0; i < N; i++) {
    cin >> aa[i];
  }

  dp.assign(N,vector<ll>(N,0));
  flags.assign(N,vector<bool>(N,false));

  cout << calc(0,N-1,true) << endl;
}


Measured memory_bytes: 72192
# -*- coding: utf-8 -*-
"""
A - Maximize the Formula
https://atcoder.jp/contests/abc110/tasks/abc110_a

"""
import sys


def solve(nums):
    return nums[0]*10 + nums[1] + nums[2]


def main(args):
    nums = sorted(map(int, input().split()), reverse=True)
    ans = solve(nums)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
In = [int(x) for x in input()]
BREAK = False
for i in range(2):
  for j in range(2):
    for k in range(2):
      s = In[0]
      if i == 0:
        s += In[1]
      else:
        s -= In[1]
      if j == 0:
        s += In[2]
      else:
        s -= In[2]
      if k == 0:
        s += In[3]
      else:
        s -= In[3]
      if s == 7:
        BREAK = True
        break
    if BREAK:
      break
  if BREAK:
    break
Out = str(In[0])
m = 1
for l in [i, j, k]:
  if l % 2:
    Out += "-" + str(In[m])
  else:
    Out += "+" + str(In[m])
  m += 1
print(Out + "=7")

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

int main() {
  int N, sum = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      for (int k = 1; k <= N; k++) {
        sum += gcd(i, gcd(j, k));
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
import qualified Data.ByteString.Char8 as BSC8
import qualified Data.Maybe            as Maybe

readIntegers :: IO [Integer]
readIntegers = map ( fst . Maybe.fromJust . BSC8.readInteger ) . BSC8.words <$> BSC8.getLine

solve :: Integer -> Integer
solve n
  | even n    = n `div` 2
  | otherwise = (n + 1) `div` 2
main :: IO ()
main = do
  (h:w:_) <- readIntegers
  print $ if h == 1 || w == 1 then 1 else solve (h * w)

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

//#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int maxn = 3e3+10;
const int INF = 1e9+10;

int dp[maxn][maxn];
vii v;
int n,t;

int solve(int idx,int cap){
	if(idx==n || cap <= 0)
		return 0;
	if(dp[idx][cap]!=-1)
		return dp[idx][cap];
	return dp[idx][cap] = max(solve(idx+1,cap),solve(idx+1,cap-v[idx].ff)+v[idx].ss);
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	///#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#/endif
	cin>>n>>t;
	v=vii(n);
	for(int i=0;i<n;++i){
		cin>>v[i].ff>>v[i].ss;
	}
	sort(all(v));
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,t)<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	int n, c, d[30][30];
	cin >> n >> c;
	for (int i = 0; i < c; i++)
		for (int j = 0; j < c; j++)
			cin >> d[i][j];
	int grid[3][30] = {};
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			int c;
			cin >> c;
			grid[(i + j) % 3][c - 1]++;
		}
	int ans = 1000000000;
	for (int i = 0; i < c; i++)
		for (int j = 0; j < c; j++)
		{
			if (i == j)
				continue;
			for (int k = 0; k < c; k++)
			{
				if (i == k || j == k)
					continue;
				int tmp = 0;
				for (int l = 0; l < c; l++)
				{
					tmp += d[l][i] * grid[0][l];
					tmp += d[l][j] * grid[1][l];
					tmp += d[l][k] * grid[2][l];
				}
				ans = min(ans, tmp);
			}
		}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

#define REP(i, N) for(int (i) = 0; (i) < (N); i++)
#define MAX 1 << 20

int main(){
    int n, k, x, y;
    scanf("%d %d %d %d", &n, &k, &x, &y);
    printf("%d\n", n<=k ? n*x : k*x + (n-k)*y);
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	int i=0;
	rep(j,N){
		int t;
		cin >> t;
		if(t==i+1)i++;
	}
	if(i)cout << N-i << endl;
	else cout << -1 << endl;
}



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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0n(i, n) for (i = 0; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
//*/

//int row, column;
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll a, b, c, d;

        cin >> a >> b >> c >> d;
        if ((abs(a-c) <= d) or ((abs(a-b) <= d) and (abs(b-c) <= d)))
            cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}
template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val s = StdIn.readInt()
  def factorial(n: Int):BigInt = List.range(1, n+1).map(BigInt(_)).foldLeft(BigInt(1))(_*_)
  def factorialPart(from:Int,to:Int):BigInt = List.range(from, to+1).map(BigInt(_)).foldLeft(BigInt(1))(_*_)
  var sum = BigInt(0)
  var seqLength = 1
  while(3*seqLength <= s){
    val retNum = s - 3*seqLength
    sum += factorialPart(retNum+1,retNum + (seqLength -1))/factorial(seqLength -1)
    //println(s"${seqLength}:${factorialPart(retNum+1,retNum + (seqLength -1))},${factorial(seqLength -1)}")
    seqLength += 1
  }

  val mod = BigInt(10).pow(9) + 7
  println(sum % mod)
}







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

int main() {
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = {}
for a in A:
    if a not in cnt:
        cnt[a] = 1
    else:
        cnt[a] += 1

cnt = [[k, v] for k, v in cnt.items()]
cnt.sort(reverse=True)
ans = 0
for k, v in cnt:
    # e.g.) 4という数が4以上存在する
    if k <= v:
        # 4が4つになるまで取り除く
        ans += v - k
    else:
        # 4という要素は全部取り除くしかない
        ans += v

print(ans)


Measured memory_bytes: 76968
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        String msg = scanner.nextLine();
        while(!msg.equals("-")){
            int cnt = Integer.parseInt(scanner.nextLine());
            for(int i=0; i<cnt; i++){
                int h = Integer.parseInt(scanner.nextLine());
                String h1 = msg.substring(0,h);
                String h2 = msg.substring(h);
                msg = h2 + h1;
            }
            System.out.println(msg);
            msg = scanner.nextLine();
        }
    }
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    long long int  n,d;
    cin>>n>>d;
    int count=0;
    rep(i,n){
        long long int  x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <vector>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  int a, b, c;
  cin >> a >> b >> c;
  bool d = false;
  if((a==b)&&(b!=c)){
    d = true;
  }
  if((b==c)&&(c!=a)){
    d = true;
  }
  if((c==a)&&(a!=b)){
    d = true;
  }
  if(d==true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

namespace abc080
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int A = int.Parse(input[1]);
            int B = int.Parse(input[2]);
            int ans = N * A <= B ? N * A : B;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092