akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c,d; cin >> a >> b >> c >> d;
    out(max(min(b,d)-max(a,c),0LL));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  unsigned int S, h, m, s;
  cin >> S;
   if (S>86400){
   cout << "This value is not in the allowed range." << endl;
   } else {
    h = S/3600;
    m = (S % 3600)/60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
   }
}


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


int main(){
    int n,m;
    cin>>n>>m;
    vector<string> f(n);
    for(int i=0;i<n;i++) cin>>f[i];
        
    int res=0;
    bool update=true;
    while(update){
        update=false;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(f[i][j]=='.'){
                    map<char,int> cnt;
                    for(int k=i+1;k<n;k++){
                        if(f[k][j]!='.'){
                            cnt[f[k][j]]++;
                            break;
                        }
                    }
                    for(int k=i-1;k>=0;k--){
                        if(f[k][j]!='.'){
                            cnt[f[k][j]]++;
                            break;
                        }
                    }
                    for(int k=j+1;k<m;k++){
                        if(f[i][k]!='.'){
                            cnt[f[i][k]]++;
                            break;
                        }
                    }
                    for(int k=j-1;k>=0;k--){
                        if(f[i][k]!='.'){
                            cnt[f[i][k]]++;
                            break;
                        }
                    }
                    for(auto &e:cnt){
                        if(e.second==2){
                            update=true;
                            res+=2;
                            for(int k=0;k<n;k++){
                                if(f[k][j]==e.first) f[k][j]='.';
                            }
                            for(int k=0;k<m;k++){
                                if(f[i][k]==e.first) f[i][k]='.';
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3348
N, M = map(int, input().split())
city = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    city[p-1].append((y, i))

ans = [None] * M
for i, c in enumerate(city):
    c.sort()
    for j, (y, k) in enumerate(c):
        ans[k] = str(i+1).zfill(6) + str(j+1).zfill(6)

for m in range(M):
    print(ans[m])

Measured memory_bytes: 74656
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  long long int n,l,i,j;
  cin >> n >> l;
  vector <string> str(n);
  string answer;
  for(i=0;i<n;i++)
  {
    cin >> str[i];
  }
  sort(str.begin(), str.end());
  for(i=0;i<n;i++)
  {
    answer = answer + str[i];
  }
  cout << answer;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    ll n, a = 0, b;
    cin >> n;
    for(b = n; b > 0; b /= 10) {
        a += b % 10;
    }
    puts((n%a==0)?"Yes":"No");

}


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

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int calc(vector<int> &a, vector<int> &b, int d)
{
    int res = 0;
    for (int i = 0; i < d; i++)
    {
        res += (a[i] - b[i]) * (a[i] - b[i]);
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    vector<vector<int>> p(n, vector<int>(d));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> p[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int tmp = calc(p[i], p[j], d);
            double res = sqrt(tmp);
            if (res - int(res) == 0)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int N;
int *A;

int main()
{
    cin >> N;
    A = new int[N];
    int *modList = new int[N];
    for (int i = 0; i < N;i++)
    {
        cin >> A[i];
    }
    int answer = 0;
    int counter = 1;
    for (int i = 0; i < N;i++)
    {
        counter *= 2 - A[i] % 2;
    }

    cout << pow(3, N) - counter;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>

#define int long long

using namespace std;

const int SZ = 1e6;

int dp[SZ];

int32_t main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    fill(dp, dp + SZ, 0);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        dp[i + 1] = max(dp[i + 1], dp[i]);
        dp[i + 2] = max(dp[i + 2], dp[i]);
        if (s[i] == '1' || i == 0 || i == n - 1) continue;
        if (s[i-1] != '1' || s[i + 1] != '1') continue;
        int i1 = i - 1, i2 = i + 1;
        while (s[i1] == '1' && i1 >= 0)
            i1--;
        while (s[i2] == '1' && i2 < n)
            i2++;
        for (int j = i1 + 1; j < i; j++)
            dp[i + 2] = max(dp[i + 2], i - j + dp[j]);
        for (int j = i2 - 1; j > i; j--)
            dp[j + 1] = max(dp[j + 1], j - i + dp[i - 1]);
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 9076
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char ch;
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>aa[i];
        ab[aa[i]]++;
    }
    rep(i,n+1){
        if(ab[i]!=0){
            cnt++;
        }
    }
    sort(ab,ab+n);
    reverse(ab,ab+n);
    rep(i,m){
        n-=ab[i];
    }
    cout<<n<<endl;
}

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

#define REP(i,n) for(long long 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)

using ll = long long;
#define INF 1e9


int main(){
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int A, B;
    scanf("%d", &A);
    scanf("%d", &B);

    for (int i = 1; i <= 3; i++) {
        if (i != A && i != B) {
            printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int H, A;
    cin >> H >> A;

    cout << (H - 1 + A) / A << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

class UnionFind
{
 public:
    vector<int> par,sz;
    UnionFind(int N):par(N),sz(N){
        for(int i=0;i<N;i++){
            par[i]=i; sz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]<sz[y]) swap(x,y);
        par[y]=x;
        sz[x]+=sz[y];
    }
    bool same(int x,int y){ return find(x)==find(y); }
    int size(int x){ return sz[find(x)]; }
    bool root(int x){ return par[x]==x; }
};

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

    int N; cin>>N;
    vector<int> a(N),b(N);
    for(int i=0;i<N;i++) cin>>a[i];
    for(int i=0;i<N;i++) cin>>b[i];

    vector<int> c=a,d=b;
    sort(c.begin(),c.end());
    sort(d.begin(),d.end());
    for(int i=0;i<N;i++) if(c[i]>d[i]){
        cout<<"No"<<endl;
        return 0;
    }

    for(int i=0;i<N-1;i++){
        swap(c[i],c[i+1]);
        if(c[i]<=d[i] and c[i+1]<=d[i+1]){
            cout<<"Yes"<<endl;
            return 0;
        }
        swap(c[i],c[i+1]);
    }

    vector<pair<int,int>> v;
    for(int i=0;i<N;i++) v.push_back({b[i],a[i]});
    sort(v.begin(),v.end());
    for(int i=0;i<N;i++){
        b[i]=v[i].first;
        a[i]=v[i].second;
        // cout<<a[i]<<' '<<b[i]<<endl;
    }

    UnionFind tree(N);
    for(int i=0;i<N;i++){
        int j=lower_bound(c.begin(),c.end(),a[i])-c.begin();
        tree.unite(i,j);
    }
    if(tree.size(0)==N){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

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

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if (b>=a) printf("%d\n",a);
    else printf("%d\n",a-1);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true) {
			String num = br.readLine();
			String[] set = num.split(" ");

			int a = Integer.parseInt(set[0]);
			int b = Integer.parseInt(set[1]);

			if (a==0 && b==0) {
				break;
			}

			for (int i = 0; i < a ; i++) {
				for (int j = 0; j < b ; j++) {
					if(i%2==0) {
						if(j%2==0) {
							sb.append("#");
						}else {
							sb.append(".");
						}
					}else{
						if(j%2==0) {
							sb.append(".");
						}else {
							sb.append("#");
						}
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}

		System.out.print(sb);

	}

}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int H, W;
char grid[22][22];
typedef pair<int, int> Pii;

int cost[22][22][22][22];
int dist[12][12];
int dp[1<<12][12];
map<Pii, int> dmap;
#define MP make_pair

#define INF ((int)1e8)

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

inline bool inF(int x, int y) {
  return 0<=x && x<W && 0<=y && y<H;
}

bool bfs(int SX, int SY) {

#define COST(x, y) cost[SY][SX][y][x]
  
  fill(&COST(0, 0), &COST(0, 0)+22*22, INF);
  queue<Pii> Q;
  Q.push(Pii(SX, SY));
  COST(SX, SY) = 0;
  while(!Q.empty()) {
    Pii pii = Q.front(); Q.pop();
    int x = pii.first, y = pii.second;
    for(int i=0; i<4; i++) {
      int nx = x+dx[i], ny = y+dy[i];
      if(!inF(nx, ny)) continue;
      if(COST(nx, ny) != INF) continue;
      if(grid[ny][nx] == 'x') continue;
      COST(nx, ny) = COST(x, y) + 1;
      Q.push(Pii(nx, ny));
    }
  }
  
  bool ok = true;
  rep(i, H)rep(j, W) if(grid[i][j] == '*' && COST(j, i) == INF) ok = false;
  
  return ok;
}

int main() {
  
  while(cin >> W >> H && (W|H)) {
    
    dmap.clear();
    
    int dsx, dsy;
    int dcnt = 1;
    rep(i, H) rep(j, W){
      cin>>grid[i][j];
      if(grid[i][j] == 'o') {
	dsx = j, dsy = i;
	dmap[Pii(j, i)] = 0;
      }
      if(grid[i][j] == '*') {
	dmap[Pii(j, i)] = dcnt++;
      }
    }

    
    bool NA = false;
    rep(i, H) rep(j, W) {
      if(grid[i][j] == '*' || grid[i][j] == 'o') {
	if(!bfs(j, i)) {
	  cout << -1 << endl; NA = true;
	  i = j = INF;
	}
      }
    }
    if(NA) continue;
    
    rep(i, H) rep(j, W) rep(k, H) rep(l, W) {
      if(i == k && j == l) continue;
      if((grid[i][j] == '*' && grid[k][l] == '*')
	 ||
	 (grid[i][j] == 'o' && grid[k][l] == '*')) {
	dist[dmap[Pii(j, i)]][dmap[Pii(l, k)]] = cost[i][j][k][l];
      }
    }
   
    int V = dcnt;
    
    for(int i=0; i<(1<<V); i++) fill(dp[i], dp[i]+12, INF);
    dp[(1<<V)-1][0] = 0;
    
    for(int st = (1<<V)-2; st >= 0; st--) {
      for(int v=0; v<V; v++) {
	for(int u=0; u<V; u++) {
	  if(!((st >> u) & 1)) { dp[st][v] = min(dp[st][v], dp[st|(1<<u)][u]+dist[v][u]); }
	}
      }
    }
    
    cout << dp[0][0] << endl;
  }
  
  return 0;
}

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

int main(){
    int K,S;
    cin >> K >> S;

    int count = 0;

    rep(i,K+1){
        rep(j,K+1){
            if(S-i-j <= K && S-i-j >= 0){
                count++;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
typedef long long ll;
ll n;
ll a[200];
ll sum[200]={0};
int main(void)
{
	scanf("%lld",&n);
	for(ll i=0;i<n;i++) scanf("%lld",&a[i]);
	ll mon=1000;
	for(ll i=0;i<n-1;i++)
	{
		sum[i]=a[i+1]-a[i];
	}
	vector<ll> vec;
	bool up=true;
	if(sum[0]>=0) vec.push_back(a[0]);
	if(sum[0]<0) up=false;
	ll st=0;
	for(ll i=1;i<n-1;i++)
	{
		if(sum[i]>=0&&!up)
		{
			vec.push_back(a[i]);
			up=!up;
		}
		else if(sum[i]<0&&up)
		{
			vec.push_back(a[i]);
			up=!up;
		}
	}
	if(vec.size()%2!=0&&a[n-1]>=a[n-2]) vec.push_back(a[n-1]);
	for(ll i=0;i<vec.size();i+=2)
	{
		ll k=mon/vec[i];
		mon=mon-vec[i]*k+vec[i+1]*k;
	}
	printf("%ld\n",mon);
}


Measured memory_bytes: 3792
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
int u,min;
int d[MAX],p[MAX],color[MAX];

for(int i=0;i<n;i++){
d[i]=INFTY;
p[i]=-1;
color[i]=WHITE;
}

d[0]=0;

while(1){
min=INFTY;
u=-1;
for(int i=0;i<n;i++){
if(min>d[i]&&color[i]!=BLACK){
u=i;
min=d[i];
}
}
if(u==-1)break;
color[u]=BLACK;
for(int v=0;v<n;v++){
if(color[v]!=BLACK&&M[u][v]!=INFTY){
if(d[v]>M[u][v]){
d[v]=M[u][v];
p[v]=u;
color[v]=GRAY;
}
}
}
}
int sum=0;
for(int i=0;i<n;i++){
if(p[i]!=-1)sum+=M[i][p[i]];
}
return sum;
}

int main(){
cin >> n;

for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
int e;
cin >> e;
M[i][j]=(e==-1)?INFTY : e;
}
}

cout << prim() << endl;

return 0;
}

Measured memory_bytes: 3120
#Minesweeper
H,W = map(int,input().split())
S = ["."*(W+2)]
for i in range(H):
    S.append("."+input()+".")
S.append("."*(W+2))

for i in range(H):
    R = ""
    for j in range(W):
        n = 0
        if S[i+1][j+1] == "#":
            R = R + "#"
        else:
            if S[i][j] == "#":
                n += 1
            if S[i][j+1] == "#":
                n += 1
            if S[i][j+2] == "#":
                n += 1
            if S[i+1][j] == "#":
                n += 1
            if S[i+1][j+2] == "#":
                n += 1
            if S[i+2][j] == "#":
                n += 1
            if S[i+2][j+1] == "#":
                n += 1
            if S[i+2][j+2] == "#":
                n += 1
            R = R + str(n)
    print(R)
    

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;
using System.Collections;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static string s;
    
    static bool CanReach(int l, int r)
    {
	for (int i = l; i < r; i++)
	{
	    if (s[i] == '#' && s[i+1] == '#') return false;
	}
	return true;
    }
    
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], a = tmp[1], b = tmp[2], c = tmp[3], d = tmp[4];
	s = "#" + ReadLine() + "#";

	if (!CanReach(a, c) || !CanReach(b, d))
	{
	    WriteLine("No");
	    return;
	}

	if (c > d)
	{
	    bool can_overtake = false;
	    for (int i = b; i <= d; i++)
	    {
		if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.')
		{
		    can_overtake = true;
		    break;
		}
	    }

	    WriteLine(can_overtake ? "Yes" : "No");
	    return;
	}
	
	WriteLine("Yes");
    }
}


Measured memory_bytes: 14304
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



string s;
map<string,int> c;
int mx;

signed main() {
	while (!cin.eof()) {
		cin >> s;
		c[s]++;
	}
	s = "";
	each(i,c) {
		chmax(mx,i.second);
		if (s.size()<i.first.size()) s = i.first;
	}
	each(i,c) if (i.second==mx) cout << i.first << ' ';
	cout << s << endl;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int N=100010;
int n;
vector<vector<int>> g(N);
vector<int> color(N,0);

bool dfs(int v,int c){
	color[v]=c;
	for(auto itr:g[v]){
		if(color[itr]==c) return false;
		if(color[itr]==0 && !dfs(itr,-c)) return false;
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m;
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	if(m<=2){
		cout<<0<<endl;
		return 0;
	}
	if(dfs(0,1)){
		int cnt=0;
		rep(i,n){
			if(color[i]==1) cnt++;
		}
		cout<<(ll)cnt*(ll)(n-cnt)-m<<endl;
	}else{
		cout<<ll(n)*ll(n-1)/2-m<<endl;
	}
}

Measured memory_bytes: 6528
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)


def base_10_to_n(x, n):
    if (int(x/n)):
        return base_10_to_n(int(x / n), n)+str(x % n)
    return str(x % n)


N, K = inp_list()
n_base_k = base_10_to_n(N, K)
print(len(n_base_k))


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

#define VV(T) vector<vector<T> >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

#define REP(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  VV(int) d;
  initvv(d, n, n, 1010101010);
  for (int i = 0; i < n; ++i) {
    d[i][i] = 0;
  }
  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
  int ans = 0;
  for (int i = 0; i < m; ++i) {
    ans += d[a[i]][b[i]] != c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
A.sort()
dp = [True] * (max(A) + 1)
ans = 0
for n in A:
    ans += int(dp[n] and cnt[n] == 1)
    tmp = n
    while tmp < len(dp):
        dp[tmp] = False
        tmp += n
print(ans)

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

template<typename T> bool chmax(T &a,const T b){if(a < b){a=b; return true;} return false;}
template<typename T> bool chmin(T &a,const T b){if(a > b){a=b; return true;} return false;}

const int MAX = 510000;


ll 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; //i!の計算
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; //iの逆元の計算
        finv[i] = finv[i - 1] * inv[i] % MOD; //i!の逆元の計算
    }
}

// 二項係数計算
ll 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;
}

int main(){
    int s; cin >> s;
    ll ans=0;
    COMinit();
    for(int i=1; i<=s/3; i++){
        ans=(ans+COM(s-2*i-1, i-1))%MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15580
#include<math.h>
#include<stdio.h>
int main(void)
{
	int n = 1, i,score[1000];
	double sum = 0;
	double ave, dev=0;//devは「deviation：偏差」aveは「average」の省略
	while (n != 0)
	{
		scanf(" %d", &n);
		if (n != 0)
		{
			for (i = 0; i < n; i++)
			{
				scanf("%d", &score[i]);
				sum += score[i];
			}
			ave = sum / n;
			for (i = 0; i < n; i++)
			{
				dev += (score[i] - ave)*(score[i] - ave);
			}
			printf("%f\n", sqrt(dev/n));
		}
		dev = 0;
		sum = 0;
	}
	return 0;
}


Measured memory_bytes: 2032
//#include "pch.h"
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)

int n, a, b, c;
vector<int> bamboo(8);
int min1 = 9999999;

void calc(vector<int> flag) {
	//FOR(i, 0, n) cout << flag[i] << ",";
	//cout << endl;

	int cost = -30; //a,b,cの1回分の合成costを始めに引いておく

	//合成
	vector<int> synthesis(4,0);
	FOR(i,0,n) {
		synthesis[ flag[i] ] += bamboo[i];
		//a,b,cのどれかに使うならcostに10足す
		if (flag[i] != 0) cost += 10;
	}

	//FOR(i, 0, 4) cout << synthesis[i] << ",";
	//cout << endl;
	//cout << a << " " << b << " " << c << endl;

	if (synthesis[1] != 0 && synthesis[2] != 0 && synthesis[3] != 0) {
		cost += abs(a - synthesis[1]) + abs(b - synthesis[2]) + abs(c - synthesis[3]);
		min1 = min(min1, cost);
		//cout << cost << " : " << min1 << endl;
	}
}

//0: 未使用、1:a、2:b、3:c
void dfs(int depth, vector<int> flag) {
	if (depth == n) calc(flag);
	else{
		FOR(i, 0, 4) {
			flag[depth] = i;
			dfs(depth + 1, flag);
		}
	}
}

int main(void) {
	
	cin >> n >> a >> b >> c;
	
	FOR(i, 0, n) {
		cin >> bamboo[i];
	}

	vector<int> comb(n);
	dfs(0, comb);

	//cout << "ans:" << endl;
	cout << min1 << endl;

	//vector<int> flag({1,2,2,2,3});
	//calc(flag);
}

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

using namespace std;
typedef long long ll;
#define pb push_back
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1000000000000000;

int main(){
	ll N; cin>>N;
	vector<ll>A(N);
	vector<ll>B(N);
	vector<ll>C(N);
	rep(i,N) cin>>A[i]; A.pb(INF);
	rep(i,N) cin>>B[i];
	rep(i,N) cin>>C[i]; C.pb(INF);
	sort(all(A));sort(all(B));sort(all(C));

	ll ans=0;
	rep(b,N){
		ll l=0,r=N;
		while(r-l>=1){
			ll i=(l+r)/2;
			if(A[i]<B[b]) l=i+1;
			else r=i;
		}
		ll tmpA=l;

		l=0,r=N;
		while(r-l>=1){
			ll i=(l+r)/2;
			if(C[i]<=B[b]) l=i+1;
			else r=i;
		}
		ll tmpC=N-l;
		ans+=tmpA*tmpC;
	}
	cout<<ans;
}

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

#define sz(x) (int)(x.size())
#define int long long

const int N = 1e5 + 2, inf = 1e18;

std::vector<int> g[N];
int n, m, u, v, vis[N], ans[N];

struct DSU
{
    int connected;
    int par[N], sz[N];
 
    void init(int n) 
    {
        for(int i=1;i<=n;i++)
        {
            par[i]=i;
            sz[i]=1;
        }
        connected=n;
    }
 
    int getPar(int k)
    {
        while(k!=par[k])
        {
            par[k]=par[par[k]];
            k=par[k];
        }
        return k;
    }
 
    int getSize(int k)
    {
        return sz[getPar(k)];
    }

    bool same(int u , int v)
    {
        return (getPar(u) == getPar(v));
    }
 
    bool unite(int u, int v)
    {
        int par1=getPar(u), par2=getPar(v);
 
        if(par1==par2)
            return false;
 
        connected--;
 
        if(sz[par1]>sz[par2])
            swap(par1, par2);
 
        sz[par2]+=sz[par1];
        sz[par1]=0;
        par[par1]=par[par2];
        return true;
    }
};

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    cin >> n >> m;
    DSU dsu;
    dsu.init(n);
    while(m--){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        dsu.unite(u, v);
    }
    if(dsu.connected != 1){
        cout << "No" << '\n';
        return 0;
    }

    queue<int> Q;
    Q.push(1);
    while(!Q.empty()){
        int start = Q.front();
        vis[start] = 1;
        Q.pop();
        for(int child : g[start]) if(!vis[child]){
            ans[child] = start;
            vis[child] = 1;
            Q.push(child);
        }
    }

    cout << "Yes" << '\n';
    for(int i = 2; i <= n; i++)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 15336
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

problem = [0, 0, 0]
for p in P:
    if p <= a:
        problem[0] += 1
    elif p <= b:
        problem[1] += 1
    else:
        problem[2] += 1

print(min(problem))

Measured memory_bytes: 61712
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;

int main() {
  string S;
  cin >> S;
  
  int t = 0;
  int maxT = t;
  for(int i = 0;i < S.length();++i){
    if(S[i] == 'R'){
      t++;
      if(maxT < t){
        maxT = t;
      }
    }
    else{
      t = 0;
    }
  }
  cout << maxT << endl;
}


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



int main()
{
	std::ios::sync_with_stdio(false);
    
	int n, k;
	cin >> n >> k;

	int cnt = 0;

	for (int i = 1; i <= n; i=i+2)
	{
		cnt++;
	}

	if (cnt >= k)
	{
		cout << "YES"<<endl;
	}
	else
	{
		cout << "NO" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	as := make([]int, 5)
	for i := range as {
		fmt.Scan(&as[i])
	}

	tmpIdx := 0
	tmp := as[tmpIdx] % 10
	for i := 1; i < len(as); i++ {
		r := as[i] % 10
		if r != 0 && r < tmp {
			tmpIdx = i
			tmp = r
		}
	}

	var time int
	for i, a := range as {
		if i != tmpIdx {
			r := a % 10
			if r != 0 {
				time += a - r + 10
			} else {
				time += a
			}
		} else {
			time += a
		}
	}

	fmt.Print(time)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;cin>>n>>k;
    vector<int> a(n);rep(i,n)cin>>a[i];
    bool alln = false;
    
    while(!alln&&k>0){
        k--;
        alln = true;
        vector<ll> inc(n+1,0);
        for(int i=0; i<n; i++){
            inc[max(0,i-a[i])]+=1;
            inc[min(n,i+a[i]+1)]-=1;
        }
        int pre = 0;
        for(int i=0; i<n; i++){
            a[i] = pre + inc[i];
            pre = a[i];
            if(a[i]!=n)alln = false;
        }
    }

    for(int A:a)cout<<A<<" ";


    return 0;
}

Measured memory_bytes: 5524
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    s = input()
    if s=="AC":
        ac += 1
    if s=="TLE":
        tle += 1
    if s=="WA":
        wa += 1
    if s=="RE":
        re += 1
for s,c in [("AC", ac), ("WA", wa), ("TLE", tle), ("RE", re)]:
    print("{} x {}".format(s, c))

Measured memory_bytes: 9208
import java.util.*;
import java.io.*;

public class Main {

	static final int mod = 998244353;
	static long base;
	static long modInv;

	public static long dp(int idx, int rem, long[][] dp, int[] a) {
		if (rem < 0)
			return 0;
		if (rem == 0) {
			return base;
		}
		if (idx == a.length)
			return 0;
		if (dp[idx][rem] != -1)
			return dp[idx][rem];
		return dp[idx][rem] = (dp(idx + 1, rem, dp, a) + modInv * dp(idx + 1, rem - a[idx], dp, a)) % mod;

	}

	public static long modpow(int a, int e) {
		if (e == 0)
			return 1;
		long p = modpow(a, e / 2);
		if (e % 2 == 0)
			return (p * p) % mod;
		else
			return a * p % mod * p % mod;
	}

	public static long modInv(int a) {
		return modpow(a, mod - 2) % mod;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int s = sc.nextInt();
		int[] a = sc.nextIntArr(n);
		long[][] dp = new long[n][s + 1];
		for (long[] x : dp)
			Arrays.fill(x, -1);
		base = modpow(2, a.length);
		modInv = modInv(2);
		pw.println(dp(0, s, dp, a));
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}


Measured memory_bytes: 96916
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef pair<int, int> pa;
typedef vector<pair<int,int> > vepa;
typedef map<int, int> mp;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
ll cnt[N]={};
bool f;
 int main()
{
    ll n;
    cin>>n;
    ve v(n);
   for(ll i=0;i<n&&cin>>v[i];i++);
   sort(all(v));
   rep(i,n)
   {
       if(v[i]==v[i+1])
       {
           puts("NO");
           go;
       }
   }
   puts("YES");

go;
}


Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var x, k, d int
	fmt.Scan(&x, &k, &d)

	x = abs(x)
	c := min(k, max(1, x/d))
	x = abs(x - c*d)
	k -= c
	if k == 0 {
		fmt.Println(abs(x))
		return
	}

	if k%2 == 1 {
		x = abs(x - d)
	}

	fmt.Println(x)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1832
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int digitSum(int n,int digit=8) {
	// digit > 2
	int x = 1;
	FOR(i,0,digit){
		x *= 10;
	}
	int sum = 0;
	FOR(i, 0, digit) {
		sum += n / x;
		n %= x;
		x /= 10;
	}
	sum += n;
	return sum;
}

int checkSize(string s) {
	return s.size();
}

int nHalf(int n) {
	return n / 2;
}

int main()
{
	string s;
	cin >> s;
	if(s.size()%2==1)s.pop_back();
	else {
		s.pop_back(); s.pop_back();
	}
	int i = 0;
	while(not s.empty() and i<nHalf(checkSize(s))){
		if (s[i] != s[nHalf(checkSize(s)) + i]) {
			s.pop_back();
			s.pop_back();
			i = 0;
			continue;
		}
		else { i++; continue; }
	}
	cout << checkSize(s) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
    int a[4];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    if(a[0]+a[1]==a[2]) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}


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

typedef long long int lli;
typedef pair<int, int> ii;
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false);

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

	return 0;
}

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

public class Main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    StringTokenizer tok = new StringTokenizer("");

    String next() throws IOException {
        if (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long mod = (long) (1e9 + 7);

    void slave() throws IOException {
        int n = nextInt();
        String s = next();
        int col[] = new int[26];
        for (int i = 0; i < s.length(); i++) {
            col[s.charAt(i) - 'a']++;
        }
        long ans = 0;
        for (int i = 0; i < 26; i++) {
            long ans1 = 0;
            ans1 = (ans * col[i]) % mod;
            ans1 = (ans1 + ans) % mod;
            ans1 = (ans1 + col[i]) % mod;
            ans = ans1;
        }
        System.out.println(ans);
    }

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

Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), D = sc.nextInt();
		int row[] = new int[N * M], col[] = new int[N * M];
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= M; j++) {
				int k = sc.nextInt() - 1;
				row[k] = i;
				col[k] = j;
			}
		}
		int O[][] = new int[D][N * M / D + 1];
		int P[][] = new int[D][N * M / D + 1];
		for (int r = 0; r < D; r++) {
			for (int k = 1; k * D + r < N * M; k++) {
				int f = (k - 1) * D + r;
				int s = k * D + r;
				O[r][k] = Math.abs(row[f] - row[s]) + Math.abs(col[f] - col[s]);
			}
		}
		for (int r = 0; r < D; r++) {
			for (int k = 1; k * D + r < N * M; k++) {
				P[r][k] = P[r][k - 1] + O[r][k];
			}
		}
		int Q = sc.nextInt();
		while (Q-- > 0) {
			int l = sc.nextInt() - 1, r = sc.nextInt() - 1;
			System.out.println(P[r % D][r / D] - P[l % D][l / D]);
		}
	}

}

Measured memory_bytes: 61968
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

int N,ans, dp[500001][4];
string s;

void solve(vi z) {
    vi cur; cur.pb(0);
    int tmp = 0;
    F0R(i,z.size()) {
        if (z[i] == 0) {
            if (tmp) cur.pb(tmp);
            tmp = 0;
        } else tmp++;
    }
    if (tmp) cur.pb(tmp);
    FOR(i,1,cur.size()) {
        dp[i][0] = dp[i][1] = dp[i][2] = dp[i][3] = 0; // nothing, 1, whole-1, whole
        dp[i][3] = max(max(dp[i-1][0],dp[i-1][1]),max(dp[i-1][2],dp[i-1][3]));
        
        // fill dp[i][0]
        if (cur[i-1] >= 1) dp[i][0] = max(dp[i][0],dp[i-1][1]+cur[i]);
        if (cur[i-1] >= 2) dp[i][0] = max(dp[i][0],dp[i-1][2]+cur[i]);
        if (cur[i-1] >= 1) dp[i][0] = max(dp[i][0],dp[i-1][3]+cur[i]);
        
        // fill dp[i][1]
        if (cur[i-1] >= 1) dp[i][1] = max(dp[i][1],dp[i-1][1]+cur[i]-1);
        if (cur[i-1] >= 2) dp[i][1] = max(dp[i][1],dp[i-1][2]+cur[i]-1);
        if (cur[i-1] >= 1) dp[i][1] = max(dp[i][1],dp[i-1][3]+cur[i]-1);
        
        // fill dp[i][2]
        if (cur[i-1] >= 1) dp[i][2] = max(dp[i][2],dp[i-1][1]+1);
        if (cur[i-1] >= 2) dp[i][2] = max(dp[i][2],dp[i-1][2]+cur[i-1]-1);
        if (cur[i-1] >= 1) dp[i][2] = max(dp[i][2],dp[i-1][3]+cur[i-1]);
    }
    ans += max(max(dp[cur.size()-1][0],dp[cur.size()-1][3]),max(dp[cur.size()-1][1],dp[cur.size()-1][2]));
}

void process() {
    vi z;
    F0R(i,s.length()) {
        z.pb(s[i]-'0');
        if (z.size() > 1 && z[z.size()-1] == 0 && z[z.size()-2] == 0) {
            solve(z);
            z.clear();
        }
    }
    solve(z);
}

int main() {
    F0R(j,1) {
    	cin >> N >> s;
        ans=0;
        process();
        cout << ans << "\n";
    }
}

// read!
// ll vs. int!

Measured memory_bytes: 4856
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=500010;
int f[N];
char s[N];
int main() {
    int n;
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++) {
	f[i]=max(f[i],f[i-1]);
	if(s[i]=='1'&&s[i+1]=='0'&&s[i+2]=='1') {
	    int l=i,r=i+2;
	    while(s[l-1]=='1') --l;
	    while(s[r+1]=='1') ++r;
	    for(int j=i+2;j<=r;j++)
		f[j]=max(f[j],f[i-1]+j-i-1);
	    for(int j=l;j<=i;j++)
		f[i+2]=max(f[i+2],f[j-1]+i+1-j);
	}
    }
    cout<<f[n];
    return 0;
}

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

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int count = 0;
    for(int i=0;i<=a;i++){
      for(int j=0;j<=b;j++){
        for(int k=0;k<=c;k++){
          int total = 500 * i + 100 * j + 50 * k;
          if(total == x){
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}


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

using namespace std;

const double k = 0.006;

int n, t, a, h, ans = 1;
double tmp;

inline double calc(int x)
{
	return abs(a-(t-x*k));
}

int main()
{
	cin >> n >> t >> a >> h;
	tmp = calc(h);
	for(int i = 2; i <= n; ++i)
	{
		cin >> h;
		if(calc(h) < tmp)
		{
			tmp = calc(h);
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#define endl "\n"
#define ll long long
using namespace std;

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

    unordered_map <ll, ll> mp;
    ll count = 0;
    for(ll i = 0; i < n; i ++)
    {
    	ll value;
		cin >> value;
		count += mp[i - value];
		mp[i + value] ++;
    }

    cout << count << endl;

}

Measured memory_bytes: 18404
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n), b(n);
  REP(i, 0, n) cin >> a[i];
  REP(i, 0, n) cin >> b[i];
  vector<vector<VI> > cb(29, vector<VI>(2, VI()));
  REP(i, 0, 29) {
    REP(j, 0, n) {
      int pat =  b[j] & ((1 << i) - 1);
      int pop = b[j] & 1 << i ? 1 : 0;
      cb[i][pop].push_back(pat);
    }
    REP(pop, 0, 2) {
      sort(cb[i][pop].begin(), cb[i][pop].end());
    }
  }
  ll ans = 0;
  REP(i, 0, 29) {
    int bpop = 0;
    REP(j, 0, n) {
      if (b[j] & 1 << i) {
	bpop += 1;
      }
    }
    if (0&&i <= 3) {
      DEBUGP(i);
      DEBUGP(bpop);
    }
    REP(j, 0, n) {
      int pat = a[j] & ((1 << i) - 1);
      int apop = a[j] & 1 << i ? 1 : 0;
      int num = apop ? n - bpop : bpop;
      REP(pop, 0, 2) {
	int idx = cb[i][pop].end() - lower_bound(cb[i][pop].begin(), cb[i][pop].end(), (1 << i) - pat);
	if(0&&i<=3){
	  DEBUGP(pop);
	  DEBUGP(idx);
	}
	if (pop == apop) {
	  num += idx;
	} else {
	  num -= idx;
	}
      }
      if (0&&i <= 3) {
	DEBUGP(j);
	DEBUGP(num);
      }
      if (num % 2 != 0) {
	ans ^= 1 << i;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 30456