akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


map<LL,int> prime_factor(LL n){
  map<LL,int> ret;
  for(LL i = 2; i * i <= n; i++){
    while(n % i == 0){
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


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

    // N!までに含まれている素因数の数をカウント
    map<LL,int> lis;
    for(LL i = 2;i <= N;++i){
        map<LL,int> tmp = prime_factor(i);
        for(auto a : tmp){
            if(lis[a.F] > 74)continue;
            lis[a.F] += a.S;
        }
    }

    // 指数が74以下の素因数の数をチェック
    vector<LL> pri(75,0);
    for(auto a : lis){
        int k = a.S;
        if(k >= 2)pri[2]++;
        if(k >= 4)pri[4]++;
        if(k >= 14)pri[14]++;
        if(k >= 24)pri[24]++;
        if(k >= 74)pri[74]++;
    }

    // 75 は 3*5*5 3*25 75 15*5 の4通りで表せる
    LL ans = 0;
    if(pri[2] > 2 && pri[4] > 1)ans += (pri[2] -2) * pri[4] * (pri[4] -1) / 2;
    if(pri[2] > 1 && pri[24] > 0)ans += (pri[2] -1) * pri[24];
    if(pri[74] > 0)ans += pri[74];
    if(pri[4] > 1 && pri[14] > 0)ans += (pri[4] -1) * pri[14];

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] temp = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
            temp[i] = a[i];
        }
        Arrays.sort(temp);
        int max = temp[temp.length - 1];
        for(int i = 0;i < n;i++){
            if (max == a[i]) {
                System.out.println(temp[temp.length - 2]);
                continue;
            }
            System.out.println(max);
        }
    }
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] canComeFrom1 = new boolean[N+1];
        boolean[] canGoToN = new boolean[N+1];
        for(int i=0;i<=N;i++){
        	canComeFrom1[i] = false;
        	canGoToN[i] = false;
        }
        for(int i=0;i<M;i++){
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	if(a==1) canComeFrom1[b]=true;
        	if(b==N) canGoToN[a]=true;
        }
        boolean ans = false;
        for(int i=1;i<=N;i++) if(canComeFrom1[i]&&canGoToN[i]) ans=true;
        
        if(ans)System.out.println("POSSIBLE");
        else System.out.println("IMPOSSIBLE");
    }
}

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

int main(void)
{	ll n,W;	
	ll i,j;
	cin>>n>>W;
	
	ll w[n],P[n];
	ll dp[n+1][W+1];
	
	for(i=0;i<n;i++)
	{
	cin>>w[i]>>P[i];
	}
	
	
	for(i=0;i<=n;i++)
	for(j=0;j<=W;j++)
	{
		dp[i][j]=0;
	}
	
	for(i=1;i<=n;i++)
	for(j=1;j<=W;j++)
	{
		
		if(w[i-1]<=j)
		{
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+P[i-1]);
		}
		else dp[i][j]=dp[i-1][j];
		
	}
	ll ans=0;
	for(i=1;i<=n;i++)
	{
	for(j=1;j<=W;j++)
	{	
		ans=max(ans,dp[i][j]);
	}
	
	}
		cout<<ans;
}

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

n = int(input())
s = list(input())
t = list(input())

for i in range(n):
    match = True
    for j in range(n):
        if i + j < n:
            if s[i + j] != t[j]:
                match = False
    if match:
        if i == 0:
            print(n)
        else:
            print(n + i)
        break
else:
    print(n * 2)


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

int main()
{
    int len,idx=0,i;
    cin>>len;
    string s,t;
    char result[2*len+1];
    cin>>s>>t;
    for(i=0;i<len;i++)
    {
        result[idx++]=s[i];
        result[idx++]=t[i];
    }
    for(i=0;i<2*len;i++)
        cout<<result[i];
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (1 << 30 - 2)
using namespace std;
int dis[201][201];
char A[200][200];

vector<vector<int>> graph(201);
int visited[201];
bool dfs(int st){
	fill(visited, visited + 201, -1);
	vector<pair<int, bool>> stack = {{st, 0}};
	while(stack.size()){
		pair<int, bool> x = stack.back();
		stack.pop_back();
		if(visited[x.first] != -1){
			if(visited[x.first] != x.second) return 1;
			continue;
		}
		visited[x.first] = x.second;
		for(auto i : graph[x.first]){
			stack.push_back({i, x.second ^ 1});
		}
	}
	return 0;
}
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(A[i][j] == '1')
				graph[i+1].push_back(j+1);
		}
	}
	if(dfs(1)){
		cout << -1;
		exit(0);
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i == j){
				dis[i][j] = 0;
			}else if(A[i-1][j-1] == '1'){
				dis[i][j] = 1;
			}else{
				dis[i][j] = inf;
			}
		}
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	
	int _max = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i != j){
				_max = max(_max, dis[i][j]);
			}
		}
	}
	cout << _max + 1 << endl;
}

Measured memory_bytes: 688
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

const ll V = 100005;

vvll to(2 * V);
vector<bool> seen(2 * V);
ll cnt[2];
void dfs(ll u) {
  if (seen[u]) return;
  seen[u] = true;
  cnt[u / V]++;
  for (ll v : to[u]) {
    dfs(v);
  }
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    y += V;
    to[x].push_back(y);
    to[y].push_back(x);
  }

  ll ans = 0;
  rep(i, 2 * V) {
    cnt[0] = cnt[1] = 0;
    dfs(i);
    ans += cnt[0] * cnt[1];
  }
  ans -= n;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9984
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b;
map<ll,ll> mpa;

//これACだったらちょっとひどいよ、まあ多分違うだろうが

int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        mpa[a]+=b;
    }
    for(auto it=mpa.begin();it!=mpa.end();++it){
        m-=it->second;
        if(m<=0){
            C it->first E;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  vector<int> S;
  map<int,int> temp;

  int a, L, min, max;
  while (1){
    bool FLAG = false;
    cin >> a >> L;
    if (!a && !L) break;
    if (a == 0){
      cout << a << " " << a << " " << a + 1 << endl;
      continue;
    }
    temp.insert(make_pair(a,0));
    for (int i = 0; i < 100; ++i){

      for (int l = 0; l < L; ++l){
        S.push_back(a % 10);
        a = a / 10;
      }
      sort(S.begin(), S.end());
      int digit = 1;
      min = 0;
      max = 0;
      for (int j = 0; j < L; ++j){
        max += S[j] * digit;
        min += S[L - j - 1] * digit;
        digit *= 10;
      }
      //cout << max << " " << min << endl;
      auto itr=temp.find(max-min);
      if (itr!=temp.end()){
        cout << itr->second << " " << max - min << " " << i - itr->second + 1 << endl;
        FLAG = true;
        break;
      }
      if (FLAG)break;
      a = max - min;
      temp.insert(make_pair(a,i+1));
      //cout << "a" << a << endl;
      S.clear();
    }
    S.clear();
    temp.clear();
  }

  return 0;
}

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007


int n, x, y;
set<pii> se;
vector<pii> vi;
vector<pii> rvi;
map<pii, int> ma;
vector<pll> g[1<<20];
vector<bool> visited(1<<20, false);
vector<ll> dist(1<<20, LONG_LONG_MAX);

bool comparator(const pii& u, const pii& v) {
    if(u.second < v.second) return true;
    if(u.second == v.second) u.first < v.first;
    return false;
}

int weight1(int i) {
    int x = vi[i].first-vi[i+1].first;
    int y = vi[i].second-vi[i+1].second;
    return min(abs(x), abs(y));
}

int weight2(int i) {
    int x = rvi[i].first-rvi[i+1].first;
    int y = rvi[i].second-rvi[i+1].second;
    return min(abs(x), abs(y));
}

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>n;
  rep(i, n) {
      cin>>x>>y;
      se.insert({x, y});
  }

  for(auto it = se.begin();it != se.end();it++) {
      vi.pb(*it);
      rvi.pb(*it);
  }

  sort(rvi.begin(), rvi.end(), comparator);
  rep(i, vi.size()) ma[vi[i]] = i+1;

  rep(i, vi.size()-1) {
      g[i+1].pb({weight1(i), i+2});
      g[i+2].pb({weight1(i), i+1});

      int x = ma[rvi[i]];
      int y = ma[rvi[i+1]];
      g[x].pb({weight2(i), y});
      g[y].pb({weight2(i), x});
  }

  set<pll> pq;
  pq.insert({0, 1});
  ll answer = 0;


  while(not pq.empty()) {
      pii temp = *(pq.begin());
      pq.erase(pq.begin());
      if(visited[temp.second]) continue;
      visited[temp.second]=1;
      dist[temp.second]=temp.first;
      answer = answer + (long long)(temp.first);
      for(auto&z:g[temp.second]) {
          if(not visited[z.second] and z.first < dist[z.second]) {
              pq.erase({dist[z.second], z.second});
              dist[z.second]=z.first;
              pq.insert({z.first, z.second});
          }
      }
  }

  cout<<answer<<endl;

  return 0;
}


Measured memory_bytes: 56556
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,X,Y;
	while(cin>>N>>X>>Y) {
		X--;Y--;
		/*
		k: デフォでN-k
		Y-X <= k の場合
		*/
		VI w(N);
		RANGE(k, 1, N) {
			w[k] = N-k;
		}
//		DD(w);
		REP(i, N) RANGE(j, i+1, N) {
			ll orig = j-i;
			ll n = abs(i-X)+1+abs(Y-j);
			if(n<orig) {
				w[orig]--;
				w[n]++;
			}
		}
//		DD(w);
		RANGE(k, 1, N) {
			cout<<w[k]<<endl;
		}
//		break;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
using ll=long long;

int main(){
    int n[3]={1,2,3};
    int a,b;
    cin>>a;
    cin>>b;
    for(int i=0;i<3;i++){
        if(i!=a-1&&i!=b-1)cout<<n[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    ll sum=0;
    fr(i,1,n+1){
        if(!(i%3==0||i%5==0))
        sum+=(ll)i;
    }
    cout<<sum;
}


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

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

    int* P = new int[N];
    int* Q = new int[N];
    for(int i=0; i<N; i++)
    {
        cin >> P[i];
        Q[P[i]-1] = i;
    }

    int max_order = 1;
    int order = 1;
    for(int i=1; i<N; i++)
    {
        if(Q[i-1] < Q[i]) {
            order++;
            if (max_order < order) max_order = order;
        } else {
            order = 1;
        }
        
    }


    cout << N - max_order;
}

Measured memory_bytes: 4716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1000000007;
void files(){
 freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);

}
void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

}
int main(){
 fast();
 ll n;
 cin>>n;
 ll ans=1,ans1=1,ans2=1;
 for(ll i=0; i<n; i++){
    ans=(ans*10)%mod;
    ans1=(ans1*9)%mod;
    ans2=(ans2*8)%mod;
 }
 cout<<(ans+ans2-2*ans1+2*mod)%mod;
}

Measured memory_bytes: 3680
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

vector<int> A;
int n;

int ansify(int el, ll lim) {
    ll v = A[el];
    if(!v) return (lim >= 0)?(A.size()-1):0;
    int l = 0, r = n-1, ans = (v < 0)?n:(-1);
    while(l <= r) {
        int mid = (l+r)/2;
        if(v*A[mid] <= lim) {
            ans = mid;
            if(v < 0) r = mid-1;
            else l = mid+1;
        } else {
            if(v < 0) l = mid+1;
            else r = mid-1;
        }
    }
    if(v < 0) {
        int cnt = 0; if(ans <= el) cnt = -1;
        cnt += (n-ans); return cnt;
    } else {
        int cnt = 0; if(el <= ans) cnt = -1;
        cnt += (ans+1); return cnt;
    }
}

ll ttt(ll lim) {
    ll ans = 0;
    rep(i, n) ans += ansify(i, lim);
    return ans/2;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    ll K; cin >> K;
    rep(i, n) {
        int t; cin >> t;
        A.pb(t);
    }
    sort(all(A));
    ll l = -1000000000000000009ll, r = -l, ans = r;
    while(l <= r) {
        ll mid = (l+r)/2;
        if(K <= ttt(mid)) {
            ans = mid;
            r = mid-1;
        } else l = mid+1;
    }
    cout << ans << endl;
}



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

int main() {
    double n, k;
    cin >> n >> k;
    double ans = 0;
    for(ll i = 1; i <= n; i++){
        ll count = 0;
        ll m = i;
        while(m < k){
            m *= 2;
            count++;
        }
        ans += (1 / n) * pow(0.5, count);
    }

    printf("%.10f\n", ans);



}


Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
using namespace::std;


long long n, bc, now, C, H, W, X, Y, ans, r, l, numcon, N, M;
string S,s;

int main() {
	cin >> N>>n;
	cout << N-n+1 << endl;
	return 0;

}




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

int main(){
    int x, y, a, b, c;
    cin >> a >> b >> c >> x >> y;
    //Max AB+@ or nA+mB
    int p,q,r;
    if(x>y){
        p = 2*c * y + a*(x - y);
    }else{
        p = 2*c * x + b * (y - x);
    }
    r = 2 * c * max(x, y);
    q = a * x + b * y;
    cout << min(min(p,q),r) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

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 998244353

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

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

	ll n;cin >> n;
	set<string> s;
	REP(i, n){
		string str;cin >> str;
		s.insert(str);
	}

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 15736
import java.util.*
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)
    // スペース区切りの整数の入力
    val N=sc.nextInt()
    val K=sc.nextInt()
    val X=sc.nextInt()
    val Y=sc.nextInt()

    println(when(N>=K)
    {
      true -> X*K+Y*(N-K)
      else -> X*N
    }
    )

  }
}


Measured memory_bytes: 16944
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 200005

using namespace std;

int main()
{
    ll n,crr[sz],arr[sz],brr[sz];

    scanf("%lld",&n);

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&crr[i]);
    }

    ll m=n,j=0,k=0;

    for(ll i=1; i<=n; i++)
    {
        if(i%2!=0)
        {
            arr[j++]=crr[m];
        }

        else
        {
            brr[k++]=crr[m];
        }

        m--;
    }

    for(ll i=0; i<j; i++)
    {
        printf("%lld ",arr[i]);
    }

    for(ll i=k-1; i>=0; i--)
    {
        printf("%lld ",brr[i]);
    }

    printf("\n");

    return (0);
}




Measured memory_bytes: 6784
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < m; ++i) {
                ++a[in.nextInt() - 1];
                ++a[in.nextInt() - 1];
            }
            for (int x : a)
                if (x % 2 != 0) {
                    out.println("NO");
                    return;
                }
            out.println("YES");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 42732
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int dp[3010][3010];

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

    string s, t;
    cin >> s >> t;
    rep(i, s.size()) rep(j, t.size())
    {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        if (s[i] == t[j])
            dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1]);
    }
    int n = s.size(), m = t.size(), u = dp[n][m];
    string ans = "";
    while (u)
    {
        if (dp[n - 1][m - 1] == dp[n][m] - 1 && s[n - 1] == t[m - 1])
        {
            ans.push_back(s[n - 1]);
            n--, m--, u--;
        }
        else if (dp[n - 1][m] == dp[n][m])
            n--;
        else
            m--;
    }
    reverse(all(ans));
    cout << ans << endl;
}

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

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

    char b;
    cin >> b;
    if (b == 'A') {
        cout << 'T';
    } else if (b == 'T') {
        cout << 'A';
    } else if (b == 'C') {
        cout << 'G';
    } else if (b == 'G') {
        cout << 'C';
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    
    //愚直
    /*
    for (int i=0; i<k; i++){
        if ( abs(x+d) < abs(x-d))x += d;
        else x -= d; 
    }
    */

    ll to_zer = abs(x)/d;
    if (k < to_zer){
        cout << min(abs(x-k*d), abs(x+k*d)) << endl;;
        return 0;
    }

    if (x > 0){
        x -= to_zer*d;
        k -= to_zer;
        //たぶんこの時点でx > 0

        if (x > abs(x-d) and k > 0){
            x -= d;
            k--;
        }
    } else {
        x += to_zer*d;
        k -= to_zer;
        //この時点ではx < 0
        if (abs(x) > abs(x+d) and k > 0){
            x += d;
            k++;
        }
    }

    if (k%2 == 0){
        cout << abs(x) << endl;
    }
    else {
        cout << min(abs(x+d), abs(x-d)) << endl;
    }
    
}

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

int main(){
    int x;
    cin >> x;
    int a, b, c, ans;
    a = x/500;
    c = x%500;
    b = c/5;
    ans = 1000*a + 5*b;
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int mo=998244353;
const int N=2e6;
int n,m,inv[N+10],fac[N+10];
int Sum(int x,int y) {
    x+=y;
    return (x>=mo)?x-mo:x;
}
int Sub(int x,int y) {
    x-=y;
    return (x<0)?x+mo:x;
}
int Mul(int x,int y) {
    return (long long)x*y%mo;
}
int Pow(int x,int y=mo-2) {
    int z=1;
    while (y) {
        if (y&1) z=Mul(z,x);
        y>>=1;
        x=Mul(x,x);
    }
    return z;
}
void Prework() {
    fac[0]=1;
    for (int i=1;i<=N;i++) fac[i]=Mul(fac[i-1],i);
    inv[N]=Pow(fac[N]);
    for (int i=N-1;i>=0;i--)
        inv[i]=Mul(inv[i+1],i+1);
}
int C(int x,int y) {
    if (y>x||y<0) return 0;
    return Mul(fac[x],Mul(inv[y],inv[x-y]));
}
void Solve() {
    if (n<m) swap(n,m);
    int ans=n;
    int invc=Pow(C(n+m,n));
    for (int i=0;i<m;i++)
        ans=Sum(ans,Mul((mo+1)/2,Mul(Mul(C(i*2+n-m,i),C(2*(m-i),m-i)),invc)));
    printf("%d\n",ans);
}
int main() {
    Prework();
    scanf("%d%d",&n,&m);
    Solve();
    return 0;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

  int cnt[200001] = {0};

  for (int i = 0; i < n-1; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << cnt[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,t;
    cin >> n >> t;
    vector<ll>time(n);
    for(ll i=0;i<n;i++){
        cin >> time[i];
    }
    ll ans=0;
    for(ll i=1;i<n;i++){
        if(time[i]-time[i-1]>t){
            ans+=t;
        }
        else {
            ans+=time[i]-time[i-1];
        }
    }
    ans+=t;
    cout << ans << endl;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, n) cin >> a[i+1];
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 1 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll n,k; cin >> n >> k;
  if(n * 2 < k) {
    cout << 0 << "\n";
    return 0;
  }
  if(k % 2 == 0) {
    ll x = (n - k/2) / k + 1;
    ll y = n / k;
    cout << x*x*x + y*y*y << "\n";
  }
  else {
    ll y = n / k;
    cout << y*y*y << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
int main()
{
	
	int a,b,c;
	cin >> a >> b >> c;
	if (b - a == c - b) { cout << "YES" << endl;}
	else { cout << "NO" << endl; }
	
	return 0;
}


Measured memory_bytes: 256
import heapq

T = int(input())

for i in range(T):
    N,A,B,C,D=map(int,input().split())
    Q=[]
    Q.append((0,N))
    Dict={}
    heapq.heapify(Q)
    while 1 not in Dict:
        q0,q1=heapq.heappop(Q)
        if q1 not in Dict:
            Dict[q1]=q0
            if q1%2==0:
                heapq.heappush(Q,(q0+min(A,D*(q1//2)),q1//2))
            else:
                heapq.heappush(Q,(q0+min(D+A,D*(q1+1)//2),q1//2))
                heapq.heappush(Q,(q0+min(D+A,D*(q1+1)//2),q1//2+1))
            if q1%3==0:
                heapq.heappush(Q,(q0+min(B,D*(q1//3)*2),q1//3))
            else:
                M=q1%3
                m=3-M
                heapq.heappush(Q,(q0+min(M*D+B,(q1-q1//3)*D),q1//3))
                heapq.heappush(Q,(q0+min(m*D+B,(q1-(q1+3)//3)*D),(q1+3)//3))
            if q1%5==0:
                heapq.heappush(Q,(q0+min(C,D*(q1//5)*4),q1//5))
            else:
                M=q1%5
                m=5-M
                heapq.heappush(Q,(q0+min(M*D+C,(q1-q1//5)*D),q1//5))
                heapq.heappush(Q,(q0+min(m*D+C,(q1-(q1+5)//5)*D),(q1+5)//5))
    print(Dict[1]+D)

Measured memory_bytes: 96112
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
bool Is(LL x){
	for(LL i=2;i*i<=x;i++){
		if(x%i==0) return 0;
	}
	return 1;
}
map<LL,int> cnt,cnt2;
int main(){
	LL a,b;
	cin>>a>>b;
	for(LL i=1;i*i<=a;i++) {
		if(a%i==0){
			if(Is(i)){
				cnt[i]=1;
			}
			if(Is(a/i)){
				cnt[a/i]=1;
			}
		}
	}
	for(LL i=1;i*i<=b;i++) {
		if(b%i==0){
			if(Is(i)){
				cnt2[i]=1;
			}
			if(Is(b/i)){
				cnt2[b/i]=1;
			}
		}
	}
	int res=0;
	for(map<LL,int> :: IT ite=cnt.begin();ite!=cnt.end();ite++){
		if(cnt2[ite->FIR]) res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cctype> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  int N,K;
  int i;
  long long ans1=1;
  cin >> N >> K;
  long long ans2=K;
  if(N==K){
    for(i=1;i<=K;i++){
      ans1*=i;
    }
    cout << ans1 << endl;
  }else{
    for(i=2;i<=N;i++){
      ans2*=(K-1);
    }
    cout << ans2 << endl;
  }
 
  return 0;
} 



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
        int c1, c2, c3, i, cnt = 0;
        int card[11];

        for ( int i = 1 ; i < 11 ; i++ ) {
                card[i] = 1;
        }

        while ( scanf( "%d %d %d", &c1, &c2, &c3 ) == 3 ) {
                cnt = 0;
                for ( i = 1 ; i < 11 ; i++ ) {
                        if ( c1 != i && c2 != i && c3 != i ) {
                                if ( c1 + c2 + i <= 20 ) {
                                        cnt++;
                                }
                        }
                }
                if ( cnt >= 4 ) {
                        printf( "YES\n" );
                } else {
                        printf( "NO\n" );
                }
        }
        return 0;
}



Measured memory_bytes: 2080
import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)

cake_list = []
num_set = set([0])

def hash2(a,b,c):
    return 10**8*a+10**4*b+c


def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            num_set.add(hash2(1,0,0))
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            num_set.add(hash2(0,1,0))
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            num_set.add(hash2(0,0,1))
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if hash2(ai+1,bi,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                num_set.add(hash2(ai+1,bi,ci))
        if bi < y - 1:
            if hash2(ai,bi+1,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                num_set.add(hash2(ai,bi+1,ci))
        if ci < z - 1:
            if hash2(ai,bi,ci+1) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                num_set.add(hash2(ai,bi,ci+1))
        print(-di)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl

/* -----  2018/03/11  Problem: ARC 091 B / Link: http://arc091.contest.atcoder.jp/tasks/arc091_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, K;

LL ans = 0LL;

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

	cin >> N >> K;
	if (K == 0) {
		cout << N*N << endl;
		return 0;
	}


	//FOR(i, 1, N + 1) {
	//	FOR(j, 1, N + 1) {
	//		cout << i%j << '\t';
	//	}cout << endl;
	//}
	FOR(b, K + 1, N + 1) {//
		LL ret = 0;
		ret += (b - K)*(N / b);
		ret += max(0LL, N%b - K + 1);
		ans += ret;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

// 重さがw1,w1+1,w1+2,w1+3の4種類しかない
// 全探索

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll W;
    cin >> N >> W;
    vector<vector<ll>> v(4);
    ll w1, v1;
    cin >> w1 >> v1;
    v[0].push_back(v1);
    for (int i = 1; i < N; i++)
    {
        ll ww, vv;
        cin >> ww >> vv;
        v[ww - w1].push_back(vv);
    }
    for (int i = 0; i < 4; i++)
    {
        sort(RALL(v[i]));
    }
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < (int)v[i].size(); j++)
        {
            if (j == (int)v[i].size() - 1)
            {
                continue;
            }
            v[i][j + 1] += v[i][j];
        }
        v[i].insert(v[i].begin(), 0LL);
    }
    ll ans = 0;
    for (ll i = 0; i < (ll)v[0].size(); i++)
    {
        for (ll j = 0; j < (ll)v[1].size(); j++)
        {
            for (ll k = 0; k < (ll)v[2].size(); k++)
            {
                for (ll l = 0; l < v[3].size(); l++)
                {
                    ll wsum = i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3);
                    if (wsum <= W)
                    {
                        ll vsum = v[0][i] + v[1][j] + v[2][k] + v[3][l];
                        chmax(ans, vsum);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

#pragma GCC optimize "O3"
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = (int)1e9 + 7;
const ll INF = MOD * MOD;
const ll powll = 1LL << 1;

int main(void)
{
    int a, b, c;
    while (1)
    {
        cin >> a >> b >> c;
        if (a == 0)
            break;

        double prePer = 1.0 + a / 100.0;
        double aftPer = 1.0 + b / 100.0;

        int ans = 0;
        rep(i, 1, 1001)
        {
            rep(j, 1, 1001)
            {
                if (i + i * a / 100 + j + j * a / 100 == c)
                {
                    ans = max(ans, i + i * b / 100 + j + j * b / 100);
                }
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
const static long long int MOD = 1000000000 + 7;

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    stack<char> ST;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'S') {
            ST.push(S[i]);
        } else if (S[i] == 'T') {
            if (ST.empty() == true) {
                ST.push(S[i]);
            } else {
                char check = ST.top();
                if (check == 'S') ST.pop();
                else ST.push(S[i]);
            }
        }
    }

    cout << ST.size() << endl;

    return 0;
}

Measured memory_bytes: 720
N = int(input())
A = list(map(int, input().split()))

if not 1 in A:
    res = -1
else:
    b = 1
    B = []
    for a in A:
        if a == b:
            B.append(b)
            b += 1
    res = N - len(B)

print(res)


Measured memory_bytes: 24744
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll a;
  ll ma=0;
  ll ans =0;
  rep(i,n){
    cin >> a;
    chmax(ma,a);
    ans += a;
  }
  ans -=(ma/2);
  pri(ans);


  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 128;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

int n;
PII A[MAX];
PII B[MAX];
bool G[MAX][MAX];
int U[MAX];
int M[MAX];

bool dfs(int v)
{
  if (U[v]) return 0;
  U[v] = 1;

  FOR (i,0,n)
  {
    if (G[v][i] && (M[i] == -1 || dfs(M[i])))
    {
      M[i] = v;
      return 1;
    }
  }

  return 0;
}

int main()
{

  cin >> n;
  FOR (i,0,n) cin >> A[i].first >> A[i].second;
  FOR (i,0,n) cin >> B[i].first >> B[i].second;

  FOR (i,0,n)
    FOR (j,0,n)
      G[i][j] = A[i].first < B[j].first && A[i].second < B[j].second;

  FILL(M, -1);

  FOR (i,0,n)
  {
    FILL(U, 0);
    dfs(i);
  }

  int res = 0;
  FOR (i,0,n) res += M[i] != -1;

  cout << res << endl;
  







  return 0;
}


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

int main() {
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A + 2);
    vector<ll> t(B + 2);
    vector<ll> x(Q);
    s[0]     = -1e11;
    s[A + 1] = 1e11;
    t[0]     = -1e11;
    t[B + 1] = 1e11;
    rep(i, A) cin >> s[i + 1];
    rep(i, B) cin >> t[i + 1];
    rep(i, Q) cin >> x[i];

    rep(i, Q) {
        ll sl = s[lower_bound(all(s), x[i]) - s.begin() - 1];
        ll sr = s[lower_bound(all(s), x[i]) - s.begin()];
        ll tl = t[lower_bound(all(t), x[i]) - t.begin() - 1];
        ll tr = t[lower_bound(all(t), x[i]) - t.begin()];

        ll p1 = x[i] - min(sl, tl);
        ll p2 = max(sr, tr) - x[i];
        ll p3 = 2 * sr - x[i] - tl;
        ll p4 = 2 * tr - x[i] - sl;
        ll p5 = x[i] - sl + tr - sl;
        ll p6 = x[i] - tl + sr - tl;
        cout << min({p1, p2, p3, p4, p5, p6}) << endl;
    }
}

Measured memory_bytes: 3712
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    h,w = LI()
    board = [["#" for _ in range(w+2)]]
    num = 0
    for _ in range(h):
        line = ["#"] + list(S()) + ["#"]
        num += line.count(".")
        board.append(line)
    board.append(["#" for _ in range(w+2)])
    
    queue = collections.deque([(1,1)])
    explored = {(1,1)}
    nbh = [[0,1],[0,-1],[1,0],[-1,0]]
    level = 0
    cnt = 0
    
    while len(queue)!=0 and (h,w) not in explored:
        if cnt==0:
            level+=1
            cnt=len(queue)
        nxt = queue.popleft()
        for dx,dy in nbh:
            ex = (nxt[0]+dx, nxt[1]+dy)
            if board[ex[0]][ex[1]] == ".":
                if ex not in explored:
                    explored.add(ex)
                    queue.append(ex)
        cnt -= 1
    ans = num-(level+1) if (h,w) in explored else -1
    print(ans)
main()            


Measured memory_bytes: 74924