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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	string s;
	cin>>n>>s>>t;
	n=s.length();
	set<ll> x[26];
	rep(i,n)
	{
		x[s[i]-'a'].insert(i+1);
	}
	while(t--)
	{
		char ch;
		cin>>n;
		// cout<<(x[0].lower_bound(7)==x[0].end());
		if(n==1)
		{
			ll pos;
			cin>>pos>>ch;
			// pos--;
			rep(i,26)
			{
				auto y=x[i].lower_bound(pos);
				if(y!=x[i].end() && (*y)==pos)
				{
					x[i].erase(y);
					break;
				}
			}
			x[ch-'a'].insert(pos);
		}
		else
		{
			c=0;
			cin>>j>>k;
			rep(i,26)
			{
				auto y=x[i].lower_bound(j);
				if(y!=x[i].end() && (*y)<=k)
					c++;
			}
			cout<<c;

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

Measured memory_bytes: 26268
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	lli n, mul = 1;
	cin >> n;

	bool minus = false;

	for (int i = 0; i < n; i++) {
		lli a;
		cin >> a;

		if (mul > pow(10, 18) / a || mul * a > (lli)pow(10, 18)) {
			minus = true;
		}

		if (a == 0) {
			mul = 0;
			minus = false;
		}

		mul *= a;

	}
	if (minus == true)
		cout << -1 << endl;
	else
		cout << mul << endl;

	return 0;
}

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

using namespace std;

const int N=1e6+5,MOD=998244353;

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

typedef long long ll;

int u,v,p,d,n,tc,q,k,l,r,c,m,b[N],cnt,curr,a[N],ans;

bool sum[N];

char s[N];

int main()
{   
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int curr=0;
    ans=1e9;
    for(int i=0;i<n;i++){
            curr+=a[i];
            int othercurr= 0;
            for(int j=i+1;j<n;j++)othercurr+=a[j];
            ans=min(ans,abs(othercurr-curr));
        }
 
    printf("%d\n",ans );
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  string S,T;
  cin >> S >> T;
  int A,B; cin >> A >> B;
  string U; cin >> U;

  if(U == S) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

cnt1 = 0
cnt2 = 0

for i in range(n):
    if a[i]%2 == 0:
        cnt1 += 1
        if a[i]%3 == 0 or a[i]%5 == 0:
            cnt2 += 1
        else:
            continue
    else:
        continue

if cnt1 == cnt2:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string t;
    cin >> t;
    for(int i=0; i<t.size(); i++)
    {
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3740
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

#    print(arr)
    cnt = 0
    N = n
    prime_arr = []
    array = []
#    print(len(arr))
    if len(arr) > 1:
        for i in range(len(arr)):
            array.append(arr[i][0])
#        print(array)
        for i in range(len(arr)):
            for j in range(arr[i][1]):
                prime_arr.append(array[i]**(j+1))
        prime_arr.sort()
#        print(prime_arr)
        for i in range(len(prime_arr)):
            if (N/prime_arr[i] >= 1 and N%prime_arr[i] == 0):
                N /= prime_arr[i]
                cnt += 1
        print(cnt)
    elif len(arr) == 1:
        if arr[0][0] == 1:
            print(0)
        else:
            num = arr[0][1]
            for i in range(num):
                prime_arr.append(arr[0][0]**(i+1))
            prime_arr.sort()
#            print(prime_arr)
            for i in range(len(prime_arr)):
                if (N/prime_arr[i] >= 1):
                    N /= prime_arr[i]
                    cnt += 1
            print(cnt)

    return arr
    

if __name__=="__main__":
    n = int(input())
    factorization(n)


Measured memory_bytes: 9504
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <random>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[30];
ll c[30],s[400][30],ans[150000];
std::vector<int> v[150000];

int main(void){
	int d,i,j,n=26,k,m=125000;
	ll ansm = -INFLL;
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			v[k].push_back(j);
		}
		std::random_device seed_gen;
		std::mt19937 engine(seed_gen());
		std::shuffle(v[k].begin(), v[k].end(), engine);
	}
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
	}
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			l[j] = -1;
		}
		for(i=0; i<d; ++i){
			ans[k] += s[i][v[k][i%26]];
			l[v[k][i%26]] = i;
			for(j=0; j<n; ++j){
				ans[k] -= c[j]*(i-l[j]);
			}
		}
		ansm = std::max(ansm,ans[k]);
		// std::cout << ans[k] << std::endl;
	}
	for(k=0; k<m; ++k){
		if(ans[k] == ansm){
			for(i=0; i<d; ++i){
				std::cout << v[k][i%26]+1 << std::endl;
			}
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 25796
import numpy as np
N,M=[int(i) for i in input().split()]
a=[]
for j in range(N):
  a.append([int(i) for i in input().split()])
 
a.sort(key=lambda x:x[0])
 
cost=0
shop=0
for j in range(M):
  if a[shop][1]==0:
    shop+=1
  a[shop][1]-=1
  cost+=a[shop][0]
print(cost)

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

int main(){
  int N, num;
  cin >> N;
  num = N;
  int sum = 0;
  while(N){
    sum += N % 10;
    N /= 10;
  }
  if(num%sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

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

int x, y;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> x >> y;
  bool ok = true;
  if (y & 1) {
    ok = false;
  }
  if (y > 4 * x || y < 2 * x)
    ok = false;

  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>

#define MAX 9

int count_combi(int);

int main(){
	int num, count;

	while(scanf("%d", &num) != EOF){
		count = count_combi(num);
		printf("%d\n", count);
	}

	return 0;
}

int count_combi(int num){
	int count = 0;
	int i,j,k,l;

	// すぐ数えれるシリーズ
	// 36より大きい時と36のとき
	if(num > 36){
		return 0;
		// 9,9,9,9
	} else if(num == 36){
		return 1;
		// その他
	} else {
		for(i=0;i<=MAX;i++){
			for(j=0;j<=MAX;j++){
				for(k=0;k<=MAX;k++){
					for(l=0;l<=MAX;l++){
						if((i+j+k+l) == num){
							count++;
						}
					}
				}
			}
		}
	}
	return count;
}

Measured memory_bytes: 596
#include <iostream>
 
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int a[N], mem[N], flg=0, p=0, count=1;

  for(int i=0; i<N; i++){
    cin >> a[i];
    mem[i]=0;
    if(a[i]==2){
      flg=1;
    }
  }

  if(flg==0){
    printf("-1\n");
  }else{
    while(mem[p]==0 && a[p] != 2){
      mem[p]=1;
      p = a[p]-1;
      count++;
    }
    if(a[p]==2){
      printf("%d\n",count);
    }else{
      printf("-1\n");
    }
  }
}


Measured memory_bytes: 4508
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// ユークリッドの互除法
// 最大公約数を求める
// Gcd(割られる数, 割る数)
long long Gcd(long long a, long long b)
{
   // bが0になるまでa%bを繰り返す
   // 割る数bが次の割られる数になり, あまりが割る数になる
   return b ? Gcd(b, a%b) : a;
}

// あまりが0になるまで再帰的にGCD
// ただし, 再帰で呼び出すときは割る数を割られる数, あまりを割る数にして呼び出す
ll GCD(ll a, ll b)
{
   if(a%b == 0){return b;}
   else{return GCD(b, a%b);}

}

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

   // aの全ての要素の最大公約数を求める.
   // 最初の要素から最大公約数を探索して
   long long res = a[0];
   for(int i=0; i < n; i++){
      res = GCD(res, a[i]);
   }

   cout << res << endl;

   return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define N 1010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, x, n) for(int i = x; i <= n; ++i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
 
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
 
using namespace std;

ll dp[N][N]; 
char a[N][N];

int main()
{
	barnarnar
	int n, m;
	cin >> n >> m;
	dp[1][1] = 1ll;
	forn1(i, n)  forn1(j, m)  cin >> a[i][j];
	forn1(i, n)
	{
	    forn1(j, m)
	    {
	        if(i == 1 && j == 1)    continue;
	        if(a[i - 1][j] == '.')  dp[i][j] = (dp[i][j] + dp[i - 1][j]) % modw;
	        if(a[i][j - 1] == '.')  dp[i][j] = (dp[i][j] + dp[i][j - 1]) % modw;
	    }
	}
	cout << dp[n][m];
    return 0;
}









Measured memory_bytes: 9088
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


H,W = LI()
field = [list(input()) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if field[i][j]==".":
            field[i][j]=inf

tmp = copy.deepcopy(field)

dx = [1,0,-1,0]
dy = [0,1,0,-1]
ans=[]


def bfs(sh,sw):
    field[sh][sw] = 0
    que = collections.deque([[sh,sw]])

    while que:
        h,w = que.popleft()
        for i in range(4):
            nh = h+dx[i]
            nw = w+dy[i]
            if (nh<0) or (nw<0) or (nw>W-1) or (nh>H-1):
                continue
            dist = field[nh][nw]
            if dist!="#":
                if dist>field[h][w]+1:
                    field[nh][nw] = field[h][w]+1
                    que.append([nh,nw])

    m = 0
    for i in range(H):
        for j in range(W):
            if field[i][j]!="#":
                if field[i][j]>m:
                    m = field[i][j]
    return m

for i in range(H):
    for j in range(W):
        field = copy.deepcopy(tmp)
        if field[i][j]=="#":
            continue
        ans.append(bfs(i,j))


print(max(ans))

Measured memory_bytes: 5296
#include<iostream>
using namespace std;
int main(){
  int k,n,x,y,money=0;
  cin>>n>>k>>x>>y;
  if(n>k){
  money=k*x+(n-k)*y;
  }else if(n<=k){
    money=n*x;
  }
  cout<<money<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    cout<<n*n*n;
    return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int H,W;
    cin>>H>>W;
    vector<vector<int>> road(H,vector<int>(W));
    rep(i,H){
        rep(j,W){
            char c;
            cin>>c;
            if(c=='#'){road.at(i).at(j)=-1;}
            else{road.at(i).at(j)=0;}
        }
    }
    road.at(0).at(0)=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(road.at(i).at(j)==-1){continue;}
            else{
                if(i+1<H && road.at(i+1).at(j)!=-1){road.at(i+1).at(j)+=road.at(i).at(j);road.at(i+1).at(j)%=MOD;}
                if(j+1<W && road.at(i).at(j+1)!=-1){road.at(i).at(j+1)+=road.at(i).at(j);road.at(i).at(j+1)%=MOD;}
            }
        }
    }
    cout<<road.at(H-1).at(W-1)<<endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define r(x,i,n) for(int i = x; i<n; i++)
#define long long ll;
using namespace std;

int main(){
  int n,x,count=0;
  cin >> n >> x;
  vector<int> v(n,0);
  r(0,i,n){
    cin >> v.at(i);
    x-=v.at(i);
    count++;
  }
  sort(v.begin(),v.end());
  count+=x/v.at(0);
  cout << count << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e10
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    unordered_map<char, string>cards;
    cin >> cards['a']>> cards['b']>> cards['c'];

    unordered_map<char, int>ct;
    char curr = 'a';

    while (true){
        ct[curr]++;
        if(ct[curr] > cards[curr].size()){
            if(curr=='a') cout << 'A' << endl;
            else if (curr=='b') cout << 'B' << endl;
            else cout << 'C' << endl;
            return 0;
        }
        curr = cards[curr][ct[curr]-1];
    }


}
        

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

using namespace std;

int main()
{
	int n;
  	cin >> n;
  	vector<int> a(n);
  	for(int i = 0; i < n; i ++){
      	int x;
      	cin >> x;
      	a[x - 1] = i;
    }
  	for(int i = 0; i < n; i ++)
    	cout << a[i] + 1 << " ";
  	cout << "\n";
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    int i;
    for (i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    for (i = 0; i < n; i++)
    {
        b.at(a.at(i)-1) = i+1;
    }
    for (i = 0; i < n-1; i++)
    {
        cout << b.at(i)<<" ";
    }
    cout << b.at(n-1) << endl;
    
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  V a(n); 
  rep(i, n) {
    int x; cin >> x;
    --x;
    a[x] = i;
  }

  ll ans = 0;
  set<int> S;
  S.insert(-1);
  S.insert(n);
  rep(i, n) {
    auto it = S.lower_bound(a[i]);
    ll x = *it - a[i];
    --it;
    ll y = a[i] - *it;
    ans += x*y * (i+1);
    S.insert(a[i]);
  }

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


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	string s;cin>>s;
	if(n&1)cout<<"No";
	else{
		string s1,s2;
		rep(i,0,n/2)s1+=s[i];
		rep(i,n/2,n)s2+=s[i];
		if(s1==s2)cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    string S,T="keyence";
    cin>>S;
    n=S.length();
    rep(i,8){
        string L=S.substr(0,i);
        string R=S.substr(n-(7-i),7-i);
        if(L+R==T)ans=1;
    }

    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli   long long int
#define pb push_back
#define rep(i,s,n) for(lli i=s;i<n;i++)
#define irep(i,n,s) for(lli i=n-1;i>=s;i--)
#define mp make_pair
#define mod 1000000007
using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio;
    cin.tie(NULL);
    int i, j, k, m, n, t;
    //cin >> t;
    t = 1;
    while (t--)
    {

        string s;
        cin >> s;
        int res = 0;
        i = 0;
        while (i < 3)
        {
            if (s[i] == 'R')
            {
                int c = 0;
                while (i < 3 && s[i] == 'R')
                {
                    c++;
                    i++;
                }
                res = max(res, c);
            }
            else
            {
                i++;
            }
        }
        cout << res;
    }

}




Measured memory_bytes: 3608
using System;
using System.Linq;

public class Hoge{
static void Main()
{
	var n = int.Parse(Console.ReadLine());
	var c = Console.ReadLine().Split(' ');
	
	var bubbleSorted = BubbleSort(c, n);

	Console.WriteLine(string.Join(" ", bubbleSorted));
	Console.WriteLine(IsStable(c, bubbleSorted) ? "Stable" : "Not stable");
		
	var selectionSorted = SelectionSort(c, n);

	Console.WriteLine(string.Join(" ", selectionSorted));
	Console.WriteLine(IsStable(c, selectionSorted ) ? "Stable" : "Not stable");
}

public static string[] BubbleSort(string[] cparam, int n)
{
	var c = (string[])cparam.Clone();
	for (var i = 0; i < n - 1; i++)
		for (var j = n - 1; j > i; j--)
			if (int.Parse(c[j].Substring(1)) < int.Parse(c[j - 1].Substring(1)))
			{
				var temp = c[j];
				c[j] = c[j - 1];
				c[j - 1] = temp;
			}
	
	return c;
}

public static string[] SelectionSort(string[] cparam, int n)
{
	var c = (string[])cparam.Clone();
	for (var i = 0; i < n - 1; i++)
	{
		var minj = i;
		for (var j = i; j < n; j++)
			if (int.Parse(c[j].Substring(1)) < int.Parse(c[minj].Substring(1)))
				minj = j;
		
		var temp = c[i];
		c[i] = c[minj];
		c[minj] = temp;
	}
	return c;
}

public static bool IsStable(string[] origin, string[] sorted)
{
	// ??°????????????????????§?????¨??????
	var g = origin.GroupBy(x => int.Parse(x.Substring(1)));
	
	// ??°???????????????????????????????????????
	foreach(var numberToInputs in g.Where(x => x.Count() > 1))
	{
		// ?????¨?????????index?????????
		var preIndex = -1;
		foreach (var input in numberToInputs)
		{
			// origin???????????§sort??????????????????????????????????????????
			// sorted????????????????????????????????§????????£??????not stable
			var index = Array.IndexOf(sorted, input);
			if (preIndex > index)
				return false;
			preIndex = index;
		}
	}
	
	return true;
}
}

Measured memory_bytes: 6244
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void CountPrimeNumber() {
	int PrimeNumber[50000];
	int pcount = 0;
	int x;
	cin >> x;

	PrimeNumber[pcount++] = 2;
	PrimeNumber[pcount++] = 3;

	for (int n = 5; n <= 100005; n += 2)
	{
		int flag = 0;
		for (int i = 1; PrimeNumber[i] * PrimeNumber[i] <= n; ++i)
		{
			if (n % PrimeNumber[i] == 0)
			{
				flag = 1;
				break;
			}
		}
		if (!flag)
			PrimeNumber[pcount++] = n;
	}
	for (int i = 0; i < pcount; ++i) {
		if (PrimeNumber[i] >= x) {
			cout << PrimeNumber[i] << endl;
			return;
		}
	}
}

int main() {
	CountPrimeNumber();

	return 0;
}

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

using namespace std;

void solve(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }else if(a < b){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }
}

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

Measured memory_bytes: 3068
MOD=10**9+7

def cmb(n, r):
    if n < r: return 0 #date added
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result = result%MOD

    return result

x, y = map(int, input().split())
a = (2*y - x)/3
b = (2*x - y)/3

#print(a, b)

if a.is_integer() and b.is_integer() and a>=0 and b>=0:
    print(cmb(int(a+b), int(a)))
else:
    print(0)


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;
int b[100];
int cnt[MAXN], a[MAXN];

int O;

void read(){
	cin>>n>>O;
}

int mid(int p, int q, int r){
	int x = max(p, max(q, r));
	int y = min(p, min(q, r));
	return p + q + r -x - y;
}

void solve(){
	/*
	for(int i = 1; i <= 2 * n - 1; i++)
		b[i] = i;
	m = 2 * n - 1;
	for(int i = 1; i <= m; i++)
		cnt[i] = 0;
	cnt = 0;
	do{
		for(int i = 1; i <= m; i++)
			a[0][i] = b[i];
		for(int i = 1; i < n; i++){
			for(int j = 1 + i; j <= m - i; j++){
				a[i][j] = mid(a[i-1][j-1], a[i-1][j], a[i-1][j+1]);
			}
		}
		cnt[a[n-1][n]]++;
	}while();
	for(int i = 1; i <= m; i++)
		cout<<cnt[i]<<' '; cout<<endl;*/
	m = 2 * n - 1;
	for(int i = 1; i <= m; i++)
		cnt[i] = 0;
	if (O == 1 || O == m){
		puts("No");
		return ;
	}
	for(int i = 1; i <= n - 2; i++)
		cnt[i] = i + n;
	cnt[n-1] = cnt[n-2];
	cnt[n] = 2;
	for(int i = 2; i <= n; i++)
		cnt[n - 1 + i] = i;
	int ii = 0;
	for(int i = 1; i <= m; i++)
		if (cnt[i] == O){
			ii = i;
			break;
		}
			
		for(int j = 1; j <= m; j++)
			a[j] = (ii + j - 1) % m + 1;
		
	puts("Yes");
	for(int i = 1; i <= m; i++)
		printf("%d\n", a[i]);
}

void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	 char c;
	 cin >> c;
	 if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
	 	cout << "vowel"<< endl;
	 else
	 	cout << "consonant" << endl;
}

Measured memory_bytes: 256
N=int(input())
w = list(map(int,input().split()))
s1=0
s2=0
ans=100000000

for i in range(1,N):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    if ans > abs(s1-s2):
        ans = abs(s1-s2)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll A,B,K; cin>>A>>B>>K;
    if(A-K>=0){
        cout<< A-K<<" "<<B<<"\n";
    }
    else{
        cout<< 0 <<" " <<max(B-(K-A),0LL)<<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;
typedef long long int ll ;


int main(){
	ios;
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	if(a1+a2+a3>=22)cout<<"bust\n";
	else
		cout<<"win\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
    
    string inName;
    cin >> inName;
    int sizeIN = inName.length();
    string out(sizeIN, 'x');

    cout << out << endl;
}

Measured memory_bytes: 256
while 1:
    n, l, r = map(int, input().split())
    if n == 0:
        break

    data = []
    for _ in range(n):
        data.append(int(input()))

    cnt = 0
    for i in range(l, r+1):
        for j, d in enumerate(data):
            if i % d == 0:
                if j % 2 == 0:
                    cnt += 1
                break
        else:
            if n % 2 == 0:
                cnt += 1

    print(cnt)



Measured memory_bytes: 5600
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

#define INF 100000

bool isUppercaseLetter(char c) {
    if (c >= 'A'&&c<='Z')return true;
    else return false;
}

int main() {
    string S;
    cin >> S;

    if (S.front() == 'A'&&count(S.begin() + 2, S.end() - 1, 'C') == 1 && count_if(S.begin(), S.end(), isUppercaseLetter)==2)cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}

Measured memory_bytes: 256
[L, R] = map(int, input().split())

# L <= i < j <= R
if int(R / 3) - int((L-1) / 3) > 0 and int(R / 673) - int((L-1) / 673) > 0:
    print(0)
else:
    res = 2018
    R2 = min(R+1, L+2019)
    for i in range(L, R2):
        for j in range(i+1, R2):
            res = min(res, ((i % 2019) * (j % 2019)) % 2019)
            if res == 1:
                break
    
    print(res)


Measured memory_bytes: 3060
str = input()
text = input()
ans = len(text)
for i in range(len(str) - len(text) + 1):
    dif = 0
    for j in range(len(text)):
        if not str[i+j] == text[j]:
            dif += 1
    ans = min(ans, dif)
print(ans)


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pint;

#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) 
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>> 
#define vin(v) rep(i,v.size()) {cin >> v[i];}

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 (b<a) { a=b; return 1; } return 0; }

int main(void){
  string s;cin >> s;
  rep(i,s.length())
    if(i%2==0&&s[i]=='L'||i%2&&s[i]=='R'){
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

struct Barrier {
	int x, y, r;
};

int main() {
	int xs; int ys; int xt; int yt;
	while(~scanf("%d%d%d%d", &xs, &ys, &xt, &yt)) {
		int N;
		scanf("%d", &N);
		vector<Barrier> barrieres(N + 2);
		rep(i, N) {
			int x; int y; int r;
			scanf("%d%d%d", &x, &y, &r);
			barrieres[i] = { x, y, r };
		}
		barrieres[N] = { xs, ys, 0 };
		barrieres[N + 1] = { xt, yt, 0 };
		vector<double> dist(N + 2, 1e99);
		vector<bool> vis(N + 2);
		vis[N] = true;
		dist[N] = 0;
		double ans = 1e99;
		while(1) {
			int i = (int)(min_element(dist.begin(), dist.end()) - dist.begin());
			double D = dist[i];
			if(i == N + 1) {
				ans = D;
				break;
			}
			vis[i] = true;
			dist[i] = 1e99;
			rep(j, N + 2) if(!vis[j]) {
				const auto &a = barrieres[i], &b = barrieres[j];
				double d = hypot(a.x - b.x, a.y - b.y);
				amin(dist[j], D + max(0., d - a.r - b.r));
			}
		}
		printf("%.10f\n", ans);
	}
	return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
    var sa, sb, sc string
    var a_cnt, b_cnt, c_cnt int
    turn := 0

    fmt.Scan(&sa, &sb, &sc)

    for {
        switch turn {
        case 0:
            if a_cnt == len(sa) {
                fmt.Println("A")
                return
            }
            turn = int(sa[a_cnt]-'a')
            a_cnt++
        case 1:
            if b_cnt == len(sb) {
                fmt.Println("B")
                return
            }
            turn = int(sb[b_cnt]-'a')
            b_cnt++
        case 2:
            if c_cnt == len(sc) {
                fmt.Println("C")
                return
            }
            turn = int(sc[c_cnt]-'a')
            c_cnt++
        }
    }
}

Measured memory_bytes: 512
{-# LANGUAGE TupleSections #-}

import Data.Array (accumArray, (!), elems)

ptable = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]

pfact [] n = []
pfact _ 1 = []
pfact (p:ps) n
  | mod n p == 0 = p : pfact (p:ps) (div n p)
  | otherwise = pfact ps n

c m = length . filter (>=(m-1))

main = do
  n <- read <$> getLine
  let fact = filter (>1) . elems . accumArray (+) 0 (2,47) . concat $
                [map (,1) $ pfact ptable x | x<-[2..n]] 
  print $ sum [ c 75 fact
              , c 25 fact * (c 3 fact - 1)
              , c 15 fact * (c 5 fact - 1)
              -- aC2 == aP2 / 2
              , ((c 5 fact * (c 5 fact - 1)) `div` 2) * (c 3 fact - 2)
              ]


Measured memory_bytes: 508
# -*- coding:utf-8 -*-
S = list(input())
flag1 = True 
flag2 = True
list1 = [ tmp for tmp in S if tmp == 'N' or tmp == 'S' ]
list2 = [ tmp for tmp in S if tmp == 'W' or tmp == 'E' ]
if len(list1) > 0:
    if 'N' in list1 and 'S' in list1:
        pass
    else:
        flag1 = False
if len(list2) > 0:
    if 'W' in list2 and 'E' in list2:
        pass
    else:
        flag2 = False
if flag1 and flag2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
// Date: 2020-03-13

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a[N], dp[N];
int main() {
    FIO;
    int n, k;
    cin >> n >> k;
    rep(i, 1, n) cin >> a[i];
    rep(i, 0, k) if(!dp[i]) rep(j, 1, n) dp[i+a[j]] = 1;
    if(dp[k]) cout << "First";
    else cout << "Second";

    return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 200111, inf = 1000111222;

string s, t;
int h, w, n, si, sj;
string ss, tt;

void inv(string& s) {
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'D') {
            s[i] = 'R';
        }
        if (s[i] == 'U') {
            s[i] = 'L';
        }
    }
}

bool solve(string s, string t, int pos, int mx) {
    int l = -1, r = mx;
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s[i] == 'L') {
            ++l;
        }
        if (s[i] == 'R') {
            --r;
        }
        if (t[i] == 'L') {
            ++r;
        }
        if (t[i] == 'R') {
            --l;
        }
        l = max(-1, l);
        r = min(mx, r);
        if (s[i] == 'R') {
            r = min(mx - 1, r);
        }
        if (s[i] == 'L') {
            l = max(0, l);
        }
        if (r - l <= 1) return true;
    }
    if (pos <= l || pos >= r) return true;
    return false;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> h >> w >> n;
    cin >> si >> sj;
    --si, --sj;
    cin >> s;
    cin >> t;
    ss = s;
    tt = t;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'U' || s[i] == 'D') {
            ss[i] = '.';
        }
        if (t[i] == 'U' || t[i] == 'D') {
            tt[i] = '.';
        }
    }
    if (solve(ss, tt, sj, w)) {
        cout << "NO" << endl;
        return 0;
    }
    ss = s;
    tt = t;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'L' || s[i] == 'R') {
            ss[i] = '.';
        }
        if (t[i] == 'L' || t[i] == 'R') {
            tt[i] = '.';
        }
    }
    inv(ss);
    inv(tt);
    if (solve(ss, tt, si, h)) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;

    return 0;
}




Measured memory_bytes: 1544
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return ((a*b)/gcd(a,b));}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{






int n,a,b;
cin>>n>>a>>b;
cout<<min(n*a,b);








}return 0;}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
sum_t = [0] * N
sum_t[0] = W[0]
for i in range(1, N):
    sum_t[i] = sum_t[i-1] + W[i]
diff_m = float('inf')
for i in range(N):
    diff_m = min(diff_m, abs(sum_t[N-1] - 2*sum_t[i]))
print(diff_m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if (N%10 == 9 || N%100 >= 90){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    



Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long L;
using namespace std;
 
#define N 100005
map<L,L> path[N];
L par[N], dep[N], siz[N], hev[N];
L cst[N];
void dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d==par[a]) continue;
        par[d]=a;
        dep[d]=dep[a]+1;
        cst[d]=I->second;
        dfs(d);
        siz[a]+=siz[d];
        if(!hev[a] || siz[hev[a]]<siz[d])
            hev[a]=d;
    }
}
   
L k;
L add[N];
L edgecost(L a){
    L ret=add[a]+add[par[a]]+cst[a];
    return ret%k ? ret : 0;
}
   
L pos[N];
L hl_par[N];
   
L bit[N];
L sum(L i){
    L ret=0;
    while(i){
        ret+=bit[i];
        i-=i&-i;
    }
    return ret;
}
void S(L i, L x){
    x-=sum(i+1)-sum(i);
    i++;
    while(i<N){
        bit[i]+=x;
        i+=i&-i;
    }
}
   
L cost(L a, L b){
    L p=hl_par[a], q=hl_par[b];
    if(p==q) return abs(sum(pos[a])-sum(pos[b]));
    if(dep[p]<dep[q]){
        swap(p, q);
        swap(a, b);
    }
    return sum(pos[a]) - sum(pos[p])
        + edgecost(p) + cost(par[p], b);
}
 
main(){
    L n;
    cin >> n >> k;
    for(L i=0; i<n-1; i++){
        L a, b;
        L c;
        cin >> a >> b >> c;
        path[a][b]=c;
        path[b][a]=c;
    }
    for(L i=0; i<n; i++) hev[i]=0;
    par[0]=dep[0]=cst[0]=0;
    dfs(0);
   
    for(L i=0; i<n; i++) add[i]=0;
   
    L cnt=0;
    for(L i=0; i<n; i++){
        if(i && hev[par[i]]==i) continue;
        L j=i;
        do{
            pos[j]=cnt++;
            hl_par[j]=i;
        }while(j=hev[j]);
    }
  
    for(L i=0; i<N; i++) bit[i]=0;
    for(L i=0; i<n; i++)
        S(pos[i], edgecost(hev[i]));
       
    L q;
    cin >> q;
    for(L i=0; i<q; i++){
        string s;
        L a, b;
        cin >> s >> a >> b;
        if(s[0]=='a'){
            add[a]+=b;
            S(pos[a], edgecost(hev[a]));
            if(a) S(pos[a]-1, edgecost(a));
        }else{
            cout << cost(a, b) << endl;
        }
    }
}

Measured memory_bytes: 32056
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(b<a){
		d=a;
		a=b;
		b=d;
	}
	else{
	}
	if(c<b){
		d=b;
		b=c;
		c=d;
	}
	else{
	}	
	if(b<a){
		d=a;
		a=b;
		b=d;
	}
	else{
	}
	printf("%d %d %d\n",a,b,c);

	return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int len=s.size();
  int cur=len-1;
  string sub[]={"dreamer","eraser","dream","erase"};
  bool flag=false;
  while(cur>=0){
    REP(i,4){
      if(cur-(int)sub[i].size()<-1){
        continue;
      }else{
        if(s.substr(cur-(int)sub[i].size()+1,(int)sub[i].size())==sub[i]){
          cur -= (int)sub[i].size();
          flag = true;
          break;
        }
      }
    }
    if(flag){
      flag=false;
      continue;
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 512
import sys
from itertools import accumulate


def input():
    return sys.stdin.readline().strip()


def acc(li, n):
    res = [0] * (n + 1)
    for i in range(n):
        if li[i] == "A":
            res[i + 1] = 1
        elif li[i] == "B":
            res[i + 1] = 2
    return list(accumulate(res))


def restore(x, y, li):
    return (li[y] - li[x - 1]) % 3


S = input()
T = input()
N = len(S)
M = len(T)

acc_S = acc(S, N)
acc_T = acc(T, M)

q = int(input())
for _ in range(q):
    a, b, c, d = map(int, input().split())
    v_S = restore(a, b, acc_S)
    v_T = restore(c, d, acc_T)
    print("YES") if v_S == v_T else print("NO")


Measured memory_bytes: 17876
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll INF=1e18L+5;
const int nax=405;
ll dp[nax][nax];
int main()
{
    int n;cin>>n;
    vector<long long int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];

    auto sum=[&](int L,int R){
        ll ans=0;
         for(int i=L;i<=R;i++) ans+=v[i];
         return ans;
    };

      for(int L=n-1;L>=0;L--){
        for(int R=L;R<n;R++){
            if(L==R){
                dp[L][R]=0;
            }
           else {
                dp[L][R]=INF;
                ll s=sum(L,R);
              for(int i=L;i<R;i++){
                dp[L][R]=min(dp[L][R],dp[L][i]+dp[i+1][R]+s);
              }
           }
        }
      }
     cout<<dp[0][n-1];

}


Measured memory_bytes: 4912