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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

// [position][stuck]
double dp[105][2], dp2[105][2];

int main() {
    for (;;) {
        rep(i, 0, 105) rep(j, 0, 2) dp[i][j] = 0.0;
        dp[0][0] = 1.0;

        int n, t, l, b; cin >> n >> t >> l >> b; if (!n) break;
        bitset<105> islose, isback;
        rep(i, 0, l) {
            int t; cin >> t; islose[t] = 1;
        }
        rep(i, 0, b) {
            int t; cin >> t; isback[t] = 1;
        }
        rep(i, 0, t) {
            rep(j, 0, n) {
                rep(k, 1, 7) {
                    int nxt = j + k;
                    if (nxt > n) nxt = n - (nxt - n);
                    if (isback[nxt]) dp2[0][0] += dp[j][0] / 6;
                    else if (islose[nxt]) dp2[nxt][1] += dp[j][0] / 6;
                    else dp2[nxt][0] += dp[j][0] / 6;
                }
                dp2[j][0] += dp[j][1];
            }
            dp2[n][0] += dp[n][0];
            rep(i, 0, 105) rep(j, 0, 2) { dp[i][j] = dp2[i][j]; dp2[i][j] = 0; }
            // rep(i, 0, n + 1) { fprintf(stderr, "%d=%.6lf(%.6lf) ", i, dp[i][0], dp[i][1]); } fprintf(stderr, "\n");
        }
        // fprintf(stderr, "\n\n\n\n");
        cout << fixed << setprecision(9) << dp[n][0] << endl;
    }
}


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

int main() {
	const double PI = acos(-1);
	double a;
	cin >> a;
	double b;
	cin >> b;
	double x;
	cin >> x;
	constexpr int d = std::numeric_limits<float>::max_digits10;
	if (x / a < a * b / 2.0) {
		cout << setprecision(d) << 180.0 * atan(a * b * b / (2 * x)) / PI << endl;
	}
	else {
		//cout << 180.0 * atan(2 * b / a - 2 * x / (a * a * a)) / PI << endl;
		cout << setprecision(d) << 180.0 * atan((2 * b - 2 * x / (a * a)) / a) / PI << endl;
	}
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    LL x;
    cin >> x;

    DD xx = (-1. + sqrt(1. + 8. * x)) / 2.;
    LL n = xx;
    if(n * 1. != xx)
        n++;

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


Measured memory_bytes: 3668
import math
N, M = input().split()
N=int(N)
M=int(M)
values = [int(i) for i in input().split()]
values.sort()
app = []
for i in range(M-1):
    app.append(values[i+1]-values[i])
app.sort()
ans = 0
for i in range(M-N):
    ans += app[i]
print(ans)


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
const int MOD = 1e9 + 7;
ll factorial(ll n){
    if (n == 1) return 1;
    return n * factorial(n-1);
}
vector<pair<ll,ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
    }
int main(){

    ll N;
    cin >> N;
    //vector<pair<int,int>> prime;
    map<int,int> prime;
    for (int i = 2; i <= N; i++){
        bool ok = true;
        for (int k = 2; k < i; k++){
            if (i % k == 0) ok = false;
        }
        if (ok){
            //prime.push_back(make_pair(i,0));
            prime[i] = 0;
        }
    }

    /*
    for (int i = 0; i < (int)prime.size(); i++){
        cout << prime[i].first << endl;
    }
    */


    vector<pair<ll,ll>> test;
    test = prime_factorize(N);
    for (int i = 0; i < test.size(); i++){
    }

    for (int i = 2; i <= N; i++){
        vector<pair<ll,ll>> tmp;
        tmp = prime_factorize(i);
        for (int i = 0; i < tmp.size(); i++){
            prime[tmp[i].first] += tmp[i].second;
        }
    }

    ll ans = 1;
    for (auto i = prime.begin(); i != prime.end(); ++i){
        ans *= i -> second + 1;
        ans %= MOD;
    }
    cout << ans << endl;







    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//const int N=100*1000;
//int tree[];
//int f[56];
int x[109];
int main(){
    int n,k;cin>>n>>k;
    for(int i=1;i<=n;++i)cin>>x[i];
    int ans=0;
    for(int i=1;i<=n;++i){
       int val1=2*(x[i]);
        int val2=2*(abs(k-x[i]));
        ans+=min(val1,val2);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    vector<int> v(100001);
    
    int n;
    cin >> n;

    int val;
    for(int i = 0; i < n; i++){
        cin >> val;
        if(val > 0) v[val-1] ++;
        v[val] ++;
        v[val+1] ++;
    }   

    int max = *max_element(v.begin(), v.end());
    cout << max << endl;

}

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


int main() {
  string S;
  string S1 = "ABC";
  string S2 = "ARC";
  cin >> S;
  
  if(S == S1){
    cout << S2 <<endl;
  }
  else{
    cout << S1 <<endl;
  }
}


Measured memory_bytes: 3628
# coding: utf-8
# Your code here!

def Floyd_Warshall(dist):
    num_of_vertices = n
    for k in range(num_of_vertices):
        for i in range(num_of_vertices):
            for j in range(num_of_vertices):
                dist[i][j] = min(dist[i][j], dist[i][k]+ dist[k][j])


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

#n,m = [int(i) for i in readline().split()]

n = int(input())


dist = [None for i in range(n)]
INF = float("inf")

g = [[] for i in range(n)]

for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == "1":
            g[i].append(j)
    dist[i] = [1 if j == "1" else INF for j in s]

for i in range(n):
    dist[i][i] = 0


from collections import deque
def bfs(g,root):
        
    q = deque()
    memo = [-1]*(len(g))
    """初期化、キューに入れて訪問済みにする"""
    memo[root] = 0
    q.append(root)
    """BFS"""
    while q: #キューが空になるまで
        v = q.popleft() #キューから情報を取り出す
        for c in g[v]:
            if memo[c] >= 0:
                if memo[c] ==  memo[v] ^ 1:
                    continue
                else:
                    return False
            memo[c] = memo[v] ^ 1
            q.append(c)
    return True

if bfs(g,0):
    #print(dist)
    Floyd_Warshall(dist)
    #print(dist)
    ans = 0
    for i in range(n):
        for j in range(n):
            ans = max(ans,dist[i][j])
    print(ans+1)
            

else:
    print(-1)











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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string a;
	cin >> a;
	
	ll n = (ll) (a.length());
	
	ll cnt[26] = {};
	rep(i, n) {
		cnt[a[i] - 'a']++;
	}
	
	ll ans = n * (n - 1) / 2;
	rep(i, 26) {
		ans -= cnt[i] * (cnt[i] - 1) / 2;
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}

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

using namespace std;

const int N = 123456;
const long long llinf = 1e18;

int n, e, t, p[N], q[N], l, r;
long long dp[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> e >> t;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  q[l = r = 0] = 0;
  long long pre_min = llinf;
  for (int i = 1, j = 0; i <= n; ++i) {
    dp[i] = llinf;
    while (l <= r && 2 * (p[i] - p[q[l] + 1]) > t) {
      ++l;
    }
    if (l <= r) {
      dp[i] = min(dp[i], dp[q[l]] - p[q[l]] + p[i] + t);
    }
    while (2 * (p[i] - p[j + 1]) > t) {
      pre_min = min(pre_min, dp[j] - p[j] - 2 * p[j + 1]);
      ++j;
    }
    dp[i] = min(dp[i], pre_min + 3ll * p[i]);
    while (l <= r && dp[i] - p[i] <= dp[q[r]] - p[q[r]]) {
      --r;
    }
    q[++r] = i;
  }
  cout << dp[n] + e - p[n] << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pir pair<int,int>
#define make(a,b) make_pair(a,b)
using namespace std;
const int N=3e5+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int x[N],t[N],del[N];
stack<int>v[2];
pir f[N];
ll ans;
int main(){
    int n=gi(),L=gi();
    for (int i=1; i<=n; ++i) x[i]=gi();
    for (int i=1; i<=n; ++i){
	t[i]=gi();
	ans+=L*2*(t[i]/(L*2));
	t[i]%=L*2;
    }
    for (int i=1; i<=n; ++i)
	if (t[i]){
	    f[i].fi=(t[i]>2*(L-x[i])?1:0);
	    f[i].se=(t[i]>2*x[i]?1:0);
	}
	else
	    f[i]=make(1,1);
    for (int i=1; i<=n; ++i)
	if (f[i].fi&f[i].se){
	    del[i]=1;
	    if (t[i]!=0)
		ans+=2*L;
	}
    for (int i=1; i<n; ++i){
	if (del[i]) continue;
	if (f[i].fi==0){
	    if (f[i].se==1){
		if (!v[0].empty()){
		    del[i]=del[v[0].top()]=1;
		    v[0].pop(),ans+=2*L;
		}
	    }
	    else
		v[0].push(i);
	}
    }
    while(!v[0].empty()) v[0].pop();
    for (int i=1; i<n; ++i){
	if (del[i]==1||f[i].se==1) continue;
	if (f[i].fi==0){
	    if (!v[1].empty()){
		del[i]=del[v[1].top()]=1;
		v[1].pop(),ans+=2*L;
	    }
	    else if (!v[0].empty()){
		del[i]=del[v[0].top()]=1;
		v[0].pop(),ans+=2*L;
	    }
	    else v[0].push(i);
	}
	else v[1].push(i);
    }
    if (f[n].fi==0&&!del[n])
	for (int i=1; i<n; ++i)
	    if (!del[i]&&f[i].se==0){
		del[i]=del[n]=1;
		ans+=2*L;
		break;
	    }
    for (int i=1; i<=n; ++i)
	if (!del[i])
	    ans+=2*L;
    if (!del[n]&&f[n].fi==1)
	    ans+=2*L;
    if (del[n]==1)
	ans+=2*L;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7296
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
#include<string.h>
int main(){
    int N,M;
    while(cin>>N>>M, N+M){
        int r; cin>>r;
        vector<vector<pii>>v(M+1,vector<pii>());
        vvi pclog(N+1,vi(M+1,0));
        rep(i,r){
            int t,n,m,s; cin>>t>>n>>m>>s;
            if(s){
                pclog[n][m]=t;
            }else{
                v[m].push_back(pii(pclog[n][m],t));
                pclog[n][m]=0;
            }
        }
        int q; cin>>q;
        rep(j,q){
            int ts,te,m; cin>>ts>>te>>m;
            ll ans=0;
            pii gotiusa;
            int imos[100000]={0};
            memset(imos, 0,sizeof(imos));
            rep(hoge,v[m].size()){
                imos[v[m][hoge].first]++;
                imos[v[m][hoge].second]--;
            }
            for(int i=0; i<10000;i++)
                if(i)imos[i]+=imos[i-1];
            for(int i=ts; i<te;i++)
                if(imos[i]>0)ans++;
            cout<<ans<<endl;
        }
    }
}

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

int main() {
    int h,w;
    cin>>h>>w;
    char paint[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>paint[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w-1;j++){
            if((paint[i][j]=='#'||paint[i][j]=='+')&& (paint[i][j+1]=='#'|| paint[i][j+1]=='+')){
                paint[i][j]='+';
                paint[i][j+1]='+';
            };
        }
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h-1;j++){
            if((paint[j][i]=='#'||paint[j][i]=='+')&& (paint[j+1][i]=='#'|| paint[j+1][i]=='+')){
                paint[j][i]='+';
                paint[j+1][i]='+';
            };
        }
    }
    int result=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(paint[i][j]=='#') result=0;
        }
    }
    if(result==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
void show(VEC<VEC<int>> a) {
  int h = a.size();
  int w = a[0].size();
  REP(i, 0, h) {
    REP(j, 0, w) { cerr << a[i][j] << " "; }
    cerr << endl;
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  VEC<VEC<int>> a(H, VEC<int>(W, 0));
  REP(h, 0, H) {
    REP(w, 0, W) {
      int b;
      cin >> b;
      a[h][w] = b % 2 == 1;
    }
  }
  stringstream stream;
  int cnt = 0;
  // cerr << endl;
  // show(a);
  // cerr << endl;

  REP(h, 0, H) {
    REP(w, 0, W - 1) {
      if (a[h][w] == 1) {
        cnt++;
        stream << h + 1 << " " << w + 1 << " " << h + 1 << " " << w + 2 << endl;
        a[h][w + 1] = (a[h][w + 1] + 1) % 2 == 1;
        a[h][w] = 0;
        // cerr << endl;
        // show(a);
        // cerr << endl;
      }
    }
  }
  //cerr << "HI" << endl;
  REP(h, 0, H - 1) {
    if (a[h][W - 1]) {
      cnt++;
      stream << h + 1 << " " << W << " " << h + 2 << " " << W << endl;
      a[h+1][W - 1] = (a[h+1][W - 1] + 1) % 2 == 1;
      a[h][W - 1] = 0;
      // cerr << endl;
      // show(a);
      // cerr << endl;
    }
  }
  cout << cnt << endl;
  cout << stream.str() ;
  return 0;
}


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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

using Graph = vector<vector<int>>;

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

    void inputGraph(Graph &g,int path_num,bool isdirected){
        for(int i = 0;i < path_num;i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            if(isdirected){
                g[a].push_back(b);
            }
            else{
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
}

void calculate(){
    int N,M;
    map<string,int> m;
    Input::input(N);
    string tmp;
    rep(i,N){
        cin >> tmp;
        if(m.count(tmp) == 0){
            m.insert(make_pair(tmp,1));
        }
        else{
            m[tmp]++;
        }
    }
    Input::input(M);
    rep(i,M){
        cin >> tmp;
        if(m.count(tmp) == 0){
            m.insert(make_pair(tmp,-1));
        }
        else{
            m[tmp]--;
        }
    }
    int res = 0;
    for(auto i : m){
        res = max(res,i.second);
    }
    cout << res<< '\n';
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
int main()
{
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int AB = 2 * C;
  int ans = AB * max(X, Y);
  rep(i, 0, max(X, Y))
      ans = min(ans, AB * i + A * max(0, X - i) + B * max(0, Y - i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, K) = (input[0], input[1])
var S = readLine()!.toArray()
for (i, c) in S.enumerate() {
    if i == K-1 {
        print(c.lowercased(), terminator: "")
    } else {
        print(c, terminator: "")
    }
}
print("")


Measured memory_bytes: 7908
#include<iostream>
#include<bitset>
using namespace std;
bitset<10000> cookie[10];
int N , M;
int main(int argc, char const *argv[])
{
	while(cin >> N >> M , N != 0)
	{
		for(int i = 0 ; i < N ; i++)
			for(int j = 0 ; j < M ; j++)
			{
				bool data;
				cin >> data;
				cookie[i][j] = data;
			}
		int permute = 1 << N;
		int result = 0;
		for(int i = 0 ; i < permute ; i++)
		{
			for(int j = 0 ; j < N ; j++)
			{
				if(i & (1 << j))
				{
					cookie[j].flip();
				}
			}
			int possible_answer = 0;
			for(int j = 0 ; j < M ; j++)
			{
				int up_possible_answer = 0;
				for(int k = 0 ; k < N ; k++)
				{
					if(cookie[k][j])
					{
						up_possible_answer++;
					}
				}
				possible_answer += max(up_possible_answer , N - up_possible_answer);
			}
			result = max(result , possible_answer);
			for(int j = 0 ; j < N ; j++)
			{
				if(i & (1 << j))
				{
					cookie[j].flip();
				}
			}
		}
		cout << result << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>

int main(){
  int i,j,n,tmp;
  int cnt=0;
  scanf("%d",&n);
  int A[n];

  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
  
  for(i=0; i<n; i++)
    for(j=n-1; j>=i; j--)
      if(A[j] < A[j-1]){
        tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	cnt++;
      }
  
  for(i=0; i<n-1; i++)
    printf("%d ",A[i]);
  
  printf("%d\n",A[n-1]);
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define ff(i,n,b) fill(i,i+n,b)
#define sorts(v) sort(v.begin(),v.end())
#define sf(a) scanf("%d",&a)
#define down greater<int>()
#define sankaku(x,y)
#define kiru substr// s.insort(0,"a"); s.substr(5,3) //5~3
#define asas(a,b) assign(a,b) ////amojimenibwodainyuu anoutinobkowodainyuu
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int a[100005]={0},b[100005]={0};
    cin >> n;
    rep(i,0,n){
        cin >> a[i] >> b[i];
    }
    int ans = 0;
    repm(i,n,0){
        int x = (a[i]+ans)%b[i];
        if(x!=0){
            ans += (b[i]-x);
        }
    }
    cout << ans << endl;
return 0;
}


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

int main(void){
    ll x;
    cin >> x;
    int cnt = 0;
    ll atm = 100;
    while (atm < x) {
        atm *= 1.01;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3628
h,w=map(int,input().split())
grid=[list(input())  for i in range(h)]

dx=[-1,0,1,0]
dy=[0,1,0,-1]
for i in range(h):
    for j in range(w):
        if grid[i][j]=='#':
            flag=False
            for k in range(4):
                x=i+dx[k]
                y=j+dy[k]
                if 0<=x<h and 0<=y<w and grid[x][y]=='#':
                    flag=True
                    break
            if flag:
                continue
            else:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
import std;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto s = new long[](N + 2);
    foreach (i; 0 .. N + 1)
    {
        s[i + 1] += s[i] + i;
    }
    long ans;
    foreach (i; K .. N + 1)
    {
        ans = (ans + (s[$ - 1] - s[$ - i - 1]) - (s[i]) + 1) % MOD;
    }
    writeln(ans + 1);
}


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

blue_ball = 0
if n / (a + b) > 1:
    answer = divmod(n, a + b)
    blue_ball = answer[0] * a
    n = answer[1]

if n > a:
    blue_ball += a
else:
    blue_ball += n

print(blue_ball)

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

int main(){
	ll l, r;
	cin >> l >> r;

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

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

bool cmp(int a, int b)
{
    return a > b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    int t = 1;
    int indx = 1;
    ll sum = a[0];
    if (n & 1)
    {
        while (t < n - 2)
        {
            sum += 2 * a[indx];
            indx++;
            t += 2;
        }
        sum += a[indx];
    }
    else
    {
        while (t < n - 1)
        {
            sum += 2 * a[indx];
            indx++;
            t += 2;
        }
    }
    cout << sum;
}


Measured memory_bytes: 4428
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    ll n; cin >> n;
    ll count = 0;
    vector<int> A(n);
    REP(i, n) {
        ll tmp; cin >> tmp;
        if(tmp <= 0) count++;
        A[i] = abs(tmp);
    }
    whole(sort, A);
    ll ans = whole(accumulate, A, 0ll);
    if(count % 2 != 0) ans = ans - A[0] * 2;
    cout << ans << endl;
    

}

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

using namespace std;

int main(){
	int a, b, x;

	cin >> a >> b >> x;
	if (a+b >= x && a <= x){
		cout << "YES";
	} else {
		cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/23.
//  Copyright © 2019 yuya. All rights reserved.
//

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

int main()
{
    int i;
    
    int r, D, x;
    
    cin >> r >> D >> x;
    
    for(i=0;i<10;i++){
        x = r*x - D;
        cout << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  if((a+b)&1) cout<<"IMPOSSIBLE"<<endl;
  else cout<<(a+b)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    n: usize,
    a: [i32; n],
    );
    let mut a = a;
    a.sort();
    let uniq: HashSet<i32> = a.into_iter().collect();
    println!("{:?}", uniq.len());
}


Measured memory_bytes: 4476
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin>>N;
  vector<ll> a(N), b(N) , c(N);
  rep(i,N) cin>>a[i];
  rep(i,N) cin>>b[i];
  rep(i,N) cin>>c[i];
  SORT(a); SORT(b); SORT(c);

  ll ans = 0;
  vector<ll> av(N), bv(N);
  //bvを求める
  rep(i,N){
    bv[i] = N - POSU(c,b[i]);
  }
  //累積和を作成する
  vector<ll> tmp(N);
  tmp[N-1] = bv[N-1];
  for(int i = N-2; i>=0; i--){
    tmp[i] = tmp[i+1] + bv[i];
  }
  //avを求める
  rep(i,N){
    av[i] += tmp[POSU(b,a[i])];
  }
  //ansを求める
  rep(i,N){
    ans += av[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{   
    class Program
    {
         static void Main(string[] args) {
           while(true){int g =0;
           	string a =Console.ReadLine();
           	if(a==null)break;
           	int b =int.Parse(a);
           	for(int e=2;b>=e;e++){
           		bool f=false;
           		int h =(int)(Math.Sqrt((double)e));
           		if(e%2==0 && e>2)f=true;
           		for(int d=3;d<=h;d+=2){	
           			if(e%d==0)f=true;
           			if(f)break;
           		}
           		if(f==false)g++;
           	}
           	Console.WriteLine(g);
           }
        }
    }
   }

Measured memory_bytes: 9068
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
	
	int N, M;
	int l, c;
	vector<int> tmp;
	vector<vector<int>> A;
	int ans;
	
	scanf("%d", &N);
	scanf("%d", &M);
	for(int i=0; i<N; i++){
		scanf("%d", &c);
		tmp.clear();
		for(int j=0; j<c; j++){
			scanf("%d", &l);
			tmp.push_back(l);
		}
		A.push_back(tmp);
	}
	
	/*
	for(int i=0; i<N; i++){
		for(int j=0; j<A[i].size(); j++){
			printf("%d ", A[i][j]);
		}
		printf("\n");
	}
	*/

	vector<bool> tmp_flag(M);
	vector<bool> final_flag(M);
	fill(tmp_flag.begin(), tmp_flag.end(), false);
	fill(final_flag.begin(), final_flag.end(), true);
	
	for(int i=0; i<N; i++){
		
		fill(tmp_flag.begin(), tmp_flag.end(), false);
		
		for(int j=0; j<A[i].size(); j++){
			tmp_flag[A[i][j]-1] = true;
		}
		
		for(int k=0; k<M; k++){
			if(tmp_flag[k] == false) final_flag[k] = false;
		}
		
	}
	
	ans = count(final_flag.begin(), final_flag.end(), true);
	
	printf("%d\n", ans);
	
	return 0;
	
}


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

ll dequeGame(int arr[], int n){

    ll dp[n][n][2];
    for(int i=0; i<n; i++){
        dp[i][i][0] = arr[i];
        dp[i][i][1] = 0;
    }
    for(int l=2; l<=n; l++){
        for(int i=0; i<=n-l; i++){
            int j = i+l-1;
            ll op1 = dp[i+1][j][1] + arr[i], op2 = dp[i][j-1][1] + arr[j];
            if(op1 > op2){
                dp[i][j][0] = op1;
                dp[i][j][1] = dp[i+1][j][0];
            }
            else{
                dp[i][j][0] = op2;
                dp[i][j][1] = dp[i][j-1][0];
            }
        }
    }
    ll ans = dp[0][n-1][0] - dp[0][n-1][1];
    return ans;
}

int main()
{
 int n;
 cin>>n;
 int arr[n];
 for(int i=0; i<n; i++)
     cin>>arr[i];
 ll ans = dequeGame(arr, n);
 cout<<ans;
 return 0;
}



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

int main()
{
	int i, n, x;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		x = i;
		if (x % 3 == 0)
		{
			cout << " " << i;
		}
		else if (x % 10 == 3)
		{
			cout << " " << i;
		}
		else
		{
			for (x; x > 1; x /= 10)
			{
				if (x % 10 == 3)
				{
					cout << " " << i;
					break;
				}
			}
		}
	}
	cout << endl;
}

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

int main() {
  ll D;
  cin>>D;
  ll c[26];
  ll s[D][26];
  rep(i,26){
    cin>>c[i];
  }
  rep(i,D){
    rep(j,26){
      cin>>s[i][j];
    }
  }
  ll t[D];
  rep(i,D){
    cin>>t[i];
    t[i]--;
  }
  
  ll M;
  cin>>M;
  ll d[M];
  ll q[M];
  rep(i,M){
    cin>>d[i]>>q[i];
    d[i]--;q[i]--;
  }
  ll satis=0;
  rep(i,D){
    ll last[26];
    rep(j,26){
      last[j]=-1;
    }
    satis=0;
    satis+=s[i][t[i]];
    last[t[i]]=i;
    rep(j,26){
      satis-=c[j]*(i-last[j]);
    }
  }
  ll b_satis=satis;
  rep(k,M){
    satis=0;
    ll last[26];
    rep(i,26){
      last[i]=-1;
    }
    t[d[k]]=q[k];
    rep(i,D){
      satis+=s[i][t[i]];
      last[t[i]]=i;
      rep(j,26){
        satis-=c[j]*(i-last[j]);
      }
      
    }
    cout<<satis<<endl;
    b_satis=satis;
  }
}


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

int main(){
  ll a,b,c,d,i;
  cin >> a >> b;
  d=1;
  c=min(a,b);
  i=1;
  while(i!=c){
    i+=1;
    if((a%i==0)&(b%i==0)){
      a=a/i;
      b=b/i;
      c=c/i;
      d=d*i;
      i=1;
    }
  }
  d=d*a*b;
  cout << d;
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll f(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}

ll g(ll a,ll n)
{
  if(a<0)return ((a%n)+n)%n;
  else return a%n;
}
char A[51][51]={0};
char B[51][51]={0};

ll solve(ll x,ll y,ll na,ll ma,ll nb,ll mb)
{
  ll cnt=0;
  for(int i=1;i<=na;i++)
  {
    //ll temp1=x+i;
    if(x+i<=0)continue;
    else if(x+i>nb)break;
    else 
      {
        for(int j=1;j<=ma;j++)
        {
          if(y+j<=0)continue;
          else if(y+j>mb)break;
          else 
            {
              cnt+=A[i][j]=='1'&&B[i+x][j+y]=='1';
            }
        }
      }
  }
  return cnt;
}

int main()
{
ll n;cin>>n;
ll ans=n*(n-1);
ans/=2;
cout<<ans<<"\n";

  return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		int j = sc.nextInt();
		int k = sc.nextInt();

		if(i+j+k >= 22)
			System.out.println("bust");
		else
			System.out.println("win");
	}
}

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

int main() {
  int n;
  cin >> n;
  
  int fill_even = 0, fill_condition = 0;
  //vector<int> ary(n);
  for (int i = 0; i < n; i++) {
    //cin >> ary.at(i);
    int num;
    cin >> num;
    
    if (num % 2 == 0) {
      fill_even++;
      if (num % 3 == 0 || num % 5 == 0) {
        fill_condition++;
      }
    }
    
  }
  
  if (fill_even == fill_condition) {
    cout << "APPROVED" << endl;
    return 0;
  }
  
  cout << "DENIED" << endl;
}

Measured memory_bytes: 256
from collections import Counter
from itertools import takewhile
N = int(input())
A_list = []
for i in range(N):
	A = str(input())
	A_list.append(A)
A_cnt = Counter(A_list)
mode_A = A_cnt.most_common()[0][-1]
#print(mode_A)
it = takewhile(lambda x: x[-1]== mode_A, A_cnt.most_common())
re_it = sorted(it, key = lambda x: x[0])
for k,v in re_it:
	print(k)

#print(A_cnt.most_common())

Measured memory_bytes: 48568
#include<iostream>
#include<string.h>

using namespace std;

int main()
{
    int n;
    char ch[1001];

    while(cin.getline(ch,1001,'\n')&&ch[0]!='0')
    {

        int len=strlen(ch);

        n=0;
        for(int i=0;i<len;i++)
        {
            n+=ch[i]-'0';
        }
        cout<<n<<endl;
    }


    return 0;
}



Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine()
            .Split(' ')
            .Select(txt => int.Parse(txt))
            .ToList();
        var lines = inputs[0];

        var hashSet = new HashSet<string>();
        for (int i = 0; i < lines; i++)
        {
            hashSet.Add(Console.ReadLine());
        }

        Console.WriteLine(hashSet.Count);
    }

}

Measured memory_bytes: 47636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

class strongly_connected_components{
public:
	vector<vector<int> > G, rG;
	vector<int> used, vs;
	vector<int> cmp; //cmp[v] := ??????v?????????????????£??????????????????????????????????????????
	strongly_connected_components(int n): G(n), rG(n), cmp(n), used(n){}
	void add_edge(int from, int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	int scc(){
		fill(used.begin(), used.end(), 0);
		vs.clear();
		for (int i = 0; i < G.size(); ++i){
			if(!used[i]) dfs(i);
		}
		fill(used.begin(), used.end(), 0);

		int k = 0;
		for (int i = vs.size() - 1; i >= 0; --i){
			if(!used[vs[i]]){
				rdfs(vs[i], k++);
			}
		}
		return k; //scc?????°
	}
private:
	void dfs(int curr){
		used[curr] = true;
		for(auto next : G[curr]){
			if(!used[next]) dfs(next);
		}
		vs.push_back(curr);
	}
	void rdfs(int curr, int k){
		used[curr] = true;
		cmp[curr] = k;//??????v???????????????k????????¨?????£???????????§???????????¨??\??????
		for(auto next : rG[curr]){
			if(!used[next]) rdfs(next, k);
		}
	}
};

int main(void){
	int v, e; cin >> v >> e;
	strongly_connected_components scc(v);
	rep(i, e){
		int s, t; cin >> s >> t;
		scc.add_edge(s, t); // s->t
	}
	scc.scc();
	int q; cin >> q;

	rep(i, q){
		int u, v; cin >> u >> v;
		if(scc.cmp[u] == scc.cmp[v]){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
 ll H,W,ans=0;
  cin>>H>>W;
  if(H%2==0) ans+=W*(H/2);
  else{
    ans+=W*((H-1)/2);
    ans+=W/2+W%2;
  }
  if(H==1||W==1){
    cout<<"1"<<endl;
    return 0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    vector<int> b(n-1);
    con_input(b);
    int ans=b[0];
    rep(i,n-2){
        ans+=min(b[i],b[i+1]);
    }
    ans+=b[b.size()-1];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){

	int a, b;
	char op;

	while (cin >> a >> op >> b) {
		if (op == '?')
			break;
		else if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else
			cout << a / b << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
	int a[30] = {0};
	int n;
	for (int i = 0; i < 28; i++) {
		cin >> n;
		a[n-1] = 1;
	}

	for (int i = 0; i < 30; i++) {
		if (a[i] == 0) {
			cout << i+1 << endl;
		}
	}
	return 0;
}

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

int main() {
    ll l, r;
    cin >> l >> r;

    if (r - l + 1 >= 2019) {
        cout << 0 << endl;
    } else {
        ll ans = 1e10;
        for (ll i = l; i <= min(r, l+2019+1); i++) {
            for (ll j = i + 1; j <= min(r, l+2019+1); j++) {
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
#include <unordered_map>
#include <cstring>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		cout << "x";
	}
}



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

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int Z=sc.nextInt();
		int W=sc.nextInt();
		int max=0;
		int[] cards=new int[N];
		for(int i=0; i<N; i++) {
			cards[i]=sc.nextInt();
		}
		max=Math.max(max, Math.abs(W-cards[N-1]));
		if(N>1) {
			max=Math.max(Math.abs(cards[N-1]-cards[N-2]), max);
		}
		pl(max);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

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

int main(){
	int N,K;
	cin >> N >> K;
	vector<ll> a(N);
	for(int i(0);i<N;++i) cin >> a[i];
	ll ans(-pow(10,10));
	for(int l(0);l<=K;++l){
		for(int r(0);r<=K-l;++r){
			if(l+r > N) continue;
			int d = K - l - r;
			ll now = 0;
			vector<ll> s;
			for(int i(0);i<l;++i){
				now += a[i];
				s.push_back(a[i]);
			}
			for(int i(N-r);i<N;++i){
				now += a[i];
				s.push_back(a[i]);
			}
			sort(s.begin(),s.end());
			for(int i(0);i<d;++i){
				if(i>=s.size()) break;
				if(s[i]>0) break;
				now -= s[i];
			}
			ans = max(ans,now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        mut m: i64,
        ab: [(i64, i64); n],
    }
    let mut btmap = BTreeMap::new();
    let mut ans = 0;
    for (a, b) in ab { *btmap.entry(a).or_insert(0) += b; }
    for (price, stock) in btmap {
        let to_buy = min(m, stock);
        m -= to_buy;
        ans += price * to_buy;
    }
    println!("{}", ans);
}


Measured memory_bytes: 7776