akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
const int MOD = 1e9 + 7;
int add(int x, int y)
{
    int res = ((x % MOD) + (y % MOD)) % MOD;
    return res;
}
int sub(int x, int y)
{
    int res = ((x % MOD) - (y % MOD) + MOD) % MOD;
    return res;
}
int binpow(int a, int b)
{
    a %= MOD;
    int res = 1;
    while (b)
    {
        if (b & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}
int32_t main() {
    fast_io();
    int n, k;
    cin >> n >> k;
    int a[k + 1] = {0}; // number of tuples with gcd i
    int ans = 0;
    for (int i = k; i >= 1; i--)
    {
        int aux = binpow(k / i, n);
        int foo = 0;
        for (int j = 2 * i; j <= k; j += i)
        {
            foo = add(foo, a[j]);
        }
        aux = sub(aux, foo);
        a[i] = aux;
    }
    for (int i = 1; i <= k; i++)
        ans = add(ans, a[i] * i);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    string s; cin>>s;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]=='(') cnt++;
        else cnt--;
        if(cnt<0) {s='('+s; cnt++; i++; n++;}
    }
    while(cnt){
        s+=')'; cnt--;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

struct pos {
    ll p[3];
    bool operator<(pos const& oth) const {
        pair<ll, pair<ll, ll>> p1, p2;
        p1.first = p[0], p1.second.first = p[1], p1.second.second = p[2];
        p2.first = oth.p[0], p2.second.first = oth.p[1], p2.second.second = oth.p[2];
        return p1 < p2;
    }
    void print() const {
        cout << p[0] << " " << p[1] << " " << p[2] << endl;
    }
};

int main() {
    ll A[3], N;
    cin >> A[0] >> A[1] >> A[2] >> N;
    ll res = (A[0]*A[1] + A[1]*A[2] + A[2]*A[0]) * 2;
    map<pos, int> m[3];
    for(int i=0; i<N; ++i) {
        pos p;
        for(int j=0; j<3; ++j) {
            cin >> p.p[j];
        }
        for(int j=0; j<3; ++j) {
            for(int k=0; k<2; ++k) {
                pos p2 = p;
                p2.p[j] += k;
                m[j][p2]++; 
            }
        }
    }
    for(int i=0; i<3; ++i) {
        for(auto& pa : m[i]) {
            if(pa.first.p[i] == 0 || pa.first.p[i] == A[i] || pa.second == 2) {
                res--;
                auto p2 = pa.first;
                if(m[i].count(p2) && m[i][p2] == 2) {
                    res++;
                }
            } else {
                res++;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin >> n;
  
  vector<double> v(n);
  for(auto &x:v) cin >> x;
  
  vector<vector<double>> dp(n + 1,vector<double>(2));
  
  dp[1][0] = v[0];
  dp[0][0] = 1 - v[0];
  
  for(int i = 1; i < n; ++i)
  {
  	for(int j = 0; j <= n; ++j)
    {
      dp[j][i%2] = (1 - v[i]) * dp[j][(i+1)%2] + (v[i]) * (j > 0 ? dp[j-1][(i+1)%2] : 0.0);
    }
  }
  
  double ans = 0.0;
  for(int i = (n+1)/2; i <= n; ++i)
  {
  	ans += dp[i][(n-1)%2];
  }
  
  cout << fixed << setprecision(15);
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fo(i,ini,n) for(int i=ini;i<n;i++)
int const inf=1e9+7;
typedef long long ll;

int main(){
	int t;
	cin>>t;
	int a[t];
	fo(i,0,t){
		cin>>a[i];
	}
	vector<ll>dp(t+1,inf);
	dp[0]=0;
	fo(i,0,t-1){
		fo(j,i+1,i+3){
			dp[j]=min(dp[i]+abs(a[i]-a[j]),dp[j]);
		}
	}
	cout<<dp[t-1]<<endl;
}


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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define foi(i,a,n) for(i = (a); i <= (n); i++)
#define pd(x) cout<<x
#define sd(x) cin>>x
#define nl cout<<endl
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//ll fibonacci[2][2] = {{0,1},{1,1}};
//ll identity[2][2] = {{1,0},{0,1}};
ll i,j,k;

int main() {
	ll a,b;
	cin>>a>>b;
	cout << (((b-a)*(b-a-1)/2) - a) <<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    static Scanner in;

    void solve() {
        String s = in.nextLine();
        Deque<Integer> q1 = new ArrayDeque<>();
        Deque<Pair> q2 = new ArrayDeque<>();
        ArrayList<Integer> list = new ArrayList<>();
        int sum = 0;

        for(int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if(c == '\\') {
                q1.push(i);
            }else if(c == '/' && q1.size() > 0) {
                int j = q1.pop();
                int a = i - j;
                sum += a;
                while(q2.size() > 0 && q2.getFirst().first > j) {
                    a += q2.pop().second;
                }
                q2.push(new Pair(j, a));
            }
        }
        System.out.println(sum);
        System.out.print(q2.size());
        while(q2.size() > 0) {
            System.out.print(" " + q2.removeLast().second);
        }
        System.out.println();
    }

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

class Pair{
    int first, second;
    public Pair(int i, int j) {
        first = i; second = j;
    }
}

Measured memory_bytes: 29960
a = input()

d = {}
for c in a:
  if c in d:
    d[c] += 1
  else:
    d[c] = 1

sum = 0
if len(d) == 2:
  for s in d.values():
    sum += s
  if sum == 4:
    print('Yes')
  else:
    print('No')
else:
  print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, W;
    cin >> n >> W;
    ll w[n], v[n];
    rep(i, n) cin >> w[i] >> v[i];
    ll mp[n + 1][W + 1] = {};
    set<ll> for_search; //重さ
    for_search.insert(W);

    rep(i, n) {
        set<ll> temp;
        for (auto wi : for_search) {
            if (wi - w[i] >= 0) {
                mp[i + 1][wi - w[i]] = max(mp[i][wi - w[i]], mp[i][wi] + v[i]);
                temp.insert(wi - w[i]);
            }
            mp[i + 1][wi] = max(mp[i + 1][wi], mp[i][wi]);
        }
        for (auto a : temp) for_search.insert(a);
    }
    ll ans = 0;
    for (ll i = 0; i <= W; ++i) ans = max(ans, mp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 87808
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[200][200000];
const ll INF = 1LL<<60;
int main() {
  int n;
  ll w;
  cin >> n >> w;
  vl W(n),V(n);
  Fill(dp,INF);
  rep(i,n)cin >> W[i] >> V[i];
  dp[0][0] = 0LL;
  rep(i,n){
    rep(j,100100){
      mins(dp[i+1][j],dp[i][j]);
      if(j-V[i] < 0)continue;
      if(dp[i][j-V[i]]+W[i] >w)continue;
      mins(dp[i+1][j],dp[i][j-V[i]]+W[i]);
    }
  }
  ll ans = 0;
  rep(j,100100){
    if(dp[n][j] <= w)maxs(ans,(ll)j);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 312704
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;



int main()
{
	int N,m=0,r=0;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		if(m<=t)
		{
			r++;
			m=t;
		}
	}
	cout<<r<<endl;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
goal_0 = 0
goal_n = 0
for i in range(x, -1, -1):
    if i in a:
        goal_0 += 1
for j in range(x, n+1):
    if j in a:
        goal_n += 1
print(min(goal_0, goal_n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, t; cin >> n >> t;
	int mi = 1 << 30;
	for(int i = 0; i < n;  i++) {
		int a, b; cin >> a >> b;
		
		if(b <= t) mi = std::min(mi, a);
	}
	
	cout << (mi == 1 << 30 ? "TLE" : std::to_string(mi)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
#ifdef TarekHasan
    freopen("input.txt","r",stdin);
#endif // TarekHasan
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;

    vector< int > A(a);
    vector< int > B(b);
    vector< int > C(c);

    for(int i=0; i<a; i++)
        cin >> A[i];
    for(int i=0; i<b; i++)
        cin >> B[i];
    for(int i=0; i<c; i++)
        cin >> C[i];


    sort(A.begin(),A.end(),greater<int>());
    sort(B.begin(),B.end(),greater<int>());
    sort(C.begin(),C.end());


    vector< int > Final;

    for(int i=0;i<x;i++)
        Final.push_back(A[i]);
    for(int i=0;i<y;i++)
        Final.push_back(B[i]);
    for(int i=0;i!=C.size();i++)
        Final.push_back(C[i]);

    sort(Final.begin(),Final.end(),greater<int>());

    long long int result = 0;

    for(int i=0;i<x+y;i++)
        result+=Final[i];
    cout << result << endl;




    return 0;
}


Measured memory_bytes: 6552
#include <stdio.h>
int main(void)
{
  int N;
  int A[100000];
  int Rain[100000];
  int SumRain;

  int i,j;

  scanf("%d",&N);

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


  SumRain = 0;
  for ( i = 1; i < N; i++ )
    SumRain += A[i];
  SumRain = SumRain - A[0];

  for ( i = 2; i < N - 1; i = i + 2){
    SumRain = SumRain - 2 * A[i];
  }

  Rain[N-1] = SumRain;

  
  for ( i = N - 2; i >= 0; i-- ){
    Rain[i] = 2 * A[i] - Rain[i + 1];
  }

  for ( i = 0; i < N-1; i++ )
    printf("%d ",Rain[i]);
  printf("%d\n",Rain[N-1]);


  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin>>n;
    vector<ll>x={0,0,0,0,0,0,1,1,1,2};
    vector<ll>y={1,1,1,2,2,3,2,2,3,3};
    vector<ll>z={2,3,4,3,4,4,3,4,4,4};
    vector<ll>a(5,0);
    rep(i,0,n){
        string s;
        cin>>s;
        if(s[0]=='M'){
            a[0]++;
        }
        if(s[0]=='A'){
            a[1]++;
        }
        if(s[0]=='R'){
            a[2]++;
        }
        if(s[0]=='C'){
            a[3]++;
        }
        if(s[0]=='H'){
            a[4]++;
        }
    }
    ll ans=0;
    rep(i,0,10){
        ans+=a[x[i]]*a[y[i]]*a[z[i]];
    }
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
//素数列挙
#define P 1100
vl primes;
ll primenum[P];
bool bprime[P+1];
ll searchprime(ll max){//発見した素因数の個数を返す
  max*=2;
  bprime[1]=false;
  for(ll i=2;i<=max;i++){
    bprime[i]=true;
  }
  ll nowprimes=1;
  primes.pb(2);
  for(ll i=4;i<max;i+=2){
    bprime[i]=false;
  }

  for(ll i=3;i<max/2;i+=2){
    if(bprime[i]==true){
      //primes[nowprimes]=i;
      primes.pb(i);
      nowprimes++;
      for(ll j=2;i*j<=max;j++){
        bprime[i*j]=false;
      }
    }
  }
  return nowprimes;
}

ll nn;
void primenum_factorization(ll n){//primesで素因数分解の結果をprimenumに格納
  rep(i,P){
    primenum[i]=0;
  }
  for(int i=0;primes[i]<=n;i++){
    ll pren = n;
    while(1){
      if(pren%primes[i]==0){
        primenum[i]++;
        pren/=primes[i];
      }else{
        break;
      }
    }
  }
  return;
}
vector<vector<ll>> Combi(2001,vector<ll>(2001,-1));
//combination
long long combi(long long n, long long k) {
  if(n<k){
    cout << "ERROR" << endl;
    return 0;
  }
  if(k<0){
    return 0;
  }
  if(Combi[n][k]!=-1){
    return Combi[n][k];
  }
  if (n == k || k == 0){
    Combi[n][n]=1;
    Combi[n][0]=1;
    return 1;
  }else {
    Combi[n][k]=combi(n - 1, k - 1)%d9_7 + combi(n - 1, k)%d9_7;
    Combi[n][n-k]=Combi[n][k];
    return Combi[n][k];
  }
}
//階乗

ll Factrial(ll num){
  if(num==1||num==0){
    return 1;
  }else if(num<0){
    printf("ERROR_minus\n");
    return 0;
  }else{
    return (num*Factrial(num-1))%d9_7;
  }
}
int main(void){
  int n;
  cin>>n;
  searchprime(110);
  vi nums(110,0);
  for(ll i=1;i<=n;i++){
    //cout<<i <<endl;
    ll now=i;
    int j=0;
    while(now!=1){
      if(now%primes[j]==0){
        now/=primes[j];
        nums[j]++;
      }else{
        j++;
      }
    }
  }
  int ans=0;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        if(i<j && j < k){
          if((nums[i]>=2 && nums[j]>=4 && nums[k]>=4)){
            ans++;
          }
          if((nums[i]>=4 && nums[j]>=2 && nums[k]>=4)){
            ans++;
          }
          if((nums[i]>=4 && nums[j]>=4 && nums[k]>=2)){
            ans++;
          }
        }
      }
    }
  }
  rep(i,n){
    if(nums[i]>=74)ans++;
  }
  // 3 25
  rep(i,n){
    rep(j,n){
      if(i<j){
        if((nums[i]>=2 && nums[j]>=24)){
          ans++;
        }
        if((nums[i]>=24 && nums[j]>=2)){
          ans++;
        }
      }
    }
  }
  // 15 5
  rep(i,n){
    rep(j,n){
      if(i<j){
        if((nums[i]>=4 && nums[j]>=14)){
          ans++;
        }
        if((nums[i]>=14 && nums[j]>=4)){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 31616
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma") 
 
#include<bits/stdc++.h>
 
#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left
#define lld long long int
#define ulld unsigned long long int
typedef long long ll;
using namespace std;
 
ll binpow(ll a, ll b) { 
ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;
}
 
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
 
bool isPrime(ll n) { 
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}
void solve(){
      lld n,m;
    cin>>n>>m;
    lld sum=0;
    int arr[n];
    for(int i=0;i<n;i++)
    {
      cin>>arr[i];
      sum+=arr[i];
    }
    sort(arr,arr+n);
    for(int i=n-1;i>=0;i--)
    {
       if(m==0)
       break;
       sum-=arr[i];
       m--;
    }
       cout<<sum;
    
}
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll t;
   t=1;
   while(t--)
   { 
   solve();
   }
   return 0;
}

Measured memory_bytes: 4380
# テーブル埋め
INF = float('inf')
V, E = [int(x) for x in input().split()]
D = [[INF for _ in range(V)] for _ in range(V)]
for i in range(V):
    D[i][i] = 0
for j in range(E):
    s, t, d = [int(x) for x in input().split()]
    D[s][t] = d

dp = [[INF for _ in range(V)] for _ in range(1 << V)]
for S in range((1 << V) - 1, -1, -1):
    for v in range(V):
        if S == (1 << V) - 1:
            if v == 0:
                dp[S][v] = 0
        else:
            # 次に行くuを決める
            for u in range(V):
                if (S >> u) & 1 == 0:
                    dp[S][v] = min(dp[S][v], D[v][u] + dp[S + (1 << u)][u])

if dp[0][0] == INF:
    print(-1)
else:
    print(dp[0][0])


Measured memory_bytes: 20068
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll S,S_2;

void func(){

	S_2 = 2*S;

	ll left = 1,right = sqrt(S_2),mid = (left+right)/2;
	ll maximum;

	while(left <= right){
		if(mid*(mid+1) <= S_2){

			maximum = mid;
			left = mid+1;

		}else{

			right = mid-1;
		}
		mid = (left+right)/2;
	}

	for(ll n = maximum; n >= 1; n--){
		if((S_2-n*(n-1))%(2*n) == 0){

			printf("%lld %lld\n",(S_2-n*(n-1))/(2*n),n);
			return;
		}
	}
}

int main(){

	while(true){
		scanf("%lld",&S);
		if(S == 0)break;

		func();
	}

	return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a <=5 )
        ans = 0;
    else if(a <= 12)
        ans = b/2;
    else
        ans = b;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];

    int count = 0;
    while(true) {
        bool flag = false;
        for (int i=0; i<n; i++) {
            if (a[i] % 2 != 0) {
                flag = true;
                break;
            }
        }

        if (flag) break;

        for (int i=0; i<n; i++) {
            a[i] /= 2;
        }
        count++;

    }

    cout << count << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int main()
{
  // input_from_file;
  ll n;cin>>n;
  vector< double> vec(n+1,0);
  for(ll i=1;i<=n;i++)   cin>>vec[i];
  vector<vector<double>> dp(2,vector<double>(n+1,0));
  dp[0][0]=1;
  double ans=0;
  // for(ll i=1;i<=n;i++)  dp[i%2][0]=dp[(i-1)%2][0]*(1-vec[i]);
  for(ll i=1;i<=n;i++){
    for(ll j=0;j<=n;j++){
      if(j==0)  dp[i%2][0]=dp[(i-1)%2][0]*(1-vec[i]);
      if(i<j) continue;
      dp[i%2][j]=dp[(i-1)%2][j]*(1-vec[i])+dp[(i-1)%2][j-1]*(vec[i]);
      if(i==n && j>n/2)  ans+=dp[i%2][j];
    }
  }
  cout<<setprecision(9)<<ans;
  return 0;

}

Measured memory_bytes: 512
A,B,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
XYC=[list(map(int,input().split())) for i in range(M)]
r=10**9
for x,y,c in XYC:
    r=min(r,A[x-1]+B[y-1]-c)
print(min(r,min(A)+min(B)))

Measured memory_bytes: 38564
import java.util.Scanner;

public class Main {
	private Scanner sc;

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

		while (sc.hasNextLine()) {
			int lines = Integer.parseInt(sc.nextLine());
			if (lines == 0) break;

			double[] x = new double[lines];
			double[] y = new double[lines];
			for (int i = 0; i < lines; i++) {
				String[] nico = sc.nextLine().split(",");
				x[i] = Double.parseDouble(nico[0]);
				y[i] = Double.parseDouble(nico[1]);
			}
			
			int max = 1;
			for (int i = 0; i < lines; i++) {
				for (int j = (i + 1); j < lines; j++) {
					double d = calc(x[i], x[j], y[i], y[j]);
					if (d > 4.0) continue;
					
					double[] px = new double[1];
					double[] py = new double[1];
					
					if ((x[i] == x[j]) && (y[i] == y[j])) {
						px[0] = x[i];
						py[0] = y[i];
					} else {
						double cr = Math.atan2(-(y[j] - y[i]), (x[j] - x[i]));
						double dr = Math.atan2(Math.sqrt(1.0 - (d / (2.0 * 2.0))), (Math.sqrt(d) / 2.0));
						
						px = new double[2];
						py = new double[2];

						px[0] = x[i] + Math.cos(cr - dr);
						py[0] = y[i] - Math.sin(cr - dr);
						
						px[1] = x[i] + Math.cos(cr + dr);
						py[1] = y[i] - Math.sin(cr + dr);
					}
					
					for (int p = 0; p < px.length; p++) {
						int tmp = 0;
						for (int k = 0; k < lines; k++) {
							if (calc(px[p], x[k], py[p], y[k]) < 1.1) tmp++;
						}
						
						if (max < tmp) max = tmp;
					}
				}
			}
			System.out.println(max);
		}
	}
	
	public double calc(double x0, double x1, double y0, double y1) {
		return ((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
	}
}

Measured memory_bytes: 29272
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x) cin >> x
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll X, A;
    in(X);
    in(A);

    if (X < A)
    {
        outl(0);
    }
    else
    {
        outl(10);
    }

    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m, a[101010], x[101010],y[101010];
struct UnionFind {
	vector<int> par, depth, sz;
	UnionFind(int n) : par(n+1), depth(n+1), sz(n+1){
		for(int i = 0; i <= n; i++){
			par[i] = i;
			depth[i] = 0;
			sz[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		sz[x] += sz[y];
		sz[y] = sz[x];
		if(depth[x] < depth[y]){
			par[x] = y;
		}
		else{
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};
void solve(){
	cin >> n >> m;
	UnionFind uf(n+1);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	for(int i = 0; i < m; i++){
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
		uf.unite(x[i],y[i]);
	}
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(uf.same(a[i],i)) cnt++;
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

long long mx,mn;

int main()
{
    mx = -1;
    mn = 10000000000LL;

    scanf("%d",&n);

    for(int i=0;i<n;i++)
    {
        long long v;
        scanf("%lld",&v);
        mx = max(mx,v);
        mn = min(mn,v);
    }
    printf("%lld\n",mx-mn);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(b>a) swap(a,b);
    if((a+b)%2!=0) puts("IMPOSSIBLE");
    else cout<<(a+b)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

ll X;
  cin>>X;
  bool out=false;
  for(ll i=-1000;i<10000;i++){
    for(ll j=-1000;j<1000;j++){
      if(pow(i,5)-pow(j,5)==X){
        cout<<i<<" "<<j<<endl;
        out=true;
      }
      if(out)break;
    }
  }
  
}



Measured memory_bytes: 4232
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=0; (i)--)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))

typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


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

  cin>>H>>W;

  string S[H];
  REP(i,H)cin>>S[i];
  int num[H][W],num2[H][W];
  REP(i,H)REP(j,W){
    num[i][j]=0;
    num2[i][j]=0;
  }
  REP(i,H)REP(j,W){
    if(j>=1 && S[i][j-1]!='#'){
      num[i][j]=num[i][j-1]+1;
    }
    else if(S[i][j]=='.'){
      num[i][j]=1;
    }
  }
  REP(i,H)RREP(j,W){
    if(j<=W-2 && S[i][j+1]!='#') num[i][j]=num[i][j+1];
  }
  REP(j,W)REP(i,H){
    if(i>=1 && S[i-1][j]!='#') num2[i][j]=num2[i-1][j]+1;
    else if(S[i][j]=='.') num2[i][j]=1;
  }
  REP(j,W)RREP(i,H){
    if(i<=H-2 && S[i+1][j]!='#') num2[i][j]=num2[i+1][j];
  }
  int ans=0;
  REP(i,H)REP(j,W){
    num[i][j] += num2[i][j]-1;
    ans = max(ans,num[i][j]);
  }
  cout<<ans;

  return 0;
}


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

vector<int>ans(60);
vector<bool>prime(2000,true);

void setup(){
    prime[0]=prime[1]=false;

    for(int i=2;i<1000;i++){
        if(!prime[i])continue;
        int k=2;
        while(i*k<2000){
            prime[i*k]=false;
            k++;
        }
    }
    int k=0;
    rep(i,2000){
        if(prime[i]&&i%10==1){
            ans[k]=i;
            k++;
        }
        if(k==59)break;
    }
}

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

    rep(i,n)cout<<ans[i]<<' ';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;
    int pa = 0, pb = 0;
    for(int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if(a > b) {
        pa += a + b;
      }
      else if(a < b) {
        pb += a + b;
      }
      else {
        pa += a;
        pb += b;
      }
    }
    cout << pa << " " << pb << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>

int main(){
  int  n, q;
  int *S,*T;
  int  i, m, r, l, c=0;

  /*scan S*/
  scanf("%d", &n);
  S = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++)
    scanf("%d", &S[i]);

  /*scan T*/
  scanf("%d", &q);
  T = (int *)malloc(sizeof(int) * q);
  for(i=0; i<q; i++)
    scanf("%d", &T[i]);

  /*calc the ans*/
  for(i=0; i<q; i++){
    l = 0;
    r = n;
    while(l < r){
      m = (l + r) / 2;
      if(S[m] == T[i]) {c++; break;}
      else if(S[m] > T[i]) r = m;
      else l = m + 1;
    }
  }
  /*print the ans*/
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

typedef long long LL;

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

const int N = 100 + 10;

int n, t, l, b;
int tp[N];
long double p[N][N];

void solve() {
	for(int i = 0; i <= n; ++ i) {
		tp[i] = 0;
	}
	for(int i = 0; i < l; ++ i) {
		int x;
		scanf("%d", &x);
		tp[x] = 1;
	}
	for(int i = 0; i < b; ++ i) {
		int x;
		scanf("%d", &x);
		tp[x] = 2;
	}

	memset(p, 0, sizeof p);
	p[0][0] = 1;
	long double ret = 0;

	for(int i = 0; i < t; ++ i) {
		for(int j = 0; j < n; ++ j) {
			for(int k = 1; k <= 6; ++ k) {
				int nj = j + k;
				if (nj > n) {
					nj = 2 * n - nj;
				}
				if (tp[nj] == 0) {
					p[i + 1][nj] += p[i][j] / 6;
				}
				if (tp[nj] == 1) {
					p[i + 2][nj] += p[i][j] / 6;
				}
				if (tp[nj] == 2) {
					p[i + 1][0] += p[i][j] / 6;
				}
			}
		}
		ret += p[i + 1][n];
	}
	printf("%.12f\n", (double)ret);
}

int main() {
	for( ; scanf("%d%d%d%d", &n, &t, &l, &b); ) {
		if (n == 0 && t == 0 && l == 0 && b == 0) {
			break;
		}
		solve();
	}
	return 0;
}

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

int ab(int x){
  if(x>0){
    return x;
  }else{
    return -x;
  }
}

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  
  vector<int> dp(N,1000000000);
  dp.at(0)=0;
  for(int i=0;i<N-1;i++){
    for(int j=1;j<=K;j++){
      if(i+j>=N){
        break;
      }
      dp.at(i+j)=min(dp.at(i+j),dp.at(i)+ab(h.at(i+j)-h.at(i)));
    }
  }
  
  cout<<dp.at(N-1)<<endl;
}

Measured memory_bytes: 1024
#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

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

int n, a[100005];
multiset<int> st;
int main() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; ++i)
    scanf("%d", &x), a[x] = i;
  st.insert(0);
  st.insert(0);
  st.insert(n + 1);
  st.insert(n + 1);
  long long ans = 0;
  for (int i = n; i >= 1; --i) {
    auto it = st.lower_bound(a[i]);
    auto nxt = it; nxt++;
    auto prv = it; prv--;
    auto prvv = prv; prvv--;
    ans += 1LL * i * ((*nxt - *it) * (a[i] - *prv) + (*prv - *prvv) * (*it - a[i]));
    st.insert(a[i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
# define  _deb(x) { cerr << "\033[94m"<< "[ " << #x << " = " << (x) << " ]\n\033[0m"; }
using namespace std;
#define int long long
signed main(){
	string s;
	cin >> s;
	int n = s.size();
	vector<int>dp(n,0);
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(s[i]=='L' && cnt>0){
			dp[i-1] = cnt;
			cnt = 0;
		}
		else if(s[i]=='R'){
			cnt++;
		}
	}
	cnt = 0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='R' && cnt>0){
			dp[i+1] = cnt;
			cnt = 0;
		}
		else if(s[i] == 'L'){
			cnt++;
		}
	}
	for(int i=0;i<n;i++) {
		if(dp[i]>0){

			int x = dp[i]; int y = dp[i+1];
			dp[i] = dp[i+1] = 1;
			x--,y--;
			if(x%2==0){
				dp[i]+=(x/2);
				dp[i+1] += (x/2);
			}
			else if(x%2){
				dp[i] += (x/2);
				dp[i+1] += (x/2) + 1;

			}

			if(y%2==0){
				dp[i+1]+=(y/2);
				dp[i] += (y/2);
			}
			else if(y%2){
				dp[i+1] += (y/2);
				dp[i] += (y/2) + 1;
			}
			i++;
		}
	}
	for(int i=0;i<n;i++) cout << dp[i]<<" ";cout<<endl;

}


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

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

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

#define MOD 1000000007

ll modpow(ll a, ll b){
	ll r = 1;
	while(b){
		if(b&1)r=r*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return r;
}

int main(){
	ll x,y;
	cin>>x>>y;
	ll n = (x+y);
	if(n%3!=0){
		puts("0"); return 0;
	}
	n /= 3;
	if(x<n || y<n){
		puts("0"); return 0;
	}
	x -= n; y -= n;
	ll a = 1, b = 1;
	FOR(i,1,x+y+1)a = a * i % MOD;
	FOR(i,1,x+1)b = b * i % MOD;
	FOR(i,1,y+1)b = b * i % MOD;
	ll ans = a * modpow(b,MOD-2)%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var str string

	fmt.Scan(&str)
	S := []rune(str)
	l := len(S)

	ret := "AC"
	cnt := 0
	for i, c := range S {
		if i == 0 {
			if c != 'A' {
				ret = "WA"
				break
			}
		} else if 2 <= i && i <= (l-2) {
			if c == 'C' {
				cnt++
				if cnt > 1 {
					ret = "WA"
					break
				}
			} else if c < 'a' || 'z' < c {
				ret = "WA"
				break
			}
		} else {
			if c < 'a' || 'z' < c {
				ret = "WA"
				break
			}
		}
	}

	if ret == "AC" && cnt == 0 {
		ret = "WA"
	}

	fmt.Println(ret)
}


Measured memory_bytes: 512
#include "iostream"
#include "random"
#include "ctime"
#include "chrono"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"

using namespace std;


int main() {
	int H, W;
	cin >> W >> H;
	while (H) {
		vector<string>s(H);
		for (int i = 0; i < H; i++) {
			cin >> s[i];
		}
		int wh = 0;
		int bl = 0;
		int dir[] = { 1,0,-1,0,1 };
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (s[i][j] != '.') {
					continue;
				}
				bool w = false;
				bool b = false;
				queue<pair<int, int>>Q;
				Q.push({ i,j });
				vector<vector<bool>>flag(H, vector<bool>(W, true));
				flag[i][j] = false;
				while (!Q.empty()) {
					int cy = Q.front().first;
					int cx = Q.front().second;
					Q.pop();
					for (int k = 0; k < 4; k++) {
						int ny = cy + dir[k];
						int nx = cx + dir[k + 1];
						if (ny < 0 || nx < 0 || ny >= H || nx >= W) {
							continue;
						}
						if (!flag[ny][nx]) {
							continue;
						}
						if (s[ny][nx] == 'W') {
							flag[ny][nx] = false;
							w = true;
						}
						else if (s[ny][nx] == 'B') {
							flag[ny][nx] = false;
							b = true;
						}
						else {
							flag[ny][nx] = false;
							Q.push({ ny,nx });
						}
					}
				}
				if (w&&!b) {
					wh++;
					s[i][j] = 'W';
				}
				if (b&&!w) {
					bl++;
					s[i][j] = 'B';
				}
			}
		}
		cout << bl << " " << wh << endl;
		cin >> W >> H;
	}
	return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>

int main(){
	int A, B, C, X, i, j, k;
  	int count=0;
  	scanf("%d", &A);
  	scanf("%d", &B);
  	scanf("%d", &C);
  	scanf("%d", &X);
  
  	for (i = 0; i <= A; i++){
      for(j = 0; j <= B; j++){
        for(k = 0; k <= C; k++){
          if(500*i + 100*j + 50*k == X) count++;
        }
      }
    }
  
printf("%d", count);  

return 0;
}

Measured memory_bytes: 128
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		
		long ans = 0;
		for (int i = 1; i < n; i++) {
			long d = x[i] - x[i-1];
			if( a * d < b) {
				ans += a * d;
			}else{
				ans += b;
			};
		}
		System.out.println(ans);
	}
	
    
}



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

int main(){	
	long long int a,b,c;
	vector<long long int >x(3);
	int veces;
	
	scanf("%lld%lld%lld%d",&x[0],&x[1],&x[2],&veces);
	sort(x.begin(),x.end());
	for(int i=0;i<veces;i++)
	x[2]+=x[2];
	long long  int suma=x[0]+x[1]+x[2];
	printf("%lld\n",suma);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  S = '.' + S + '#'; // その後の処理を簡単にするため,左端に'.', 右端に'#'を付ける
  int black = 0, white = 0; // black:左から黒を数える, white:右から白を数える
  vector<int> border(N+2); // ".#"ごとに左の黒の数を記録
  int j = 0;
  for (int i = 0; i < N+2; i++) { // 左から黒の数を記録
    if (S.at(i) == '#') { // i番目が黒の場合
      if (S.at(i-1) == '.') { // 直前が'.'ならば境界になる
        border.at(j) = black; // 境界より左にある黒の数を記録
        j++;
      }
      black++;
    }
  }
  j--;
  int ans = N+2;
  for (int i = 0; i < N+2; i++) { // 右から白の数を記録
    if (S.at(N-i+1) == '.') { // i番目が白の場合
      if (S.at(N-i+2) == '#') { // 直後が'#'ならば境界になる
        ans = min(ans, border.at(j) + white);
        j--;
      }
      white++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1344
import java.util.Scanner;
import java.util.Arrays;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x == 0 && y == 0) break;
            if(x < y){
                System.out.println(x + " " + y);
            }else{
                System.out.println(y + " " + x);
            }
        }
    }
}


Measured memory_bytes: 36052
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return self.f[n]*self.i[n-k]%mod*self.i[k]%mod
mod=10**9+7
h,w,a,b=map(int,input().split())
f=Factorial(h+w,mod)
ans=0
for i in range(b,w):
    ans=(ans+f.comb(h-a-1+i,i)*f.comb(a-1+w-i-1,w-i-1))%mod
print(ans)

Measured memory_bytes: 18988
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  string s;
  cin >> s;
  int sum = 0;
  REP(i,3){
    if(s[i] == 'o')
      sum++;
  }
  cout << 700+sum*100 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string str;
    cin >> str;
    int n=str.size();
    for(int i=0 ; i<n ; i++ ){
      char tmp=str[i];
      int counter=0;
      for(int j=0 ; j<n ; j++ ){
        if(tmp==str[j])
          counter++;
      }
      if(counter%2==1){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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; }

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string a,b; cin >> a >> b;
int na,nb;  cin >> na >> nb;
  string u; cin >> u;
  if(a==u) na--;
  else nb--;
  cout << na << " " << nb << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s1[100],s2[100];
    scanf("%s %s",s1,s2);
    int l2,l1;
    l1=strlen(s1);
    l2=strlen(s2);
    int k=0,i,j,x,y;
    for(i=0;i<l1;i++)
    {
        k=0;
        if(s1[i]==s2[0])
        {
            for(j=0,x=i;j<l2;j++,x++)
            {
                if(x==l1) x=0;
                if(s2[j]==s1[x]) k++;
                //printf("%d\n",k);
            }
        }
        if(k==l2) break;
    }
    if(k==l2) printf("Yes\n");
    else  printf("No\n");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int a,b,c;
  int M[30];
  int counter=0;
  scanf("%d %d %d",&a,&b,&c);
  for(int ite=0;ite<b;ite++){
    scanf("%d",&M[ite]);
  }
  for(int i=0;i<a;i++){
    int sum=0;
    int A[30];
    for(int repe=0;repe<b;repe++){
      scanf("%d",&A[repe]);
}
    for(int rep=0;rep<b;rep++){
      sum+=A[rep]*M[rep];
}
    if(sum>-c) counter++;
  } 
  printf("%d",counter);
  return 0;
}


Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    t = 'ACGT'
    r = 0
    u = 0
    for c in s:
        if c in t:
            u += 1
        else:
            if r < u:
                r = u
            u = 0
    if r < u:
        r = u

    return r


print(main())




Measured memory_bytes: 5460
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int m = S % 3600 / 60;
		int s = S % 3600 % 60;
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 17316