akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, K; cin >> N >> K;
    int R, S, P; cin >> R >> S >> P;
    string s; cin >> s;

    ll ans = 0;
    vector<bool> take(N, false);
    for(int i=0; i<N; i++) {
        take[i] = true;
        if(i - K >= 0 and s[i-K] == s[i]) {
            take[i] = (take[i-K] ? false : true);
        }

        if(take[i]) {
            if(s[i] == 'r') ans += P;
            if(s[i] == 's') ans += R;
            if(s[i] == 'p') ans += S;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> refr(a), mic(b);
    for (int i=0; i<a; i++) cin >> refr[i];
    for (int i=0; i<b; i++) cin >> mic[i];

    vector<int> refr_tmp(a), mic_tmp(b);
    refr_tmp = refr;
    mic_tmp = mic;
    sort(refr_tmp.begin(), refr_tmp.end());
    sort(mic_tmp.begin(), mic_tmp.end());
    int ans = refr_tmp[0] + mic_tmp[0];

    for (int i=0; i<m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, refr[x] + mic[y] - c);
    }

    cout << ans << endl;
}


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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
		cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

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

int main(){

  int r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
    x = r*x-d;
    cout << x << endl;
  }
}

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

using namespace std;

using i64 = long long;

const i64 MOD = i64(1e9) + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int n, u, v, m;
    cin >> n >> u >> v >> m;
    vector<vector<int>> usagi(n, vector<int>(n, 0));
    vector<vector<int>> neko(n, vector<int>(n, 0));
    map<int,pair<int,int>> usagi_set, neko_set;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            cin >> usagi[i][j];
            usagi_set[usagi[i][j]] = make_pair(i, j);
        }
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            cin >> neko[i][j];
            neko_set[neko[i][j]] = make_pair(i, j);
        }

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

    unordered_map<int,int> usagi_h, usagi_w, usagi_hw, usagi_wh;
    unordered_map<int,int> neko_h, neko_w, neko_hw, neko_wh;

    int usagi_cnt = 0, neko_cnt = 0;
    for(auto& b : a){
        if(usagi_set.find(b) != usagi_set.end()){
            int x, y;
            tie(x, y) = usagi_set[b];
            ++usagi_h[x];
            ++usagi_w[y];
            ++usagi_hw[x + y];
            ++usagi_wh[x - y];
            usagi_cnt += (usagi_h[x] == n);
            usagi_cnt += (usagi_w[y] == n);
            usagi_cnt += (usagi_hw[x + y] == n);
            usagi_cnt += (usagi_wh[x - y] == n);
            if(n == 1){
                usagi_cnt = 1;
            }
        }
        if(neko_set.find(b) != neko_set.end()){
            int x, y;
            tie(x, y) = neko_set[b];
            ++neko_h[x];
            ++neko_w[y];
            ++neko_hw[x + y];
            ++neko_wh[x - y];
            neko_cnt += (neko_h[x] == n);
            neko_cnt += (neko_w[y] == n);
            neko_cnt += (neko_hw[x + y] == n);
            neko_cnt += (neko_wh[x - y] == n);
            if(n == 1){
                neko_cnt = 1;
            }
        }
        if(usagi_cnt >= u && neko_cnt >= v){
            cout << "DRAW" << endl;
            return 0;
        }
        if(usagi_cnt >= u && neko_cnt < v){
            cout << "USAGI" << endl;
            return 0;
        }
        if(usagi_cnt < u && neko_cnt >= v){
            cout << "NEKO" << endl;
            return 0;
        }
    }
    cout << "DRAW" << endl;
    return 0;
}




Measured memory_bytes: 22352
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n,m,temp,sum = 0;
	cin >> n>>m;
	rep(i, m) {
		cin >> temp;
		sum += temp;
	}
	if (sum > n) cout << -1 << endl;
	else cout << n - sum << endl;

	


	system("pause");
	return 0;
}


Measured memory_bytes: 3748
#include <cstdio>
#include <iostream>
#include <algorithm>
#define fir first
#define sec second
#define mid ((L + R) >> 1)
using namespace std;

const int N = 3e5 + 5;
const int M = 7e6 + 6;

int n, m, base = 0;
pair <int, int> seg[N];
int rt[N], lc[M], rc[M], key[M], S = 0;

template <typename T> void Read(T &x) {
  x = 0; char ch;
  while (!isdigit(ch = getchar()));
  do {x = (x << 1) + (x << 3) + ch - '0';} while (isdigit(ch = getchar()));
}

inline void add(int x, int y, int L, int R, int p) {
  key[y] = key[x] + 1;
  if (L == R) return;
  if (p <= mid) {
    rc[y] = rc[x];
    lc[y] = ++ S;
    add(lc[x], lc[y], L, mid, p);
  }
  else {
    lc[y] = lc[x];
    rc[y] = ++ S;
    add(rc[x], rc[y], mid + 1, R, p);
  }
}

inline int query(int x, int y, int L, int R, int low) {
  if (low > R) return 0;
  if (L == R) return key[y] - key[x];
  if (low <= mid) return query(lc[x], lc[y], L, mid, low) + key[rc[y]] - key[rc[x]];
  else return query(rc[x], rc[y], mid + 1, R, low);
}

int main() {
  int t = 0;
  Read(n); Read(m);
  for (int i = 1, l, r; i <= n; i ++) {
    Read(l); Read(r);
    if (l == 0) base ++;
    else seg[++ t] = make_pair(l, r);
  }
  sort(seg + 1, seg + t + 1);
  int p = 0;
  for (int i = 1, tmp; i <= t; i ++) {
    while (p < seg[i].fir) rt[p + 1] = rt[p], p ++;
    tmp = ++ S;
    add(rt[p], tmp, 1, m, seg[i].sec);
    rt[p] = tmp;
  }
  while (p < m) rt[p + 1] = rt[p], p ++;
  int ans = 0;
  for (int i = 1; i <= m; i ++) {
    ans = base;
    for (int j = 0; j <= m; j += i)
      ans += query(rt[j], rt[min(j + i, m)], 1, m, j + i);
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 72192
N,M=map(int,input().split())
AB=[]
for i in range(N):
    AB.append(list(map(int, input().split())))
AB.sort()

h=0
k=0
i=0
while h+AB[i][1]<M:
    h+=AB[i][1]
    k+=AB[i][0]*AB[i][1]
    i+=1

k+=AB[i][0]*(M-h)

print(k)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	if (n < 3) {
		puts("0");
		return 0;
	}
	int k = ri();
	int table[11][5];
	int sum = 0;
	for (int i = 0; i < 11; i++) for (int j = 0; j <= 4; j++) {
		table[i][j] = (4 + i * 8 + j * 9) % 11 == k;
		sum += table[i][j];
	}
	n -= 2;
	int big = n / 11;
	int res = sum * big;
	for (int i = 0; i < n % 11; i++) for (int j = 0; j <= 4; j++) res += table[i][j];
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 3768
#include<stdio.h>

int main (void){
	
	int a,b,c,x,count;
	count = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
		if(c%x == 0){
			count += 1;
		}
	}
	printf("%d\n",count);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}


int main(void){
	ll n;
	cin>>n;
	ll a,b,c;
	vector<ll> A,B,C,D;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	rep(i,n){
		cin>>b;
		B.push_back(b);
	}
	rep(i,n){
		cin>>c;
		C.push_back(c);
	}
	sort(all(A));
	sort(all(B));
	sort(all(C));
	int ai=0,bi=0,ci=0;
	ll ans = 0;
	while(bi < n && ci < n){
		while(ci < n && B[bi] >= C[ci]){
			ci++;
		}
		D.push_back(n-ci);
		bi++;
	}
	rep(i,n){
		D.push_back(0);
	}
	
	REP(i,n){
		D[i] += D[i+1];
	}

	ai=0;bi=0;
	while(ai < n && bi < n){
		while(bi < n && A[ai] >= B[bi]){
			bi++;
		}
		ans += D[bi];
		ai++;
	}
	cout<<ans<<endl;
	/*rep(i,n){
		cout<<D[i]<<" ";
	}
	cout<<endl;*/

	return 0;
}


Measured memory_bytes: 4980
n = list(map(int, input().split()))

cnt = 0

while True:
    n.sort()
    a, b, c = n[0], n[1], n[2]
    if a == b == c:
        break
    if a + 2 <= c:
        a += 2
    else:
        a += 1
        b += 1
    cnt += 1
    n[0], n[1], n[2] = a, b, c
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,i;
  char s;
  vector<int> c(30,1);
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    c[s-97]++;
  }
  long long ans=1;
  for(i=0;i<30;i++){
    ans=(ans*c[i])%1000000007;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 256
using System;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var a = Convert.ToInt32(x[0]);
            var b = Convert.ToInt32(x[1]);

            int d = a / b;
            var r = a % b;
            double f = Convert.ToDouble(a) / Convert.ToDouble(b);

            Console.WriteLine(d + " " + r + " " + f.ToString("F6"));
            Console.ReadLine();
        }
    }
}

//var x = Console.ReadLine().Split(' ');
//var a = Convert.ToInt32(x[0]);
//var b = Convert.ToInt32(x[1]);

Measured memory_bytes: 9240
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }
  int ans = 0;
  rep(i,N){
    rep(j, N) {
      if (i != j) {
        ans += list[i] * list[j];
      }
    }
  }
  ans /= 2;
  cout << ans;
  return 0;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
    //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
/*
  AOJ 1078
  Title:SAT-EN-3
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
char exp_[501];
char literal[3][250];
int lit_cnt;

int x_and_not_x(char e1[],char e2[])
{
        //printf("e1e2=%s %s\n",e1,e2);


        if(e1[0]=='~')
                return(0==strcmp(&e1[1],e2));
        if(e2[0]=='~')
                return(0==strcmp(e1,&e2[1]));
        return(0);
}
int check()
{
        int i,j;

        if(lit_cnt<=1)
                return(1);
        for(i=0;i<lit_cnt-1;i++)
                for(j=i+1;j<lit_cnt;j++)
                        if(x_and_not_x(&literal[i][0],&literal[j][0]))
                                return(0);
        return(1);
}



int satis_clause(char exp_[])
{
        char *p;
        char buf[500];

        strcpy(buf,exp_);
        lit_cnt=3;

        if(buf[strlen(buf)-1]==')')
                buf[strlen(buf)-1]='\0';
        //printf("S1:%s\n",buf);

        sscanf(buf,"%[^&]&%[^&]&%s",&literal[0][0],&literal[1][0],&literal[2][0]);
        //printf("*>%s:%s:%s\n",&literal[0][0],&literal[1][0],&literal[2][0]);
        
        return(check());
}

int satisfiable(char exp_[])
{
        char *p;
        int ret;

        if(NULL==strchr(exp_,'|'))
                return(satis_clause(exp_+1));
        p=strtok(exp_,"|");
        do
        {
                //printf("s0=%s\n",p);

                ret=satis_clause(p+1);

                //printf("ret=%d\n",ret);

                if(ret)
                        return(1);

        }
        while(p=strtok(NULL,"|"));

        return(0);
}

main()
{
        while(EOF!=scanf("%s",&exp_[0]) && exp_[0]!='#')
        {
                printf("%s\n",satisfiable(exp_)?"yes":"no");
        }
  return(0);
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
//#define all(a) a.begin(),a.end()
//#define pb push_back
//#define pob pop_back
typedef long long ll;
//using vi=vector<ll>;
//using vvi=vector<vector<ll>>;
//bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
//bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
//int sum(vector<int> v){int x=0;rep(i,v.size()) x+=v[i];return x;}
//void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
//void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
void slove(){
  int k,x;cin>>k>>x;
  if(500*k>=x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
int main(){
  slove();return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	int n;
	cin >> n;
	
	/*Rating 1-399 : gray
Rating 400-799 : brown
Rating 800-1199 : green
Rating 1200-1599 : cyan
Rating 1600-1999 : blue
Rating 2000-2399 : yellow
Rating 2400-2799 : orange
Rating 2800-3199 : red*/
	int mn = 0 , mx = 0;
	vi used(10);
	rep(i , n){
		int x;
		cin >> x;
		if(x >= 3200){
			++mx;
			continue;
		}else if(x <= 399){
			++used[0];
			continue;
		}else if(x <= 799){
			++used[1];
			continue;
		}else if(x <= 1199){
			++used[2];
			continue;
		}else if(x <= 1599){
			++used[3];
			continue;
		}else if(x <= 1999){
			++used[4];
			continue;
		}else if(x <= 2399){
			++used[5];
			continue;
		}else if(x <= 2799){
			++used[6];
			continue;
		}else if(x <= 3199){
			++used[7];
			continue;
		}
	}
	
	int mna = 0 , mxa = 0;
	rep(i , 8){
		if(used[i]){
			++mna;
		}
	}
	int c = 8 - mna;
	c = min(c , mx);
	mxa = mna;
	mna = max(mna , 1);
	mna = min(mna , 8);
	cout << mna << " " << mxa + mx << nl;

	return 0;
}

Measured memory_bytes: 256
k, s = map(int, input().split())
cnt = 0

for i in range(k, -1, -1):
    # 1桁目を決定する
    if s - i > k * 2:
        continue

    # 2桁目を決定する
    for j in range(k, -1, -1):
        # 3桁目を決定する
        x = s - i - j

        if x > k:
            # 3桁目が設定できないとき
            continue
        cnt += x >= 0
print(cnt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	int N;
	int C[22],V[22];
	cin >> N;
	int ans = 0;
	for(int i=0;i<N;i++)cin >> V[i];
	for(int i=0;i<N;i++)cin >> C[i];
	for(int i=0;i<N;i++){
		ans += max(0,V[i]-C[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H,W = map(int,input().split())
mod = 10**9+7

A = [list(input()[:-1]) for _ in range(H)]

dp = [[0]*W for _ in range(H)]
dp[0][0]=1
for h in range(H):
    for w in range(W):
        if (h+1<H and A[h][w] == '.'):
            dp[h+1][w] += dp[h][w]
        if (w+1<W and A[h][w]=='.'):
            dp[h][w+1] += dp[h][w]
print(dp[H-1][W-1] % mod)

Measured memory_bytes: 254300
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vvint d(m, vint(m));
    rep(i, m) rep(j, m) cin >> d[i][j]; 
    vvint c(n, vint(n));
    rep(i, n) rep(j, n) cin >> c[i][j]; 

    vector<map<int, int>> mp(3);
    rep(i, n) rep(j, n) {
        int id = (i+j+2)%3;
        mp[id][c[i][j]-1]++;
    }

    int ans = INF;
    rep(i, m) {
        rep(j, m) {
            if (i==j) continue;
            rep(k, m) {
                if (i==k || j==k) continue;
                int t = 0;
                for (auto x : mp[0]) t += d[x.fi][i]*x.se;
                for (auto x : mp[1]) t += d[x.fi][j]*x.se;
                for (auto x : mp[2]) t += d[x.fi][k]*x.se;
                ans = min(ans, t);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;

struct Node {
	bool flag = true;
	vector<int> c;
};

list<int> out;

void dfs(vector<Node>& v, int n)
{
	v[n].flag = false;
	for (int i = 0; i < v[n].c.size(); i++)
	{
		if (v[v[n].c[i]].flag) dfs(v, v[n].c[i]);
	}
	out.push_front(n);
}

void topologicalSort(vector<Node>& v)
{
	for (int i = 0; i < v.size(); i++)
	{
		if (v[i].flag) dfs(v, i);
	}
}

int main(void)
{
	int V, E, s, t;
	cin >> V >> E;
	vector<Node> v(V);

	for (int i = 0; i < E; i++)
	{
		cin >> s >> t;
		v[s].c.push_back(t);
	}

	topologicalSort(v);

	for (int i = 0; i < V; i++) {
		cout << out.front() << endl;
		out.pop_front();
	}

	return 0;
}


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

using namespace std;

typedef long long ll;

map <long long, char> mp;

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

int main() {
	int n, m;
	cin >> n >> m;
	string a, b;
	cin >> a >> b;

	ll gc = gcd(n, m);
	ll lc = n/gc * 1ll * m;

	for (int i = 0; i < n; ++i) {
		mp[(lc/n) * i] = a[i];
	}
	int ok = 1;
	for (int i = 0; i < m; ++i) {
		if (mp.find((lc/m) * 1ll * i) != mp.end()) {
			if(mp[(lc/m) * 1ll * i] != b[i]) {
				ok = 0;
			}
		} 
	}
	if (ok) printf("%lld\n", lc);
	else printf("-1\n");




}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,j=0;
  cin>>N;
  while(N--){
    int A;
    cin>>A;
    if(A%2==1)
      j++;
  }
  if(j%2==0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

vector<vi> AdjList;
const int maxn = 1e5 + 5;
bool vis[maxn];

void dfs(int node) {
	int i,j;
	vis[node] = true;
	for(i=0;i<AdjList[node].size();i++){
		int v = AdjList[node][i];
		if(!vis[v]){
			dfs(v);
		}
	}
}

int main(){
	int n,m,i,j;
	scanf("%d %d",&n,&m);
	AdjList.assign(n+1, vi());
	for(i=0;i<m;i++){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		AdjList[x].pb(y); AdjList[y].pb(x);
	}
	memset(vis, false, sizeof vis);
	int cnt = 0;
	for(i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
};

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

int main() {
	int H,W;
	cin >> H >> W;
	vector<string> S(H);
	rep(i,H) cin >> S[i];

	rep(i,H)rep(j,W) {
		if(S[i][j] == '.') {
			S[i][j] = '0';
			for(int k=-1; k<=1; k++) {
				for(int l=-1; l<=1; l++) {
					int h = i+k, w = j+l;
					if(0<=h && h<H && 0<=w && w<W) {
						if(S[h][w] == '#') S[i][j]++;
					}
				}
			}
		}
	}
  rep(i,H) cout << S[i] << endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

bool grid [20][20];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int H, W; cin >> H >> W;
    int bestDist = 0;
    F0R(y, H) {
        F0R(x, W) {
            char c; cin >> c; 
            grid[y][x] = (c == '#');
        }
    }
    F0R(y, H) {
        F0R(x, W) {
            if (grid[y][x]) continue;
            int dist [20][20];
            bool visited[20][20];
            F0R(i, 20) {
                F0R(j, 20) {
                    dist[i][j] = 0;
                    visited[i][j] = false;
                }
            }

            queue<pair<int, int>> q;
            q.push(pair<int, int> {x, y});
            visited[y][x] = true;

            while (!q.empty()) {
                pair<int, int> cur = q.front(); q.pop();
                for (pair<int, int> delta : vector<pair<int, int>>{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}) {
                    int nx = cur.first + delta.first;
                    int ny = cur.second + delta.second;
                    if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;\
                    if (visited[ny][nx]) continue;
                    if (grid[ny][nx]) continue;

                    q.push(pair<int, int> {nx, ny});
                    visited[ny][nx] = true;
                    dist[ny][nx] = dist[cur.second][cur.first] + 1;
                }
            }

            F0R(i, 20) {
                F0R(j, 20) {
                    bestDist = max(bestDist, dist[i][j]);
                }
            }

        }
    }
    cout << bestDist << endl;
}

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        
	        int N = sc.nextInt();	
	        long[] a = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	        }

	        long ans = 1000;

	        
	        for(int i=1;i<N;i++) {
	        	if(a[i-1]<a[i]) {
	        		ans = ans/a[i-1] * a[i] + ans%a[i-1];
	        	}
	        }
	        
	        System.out.println(ans);
	        
		 }
		 
	}

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

def gcd(a, b):
	while b:
		a, b = b, a%b
	return a

g=0
max_a=0
for a in A:
	g=gcd(g, a)
	max_a=max(max_a, a)

if K%g==0 and K<=max_a:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Measured memory_bytes: 85216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.pointCount();
		return;
	}
	
	private void pointCount() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		try {
			
			int point = 0;
			
			for (int i = 0; i < 10; i++) {
				String inputStr = bufferedReader.readLine();
				int num = Integer.parseInt(inputStr);
				point += num;
			}
			
			System.out.println(point);
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 16904
#include<bits/stdc++.h>
using namespace std;
#define MAXA 1000000

int main() {
    int N, cnt[MAXA + 3];
    bool divisorExist[MAXA + 3];

    cin >> N;

    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= N; i++) {
        int A;
        cin >> A;

        cnt[A] += 1;
    }

    memset(divisorExist, false, sizeof(divisorExist));
    for (int i = 1; i <= MAXA; i++) {
        if (cnt[i] > 0) {
            for (int j = 2 * i; j <= MAXA; j += i) {
                divisorExist[j] = true;
            }
        }
    }

    int answer = 0;
    for (int i = 1; i <= MAXA; i++) {
        if (cnt[i] == 1 && !divisorExist[i])
            answer += 1;
    }

    cout << answer << endl;
}


Measured memory_bytes: 8512
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B;
        cin >> A >> B;
        if (B == 1) {
                cout<< 0 << endl;
                return 0;
        }
        ll ans = 0;
        while (B > A) {
                B -= (A-1);
                ++ans;
        }
        if (B != 0) ++ans;

        cout << ans << endl;
}

Measured memory_bytes: 3608
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int A, B, M, amin = 0, bmin = 0, ans = 0, p = 0, minp = 0;
    
    cin >> A >> B >> M;
    
    int a[A], b[B], x[M], y[M], c[M];
    
    
    for(int i=0; i<A; i++)
    {
        cin >> a[i];
        
        if(i == 0) amin = a[i];
        
        if(a[i] < amin)
        {
            amin = a[i];
        }
    }
    
    for(int i=0; i<B; i++)
    {
        cin >> b[i];
        
        if(i == 0) bmin = b[i];
        
        if(b[i] < bmin)
        {
            bmin = b[i];
        }
    }
    
    ans = amin + bmin;
    
    for(int i=0; i<M; i++)
    {
        cin >> x[i] >> y[i] >> c[i];
        
        p = a[x[i] - 1] + b[y[i] - 1] - c[i];
        
        if(i == 0) minp = p;
        if(p < minp) minp = p;
    }
    
    if(minp < ans) ans = minp;
    
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF INT_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
string s[100010];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s, s + n);
	int ans = 0;
	rep(i, n) {
		ans += upper_bound(s, s + n, s[i]) - lower_bound(s, s + n, s[i]) - 1;
	}
	cout << ans / 2 << endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int l, r, d;
	cin >> l >> r >> d;
	if (l % d == 0)
		cout << r / d - l / d + 1;
	else
		cout << r / d - l / d;
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}


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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll D = A - B;
  vector<ll> h(N);
  rep(i, 0, N) cin >> h[i];
  ll left = 0, right = 1e9;
  while(right - left > 1) {
    ll mid = (left + right) / 2;
    ll cnt = 0;
    rep(j, 0, N) {
      ll v = h[j] - B * mid;
      if(v > 0) cnt += (v - 1) / D + 1;
    }
    if(cnt <= mid) right = mid;
    else left = mid;
  }
  cout << right << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
ll modInv(ll a){
	return powm(a,mod-2)%mod;
}

int main()
{
	fast;
	ll n,i,j,k;
	cin>>n>>k;
    vector<pll>v;
    int z=0;
	for(i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		if(x==0)
		{
			z=1;
		}
		if(x<0)
		{
			v.pb({-1*x,1});
		}
		else
		{
			v.pb({x,0});
		}
	}
    sort(all(v));
    reverse(all(v));
    int x=0;
    int y;
    for(i=0;i<k;i++)
    {
    	if(v[i].se)
    	{
    		x++;
    		y=i;
		}
    	
	}
	ll ans=1;
	if(x%2==0)
	{
		for(i=0;i<k;i++)
		{
			ans=(ans*v[i].fi)%mod;
		}
		cout<<ans;
	}
	else
	{
		if(x==k)
		{
			int f=0;
			for(i=k;i<n;i++)
			{
				if(v[i].se==0)
				{
					f=i;
					break;
				}
			}
			if(f==0)
			{
				
				for(i=0;i<k;i++)
				{
					ans=(ans*v[n-i-1].fi)%mod;
				}
				ans=ans*-1;
				ans=(ans+mod)%mod;
				cout<<ans;
			}
			else
			{
				for(i=0;i<k-1;i++)
				{
					
					ans=(ans*v[i].fi)%mod;
					
				}
				ans=(ans*v[f].fi)%mod;
				cout<<ans;
			}
			
		}
		else
		{
			ll p=0;
			ll ne=0;
			for(i=0;i<k;i++)
			{
				if(v[i].se)
				{
					ne=max(ne,i);
				}
				else
				{
					p=max(p,i);
				}
				
			}
			ans=1;
			for(i=0;i<k;i++)
			{
				ans=(ans*v[i].fi)%mod;
			}
			ll p1=n,ne1=n;
			for(i=k;i<n;i++)
			{
				if(v[i].se)
				{
					ne1=min(ne1,i);
				}
				else
				{
					p1=min(p1,i);
				}
			}
			if(p1==n)
			{
				if(ne1==n)
				{
					
					ans=ans*-1;
					ans+=mod;
					ans%=mod;
					cout<<ans;
				}
				else
				{
					ans*=v[ne1].fi;
					ans=ans%mod;
					ans=ans*modInv(v[p].fi);
					ans=ans%mod;
					cout<<ans;
				}
			}
			else
			{
				if(ne1==n)
				{
					ans=ans*v[p1].fi;
					ans=ans%mod;
					ans=ans*modInv(v[ne].fi);
					ans%=mod;
					cout<<ans;
				}
				else
				{
					if(v[ne1].fi*v[ne].fi>=v[p1].fi*v[p].fi)
					{
						ans=ans*v[ne1].fi;
						ans%=mod;
						ans*=modInv(v[p].fi);
						ans=ans%mod;
						cout<<ans;
					}
					else
					{
						ans=ans*v[p1].fi;
						ans%=mod;
						ans*=modInv(v[ne].fi);
						ans%=mod;
						cout<<ans;
					}
					
				}
			}
		
		
		}
	}
	
	
    
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD M
ll N, M = 1;

struct llm{
    ll value=0;

    //llm(const unsigned ll &val) { (this->value = val) %= MOD; }
    //llm(const unsigned int &val) { (this->value = val) %= MOD; }
    llm(const ll& val=0){(this->value = MOD + val % MOD) %= MOD;}
    //llm(const int& val){(this->value = MOD + val % MOD) %= MOD;}
    llm(const llm& a) { llm(a.value); }
    llm inv(){ll a = 1;ll b = this->value;for(ll m=MOD-2;m>0;m/=2){if(m&1){a=a*b%MOD;}b=b*b%MOD;}return llm(a);}
    llm &operator+=(const llm &a) {(this->value += a.value) %= MOD;return *this;}
    llm &operator-=(const llm &a) {(this->value += MOD - a.value) %= MOD;return *this;}
    llm &operator*=(const llm &a) {(this->value *= a.value) %= MOD; return *this; }
    explicit operator ll() const{return (ll)value;}
    explicit operator int() const{return (int)value;}
};
llm operator+(const llm &a, const llm &b) { return llm(a.value + b.value); }
llm operator-(const llm &a, const llm &b) { return llm(a.value - b.value); }
llm operator*(const llm &a, const llm &b) { return llm(a.value * b.value); }
#define pllm pair<llm,llm>
llm Fa[101010],iFa[101010];
void init(){
    ll i = 0;
    Fa[0] = 1;
    fornum(i,0,100000){
        Fa[i + 1] = Fa[i]*(i + 1);
    }
    iFa[100000] = Fa[100000].inv();
    for (i = 100000; i > 0;--i){
        iFa[i - 1] = iFa[i] * i;
    }
}
llm inv(ll a){
    if(a<=0)
        return 1;
    return iFa[a] * Fa[a - 1];
}


ll i, j, k;

int main(){
    scanf("%lld%lld", &N,&M);
    vector<vector<llm>> dp(N * 3 + 50, vector<llm>(7000));
    init();
    dp[0][3000] = Fa[N * 3];

    fornum(i, 0, N * 3)
    {
        fornum(j, 3000-i/2, 6000)
        {
            dp[i + 1][j + 1] += dp[i][j] * inv(i + 1);
            if(j>0)
                dp[i + 2][j - 1] += dp[i][j] * inv(i + 2);
            dp[i + 3][j] += dp[i][j] * inv(i + 3);
        }
        dp[i + 1][j] += dp[i][j] * inv(i + 1);
        dp[i + 2][j] += dp[i][j] * inv(i + 2);
        dp[i + 3][j] += dp[i][j] * inv(i + 3);
    }
    llm ans = 0;
    fornum(i,3000,7000){
        ans += dp[N * 3][i];
    }
    printf("%lld\n", (ll)ans);

    return 0;
}

Measured memory_bytes: 334976
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> II;

struct UnionFind {
	std::vector<int> _parent;
	std::vector<int> _size;
	UnionFind(int size) : _parent(size, -1), _size(size, 1) { }
	void unite(int a, int b) {
		int ra = root(a), rb = root(b); if (ra == rb) { return; }
		if (_size[ra] >= _size[rb]) { _parent[rb] = ra, _size[ra] += _size[rb]; } else { _parent[ra] = rb, _size[rb] += _size[ra]; }
	}
	int root(int a) {
		int p = _parent[a];
		if (p < 0) { return a; }
		while (_parent[p] >= 0) { p = _parent[p]; }
		return _parent[a] = p;
	}
	int size(int a) { return _size[root(a)]; }
};

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<II> v(m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		v[i].first = a - 1;
		v[i].second = b - 1;
	}
	UnionFind uf(n);
	vector<LL> ans(m);
	LL d = ((LL)n * (n - 1)) / 2;
	for (int i = m - 1; i >= 0; --i) {
		ans[i] = d;
		if (uf.root(v[i].first) != uf.root(v[i].second)) {
			d -= uf.size(v[i].first) * uf.size(v[i].second);
			uf.unite(v[i].first, v[i].second);
		}
	}
	for (int i = 0; i < m; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>

using namespace std;

int main(void){
    int n =0;
    int k=0;
    double ans = 0;

    scanf("%d",&n);
    scanf("%d",&k);

    for(int i = 1; i<=n;i++){
        int j=0;
        int tmp_point = i;
        double tmp_per = ((double)1/(double)n);

        for(j=0; tmp_point< k; j++ ){
            tmp_point = tmp_point *2;
            tmp_per = tmp_per * (1.0/2.0);
//            printf("tpe = %lf\n",tmp_per);
        }
        ans += tmp_per;

//        printf("t = %lf\n",ans);
    }

    printf("%.10lf",ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int x, a, b;

  cin >> x >> a >> b;

  if(a >= b) cout << "delicious" << endl;
  else{
    if(b-a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
c4=0
c2=0

for i in range(n):
    if a[i]%4==0:
        c4+=1
for i in range(n):
    if a[i]%2==0:
        c2+=1

if n<=(2*c4 + max(1,c2-c4)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15020
#include<iostream>
#include<cstdio>
#include<complex>
#include<cmath>
using namespace std;
typedef complex<double> xy_t;
int main()
{
  xy_t P[110];
  int N = 0;
  double x,y;
  while(~scanf("%lf,%lf",&x,&y)){
    P[N++] = xy_t(x,y);
  }
  double sum = 0.0;
  for(int i = 0; i + 2 < N; ++i){
    xy_t a = P[0],b = P[i + 1],c = P[i + 2]; 
      sum += (conj(b - a) * (c - a)).imag();
  }
  sum /= 2;
  printf("%.6f\n",abs(sum));
}

Measured memory_bytes: 1248
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

ll dp[101010];

int main(){
    
    ll N, W;
    cin >> N >> W;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll w, v;
        cin >> w >> v;
        for(ll to = W; to >= 0; to--){
            ll from = to - w;
            if(from < 0)break;
            dp[to] = max(dp[to], dp[from] + v);
            ans = max(dp[to], ans);
        }
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	int cnt = 0;
	while( n-- ){
		int h; cin >> h;
		if( h >= k ) ++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

n, m = map(int, input().split())

wa=defaultdict(lambda: 0)
already=set()
ac = 0
for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in already:
    continue

  if s == "AC":
    ac+=1
    already.add(p)
  else:
    wa[p] += 1

print(ac, sum(wa[i] for i in already))

Measured memory_bytes: 22888
x = []
y = []
ans = []
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
for i in range(len(x)):
    if x[i] % 10 == 0:
        y.append(x[i])
    else:
        y.append(10 * (x[i] // 10 + 1))
for i in range(len(x)):
    tmp = 0
    tmp = x[i] + sum(y) -y[i]
    ans.append(tmp)
print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main(){
long N, M, tmp, Ptmp;
string Stmp;

cin >> N;
vector<long> W(N+1);
erep(i, N) cin >> W[i];
long s1, s2;
long ans = 1e5;
erep(i, N-1){
    s1 = accumulate(W.begin()+1, W.begin()+i+1, 0);
    s2 = accumulate(W.begin()+i+1, W.end(), 0);
    // cout << s1 << "," << s2 << endl;
    ans = min(ans, abs(s1-s2));
}
show(ans);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c,r;
  scanf("%d%d%d",&a,&b,&c);
  if(a>=b&&a>=c)r=a;
  if(b>=a&&b>=c)r=b;
  if(c>=a&&c>=b)r=c;
  printf("%d",a+b+c-r);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
static const int M = 100;
static const int INF = (1 << 21);
static const int W = 0;
static const int G = 1;
static const int B = 2;

int n, m[M][M];


void dijk() {
	int u, minv;
	int i, v, d[M], c[M];

	for (i = 0; i < n; i++) {
		d[i] = INF;
		c[i] = W;
	}
	d[0] = 0;
	c[0] = G;
	while (1) {
		minv = INF;
		u = -1;
		for (i = 0; i < n; i++) {
			if (minv > d[i] && c[i] != B) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1) {
			break;
		}
		c[u] = B;
		for (v = 0; v < n; v++) {
			if (c[v] != B && m[u][v] != INF) {
				if (d[v] >(d[u] + m[u][v])) {
					d[v] = d[u] + m[u][v];
					c[v] = G;
				}
			}
		}
	}
	for (i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
	}
}

int main(void) {
	int i, j,k,c,u,v;
	cin >> n;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			m[i][j] = INF;
		}
	}
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		for (j = 0; j < k; j++) {
			cin >> v >> c;
			m[u][v] = c;
		}
	}
	dijk();
	return 0;
}



Measured memory_bytes: 3148