akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
one = [0] * 40
zero = [0] * 40
for i in range(40):
    for a in A:
        if a >> i & 1:
            one[i] += 1
        else:
            zero[i] += 1
dp1 = [-1e10] * 41 # 上から 40 - i 桁目までみたとき、 K と同じ
dp2 = [-1e10] * 41 # 上から 40 - i 桁目までみたとき、 K より小さい
dp1[40] = 0
for i in range(39, -1, -1):
    if k >> i & 1:
        dp2[i] = max(dp2[i + 1] * 2 + max(zero[i], one[i]), dp1[i + 1] * 2 + one[i])
        dp1[i] = dp1[i + 1] * 2 + zero[i]
    else:
        dp2[i] = dp2[i + 1] * 2 + max(zero[i], one[i])
        dp1[i] = dp1[i + 1] * 2 + one[i]
print(max(dp1[0], dp2[0]))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  vector<vll> group;
  for(ll i = 1; i <= n/2; i++){
    vll v;
    v.push_back(i);
    if(n%2==0)
      v.push_back(n+1-i);
    else
      v.push_back(n-i);
    group.push_back(v);
  }

  if(n%2 == 1){
    vll v;
    v.push_back(n);
    group.push_back(v);
  }


  if(n%2==0)
    cout << n*(n-2)/2 << endl;
  else
    cout << (n-1)*(n-1)/2 << endl;

  for(ll i = 0; i<group.size(); i++){
    for(ll j = i+1; j<group.size(); j++){
      REP(k, group[i].size()){
        REP(l, group[j].size())
          cout << group[i][k] << " " << group[j][l] << endl;
      }
    }
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
int main() {
	int n,x,t;
	cin >> n >> x >> t;
	ll ans = (n/x)*t + (n%x?t:0);
	cout<<ans;
}


Measured memory_bytes: 3632
ans = ''
s = input()
if s[0:4] < '2019':
	ans = 'Heisei'
if s[0:4] == '2019':
	if int(s[5:7]) >= 5:
		ans = 'TBD'
	else:
		ans = 'Heisei'
else:
	ans = 'TBD'
print(ans)

Measured memory_bytes: 2940
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A%3==0||B%3==0||(A+B)%3==0) {
            System.out.print("Possible");
        }else{
            System.out.print("Impossible");
        }
    }
}

Measured memory_bytes: 21076
#include <climits>
#include <vector> 
#include <iostream>
using namespace std;

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

    vector<int> R(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> R[i];
    }

    int max_diff  = -INT_MAX;
    int min_value = R[0];
    for (int i = 1; i < N; ++i)
    {
        //最大の「価格の差」を更新
        max_diff = max(max_diff, R[i] - min_value);

        //現時点の価格の最小値を更新
        min_value = min(min_value, R[i]);
    }

    cout << max_diff << endl;


    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

bool bo(pair<int, int> &a, pair<int, int> &b)
{
    if (a.first>b.first)
    {
        return true;
    }
    return false;
}
int main()
{
    start();
    int n;
    cin>>n;
    unordered_map<string, vector<pair<int, int>>> a;
    set<string> b;
    for (int i=0;i<n;i++)
    {
        string s;
        int x;
        cin>>s>>x;
        a[s].push_back({ x, i+1 });
        b.insert(s);
    }
    for (auto x:b)
    {
        sort(a[x].begin(), a[x].end(), bo);
        for (auto y:a[x])
        {
            cout<<y.second<<"\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    bool rev = false;
    string s; cin >> s;
    int q; cin >> q;
    string front = "";
    string back = "";
    rep(i, q) {
        int t; cin >> t;
        if(t == 1) {
            rev = !rev;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            if(f == 1) {
                if(rev) back += c;
                else front += c;
            } else {
                if(rev) front += c;
                else back += c;
            }
        }
    }

    if(rev) {
        reverse(s.begin(), s.end());
        reverse(back.begin(), back.end());
        string ans = back + s + front;
        cout << ans << endl;
    } else {
        reverse(front.begin(), front.end());
        string ans = front + s + back;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1436
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll b,c=0,k=1,n,h,w,m,min=100000000000,ans=0,max=0;
    string s,s2;
    cin >> s;  
    bool f = true;
    for(int i= s.size()-1; i>=0; i--){
        if(i%2==1) 
            continue;
        f = true;
        rep(j,i/2){
            if(s[j]!=s[j+i/2])
                f = false;
        }
        if(f){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */

void max_self(ll &a,ll b){
	a = max(a,b);
}


int main(){
	FAST;
	int n,W;
	scanf("%d%d",&n,&W);
	vector <ll> dp(W+1); //0,1,2...W

	for(int item = 0;item<n;++item){
		int weight, value;
		scanf("%d%d",&weight,&value);
		for(int weight_already = W - weight;weight_already>=0;--weight_already){
			max_self( dp[weight_already+weight] , dp[weight_already] + value);
		}
	}
	ll answer = 0;
	for(int i=0; i<=W;++i){
		max_self(answer, dp[i]);
	}
	printf("%lld",answer);
	
	
	return 0;
}

	

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

int main()
{
    int a, b, c;
    int ans = 0;
    vector<int> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    if ((v[1]-v[0]) % 2 == 0) {
        while(1) {
            if (v[0] == v[1]) break;
            ans++;
            v[0] = v[0]+2;
        }
        while(1) {
            if (v[2] == v[0]) break;
            ans++;
            v[0]++;
        }
    }
    else {
        while(1) {
            if (v[0]+1 == v[1]) break;
            ans++;
            v[0] = v[0] + 2;
        }
        while(1) {
            if (v[0] == v[2]) {
                ans++;
                break;
            }
            ans++;
            v[0]++;
        }         
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



template< typename T >
struct SegmentTree{
    private:
        int n;
        vector<T> segMax;
        vector<T> segAdd;
 
    public:
        SegmentTree(int sz){
            n = 1;
            while(n < sz) n *= 2;
            segMax.resize(2*n-1, 0);
            segAdd.resize(2*n-1, 0);
        }
 
        void add(int a, int b, T x, int k, int l, int r) {
            if (r <= a || b <= l) return;
            if (a <= l && r <= b){
                segAdd[k] += x;
                return;
            }
            add(a, b, x, k * 2 + 1, l, (l + r) / 2);
            add(a, b, x, k * 2 + 2, (l + r) / 2, r);
            segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
        }
 
        void add(int a,int b, T x) {
            add(a, b, x, 0, 0, n);
        }
 
        T getMax(int a, int b, int k, int l, int r) {
            if (r <= a || b <= l) return 0;
            if (a <= l && r <= b) return (segMax[k] + segAdd[k]);
            T left = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
            T right = getMax(a, b, k * 2 + 2, (l + r) / 2, r);
            return (max(left, right) + segAdd[k]);
        }
 
        T getMax(int a,int b){
            return getMax(a, b, 0, 0, n);
        }
};


int main(){
    int h,w,m;cin >> h >> w >> m;
    vector<LL> y(h,0), x(w,0);
    vector<vector<int>> xx(h);
    for (int i = 0; i < m; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        y[a]++;
        x[b]++;
        xx[a].pb(b);
    }
    SegmentTree<int> seg(w);
    for (int i = 0; i < w; i++) {
        seg.add(i, i+1, x[i]);
    }
    LL ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < xx[i].size(); j++) {
            seg.add(xx[i][j], xx[i][j]+1, -1);
        }
        chmax(ans, y[i] + seg.getMax(0, w));
        for (int j = 0; j < xx[i].size(); j++) {
            seg.add(xx[i][j], xx[i][j]+1, 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 32548
n = int(input())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))

ans = a[0]
idx = 1
n -= 2
while n > 0:
    if n == 1:
        ans += a[idx]
        n -= 1
    else:
        ans += 2*a[idx]
        n -= 2
    idx += 1
print(ans)

Measured memory_bytes: 31624
#include<bits/stdc++.h>
#define ll long long 
#define ld long double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX 10000003
using namespace std;
void solve()
{
    ll n;  cin>>n;
    ld arr[n];  
    rep(i,0,n)  cin>>arr[i];
    vector<vector<ld>> dp(n+1,vector<ld>(n+1,0));
    dp[0][0]=1;
    rep(i,1,n+1) dp[i][0]=dp[i-1][0]*(1-arr[i-1]);
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
        {
            dp[i][j]=dp[i-1][j-1]*arr[i-1]+dp[i-1][j]*(1-arr[i-1]);
        }
    }
    ld ans=0;
    rep(j,(n+1)/2,n+1) ans+=dp[n][j];
    cout<<fixed<<setprecision(10)<<ans;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}

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

int main() 
{
    ll k,n; cin>>k>>n;
    ll a[n+1],ma=-(1e9+9);
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    a[n]=a[0]+k;
    rep(i,n) ma=max(ma,a[i+1]-a[i]);
    cout<<k-ma<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
//#define int long long

const int M = 80 * (80 + 80);
int A[100][100], B[100][100];

signed main(){

  int H, W; cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> B[i][j];
    }
  }

  static int dp[100][100][M * 2];
  dp[0][0][M + abs(A[0][0] - B[0][0])] = dp[0][0][M - abs(A[0][0] - B[0][0])] = 1;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      for(int k = 0; k < M * 2; k++){
        if(dp[i][j][k]){
          if(i+1 < H){
            dp[i+1][j][k + abs(A[i+1][j] - B[i+1][j])] |= dp[i][j][k];
            dp[i+1][j][k - abs(A[i+1][j] - B[i+1][j])] |= dp[i][j][k];
          }
          if(j+1 < W){
            dp[i][j+1][k + abs(A[i][j+1] - B[i][j+1])] |= dp[i][j][k];
            dp[i][j+1][k - abs(A[i][j+1] - B[i][j+1])] |= dp[i][j][k];
          }
        }
      }
    }
  }

  int ans = 1 << 30;
  for(int i = 0; i < M * 2; i++){
    if(dp[H-1][W-1][i]){
      ans = min(ans, abs(M - i));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 797184
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(){
	string s;
	
	while(getline(cin,s)){
		
		stack<char> st;
		bool flag=true;

		if(s==".")break;

		for(int i=0;i<s.size();i++){
			char ch=s[i];

			if(ch=='('||ch=='['){
				st.push(ch);
			}
			else if(ch==')'||ch==']'){
				if(st.empty()){
					flag=false;
					break;
				}else if(ch==')'&&st.top()=='('){
					st.pop();
				}else if(ch==']'&&st.top()=='['){
					st.pop();
				}
				else{
					flag=false;
					break;
				}
			}
		}
		if(st.empty()&&flag){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> count(100005);
  for(int i=0;i<n;i++){
  int a;
  cin>>a;
  count[a]++;
  if(a-1==-1){
    count[100001]++;
  }
  else{
    count[a-1]++;
  }
  count[a+1]++;
  }
  int ans=0;
  for(int i=0;i<count.size();i++){
    ans=max(ans,count[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3772
n,m = map(int,input().split())
arr= list(map(int,input().split()))

arr.sort()
oper = []
for i in range(m):
    a,b = map(int,input().split())
    oper.append([b,a])
oper = sorted(oper,reverse=True)
idex = 0
while(idex<n):
    for v,c in oper:
        for i in range(c):
            if arr[idex]<v:
                arr[idex]=v
                idex+=1
            else:
                print(sum(arr))
                exit()
            if idex>n-1:
                print(sum(arr))
                exit()
    print(sum(arr))
    break

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

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        vector<string> train;
        string s;
        cin >> s;
        int k = s.size();

        for (int j = 1; j < k; j++){
            vector<string> left(2);
            vector<string> right(2);
            left[0] = s.substr(0, j);
            right[0] = s.substr(j);
            string r_left = left[0];
            string r_right = right[0];
            reverse(r_left.begin(), r_left.end());
            reverse(r_right.begin(), r_right.end());
            left[1] = r_left;
            right[1] = r_right;

            for (int j = 0; j < 2; j++){
                for (int z = 0; z < 2; z++){
                    train.push_back(left[j] + right[z]);
                    train.push_back(right[z] + left[j]);
                }
            }
        }
        set<string> ans(train.begin(), train.end());

        cout << (int)ans.size() << endl;
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<vector<int>> A(K, vector<int>());
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    A[i].resize(d[i]);
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    bool have = false;
    for (auto v : A) {
      for (auto p : v) {
        if (p == i) have = true;
      }
    }
    if (!have) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto& i : a) cin >> i;
	for (int i = k; i < n; ++i) {
		if (a[i] > a[i - k]) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll=long long;
int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> h(n);
  vector<int> ans(n);
  rep(i,n) cin >> h[i];
  rep(i,m){
    int p1, p2;
    cin >>p1 >>p2;
    //cout << h[p1-1] << h[p2-1] << endl;
    if(h[p1-1]>h[p2-1]) ans[p2-1]+=1;
    else if(h[p1-1]<h[p2-1])  ans[p1-1]+=1;
    else{
      ans[p1-1]+=1;
      ans[p2-1]+=1;
    }
  }
  int cnt=0;
  rep(i,n){
    if(ans[i]==0) cnt+=1;
  }
  cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;
const ll mod = 1e9 + 7;

ll bigmod(ll n, ll m) {
  ll rem = 1;
  while(m) {
    if(m & 1) rem = (rem * n) % 13;
    m >>= 1;
    n = (n * n) % 13;
  }
  return rem;
}

ll dp[N][20];
int n; string x;

ll go(int idx, ll rem) {
  if(idx == n) return rem == 5;
  if(dp[idx][rem] != -1) return dp[idx][rem];
  ll ways = 0;
  if(x[idx] == '?') {
    for(ll i = 0; i < 10; i++) {
      ways = (ways + go(idx + 1, (rem + i * bigmod(10ll, idx)) % 13ll)) % mod;
    }
  } else {
    ways = (ways + go(idx + 1, (rem + (x[idx] - '0') * bigmod(10ll, idx)) % 13ll)) % mod;
  }
  return dp[idx][rem] = ways;
}

int main() {
  cin >> x; n = x.length();
  reverse(x.begin(), x.end());
  memset(dp, -1, sizeof dp);
  cout << go(0, 0) << '\n';
}

Measured memory_bytes: 23936
n = gets.to_i
as = gets.split.map(&:to_i)
bs = as.map { |a| a + 1 }
cs = as.map { |a| a - 1 }

count = [*as, *bs, *cs].each_with_object(Hash.new(0)) do |n, h|
  h[n] += 1
end

puts count.values.max


Measured memory_bytes: 21252
#include<stdio.h>

int main()
{
	int a, b, c, x, count = 0;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	int i, j, k, sum = 0;
	for (i = 0; i <= a; i++)
		for (k = 0; k <= b; k++)
			for (j = 0; j <= c; j++)
			{
				sum = i * 500 + k * 100 + j * 50;
				if (sum == x)
					count++;
			}


	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let k: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    print!("{}", (&s).into_iter().take(k).collect::<String>());
    if s.len() > k {
        println!("...");
    } else {
        println!("");
    }
}


Measured memory_bytes: 2128
W, H, N = map(int, input().split())
XYA = [list(map(int, input().split())) for _ in range(N)]
x1, x2, y1, y2 = 0, W, 0, H
for x, y, a in XYA:
    if a == 1:
        x1 = max(x1, x)
    elif a == 2: 
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    elif a == 4:
        y2 = min(y2, y)
if x2 > x1 and y2 > y1:
    print((x2-x1)*(y2-y1))
else:
    print(0)


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,m;cin >> n >>m;
    vector<vector<lint>> v(m,vector<lint>(3));
    REP(i, m) {
        lint p, y;
        cin >> v[i][0] >> v[i][1];
        v[i][2] = i;
        }
    lint ans=0;
    vector<vector<lint>> number(m, vector<lint>(2));
    sort(ALL(v));
    lint j = 1,c=1;
    REP(i,m){
        while(true){
            if (v[i][0] != j)
            {
                j++;
                c = 1;
            }else{
                break;
            }
        }
        number[v[i][2]][0] = v[i][0];
        number[v[i][2]][1] = c;
        c++;
    }

    REP(i, m){
       // cout << number[i][0] <<" "<< number[i][1]<<"\n";
       cout << std::setfill('0') << std::right << std::setw(6) << number[i][0];
       cout << std::setfill('0') << std::right << std::setw(6) << number[i][1] << "\n";
    }

    return 0;
}

Measured memory_bytes: 12416
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
        int n,a[100000],s=0,i;
        scanf("%d",&n);
        a[0]=0;
        a[n+1]=0;
        for(i=1;i<=n;i++) scanf("%d",&a[i]);
        for(i=0;i<=n;i++) s=s+abs(a[i]-a[i+1]);
        for(i=1;i<=n;i++) printf("%d\n",s-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
        return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>

using namespace std;

struct Node{
    Node *left;
    Node *right;
	int key;
	int pri;

	Node(int k, int p) : key(k), pri(p){
		left = right = NULL;
	}
};

Node* rightRotate(Node *t){
    Node* s = t->left;
	t->left = s->right;
	s->right = t;
	
	return s; 
}

Node* leftRotate(Node *t){
    Node* s = t->right;
	t->right = s->left;
	s->left = t;
	
	return s; 
}

void find(Node *t, int k){
  while(t != NULL && k != t->key){
    if(k < t->key) t = t->left;
    else t = t->right;
  }

  if ( t != NULL ) cout << "yes" << endl;
  else cout << "no" << endl;
}

Node* insert(Node *t, int key, int pri){
    if(t == NULL){ return new Node(key, pri); }
    if(key == t->key){ return t; }                     

    if(key < t->key){                         
        t->left = insert(t->left, key, pri);  
		if(t->pri < t->left->pri){ t = rightRotate(t); }
	} else{
        t->right = insert(t->right, key, pri);
		if(t->pri < t->right->pri){ t = leftRotate(t); }
	}
	
	return t;
}

Node* erase(Node *t, int key){
    if(t == NULL){ return NULL; }
	
	if(key == t->key){                         
		if(t->left == NULL && t->right == NULL){ return NULL; }
        else if(t->left == NULL){ t = leftRotate(t); }
        else if(t->right == NULL){ t = rightRotate(t); }
        else{
            if(t->left->pri > t->right->pri){ t = rightRotate(t); }
            else{ t = leftRotate(t); }
		}
		return erase(t, key);
	}
	
	if(key < t->key){ t->left = erase(t->left, key); }
	else{ t->right = erase(t->right, key); }
	
	return t;
}


void Inorder(Node *t){
  if(t->left != NULL) Inorder(t->left);
  if(t->key != -1) cout << " " << t->key;
  if(t->right != NULL) Inorder(t->right);
}
   
void Preorder(Node *t){
  if(t->key != -1) cout << " " << t->key;
  if(t->left != NULL) Preorder(t->left);
  if(t->right != NULL) Preorder(t->right);
}


void print(Node *t){
	if(t != NULL) Inorder(t);
	  cout <<endl;
      if(t != NULL) Preorder(t);
	  cout <<endl;
}

int main(){
	int n;
	cin >> n;
    char ope[n];
	int k, p;

	Node *t=new Node(-1, -1);

	for(int i=0; i<n; i++){
		scanf("%s", ope);
		if(ope[0] == 'p'){ print(t); }
		else if(ope[0] == 'f'){ cin >> k; find(t, k); }
		else if(ope[0] == 'd'){ cin >> k; t = erase(t, k); }
		else if(ope[0] == 'i'){ cin >> k >> p; t = insert(t, k, p); }
	}

	return 0;
}


Measured memory_bytes: 9484
from collections import Counter

class Prime:
    def __init__(self, N):
        smallestPrime = [i for i in range(N + 1)]

        for i in range(2, N + 1):
            if smallestPrime[i] != i:
                continue
            for p in range(i * 2, N + 1, i):
                if smallestPrime[p] == p:
                    smallestPrime[p] = i

        self.smallestPrime = smallestPrime

    def isPrime(self, n):
        return n > 1 and self.smallestPrime[n] == n

    def factorization(self, n):
        ret = Counter()
        while n > 1:
            p = self.smallestPrime[n]
            ret[p] += 1
            n //= p
        return ret

from math import gcd

N = int(input())
A = list(map(int, input().split()))
primeFactorization = Prime(max(A) + 10).factorization

def isSetwise(A):
    ret = A[0]
    for a in A:
        ret = gcd(ret, a)
    return ret == 1

def isPairwise(A):
    P = Counter()
    for a in A:
        for p in primeFactorization(a):
            if P[p] >= 1:
                return False
            P[p] += 1
    return True

if not isSetwise(A):
    print('not coprime')
    exit()

if isPairwise(A):
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 133280
from collections import Counter
n = int(input())
a = [int(i) for i in input().split(" ")]
r = [i+1-j for i, j in enumerate(a)]
l = [j+i+1 for i, j in enumerate(a)]
nl = Counter(l)
nr = Counter(r)
 
ans = 0
for k, v in nl.items():
    ans += nr[k]*v
print(ans)

Measured memory_bytes: 63316
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;

int h, w, n, a[101][101],iro[10003],cnt[10011];


int main() {
	cin >> h >> w>>n;
	rep(n)cin >> iro[i];
	memset(a, 0, sizeof(a));
	memset(cnt, 0, sizeof(cnt));
	int loc = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			a[i][j] = loc;
			cnt[loc-1]++;
			if (cnt[loc-1] == iro[loc-1])loc ++;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i % 2 == 1)cout << a[i][w - 1 - j]<<" ";
			else cout << a[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
    }
    Y = X;
    sort(ALL(Y));
    int a = Y.at(N / 2 - 1), b = Y.at(N / 2);
    for (int i = 0; i < N; i++) {
        if (X.at(i) >= b) {
            cout << a << endl;
        }
        else {
            cout << b << endl;
        }
    }
}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		var a=sc.Ia2;
		var h=Enumerable.Repeat(-1,(int)s[0]+1).ToArray();
		int d=1,k=0;
		while(h[d]==-1){
			h[d]=k;
			if(k==s[1]){
				Console.WriteLine(d);
				return;
			}
			d=a[d];
			k++;
		}
		s[1]-=h[d];
		s[1]%=k-h[d];
		while(s[1]>0){
			d=a[d];
			s[1]--;
		}
		Console.WriteLine(d);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,t; cin>>n>>t;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll r=0;
  ll max=0, ans=0;
  rep(l,n){
    ll tmp=0;
    while(r<n&&a[l]<=a[r]){
      chmax(tmp,a[r]);
      r++;
    }
    ll d=tmp-a[l];
    if(chmax(max,d)) ans=1;
    else if(max==d) ans++;
    
    // cout<<a[l]<<" "<<a[r]<<" "<<d<<endl;
    
    if(l==r) r++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
tuple<int, int ,int> d[1000];
signed main() {
  int N, M, A;
  while (cin>>N>>M>>A,N+M+A!=0) {
    for (int i = 0; i < M; i++) {
      int h, p, q; cin>>h>>p>>q;
      d[i] = make_tuple(h,p,q);
    }
    sort(d, d+M);
    reverse(d, d+M);
    int ans = A;
    for (int i = 0; i < M; i++) {
      if (get<1>(d[i]) == ans) {
        ans = get<2>(d[i]); 
      } else if (get<2>(d[i]) == ans) {
        ans = get<1>(d[i]);
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	char s[100];
	for (int i = 0; i < 3; ++i) {
		cin >> s;
		cout << (char)toupper(s[0]);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
s = input().split()
N = int(s[0])
T = int(s[1])
c_min = 1000
count = 0
for i in range(N):
    d = input().split()
    c = int(d[0])
    t = int(d[1])
    if t <= T:
        count += 1
        if c_min >= c:
            c_min = c

if count == 0:
    print('TLE')
else:
    print(c_min)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  n = 2 * n - 1;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  auto get = [&] (int x) {
    vector <int> b(n);
    for (int i = 0; i < n; ++i) {
      if (a[i] >= x) b[i] = 1;
      else b[i] = 0;
    }
    int p = n / 2;
    int cnt_l = 0, cnt_r = 0;
    for (int i = p - 1; i >= 0; --i) {
      if (b[i] != b[i + 1]) {
        ++cnt_l;
      } else {
        break;
      }
    }
    for (int i = p + 1; i < n; ++i) {
      if (b[i] != b[i - 1]) {
        ++cnt_r;
      } else {
        break;
      }
    }
    int c = min(cnt_l, cnt_r) % 2;
    return b[p] ^ c;
  };
  int l = 0, r = n;
  while (r - l > 1) {
    int m = (l + r) >> 1;
    if (get(m) == 1) l = m;
    else r = m;
  }
  cout << l << '\n';
}



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

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

	string s,t;
	cin>>s>>t;
	int n = s.size();
	int ans = 0;
	for(int i=0; i<n; ++i){
		if( s[i] != t[i] ){ ++ans; }
	}
	cout<<ans<<'\n';


	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<ll> Vec;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD =  1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans;
    ans = min(n*a,b);
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

    switch (s) {
      case "SUN":
        next = 7;
        break;
      case "MON":
        next = 6;
        break;
      case "TUE":
        next = 5;
        break;
      case "WED":
        next = 4;
        break;
      case "THU":
        next = 3;
        break;
      case "FRI":
        next = 2;
        break;
      case "SAT":
        next = 1;
        break;
    }
    System.out.println(next);
  }

}


Measured memory_bytes: 21844
a1 = list(input().split())
a2 = list(input().split())
a3 = list(input().split())

n = int(input())

for _ in range(n):
    b = input()
    for i in range(3):
        if b == a1[i]:
            a1[i] = 0
        if b == a2[i]:
            a2[i] = 0
        if b == a3[i]:
            a3[i] = 0
        
if a1[0]==0 and a1[1]==0 and a1[2]==0:
    print('Yes')
elif a2[0]==0 and a2[1]==0 and a2[2]==0:
    print('Yes')
elif a3[0]==0 and a3[1]==0 and a3[2]==0:
    print('Yes')
elif a1[0]==0 and a2[0]==0 and a3[0]==0:
    print('Yes')
elif a1[1]==0 and a2[1]==0 and a3[1]==0:
    print('Yes')
elif a1[2]==0 and a2[2]==0 and a3[2]==0:
    print('Yes')
elif a1[0]==0 and a2[1]==0 and a3[2]==0:
    print('Yes')
elif a1[2]==0 and a2[1]==0 and a3[0]==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.*;

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

    int H = sc.nextInt();
    int W = sc.nextInt();
    
    String[] C = new String[H];
    for (int i = 0; i < H; i++) {
      C[i] = sc.next();
      System.out.println(C[i]);
      System.out.println(C[i]);
    }
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k, s;
  cin >> n >> k >> s;
  if (s == 1e9) {
    for (int i = 0; i < k; i++) {
      cout << s << ' ';
    }
    for (int i = 0; i < n - k; i++) {
      cout << 1 << ' ';
    }
    cout << '\n';
  }
  else {
    for (int i = 0; i < k; i++) {
      cout << s << ' ';
    }
    for (int i = 0; i < n - k; i++) {
      cout << s + 1 << ' ';
    }
    cout << '\n';
  }
} 

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int hero[100001];
int monster[100001];
int killed[100001];
int main()
{
    int n;
    memset(monster,0,sizeof(monster));
    memset(hero,0,sizeof(hero));
    memset(killed,0,sizeof(killed));
    cin>>n;
    int i;
    for(i=0; i<=n; i++)
        cin>>monster[i];
    for(i=0; i<n; i++)
        cin>>hero[i];
    long long int num=0;
    for(i=0; i<n; i++)
    {
        if(monster[i]>=hero[i])
            killed[i]=hero[i];
        else if(monster[i+1]>hero[i]-monster[i])
        {
            killed[i]=hero[i];
            monster[i+1]=monster[i+1]+monster[i]-hero[i];
        }
        else
        {
            killed[i]=monster[i]+monster[i+1];
            monster[i]=0;
            monster[i+1]=0;
        }
    }
    for(i=0; i<n; i++)
        num+=killed[i];
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 1408
n,k = map(int,input().split())
field = list(map(int,input().split()))
dp = [float("inf")]*len(field)
dp[0] = 0
for i in range(0,n - 1):
  for j in range(1,k + 1):
    if i + j < n:
      dp[i + j] = min(dp[i + j],dp[i] + abs(field[i + j] - field[i]))
print(dp[-1])


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

typedef long long int ll;

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

    ll ans = 0;
    for(ll i = 0;i < s.size();i++){
        if(s[i] == '+'){
            ans++;
        }
        else{
            ans--;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_149
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            bool[] isPrime = new bool[1000000];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i < isPrime.Length; i++)
            {
                if (!isPrime[i]) continue;
                for (int j = 2; i * j < isPrime.Length; j++)
                {
                    isPrime[i * j] = false;
                }
            }

            int x = ReadInt();
            for (int i = x; i < isPrime.Length; i++)
            {
                if (isPrime[i])
                {
                    WriteLine(i);
                    return;
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

    int main()
    {
unsigned ll n,c=0;
cin>>n;
// a[n];
for(unsigned ll i=1;i<=n;i++)
{

    if(i%3!=0 && i%5!=0) {c+=i;}
}
cout<<c;
          return 0;
    }


Measured memory_bytes: 3600
#include<algorithm>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;

int main() {
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    
    int n, m;
    string s;
    cin >> n >> m;
    cin >> s;
    s[m - 1] -= 'A' - 'a';
    cout << s << endl;
    return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a;
	if(a%2==0){
		b=a/2;
		c=a/2;
	}
	else{
		b=a/2;
		c=a/2+1;
	}
	cout<<b*c<<endl;
}

Measured memory_bytes: 256