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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        vl h(n);
        rep(i, n) cin >> h[i];
        
        ll now = h[0];
        for (long long i = 1; i < n; ++i) {
            if (h[i] == now) continue;
            if (h[i] == now + 1) continue;
            if (h[i] > now) h[i]--, now = h[i];
            else {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1024
nml=input().split()
n,m,l=int(nml[0]),int(nml[1]),int(nml[2])
A_=[input() for i in range(n)]
B_=[input() for i in range(m)]
A,B=[],[]
for i in range(n):
    A_[i]=A_[i].split()
for i in A_:
    A.append(list(map(lambda i:int(i),i)))
for i in range(m):
    B_[i]=B_[i].split()
for i in B_:
    B.append(list(map(lambda i:int(i),i)))
AB=[]
for i in range(n):
    AB.append([])
for i in range(n):
    for j in range(l):
        AB[i].append(0)
for i in range(n):
    for j in range(l):
        for k in range(m):
            AB[i][j]+=(A[i][k]*B[k][j])
for i in AB:
    print(*i)


Measured memory_bytes: 8376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int along = 0;
		int blong = 0;
		int clong = 0;

		int h[] = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		// 0捨
		// 1a
		// 2b
		// 3c
		int ans = 9999999;
		int finalcost = 99999999;
		for (int i = 0; i <= Math.pow(4, n); i++) {
			String s = Integer.toString(i, 4);
			s = fixs(s, n);

			if (allin(s)) {
				finalcost = -30;
				along=0;
				blong=0;
				clong=0;
				char cs[] = s.toCharArray();
				for (int o = 0; o < cs.length; o++) {
					if (cs[o] == '1') {
						along += h[o];
						finalcost += 10;
					}
					if (cs[o] == '2') {
						blong += h[o];
						finalcost += 10;
					}
					if (cs[o] == '3') {
						clong += h[o];
						finalcost += 10;
					}
				}
				finalcost = finalcost + Math.abs(a - along)
						+ Math.abs(b - blong) + Math.abs(c - clong);
			}
			if (ans > finalcost) {
				ans = finalcost;
			}
		}
		System.out.println(ans);

	}

	static String fixs(String s, int n) {
		String s1 = "0";
		for (int i = s.length(); i < n; i++) {
			s = s1 + s;
		}
		return s;
	}

	static boolean allin(String s) {
		if ( s.contains("1") && s.contains("2")
				&& s.contains("3")) {
			return true;
		} else {
			return false;
		}
	}
}


Measured memory_bytes: 39648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

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

    string name;
    while(N){
        N--;
        name += 'a' + N%26;
        N /= 26;
    }

    rvs(name);
    cout << name << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  vector<int>dp(n);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
use std::io::Read;
use std::cmp::{max, min};

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = Vec::new();
    let mut a_max: usize = 0;
    for _ in 0..n {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        a.push(ai);
        a_max = max(a_max, ai);
    }

    let mut b_max = 0;
    let mut b = 0;
    for i in 0..n {
        let bi: usize = a[i];
        if bi == a_max {
            continue;
        }
        if b_max < min(bi, a_max - bi) {
            b_max = min(bi, a_max - bi);
            b = bi;
        }
    }

    return format!("{} {}", a_max, b);
}


Measured memory_bytes: 6396
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

vector<vector<ll>> memo;
vector<vector<ll>> map;

void DFS(ll d,ll r,ll oldmap,ll cnt){
	if(d<0)return;
	if(r<0)return;
	if(d>=memo.size())return;
	if(r>=memo[0].size())return;
	
	if(oldmap!=map[d][r])cnt++;
	if(memo[d][r]<=cnt)return;
	else memo[d][r]=cnt;
	
	DFS(d+1,r,map[d][r],cnt);
	DFS(d,r+1,map[d][r],cnt);

	return;
}

int main(){
	ll h; cin>>h;
	ll w; cin>>w;
	vector<string> s(h);
	REP(i,h)cin>>s[i];

	memo = vector<vector<ll>>(h,vector<ll>(w,INF));
	map = vector<vector<ll>>(h,vector<ll>(w));
	REP(i,h){
		REP(j,w){
			if(s[i][j]=='.')map[i][j]=0;
			else map[i][j]=1;
		}
	}

	DFS(0,0,0,0);
	/*
	cout<<endl;
	REP(i,h){
		REP(j,w){
			cout<<memo[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
	*/

	cout<<(memo[h-1][w-1]+1)/2<<endl;
	return 0;
}
/*
5 5
####.
###.#
##.##
#.###
.####

5 5
##..#
#..#.
#####
.#..#
#..##

5 5
.#...
.#.#.
.#.#.
.#.#.
...#.

*/

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
signed main() {
	int n, a[123456]; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] > a[i + 1] + 1) {
			cout << "No\n"; return 0;
		}
		a[i] = min(a[i], a[i + 1]);
	}
	cout << "Yes\n";
}

Measured memory_bytes: 1024
ls = input()
count = 0
if len(ls) == 0:
  print('0')
else:
  temp = ls[0] #一つ前のやつ
  ls = ls[1:]
  for i in ls:
    if i == temp:
      count += 1
      if i == '0':
        temp = '1'
      else:
        temp = '0'
    else:
      temp = i
print(count)

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

int main() {
  int N,a,b,c,d;
  cin>>N;
  a=N/1000,b=N%1000/100,c=N%100/10,d=N%10;
  
  if((a==b&&a==c)||(b==c&&b==d)){
    cout<<"Yes"<<endl;
  }
  
  else {
    cout<<"No"<<endl;
  }
}

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

#define rep(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define int long long

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (10000001)
#define MAX (1000000000000000000LL)
using namespace std;

signed main() {
	int n; cin >> n;
	if (n >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>
using namespace std;

int main() {
	int K, X;

	cin >> K >> X;

	if (500 * K >= X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String in_str;
			in_str = sc.next();
			if(in_str.equals("#"))
				break;
			boolean[] use = new boolean[26];
			for(int i = 0; i < use.length; i++) use[i] = false;
			ArrayList<String> ans = new ArrayList<String>();
			solve(in_str,0,use,ans);
			System.out.println(ans.size());
			Collections.sort(ans);
			if(ans.size() <= 10) {
				for(int i = 0; i < ans.size(); i++)
					System.out.println(ans.get(i));
			}
			else {
				for(int i = 0; i < 5; i++)
					System.out.println(ans.get(i));
				for(int i = ans.size()-5; i < ans.size(); i++)
					System.out.println(ans.get(i));
			}
		}
	}

	private static void solve(String str, int indx, boolean[] use, ArrayList<String> res) {
		if(indx == str.length()) {
				res.add(str);
			return;
		}
		if(str.charAt(indx) != 'z' && use[(int)(str.charAt(indx)-'a'+1)] == false) {
			use[(int)(str.charAt(indx)-'a'+1)] = true;
			StringBuffer sb = new StringBuffer(str);
			sb.setCharAt(indx,(char)(str.charAt(indx)+1));
			solve(sb.toString(), indx+1, use, res);
			use[(int)(str.charAt(indx)-'a'+1)] = false;
		}
		if(str.charAt(indx) == 'a' || use[(int)(str.charAt(indx)-'a')]) {
			solve(str, indx+1, use, res);
		}
	}
}

Measured memory_bytes: 59004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;
const int nmax=1000010;
ll fac[nmax],finv[nmax],inv[nmax];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
  COMinit();
  ll h,w,a,b;
  cin >> h >> w >> a >> b;
  ll ans=0;
  for(int i=0;i<h-a;i++){
    ans+=com(b+i-1,i)*com(w-b-1+h-i-1,h-i-1)%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> color(9,0);
    rep(i,n){
        ll a; cin>>a;
        if(a<3200) color[a/400]++;
        else color[8]++;
    }
    ll c=0;
    rep(i,8) if(color[i]) c++;
    if(c) cout << c;
    else cout << 1;
    cout << " " << c+color[8] << endl;
    return 0;
}

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

int main() {
	
	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	int N, X; std::cin >> N >> X;
	std::vector<int> L(N);
	for (int i = 0; i < N; i++)std::cin >> L[i];
	std::vector<int> D(N + 1);
	D[0] = 0;
	int ans = 1;
	for (int i = 1; i < D.size(); i++) {
		D[i] = D[i - 1] + L[i - 1];
		if (D[i] <= X)ans++;
	}
	std::cout << ans;

	return 0;
}

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

from collections import defaultdict, Counter

counted_a = Counter(A)
total = 0

for key, v in counted_a.items():
    total += v * (v-1) // 2

ans = []
for a in A:
    v = counted_a[a]
    t = total - v * (v-1) // 2 + (v-1) * (v-2) // 2
    ans.append(t)

print(*ans, sep='\n')

Measured memory_bytes: 33320
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = list(iss())
    for n in range(ord('a'), ord('z')+1):
        if N.count(chr(n)) % 2 != 0:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

	string s = "";
	string t = "";

	for (int i = 0; i < stoi(b); i++) {
		s += a;
	}
	for (int i = 0; i < stoi(a); i++) {
		t += b;
	}

	if (s <= t) cout << s << endl;
	else cout << t << endl;

	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = INF;
  rep(i,s.size()-t.size()+1) {
    int cnt = 0;
    rep(j,t.size()) {
      cnt += s[i+j]!=t[j];
    }
    ans = min(ans,cnt);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
def make2d(m,n)
  Array.new(m).map{Array.new(n,0)}
end


def min(x,y)
  if x > y
    return y
  else
    return x
  end
end

def align_ed(s,t)
  m = s.length()
  n = t.length()
  a = make2d(m+1,n+1)
  a[0][0] = 0
  for j in 1..n
    a[0][j] = a[0][j-1] + 1
  end
  for i in 1..m
    a[i][0] = a[i-1][0] + 1
  end
  for i in 1..m 
    for j in 1..n
      x = a[i-1][j-1]
      if s[i-1] != t[j-1]
        x += 1
      end
      y = a[i][j-1] + 1                         
      z = a[i-1][j] + 1
      a[i][j] = min(x,min(y,z))
    end
  end
  a[-1][-1]
end


s1 = gets.chomp
s2 = gets.chomp
puts align_ed(s1,s2)

Measured memory_bytes: 16696
#include <stdio.h>
#include <stdlib.h>

void DisplayArray(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

int BubbleSort(int A[], int N)
{
    int flag = 1;
    int count = 0;
    int j, tmp;

    while (flag) {
        flag = 0;
        for (j = N - 1; j != 0; j--) {
            if (A[j] < A[j - 1]) {
                tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                count++;
                flag = 1;
            }
        }
    }

    return count;
}

int main(void)
{
    int N, i, numOfExchanges;
    scanf("%d%*c", &N);
    int* A = (int*)malloc(sizeof(int) * N);

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

    numOfExchanges = BubbleSort(A, N);
    DisplayArray(A, N);
    printf("%d\n", numOfExchanges);

    return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,a[1000005],ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=2;i<=n;i++)
		if (a[i]==a[i-1])
		{
			if (a[i]+1==a[i+1]) a[i]+=2,ans++;
			else a[i]+=1,ans++;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    int p = sc.nextInt();
	    if(n==0 && p==0) break;

	    int pp = p;
	    int[] have = new int[n];
	    int turn = 0;
	    int winner = 0;
	    while(true){
		if(pp==1 && have[turn]==p-1){
		    winner = turn;
		    break;
		}else if(pp>0){
		    pp--;
		    have[turn]++;
		    turn = (turn+1)%n;
		}else{
		    pp = have[turn];
		    have[turn] = 0;
		    turn = (turn+1)%n;
		}
	    }

	    System.out.println(winner);
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 12000
#include <stdio.h>

int main(void) {
    char c;

    scanf("%c", &c);

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        printf("vowel\n");
    } else {
        printf("consonant\n");
    }

    return 0;
}

Measured memory_bytes: 128
def solve(string):
    x, k, d = map(int, string.split())
    x = abs(x)
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    if x < k * d:
        return str(min(x % (2 * d), abs((x % (2 * d)) - 2 * d)))
    else:
        return str(x - k * d)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

int main() {
	int	n;
	cin >> n;
	vector<double> v(n);
	rep(i, n)
		cin >> v.at(i);
	rep(i, n)
	{
		double	temp;
		cin >> temp;
		v.at(i) = abs(v.at(i) - temp);
	}
	cout << fixed << setprecision(6) << accumulate(v.begin(), v.end(), 0LL) << endl; 
	double	sum;
	rep(i, n)
		sum += v.at(i) * v.at(i);
	cout << fixed << setprecision(6) << sqrt(sum) << endl;
	sum = 0;
	rep(i, n)
		sum += pow(v.at(i), 3);
	cout << fixed << setprecision(6) << pow(sum, 1.0 / 3.0) << endl; 
	cout << fixed << setprecision(6) << *max_element(v.begin(), v.end()) << endl; 
}



Measured memory_bytes: 3488
#include<stdio.h>
int a[100001];
int main(){
  int n,i,max,max1;
  scanf("%d",&n);
  for(i=0;i<n;++i){
    scanf("%d",&a[i]);
    if(i==0){
      max=0;
      max1=0;
    }
    else{
      if(a[i]<=a[i-1])
        ++max1;
       else{
         if(max1>max)
         max=max1;
         max1=0;
       }
    }
  }
  if(max1>max)
  max=max1;
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = Integer.parseInt(sc.next());
    static int[] a = new int[100000];

    public static void main(String[] args){
        int q,key,sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        q = Integer.parseInt(sc.next());
        for (int i = 0; i < q; i++) {
            key = Integer.parseInt(sc.next());
            if(binarySearch(key)) sum++;
        }
        System.out.println(sum);
    }

    static boolean binarySearch(int key){
        int left = 0;
        int right = n;
        int mid;
        while(left < right){
            mid = (left + right)/2;
            if(key == a[mid]) return true;
            if (key > a[mid]) left = mid + 1;
            else if (key < a[mid]) right = mid;
        }
        return false;
    }
}


Measured memory_bytes: 69760
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] array = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int num = sc.nextInt();
    System.out.println(array[num-1]);
  }
}


Measured memory_bytes: 22608
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
 while(1){
  int n;
  cin >> n;
  if(n == 0) break;
  int s[n];
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }

  int sum = 0;
  for(int i = 0; i < n; i++){
    sum += s[i];
  }
  double mean = 1.0 * sum / n;
  double var = 0.0;
  for(int i = 0; i < n; i++){
    var += 1.0 * (s[i] - mean) * (s[i] - mean);
   }
  double SD = sqrt(1.0 * var / n);
  printf("%f\n", SD);
  }
 return 0;
}


Measured memory_bytes: 3212
from copy import deepcopy

class SegTree():
    def segfunc(self, x, y):
        return x + y

    def __init__(self, ide, n, init_val):
        self.ide_ele = ide
        self.num = 2**(n-1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        for i in range(n):
            self.seg[i+self.num-1] = init_val[i]    
        for i in range(self.num-2,-1,-1):
            self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    def query(self, p, q):#p <= x < q
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res

def main():
    n, k = map(int, input().split())
    cum = [None]*(n+1)
    cum[0] = 0
    for i in range(1, n+1):
        cum[i] = int(input())
        cum[i] += cum[i-1]
    for i in range(n+1):
        cum[i] -= k*i
    srt = deepcopy(cum)
    srt.sort()
    dic = {}
    cnt = 0
    for i in range(n+1):
        if not srt[i] in dic:
            dic[srt[i]] = cnt
            cnt += 1
    tmp = [0]*cnt
    tmp[dic[cum[0]]] += 1
    seg = SegTree(0, cnt, tmp)
    ans = 0
    for i in range(1, n+1):
        p = dic[cum[i]]
        ans += seg.query(0, p+1)
        tmp[p] += 1
        seg.update(p, tmp[p])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 120848
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! { a: u32, b: u32, k: u8 }
    let (mut a, mut b) = (a, b);
    {
        let (mut x, mut y) = (&mut a, &mut b);
        for _ in 0..k {
            *x /= 2;
            *y += *x;
            std::mem::swap(&mut x, &mut y);
        }
    }
    println!("{} {}", a, b);
}

Measured memory_bytes: 4352
def main():
    a = list(input())
    b = list(input())
    c = list(input())
    tmp = 'a'
    while True:
        if tmp == 'a':
            if len(a) == 0:
                print('A')
                break
            else:
                tmp = a.pop(0)

        elif tmp == 'b':
            if len(b)==0:
                print('B')
                break
            else:
                tmp = b.pop(0)

        else:
            if len(c) == 0:
                print('C')
                break
            else:
                tmp = c.pop(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

signed main() {
  int n; cin >> n;
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  
  sort(l.begin(), l.end());
  int ans = 0;
  rep(i,n) for(int j=i+1; j<n; j++) for(int k=j+1; k<n; k++) {
    if(l[i] == l[j]) continue;
    if(l[i] == l[k]) continue;
    if(l[j] == l[k]) continue;
    assert(l[k] > l[i] && l[k] > l[j]);
    if(l[k] >= l[i] + l[j])  continue;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
import re

s = "".join("." if i == "?" else i for i in input())
t = input()

lent = len(t)
mstart = -1
for start in range(len(s) - lent + 1):
    m = re.match(re.compile(s[start:start+lent]), t)    
    if m:
        mstart = start
else:
    if mstart == -1:
        print("UNRESTORABLE")
    else:
        s = s[:mstart] + t + s[mstart+lent:]
        print(s.replace(".", "a"))

Measured memory_bytes: 9820
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
    int N,D;
    cin>>N>>D;
    cout<<ceil((double)N/(2.0*D+1.0))<<endl;
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
  int H,W;
  cin >> H >> W;  
  vector<int> A;
  A.resize('z' - 'a' + 1);
  string str;
  for (int i = 0; i < H; ++i) {
    cin >> str;
    for (int j = 0; j < W; ++j) {
      A[str[j] - 'a']++;
    }
  }
  // odd x odd
  if ((H&1) && (W&1)) {
    for (auto &a: A) {
      if (a&1) {
        a--;
        break;
      }
    }
    if (all_of(A.begin(), A.end(), [] (int a){ return a % 2 == 0;})) {
      int oddnum = H + W - 2;
      int rem = 0;
      for (auto a: A) {
        rem += a % 4;
      }
      if (oddnum - rem >= 0 && !((oddnum - rem) & 3)) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }    
    // odd x even
  } else if ((H&1) || (W&1)) {
    int neven =  (H&1) ? W : H;
    if (all_of(A.begin(), A.end(), [] (int a){ return a % 2 == 0;})) {
      int rem = 0;
      for (auto a: A) {
        rem += a % 4;
      }
      if (neven - rem >= 0 && !((neven - rem) & 3)) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  } else {
    if (all_of(A.begin(), A.end(), [] (int a){ return a % 4 == 0;})) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int cnt1[4010][4010], cnt2[4010][4010], trakm1[4010][4010], trakm2[4010][4010];
int f1(int x, int y, int x1, int y1){
  int tmp=0;
  if(x!=0)
    tmp-=trakm1[x-1][y1];
  if(y!=0)
    tmp-=trakm1[x1][y-1];
  if(x!=0&&y!=0)
    tmp+=trakm1[x-1][y-1];
  tmp+=trakm1[x1][y1];
  return tmp;
}
int f2(int x, int y, int x1, int y1){
  int tmp=0;
  if(x!=0)
    tmp-=trakm2[x-1][y1];
  if(y!=0)
    tmp-=trakm2[x1][y-1];
  if(x!=0&&y!=0)
    tmp+=trakm2[x-1][y-1];
  tmp+=trakm2[x1][y1];
  return tmp;
}
int main(){
  int n, k, a, b;
  char c;
  while(cin>>n>>k){
    int kk=2*k, bb=0;
    for(int i=0; i<n; ++i){
      cin>>a>>b>>c;
      a%=kk;
      b%=kk;
      if(c=='B'){
        ++cnt1[a][b];
        ++cnt1[a+kk][b];
        ++cnt1[a][b+kk];
        ++cnt1[a+kk][b+kk];
        ++bb;
      }
      else{
        ++cnt2[a][b];
        ++cnt2[a+kk][b];
        ++cnt2[a][b+kk];
        ++cnt2[a+kk][b+kk];
      }
    }
    trakm1[0][0]=cnt1[0][0];
    trakm2[0][0]=cnt2[0][0];
    for(int i=1; i<kk+kk; ++i){
      trakm1[0][i]=cnt1[0][i]+trakm1[0][i-1];
      trakm2[0][i]=cnt2[0][i]+trakm2[0][i-1];
      trakm1[i][0]=cnt1[i][0]+trakm1[i-1][0];
      trakm2[i][0]=cnt2[i][0]+trakm2[i-1][0];
    }
    for(int i=1; i<kk+kk; ++i){
      for(int j=1; j<kk+kk; ++j){
//        cout<<i<<" "<<j<<" "<<cnt1[i][j]<<" "<<cnt2[i][j]<<endl;
        trakm1[i][j]=trakm1[i-1][j]+trakm1[i][j-1]-trakm1[i-1][j-1]+cnt1[i][j];
        trakm2[i][j]=trakm2[i-1][j]+trakm2[i][j-1]-trakm2[i-1][j-1]+cnt2[i][j];
//        trakm1[i+kk][j]=trakm1[i][j+kk]=trakm1[i+kk][j+kk]=trakm1[i][j];
//        trakm2[i+kk][j]=trakm2[i][j+kk]=trakm2[i+kk][j+kk]=trakm2[i][j];
//        cout<<i<<" "<<j<<"___"<<trakm1[i][j]<<endl;
      }
    }
//    for(int i=0; i<kk+kk; ++i){
//      for(int j=0; j<kk+kk; ++j){
//        cout<<cnt2[i][j]<<" ";
//      }
//      cout<<endl;
//    }
    int mx=0, tmp, x1, x2, x3, x4, y1, y2, y3, y4;
    for(int i=0; i<kk; ++i){
      for(int j=0; j<kk; ++j){
        x1=i;y1=j;x2=i+k-1;y2=j+k-1;
        x3=x2+1;y3=y2+1;x4=x3+k-1;y4=y3+k-1;
        tmp=bb-f1(x1, y1, x2, y2)-f1(x3, y3, x4, y4);
        tmp+=f2(x1, y1, x2, y2)+f2(x3, y3, x4, y4);
//        cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<",,," <<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
//        cout<<f1(x1, y1, x2, y2)<<" "<<f1(x3, y3, x4, y4)<<"++"<<tmp<<endl;
//        cout<<f2(x1, y1, x2, y2)<<" "<<f2(x3, y3, x4, y4)<<"++"<<tmp<<endl;
        mx=max(mx, tmp);
      }
    }
    cout<<mx<<endl;
  }
  return 0;
}




Measured memory_bytes: 251392
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin >> h[i];
    int dp[n+1]={0,};
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i=3;i<=n;i++)
        {
            dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]),dp[i-1] + abs(h[i] - h[i-1])) ;
        }
        cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n, q;
        int i, l, r, p, conut;
        int[] A, m;

        n = sc.nextInt();
        A = new int[n];
        for (i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }

        q = sc.nextInt();
        m = new int[q];
        for (i = 0; i < q; i++) {
            m[i] = sc.nextInt();
        }

        conut = 0;

        for(i=0;i<q;++i){

            r = n/2;
            l = 0;
            p = n;

            while(true){
                
                if(m[i] == A[r]){
                    conut++;
                    break;
                }else if(l == p || p-l == 1){
                    break;
                }else if(m[i] > A[r]){
                    l = r;
                    r = p - (p-l)/2;
                }else{
                    p = r;
                    r = p - (p-l)/2;
                }

            }

        }
        System.out.println(conut);
    }
}



Measured memory_bytes: 68724
#include <iostream>

using namespace std;

int main()
{
	int A, B, tmp1, tmp2, tmp3;
	cin >> A >> B;
	tmp1 = A + B;
	tmp2 = A - B;
	tmp3 = A * B;
	if (tmp1 >= tmp2 && tmp1 >= tmp3)
	{
		cout << tmp1 << endl;
	}
	else if (tmp2 >= tmp1 && tmp2 >= tmp3)
	{
		cout << tmp2 << endl;
	}
	else if (tmp3 >= tmp1 && tmp3 >= tmp2)
	{
		cout << tmp3 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

lol a, b, n;
lol ans(lol x){
  return (a * x / b - a * (x / b));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  cin >> a >> b >> n;
  cout << ans(min(n, b - 1)) << '\n';
  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int shu[5][5];

int main()
{
	int flag = 0;
	int a1, a2, a3, b1, b2, b3;
	a1 = a2 = a3 = b1 = b2 = b3 = 0;
	for(int i = 1; i <= 3; i++)
		for(int j = 1; j <= 3; j++)
		{
			scanf("%d", &shu[i][j]);
		}
	for(int i = 1; i <= 10000000; i++)
	{
		a1 = i;
		b1 = shu[1][1] - a1;
		b2 = shu[1][2] - a1;
		b3 = shu[1][3] - a1;
		a2 = shu[2][1] - b1;
		a3 = shu[3][1] - b1;
		if(b2 + a2 == shu[2][2] && a2 + b3 == shu[2][3] && a3 + b2 == shu[3][2] && a3 + b3 == shu[3][3]) {
			flag = 1;
			break;
		}
	}
	if(flag == 1) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int H, W;
    cin >> H >> W;
    string S[H];
    rep(i, H) cin >> S[i];
    int d[H][W];
    queue<int> que;
    rep(i, H) rep(j, W){
        if(S[i][j] == '#'){
            d[i][j] = 0;
            que.push(i*W+j);
        }
        else d[i][j] = inf;
    }
    while(!que.empty()){
        int p = que.front();
        que.pop();
        int x = p/W, y = p%W;
        rep2(i, -1, 1) rep2(j, -1, 1){
            if(abs(i)+abs(j) != 1) continue;
            int nx = x+i, ny = y+j;
            if(nx < 0 || H <= nx || ny < 0 || W <= ny) continue;
            if(chmin(d[nx][ny], d[x][y]+1)) que.push(nx*W+ny);
        }
    }
    int ans = 0;
    rep(i, H) rep(j, W) chmax(ans, d[i][j]);
    cout << ans << endl;
}

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

void map_print(int);

int main(){
  int N;
  int i = 0;
  while(cin >> N && N != 0){
    //    cout << N << endl;
    i++;
    cout << "Case " << i << ":" << endl;
    map_print(N);
  }
}

void map_print(int N){
  int j=0; int k=0; int count = 1;
  int map_[N][N];
 
  // 左上半分の数字埋め
  for(int i=0;i<N;i++){
    int var_i = i;
    if(i%2){
      for(int k=0;k<=i;k++){
	map_[k][i-k] = count++;
      }
    }
    else{
      for(int k=0;k<=i;k++){
	map_[i-k][k] = count++;
      }
    }
  }

  //右下半分残りの数字埋め
  for(int i=0;i<N;i++){
    for(int j=0;j<N-i-1;j++){
      map_[N-i-1][N-j-1] = N*N - map_[i][j] + 1;
    }
  }


  for(int i=0;i<N;i++){
    for(int l=0;l<N;l++){
      cout << setw(3) << right << map_[i][l];
    }
    cout << endl;
  }
  
}

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

int main () {
  int a[4];
  for (int i = 0; i < 4; i++) {
    cin >> a[i];
  }
  sort(a,a+4);
  if (a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9) {
    cout <<"YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    map<string,int> cnt;
    rep(i,n){
        string s; cin>>s;
        cnt[s]++;
    }
    int m; cin>>m;
    rep(i,m){
        string s; cin>>s;
        cnt[s]--;
    }
    int ans=0;
    for(auto e:cnt){
        chmax(ans, e.se);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int[] m = new int[N];
    int sum = X;
    int cnt = 0;
    for(int i=0; i<N; i++){
      m[i] = sc.nextInt();
      sum -= m[i];
      cnt++;
    }
    Arrays.sort(m);
    while(m[0] <= sum){
      sum -= m[0];
      cnt++;
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 35788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
   int n, k;
   cin>>n>>k;
   ll a[n];
   for(int i=0; i<n; i++){
       cin>>a[i];
   }
   ll mn = 1e18;
    for(int i=0; i<n-k+1; i++){
        ll val;
        if(a[i]*a[i+k-1]>=0){
            val = max(abs(a[i]), abs(a[i+k-1]));
        }else{
            val = abs(a[i])+abs(a[i+k-1])+min(abs(a[i]),abs(a[i+k-1]));
        }
        mn = min(mn, val);
    }
    cout<<mn<<endl;


}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main() {
	int Sx, Sy, Tx, Ty;
	cin >> Sx >> Sy >> Tx >> Ty;
	for (int i = Sy; i < Ty; i++) {
		cout << 'U';
	}
	for (int i = Sx; i < Tx; i++) {
		cout << 'R';
	}
	for (int i = Sy; i < Ty; i++) {
		cout << 'D';
	}
	for (int i = Sx; i < Tx + 1; i++) {
		cout << 'L';
	}
	for (int i = Sy; i < Ty + 1; i++) {
		cout << 'U';
	}
	for (int i = Sx; i < Tx + 1; i++) {
		cout << 'R';
	}
	cout << "DR";
	for (int i = Sy; i < Ty + 1; i++) {
		cout << 'D';
	}
	for (int i = Sx; i < Tx + 1; i++) {
		cout << 'L';
	}
	cout << 'U' << endl;
}

Measured memory_bytes: 256
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 1e6+1;
const ll inf = 1e8;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pwr(x, MOD-2);
}

void solve()
{
    int n,a,b; cin>>n>>a>>b;
    cout<<min(n*a, b);
}

signed main()
{
// #ifndef ONLINE_JUDGE
//     freopen("ladders_and_snakes_sample_input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    
    int t=1;
    // cin >>t;
    for(int tt=1;tt<=t;tt++){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int MAXN=110000;
int r[MAXN];
vector<int> g[MAXN];
bool dfs(int u, int f, int c)
{
	if (~r[u]) return c==r[u];
	r[u]=c; bool k=1;
	for (int i=0; i<g[u].size(); i++)
	{
		int v=g[u][i];
		k&=dfs(v, u, c^1);
	}
	return k;
}
int main()
{
//	freopen("C.in", "r", stdin);
//	freopen("C.out", "w", stdout);
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	memset(r, -1, sizeof r);
	int p=0, c=0, d=0;
	for (int i=1; i<=n; i++)
		if (r[i]==-1)
		{
			if (g[i].size()==0) p++;
			else if (dfs(i, 0, 0)) c++;
			else d++;
		}
	printf("%lld\n", 1ll*p*n+1ll*(n-p)*p+2ll*c*c+1ll*d*(d+c*2));
	return 0;
}

Measured memory_bytes: 10240
import sys

def solve():
    c = int(raw_input())
    for i in range(c):
        n = int(raw_input())
        data = map(int, raw_input().split())
        u,d = 0,0
        for i in range(len(data) - 1):
                if data[i + 1] - data[i] > 0 and data[i + 1] - data[i] > u:
                        u = data[i + 1] - data[i] 
                elif data[i + 1] - data[i] < 0 and data[i] - data[i + 1] > d :
                        d = data[i] - data[i + 1]
        print u,d
if __name__ == "__main__":
    solve()

Measured memory_bytes: 4248
n = gets.to_i
ans = 'No'
cnt = 0
n.times do
  d1, d2 = gets.split.map(&:to_i)
  if d1 == d2
    cnt += 1
  else
    cnt = 0
  end
  if cnt == 3
    ans = 'Yes'
  end
end
puts ans

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

// Data structures.
struct Point {
    double x, y;
    Point(double x = 0, double y = 0) : x(x), y(y) {}
    Point(const Point& p) : x(p.x), y(p.y) {}

    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }

    bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; }
    bool operator==(const Point& p) const { return fabs(x - p.x) < 1e-10 && fabs(y - p.y) < 1e-10; }

    static double norm(const Point& p) { return sqrt(p.x * p.x + p.y * p.y); }
    static double dot(const Point& p1, const Point& p2) { return p1.x * p2.x + p1.y * p2.y; }
    static double cross(const Point& p1, const Point& p2) { return p1.x * p2.y - p1.y * p2.x; }
};

struct Segment {
    Point s, t;
};

int ccw(const Point& p1, const Point& p2, const Point& p) {
    double cr = Point::cross(p2 - p1, p - p1);
    if (cr > 0) return 1;
    if (cr < 0) return -1;
    // p, p1, p2.
    if (Point::dot(p2 - p1, p - p1) < 0) { return 2; }
    // p1, p2, p.
    if (Point::dot(p - p2, p1 - p2) < 0) { return -2; }
    // p is in [p1, p2].
    return 0;
}

bool intersect(const Segment& s1, const Segment& s2) {
    bool ok1 = ccw(s1.s, s1.t, s2.s) * ccw(s1.s, s1.t, s2.t) <= 0;
    bool ok2 = ccw(s2.s, s2.t, s1.s) * ccw(s2.s, s2.t, s1.t) <= 0;
    return ok1 && ok2;
}

double distance(const Segment& s, const Point& p) {
    if (Point::dot(s.t - s.s, p - s.s) < 0) { return Point::norm(p - s.s); }
    if (Point::dot(s.s - s.t, p - s.t) < 0) { return Point::norm(p - s.t); }
    return abs(Point::cross(s.t - s.s, p - s.s)) / Point::norm(s.t - s.s);
}

double distance(const Segment& s1, const Segment& s2) {
    if (intersect(s1, s2)) { return 0; }
    double ans = DBL_MAX;
    ans = min(ans, distance(s1, s2.s));
    ans = min(ans, distance(s1, s2.t));
    ans = min(ans, distance(s2, s1.s));
    ans = min(ans, distance(s2, s1.t));
    return ans;
}

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

    int q;
    cin >> q;

    rep(i, 0, q) {
        Segment s1, s2;
        cin >> s1.s.x >> s1.s.y >> s1.t.x >> s1.t.y;
        cin >> s2.s.x >> s2.s.y >> s2.t.x >> s2.t.y;
        printf("%.10f\n", distance(s1, s2));
    }

    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    
    vector<pair<double, double>> pos(N);
    for(int i = 0; i < N; i++) {
        cin >> pos[i].first >> pos[i].second;
    }

    double sum = 0;
    int tt  = 0;
    for(int i = 0; i < N-1; i++) {
        for(int j = i+1; j < N; j++) {
            sum += pow((pow(abs(pos[i].first - pos[j].first), 2) + pow(abs(pos[i].second - pos[j].second), 2)), 0.5);
            tt ++;
        }
    }

    int tmp = 1;
    for(int i = 1; i < N+1; i++) {
        tmp *= i;
    }

    sum *= 2 * tmp / N;
    double ave = 0;
    ave = sum / tmp;

    printf("%.10f", ave);
    // cout << ave << endl;
    
 
    return 0;
}

Measured memory_bytes: 640
H, W = [int(x) for x in input().split(" ")]

def f(h, w):
    if h == 1 or w == 1:
        return 1
    if h % 2 == 0 and w % 2 == 0:
        return (h // 2) * w
    elif h % 2 == 1 and w % 2 == 0:
        return f(h - 1, w) + w // 2
    elif h % 2 == 0 and w % 2 == 1:
        return f(h, w - 1) + h // 2
    else:
        return f(h - 1, w) + w // 2 + 1

print(f(H, W))

Measured memory_bytes: 3064
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

	public void Proc()
	{
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        while(true) {
            int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            if(inpt.All(a=>a==0)) {
                break;
            }
            ans.AppendLine(GetAns(inpt[0], inpt[1]).ToString());
        }
        Console.Write(ans.ToString());
    }

    private int GetAns(int n, int x) {
        int ans = 0;
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i + 1; j <= n; j++) {
                int diff = x - (i + j);
                if (diff <= j) {
                    break;
                }
                if (diff > n) {
                    continue;
                }
                ans++;
            }
        }
        return ans;
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


5 9
0 0


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

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

int main() {
	int n , num;
	scanf("%d",&n);
	vector< pair<int,int> > v(n);
	for(int i = 0 ; i < n ; ++i){
		scanf("%d",&num);
		v[i].first = num;
		v[i].second = i+1;
	}
	sort(v.begin(),v.end());
	for(int i = 0 ; i < n ; ++i)printf("%d ",v[i].second);
	return 0;
}

Measured memory_bytes: 1536