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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

vi dp;

ll solve(vvi& ed, ll s) {
    if (dp[s] != -1)
        return dp[s];
    REP(i, 0, ed[s].size())
        dp[s] = max(dp[s], solve(ed, ed[s][i]) + 1);
    return dp[s];
}

int main() {
    fast;
    ll n, m, u, v;
    cin >> n >> m;
    vvi ed(n+1);
    vi src(n+1, 1);
    dp.resize(n+1, -1);
    REP(i, 0, m) {
        cin >> u >> v;
        ed[u].pb(v);
        src[v] = 0;
    }
    ll s, ss;
    ll ans = 0;
    REP(i, 1, n+1) {
        if (ed[i].empty())
            dp[i] = 0;
    }
    REP(i, 1, n+1)
        if (src[i])
            ans = max(ans, solve(ed, i));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    cout << 6.28 * n << endl;    
    return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>
int main(void){
    int x,y,tmp;
    
    while(1){
        scanf("%d",&x);
        scanf("%d",&y);
        if(x==0 && y==0){
            break;
        }
        if(x>y) {
            tmp=y;
            y=x;
            x=tmp;
        }
        printf("%d %d\n",x,y);
    }
    
    return 0;
}


Measured memory_bytes: 2024
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()

pn = list(map(int, input().split()))

ls = [i for i in range(102)]
for i in pn:
    ls[i] = 0

ls = list(set(ls))
ans = 0
m = 10**5
for j in ls:
    if abs(x - j) < m:
        m = abs(x - j)
        ans = j

print(ans)



Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define MAXN 110
using namespace std;

int n, d, x, a[MAXN], ans;

int main() {
	scanf("%d%d%d", &n, &d, &x);
	for (register int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for (register int i = 1; i <= n; ++i)
		for (register int day = 1; day <= d; day += a[i])
			++ans;
	printf("%d", ans + x);
	return 0;
}

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

using namespace std;

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

  string sa,sb,sc;cin>>sa>>sb>>sc;
  int count_a=sa.length(),count_b=sb.length(),count_c=sc.length();
  char next=sa[0];
  while(true){
      if(next=='a'){
          if(count_a==0) break;
          else{
              count_a--;
              next=sa[sa.length()-count_a-1];
          }
      }
      else if(next=='b'){
          if(count_b==0) break;
          else{
              count_b--;
              next=sb[sb.length()-count_b-1];
          }
      }
      else{
          if(count_c==0) break;
          else{
              count_c--;
              next=sc[sc.length()-count_c-1];
          }
      }
  }
  if(next=='a') cout<<"A"<<endl;
  else if(next=='b') cout<<"B"<<endl;
  else cout<<"C"<<endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li x[1010];
li y[1010];
li z[1010];

li tmp[1010];

int main() {
    li n, m;
    cin >> n >> m;
    rin{
        cin >> x[i] >> y[i] >> z[i];
    }

    li res = 0;
    rep(i, bit(3)) {
        li kake_x = ((i & 1) > 0 ? 1 : -1);
        li kake_y = ((i & 2) > 0 ? 1 : -1);
        li kake_z = ((i & 4) > 0 ? 1 : -1);

        rep(j, n) {
            tmp[j] = x[j] * kake_x + y[j] * kake_y + z[j] * kake_z;
        }
        sort(tmp, tmp + n);
        li tres = 0;
        rep(j, m) {
            tres += tmp[n - 1 - j];
        }
        res = max(res, tres);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstdio>
#include<cmath>
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
	long double in=0,out=0;
	int a,b;
	int co=0;
	char d;
	while(cin>>a>>d>>b){
		in+=a*b;
		out+=b;
		co++;
	}
	out/=co;
	if(out-(int)out>=0.5)out+=1;
	cout<<in<<endl<<(int)out<<endl;

}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define ri register int
const int N=5005;
int mod,c[N],f[N];
inline void add(int &x,ri y){
	x=(x+=y)>=mod?x-mod:x;
}
int main(){
	ri n,i,j,ans;
	scanf("%d%d",&n,&mod);
	for(i=1;i<=n/2+1;++i) c[i]=(i-2)+1;
	for(;i<=n;++i)		  c[i]=(n-i+1)+1;
	f[0]=1;
	for(i=2;i<=n;++i)
		for(j=0;j+c[i]<=n;++j)
			add(f[j+c[i]],f[j]);
	ans=0;
	for(i=0;i<n;++i) ans=(ans+(long long)(n-i)*f[i])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> D1(N), D2(N);
  for (i64 i = 0; i < N; i++)
    cin >> D1[i] >> D2[i];
  i64 cnt = 0;
  for (i64 i = 0; i < N; i++)
    if (D1[i] == D2[i])
    {
      cnt++;
      if (3 <= cnt)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
    else
      cnt = 0;
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3604
N = int(input())
Ws = [input() for i in range(N)]

if len(Ws) != len(list(set(Ws))):
    print("No")
    exit(0)

for i in range(N-1):
    if Ws[i][-1] != Ws[i+1][0]:
        print("No")
        exit(0)

print("Yes")


Measured memory_bytes: 3060
using System;

namespace ABC139
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            int count = 1;
            for (int i = A; i < B; i += (A - 1))
            {
                count++;
            }
            if (B != 1) Console.WriteLine(count);
            else Console.WriteLine(0);

        }
    }
}


Measured memory_bytes: 13140
#include<iostream>

using namespace std;

const int maxSize = 21;
int mapData[maxSize][maxSize] = {0};
int W, H, Ans;

void dfs(int hh, int ww) {
  if(mapData[hh][ww] == 1) {
    mapData[hh][ww] = 0;
    Ans++;
    if(hh+1<H && mapData[hh+1][ww]==1) {
      dfs(hh+1, ww);
    }
    if(ww+1<W && mapData[hh][ww+1]==1) {
      dfs(hh, ww+1);
    }
    if(0<=hh-1 && mapData[hh-1][ww]==1) {
      dfs(hh-1, ww);
    }
    if(0<=ww-1 && mapData[hh][ww-1]==1) {
      dfs(hh, ww-1);
    }
  }
}

int main() {
  while(cin>>W>>H && !(W==0 && H==0)) {
    int startW, startH;
    Ans = 0;
    for(int i=0; i<H; i++) {
      string str;
      cin>>str;
      for(int j=0; j<W; j++) {
	if(str[j] == '.') {
	  mapData[i][j] = 1; // true
	}
	else if(str[j] == '#') {
	  mapData[i][j] = -1; // false;
	}
	else {
	  mapData[i][j] = 1; //true
	  startW = i;
	  startH = j;
	}
      }
    }
    /*
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
	cout<<mapData[i][j]<<" ";
      }
      cout<<endl;
    }
    */
    dfs(startW, startH);
    /*
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
	cout<<mapData[i][j]<<" ";
      }
      cout<<endl;
    }
    */
    cout<<Ans<<endl;
  }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

const int MAX=1e6+1;

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

    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    vi dp(MAX,-1);
    dp[1]=1;
    for(int i=2; i<MAX; i++){
        if(dp[i]!=-1) continue;
        for(int j=i; j<=MAX; j+=i){
            dp[j]=i;
        }
    }


    vi sum(MAX,0);
    bool pc=true;
    rep(i,n){
        int t=a[i];
        while(t>1){
            int div=dp[t];
            while(t%div==0) t/=div;
            sum[div]++;
            if(sum[div]>1){
                pc=false;
                break;
            }
        }
        if(pc==false) break;
    }

    int sc=a[0];
    for(int i=1; i<n; i++) sc=gcd(sc,a[i]);

    if(pc)cout<<"pairwise coprime"<<endl;
    else if(sc==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    

}

Measured memory_bytes: 26668
#include <iostream>
using namespace std;
int main()
{
  int a,b,c;
  int sum=0;
  cin >> a >> b >> c;
  for(int i=a;i<=b;i++){
    if(c%i==0)
      sum++;
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 3072
def d(s, t):
    cnt = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            cnt += 1
    return cnt


s, t = input(), input()
n = len(s)
m = len(t)
ans = 1000000
print(min(d(s[i:i + m], t) for i in range(n - m + 1)))


Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
int a[110000];

main()
{
int n;
scanf("%d",&n);
int ans=0;
while(1000 <= n){
    n-=1000;
}
if(n==0){
    cout<<0;
    return 0;
}
cout<<1000-n;
}




Measured memory_bytes: 3656
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,a,b;cin>>n>>a>>b;
    string s;cin>>s;
    int now=0;
    int xb=0;
    for(int i=0;i<n;i++){
        if(s[i]=='a'){
            if(now<a+b){
                now++;
                cout<<"Yes"<<Endl;
            }
            else cout<<"No"<<endl;
        }
        else if(s[i]=='c')cout<<"No"<<endl;
        else{
            if(now<a+b&&xb<b){
                now++;xb++;
                cout<<"Yes"<<endl;
            }
            else cout<<"No"<<endl;
        }
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 848
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNDEFCHAN -1

int dx[4],dy[4];
int fmem[1<<16];

int f(int s){
	if(fmem[s]!=UNDEFCHAN) return fmem[s];
	if(s==0) return 1;

	int bn=15;
	while(bn>=0){
		if(s>>(15-bn)&1){break;}
		else{bn--; continue;}
	}

	int bx=bn%4, by=bn/4;

	int re=0;
	FOR(i,0,4){
		int ax=bx-dx[i], ay=by-dy[i];
		int an=ay*4+ax;
		if(ax<0||4<=ax||ay<0||4<=ay||(~s>>(15-an)&1)){continue;}
		else{
			re += f( s - (1<<(15-an)) - (1<<(15-bn)));
		}
	}

	fmem[s]=re;
	return re;
}



int solve(){
	FOR(s,0,1<<16) fmem[s]=UNDEFCHAN;
	return f((1<<16)-1);
}



int main(){
	while(true){
		cin>>dx[0];		if(dx[0]>=4) return 0;
		cin>>dy[0]>>dx[1]>>dy[1]>>dx[2]>>dy[2]>>dx[3]>>dy[3];
		cout<<solve()<<endl;
	}
}

Measured memory_bytes: 1416
#include<stdio.h>
#define min(a,b)((a)<(b)?(a):(b))
int main(void)
{
	int n,k,i,x,y,res=0;
	scanf("%d",&n);
	scanf("%d",&k);
	for (i = 0; i < k; i++) {
		scanf("%d %d",&x,&y);
		res = min(x - 1, y - 1);
		res = min(res, n - x);
		res = min(res, n - y);
		printf("%d\n",res%3+1);
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int n, m;
    int cnt[50] = {};
    int a, b;

    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &a, &b);
        cnt[a - 1]++;
        cnt[b - 1]++;
    }

    for (int i = 0; i < n; i++) {
        printf("%d\n", cnt[i]);
    }

    return 0;
}

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


class Graph:
    def __init__(self, n, adj_matrix):
        self.n = n
        self.adj_matrix = adj_matrix

    def show(self):
        for _ in self.adj_matrix:
            print(*_)

    def dfs(self):
        self.states = [2] * self.n
        self.d = [None] * self.n
        self.f = [None] * self.n
        self.time = 0

        for u in range(self.n):
            if self.states[u] == 2:
                self.dfs_visit(u)

    def dfs_visit(self, u):
        self.states[u] = 1
        self.time += 1
        self.d[u] = self.time

        for v, edge in enumerate(self.adj_matrix[u]):
            if edge and self.states[v] == 2:
                self.dfs_visit(v)

        self.states[u] = 0
        self.time += 1
        self.f[u] = self.time

    def show_dfs(self, start=0):
        self.dfs()
        for i, (d, f) in enumerate(zip(self.d, self.f)):
            print(i + 1, d, f)


if __name__ == '__main__':
    n = int(input())
    adj_matrix = [[0] * n for i in range(n)]
    for i in range(n):
        for v in input().split()[2:]:
            adj_matrix[i][int(v) - 1] = 1

    g = Graph(n, adj_matrix)
    g.show_dfs()



Measured memory_bytes: 5812
#include <stdio.h>

int main(void) {
  char input;
  char s[100] = {};
  char p[100] = {};
  int slen, plen, i, j;
  for (slen = 0; slen < 101; slen++) {
    scanf("%c", &input);
    if (input == '\n')
      break;
    s[slen] = input;
  }
  for (plen = 0; plen < 101; plen++) {
    scanf("%c", &input);
    if (input == '\n')
      break;
    p[plen] = input;
  }
  for (i = 0; i < slen; i++) {
    if (s[i] == p[0]) {
      for (j = 0; j < plen; j++) {
	if (s[(i + j) % slen] != p[j])
	  break;
	else if (j == plen - 1) {
	  printf("Yes\n");
	  return 0;
	}
      }
    }
  }
  printf("No\n");
  return 0;
}



Measured memory_bytes: 2080
# import numpy as np

from operator import or_

class segtree:

    def __init__(self, n,operator,identity):
        nb = bin(n)[2:]
        bc = sum([int(digit) for digit in nb])
        if bc == 1:
            self.num_leaves = 2**(len(nb)-1)
        else:
            self.num_leaves = 2**(len(nb))

        self.array = [identity for i in range(self.num_leaves * 2)]
        self.identity = identity
        self.operator =operator
        self.n = n

    def build(self,init_arr):
        for i in range(self.n):
            self.array[i+self.num_leaves] = init_arr[i]
        for i in range(self.num_leaves):
            pt = self.num_leaves-1-i
            self.array[pt] = self.operator(self.array[pt*2],self.array[pt*2+1])


    def update(self,x,val):
        actual_x = x+self.num_leaves
        # self.array[actual_x] = self.operator(self.array[actual_x],val)
        self.array[actual_x] = val
        while actual_x > 0 :
            actual_x = actual_x//2
            self.array[actual_x] = self.operator(self.array[actual_x*2],self.array[actual_x*2+1])

    def get(self,q_left,q_right,arr_ind=1,leaf_left=0,depth=0):
        width_of_floor = self.num_leaves//(2**depth)
        leaf_right = leaf_left+width_of_floor-1

        if leaf_left > q_right or leaf_right < q_left:
            return  self.identity

        elif leaf_left >= q_left and leaf_right <= q_right:
            return self.array[arr_ind]

        else:
            val_l = self.get(q_left,q_right,2*arr_ind,leaf_left,depth+1)
            val_r = self.get(q_left,q_right,2*arr_ind+1,leaf_left+width_of_floor//2,depth+1)
            return self.operator(val_l,val_r)

    def find(self, l, r):
        #findの方が高速
        l += self.num_leaves
        r += self.num_leaves+1
        ret = self.identity
        while l < r:
            if l & 1:
                ret = self.operator(ret, self.array[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.operator(ret, self.array[r])
            l //= 2
            r //= 2
        return ret







n = int(input())
s = input()
q = int(input())

tree = segtree(n, or_, 0)
buf = [0 for i in range(n)]

for i in range(n):
    c = ord(s[i]) - 97
    buf[i] = 1<<c


for i in range(26):
    tree.build(buf)




s = list(s)

for i in range(q):
    ty, i, c = input().split()

    if ty == "1":
        i = int(i)
        t = ord(c) - 97
        tree.update(i-1,1<<t)


    else:
        i = int(i)
        c = int(c)
        i -= 1
        c -= 1
        tp = 0
        hoge = tree.get(i,c)
        print(sum(map(int,bin(hoge)[2:])))


Measured memory_bytes: 125532
#include<stdio.h>

int main(){
  int n, i, minj, flag, c = 0, t, j;
  scanf("%d",&n);
  int A[n];
  for(i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }
  for(i = 0 ; i < n ; i++){
    minj = i;
    flag = 0;
    for(j = i ; j < n ; j++){
      if(A[j] < A[minj]){
	minj = j;
	flag = 1;
      }
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
    if(flag == 1) c++;
  }
  for(i = 0 ; i < n ; i++){
    if(i != n - 1) printf("%d ", A[i]);
    else printf("%d\n", A[i]);
  }
  printf("%d\n", c);
}



Measured memory_bytes: 2144
A,B= map(int,input().split())
K = (A+B)//2
if abs(A-K) == abs(B-K):
  print(K)  
else:
  K,m = (max(A,B)-min(A,B))//2,(max(A,B)-min(A,B))%2
  if abs(A-K) == abs(B-K) and m == 0:
    print(K)
  else:
    print("IMPOSSIBLE")

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    vector <int> p;
    for (int i = 1; i <= min(a, b); i++) {
        if (a % i == 0 && b % i == 0) {
            p.push_back(i);
        }
    }
    reverse(p.begin(), p.end());
    cout << p[k - 1] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
typedef long long int ll;
using namespace std;
int main(){
	int K,X;
	cin>>K>>X;
	if(K*500>=X){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
  double r;
  int n;
  int hight[40];
  int xl, xr, h;

  while(1) {
    cin >> r >> n;
    if(r + n == 0) break;

    for(int i = 0; i < 40; i++) {
      hight[i] = 0;
    }
    
    for(int i = 0; i < n; i++) {
      cin >> xl >> xr >> h;
      for(int j = xl+20; j < xr+20; j++) {
	if(hight[j] < h) {
	  hight[j] = h;
	}
      }
    }
    
    float ans = 10000;
    double x, y;
    for(int i = 20-r; i < 20+r-1; i++) {
      if(hight[i] < hight[i+1]) {
	x = i - 20 + 1;
	y = hight[i];
      }
      else {
	x = i - 20 + 1;
	y = hight[i+1];
      }
      float t = y + r - sqrt(r * r - x * x);
      if(ans > t) {
	ans = t;
      }
    }
    cout << fixed << setprecision(4) << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3280
#include<iostream>

using namespace std;

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

    long long int sum = 0;
    for(long long int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout << sum << endl;
    return 0;
}

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

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        int c = 1;
        
        while(true){
            int n = scan.nextInt();
            
            if(n == 0) break;
            
            System.out.println("Case " + c++ + ": " + n);
        }
    }
}


Measured memory_bytes: 41140
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const inf = 1 << 60

func solve() {
	n := getInt()
	cnt := make([]int, 26)
	for i := 0; i < 26; i++ {
		cnt[i] = inf
	}
	for i := 0; i < n; i++ {
		s := []rune(getString())
		t := make([]int, 26)
		for _, r := range s {
			t[r-'a']++
		}

		for j := range cnt {
			cnt[j] = min(cnt[j], t[j])
		}
	}

	ans := ""
	for i := 0; i < 26; i++ {
		str := string(i + 'a')
		ans += strings.Repeat(str, cnt[i])
	}

	fmt.Fprintln(wr, ans)
}

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

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll A[200010];
double ABS(double n){
    return (n<0)?-n:n;
}
int main(){
    cin>>N;
    ll sum=0;
    A[0]=0;
    for(ll i=1;i<=N;i++){
        ll a;cin>>a;
        A[i]=A[i-1]+a;
    }
    double minDif=INF;
    for(ll i=0;i<=N;i++){
        minDif=min(minDif,ABS((double)A[i]-(double)A[N]/2.0));
    }
    cout<<(ll)( minDif/0.5)<<endl;
    return 0;
}

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

int main(){
  int K,S;
  cin >> K >> S;
  int count=0;
  for (int i=0;i<=K;i++){
    for (int j=0;j<=K;j++){
      if (0<=S-i-j && S-i-j<=K)
        count++;
    }
  }
  cout << count << endl;
      
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1e6+10;
int a[N];
ll sum;
int main(){
	int i,j,k,n;
	cin>>n;
	for(i=1;i<=n;i++){
		ll a,b;
		cin>>a>>b;
		sum+=abs(a-b)+1;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
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(){
  long h,w,k;
  cin >> h >> w >> k;
  vs data(h);
  rep(i,h) cin >> data.at(i);
  int ans = 0;
  rep(x,1<<h){
    rep(y,1<<w){
      int cnt = 0;
      rep(i,h){
        rep(j,w){
          if((x & (1<<i)) || (y & (1<<j))) continue;
          if(data.at(i).at(j) == '#') cnt++;
        }
      }
      if(cnt == k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int flag = 0;
		for(int i=0; i<=x; i++) {
			if(y==2*i + 4*(x-i)) {
				flag = 1;
				break;
			}
		}
			if(flag==1) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
	}

}


Measured memory_bytes: 35756
using System;
using System.Text;

public class Program
{
    private int H, W, A, B;

    public void Solve()
    {
        var sc = new Scanner();
        H = sc.NextInt();
        W = sc.NextInt();
        A = sc.NextInt();
        B = sc.NextInt();
        
        char[][] ans = new char[H][];
        for (int i = 0; i < H; i++)
        {
            ans[i] = new char[W];
        }

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                bool b = (i < B) ^ (j < A);
                ans[i][j] = b ? '1' : '0';
            }
        }

        var sb = new StringBuilder();
        for (int i = 0; i < H; i++)
        {
            sb.AppendLine(new string(ans[i]));
        }
        Console.Write(sb.ToString());
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 17888
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))

odd = sum([num%2!=0 for num in a])
even = n-odd
if odd%2==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 62448
program a
    implicit none
    character(len=3) :: S
    character(len=3) :: days(7)
    integer :: i

    read(*, *) S

    days(:) = ["SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"]

    do i = 1, 7
        if(S == days(i)) then
            print *, i
            exit
        endif
    end do

end program a

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
  int diceA[6],diceB[6],subdiceB[6],i,j;
  for(i = 0; i < 6; i++)scanf("%d",&diceA[i]);
  for(i = 0; i < 6; i++)scanf("%d",&diceB[i]);

  if(diceA[0] == diceB[0] && diceA[1] == diceB[1] && diceA[2] == diceB[2])i = 0;
  else if(diceA[0] == diceB[1] || diceA[0] == diceB[4]){
    for(i = 0; i < 6; i++){
      subdiceB[0] = diceB[4];
      subdiceB[4] = diceB[5];
      subdiceB[5] = diceB[1];
      subdiceB[1] = diceB[0];
      subdiceB[2] = diceB[2];
      subdiceB[3] = diceB[3];
      for(j = 0; j < 6; j++)diceB[j] = subdiceB[j];
      if(diceA[5] == diceB[5] && diceA[0] == diceB[0])break;
    }
  }
  else{
    for(i = 0; i < 6; i++){
      subdiceB[0] = diceB[2];
      subdiceB[2] = diceB[5];
      subdiceB[5] = diceB[3];
      subdiceB[3] = diceB[0];
      subdiceB[1] = diceB[1];
      subdiceB[4] = diceB[4];
      for(j = 0; j < 6; j++)diceB[j] = subdiceB[j];
      if(diceA[5] == diceB[5] && diceA[0] == diceB[0])break;
    }
  }
  if(i == 6){
    printf("No\n"); return 0;
  }

  //for(i = 0; i < 6; i++)printf("diceA[%d] = %d diceB[%d] = %d\n",i,diceA[i],i,diceB[i]);

  for(i = 0; i < 4; i++){
    subdiceB[1] = diceB[2];
    subdiceB[2] = diceB[4];
    subdiceB[4] = diceB[3];
    subdiceB[3] = diceB[1];
    for(j = 1; j < 5; j++)diceB[j] = subdiceB[j];
    if(diceA[1] == diceB[1]){
      //printf("------------------------\n");
      //for(i = 0; i < 6; i++)printf("diceA[%d] = %d diceB[%d] = %d\n",i,diceA[i],i,diceB[i]);
      if(diceA[2] == diceB[2] && diceA[3] == diceB[3] && diceA[4] == diceB[4])printf("Yes\n");
      else{
        printf("No\n");
      }
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        ll l, r;
        cin >> l >> r;
        if ((l - 1) / 2019 != r / 2019) {
            cout << 0 << endl;
            return 0;
        }

        l %= 2019;
        r %= 2019;
        int ans = 2018;
        for (int i = l; i <= r; i++)
        {
            for (int j = i + 1; j <= r; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}

// dp[i] - TRUE if first player wins with i stones remaining

int main()
{ 
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vi a(n);
	for (int& i : a)
		cin >> i;
	vector<vector<ll>> dp(n + 1, vll(n + 1));
	for (int L = n - 1; L >= 0; L--)
	{
		for (int R = L; R < n; R++)
		{
			if (L == R)
				dp[L][R] = a[L];
			else
				dp[L][R] = max(a[L] - dp[L + 1][R], a[R] - dp[L][R - 1]);
			
		}
	}
	cout << dp[0][n - 1];
	return 0;
}

Measured memory_bytes: 70784
n=int(input())

hxy=[]
for _ in range(n):
    x,y,h=map(int,input().split())
    hxy.append([h,x,y])

hxy.sort()

for cx in range(101):
    for cy in range(101):
        flag=0
        temp=hxy[-1]
        H=temp[0]+abs(temp[1]-cx)+abs(temp[2]-cy)

        for item in hxy:
            h=item[0]
            x=item[1]
            y=item[2]
            if h!=max(H-abs(x-cx)-abs(y-cy),0):
                flag=1
                break
        
        if flag==0:
            print(cx,cy,H)
            exit()


Measured memory_bytes: 42480
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    double N,K;
    cin >>N>>K;
    double ans=0;
    REP(i,N){
        int i1=i+1;
        double ians=1/N;
        while(K>i1){
            ians/=2.0;
            i1 *=2;
        }
        ans +=ians;
    }
    printf("%.15f",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
 int main(void)
 {
 int i, j, k;
 int n, m, l;
 int a[100][100]={};
 int b[100][100]={};
 long long int c[100][100]={};
 scanf("%d%d%d", &n, &m, &l);
 for(i=0; i<n; i++)
 {
 for(k=0;
 k<m;
 k++) scanf("%d", &a[i][k]);
 }
 for(k=0;
 k<m;
 k++)
 {
 for(j=0;
 j<l;
 j++) scanf("%d", &b[k][j]);
 }
 for(i=0;
 i<n;
 i++)
 {
 for(j=0;
 j<l;
 j++)
 {
 for(k=0;
 k<m;
 k++) c[i][j]+=a[i][k]*b[k][j];
 }
 }
 for(i=0;
 i<n;
 i++)
 {
 for(j=0;
 j<l;
 j++)
 {
 printf("%lld", c[i][j]);
 if(j!=l-1) putchar(' ');
 }
 putchar('\n');
 }
 return 0;
 }


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=b+1;i<=a;i++){
		ans+=a/i*(i-b)+max((int)(0),a%i-max((int)(0),b-1));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int a[55],b[55];
    for (int i=0;i<M;i++){
	cin >> a[i] >> b[i];
    }

    int ret[55]={0};
    for (int i=0;i<M;i++){
	ret[a[i]]++;
	ret[b[i]]++;
    }

    for (int i=1;i<=N;i++) cout << ret[i] << endl;

    return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
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; }

using Graph = vector<vector<ll>>;

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

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> h(n,0);
	
	rep(i, n)
	{
		cin >> a[i];
	}
	rep(i, n - 1)
	{
		h[i + 1] = max(a[i + 1], h[i]);
	}

	ll bit = (1LL << n) - 1LL;

	ll now = 0;
	ll sum = 0;
	rep(i, n)
	{
		if (now < a[i])
		{
			sum++;
			now = a[i];
		}
	}

	if (sum == k)
	{
		cout << 0 << endl;
		ret;
	}
	sum = 0;
	now = 0;
	ll ans = LINF;


	while (bit)
	{
		vector<ll> tal(n);
		rep(i, n)
			tal[i] = a[i];

		ll tmp = bit;
		now = 0;
		sum = 0;
		ll point = 0;
		while (tmp)
		{
			if (tmp & 1)
			{
				if (a[point] <= now)
				{
					sum += now - a[point] + 1;
					now++;
					tal[point] = now;
				}
			}

			tmp >>= 1;
			now = max(now, a[point]);
			point++;
		}

		now = 0;
		ll ok = 0;
		rep(i, n)
		{
			if (tal[i] > now)
			{
				ok++;
				now = tal[i];
			}
		}
		if (ok >= k)
		{
			ans = min(ans, sum);
		}
		bit--;
	}



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

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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

const int maxn = 3e5+5;
int n;
int arr[maxn];

ll Left[maxn],Right[maxn];
int main(){
	scanf("%d",&n);
	rep(k,0,3*n)scanf("%d",&arr[k]);
	
	pq<int,vector<int>,greater<int> > ki;
	pq<int> ka;
	
	ll ret = 0;
	rep(k,0,3*n){
		ki.push(arr[k]);ret+= arr[k];
		while(ki.size()>n)ret-=ki.top(),ki.pop();
		Left[k] = ret;
	}
	ret = 0;
	repd(k,3*n-1,0){
		ka.push(arr[k]);ret+= arr[k];
		while(ka.size()>n)ret-=ka.top(),ka.pop();
		Right[k] = ret;
	}
	
	ret = -INFLL;
	rep(k,n-1,2*n)ret = max(ret,Left[k] -Right[k+1]);
	cout<<ret<<endl;
	return 0;
}


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

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> l(m), r(m);

    int l_max = 0, r_min = n + 1;

    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
        l_max = max(l_max, l[i]);
        r_min = min(r_min, r[i]);
    }

    int ans = max(0, r_min - l_max + 1);

    cout << ans;

    return 0;
} 


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define met(a) memset(a,0,sizeof(a))
using namespace std;
const int mod=1e9+7;
const int N=1e6+10;
int a[120];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int i,j,k,m,n;
    int ans=0;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        ans+=min(m*2,(k-m)*2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc127/tasks/abc127_d

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int M_MAX = 1e5;
const int A_I_MAX = 1e9;
const int C_I_MAX = 1e9;

int N, M;
int A[N_MAX];
// int B[M_MAX];
// int C[M_MAX];

pair<int, int> CB[M_MAX + 1];

void solve() {
  sort(A, A + N);
  sort(CB, CB + M, greater<pair<int, int>>());
  CB[M] = { 0, N };

  ll ans = 0;
  int j = 0;
  REP(i, N) {
    if (CB[j].second == 0) j++;
    if (A[i] < CB[j].first) {
      // printf("ans += %lld\n", CB[j].first);
      ans += CB[j].first;
      CB[j].second--;
    } else {
      // printf("ans += %lld\n", A[i]);
      ans += A[i];
    }
  }

  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) scanf("%d", A + i);
  REP(i, M) {
    int B, C;
    scanf("%d%d", &B, &C);
    CB[i] = { C, B };
  }
}

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


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

string n;
ll K, ans;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> K;
	ll N = n.size();
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
		a[i] = n[i] - '0';
	}
	
	if (K == 1) {
		for (int i = N - 1; i >= 0; i--) {
			if (i == 0) {
				ans += a[i];
			} else {
				ans += 9;
			}
		}
	} else if (K == 2) {
		for (int i = N - 2; i >= 0; i--) {
			if (i == 0) {
				bool second = false;
				for (int j = i + 1; j < N; j++) {
					if (second) ans += a[i] * 9;
					else ans += (9 * (a[i] - 1)) + a[j];
					if (a[j]) second = true;
				}
			} else {
				for (int j = i + 1; j < N; j++) {
					ans += 81;
				}
			}
		}
	} else {
		for (int i = N - 3; i >= 0; i--) {
			if (i == 0) {
				bool second = false;
				for (int j = i + 1; j < N; j++) {
					if (!second && !a[j]) continue;
					bool third = false;
					for (int k = j + 1; k < N; k++) {
						if (second) {
							ans += a[i] * 9 * 9;
						} else {
							ans += (a[i] - 1) * 9 * 9;
							ans += max(0ll, (a[j] - 1)) * 9;
							if (third) ans += 9; 
							else ans += a[k];
						}

						if (a[k]) third = true;
					}
					if (a[j]) second = true;
				}
			} else {
				for (int j = i + 1; j < N; j++) {
					for (int k = j + 1; k < N; k++) {
						ans += (9 * 9 * 9);
					}
				}
			}
		}		
	}
	
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            int cnt = 0;

            for (int i = 0; i < s.Length; i++)
            {
               
                if (s[i] == '1') cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11092
for x in range (5):
    a,k = map(int, input().strip().split())
    if a==k==0 : break
    lst=[int(input()) for i in range(a)]
    s = sum(lst[0:k])
    mx = s
    for i in range (k,a):
        s = s + lst[i] -lst[i-k]
        if s > mx :
            mx = s
            
        
    print(mx)


Measured memory_bytes: 9880