akhauriyash/Code-Regression huggingface dataset:
//Optimise
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fast()                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

#define f first
#define s second
#define pb push_back
#define mp make_pair

const long long mod = 100000000;
const long long High = 1e16;

int main()
{
    fast();
  	int n;
  	cin >> n;
  	ll sum = 0;
  	vector<int> Vect(n);
  	for(int i=0;i<n;++i)
    {
      cin >> Vect[i];
      sum += Vect[i];
    }
	sort(Vect.begin(),Vect.end());
  	if(Vect[n-1] < sum - Vect[n-1])
    	cout << "Yes";
     else cout << "No";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static int[][] dp;
	public static String b;
	public static String a;
	public static String findString(int r, int c, String st) {
		if(r < 0 || c < 0)return st;
		if(r == 0 && c == 0)return st;
		if(r == 0)return findString(r, c-1, st);
		if(c == 0)return findString(r-1, c, st);
		if(a.charAt(r-1) == b.charAt(c-1))return findString(r-1, c-1, a.charAt(r-1) + ""+st);
		if(dp[r-1][c] > dp[r][c-1])return findString(r-1, c, st);
		else return findString(r, c-1, st);
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		b = sc.nextLine();
		a = sc.nextLine();
		int alen = a.length();
		int blen = b.length();
//		System.out.println(alen+" "+blen);
		dp = new int[alen+1][blen+1];
		
		for(int i = 0; i <= alen; i ++) {		
			for(int j = 0; j <= blen; j++) {
				if(i == 0 || j == 0) {
					dp[i][j] = 0;
					continue;
				}
				if(i + j == 0);
				else if(i == 0)dp[i][j] = dp[i][j-1];
				else if(j == 0)dp[i][j] = dp[i-1][j];
				else dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
//				System.out.println(a.charAt(i-1) +" "+b.charAt(j-1));
				if(a.charAt(i-1) == b.charAt(j-1)) {
					dp[i][j] = dp[i-1][j-1]+1;
				}
			}
		}
//		for(int i = 0; i < alen+1; i++)System.out.println(Arrays.toString(dp[i]));
		System.out.println(findString(alen, blen, ""));
	}
}


Measured memory_bytes: 95796
import java.util.Scanner;

/**
 * https://abc051.contest.atcoder.jp/tasks/abc051_c
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		sc.close();
		
		int dx = tx-sx;
		int dy = ty-sy;
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<dx; i++) ans.append('R');
		for(int i=0; i<dy; i++) ans.append('U');
		for(int i=0; i<dx; i++) ans.append('L');
		for(int i=0; i<dy; i++) ans.append('D');
		ans.append('D');
		for(int i=0; i<=dx; i++) ans.append('R');
		for(int i=0; i<=dy; i++) ans.append('U');
		ans.append('L');
		ans.append('U');
		for(int i=0; i<=dx; i++) ans.append('L');
		for(int i=0; i<=dy; i++) ans.append('D');
		ans.append('R');
		
		System.out.println(ans.toString());
	}

}


Measured memory_bytes: 21716
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<lint> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
vector<lint> zyo,rz;
lint mo=1000000007;
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint co(int a,int b){
	if(a<0 || b<0 || a<b) return 0;
	return ((zyo[a]*rz[b])%mo*rz[a-b])%mo;
}
lint cal(int n,int x){
	if(x*2>=n) return 0;
	return (zyo[n-x]*zyo[n-1-x])%mo*rz[n-1-x*2]%mo;
}
int main()
{
	lint out=0;int n;
	cin>>n;n--;
	if(n<2){
		cout<<1<<endl;return 0;
	}
	zyo.pb(1);rep(i,1001001) zyo.pb((zyo[i]*(i+1))%mo);
	rep(i,1001001) rz.pb(invMod(zyo[i],mo));
	vector<lint> v;
	rep(i,(n+1)/2) v.pb(cal(n,i));
	//cout<<v<<endl;
	rep(i,v.size()-1) v[i]-=v[i+1];
	rep(i,v.size()){
		out+=(n-i)*v[i];out%=mo;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 24168
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
N, X = input().split()
xList = [int(x) for x in input().split()]
N = int(N)
X = int(X)
xList.append(X)
xList.sort()
diffList = []
for x, xx in zip(xList, xList[1:]):
    diffList.append(xx - x)
if len(diffList) > 1:
    diffList.sort()
    gcdList = []
    for x in diffList[1:]:
        gcdList.append(gcd(diffList[0], x))
    gcdList.sort()
    print(gcdList[0])
else:
    print(diffList[0])

Measured memory_bytes: 14228
#include<iostream>
#include<string>
using namespace std;;
int main(void){
string n;
cin >>n;
long long i=n.length();
long long left=0;
long long right=i-1;
long long count=0;
if(i==1){
cout<<0;
}

else{
while(1){
if(left >=right){
cout <<count;
break;
}
if(n[left]==n[right]){
left++;
right--;
}
else if(n[left]=='x'){
for(int j=left;j<=right;j++){
if(n[j]!='x'){
left=j;
break;
}
else{
count++;
}
}
}
else if(n[right]=='x'){
for(int j=right;left<=j;j--){
if(n[j]!='x'){
right=j;
break;
}
else{
count++;
}
}
}
else{
cout <<-1;
break;
}
}
}
return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false),cin.tie(0);
#define ll long long
#define inf 0x3f3f3f3f
const int N=105;
//set<string>b;
//set<string>::iterator it;

int main()
{
	IO;
	int len1,len2,i,j,x,ans;
	string s,t;
	cin>>s>>t;
	len1=s.length();
	len2=t.length();
	ans=inf;
	for(i=0;i+len2<=len1;i++)
	{
		x=0;
		for(j=0;j<len2;j++)
		{
			if(s[i+j]!=t[j])
			{
				x++;
			}
		}
		ans=min(ans,x);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int gcd(int ,int);
int main(){
  int x,y,a;
  cin>>x>>y;
  a=gcd(x,y);
  cout<<a<<endl;
  return 0;
}
   
int gcd(int x,int y){
  while(1)
    if(x>y){
      x%=y;
      if(x==0) return y;
    }
    else{
      y%=x;
      if(y==0) return x;
    }
}



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

int main(){
  int n, a[100], s;
  while(cin >> n,n){
    s=0;
    for(int i = 0;i < n;i ++){
      cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 1;i < n-1;i ++){
      s += a[i];
    }
    cout << s/(n-2)<< endl;
  }
  return 0;
}

Measured memory_bytes: 2992
#include <stdio.h>
int main(void)
{
    int N, score = 0;
    scanf("%d", &N);
    int A[N], B[N], C[N - 1];
    for (int j = 0; j < N; j++)
    {
        scanf("%d", &A[j]);
    }
    for (int j = 0; j < N; j++)
    {
        scanf("%d", &B[j]);
    }
    for (int j = 0; j < N - 1; j++)
    {
        scanf("%d", &C[j]);
    }
    for (int i = 0; i < N; i++)
    {
        score += B[i];
    }
    for (int i = 0; i < N - 1; i++)
    {
        if (A[i + 1] - A[i] == 1)
        {
            score += C[A[i]-1];
        }
    }
    printf("%d", score);
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(u64);
    let mut v = get!([i32]);
    // eprintln!("{}", n);
    // eprintln!("{:?}", v);
    if n == 1 {
        println!("Yes");
        return;
    }
    for i in (1..v.len()).rev() {
        let diff = v[i] - v[i - 1];
        // eprintln!("i: {}, v[i]: {}, v[i-1]: {}", i, v[i], v[i - 1]);
        // eprintln!("{:?}", diff);
        if diff == -1 {
            v[i - 1] -= 1;
        } else if diff < -1 {
            // println!("early");
            println!("No");
            return;
        }
    }
    // eprintln!("{:?}", v);
    for i in (1..v.len()).rev() {
        let diff = v[i] - v[i - 1];
        if diff < 0 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 8444
N,W=map(int,input().split())
l=[0]*4
s=[[] for i in range(4)]
for i in range(N):
    w,v=map(int,input().split())
    if w in l:
        s[l.index(w)].append(v)
    else:
        for i in range(4):
            if l[i]==0:
                l[i]=w
                s[i].append(v)
                break
g=[[0] for i in range(4)]
for i in range(4):
    s[i].sort(reverse=1)
    t=0
    for j in s[i]:
        t+=j
        g[i].append(t)
a=0
for i in range(len(g[0])):
    for j in range(len(g[1])):
        for k in range(len(g[2])):
            for m in range(len(g[3])):
                if i*l[0]+j*l[1]+k*l[2]+m*l[3]>W:
                    continue
                t=g[0][i]+g[1][j]+g[2][k]+g[3][m]
                if t>a:
                    a=t
print(a)

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

int main(){

  int x, y;
  int tmp;

  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0)
      break;
    if(x > y)
      cout << y <<" "<< x << endl;
    else
      cout << x <<" "<< y << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
package main

import "fmt"

func main() {
  var N, lidx, ans int
  fmt.Scan(&N)
  x := make([]int, N)
  for i := range x {
    fmt.Scan(&x[i])
  }
  
  ridx := len(x)-1
  rlen := x[ridx]
  ridx--
  llen := x[lidx]
  lidx++
  for lidx <= ridx {
    if llen <= rlen {
      llen += x[lidx]
      lidx++
    } else {
      rlen += x[ridx]
      ridx--
    }
  }
  if rlen < llen {
    ans = llen - rlen
  } else {
    ans = rlen - llen
  }
  fmt.Println(ans)
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int K;
	cin>>K;
	int odd=0,even=0;
	for(int i=1;i<=K;i++)
		if(i%2)
			odd++;
		else
			even++;
	cout<<odd*even<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
string s;
int main(void){
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int m;
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    cout << (n + m - 1) / m << "\n";
}



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

typedef long long ll;

const int N = 2e3 + 5;

int f[N] = {0};
int main(){
    int n, u, v, d;
    scanf("%d%d%d", &n, &u, &v);
    for(int i = 1; i <= n; ++i){
        for(int j = i + 1; j <= n; ++j){
            d = j - i;
            d = min(d, abs(u - i) + abs(v - j) + 1);
            d = min(d, abs(u - j) + abs(v - i) + 1);
            f[d]++;
        }
    }    
    for(int i = 1; i < n; ++i) printf("%d\n", f[i]);
    // system("pause");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main ()
{
  ios :: sync_with_stdio (false);
  cin.tie (NULL);
  cout.tie (NULL);
  
  int a;
  cin >> a;
  
  if (a < 3200)
    cout << "red";
  else
  {
    char s[11];
    cin >> s;
    
    cout << s;
  }
  
  return 0;
}

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

typedef long long ll;

const int MX=200005;
const int M=998244353;
int n,m,k,fact[MX];

int pwr(int b,int p)
{
    int x=1;
    while(p){
        if(p & 1) x=((ll)x*(ll)b)%M;
        b=((ll)b*(ll)b)%M,p>>=1;
    }
    return x;
}

int ncr(int n,int r)
{
    int x=((ll)fact[r]*(ll)fact[n-r])%M;
    x=((ll)fact[n]*(ll)pwr(x,M-2))%M;
    return x;
}

int main()
{
    cin>> n >> m >> k;
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=(i*(ll)fact[i-1])%M;
    }
    int ans=0,x;
    for(int i=0;i<=k;i++){
        x=((ll)ncr(n-1,i)*(ll)m)%M;
        x=((ll)x*(ll)pwr(m-1,n-i-1))%M;
        ans=(ans+x<M)?(ans+x):(ans+x-M);
    }
    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 4408
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int b = scan.nextInt();
		if(n>=13) {
			System.out.println(b);
		}else if(n>=6) {
			System.out.println(b/2);
		}else {
			System.out.println(0);
		}

	}
}

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

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}


int main(){
	
	int n,x;
	int i;
	int count=0,sum=0;
	
	cin >> n >> x;
	syc(n,1,100);
	syc(x,1,10000);
	int a[n+1];
	
	a[0]=0;
	for(i=1;i<n+1;i++){
		cin >> a[i];
		syc(a[i],1,100);
	}
	
	for(i=0;i<n+1;i++){
		sum += a[i];
		count ++;
		
		//cout << "sum=  " << sum << endl;
		//cout << "count=  " << count << endl;
		
		if(sum > x){
			count--;
			break;
		}else if(sum == x){
			break;
		}
	}
	cout << count << endl;
	return 0;
}


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

int main(){
  int X; cin >> X;
  int max_beki = 0;

  if (X==1){
    cout << 1 << endl;
    return 0;
  }

  for (int i = 2 ; i <=31 ; i++){
    int beki = i*i;
    if (beki > X) break;

    while (true){
      if ( beki * i <= X  ){
        beki *= i;
      } else {
        max_beki = max(beki, max_beki);
        break;
      }
    }
  }

  cout << max_beki << endl;
	return 0;
}


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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  bool ok = false;
  for(int i=0;i<N;++i){
	int s, f;
	cin >> s >> f;
	if(!(b <= s || f <= a))
	  ok = true;
  }
  cout << ok << endl;
  
  return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if ((A < C && C < B) || (A > C && C > B)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    vector<pair<int, int> > v(6);
    for(int i=0; i<6; ++i)
        cin >> v[i].first >> v[i].second;

    sort(v.begin(), v.end());
    do{
        for(int i=0; i<(1<<6); ++i){
            bitset<32> bs(i);
            vector<pair<int, int> > w = v;
            for(int j=0; j<6; ++j){
                if(bs[j])
                    swap(w[j].first, w[j].second);
            }

            if( w[0].first  == w[1].first  && w[1].first  == w[2].first  && w[2].first  == w[3].first  &&
                w[4].first  == w[5].first  && w[5].first  == w[0].second && w[0].second == w[1].second &&
                w[2].second == w[3].second && w[3].second == w[4].second && w[4].second == w[5].second )
            {
                cout << "yes" << endl;
                return 0;
            }
        }
    }while(next_permutation(v.begin(), v.end()));

    cout << "no" << endl;
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N, K, X, Y; cin >> N >> K >> X >> Y;

    if(N <= K) cout << X*N << endl;
    else cout << X*K + Y*(N-K) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
    
using namespace std;
    
#define int long long
#define endl "\n"

template<typename RandomIt>
void ruffleSort(RandomIt first, RandomIt last)
{
    random_device rd;
    mt19937 g(rd());
    shuffle(first, last, g);
    sort(first, last);
}

template<typename Container>
auto outputContainer(const Container & con) 
{
    for(int i = 0; i < con.size(); ++i)
        cout << con[i] << " \n"[i+1==con.size()];
}

template<typename T = int>
auto readVector(const int N) 
{
    vector<T> v(N);
    for(auto & e : v) cin >> e;
    return v;
}


int32_t main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    string s;
    cin >> s;

    if(s.back() == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << "s" << endl;
    }

    return 0;
}


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

int main()
{
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; i++)
  {
    if (2 * i + 4 * (x - i) == y)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

int main ()
{
  int X; //animals
  int Y; //legs
  int chk=0;
  cin >> X;
  cin >> Y;

  if ((Y < 2 * X) || (Y > X * 4))
    {
      chk = 1;
    }
  else
    {
      chk = ((X * 4) - Y) % 2;
    }

  if (chk == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

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

const int Max = 2e5 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;


string s, t;
int n, m;

int nxt[27][Max];

ll ok() {
	ll cur = 1;
	ll ans = 0;
	ll round = 0;
	for(int i = 1; i <= m; i++) {
		if(nxt[t[i] - 'a'][cur] <= n) {
			ans = 1LL * round * n + nxt[t[i] - 'a'][cur];
			cur = nxt[t[i] - 'a'][cur] + 1;
			if(cur > n) {
				round++;
				cur = 1;
			}
		}
		else {
			round++;
			cur = 1;
			if(nxt[t[i] - 'a'][cur] <= n) {
				ans = 1LL * round * n + nxt[t[i] - 'a'][cur];
				cur = nxt[t[i] - 'a'][cur] + 1;
				if(cur > n) {
					round++;
					cur = 1;
				}
			}
			else {
				return -1;
			}
		}
	}
	//cout << ": " << ans << endl;
	return ans;
}

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	cin >> s >> t;

	n = s.size();
	m = t.size();

	s = "#" + s;
	t = "#" + t;

	ll l = 1, r = 1e18;

	for(int i = 0; i < 26; i++) {
		int cur = n + 5;
		for(int j = n; j >= 1; j--) {
			if(s[j] == i + 'a') {
				cur = j;
			}
			nxt[i][j] = cur;
		}
	}

	cout << ok() << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
void solve(){
    int n;cin>>n;
    vector<int> a(n);
    int c[2]={};
    rep(i,n){
        cin>>a[i];
        c[a[i]%2]++;
    }
    if(c[0]==0 || c[1]==0){
        cout<<0<<endl;return;
    }
    if(c[1]%2){
        int ans=c[1]/2;
        c[0]+=c[1]/2;
        ans+=c[0];
        cout<<ans<<endl;return;
    }
    else{
        int ans=c[1]/2-1;
        c[0]+=(c[1]-2)/2;
        ans+=c[0];
        cout<<ans<<endl;return;
    }
}
int main(){
    solve();
    return 0;
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    vi a(5);
    vecin(5,a);

    repz(i,5)
    {
        if (a[i]==0)
        {
            cout << i+1 << endl;
            re;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 3636
dist = []
cnt = 0
n,m = gets.chomp.split(" ").map(&:to_i)
n.times do |i|
  dist[i]=true
end
h = gets.chomp.split(" ").map(&:to_i)
m.times do |i|
  a, b= gets.chomp.split(" ").map(&:to_i)
  a-=1
  b-=1
  if h[a] > h[b] && dist[b]
    dist[b] = false
  elsif h[a] < h[b] && dist[a]
    dist[a] = false
  elsif h[a] == h[b]
    dist[a] = false
    dist[b] = false
  end
  # p "#{a} #{b}"
  # p dist
end

dist.each do |v|
  cnt += 1 if v
end

# p dist
puts cnt

Measured memory_bytes: 25144
#include <stdio.h>
void _swap(int& a, int& b)
{
int t = a;
a = b;
b = t;
}

int main()
{
int n[3];
scanf("%d %d %d",&n[0],&n[1],&n[2]);

if(n[2]<n[0]) _swap(n[0],n[2]);
if(n[1]<n[0]) _swap(n[0],n[1]);
if(n[2]<n[1]) _swap(n[1],n[2]);

printf("%d %d %d\n", n[0],n[1],n[2]);

return 0;
}

Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    cum_A=[0]*(n+1) #Aの[0,i)の和
    for i in range(1,n+1):
        cum_A[i]=cum_A[i-1]+A[i-1]
    dp=[[0]*n for _ in range(n)]  #[i,j]をまとめるために必要なコストの最小値
    for length in range(2,n+1):
        for i in range(n-length+1):
            j=i+length-1 #右側
            res=10**20
            for k in range(i+1,j+1):#区間[i,k)と[k,j]に分ける
                res=min(res,dp[i][k-1]+dp[k][j])
            dp[i][j]=res+cum_A[j+1]-cum_A[i]
    print(dp[0][n-1])


if __name__=='__main__':
    main()

Measured memory_bytes: 41712
n, m = map(lambda x: int(x), input().split(" "))
v = []
for i in range(n):
    v.append(list(map(lambda x: int(x), input().split(" "))))
q = []
for i in range(m):
    q.append(int(input()))
result = []
for i in range(n):
    x = 0
    for j, val in enumerate(v[i]):
        x += val * q[j]
    result.append(x)
for x in result:
    print(x)



Measured memory_bytes: 6024
public class Main{
	public static void main(String[] args){
		String input = new java.util.Scanner(System.in).nextLine();
		String[] words = input.split("\\s");
		int a = Integer.parseInt(words[0]);
		int b = Integer.parseInt(words[1]);
		int ans_area = a * b;
		int ans_long = 2 * ( a + b );
		System.out.println( ans_area + " " + ans_long ); 
	}
}

Measured memory_bytes: 26004
#include<bits/stdc++.h>
using namespace std;
int main(){

   int a,b;
   cin>>a>>b;
   int d=a;
   int e=b;
   string x,y,z,xx;
   x=to_string(a);
   y=to_string(b);
   for(int i=0;i<d;i++){
        z=z+y;
   }
   for(int i=0;i<e;i++){
        xx=xx+x;
   }
   stringstream ss(z);
   stringstream sh(xx);
   int r1=0,r2=0;
   ss>>r1;
   sh>>r2;
   if(r1>r2)
     cout<<r1<<endl;
   else cout<<r2<<endl;
 return 0;
}



Measured memory_bytes: 384
n, T = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]

count = 0
prevEnd = T
for i in range(1, len(t)):
    # print("prevEnd:{} count:{}".format(prevEnd, count))
    if prevEnd <= t[i]:
        count += T
    else:
        count += t[i] - t[i-1]
    prevEnd = t[i] + T
    # print("prevEnd:{} count:{}\n".format(prevEnd, count))
print(count + T)


Measured memory_bytes: 25196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const double inf = 1e9;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, K, T, U, V, L;
	cin >> N >> K >> T >> U >> V >> L;
	vector<int> D(L+1, 0);
	for (int i = 0;i < N;i++) {
		int d; cin >> d;
		D[d] = 1;
	}
	long double ans = 0;

	int have_carrot = 0;
	int limit_l = -1;
	bool boost = false;
	for (int l = 0; l < L;l++) {
		//cout << l << " " << " " << boost <<" " << limit_l << " "<< ans << endl;
		// no boost
		if (!boost) {
			if (D[l] == 1) {
				ans += 1 / (double)V;
				boost = true;
				limit_l = l + T*V;
			}
			else {
				ans += 1 / (double)U;
			}
			continue;
		}

		if (l == limit_l) {
			if (D[l] == 1) have_carrot++;
			if (have_carrot > 0) {
				have_carrot--;
				limit_l = l + T*V;
				ans += 1 / (double)V;
			}
			else {
				boost = false;
				ans += 1 / (double)U;
			}
			continue;
		}

		ans += 1 / (double)V;
		if (D[l] == 1) {
			have_carrot++;
			if (have_carrot <= K) continue;
			limit_l = l + T*V;
			have_carrot--;
		}
	}
	cout << fixed << setprecision(10) << ans << endl;
}

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

int main() {
  int N, C=0;
  string A;
  cin >> N;

  int i=0;
  while(i<N){
  	cin >> A;
    if(A=="Y"){
      C=1;
    }
    i++;
  }
  if(C==0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}


Measured memory_bytes: 256
#include    <iostream>
#include    <vector>

using namespace std;

int main() {
    int n, q;
    unsigned int ans = 0;

    // 入力
    cin >> n;
    vector<int> S(n);
    for(auto& Si : S) {
        cin >> Si;
    }
    cin >> q;
    vector<int> T(q);
    for(auto& Ti : T) {
        cin >> Ti;
    }

    // 計算
    for(const auto& Ti : T) {
        unsigned int i = 0;
        S.push_back(Ti);
        while(S[i++] != Ti);
        ans += ( (i != S.size()) ? 1 : 0);
        S.pop_back();
    }

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3208
#include <iostream> // cout, endl, cin
using namespace std;

int main(){
    int N;
    string S,S1,S2;
    cin>>N>>S;
    if(N%2==0){
        for(int i=0;i<N/2;i++){
            S1=S1+S.at(i);
        }
        for(int i=N/2;i<N;i++){
            S2=S2+S.at(i);
        }
        if(S1==S2){
            cout<<"Yes"<<endl;
        }
        else{
           cout<<"No"<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
w, h, x, y, r = map(int, input().split())

if x-r >= 0:
    if x+r <= w:
        if y-r >=0:
            if y+r<=h:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 5596
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
edge=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
c=[1 for i in range(n+1)]
ans=[]
def f(s):
    c[s]=0
    ans.append(s)
    for i in edge[s]:
        if c[i]:
            return f(i)
f(1)
ans.reverse()
del ans[-1]
f(1)
print(len(ans))
print(" ".join(map(str,ans)))

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

int main(){
    int N;
    cin >> N;

    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

#define N 100

int main(){
  int i, j=0, k, inp, minj=0, temp, cha=0, count=0;
  int A[N];
  
  scanf("%d", &inp);
  for(i = 0; i < inp; i++) scanf("%d", &A[i]); /*set array*/
  
  for(j = 0; j < inp-1; j++){
    for(k = inp-1, minj = k; k > j; k--){
      if(A[minj] == A[k-1]){
        if(minj > k-1) minj = k-1;
      }
      if(A[minj] > A[k-1]) minj = k-1;
    }
    i = j; 
    if(A[minj] < A[i]){
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      count++;
    }
  }
  
  for(i=0; i < inp-1; i++) printf("%d ", A[i]);
  printf("%d", A[i]);
  printf("\n%d\n", count);
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int K,X;cin>>K>>X;int c=1e6;
	rep(i,max(-c,X-K+1),min(c,X+K-1)+1){
		cout<<(i-max(-c,X-K+1) ? " ":"")<<i;
	}cout<<endl;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

          

			var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long wa = inputArray.Sum();

			//答えの出力
			var ans = wa > 21 ? "bust":"win" ;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 18888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n, x, y;
    cin >> n >> x >> y;
    --x;
    --y;
    vector<vector<int>> graph(n);
    rep(i, n){
        if(i != n-1){
            graph[i].push_back(i+1);
            graph[i+1].push_back(i);
        }
        if(i == x){
            graph[x].push_back(y);
            graph[y].push_back(x);
        }
    }

    vector<int> ans(n-1);
    rep(i, n){
        vector<int> dis(n, -1);
        queue<int> q;
        q.push(i);
        dis[i] = 0;
        while(!q.empty()){
            int v = q.front();
            q.pop();
            rep(i, graph[v].size()){
                int u = graph[v][i];
                if(dis[u] == -1){
                    dis[u] = dis[v] + 1;
                    q.push(u);
                    ans[dis[u]-1]++;
                }
            }
        }
    }
    rep(i, n-1){
        cout << ans[i]/2 << endl;
    }
    return 0;
}

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

int main() {
	long long n,i,ans;
	cin >> n;
	vector<long long> a(5);
	for(i=0; i<5; i++){
		cin >> a[i];
		a[i]=(n+a[i]-1)/a[i];
	}
	ans=a[0];
	for(i=0; i<4; i++){
		ans=max(ans,a[i+1]);
	}
	cout << ans+4;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            string S = strArray[0];
            string T = strArray[1];
            string ans = "";
            for(int i = 0; i < N; i++)
            {
                ans += S[i];
                ans += T[i];
            }
            Console.WriteLine(ans);
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27812
#include <iostream>

using namespace std;

int main() {
	string a,b,c;
	cin >> a >> b >>c;
	int A=a.size();int B=b.size();int C=c.size();
	if(a[A-1]==b[0]&&b[B-1]==c[0]){cout<<"YES"<<endl;}
	else cout<<"NO"<<endl;
}

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

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

class Sol{
	public void Solve(){
		long Inf = (long) 1e18;
		long[] dp = new long[N];
		for(int i=0;i<N;i++){
			dp[i] = Inf;
		}
		
		dp[0] = 0;
		for(int i=0;i<N;i++){
			for(int j=1;j<=K;j++){
				if(i + j < N){
					dp[i + j] = Math.Min(dp[i + j], dp[i] + Math.Abs(H[i + j] - H[i]));
				}
			}
		}
		
		Console.WriteLine(dp[N-1]);
	}
	int[] H;
	int N, K;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		H = ria();
	}

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


Measured memory_bytes: 19168
#include <iostream>
using namespace std;
int main() {
  int N, K; cin >> N >> K;
  int x[N], sum = 0; 
  double base;
  base = K / 2.0;
  for(int i = 0; i < N; i++) {
    cin >> x[i];
    sum += (x[i] > base ? K - x[i] : x[i]);
  }
  sum *= 2;
  cout << sum << endl;
}

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

#define INF (1 << 29)
#define rep2(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define EPS 1e-10

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

int main()
{
    int k,t;
    cin >> k >> t;
    vector<int> a(t);
    rep(i,t) cin >> a[i];

    sort(a.begin(),a.end());
    int dest = a[t-1];
    rep(i,t-1) {
        dest -= a[i];
    }
    cout << max(dest-1,0) << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	// 入力
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	
	// 分割面積の最大値はW * H / 2
	double area = double(W) * double(H) / 2;
	// 例題の桁数の出力へ
	cout << fixed << setprecision(6) << area << " ";
	
	int count = 0;
	// (x, y)と(W / 2, H / 2)の直線を考える
	// x = W / 2, y = H / 2の場合、直線が複数通りありえる
	if (2 * x == W && y * 2 == H)
	{
		count = 1;
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
/**
     **author : _KMS_
     **created : 14-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+100,MOD=2e9;
typedef long long ll;
string s;
int x=-1,y=10000000;
int main() 
{ 
      
 ios::sync_with_stdio(false);
 cin.tie(0);
 int n,m;
 cin>>n>>m;
 for(int i=0;i<m;i++)
 {
       int a,b;
       cin>>a>>b;
       x=max(x,a);
       y=min(y,b);
 }
(x>y)?cout<<"0\n":cout<<y-x+1<<"\n";
 
 
	return 0; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
int main(){
    int a; cin >> a;
    string s; cin >> s;
    if(a>=3200){cout << s <<endl;}
    else{cout << "red" <<endl;}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#pragma warning(disable:4996)
int main()
{
	int u, k, n, v;
	int i, j;
	int matrix[102][102] = {0};

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &u);
		scanf("%d", &k);
		for (j = 0; j < k; j++)
		{
			scanf("%d", &v);
			matrix[u][v] = 1;
		}
	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if (j == n)
			{
				printf("%d\n", matrix[i][j]);
			}
			else
			{
				printf("%d ", matrix[i][j]);
			}
		}
	}

	return 0;

}


Measured memory_bytes: 2732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long[] L = new long[N + 1];
		L[0] = 2;
		L[1] = 1;
		
		for(int i = 2; i <= N; i++) {
			L[i] = L[i - 1] + L[i - 2];
		}
		System.out.println(L[N]);
	}
}


Measured memory_bytes: 21972
import Control.Applicative

inputs = fmap (read :: String -> Int) . words <$> getLine
input = (read :: String -> Int) <$> getLine

tuples n lst = do
    x <- [0..n-1]
    y <- [x+1..n-1]
    return (abs $ (lst !! x) - (lst !! y))

solve n xs = minimum $ tuples n xs

main = input >>= \n -> if n /= 0 then 
                                 inputs >>= (\xs -> putStrLn $ show $ solve n xs) >> main
                                 else do return ()

Measured memory_bytes: 101012
#include <stdio.h>

int main(){
	int Go[100000];
	int i,j,k;
	int n;
	int sum;
	
	while(1){
		scanf("%d\n",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d\n",&Go[i]);
			if(i%2&&Go[i]^Go[i-1]){
				for(k=i-1;k>=0;k--){
					if(Go[k]==Go[i])break;
					Go[k]=Go[i];
				}
			}
		}
		sum=0;
		for(i=0;i<n;i++)sum+=Go[i];
		printf("%d\n",n-sum);
	}
	return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

class RollingHash{
private:
	static const ull B = (ull)1e+8 + 7;

	std::string text;
	int texSize;
	std::vector<ull> pow, phash;

	inline ull TextHash(int s, int e){
		return phash[e] - phash[s] * pow[e - s];
	}

public:
	RollingHash(std::string tex) :text(tex), texSize(text.size()), pow(texSize + 1), phash(texSize + 1){
		pow[0] = 1;
		phash[0] = 0;
		rep(i, texSize){
			phash[i + 1] = phash[i] * B + text[i];
			pow[i + 1] = pow[i] * B;
		}
	}

	void find(std::string pat){
		int patSize = pat.size();
		if (patSize > texSize)return;

		ull patHash = 0;
		rep(i, patSize)patHash = patHash * B + pat[i];

		rep(i, texSize - patSize + 1){
			if (TextHash(i, i + patSize) == patHash){
				printf("%d\n", i);
			}
		}

	}
};

int main(){
	std::string a, b;
	std::cin >> a >> b;

	RollingHash rh(a);
	rh.find(b);

	return 0;
}

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

int main(){
    int D,G;cin>>D>>G;
    int P[D],C[D];
    for(int i=0;i<D;i++){
        cin>>P[i]>>C[i];
    }int score,pro,temp;int ans=1000;
    for(int j=0;j<(1<<D);j++){
        pro=0;score=0;
        for(int k=0;k<D;k++){
            if(j&(1<<k)){
                pro+=P[k];
                score+=100*(k+1)*P[k]+C[k];
            }else{
                temp=k;
            }
        }if(score<G){
            int point=100*(temp+1);
            int norma=(G-score+point-1)/point;
            if(norma>=P[temp]){
                continue;
            }else{
                pro+=norma;
            }
        }ans=min(ans,pro);//cout<<pro<<endl;
    }cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, w; cin >> n >> w;
    // dp[i] = min weight to have value of i
    int dp[100001];
    for (int i = 0; i < 100001; i++) dp[i] = w + 1;
    dp[0] = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int wi, v; cin >> wi >> v;
        for (int j = 100000; j >= v; j--) {
            dp[j] = min(dp[j], dp[j - v] + wi);
            if (dp[j] <= w) ans = max(ans, j);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define BUG(x) cout << #x << " = " << x << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

long long n, lis[100005], dp[100005], u, v, deg[100005];
vector<long long> adj[100005];

bool dfs(int x) {
	// BUG(x);
	if (deg[x] == 1) {
		dp[x] = lis[x];
		return true;
	}
	dp[x] = 0;
	for (int nex: adj[x]) if (dp[nex] == -1) {
		if (!dfs(nex)) return false;
	}
	long long maxn = 0;
	long long sumn = 0;
	for (int nex: adj[x]) {
		maxn = max(maxn, dp[nex]);
		sumn += dp[nex];
	}
	if (sumn < lis[x] || sumn > 2 * lis[x]) return false;
	long long a = 2 * lis[x] - sumn;
	long long b = 2 * (sumn - lis[x]);
	if (b > 2 * (sumn - maxn)) return false;
	dp[x] = a;
	return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  FOR (i, 1, n) cin >> lis[i];
  if (n == 2) {
  	if (lis[1] == lis[2]) cout << "YES";
  	else cout << "NO";
  	return 0;
  }
  REP (i, n - 1) {
  	cin >> u >> v;
  	deg[u]++;
  	deg[v]++;
  	adj[v].pb(u);
  	adj[u].pb(v);
  }
  reset(dp, -1);
  int root = 1;
  FOR (i, 2, n) if (deg[i] != 1) {
  	root = i;
  	break;
  }
  if (dfs(root) && !dp[root]) cout << "YES";
  else cout << "NO";
}

Measured memory_bytes: 12416
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

static int a[3][100000];

class question {
public:
	int N;
	int dp() {
		static int memo[3][100000];
		REP(j, 3) memo[j][0] = a[j][0];
		FOR(i, 1, N) {
			REP(j, 3) {
				memo[j][i] = max(memo[(j + 1) % 3][i - 1], memo[(j + 2) % 3][i - 1]) + a[j][i];
			}
		}
		return max({ memo[0][N - 1],memo[1][N - 1],memo[2][N - 1] });
	}
	void ans() {
		cin >> N;
		REP(i, N) {
			REP(j, 3) {
				cin >> a[j][i];
			}
		}
		cout << dp() << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}

Measured memory_bytes: 2560