akhauriyash/Code-Regression huggingface dataset:
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define m_p make_pair
#define vpii vector<pii>
#define vvi vector<vi>
#define vs vector<string>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const ll inf=0x3f3f3f3f3f3f3f3f;
void print(vi v){
	ll n = v.size();
	for(ll i = 0; i < n; i++)
	    cout<<v[i]<<" ";
	cout<<endl;
}
ll power(ll a, ll b){
	ll res = 1;
	while(b != 0) {
		if(b & 1)
		  res *= a;
		a = a * a;
		b /= 2;
	}
	return res;
}
int main() {
    SPEED;
    ll n;
    cin>>n;
    double d;
    cin>>d;
    ll cnt = 0;
    for(ll i = 0; i < n; i++) {
    	double x, y;
    	cin>>x>>y;
    	cnt += (sqrt(x * x + y * y)) <= d;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3864
#include <stdio.h>

int N, K;
int C[10], D;
int a[] = {10000, 1000, 100, 10, 1};
int ans;

void func(int L, int num)
{
	int i;

	if (ans != 0) return;
	if (L >= 5)
	{
		if (num >= N) ans = num;
		return;
	}

	if (N / a[L] == 0) func(L + 1, 0);
	for (i = 0; i < 10; ++i)
	{
		if (C[i]) continue;
		func(L + 1, num * 10 + i);
	}
}

int main(void)
{
	int i;

	scanf("%d %d", &N, &K);
	for (i = 0; i < K; ++i)
	{
		scanf("%d", &D);
		C[D]++;
	}

	func(0, 0);
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b)cout<<c<<"\n";
  else if(b==c)cout<<a<<"\n";
  else cout<<b<<"\n";







  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n << endl;
	}
	else {
		cout << n * 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  ll d = 1;
  vector<int> c;
  while(k>=d){
    int cnt = 0;
    rep(i,n) if((a[i]&d)>0) ++cnt;
    c.push_back(cnt);
    d <<= 1;
  }
  ll x = 0;
  int s = c.size();
  rep(i,s){
    int ii = s-1-i;
    if(c[ii]*2>=n) continue;
    ll d = 1LL<<ii;
    if(x+d>k) continue;
    x += d;
  }

  ll ans = 0;
  rep(i,n) ans += a[i]^x;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);   
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    int a,b;
    cin>>n>>a>>b;
    int nowa=a;
    int nowb=b;
    while(1){
        if(nowa+1==nowb){
            cout<<"Borys"<<endl;
            return 0;
        }else{
            nowa++;
        }
        if(nowb-1==nowa){
            cout<<"Alice"<<endl;
            return 0;
        }else nowb--;
    }
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, x;
    cin >> n;
    set<int> a, b, suni, sint, sdif;
    rep(i, n) {
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    rep(i, m) {
        cin >> x;
        b.insert(x);
    }
    set_union(all(a), all(b), inserter(suni, end(suni)));
    set_intersection(all(a), all(b), inserter(sint, end(sint)));
    set_difference(all(suni), all(sint), inserter(sdif, end(sdif)));
    for(auto e : sdif) {
        cout << e << "\n";
    }
}


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

char check(int a,int b,int c){
  if(a==0&&b==0){
  if(c==0){
  return 't';
  }
  else{
  return 'f';
  }
  }
  else{
  return 'f';
  }
}

int main(){
  vector<int>x(9);
  for(int i=0;i<9;i++){
  cin>>x.at(i);
  }
  int N;
  cin>>N;
  for(int j=0;j<N;j++){
  int y;
  cin>>y;
  for(int k=0;k<9;k++){
  if(x.at(k)==y){
  x.at(k)=0;
  }
  }
  }
  vector<char>y(8);
  y.at(0)=check(x.at(0),x.at(1),x.at(2));
  y.at(1)=check(x.at(3),x.at(4),x.at(5));
  y.at(2)=check(x.at(6),x.at(7),x.at(8));
  y.at(3)=check(x.at(0),x.at(3),x.at(6));
  y.at(4)=check(x.at(1),x.at(4),x.at(7));
  y.at(5)=check(x.at(2),x.at(5),x.at(8));
  y.at(6)=check(x.at(0),x.at(4),x.at(8));
  y.at(7)=check(x.at(2),x.at(4),x.at(6));
  for(int l=0;l<8;l++){
  if('t'==y.at(l)){
  cout<<"Yes"<<endl;
  return 0;
  }
  }
  cout<<"No"<<endl;
  }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i,s,e)for(int i=s;i<=e;i++)
#define out(a)cout << a << endl;
using namespace std;

int main(){
    int a, b;
    string op;
    while(1){
        cin >> a >> op >> b;
        if(!op.compare("?")) break;
        if(!op.compare("+")) cout << a+b << endl;
        if(!op.compare("-")) cout << a-b << endl;
        if(!op.compare("*")) cout << a*b << endl;
        if(!op.compare("/")) cout << a/b << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
typedef string::const_iterator State;

void consume(State& begin,int c);
int digit(State& begin);
int formula(State& begin);
void consume(State& begin,int c){
  if(*begin != c){
    cout << "expected:"<< (char)c<< ":input:" << *begin << endl;
  }
  begin++;
}
int P,Q,R;
int digit(State& begin){
  int ret = *begin;
  begin++;
  return ret - '0';
}

int exp(State& begin){
  int ret = 0;
  consume(begin,'(');
  int f = formula(begin);
  char op = *begin;
  begin++;
  int n = formula(begin);
  consume(begin,')');

  if(op == '*'){
    ret = f*n;
    if(ret == 2)return 1;
    if(ret == 4)return 2;
    return ret; 
  }
  if(op == '+'){
    ret = f+n;
    //   cout << "in plus ret = "  <<  ret << endl;
    if(ret == 3 || ret == 4)return 2;
    if(f == 1 && n == 1)return 1;
    return ret;
  }
}

int formula(State& begin){
  char c = *begin;
  if(isdigit(c)){
    return digit(begin);
  }else if(c == '('){
    return exp(begin);
  }else if(c == '-'){
    begin++;
    return 2 - formula(begin);
  }else if(c == 'P'){
    begin++;
    return P;
  }else if(c == 'Q'){
    begin++;
    return Q;
  }else if(c == 'R'){
    begin++;
    return R;
  }
}


int main(){
  cin.sync_with_stdio(false);
  string str;
  while(true){
    int count = 0;
    getline(cin,str);
    if(str == ".")break;
    for(P = 0;P < 3;P++)
      for(Q = 0;Q < 3;Q++)
	for(R = 0;R < 3;R++){
	  State begin = str.begin();
	  if(formula(begin) == 2){
	    //cout << '(' << P << ','<<Q<<','<<R<<')' << endl;
	    count++;
	  }
	}
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <numeric>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
typedef long long  ll;
using namespace std;
using gragh = vector<vector<int>>;

int bit_count(int i){
    if (i==0) return 0;
    return bit_count(i>>1) + (i & 1);
}

int main() {
    int N;
    cin>>N;
    int ans = 0;

    vector<vector<vector<int>>>g(N,vector<vector<int>>(0,vector<int>(2)));

    for (int k = 0; k < N; ++k) {
        
        int An;
        cin>>An;
        for (int i = 0; i < An; ++i) {
            int a;
            int b;
            cin>>a>>b;
            a--;
            g[k].push_back({a,b});

        }
    }

    for (int bit = 0; bit < (1<<N)  ; ++bit) {
        bool ok = true;
        for (int i = 0 ; i < N ; i++) {
            if(bit & (1<<i)){
                for(auto xy :g[i]){
                    if(xy[1] == 1){
                        if(!(bit & (1<<xy[0]))){
                            ok = false;
                            break;
                        }
                    }else if(xy[1] == 0){
                        if(bit & (1<<xy[0])){
                            ok = false;
                            break;
                        }
                    }
                }
            }
        if (!(ok)) break;
        }
        if (ok) ans = max(ans,bit_count(bit));
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
int main()
{
    string s;
    int n;
    cin >> n >> s;

    string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    rep(i, s.length()){
        rep(j, 27){
            if(s[i] == a[j]){
                int tmp = (j+n) % 26;
                s[i] = a[tmp];
                break;
            }
        }
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 256
n,p = map(int,input().split())
a = list(map(int,input().split()))
check = True
for i in range(n):
    if a[i]%2 == 1:
        check = False
    
if check:
    if p == 1:
        print(0)
    else:
        print(2**n)
else:
    print(2**(n-1))

Measured memory_bytes: 3060
#include "iostream"
#include "algorithm"
#include "string"
#include "set"
#include "vector"
#include "queue"
#include "iomanip"
using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W >> K;
	vector<string>s(H);
	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i + K <= H) {
				bool flag = true;
				for (int k = i; k < i + K; k++) {
					if (s[k][j] == '#') {
						flag = false;
					}
				}
				ans += flag;
			}
			if (j + K <= W) {
				bool flag = true;
				for (int k = j; k < j + K; k++) {
					if (s[i][k] == '#') {
						flag = false;
					}
				}
				ans += flag;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3248
N, hp = gets.split.map(&:to_i)

katana = N.times.map { gets.split.map(&:to_i) }.sort_by { |a, b| -a }

used, *remain = katana

remain.sort_by! { |a, b| -b }

ans = 0

until remain.empty?
  k = remain.shift

  break if hp <= 0
  break if used[0] >= k[1]
  break if used[1] >= hp

  ans += 1
  hp -= k[1]
end

if hp > 0
  if used[0] < used[1]
    hp -= used[1]
    ans += 1
  end

  if hp > 0
    ans += (hp / used[0].to_f).ceil
  end
end

puts ans


Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;cin>>a>>b;
  long long x,y;
  if(a%4==0)x=a;
  if(a%4==1)x=1;
  if(a%4==2)x=a+1;
  if(a%4==3)x=0;
  if(b%4==0)y=b;
  if(b%4==1)y=1;
  if(b%4==2)y=b+1;
  if(b%4==3)y=0;
  long long u=x^y;
  u=u^a;
  cout<<u<<endl;
}


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

const int DEBUG = 0;

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;

const int N = 100100;
int n;
VI g[N];
int deg[N];
bool alive[N];

VI gdist(int v, const VI &vals) {
  VI ret(n, -1);
  queue<PI> que;
  que.push(PI(v, vals[v]));
  while (not que.empty()) {
    PI t = que.front(); que.pop();
    int w = t.first;
    int d = t.second;
    if (ret[w] >= 0) continue;
    ret[w] = d;
    REP(i, 0, g[w].size()) {
      int u = g[w][i];
      que.push(PI(u, d + vals[u]));
    }
  }
  return ret;
}

string c;

VI vert;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  REP(i, 0, n - 1) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  cin >> c;
  {
    queue<int> que;
    REP(i, 0, n) {
      alive[i] = true;
      deg[i] = g[i].size();
      if (g[i].size() == 1) que.push(i);
    }
    while (not que.empty()) {
      int v = que.front(); que.pop();
      if (c[v] == 'B') {
	// delete
	int nxt = -1;
	REP(i, 0, g[v].size()) {
	  if (alive[g[v][i]]) {
	    nxt = g[v][i];
	    break;
	  }
	}
	alive[v] = false;
	deg[nxt]--;
	if (deg[nxt] == 1) que.push(nxt);
      }
    }
    // deletes all unnecessary edges
    REP(i, 0, n) {
      VI cp;
      REP(j, 0, g[i].size()) {
	int w = g[i][j];
	if (not alive[w]) continue;
	cp.push_back(w);
      }
      g[i] = cp;
    }
    REP(i, 0, n) if (alive[i]) vert.push_back(i);
  }
  if (DEBUG) {
    REP(i, 0, n) {
      if (alive[i]) {
	REP(j, 0, g[i].size()) {
	  int w = g[i][j];
	  cerr << " (" << i << "," << w << ")";
	}
	cerr << endl;
      }
    }
  }
  VI vals(n);
  for (int i: vert) {
    vals[i] = (c[i] == 'W') ^ (deg[i] % 2);
  }
  int idx = -1;
  for (int i: vert) {
    if (alive[i] && c[i] == 'W') idx = i;
  }
  if (idx < 0) {
    cout << 0 << endl;
    return 0;
  }
  if (vert.size() <= 1) {
    cout << vert.size() << endl;
    return 0;
  }
  assert (idx >= 0);
  PI ma1(-1, -1);
  VI d1 = gdist(idx, vals);
  for (int i: vert) {
    if (c[i] == 'W') {
      ma1 = max(ma1, PI(d1[i], i));
    }
  }
  PI ma2(-1, -1);
  VI d2 = gdist(ma1.second, vals);
  for (int i: vert) {
    if (c[i] == 'W') {
      ma2 = max(ma2, PI(d2[i], i));
    }
  }
  if (DEBUG) {
    cerr << "vals:";
    REP(i, 0, n) cerr << " " << vals[i];
    cerr << endl;
    cerr << "d2:";
    REP(i, 0, n) cerr << " " << d2[i];
    cerr << endl;
  }
  int diam = ma2.first;
  int base = 2 * (vert.size() - 1);
  for (int i: vert) {
    base += vals[i];
  }
  DEBUGP(base);
  DEBUGP(diam);
  cout << base - 2 * diam << endl;
}


Measured memory_bytes: 9200
fn getline() -> String{
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let s = getline();
    let inp: Vec<_> = s.trim().split(' ').collect();
    let n: usize = inp[0].parse().unwrap();
    
    let s = getline();
    let inp: Vec<_> = s.trim().split(' ').collect();
    

    let mut bc = 0;
    let mut cnt = vec![false;8];
    for i in 0..n {
        let a: i32 = inp[i].parse().unwrap();
        let b: usize = a as usize/400;
        if b <= 7 {
            cnt[b] = true;
        }else{
            bc += 1;
        }
    }

    let mut sum = 0;
    for v in cnt {
        if v {
            sum += 1;
        }
    }

    if sum != 0 {
        println!("{} {}",sum,sum+bc);
    }else{
        println!("{} {}",std::cmp::min(bc,1),sum+bc);
    }
}


Measured memory_bytes: 4352
N = int(input())
S = input()
 
 
ans = S.count('R') * S.count('G') * S.count('B')
 
SN = []
 
for s in S:
    if s == 'R': SN.append(-1)
    elif s == 'G': SN.append(0)
    else: SN.append(1)
 
rem2 = ['RRR', 'GGG', 'BBB']
 
count = 0
for i in range(1, N-1):
    index = i
    left = i - 1
    right = i + 1
    f = True
    while f:
        if left == -1 or right == N:
            break
        if SN[left] == SN[index] and SN[index] == SN[right] == 0 : pass
        elif SN[left] + SN[index] + SN[right] == 0 :
            count+= 1
        
        left -= 1
        right += 1
 
print(ans-count)

Measured memory_bytes: 73856
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(){
   int a,b;
   cin >> a >> b;
   int sum = max(a+b,a-b);
   sum = max(sum,a*b);
   cout << sum << endl;
   return 0;
}

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

int main() {
    int n;
    string s;

    cin >> n >> s;

    int l=0, r=0;
    string ans="";
    rep(i, n) {
        if (s[i] == ')') r++;
        else l++;

        ans += s[i];

        if (r > l) {
            ans = "(" + ans;
            l++;
        }
    }

    for (int i=r; i<l; ++i) ans += ")";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=55;
long long dp[N][N*N];      //dp值會爆int
int main()
{
    int n,a;
    cin>>n>>a;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        for(int j=i-1;j>=0;j--)    //每一次個數向下減少
            for(int k=0;k<=N*j;k++)    //優化時間  由於k最大為N*j次
                dp[j+1][k+x]+=dp[j][k];       //個數加1 則找到前面個數的值相加
    }
    long long ans=0;       
    for(int i=1;i<=n;i++)
            ans+=dp[i][i*a];    //累計所有個數會出現平均值滿足a的情況
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
l = list(map(int, input().split(' ')))

#num = int(input())
#S = str(input())

r=l[0]
g=l[1]
b=l[2]
N=l[3]

Num=3000

sum = 0
for i in range(N//r+1):
    for j in range(N//g+1):
        _b=N-i*r-j*g
        if _b<0:
            break
        if _b%b==0:
            sum+=1
print(sum)

Measured memory_bytes: 3064
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IMAX 2147483647
#define LMAX 9223372036854775807
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define PII pair<int,int>
#define PIII pair<int,PII>
#define VPII vector<PII>
#define VPIII vector<PIII>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define fi first
#define se second
#define th se.se
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define rotateleft(vec,n) rotate(a.begin(),a.begin()+n,a.end())
#define rotateright(vec,n) rotate(a.rbegin(),a.rbegin()+n,a.rend())
#define eraseif(vec,condition_VAR) vec.erase(remove_if(all(vec),[&](auto VAR){return condition_VAR;}),vec.end())
#define countif(vec,condition_VAR) count_if(all(vec),[&](auto VAR){return condition_VAR;})
#define replaceif(vec,condition_VAR,n) replace_if(all(vec),[&](auto VAR){return condition_VAR;},n)
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_VAR) for_each(all(vec),[&](auto&VAR){VAR=calc_VAR;});
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}
template<class C>int binarysearch(vector<C> vec,C n,char c){int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;while(right-left>1){int mid=left+(right-left)/2;bool OK=vec[mid]*getmin>=n*getmin;if(outleft==OK) left=mid;else right=mid;}return outleft?left:right;}


// #define int int64_t
// #define double long double


// map,makepair


signed main(){
  IOS;

  in(int,a,b,t);
  int ans=(t/a)*b;
  out(ans);

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




/* nCr */
const long long table_size = 100005;
long long fact[table_size], finv[table_size], inv[table_size];

// 前処理
void make_table(long long mod) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < table_size; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// nCr
long long nCr(long long n, long long r, long long mod){
    if(n < r)return 0;
    return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}

int main() {
    ll n;
    cin >> n;
    
    ll l = 0, r = 0;
    vector<ll> b(n);
    REP(i, n + 1){
        ll a;
        cin >> a;
        a--;
        if(b[a]){
            r = i;
            l = b[a];
        }
        else{
            b[a] = i + 1;
        }
    }
    
    make_table(MOD);
    
    REP(i, n + 1){
        cout << (nCr(n + 1, i + 1, MOD) - nCr(n - r + l - 1, i, MOD) + MOD) % MOD<< endl;
    }
}

Measured memory_bytes: 4352
N = int(input())
A_ls = map(int, input().split(' '))
B_ls = list(map(int, input().split(' ')))
C_ls = list(map(int, input().split(' ')))

result = 0
tmp = 0
for A in A_ls:
    if (A - tmp) == 1 and tmp != 0:
        result += B_ls[A-1] + C_ls[A-2]
    else:
        result += B_ls[A-1]
    tmp = A
print(result)

Measured memory_bytes: 9136
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int X, Y, Z;

int main(int argc, char const *argv[])
{
    cin >> X >> Y >> Z;
    int ans=0;
    for (int i = 0; i < 100000; i++)
    {
        if (i * Y + (i + 1) * Z > X)
        {
            ans=i-1;
            i=100000;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

    private void foodsLovedByEveryone() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = Integer.parseInt(scan.next());
            int m = Integer.parseInt(scan.next());
            List<List<Integer>> lovedFoods = IntStream.range(0, n).boxed().map(
                    i -> {
                        int j = Integer.parseInt(scan.next());
                        return IntStream.range(0, j).map(l -> Integer.parseInt(scan.next())).boxed().collect(Collectors.toList());
                    })
                    .collect(Collectors.toList());

            System.out.println(
                    IntStream.rangeClosed(1, m)
                            .mapToObj(i -> lovedFoods.stream().filter(j -> j.contains(i)).count()).filter(i -> i >= n).count());
        }
    }

    private void bPlusMinusA() {
        try (Scanner scan = new Scanner(System.in)) {
            int a = Integer.parseInt(scan.next());
            int b = Integer.parseInt(scan.next());
            if (b % a == 0) {
                System.out.println(a + b);
            } else {
                System.out.println(b - a);
            }
        }
    }
}


Measured memory_bytes: 29528
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
    int a,b;
	cin>>a>>b;
    if(a>9 || b>9){
        cout<<"-1"<<endl;
        return 0;
    }       
    cout<<a*b; 
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(H: "List[int]", M: "List[int]", K: int):
    s = H[0] * 60 + M[0]
    t = H[1] * 60 + M[1]
    ret = t - s - K
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = [int()] * (2)  # type: "List[int]"
    M = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        H[i] = int(next(tokens))
        M[i] = int(next(tokens))
    K = int(next(tokens))  # type: int
    solve(H, M, K)

if __name__ == '__main__':
    main()


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

#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define ll long long
const ll INF = 2LL<<60;

int main()
{
    int X, A;
    cin >> X >> A;

    if(X < A)   cout << 0 << endl;
    if(X >= A)  cout << 10 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int i=s.size();
  while(true){
    if(i==0){
      cout<<"YES";
      return 0;
    }
    if(i>=7){
      if(s.substr(i-7,7)=="dreamer")
        i-=7;
      else if(s.substr(i-6,6)=="eraser")
        i-=6;
      else if(s.substr(i-5,5)=="dream"||s.substr(i-5,5)=="erase")
        i-=5;
      else{
        cout<<"NO";
        return 0;
      }
    }else if(i>=6){
      if(s.substr(i-6,6)=="eraser")
        i-=6;
      else if(s.substr(i-5,5)=="dream"||s.substr(i-5,5)=="erase")
        i-=5;
      else{
        cout<<"NO";
        return 0;
      }
    }else if(i>=5){
      if(s.substr(i-5,5)=="dream"||s.substr(i-5,5)=="erase")
        i-=5;
      else{
        cout<<"NO";
        return 0;
      }
    }else{
      cout<<"NO";
      return 0;
    }
  }
}

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

int main(){
  int N;
  cin >> N;
  int c = N%10;
  int b = (N-b)%100/10;
  int a = (N-b*10-c)/100;
  if(c ==7)
    cout << "Yes";
  else if(b==7)
    cout << "Yes";
  else if(a == 7)
    cout << "Yes";
  else
    cout << "No";
}


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

int main()
{
	string ary;

	while (cin >> ary)
	{
		for (int i = 9; i > 0; i--)
		{
			for (int j = 0; j < i; j++)
			{
				ary[j] = ((ary[j] - '0' + ary[j + 1] - '0') % 10) + '0';
			}
		}

		cout << ary[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 1172
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  printf("%d\n", 6/a/b);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



int main(){
    IOS
ll n;
    cin >> n;
    cout << 3  * n * n;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
  const int MAX_P = 50000;
  bool p[MAX_P];
  for (int i = 0; i < MAX_P; ++i)
    p[i] = true;
  p[0] = p[1] = false;

  for (int i = 2; i*i <= MAX_P; ++i) {
    if (p[i]) {
      for (int j = i+i; j < MAX_P; j += i)
	p[j] = false;
    }
  }

  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;
    
    int ans = 0;
    for (int i = 0; 2*i <= n; ++i) {
      if (p[i] && p[n-i])
	++ans;
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

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

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << "[" << e << "] ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<long double> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	long double mul = 1, sum = 0;
	for (int i = 0; i < N; i++) mul *= A[i];
	for (int i = 0; i < N; i++) sum += mul / A[i];

	cout << setprecision(40);
	cout << 1.0 * mul / sum << "\n";


	return 0;
}


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

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	vector<vector<int>>grid(h, vector<int>(w,0));
	for (int i = 0; i < b; i++) {
		for (int j = a; j < w; j++)grid.at(i).at(j) = 1;
	}
	for (int i = b; i < h; i++) {
		for (int j = 0; j < a; j++)grid.at(i).at(j) = 1;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) cout << grid.at(i).at(j);
		cout << endl;
	}
}

Measured memory_bytes: 5120
//Serval vs Monster
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main ()
{
    int H, A;
    cin >> H >> A;
    int count = 0;
    while (H>0) {
        H -= A;
        count++;
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.length() == b.length()) {
            if (a.compareTo(b) < 0) {
                System.out.println("LESS");
            } else if (a.compareTo(b) == 0){
                System.out.println("EQUAL");
            } else {
                System.out.println("GREATER");
            }
        } else {
            System.out.println(a.length() > b.length() ? "GREATER" : "LESS");
        }
    }

}


Measured memory_bytes: 23380
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int from,to,cost;};
vector<edge> G;
vector<int> O[10];
P sg[10];
int d[1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int fi[1005][1005];
int ans[1005][1005]={};
bool graph[55][55];
bool visited[55];
int a[55],b[55];
int n,m;
int dp[41][405][405];
signed main(){
    int n;cin>>n;
    int c[505],s[505],f[505];
    for(int i=1;i<n;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    int time=0;
    for(int j=1;j<n;j++){
       for(int i=j;i<n;i++){
        while(time<s[i]||time%f[i]!=0){
            time++;
        }
        time+=c[i];
     }
        cout<<time<<endl;
        time=0;
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n);
    bool check = true;
    loop(i, n)
    {
        cin >> a[i];
        if (a[i] % 2 == 1)
            check = false;
    }
    if (check)
        putout("second");
    else
        putout("first");
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	vector<int> a;
	inputVector(a, n);

	int even = 0;
	int odd = 0;

	rep(i, n) {
		if (a[i] % 2) odd++;
		else even++;
	}

	while (odd > 1) {
		odd -= 2;
		even++;
	}

	even = (even > 0);

	if (even + odd == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

    return 0;
}


Measured memory_bytes: 1024
n=input()
nn=len(n)
if int(n[nn-1])==3:
    print("bon")
elif int(n[nn-1])==0 or int(n[nn-1])==1 or int(n[nn-1])==6 or int(n[nn-1])==8:
    print("pon")
else:
    print("hon")

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

template<typename T>
class segtree{
	int n;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, int a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return (a + b) % MOD;
	}
	
	T get(int k){return dat[k+n-1];}
	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(R,dat[--B]);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};


int main(){
	
	ll n,k;cin >> n >> k;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	
	segtree<ll> A(k+1,0);
	segtree<ll> B(k+1,0);
	A.update(0,1);
	
	REP(i,n){
		REP(j,k+1){
			int l = max(0LL, j-v[i]);
			int r = j + 1;
			if(i%2){
				A.update(j,B.que(l,r));
			}
			else {
				B.update(j,A.que(l,r));
			}
		}
	}
	
	if(n%2 == 0)cout << A.que(k,k+1) << endl;
	else cout << B.que(k,k+1) << endl;
	
	return 0;
}


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

int bit[200000];
vector<int>v;
void add(int k, int x) {
	while (k <= v.size()) {
		bit[k] += x;
		k += k&-k;
	}
}
int sum(int k) {
	int res = 0;
	while (k) {
		res += bit[k];
		k -= k&-k;
	}
	return res;
}
int a[100000], b[100000], c[100000], d[100000];
struct st {
	int y, t, id;
};
int main() {
	int n; scanf("%d", &n);
	vector<st>xs;
	rep(i, n) {
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
		if (a[i] > c[i])swap(a[i], c[i]);
		if (b[i] > d[i])swap(b[i], d[i]);
		v.push_back(a[i]); v.push_back(c[i]);
		if (a[i] == c[i]) {
			xs.push_back({ b[i],0,i });
			xs.push_back({ d[i],2,i });
		}
		else xs.push_back({ b[i],1,i });
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	sort(xs.begin(), xs.end(), [](st&a, st&b) {
		if (a.y == b.y)return a.t < b.t;
		return a.y < b.y;
	});
	rep(i, n) {
		a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
		c[i] = lower_bound(v.begin(), v.end(), c[i]) - v.begin() + 1;
	}
	int ans = 0;
	for (st&p : xs) {
		if (p.t == 0)add(a[p.id], 1);
		else if (p.t == 1) {
			ans += sum(c[p.id]);
			if (a[p.id])ans -= sum(a[p.id] - 1);
		}
		else add(a[p.id], -1);
	}
	printf("%d\n", ans);
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<int> d;
  int _x, x;
  rep(i, N) {
    _x = x;
    cin >> x;
    if (i != 0) d.eb(x - _x);
  }
  ll ans = 0;
  rep(i, sz(d)) { ans += min(A * d[i], B); }

  cout << ans << endl;
}


Measured memory_bytes: 892
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
            string[] input = Console.ReadLine().Split();
            long a = long.Parse(input[0]);
            decimal b = decimal.Parse(input[1]);
            var result = Math.Floor(a * b);
            Console.WriteLine(result);
    }
}

Measured memory_bytes: 27632
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

long long f(long long N){
	if(N <= 0)return 0;
	N++;

    int i = 0;
    long long n = 2;
    long long ret = 0;

    while(n < N * 2){
        long long c = (N / n) * (n / 2) + max(0LL,(N % n) - (n / 2));
        if(c % 2)ret |= 1LL << i;
        n *= 2;
        i++;
    }

    return ret;
}

int main(){
    long long A,B;

	cin >> A >> B;
	cout << (f(A - 1) ^ f(B)) << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
namespace ABC148B
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] st = Console.ReadLine().Split();
            char[] s = st[0].ToCharArray();
            char[] t = st[1].ToCharArray();

            string res = string.Empty;
            for (int i = 0; i < n; i++)
            {
                res += s[i].ToString() + t[i].ToString();
            }
            Console.WriteLine(res);

        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        List<Long> list = new ArrayList<Long>();
        Scanner scan = new Scanner(System.in);
        long n = (long)scan.nextLong();
 
        for(int i = 0 ; i < 5; i++) {
            list.add(scan.nextLong());
        }
        long p = 0;
        long min = Collections.min(list);
        if (min > 1) {
            if(n % min == 0){
                p = n / min;
            } else {
                p = n / min + 1;
            }
        } else {
            p = n;
        }
        System.out.println(4 + p);
    }
}

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

long long n, a, b;

int main() {
  cin >> n >> a >> b;

  long long ans, div, res;
  div = n / (a + b);
  res = n % (a + b);

  if (res >= a) {
    res = a;
  }

  ans = div * a + res;
  printf("%llu", ans);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	if(n==2){
		int v[2];
		cin>>v[0]>>v[1];
		if(v[0]==v[1]) cout<<1<<endl;
		else cout<<0<<endl;
		return 0;
	}
	int c0[100001]={}, c1[100001]={};
	for(int i=0; i<n; i++){
		int v;
		cin>>v;
		if(i%2==0) c0[v]++;
		else c1[v]++;
	}
	vector<P> v1;
	for(int i=1; i<=100000; i++){
		v1.push_back(P(c1[i], i));
	}
	sort(v1.begin(), v1.end(), greater<P>());
	int ans=n;
	for(int i=1; i<=100000; i++){
		int ans1=n/2-c0[i];
		if(v1[0]==P(c1[i], i)){
			ans1+=(n/2-v1[1].first);
		}else{
			ans1+=(n/2-v1[0].first);
		}
		ans=min(ans, ans1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2168
i = 1
while i<=1000000:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    print(W*'#')
    for j in range(1,H-1):
        print('#',end='')
        for k in range(1,W-1):
            print('.',end='')
        print('#')
        
    print(W*'#')
    print()


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

typedef long long ll;
const int MOD = 2019;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    vector<int> cnt(2020);
    cnt[0] = 1; // remainder 0 already exists once
    ll ans = 0;
    // subtract suffixes
    ll num = 0;
    ll pot = 1;
    for (int i = s.length() - 1; i >= 0; --i) {
        ll cur = s[i] - '0';
        num += (cur * pot) % MOD;
        ans += cnt[num % MOD];
        cnt[num % MOD]++;
        pot *= 10 % MOD;
      pot %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
int main(void){
    char a,c;
    int n,b,i,j,k;
    int cards[4][13];
    for(i=0;i<4;i++){
        for(j=0;j<13;j++) cards[i][j]=0;
    }
     
    scanf("%d",&n);
    for(k=1;k<=n;k++){
        scanf("%c",&c);
        scanf("%c %d",&a,&b);
        if(a=='S') i=0;
        if(a=='H') i=1;
        if(a=='C') i=2;
        if(a=='D') i=3;
         
        cards[i][b-1]=1;
    }
     
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(cards[i][j]==0){
               if(i==0) printf("S %d\n",j+1);
               if(i==1) printf("H %d\n",j+1);
               if(i==2) printf("C %d\n",j+1);
               if(i==3) printf("D %d\n",j+1);
                
            }
        }
    }
    return 0;
}




Measured memory_bytes: 2056
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	//int n; cin >> n;
	string s; cin >> s;
	if(s[0]==s[s.size()-1]) ans = s.size() - 3;
	else ans = s.size();
	if (ans%2==0) cout << "Second" << endl;
	else cout << "First" << endl;
	
}

Measured memory_bytes: 3732