akhauriyash/Code-Regression huggingface dataset:
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import math
import copy

a,b=map(int, input().split())

if(a < 6):
    print(0)
elif 6 <= a <= 12:
    print(int(b/2))
else:
    print(b)

Measured memory_bytes: 3572
/*input
10
5 3
5 7
8 9
1 9
9 10
8 4
7 4
6 10
7 2

*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
#define trav(a,x) for(auto &a:x)
#define bits(n) __builtin_popcount(n)
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 2*pow(10,5)+1;
 

//standard input and output template
template<typename... T>
void in(T&... args) {
    ((cin >> args), ...);
}

template<typename... T>
void out(T&&... args) {
    ((cout << args << " "), ...);
}

template<typename... T>
void outl(T&&... args) {
    ((cout << args << endl), ...);
}


int fast_exp(int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp/=2;
    }
    return res%mod;
}




int32_t main() {
  IOS;
  int t=1;
  while(t--){
    int n;cin>>n;
    int ans = 0;
    for(int i=0;i<n;i++){
      ans+=(i+1)*(n-i);
    }
    for(int i=0;i<n-1;i++){
      int u,v;
      cin>>u>>v;
      int maxi = max(u-1,v-1);
      int mini = min(u-1,v-1);
      ans-= (n-maxi)*(mini+1);
    }
    outl(ans);
  }
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vstr=vector<string>;
#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++)
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    vstr ans(s.size());
    string t="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    rep(i,s.size()){
        rep(j,26){
            if(s[i]==t[j]){
                if(j+n<=25)ans[i]=t[j+n];
                else if(j+n>25)ans[i]=t[j+n-26];
            }
        }
    }
    rep(i,s.size())cout<<ans[i];
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	string X;
	cin >> X;
	reverse(ALL(X));

	ll ans = 0;
	ll cnt = 0;
	REP(i, X.size()) {
		if (X[i] == 'T') {
			cnt--;
		} else {
			cnt++;
		}
		ans = max(cnt, ans);
	}

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


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

using namespace std;

long long dfs(int k, vector<long long>& b, int i) {
    if (i < 0) {
        return 0;
    }

    vector<long long> c(0);
    for (int j = 0; j < static_cast<int>(b.size()); j++) {
        if ((b[j] & (1LL << i)) > 0) {
            c.push_back(b[j]);
        }
    }

    if (static_cast<int>(c.size()) >= k) {
        return (1LL << i) + dfs(k, c, i - 1);
    } else {
        return dfs(k, b, i - 1);
    }
}

int main() {
    int n, k;
    cin >> n >> k;

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

    vector<long long> b(0);
    for (int i = 0; i < n; i++) {
        b.push_back(a[i]);
        for (int j = i + 1; j < n; j++) {
            b.push_back(b[b.size() - 1] + a[j]);
        }
    }

    cout << dfs(k, b, 61) << endl;
}


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

struct unionfind
{
    int n; 
    vector<int> par, rank;
    unionfind(int sz) : n(sz), par(sz), rank(sz)
    {
        for(int i=0; i<sz; i++)
        {
            par[i]=i;
            rank[i]=0;
        }
    }
    int find(int x)
    {
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
    void unite(int x, int y)
    {
        x=find(x), y=find(y);
        if(x==y) return;
        if(rank[x]>rank[y]) par[x]=y;
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x)==find(y);
    }
};

int main()
{
    int N, K, L;
    cin >> N >> K >> L;
    unionfind road(N), rail(N);
    for(int i=0; i<K; i++)
    {
        int p, q;
        cin >> p >> q;
        p--, q--;
        road.unite(p, q);
    }
    for(int i=0; i<L; i++)
    {
        int r, s;
        cin >> r >> s;
        r--, s--;
        rail.unite(r, s);
    }
    map<pair<int, int>, int>  ans;
    for(int i=0; i<N; i++) 
        ans[make_pair(road.find(i), rail.find(i))]++;
    for(int i=0; i<N; i++) 
        cout << ans[make_pair(road.find(i), rail.find(i))] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 17700
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
 
 int lis( int arr[], int n )  
{  
    int lis[n]; 
   
    lis[0] = 1;    
  
    /* Compute optimized LIS values in bottom up manner */
    for (int i = 1; i < n; i++ )  
    { 
        lis[i] = 1; 
        for (int j = 0; j < i; j++ )   
            if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)  
                lis[i] = lis[j] + 1;  
    } 
  
    // Return maximum value in lis[] 
    return *max_element(lis, lis+n); 
}  
void computeLPSArray(char* pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
} 
string longestCommonPrefix(string ar[], int n) 
{ 
  
    // If size is 0, return empty string 
    if (n == 0) 
        return ""; 
  
    if (n == 1) 
        return ar[0]; 
  
    // Sort the given array 
    sort(ar, ar + n); 
  
    // Find the minimum length from  
    // first and last string 
    int en = min(ar[0].size(),  
                 ar[n - 1].size()); 
  
    // Now the common prefix in first and  
    // last string is the longest common prefix 
    string first = ar[0], last = ar[n - 1]; 
    int i = 0; 
    while (i < en && first[i] == last[i]) 
        i++; 
  
    string pre = first.substr(0, i); 
    return pre; 
} 
bool isvalid(ll int x, ll int y, ll int m, ll int n)
{
    if(x<0||y<0||x>=m||y>=n)return 0;
    else return 1;
}
bool iscor(ll int x, ll int y, ll int m, ll int n)
{
    if(x==0||y==0||x==m-1||y==n-1)return 1;
    else return 0;
}

    
int main()
{
  fastio();
 
ll int T;
//cin>>T;
T=1;
ll int anscount=1;
while(T--)
{
 ll int x,y,z;
 cin>>x>>y>>z;
 swap(x,y);
 swap(x,z);
 cout<<x<<" "<<y<<" "<<z<<endl;
  
  
  
}
    return 0;
}

Measured memory_bytes: 256
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque
#from functools import reduce

#a, b = [int(v) for v in input().split()]


def main():
    S = input()

    count = sum(1 for i in range(len(S) // 2) if S[i] != S[-(i+1)])
    print(count)


main()


Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<map>
#include<string>
#include<queue>
using namespace std;
typedef pair<int,int>P;
typedef map<string,int>MAP;
int d[500][500],N,X=0x7f7f7f7f;
int F(int from,int to)
{
	int f[500]={},i,k;
	priority_queue<P>q;
	q.push(P(0,from));
	for(;;)
	{
		P p=q.top();q.pop();
		i=p.second;
		if(f[i]++)continue;
		if(i==to)return -p.first;
		for(k=0;k<N;++k)if(d[i][k]-X)q.push(P(p.first-d[i][k],k));
	}
}
int main()
{
	int M,h,t,x,i,j;
	MAP m;
	MAP::iterator ite;
	char s[64],p[64],g[64],a[64],b[64];
	while(scanf("%d%d",&N,&M),N)
	{
		m.clear();
		memset(d,X,sizeof(d));
		scanf("%s%s%s",s,p,g);
		while(M--)
		{
			scanf("%s%s%d%d",a,b,&h,&t);
			if((ite=m.find(a))==m.end())
			{
				x=m.size();
				m[a]=i=x;
			}
			else i=ite->second;
			if((ite=m.find(b))==m.end())
			{
				x=m.size();
				m[b]=j=x;
			}
			else j=ite->second;
			d[i][j]=d[j][i]=h/40+t;
		}
		printf("%d\n",F(m[s],m[p])+F(m[p],m[g]));
	}
	return 0;
}

Measured memory_bytes: 1980
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int n,k;
bool dp[100005];
int a[101];
int main(){
	memset(dp,0,sizeof(dp));
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	for(int i=0;i<=k;i++)
		if(dp[i]==0)
			for(int j=0;j<n;j++)
				if(i+a[j]<=k)
					dp[i+a[j]]=1;
	printf("%s\n",dp[k]?"First":"Second");
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    string s;
    cin >> s;
    bool flag1 = true;
    if (s[0] != 'A')
    {
        flag1 = false;
    }
    bool flag2 = false;
    int t;
    for (int i = 2; i < s.size() - 1; i++)
    {
        if (s[i] == 'C')
        {
            flag2 = true;
            t = i;
        }
    }
    bool flag3 = true;
    rep(i, s.size())
    {
        if(i==0 || i==t){
            continue;
        }
        if ('a' <= s[i] && s[i] <= 'z')
        {
        }
        else
        {
            flag3 = false;
        }
    }
    if(flag1 && flag2 && flag3){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}

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

#define mp make_pair
#define f first
#define s second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define speed() ios_base::sync_with_stdio(0), cin.tie()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); ++it)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N = (int)2e5;
int n, a[N];
ll s[N];

int main() { 
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	#endif
	
	scanf("%d", &n);
	ll sum = 0;
	ll mns = (ll)n * (n + 1) / 2;
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		sum += a[i];
	}
	if (sum % mns != 0) {
		puts("NO");
		return 0;
	}
	ll k = sum / mns;
	for (int i = 0; i < n; i++) {
		ll x = a[i] - a[(i+1)%n] + k;
		if (!(x >= 0 && x % n == 0)) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");

	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <deque>
using namespace std;

long long tot(long long num) {
	return (num*(num - 1) / 2);
}

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);

	long long n, m;
	cin >> n >> m;
	long long nn = tot(n);
	long long mm = tot(m);

	cout << nn + mm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;

    FOR(i,1,10000) {
        int ta = 0.08 * i;
        int tb = 0.1 * i;
        if (ta == a && tb == b) {
            OUT(i)
            return 0;
        }

    }

    OUT(-1)

    return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll inf = 100100100100100;

vector<vector<ll>> warshall_floyd(vector<vector<ll>> edges,int v){
    vector<vector<ll>> ret = edges;
    rep(k,0,v){
        rep(i,0,v){
            rep(j,0,v){
                if(ret[i][k] == inf || ret[k][j] == inf) continue;
                ret[i][j] = min(ret[i][j],ret[i][k] + ret[k][j]);
            }
        }
    }
    return ret;

}

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

    vector<vector<ll>> edges;
    int v,e;
    cin >> v >> e;
    vector<ll> t;
    rep(i,0,v) t.push_back(inf);
    rep(i,0,v) edges.push_back(t);
    rep(i,0,v) edges[i][i] = 0;
    rep(i,0,e){
        int from, to, cost;
        cin >> from >> to >> cost;
        edges[from][to] = cost;
    }

    edges = warshall_floyd(edges,v);

    rep(i,0,v) if(edges[i][i] < 0) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }

    rep(i,0,v){
        rep(j,0,v){
            if(edges[i][j] < inf) cout << edges[i][j]; else cout << "INF";
            if (j < v-1) cout << " ";
        }
        cout << endl;
    }

    
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if( (a + b) > (c + d)){
    cout << "Left" << endl;
  }
  else if((a + b) < (c + d)){
    cout << "Right" << endl;
  }
  else if((a + b) == (c + d)){
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  deque<char> dq;
  string s;
  int q;
  cin >> s >> q;
  for (int i = 0; i < s.length(); i++) {
    dq.push_back(s[i]);
  }
  bool mae = true;
  for (int i = 0; i < q; i++) {
    int suuji;
    cin >> suuji;

    if (suuji == 1) {
      //反転する
      // RSORT(s);
      if (mae)
        mae = false;
      else
        mae = true;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (mae) {
        if (f == 1) {
          //先頭に追加
          dq.push_front(c);
        } else {
          //末尾に追加
          dq.push_back(c);
        }
      } else {
        if (f == 1) {
          dq.push_back(c);
        } else {
          dq.push_front(c);
        }
      }
    }
  }
  if (mae) {
    for (int i = 0; i < dq.size(); i++) cout << dq[i];
    cout << endl;
  } else {
    RSORT(dq);
    for (int i = 0; i < dq.size(); i++) cout << dq[i];
    cout << endl;
  }
}


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

int main() {
    long long int n, y, s = 1000, g = 5000, m = 10000;
    cin >> n >> y;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            int k = abs(n - (i + j));
            if(i + j + k == n && i*m + j*g + k*s == y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    k = int(input())
    a = [1]
    a.append(7 % k)
    [a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1)]
    for i in range(1, k+1):
        if a[i] == 0:
            print(i)
            return
    print(-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 210060
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

s = list(input().rstrip())
n = len(s)

l = s[:(n-1) // 2]
r = s[(n+3) // 2 - 1:]
if s == s[::-1] and l == l[::-1] and r == r[::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#!python3

import sys

input = sys.stdin.readline

def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    smap = [1<<(i-c0) for i in range(c0, ord('z')+1)]

    T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)]

    for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

    ans = []
    #print(T)
    for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

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

if __name__ == "__main__":
    resolve()


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

#define INFTY 100000
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int head,tail;

int min(int,int);
void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(int);
int dequeue(void);
void bfs(void);

int Q[N];
int M[N][N],color[N],d[N],p[N];
int n;

int main(void){
  int u,k,v;
  int i,j;

  scanf(" %d",&n);

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      M[i][j] = 0;
    }
  }
  

  for(i = 1; i <= n; i++){
    scanf(" %d %d",&u,&k);
    for(j = 1; j <= k; j++){
      scanf(" %d",&v);
      M[u][v] = 1;
    }
  }

  bfs();

  for(i = 1; i <= n; i++){
    if(d[i] != INFTY){
      printf("%d %d\n",i,d[i]);
    }
    else{
      printf("%d %d\n",i,-1);
    }
  }
  
  return 0;
}

int min(int x, int y){
  if(x <= y) return x;
  else return y;
}

void initialize(void){
  head = tail = 0;
}

//if Queue is empty, return true
int isEmpty(void){
  return head == tail;
}

//if Queue is full, return true
int isFull(void){
  return head == (tail+1) % N;
}

void enqueue(int x){
  if(isFull()){
    fprintf(stderr,"Queue is full\n");
  }
  else{
    Q[tail] = x;
    if(tail + 1 == N) tail = 0;
    else tail++;
  }
}

int dequeue(void){
  int x;
  if(isEmpty()){
    fprintf(stderr,"Queue is empty\n");
    exit(0);
  }
  x = Q[head];
  if(head + 1 == N) head = 0;
  else head++;
  return x;
}
  
void bfs(void){
  int u,v;

  for(u = 1; u <= n; u++){
    color[u] = WHITE;
    d[u] = INFTY;
  }

  color[1] = GRAY;
  d[1] = 0;

  initialize();

  enqueue(1);

  while(!isEmpty()){
    u = dequeue();
    for(v = 1; v <= n; v++){
      if(M[u][v] == 1){
	if(color[v] == WHITE){
	  color[v] = GRAY;
	  d[v] = d[u] + 1;
	  enqueue(v);
	}
      }
    }
    color[u] = BLACK;
  }
}
  



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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	char s;
	cin >> s;

	cout << char(s+1) << endl;
	return 0;

}




Measured memory_bytes: 256
import kotlin.math.abs

fun main() {
    val (x, k, d) = readStrings().map { abs(it.toLong()) }

    val toZero = x / d
    if (toZero < k) {
        val y = x - toZero * d
        val rem = k - toZero
        val yd = d - y
        println(if (rem % 2 == 1L) yd else y)
    } else println(x - k * d)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int x;
    int n;
    
    cin >> x >> n;
    
    vector<int> arr(n);
    
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    
    set<int> s(arr.begin(), arr.end());
    
    
    int ans = 1e9+7;
    
    for (int i = 0; i <= 101; i++) {
        bool not_exist = s.find(i) == s.end();
        
        if (not_exist) {
            int diff = abs(x - i);
            int ans_diff = abs(x - ans);
            if (diff < ans_diff) {
                ans = i;
            }
        }
    }
    
    cout << ans; 
    return 0;
}
/*
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    INF = 1e9+7
    
    x, n = map(int,raw_input().split())
    
    arr = map(int,raw_input().split())
    
    s = set(arr)
    
    ret = INF
    
    for num in range(102):
        if num not in s:
            diff = abs(num - x)
            ret_diff = abs(ret - x)
            if diff < ret_diff:
                ret = num
            elif diff == ret_diff and num < ret:
                ret = num
    
    print(ret)
    

main()
*/


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
const int N = 2e6 + 5;
bitset<N>V;
int main() {
     int n, s = 0;
     scanf("%d", &n);
     V[0] = 1;
     for (int i = 0, x; i < n; i++)scanf("%d", &x), s += x, V |= V << x;
     for (int i = s / 2;; i--)
          if (V[i]) {
               printf("%d\n", s - i);
               return 0;
          }
}


Measured memory_bytes: 1024
def main():
    N=int(input())
    A=sorted([int(_) for _ in input().split()])[::-1]
    ans = A[0]
    if N==2:
        print(ans)
    else:
        for i in range(1, N//2):
            ans += A[i]*2
        if N%2:
            ans += A[N//2]
        print(ans)
main()

Measured memory_bytes: 31668
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]


h, a = na()
print((h-1)//a+1)

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

#define MAX 101
int N;
string str;
int as[MAX], bs[MAX];

void solve(){
  for(int i = N-1 ; i >=0 ; i--){
    int diff = abs(as[i] - bs[i]) % 26;
    int a = str[as[i]];
    int b = str[bs[i]];
    a += diff;
    if(a > 'z') a -= 26;
    b += diff;
    if(b > 'z') b -= 26;
    str[as[i]] = b;
    str[bs[i]] = a;
  }
  cout << str << endl;
}

int main(){
  while(cin >> N, N){
    cin >> str;
    for(int i = 0 ; i < N ; i++){
      cin >> as[i] >> bs[i];
      as[i]--; bs[i]--;
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 1200
A, B, K = map(int, input().split())
for i in range(K):
  if i%2 == 0:
    if A%2 == 1:
      A -= 1
    A, B = A//2, B+A//2
  if i%2 == 1:
    if B%2 == 1:
      B -= 1
    A, B = A+B//2, B//2
print(A, B)


Measured memory_bytes: 3316
package main

import (
  "fmt"
)

func main() {

  var a1, a2, a3 int

  fmt.Scan(&a1, &a2, &a3)

  if (a1 + a2 + a3) <= 21 {
    fmt.Print("win")
  } else {
    fmt.Print("bust")
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >;
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
using namespace std;
string s;
mpsi mp2;
string a[3]={"Sunny","Cloudy","Rainy"};
int main(){
	mp2["Sunny"]=0;
	mp2["Cloudy"]=1;
	mp2["Rainy"]=2;
	cin>>s;
	cout<<a[(mp2[s]+1)%3];
	re 0;
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
t = h[::1]
for i in range(m):
    a, b = [int(i) for i in input().split()]
    if h[a-1] > h[b-1]:
        t[b-1] = 0
    elif h[a-1] < h[b-1]:
        t[a-1] = 0
    else:
        t[a-1] = 0
        t[b-1] = 0

ans = 0
for i in t:
    if i != 0:
        ans += 1
print(ans)

Measured memory_bytes: 20128
// Copyright 2020 yaito3014
#include <iostream>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int a;
    std::cin >> a;
    if (i % 2 && a % 2) ++ans;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 3624
x = []

for i in range(3):
  a =input().split()
  x.append(a)

n = int(input())
b =[input() for i in range(n)]

for i in range(3):
  for j in range(3):
    if x[i][j] in b:
      x[i][j] = '*'

for i in range(3):
    for j in range(3):
      if x[i][0] == x[i][1] == x[i][2]:
           print('Yes')
           exit()
      elif x[0][i] == x[1][i] == x[2][i]:
           print('Yes')
           exit()
      elif x[0][0] == x[1][1] == x[2][2]:
           print('Yes')
           exit()
      elif x[0][2] == x[1][1] == x[2][0]:
           print('Yes')
           exit()
   	  
print('No')

Measured memory_bytes: 9188
import java.util.Scanner;
import java.util.Date;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a,b,c,m,n;
	while(sc.hasNext()){
	    a=sc.nextInt();
	    b=sc.nextInt();
	    m=a;n=b;
	    if(m<n)
		{
		    c=n;
		    n=m;
		    m=c;
		}
	    while(true)
		{
		    if(n==0)break;
		    c=n;
		    n=m%n;
		    m=c;
		}
	   System.out.printf("%d %d\n",m,a/m*b);
	}
    }
}

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

int main() {
	int x, h, m, s; 
	cin>>x;
	h = x/3600;
	m = (x%3600)/60;
	s = (x%3600)%60;
	cout<<h<<":"<<m<<":"<<s<<'\n';
	return 0;
}


Measured memory_bytes: 3104
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n,p = LI()
    p += n * 3

    return p // 2


print(main())



Measured memory_bytes: 7624
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

int main(){

    long long N, M;
    cin >> N >> M;

    std::priority_queue<long long, vector<long long>> q;

    long long sum = 0;
    for(int i = 0; i < N; ++i){
        long long A;
        cin >> A;
        sum += A;
        q.push(A);
    }

    for(int i = 0; i < M; ++i){
        long long top = q.top();
        q.pop();
        sum -= top;
        top /= 2;
        sum += top;
        q.push(top);
    }

    cout << sum;
}



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

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

ll n;
vector<vector<P>> v;

bool check(ll bit){
    rep(i,n){
        if(!(bit & (1<<i))) continue;
        for(auto xy:v[i]){
            ll x = xy.first, y = xy.second;
            if(y==1 && !(bit & (1<<x))) return false;
            if(y==0 && (bit & (1<<x))) return false;
        }
    }
    return true;
}

int main(void)
{
    cin >> n;
    v.resize(n);
    rep(i,n){
        ll a;
        cin >> a;
        rep(j,a){
            ll x, y;
            cin >> x >> y;
            x--;
            v[i].push_back({x,y});
        }
    }
    ll ans = 0;
    rep(bit,(1<<n)){
        if(check(bit)){
            ll cnt = 0;
            rep(i,n){
                if(bit & (1<<i)) cnt++;
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        scanner.close();

        int max = A;
        int mid = A;
        int min = A;
        if (B > max) {
            max = B;
        } else {
            mid = B;
        }
        if (C > max) {
            max = C;
        } else if (C > mid) {
            min = mid;
            mid = C;
        } else {
            min = C;
        }

        // 2つ選んで、１増やす回数
        int count = max - mid;

        // 1つ選んで、2増やす回数
        int s = max - (min + count);

        if (s % 2 == 0) {
            count += s / 2;
        } else {
            count += s / 2 + 2;
        }

        System.out.println(count);
    }
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef struct{
    int x;
    int y;
    long h;
}data;

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,N);
    data sample;
    for(int i=0;i<N;i++){
        scanf("%d%d%ld",&A[i].x,&A[i].y,&A[i].h);
        if(A[i].h!=0) sample=A[i];
    }

    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            long H = sample.h+abs(sample.x-i)+abs(sample.y-j);
            int co=1; //ピラミッドの中心として矛盾がないなら1,あるなら0
            for(int k=0;k<N;k++){
                if(A[k].h!=MAX(0,H-abs(A[k].x-i)-abs(A[k].y-j))){
                    co=0;
                    break;
                }
            }
            if(co){
                printf("%d %d %ld\n",i,j,H);
                return 0;
            }
        }
    }
}

//Nのオーダー的に、中心位置を全探索できる！！

Measured memory_bytes: 128
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,sum,ans,a[15];
int main(){
	r(n);
	for(int i=1;i<=n;i++){
		r(a[i]);
		ans=max(ans,a[i]);
		sum+=a[i];
	}
	sum-=ans;
	if(sum<=ans)puts("No");
	else puts("Yes");
    return 0;
}


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

int main() {
  int H,W;
  string S;
  string R;
  cin >>H>>W;
  int M[H+2][W+2];
  for(int i=0;i<H+2;i++)for(int j=0;j<W+2;j++)M[i][j]=0;
  
  for(int i=1;i<=H;i++){
    cin >>S;
    for(int j=0;j<W;j++){
      if(S.at(j)=='#'){
        M[i-1][j]++;
        M[i-1][j+1]++;
        M[i-1][j+2]++;
        M[i][j]++;
        M[i][j+1]=9;
        M[i][j+2]++;
        M[i+1][j]++;
        M[i+1][j+1]++;
        M[i+1][j+2]++;
      }
    }
  }
  for(int i=1;i<=H;i++){
    R="";
    for(int j=1;j<=W;j++){
      R+=M[i][j]<9?to_string(M[i][j]):"#";
    }
    cout <<R<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s1 = sc.next().toCharArray();
		char[] s2 = sc.next().toCharArray();
		sc.close();
		int count = 0;
		for(int i = 0; i < s1.length; i++) {
			if(s1[i] != s2[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 42000
fun main(args: Array<String>) {
    //val n = readLine()!!.toInt()
    val (D,N) = readLine()!!.split(" ").map { it.toInt() }
  	val result = if (N != 100) {
                     N * Math.pow(100.0,D.toDouble()).toInt()
                    } else {
		             (N+1) * Math.pow(100.0,D.toDouble()).toInt()
                    }
	println(result)
}

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

using namespace std;
int a ,b, c ,x,y ;
int main ()
{
while (scanf ("%d%d%d%d%d",&a,&b,&c,&x,&y)!=EOF)
{
   int t  = min (x,y) ;

   if (a+b>2*c)
   {

     int sum =0;
     sum+= 2*c*t;
     if (a>2*c) sum+=(x-t) *2*c;
     else sum +=(x-t) *a;
     if (b>2*c) sum += (y-t) *2*c;
     else sum +=(y-t) *b;


     printf ("%d\n",sum) ;

   }



   else
   {
     int sum =0;
     if (a>2*c) sum+=x *2*c;
     else sum +=x *a;
     if (b>2*c) sum += y *2*c;
     else sum +=y *b;


     printf ("%d\n",sum) ;
   }

}

return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    
    scanf("%d %d\n",&a,&b);
    
    d=a/b;
    r=a%b;
    f=(double)a/b;
    
    printf("%d %d %f\n",d,r,f);
    
    return(0);
}



Measured memory_bytes: 2120
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	int(1e9)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}
vi dist(int root, vvi &adj, vi &parent){
    int n = adj.size();
    queue<int> q; 
    vi d(n, INF);
    vector<bool> vis(n, false);
    q.push(root);
    vis[root] = true;
    d[root] = 0;
    while(!q.empty()){
        int top = q.front();
        q.pop();
        trav(to, adj[top]){
            if(vis[to]) continue;
            parent[to] = top;
            vis[to] = true;
            d[to] = d[top] + 1;
            q.push(to);
        }
    }
    return d;
}
void solve() {
	int n, m;
	cin >> n >> m;
	vvi adj(n);
	graph(adj, m);
	vi par(n, -1);
	vi dis = dist(0, adj, par);
	int maxm = 0;
	forn(i, n){
		maxm = max(maxm, dis[i]);
	}
	if(maxm == INF){
		cout << "No";
	}else{
		cout << "Yes\n";
		forne(i, n - 1){
			cout << par[i] + 1 << '\n';
		}
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 10596
#include<bits/stdc++.h>
using namespace std;
long long ans,w,n;
int main()
{
    
    scanf("%lld",&n);
    w=10;
    if(n%2==0)
    {
    	while(w<=n)
    	{
    		ans+=n/w;
	        w=w*5;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 2000010
#define nax2 1000002

void solve(){
	
	int n;
	cin>>n;
	cout<<(1000 - n%1000)%1000<<endl;

}

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans,a,b;
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
    printf("%lld",min(n*a,b));
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(15) //15桁表示



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

	ll n, k;
	cin >> n >> k;
	ll r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	string st="";
	ll ans = 0;

	for (int i = 0; i < n; i++)
	{
		if (i < k)
		{
			if (t[i] == 'r')
			{
				ans += p;
				st.push_back('r');
			}
			else if (t[i] == 's')
			{
				ans += r;
				st.push_back('s');
			}
			else
			{
				ans += s;
				st.push_back('p');
			}
		}
		else
		{
			if (st[i - k] == t[i])
			{
				st.push_back('a');
			}
			else
			{
				if (t[i] == 'r')
				{
					ans += p;
					st.push_back('r');
				}
				else if (t[i] == 's')
				{
					ans += r;
					st.push_back('s');
				}
				else
				{
					ans += s;
					st.push_back('p');
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
N = int(input())
W_list = list(map(int, input().split()))

S1 = W_list[0]
S2 = sum(W_list[1:])
ans = abs(S1 - S2)
for i in range(2, N):
    S1 = sum(W_list[:i])
    S2 = sum(W_list[i:])
    div = abs(S1 - S2)
    if div < ans:
        ans = div
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(a,n-1);

  vec num(n);
  rep(i,n-1){
    num[a[i]-1]++;
  }

  rep(i,n){
    prt(num[i]);
  }
}


Measured memory_bytes: 4780
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

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


Measured memory_bytes: 3788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        char[] d = new char[N+2];
        d[A] = 'A';
        d[B] = 'B';
        int dx_alice = A < B ? 1 : -1;
        int dx_borys = B < A ? 1 : -1;
        while(1 <= A && A <= N && 1 <= B && B <= N) {
            if (d[A+dx_alice] == 'B') {
                dx_alice *= -1;
            }
            d[A] = ' ';
            d[A+dx_alice] = 'A';
            A += dx_alice;
            if (d[B+dx_borys] == 'A') {
                dx_borys *= -1;
            }
            d[B] = ' ';
            d[B+dx_borys] = 'B';
            B += dx_borys;
        }
        if (A == 0 || A == N+1) {
            System.out.println("Borys");
            return;
        }
        System.out.println("Alice");
    }
}


Measured memory_bytes: 22612
// AOJ 2252

#include <iostream>
#include <map>
using namespace std;

int main(void)
{
	map <char, int> data;
	data['a'] = 1;
	data['b'] = 1;
	data['c'] = 1;
	data['d'] = 1;
	data['e'] = 1;
	data['f'] = 1;
	data['g'] = 1;
	data['h'] = 0;
	data['i'] = 0;
	data['j'] = 0;
	data['k'] = 0;
	data['l'] = 0;
	data['m'] = 0;
	data['n'] = 0;
	data['o'] = 0;
	data['p'] = 0;
	data['q'] = 1;
	data['r'] = 1;
	data['s'] = 1;
	data['t'] = 1;
	data['u'] = 0;
	data['v'] = 1;
	data['w'] = 1;
	data['x'] = 1;
	data['y'] = 0;
	data['z'] = 1;

	string str;
	while (cin >> str){
		if (str == "#") break;
		int now, prev = data[str[0]];
		int ret = 0;
		for (int i = 0; i < (int)str.length(); i++){
			now = data[str[i]];
			if (now != prev){
				ret++;
			}
			prev = now;
		}
		cout << ret << endl;
	}

	return 0;

}

Measured memory_bytes: 1188