akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<array<char, 10>> s(n);
    int x = 0;
    for (int i = 0; i < n; i++) {
        char c[11] = {};
        cin >> c;
        memcpy(&s[i], c, 10);
    }
    sort(s.begin(), s.end());

    vector<int> c(n);
    array<char, 10> t;
    int k, l = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == t) {
            k++;
        } else {
            t = s[i];
            k = 0;
        }
        c[i] = k;
        l = max(l, k);
    }

    for (int i = 0; i < n; i++) {
        if (c[i] == l) {
            char c[11] = {};
            memcpy(c, &s[i], 10);
            cout << c << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
#define min(a,b)(a<b?a:b)
int H,W,M[60][60],i,j;
int main()
{
	scanf("%d%d",&H,&W);
	for(i=0;i<=H;i++)M[i][0]=100000;
	for(i=0;i<=W;i++)M[0][i]=100000;
	M[0][1]=0;
	for(i=1;i<=H;i++)
		for(j=1;j<=W;j++)
		{
			scanf("%1d",&M[i][j]);
			M[i][j]+=min(M[i-1][j],M[i][j-1]);
		}
	printf("%d\n",M[H][W]);
	return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std ;
#define N 1000000007
#define ll unsigned long long
int main()
{
    ll n ;
    cin >> n ;
    ll a,b,x,xx , x1 , ans =0 ; ;
    cin >> a >> b >> x1 ;
    for(int i =0 ; i < n-1 ; i++)
    {
        ll x ;
        cin >> x ;
        xx = x - x1 ;
        xx = xx * a ;
        if(xx < b)
            ans += xx ;
        else
            ans+= b ;

        x1 = x ;
    }
    cout << ans << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,K;
const int fish=1e9+7;
int a[10005],b[10005],pd[5005];
long long g[5005],dp[5005][5005];
int cnt[5005][5005];
int main(){
	scanf("%d%d",&N,&K);
	for (int i=1;i<=K;i++){
		scanf("%d%d",&a[i],&b[i]);
		pd[a[i]]=b[i];
		pd[b[i]]=a[i];
	}
	N<<=1;
	g[0]=1;
	for (int i=2;i<=N;i+=2)
		g[i]=1ll*g[i-2]*(i-1)%fish;
	for (int i=1;i<=N;i++){
		for (int j=i;j<=N;j++)
			cnt[i][j]=(cnt[i][j-1]+(!pd[j]))%fish;
	}
	for (int i=1;i<=N;i++)
		for (int j=i;j<=N;j++){
			bool pdd=false;
			for (int k=i;k<=j;k++){
				if (pd[k]&&(pd[k]<i||pd[k]>j)){
					pdd=true;
					break;
				}
			}
			if (pdd) continue;
			dp[i][j]=g[cnt[i][j]];
			for (int k=i+1;k<=j-1;k++)
				dp[i][j]=(dp[i][j]-(1ll*dp[i][k]*g[cnt[k+1][j]]%fish)+fish)%fish;
		}
	long long ans=0;
	for (int i=1;i<=N;i++)
		for (int j=i;j<=N;j++)
			ans=(ans+1ll*dp[i][j]*1ll*(g[(N/2-K)*2-cnt[i][j]])%fish)%fish;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 37760
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int p[200000];
int n,m;
int cnt=0;

char s[50][50];

int main() 
{
    int h,w;
    cin>>h>>w;
    rep(i,h) rep(j,w) cin>>s[i][j];
    int flag=1;
    rep(i,h) rep(j,w){
      if(s[i][j]=='#'){
          int mini=1;
          if(i) if(s[i-1][j]=='#') mini=0;
            if(j) if(s[i][j-1]=='#') mini=0;
              if(i!=h-1) if(s[i+1][j]=='#') mini=0;
                if(j!=w-1) if(s[i][j+1]=='#') mini=0;
        if(mini) {
            flag=0;
            break;
        }
      }
    }

    if(flag){
    cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }

	return 0;
}


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

int main(){
  int n,k; cin>>n >>k;
  double sum=0;
  for(int i=1;i<=n;i++){
    double ans=1.0/n;
    int now=i;
    while(now<k){
      now*=2;
      ans/=2;
    }
    sum+=ans;
  }
  printf("%.12f\n",sum);
}

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

s = sum(B)

for i in range(N-1):
    if A[i+1]-A[i]==1:
        p=A[i]
        s +=C[p-1]
print(s)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main (void) {
    double x1,x2,y1,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%lf",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      string s;
      cin >> s;
      int left = (s[0] - '0') * 10 + (s[1] - '0');
      int right = (s[2] - '0') * 10 + (s[3] - '0');

      if(left > 0 && left <=12 && right > 0 && right <= 12){
            cout << "AMBIGUOUS";
      }else if(left > 0 && left <=12){
            cout << "MMYY";
      }else if(right > 0 && right <= 12){
            cout << "YYMM";
      }else{
            cout << "NA";
      }
      return 0;
}

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

bool isPal(string s)
{
    int start=0,last=s.length()-1;
    while(start<=last)
    {
        if(s[start]!=s[last])
            return false;
        start++;
        last--;
    }
    return true;
}

bool isStrong(string s)
{
    if(!isPal(s))
        return false;
    int l=s.length();
    int x=(l-1)/2;
    string start = s.substr(0,x);
    if(!isPal(start))
        return false;

    string last = s.substr(x+1,l);
    if(!isPal(start))
        return false;
    return true;
}

int main()
{
    string s;
    cin>>s;
    if(isStrong(s))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  int F[N][10]={};
  rep(i,N)rep(j,10) cin >> F[i][j];
  int P[N][10]={};
  rep(i,N)rep(j,11) cin >> P[i][j];
  int ans=-9999999999;
  rep(s,1<<10){//店のオンオフ全探索
    if(s==0) continue;
    int res=0,c[N]={};
    //cout << "all:" << bitset<10>(s) << endl;
    int t=0;
    rep(i,10){//一桁ずつチェック
      if(s>>i & 1){
        rep(j,N){
          if(F[j][i]==1) c[j]++;
        }
      }
    }
    //cout << bitset<3>(t) << endl;
    rep(i,N) res+=P[i][c[i]];
    //cout << ans << endl;
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int r, g;
	cin >> r >> g;
	dump(r + (g- r) * 2)
}

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

using namespace std;

int main(){
  long long n, a[200009];
  long long ans=0;
  map<long long, long long> m;
  cin >> n;
  for(long long i=0;i<n;i++){
    cin >> a[i];
    m[a[i]]++;
  };
  for(auto itr = m.begin();itr!=m.end();itr++){
    long long value = itr->second;
    ans += value*(value-1)/2;
  }
  for(long long i=0;i<n;i++){
    long long value = m[a[i]];
    cout << ans - value*(value-1)/2 + (value-1)*(value-2)/2 << endl;
  }
}


Measured memory_bytes: 11008
N=int(input())
a=[0]+list(map(int, input().split()))
b=[0]*(N+1)

for i in range(N, 0, -1):
  x=sum(b[2*i::i])
  
  if x%2!=a[i]:
    b[i]=1
    
print(sum(b))
for i in range(1, N+1):
  if b[i]==1:
    print(str(int(i)), end=' ')

Measured memory_bytes: 8756
let id x = x
let n = Scanf.scanf "%d\n" id
let ar = Array.init n (fun _ -> Scanf.scanf "%d " id)

let avg_rem =
  let sum = Array.fold_left ( + ) 0 ar in (sum / n, sum mod n)

let calc avg = 
  Array.fold_left (fun pre x -> pre + (x - avg) * (x - avg)) 0 ar

let () =
  (match avg_rem with
   | (avg, 0) -> calc avg
   | (avg, _) -> min (calc avg) (calc (avg + 1)))
  |> Printf.printf "%d\n"


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N;
    ist >> N;

    /* ------- 計算 ------- */

    ost << ceil((double)N / 1000)* 1000 - N  << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


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

int main() {
  int X, Y;
  cin >> X >> Y;
  int counter = 1;
  for (int i = 0; i < X + 1; i++) {
    int Z;
    Z = i * 4 + (X - i) * 2;
    if (Z == Y)
      counter *= 0;
    else if (Z != Y)
      counter *= 1;
  }
  if (counter == 0)
    cout << "Yes" << endl;
  else if (counter != 0)
    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, q;
string s;

int main() {
	cin >> n >> q >> s;
	
	s = "x" + s + "x";
	vector<int> v(n + 2);
	inc(i, n + 1) {
		v[i + 1] = v[i] + (s.substr(i, 2) == "AC" ? 1 : 0);
	}
	
	inc(qq, q) {
		int l, r;
		cin >> l >> r;
		r++;
		int z = v[r] - v[l] - (s.substr(r - 1, 2) == "AC" ? 1 : 0);
		cout << z << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 1404
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

w = input()
while w != "":
    if w.count(w[0])%2==0:
        w = w.replace(w[0],"")
    else:
        break
if w == "":
    print("Yes")
else:
    print("No")

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

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    string S, T;
    cin >> S >> T;
    int ans = 0;

    for(int i=0; i<3; i++)
        ans += (S[i] == T[i]);

    cout << ans << "\n";
    return 0;
}


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


int main() {
  int N, K;
  cin >> N >> K;
  int A[N];
  for(int i = 0; i < N; i++) cin >> A[i];
  long long total = 0,buf;
  for(int i = 0; i < K;i++) total += A[i];
  for(int i = K; i < N;i++){
    buf = total;
    total -= A[i-K];
    total += A[i];
    if(total > buf) cout << "Yes" << endl;
    else cout << "No" << endl;
    
  }
}


Measured memory_bytes: 4416
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, a[101], ans=999999999, sum;
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=-100; i<=100; i++)
    {
        sum=0;
        for (int j=0; j<n; j++) sum+=(a[j]-i)*(a[j]-i);
        ans=min(ans, sum);
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[52],dp[52][52][2502];
int main() {
	ll n,s;
	cin>>n>>s;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[0][0][0]=1;
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			for(int k=0;k<=2500;k++){
				if(j-1>=0&&k-a[i]>=0){
				dp[i][j][k]+=dp[i-1][j-1][k-a[i]];
				}
				dp[i][j][k]+=dp[i-1][j][k];
				if(i==n&&j*s==k&&j!=0){
					//cout << i<<" "<< j<< " "<< k<<endl;
					ans+=dp[i][j][k];
					//cout << ans<<endl;
				}
			}
		}
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 50048
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let h_n = lines.next().unwrap().unwrap();
    let mut h_n = h_n.split_whitespace();
    let h: i32 = h_n.next().unwrap().parse().unwrap();
    let n: i32 = h_n.next().unwrap().parse().unwrap();
    let mut a: Vec<i32> = Vec::new();
    let mut b: Vec<i32> = Vec::new();
    for _ in 0..n {
        let a_b = lines.next().unwrap().unwrap();
        let mut a_b = a_b.split_whitespace();
        a.push(a_b.next().unwrap().parse().unwrap());
        b.push(a_b.next().unwrap().parse().unwrap());
    }

    let mut dp: Vec<Option<i32>> = vec![None; h as usize + 1];

    let ans = solve(h, &mut dp, &a, &b);
    println!("{}", ans);
}

fn solve(h: i32, dp: &mut Vec<Option<i32>>, a: &[i32], b: &[i32]) -> i32 {
    if let Some(result) = dp[h as usize] {
        return result;
    }
    let mut min = if h - a[0] <= 0 {
        b[0]
    } else {
        solve(h - a[0], dp, a, b) + b[0]
    };
    for i in 1..a.len() {
        let value = if h - a[i] <= 0 {
            b[i]
        } else {
            solve(h - a[i], dp, a, b) + b[i]
        };
        min = std::cmp::min(min, value);
    }
    dp[h as usize] = Some(min);
    min
}


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

using namespace std;

const double pi = 3.14159265358979323846;
const int mod = 1000000007;

int main(){
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      cout << i << "x" << j << "=" << i*j << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2976
import string
alp=string.ascii_lowercase
s=input()
k=int(input())
ans=[]
i=0
while i<len(s)-1:
    t=s[i]
    d=(26-alp.index(t))%26
    if d<=k:
        k-=d
        ans.append('a')
    else:
        ans.append(t)
    i+=1
if k>0:
    ans.append(alp[(alp.index(s[-1])+k%26)%26])
else:
    ans.append(s[-1])
print(''.join(ans))


Measured memory_bytes: 46608
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    string S; cin >> S;
    vector<int> a(N+1,0);
    vector<int> b(N+1,0);
    for(int i=0;i<N;i++){
        int x=0;
        int y=0;
        if(S[i]=='E'){
            x++;
        }else{
            y++;
        }
        a[i+1] = a[i]+x;
        b[i+1] = b[i]+y;
    }
    int m=INF;
    for(int i=0;i<N;i++){
        int t=b[i]+a[N]-a[i+1];
        if(m>t) m = t;
        //cerr << i << "\t" << b[i] << " " << a[N]-a[i+1] << endl;
    }
    cout << m << endl;
    return 0;
}


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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

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

  string ans = "";
  vector<string> alpha;

  alpha.push_back("z");
  rep(i, ALPHABET.length()-1) {
    alpha.push_back(ALPHABET.substr(i, 1));
  }

  while(N > 0) {
    ans = alpha[N%26] + ans;
    N--;
    N /= 26;
  }

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


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

signed main()
{
	int k;cin>>k;
	string a;cin>>a;
	if(a.length()<=k)cout<<a<<endl;
	else{
		for(int i=0;i<k;i++)
		cout<<a[i];
		cout<<"..."<<endl;
	}
	return 0;
}

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

int main(){
//	freopen("in.txt","r",stdin);
	string s;
	cin>>s;
	string res="";
	for(int i=0;i<s.size();i+=2){
		res+=s[i];
	}
	cout<<res;
	return 0;
}

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

using namespace std;

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  int a = x;
  int b = y;
  int c = z;
  
  a = y;
  b = x;
  a = z;
  c = y;
  
  cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}

signed main(){
    puts("square1001");
    return 0;
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)


using namespace std;

int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.rbegin(),p.rend()); //sort(a.rbegin(),a.rend())で大きい順にソート
    sort(q.rbegin(),q.rend());
    vector<ll> d;
    rep(i,x) d.push_back(p[i]);
    rep(i,y) d.push_back(q[i]);
    rep(i,c) d.push_back(r[i]);
    sort(d.rbegin(),d.rend());
    ll ans = 0;
    rep(i,x+y) ans += d[i];
    cout << ans << endl;
    return 0;    
}

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

#define ll long long

int main(){

    int X;
    int i,j,k,l;
    int count=0,count_n=0,count_m=0;
    bool flag = false;
    int ans=0;
    int N;
    int min = 100000000;

    cin >> N;    

    if(N < 10){
        cout << N << endl;
        return 0;
    }

    for(i=2;i<N-2;i++){
        int ans = 0;
        ans += i / 100000 + (i / 10000) % 10 + (i / 1000) % 10 + (i / 100) % 10 + (i / 10) % 10 + i % 10;
        int b_val = N - i;
        ans += b_val / 100000 + (b_val / 10000) % 10 + (b_val / 1000) % 10 + (b_val / 100) % 10 + (b_val / 10) % 10 + b_val % 10;
        if(min > ans)min = ans;
    }

    cout << min << endl;

}

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if(A >= K){
    cout << K << endl;
  }else if(A + B >= K){
    cout << A << endl;
  }else{
    cout << A - (K - (A + B)) << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main(){
string s,t;
cin >> s;
cin >> t;
bool same = true;
for(int i = 0;i < s.length();i++){
if(s[i]!=t[i])same = false;
}
if(same){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int n;
	int j, i;
	string a[100];
	string b[100];
	string min;
	int minj;

	cin >> n;

	for (i = 0; i < n; i++){
		cin >> a[i];
		b[i] = a[i];
		reverse(a[i].begin(), a[i].end());
	}
	
	for (i = 0; i < n; i++){
		for (j = n - 1; j > i; j--){
			if (a[j - 1][0] > a[j][0]) swap(a[j - 1], a[j]);
		}
	}
	for (i = 0; i < n; i++){
		reverse(a[i].begin(), a[i].end());
	}
	
	for (i = 0; i < n; i++){
		cout << a[i];
		if (i == n - 1) cout << "\n";
		else cout << " ";
	}
	
	cout << "Stable\n";
	
	for (i = 0; i < n; i++){
		reverse(b[i].begin(), b[i].end());
	}
	
	min = b[0];
	minj = 0;
	for (i = 0; i < n; i++){
		for (j = i; j < n; j++){
			if (min[0] > b[j][0]) {
				min = b[j];
				minj = j;
			}
		}
		if (b[i][0] != b[minj][0]) {
			swap(b[i], b[minj]);
		}
		min = "z";
	}
	

	for (i = 0; i < n; i++){
		reverse(b[i].begin(), b[i].end());
		cout << b[i];
		if (i == n - 1) cout << "\n";
		else cout << " ";
	}
	for (i = 0; i < n; i++){
		if (a[i] != b[i]) {
			cout << "Not stable" << "\n";
			break;
		}
		if (i == n - 1 && a[i] == b[i]) cout << "Stable" << "\n";
	}
	
}


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

//UnionFind
int n = 100000;
vector<int> par(n);
vector<int> size(n);

void init(int n){
  for(int i=0; i<n; i++){
    par.at(i) = i;
    size.at(i) = 1;
  }
}

int root(int x){
  if(par.at(x) == x){
    return x;
  }
  else{
    return par.at(x) = root(par.at(x));
  }
}

bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  if (size.at(x) < size.at(y)){
    swap(x, y);
  }
  size.at(x) += size.at(y);
  par.at(y) = x;
}

int size_x(int x){
  return size.at(root(x));
}




int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(M,vector<int>(0));
  vector<vector<int>> vec(N,vector<int>(0));
  for(int i=0; i<N; i++){
    int K;
    cin >> K;
    for(int j=0; j<K; j++){
      int k;
      cin >> k;
      k--;
      G.at(k).push_back(i);
      vec.at(i).push_back(k);
    }
  }
  
  init(N);
  
  for(int i=0; i<M; i++){
    for(int j=0; j<G.at(i).size(); j++){
      //cout << G.at(i).at(j) << " ";
      unite(G.at(i).at(0),G.at(i).at(j));
    }
    //cout << endl;
  }
  
  bool flag = true;
  for(int i=0; i<N-1; i++){
    if(!same(i,i+1)){
      flag = false;
    }
  }
  
  if(flag){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 9208
import Control.Monad
import Control.Applicative
import Data.List

main = do
  n <- read <$> getLine :: IO Int
  xs <- map (map read . words) <$> replicateM n getLine :: IO [[Int]]
  mapM_ putStrLn $ solve xs

solve :: [[Int]] -> [String]
solve = map rightAngle

rightAngle :: [Int] -> String
rightAngle xs
  | x * x + y * y == z * z = "YES"
  | otherwise = "NO"
  where
    (x:y:z:_) = sort xs

Measured memory_bytes: 4556
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	ll n, k;
	cin >> n >> k;
	
	vector<ll> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	sort(all(a));
	reverse(all(a));
	
	ll ans = 0;
	for(int i = k; i < n; i++) ans += a[i];
	cout << ans << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,c=0,d=0;
    scanf("%d",&a);
     char b[a];
     if(a>=1&&a<=100)
     {
         for(int x=0;x<a;x++)
         {
             cin>>b[x];
             if(b[x]=='I')
             {
                 c+=1;
                 if(c>d)
                    d=c;
             }
             if(b[x]=='D')
             {
                 c-=1;
                 if(c>d)
                    d=c;
             }
         }
         printf("%d",d);
     }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 200000
int main(){
 
  int i, j, R[N], n, max = 0, min;
 
  scanf("%d",&n);
 
  for(j = 0;j < n;j++) scanf("%d",&R[j]);
 
  min = R[0];
  max = R[1] - R[0];
  for(j = 1;j < n;j++){
    if( max < R[j]-min ) max = R[j] - min;
    else max = max;
    if( min < R[j] ) min = min;
    else min = R[j];
  }
 
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
N, M = map(int, input().split())
X = list(map(int, input().split()))
X = sorted(X)
Y = [0]*(M-1)
for i in range(M-1):
  Y[i] = X[i+1] - X[i]
Y = sorted(Y)
if N == 1:
  print(sum(Y))
else:
  print(sum(Y[:-N+1]))

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

using namespace std;

void run_case() {
    long long A , B , C , D;
    cin >> A >> B >> C >> D;
    if (A < B || D < B) {
        cout << "No\n";
        return;
    }

    if (C >= B) {
        cout << "Yes\n";
        return;
    }

    long long g = __gcd(D , B);
    long long mx = B - g + A % g;

    cout << (mx > C ? "No\n" : "Yes\n");
}

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        run_case();
}


Measured memory_bytes: 256
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

using namespace std;

typedef long long int lli;
typedef long int li;
typedef vector<lli> vli; 
typedef vector<int> vi; 
typedef vector<string> vs; 


const lli mod=1000000007;
const lli limit=1000000;


void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k,a,b,c;
    cin>>a>>b>>c>>k;
    temp=min(a,k);
    k-=temp;
    k-=min(b,k);
    temp-=min(c,k);
    cout<<temp<<endl;
 
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CINS(int, h, N);

    int ans = 0;
    for (int i = 1; i <= 100; i++) {
        bool endFlag = false;
        for (int j = 0; j < N; j++) {
            if ( h[j] >= i ) {
                ans++;
                if (j>0 && h[j-1] >= i) {
                    ans--;
                }
            }
        }
        if ( endFlag ) break;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

int main(){
    int N; cin >> N;
    vector<ll> C(N);
    rep(i,N) cin >> C[i];
    sort(C.begin(),C.end());
    ll ans = 0;
    rep(i,N){
        ans += (N-i+1)*C[i]%MOD*modpow(4,N-1,MOD)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;

}
    



Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
	int N;//人
	int A;//電車A円
	int B;//タクシーN人でB円
	cin >> N >> A >> B;

	int kingaku_den = A * N;

	if (kingaku_den <= B) {
		cout << kingaku_den << endl;
	}
	else {
		cout << B << endl;
	}

}

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

using namespace std;

int main(){
	vector<int> x;
	int i;
	while(1){
		int a,b;
		cin>>a>>b;
		if (a==0 && b==0){
			break;
		}
		x.push_back(a);
		x.push_back(b);
	}
	for (vector<int>::size_type i=0;i<x.size();i+=2){
		if (x[i]>x[i+1]){
			cout<<x[i+1]<<" "<<x[i]<<endl;
		}
		else{
			cout<<x[i]<<" "<<x[i+1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1252
N, M = map(int, input().split())

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

data = {}

for c in cs:
    if c[0] not in data:
        data[c[0]] = [c]
    else:
        data[c[0]].append(c)

for c_list in data.values():
    c_list.sort(key=lambda c:c[1])

for c_list in data.values():
    for i, c in enumerate(c_list):
        c.append(i)

for c in cs:
    print("{:06}{:06}".format(c[0], c[2]+1))


Measured memory_bytes: 42148
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int dx = abs(x1 - x2);
	int dy = abs(y1 - y2);
	int x3, y3, x4, y4;

	if (x1 <= x2 && y1 <= y2) {
		x3 = x2 - dy;
		y3 = y2 + dx;
		x4 = x3 - dx;
		y4 = y3 - dy;
		cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
		return 0;
	}

	if (x1 >= x2 && y1 <= y2) {
		x3 = x2 - dy;
		y3 = y2 - dx;
		x4 = x3 + dx;
		y4 = y3 - dy;
		cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
		return 0;
	}

	if (x1 >= x2 && y1 >= y2) {
		x3 = x2 + dy;
		y3 = y2 - dx;
		x4 = x3 + dx;
		y4 = y3 + dy;
		cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
		return 0;
	}

	if (x1 <= x2 && y1 >= y2) {
		x3 = x2 + dy;
		y3 = y2 + dx;
		x4 = x3 - dx;
		y4 = y3 + dy;
		cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
		return 0;
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef signed long long ll;
typedef long double ld;

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

#define DEBUG

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

	int ans;
	ans = a * n;

	if(ans < b)
	{
		cout << ans << endl;
	}
	else
	{
		cout << b << endl;
	}

	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

// 001
// 110
// 011

// 11

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

  ll bit = 1, shifts = 0;
  while ((bit << 1) <= k) {
    bit <<= 1;
    ++shifts;
  }

  vector<int> cnt(shifts + 1);
  rep(i, n) rep(j, shifts + 1) if ((a[i] >> j) & 1)++ cnt[j];

  ll x = 0;
  for (int i = shifts; i >= 0; --i) {
    if ((x | (1LL << i)) > k) continue;
    if (cnt[i] < (n - cnt[i])) x |= (1LL << i);
  }
  dbg(x);
  ll ans = 0;
  for (ll ai : a) ans += ai ^ x;
  out(ans);
}


Measured memory_bytes: 4048
import java.util.Scanner

object Main {
  def main (args: Array[String]) = {
    val in = new Scanner(System.in)
    val a = in.nextInt
    val b = in.nextInt
    val c = in.nextInt

    val div = for (
      i <- 1 to c
      if ((c % i) == 0)
      if (a <= i && b >= i)
    ) yield i

    println(div.length)
  }
}

Measured memory_bytes: 45380
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

l = 1
m = 2
r = 3
a = sum(A[:l])
b = sum(A[l:m])
c = sum(A[m:r])
d = sum(A[r:])
ans = max(a, b, c, d) - min(a, b, c, d)
# 尺取法(3点動かす)
while m < N-1:
    # a,bの差が最小になるまで左を動かす
    while l < m-1 and abs(a - b) > abs(a+A[l] - (b-A[l])):
        a += A[l]
        b -= A[l]
        l += 1
    # c,dの差が最小になるまで右を動かす
    while r < N-1 and abs(c - d) > abs(c+A[r] - (d-A[r])):
        c += A[r]
        d -= A[r]
        r += 1
    ans = min(ans, max(a, b, c, d) - min(a, b, c, d))
    # 真ん中を動かす
    b += A[m]
    c -= A[m]
    m += 1
    # 真ん中が右に追いついたら、右も合わせて+1する
    if m == r:
        c += A[r]
        d -= A[r]
        r += 1
print(ans)


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

int main(void){
  int n;
  string s="Christmas";
  cin >> n;
  if((25-n)>0){
    for(int i=0;i<(25-n);i++) s+= " Eve";
  }
  cout << s << endl;
  
  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 D = sc.nextInt();
    int X = sc.nextInt();
    int[] A = new int[N];
    for (int i=0; i<N; i++) {
      A[i] = sc.nextInt();
    }
    int total =0;
    for (int i=0; i<N; i++) {
      total += (D-1) /A[i] +1;
    }
    total += X;
    System.out.println(total); 
  }
}

Measured memory_bytes: 23124
package main

import (
	"fmt"
	"math"
)

var ans uint64 = 1
var mod uint64 = pow(10, 9) + 7

func main() {
	var N uint64
	fmt.Scan(&N)

	var i uint64
	for i = 1; i <= N; i++ {
		ans *= i
		ans %= mod
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();

		int ans = 0;
		if (X <= 599) {
			ans = 8;
		} else if (X <= 799) {
			ans = 7;
		} else if (X <= 999) {
			ans = 6;
		} else if (X <= 1199) {
			ans = 5;
		} else if (X <= 1399) {
			ans = 4;
		} else if (X <= 1599) {
			ans = 3;
		} else if (X <= 1799) {
			ans = 2;
		} else {
			ans = 1;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 35620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int N = Integer.parseInt(tokenizer.nextToken());
		int R = Integer.parseInt(tokenizer.nextToken());
		int L = Integer.parseInt(tokenizer.nextToken());
		Pair[] pairs = new Pair[N];
		TreeSet<Pair> set = new TreeSet<Pair>();
		int[] c = new int[N];
		for (int i = 0; i < N; i++) {
			pairs[i] = new Pair(i, 0);
		}
		int now = 0;
		int index = 0;

		for (int i = 0; i < R; i++) {
			tokenizer = new StringTokenizer(reader.readLine());
			int d = Integer.parseInt(tokenizer.nextToken()) - 1;
			int t = Integer.parseInt(tokenizer.nextToken());
			int x = Integer.parseInt(tokenizer.nextToken());
			c[index] += t - now;
			set.remove(pairs[d]);
			pairs[d].point += x;
			set.add(pairs[d]);
			index = set.first().id;
			now = t;
		}
		c[index] += L - now;
		int ans = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			if (max < c[i]) {
				max = c[i];
				ans = i;
			}
		}
		System.out.println(ans + 1);

	}

	class Pair implements Comparable<Pair> {
		int id, point;

		public Pair(int id, int point) {
			super();
			this.id = id;
			this.point = point;
		}

		@Override
		public String toString() {
			return "Pair [id=" + id + ", point=" + point + "]";
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + id;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (id != other.id)
				return false;
			return true;
		}

		@Override
		public int compareTo(Pair o) {
			if (this.point == o.point)
				return this.id - o.id;
			return o.point - this.point;
		}

		private Main getOuterType() {
			return Main.this;
		}

	}
}

Measured memory_bytes: 102664
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
using namespace std;

#define rep(i,end)   for (int i=0;i<end;i++)
#define all(cont)    begin(cont), end(cont)
typedef long long ll;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s = gets(true);
    int x = 0;
    int maxval = 0;
    for (auto c: s)
    {
        if (c == 'I') {
            maxval = max(maxval, ++x);
        }
        else {
            x--;
        }
    }
    cout << maxval << endl;
    return 0;
}

string gets(bool skipnewline)
{
    if (skipnewline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}



Measured memory_bytes: 256