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

int main()
{
    int LR_f = 0;                  //左端
    int LR_s, RL, sum, gusu, kisu; //右端、集まる場所、区間にある数
    string S;
    cin >> S;
    int Length = S.size();
    S += "R";
    vector<int> list(Length);

    for (int i = 0; i < Length; i++)
    {
        if (S[i] == 'R' && S[i + 1] == 'L')
            RL = i;

        if (S[i] == 'L' && S[i + 1] == 'R')
        {
            LR_s = i;
            sum = LR_s - LR_f + 1;
            gusu = LR_s / 2 - (LR_f - 1) / 2;
            if (LR_f == 0)
                gusu++;
            kisu = sum - gusu;

            list[RL] = gusu;
            list[RL + 1] = kisu;

            if (RL % 2 == 1)
                swap(list[RL], list[RL + 1]);

            LR_f = LR_s + 1;
        }
        
    }

    for (int i = 0; i < Length ; i++)
    {
        cout << list.at(i);
        if (i < Length - 1)
            cout << " ";
    }
}

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

typedef long long ll; //longlong型をllと省略

//最大値を求めるテンプレ
template<class T> inline bool chmax(T& a, T b){
  if(a < b){
    a = b;
    return 1;
  }
  return 0;
}

//最小値を求めるテンプレ
template<class T> inline bool chmin(T& a, T b){
  if(a > b){
    a = b;
    return 1;
  }
  return 0;
}

int N,W;

ll weight[100010];
ll value[100010];

ll dp[110][100100] = {0};
int main(){
  cin >> N >> W;
  rep(i,N) cin >> weight[i] >> value[i];

  for(int i = 0; i <= W; ++i) dp[0][i] = 0;

  rep(i,N){
    for(int w = 0; w <= W; ++w){
      if(w-weight[i] >= 0) chmax(dp[i+1][w],dp[i][w-weight[i]]+value[i]);
      chmax(dp[i+1][w],dp[i][w]);
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}

Measured memory_bytes: 80128
import itertools
N = int(input())


P = list(map(int, input().split()))
Q = list(map(int, input().split()))

a = []

for i in range(1,N+1):
    a += [i]
count = 1
p = 0
q = 0
for v in itertools.permutations(a, N):

    
    if list(v) == P:
        p = count
        
    if list(v) == Q:
        q = count
    
    if p > 0 and q > 0:
        break
    count+=1
        
print(abs(p-q))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

ll mod = 998244353;

ll power(ll a, ll b) {
  if (b == 0)
    return 1;

  ll ans = power(a * a % mod, b / 2);
  if (b % 2)
    ans *= a;

  return ans % mod;
}

void
solve() {
  ll n, m, k;
  cin>>n>>m>>k;

  ll ans = 0;
  ll temp = 1;
  for (ll i=0; i<=k; i++) {
    ans = (ans + (m*temp%mod) * power(m-1, n-i-1)) % mod;
    temp = (temp * (n-i-1) % mod) * power(i+1, mod-2) % mod;
  }

  cout<<ans<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>

int main (void)
{
  int N;
  int flag = 0;
  scanf("%d",&N);
  for (int i = 0; i <= 25; i++) // ケーキの数 
  {
    for (int j = 0; j <= 14 ; j++) // ドーナツの数
    {
      if (4*i+7*j == N)
        flag = 1;
    }
  }
  if (flag == 0)
    printf("No");
  else
    printf("Yes");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
 
int main() {
    LL n;
    cin>>n;
 
    vector<pair<LL, int> > dvs;//配对<质数, 幂次>
 
    //质因数分解
    for (LL i=2; i*i<=n; i++) {
        if (0==n%i) {
            dvs.push_back(make_pair(i, 0));
            while (0==n%i) {
                dvs.back().second++;
                n /= i;
            }
        }
    }
    if (n>1) {
        dvs.push_back(make_pair(n, 1));
    }
 
    //遍历
    int ans = 0;
    for (pair<LL, int> &p : dvs) {
        int i=sqrt(p.second*2);
        if (i*(i+1)>p.second*2) {
            i--;
        }
        ans += i;
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3732
#include<stdio.h>
//int A[MAX];
#define MAX 2000001
#define VMAX 10000
void Countingsort(int[],int);
void Countingsort(int A[],int n){
  int i,j,k=0;

  int C[VMAX];
  for(i=0;i<VMAX;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    C[A[i]]++;
  }
  for(i=0;i<VMAX;i++){
    for(j=C[i];j>0;j--){
A[k++]=i;
    }

}
}
int main(){
  int n,i;
  int A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  Countingsort(A,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1){
      printf(" ");
  }

}

printf("\n");
return 0;
}



Measured memory_bytes: 9648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int N;
vector<ll> A;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N;
  A = fetch_vec<ll>(N);
}

int solve(){
  input();
  ll _xor,_sum;
  _xor = 0, _sum = 0;
  vector<int> res(N,0);
  int i=0;
  for(int j=0;j<N;j++){
    while(((_xor^A[i])==(_sum+A[i])) && (i<N)) {
      _xor ^= A[i];
      _sum += A[i];
      i++;
    }
    DBG(i)
    DBG(j)
    DBG(_xor)
    DBG(_sum)
    res[j] = i-1;
    _xor ^= A[j];
    _sum -= A[j];
  }
  DBG(res)
  ll ans=0;
  REP(l,N){
    ans += (res[l]-l+1);
  }
  cout << ans << endl;

  return 0;
}

int main()
{
  solve();
  return 0;
}


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

int main()
{
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    int ans = INT_MAX;
    for(int i=0;i<=n-m;i++)
    {
        string st = s.substr(i,m);
        int k=0;
        for(int j=0;j<m;j++)
        {
            if(st[j]!=t[j])
                k++;
        }
        if(k<ans)
            ans = k;
    }
    cout<<ans<<endl;
}


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

struct edge { int from, to, cost; };
const int MAX_V=100;
const int INF=1e9;

vector<edge> es;
int d[MAX_V];
int n;

void shortest_path(int s){
  REP(i, n) d[i] = INF;
  d[s] = 0;
  while(true){
    bool update = false;
    for(edge e : es){
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
	d[e.to] = d[e.from] + e.cost;
	update = true;
      }
    }
    if(!update) break;
  }
}

int main(){
  cin>>n;
  REP(i,n){
    int u, k; cin>>u>>k;
    REP(j,k){
      edge e;
      e.from = u;
      cin>>e.to>>e.cost;
      es.push_back(e);
    }
  }
  shortest_path(0);
  REP(i,n){
    cout<<i<<" "<<d[i]<<endl;
  }
}

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

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7
struct hoge
{
    int s, t, c;
};

int compare_int(const void *a, const void *b){
	struct hoge *A = (struct hoge *)a;
	struct hoge *B = (struct hoge *)b;
    return (A->s) - (B->s);
}

int main(void){
    int n, c;
    scanf("%d %d", &n, &c);
    struct hoge rec[n];
    for(int i = 0;i < n;i++){
        scanf("%d %d %d", &rec[i].s, &rec[i].t, &rec[i].c);
    }
    qsort(rec, n, sizeof(struct hoge), compare_int);
    //i個目の録画機の録画が次に終わるときの時間とチャンネル
    int dp[c][2];
    for(int i = 0;i < c;i++){
        dp[i][0] = -1;
        dp[i][1] = -1;
    }
    for(int i = 0;i < n;i++){
        int j = 0;
        while(1){
            if(dp[j][0] < rec[i].s || (dp[j][0] == rec[i].s && dp[j][1] == rec[i].c)){
                dp[j][0] = rec[i].t;
                dp[j][1] = rec[i].c;
                break;
            }
            j++;
        }
    }
    int ans = 0;
    while(1){
        if(dp[ans][0]==-1 || ans == c){
            printf("%d\n", ans);
            break;
        }
        ans++;
    }
    return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(ll, x, a, b);
	a = b - a;
	if (a <= 0) cout << "delicious" << endl;
	else if (a <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

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

int N,M;
    pair<int,int> PD[10010];

int main()
{
    while(cin>>N>>M&&N){
        int d,p,S=0;
        for(int i=0;i<N;i++){
            cin>>d>>p;
            PD[i]=make_pair(p,d);
            S+=d*p;
        }
        sort(PD,PD+N);
        reverse(PD,PD+N);
        for(int i=0;i<N;i++){
            if(M<=0)break;
            int pro;
            if(M>PD[i].second)pro=PD[i].second;
            else pro=M;
            S-=PD[i].first*pro;
            M-=pro;
        }
        cout<<S<<endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;



int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n);
    vector<int> wa(n);
    rep(i, n) {
        ac[i] = false;
        wa[i] = 0;
    }
    int num_ac = 0;
    int num_wa = 0;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        if (ac[p-1]) continue;
        if (s=="AC") {
            ac[p-1] = true;
            num_ac++;
            num_wa += wa[p-1];
        }
        if (s=="WA") wa[p-1]++;
    }
    
    
    cout << num_ac << " " << num_wa << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N, A, B; cin >> N >> A >> B;
	cout << ((N*A > B) ? B : N * A) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define f first
//#define s second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){	
	fast;
	int n,w;
	cin >> n >> w;
	vector<ll> dp(1e5+2,0);
	vector<ll> item;
	for(int i=0;i<n;i++ ){
		ll weight,value;
		cin >> weight >> value;
		vector<ll> new_dp = dp;
		for(int j = w;j>=0;j--){
			if(j - weight >=0){
				new_dp[j] = max(dp[j-weight]+value,new_dp[j]);
			}
		}
		dp = new_dp;
	}
	cout<<*max_element(all(dp));
	return 0;
}

	


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e3 + 7;
const int N = 2e5 + 7;
const int M = 22;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);



void solve1()
{
    int s,w;
    cin >> s >> w;
    if( s <= w )cout << "unsafe";
    else cout << "safe";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

int main() {
	long long int a, b;
	cin >> a >> b;

	int result;
	int mod;
	double precisionNum;
	result = a / b;
	mod = a % b;
	precisionNum = double(a) / double(b);

	cout << result << " " << mod << " " ;
	printf("%.5f\n", precisionNum);
	//system("pause");
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b); }

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int N, M, K;
int cnt[1000];
int tmp[1000];

int main(){
	cout << setprecision(10) << fixed;
	while(cin >> N >> M >> K and N + M + K){
		memset(tmp, 0, sizeof(tmp));
		ld res = 0;
		if(N == 1){
			int s = 0;
			REP(i, M) s += max((i+1-K), 1);
			cout << s / (double) M << endl;
			continue;
		}
		REP(i, N){
			memset(cnt, 0, sizeof(cnt));
			if(i == 0) { REP(j, M) tmp[j] = 1; continue; }
			REP(j, M*(i+1)-i){
				if(j<M) REP(k, j+1) cnt[j] += tmp[k];
				else REP(k, M) cnt[j] += tmp[j-k];
			}
			REP(i, 1000) tmp[i] = cnt[i];
		}
		ld total = pow(M, N);
		REP(i, M*N) res += cnt[i] * max(N+i-K, 1) / total;
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3396
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    long long ans = 0;
    int sum = 0, xor_sum = 0;
    int r = 0;
    for (int l = 0; l < N; l++) {
        while (r < N && (sum + A[r] == (xor_sum ^ A[r]))) {
            sum += A[r];
            xor_sum ^= A[r];
            r++;
        }
        
        ans += r - l;

        sum -= A[l];
        xor_sum ^= A[l];

        if (r == l) r++;
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

map<int, int> D(int N)
{
	map<int, int> res;
	int t = N;
	for (int i = 2; i <= (int)sqrt(N); i += (i == 2 ? 1 : 2))
	{
		while (t%i == 0)
		{
			res[i]++;
			t /= i;
		}
	}
	if (t != 1)
	{
		res[t]++;
	}
	return res;
}

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

	int N;
	cin >> N;
	auto pmap = D(N);

	int ans = 0;
	for (auto p : pmap)
	{
		int num = 1;
		while (num <= p.second)
		{
			ans++;
			p.second -= num;
			num++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
ll N,W, w[100],v[100], dp[100][100001];

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

    cin>>N>>W;
    for (ll i=0; i<N; i++)
        cin>>w[i]>>v[i];
    
    memset(dp, 0, sizeof dp);
    for (ll j=w[0]; j<=W; j++) dp[0][j] = v[0];
    for (ll i=1; i<N; i++) {
        for (ll j=1; j<=W; j++) {
            dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            if (j-w[i] >= 0) {
                dp[i][j] = max(
                    dp[i][j],
                    v[i] + dp[i-1][j-w[i]]
                );
            }
        }
    }

    cout << dp[N-1][W] << '\n';
    return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,X;
    cin >> N >> X;
    int L[N];
    REP(i,N) cin >> L[i];
    int ans = 1;
    int za = 0;
    REP(i,N){
        za += L[i];
        if(za <= X){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const ll Mod = 1e9 + 7;
ll n,k,a[100100],Fact[100100];

ll fastpower(ll a , ll b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a;
    ll res = fastpower(a,b/2)%Mod;
    res = (res %Mod  * res % Mod)%Mod;
    if(b%2!=0)
        res*=a;
    return res % Mod;
}

ll C(ll n , ll k){
    if(n - k < 0)  return 0;
    ll x = (Fact[k] * Fact[n - k] + 2 * Mod) % Mod;
    return (Fact[n] * fastpower(x , Mod - 2) + Mod)%Mod;
}


int main()
{
    cin >> n >> k;
    for(int i=0;i<n;i++)  cin >> a[i];
    Fact[0] = 1;
    for(int i = 1;i<=n;i++)  Fact[i] = i * Fact[i - 1] , Fact[i]%=Mod;
    sort(a , a + n);
    ll Max = 0,Min = 0;
    for(int i =0;i<n;i++)
        Min=((Min % Mod) + ((a[i] * C(n - i - 1 , k - 1))%Mod) + 2 * Mod)%Mod;
    for(int i = n - 1;i>=0;i--)
        Max=((Max % Mod) + ((a[i] * C(i , k - 1))%Mod) + 2 * Mod)%Mod;
    cout << (Max - Min + 2 * Mod)%Mod;
    return 0;
}


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

int main() {
    char x,y;
    scanf("%c %c",&x,&y);
   
    
   if((x-y)>0)
   printf(">");
   else if((x-y)==0)
   printf("=");
   else
   printf("<");
	return 0;
}

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

int parent(int i) {
  return (i+1)/2 - 1;
}
int left(int i) {
  return 2*(i+1) - 1;
}
int right(int i) {
  return 2*(i+1)+1 - 1;
}
void downHeap(vector<int> &A,int i) {
  int n = A.size();
  int l = left(i);
  int r = right(i);
  int largest = i;
  // A[largest] = max(A[i],A[l],A[r])
  if(l < n) {
    if(A[l] > A[i])
      largest = l;
  }
  if(r < n) {
    if(A[r] > A[largest])
      largest = r;
  }
  if(largest != i) {
    swap(A[i],A[largest]);
    downHeap(A,largest);
  }
}
/*
void buildMaxHeap(vector<int> &A) {
  for(int i=(A.size()-1)/2;i>=0;i--) {
    downHeap(A,i);
  }
}
*/
void upHeap(vector<int> &A,int i) {
  int p = parent(i);
  if(p >= 0) {
    if(A[i] > A[p]) {
      swap(A[i],A[p]);
      upHeap(A,p);
    }
  }
}
void insert(vector<int> &A,int key) {
  A.push_back(key);
  upHeap(A,A.size()-1);
}
int extractMax(vector<int> &A) {
  int max = A[0];
  A[0] = A.back();
  A.pop_back();
  downHeap(A,0);
  return max;
}
int main() {
  vector<int> A;
  char buf[10];
  while(scanf("%s",buf)) {
    if(buf[0] == 'i') {
      int key; scanf("%d",&key);
      insert(A,key);
    }
    else if(buf[1] == 'x') {
      int max = extractMax(A);
      printf("%d\n",max);
    }
    else if(buf[2] == 'd') {
      break;
    }
  }
}

Measured memory_bytes: 6320
#include <iostream>
#include <fstream>
#include <set>
#include <tuple>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
#include <queue>
#include <stack>

int main() {
	int n, k; std::cin >> n >> k;
	std::vector<bool> has_candy(n, false);
	for (auto i = 0; i < k; ++i) {
		int d; std::cin >> d;
		for (auto j = 0; j < d; ++j) {
			int a; std::cin >> a;
			has_candy[a - 1] = true;
		}
	}
	std::cout << std::count(has_candy.begin(), has_candy.end(), false) << std::endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define frd(x) freopen("x","r",stdin)
#define fwt(x) freopen("x","w",stdout)
#define fo(i,a) for(int i=1;i<=(a.n);i++)
#define fup(i,x,y) for(int i=(x);i<=(y);i++)
#define fdn(i,x,y) for(int i=(x);i>=(y);i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

template<int __>
struct ia
{
    int a[__],n;
    ia(int n=0):n(n) {}
    void rev(){reverse(a+1,a+n+1);}
    void hp(){make_heap(a+1,a+n+1);}
    int& operator[](int x){return a[x];}
    void sf(){fup(i,1,n)scanf("%d",a+i);}
    void mem(int x){memset(a,x,sizeof(a));}
    void sup(){sort(a+1,a+n+1,less<int>());}
    void sdn(){sort(a+1,a+n+1,greater<int>());}
    bool nexp(){return next_permutation(a+1,a+n+1);}
    int lb(int x){return lower_bound(a+1,a+n+1,x)-a;}
    int ub(int x){return upper_bound(a+1,a+n+1,x)-a;}
    void pf(){fup(i,1,n)printf("%d%c",a[i],i==n?'\n':' ');}
    ia operator+(const ia& b)
    {
        ia<__>c(max(n,b.n));c.mem(0);
        fo(i,c)c[i]=a[i]+b.a[i];
        while(!c[c.n] && c.n>1)c.n--;
        return c;
    }
    ia operator-(const ia& b)
    {
        ia<__>c(max(n,b.n));c.mem(0);
        fo(i,c)c[i]=a[i]-b.a[i];
        while(!c[c.n] && c.n>1)c.n--;
        return c;
    }
    ia operator*(const ia& b)
    {
        ia<__>c;c.mem(0);
        fo(i,(*this))fo(j,b)
            c.n=max(c.n,i+j-1),c[i+j-1]+=a[i]*b.a[j];
        return c;
    }
};

const int __=100005;
char a[__];

int main()
{
    scanf("%s",a+1);
    int len=strlen(a+1);
    int x=(len+1)/2,y=len/2+1;
    int ans=x;
    if(len&1)x--,y++;
    for(;x>=1 && y<=len;x--,y++)
        if(a[x]==a[x+1] && a[y]==a[y-1])
            ans++;
        else break;
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
 
    // input table size
    int r,c;
    cin>>r>>c;

    // input table data
    vector<vector<int>> table(r+1,vector<int>(c+1));
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>table.at(i).at(j);
        }
    }

    // make output table data
    for(int i=0;i<r;i++){
        int sum_raw=0;
        for(int j=0;j<c;j++){
            sum_raw+=table.at(i).at(j);
        }
        table.at(i).at(c)=sum_raw;
    }
    for(int j=0;j<c+1;j++){
        int sum_column=0;
        for(int i=0;i<r;i++){
            sum_column+=table.at(i).at(j);
        }
        table.at(r).at(j)=sum_column;
    }

    // output table data
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            if(j==c)
                cout<<table.at(i).at(j);
            else
               cout<<table.at(i).at(j)<<' ';
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, x[101], y[101], h[101];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> h[i];
	}
	
	bool b = 0;
	int s;
	for(s = 0; s < n; s++){
		if(h[s] != 0) break;
	}
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 101; j++){
			int H = h[s] + abs(i-x[s]) + abs(j-y[s]);
			b = 0;
			for(int k = 0; k < n; k++){
				if(h[k] != max(H - abs(i-x[k]) - abs(j-y[k]), 0)){
					b = 1;
					break;
				}
			}
			if(!b && H > 0){
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

N, M = map(int, input().split())
A = list(map(int, input().split()))

h = []
for a in A:
    heappush(h, -a)
for _ in range(M):
    a = -heappop(h) // 2
    heappush(h, -a)

print(-sum(h))

Measured memory_bytes: 14180
#include <iostream>

typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    ll l, m, r;
    cin >> l;
    l--;
    for(int i=1; i<n; i++) {
        cin >> m;
        if(l<m) {
            m--;
            l=m;
        } else if(l>m) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int main(){
	int n;
	cin>>n;
	
	
	rep(i,n){
		map<string,int> ans;
		string str;
		cin>>str;
		
		reps(j,1,str.size()){
			string sb1 = str.substr(0,j);
			string sb2 = str.substr(j,str.size()-j);
			
			
			string resb1 = sb1;
			reverse(resb1.begin(),resb1.end());
			string resb2 = sb2;
			reverse(resb2.begin(),resb2.end());
			
			ans[sb1+sb2]=1;
			ans[resb1+sb2]=1;
			ans[sb1+resb2]=1;
			ans[resb1+resb2]=1;
			
			ans[sb2+sb1]=1;
			ans[resb2+sb1]=1;
			ans[sb2+resb1]=1;
			ans[resb2+resb1]=1;
		}
		printf("%d\n",ans.size());
	}
	
	
}

/*
1
abcd

*/

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

int main(){
    long long N,ans=0,r=0,g=0,b=0;
    cin >> N;
    vector<char> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    for(int i=0;i<N;i++){
        if(vec[i]=='R')
        r++;
        if(vec[i]=='G')
        g++;
        if(vec[i]=='B')
        b++;
    }
    for(int j=0;j<N;j++){
        for(int k=j+1;k<N;k++){
            if(vec[k+k-j]=='R'||vec[k+k-j]=='G'||vec[k+k-j]=='B'){
            if(vec[j]!=vec[k]&&vec[k]!=vec[k+k-j]&&vec[k+k-j]!=vec[j])
            ans++;
        }
        }
    }
    cout << r*g*b-ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> mochis(0);
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(i == 0){
      mochis.push_back(x);
      continue;
    }
    for(int j=0;j<mochis.size();j++){
      if(mochis[j]==x){
        mochis.erase(mochis.begin()+j);
        continue;
      }
    }
    mochis.push_back(x);
  }
  cout << mochis.size() << endl;
}

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

const int N = 2020;

typedef long long ll;

int n, MOD, dp[3*N][6*N];

void add(int &x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

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

    for (int bal = 0; bal <= 3*n; bal++) dp[0][3*N+bal] = 1; 

    for (int x = 1; x <= 3*n; x++) {
        for (int bal = -3*n+x; bal <= 3*n-x; bal++) {
            dp[x][3*N+bal] = 0;
            ll ways = 1;
            for (int y = 1; y <= min(x,3); y++) {
                int dbal = 0;
                if (y == 1) dbal = 1;
                if (y == 2) dbal = -1;
                add(dp[x][3*N + bal], ways * dp[x-y][3*N + bal + dbal] % MOD);
                ways *= x-y;
            }
        }
    }
    cout << dp[3*n][3*N] << endl;
    return 0;
}


Measured memory_bytes: 284928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//入力データを変数で受け取る
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		//入力データを処理して、結果を出力
		int x = a * b;
		int y = c * d;

		if(x >= y) {
			System.out.println(x);
		} else {
			System.out.println(y);
		}

	}
}



Measured memory_bytes: 35540
#include <bits/stdc++.h>
#include <ext/rope>

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max4(a, b, c, d) max(max(a, b), max(c, d))

#define count_one(a) __builtin_popcount(a) // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i) __builtin_parity(i)      //even parity 0 and odd parity 1
#define blz(a) __builtin_clz(a)            //Returns the number of leading zeroes in a number(a)
#define btz(a) __builtin_ctz(a)            //Returns the number of trailing zeroes in a number(a)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * (b / gcd(a, b)))

#define pb push_back
#define PI M_PI
#define endl "\n"
#define sc scanf
#define pf printf

#define ll long long
#define ull unsigned long long

#define W(t) while (t--)
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(a, b) for (int i = a; i <= b; i++)
#define repit(it, type) for (it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

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

    ll p, i, cnt = 0, ans = 0;

    p = 2;

    while (n % p == 0) //finding the numbers divisors where divisors are power of two
    {
        n /= p;
        cnt++;
        p *= 2;
    }
    ans += cnt;

    while (n % 2 == 0)
        n /= 2;

    for (i = 3; i <= sqrt(n); i += 2)
    {
        cnt = 0;
        p = i;

        while (n % p == 0)
        {
            n /= p;
            cnt++;
            p *= i;
        }
        while (n % i == 0)
            n /= i;
        ans += cnt;
    }
    if (n > 1)
        ans++;

    cout << ans << endl;
}

Measured memory_bytes: 3668
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn criterion(k: usize, i: usize, a: &Vec<usize>) -> bool {
    if i == 0 {
        return true;
    }
    if i == a.len() + 1 {
        return false;
    }
    let mut dp = vec![false; k];
    dp[0] = true;
    for j in 0..a.len() {
        if i - 1 == j {
            continue;
        }
        for ki in (0..k).rev() {
            if ki >= a[j] && dp[ki - a[j]] {
                dp[ki] = true;
                if ki >= k - a[i - 1] {
                    return false;
                }
            }
        }
    }
    true
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, k) = (v[0], v[1]);
    let mut a = read_vec::<usize>();
    a.sort();
    let a = a.into_iter().take_while(|&num| num < k).collect::<Vec<_>>();

    let mut lb = 0;
    let mut ub = a.len() + 1;
    while ub - lb > 1 {
        let mid = (ub + lb) / 2;
        if criterion(k, mid, &a) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    println!("{}", lb);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (B % A == 0) {
			System.out.println(A + B);
		} else {
			System.out.println(B - A);
		}
	}
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int A, B;

  cin >> A >> B;

  int ans = -1;
  for(int i = 1; i <= 1100; i++){

    int v8 = (i * 108) / 100 - i;
    int v10 = (i*110) / 100 - i;

    if(v8 == A && v10 == B){
      ans = i;
      break;
    }
  }

  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    if(N >= M){
        cout << 0 << endl;
        return 0;
    }
    vector<int> X(M),D(M-1);
    for(int i = 0; i < M; i++) cin >> X[i];
    sort(X.begin(),X.end());
    for(int i = 0; i < M-1; i++) D[i] = abs(X[i+1] - X[i]);
    sort(D.begin(),D.end());
    reverse(D.begin(),D.end());
    for(int i = 0; i < N-1; i++){
        D[i] = 0;
    }
    int ans = 0; 
    for(int i = 0; i < M-1; i++) ans += D[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iomanip>
#include <iostream>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 10000000;

using namespace std;

/** Problem0144 : Packet Transportation **/
int G[101][101];
int V;

int main()
{
	int r, k, t;
	
	rep(i, 101) rep(j, 101) G[i][j]=INF;
	
	
	cin >> V;
	rep(i, V) {
		cin >> r >> k;
		rep(j, k) {
			cin >> t;
			G[r-1][t-1]=1;
		}
	}
	
	// Warshall-Floyd法
	rep(k, V)
		rep(i, V)
			rep(j, V)
				G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
			
	
	int p, s, d, v;
	cin >> p;
	
	rep(i, p) {
		cin >> s >> d >> v;
		if (G[s-1][d-1] < v)
			cout << G[s-1][d-1]+1 << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
fun main() = Thread(null, ::abc172c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc172c() {
    val (n, m, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }
    val bList = readLine()!!.split(' ').map { it.toLong() }

    var takeB = m
    var timeSumA = 0L
    var timeSumB = bList.sum()
    var answer = 0

    for (takeA in 0..n) {
        while (timeSumA + timeSumB > k && takeB > 0) {
            timeSumB -= bList[takeB - 1]
            takeB--
        }

        if (timeSumA + takeB <= k) answer = Math.max(answer, takeA + takeB)

        if (takeA in aList.indices) timeSumA += aList[takeA]
    }

    println(answer)
}


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            Arrays.sort(a);

            int ans = 0;
            for (int i = n - 1; i >= 0; i--) {
                if ((n - 1 - i) % 2 == 0) {
                    ans += a[i];
                } else {
                    ans -= a[i];
                }
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#define re register
#define maxn 3005
#define mod 998244353
#define ll long long
using namespace std;
int n;
int two[maxn];
int x[maxn],y[maxn];

void init(){
    two[0]=1;
    for(re int i=1;i<=3000;i++){
        two[i]=(two[i-1]*2)%mod;
    }
}

int main(){
    init();
    scanf("%d",&n);
    for(re int i=1;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }
    ll ans=two[n]-n-1;
    for(re int i=1;i<=n;i++){
        for(re int j=i+1;j<=n;j++){
            int sum=0;
            for(re int k=j+1;k<=n;k++){
                if((x[i]-x[j])*(y[j]-y[k])==(y[i]-y[j])*(x[j]-x[k])){
                    sum++;
                }
            }
            ans=((ans-two[sum])%mod+mod)%mod;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let x = read(&mut stdin_lock, &mut buf, b' ');
    let y = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(x, y));
}

fn solve(x: u8, y: u8) -> u8 {
    x + y / 2
}

#[test]
fn example1() {
    assert_eq!(110, solve(81, 58))
}

#[test]
fn example2() {
    assert_eq!(31, solve(4, 54))
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int bigger = Math.max(A, B);
    int smaller = Math.min(A, B);
    ArrayList<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= smaller; i++) {
      if (bigger % i == 0 && smaller % i == 0) {
        list.add(i);
      }
    }
    Collections.sort(list, Collections.reverseOrder());
    System.out.println(list.get(C - 1));
  }
}


Measured memory_bytes: 21844
use std::io::Read;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut dishes: BinaryHeap<(isize, isize, isize)> = BinaryHeap::new();
    for _ in 0..n {
        let ai: isize = iterator.next().unwrap().parse().unwrap();
        let bi: isize = iterator.next().unwrap().parse().unwrap();
        dishes.push((ai + bi, ai, bi));
    }

    let mut takahashi: isize = 0;
    let mut aoki: isize = 0;
    for i in 0..n {
        let dish = dishes.pop().unwrap();
        if i % 2 == 0 {
            takahashi += dish.1;
        } else {
            aoki += dish.2;
        }
    }
    (takahashi - aoki).to_string()
}


Measured memory_bytes: 6460
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#include <numeric>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19
vector<vector<vector<double>>> mm(301, vector<vector<double>>(301, vector<double>(301, 0)));
int n;

double rec(int sushi3_sum, int sushi2_sum, int sushi1_sum){
    if(sushi3_sum == 0 && sushi2_sum == 0 && sushi1_sum == 0){
        return 0;
    }
    // cout << "OS" << endl;
    
    if(mm[sushi3_sum][sushi2_sum][sushi1_sum] != 0) return mm[sushi3_sum][sushi2_sum][sushi1_sum];
    int branch = 0;
    double ex = 0;

    if(sushi3_sum > 0){
        ex += (rec(sushi3_sum-1, sushi2_sum+1, sushi1_sum) + ((double)n / (sushi3_sum + sushi2_sum + sushi1_sum))) * sushi3_sum;
    }
    if(sushi2_sum > 0){
        ex += (rec(sushi3_sum, sushi2_sum-1, sushi1_sum+1) + ((double)n / (sushi3_sum + sushi2_sum + sushi1_sum))) * sushi2_sum;
    }
    if(sushi1_sum > 0){
        ex += (rec(sushi3_sum, sushi2_sum, sushi1_sum-1) + ((double)n / (sushi3_sum + sushi2_sum + sushi1_sum))) * sushi1_sum;
    }
    branch += sushi3_sum + sushi2_sum + sushi1_sum;

    ex /= branch;
    mm[sushi3_sum][sushi2_sum][sushi1_sum] = ex;
    // cout << sushi3_sum << '-' << sushi2_sum << '-' << sushi1_sum << ':' << ex << "手" << endl;

    return ex;
}

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

    cin >> n;
    vector<int> a(n);
    VCIN(a);

    int s3=0, s2=0, s1=0;
    for(auto i : a){
        switch(i){
        case 1: s1++; break;
        case 2: s2++; break;
        case 3: s3++; break;
        }
    }
    double ans = rec(s3, s2, s1);
    cout << fixed << setprecision(14) << ans << endl;

    // for(int i=0; i<3; i++){
    //     cout << "[" << i << "]:" << mm[i] << endl;
    // }

    return 0;
}

Measured memory_bytes: 216960
N,K=map(x->parse(Int,x),split(readline()))
R,S,P=map(x->parse(Int,x),split(readline()))
C=zeros(Int,N)
s=readline()
ans=0
for i=1:N
	if i<=K||s[i-K]!=s[i]||C[i-K]==0
		C[i]=1
		ans+=s[i]=='r'?P:s[i]=='s'?R:S
	end
end
println(ans)


Measured memory_bytes: 123008
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n,c=map(int,input().split())
D=[]
for i in range(c):
    D.append(list(map(int,input().split())))
G=[]
for i in range(n):
    a=list(map(int,input().split()))
    G.append([i-1 for i in a])
A=[]
B=[]
C=[]
for i in range(n):
    for j in range(n):
        d=(i+j)%3
        if d==0:
            A.append(G[i][j])
        elif d==1:
            B.append(G[i][j])
        else:
            C.append(G[i][j])
A=Counter(A);B=Counter(B);C=Counter(C)
cost=inf
for s in range(c):
    for t in range(c):
        if s==t:continue
        for r in range(c):
            if s==r or t==r:continue
            cost=min(cost, sum(D[i][s]*j for i,j in A.items())+sum(D[i][t]*j for i,j in B.items())+sum(D[i][r]*j for i,j in C.items()))
print(cost)

Measured memory_bytes: 8008
s = input()
odd_step = ['R', 'U', 'D']
even_step = ['L', 'U', 'D']
number_of_step = len(s)
result = False
for i in range(1, len(s)+1):
    if (i % 2 == 1 and s[i-1] in odd_step) or (i % 2 == 0 and s[i-1] in even_step):
        result = True
    else:
        result = False
        break
if result:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long a[100005],b,c[100005],d[100005],ans;
int main()
{
	cin>>b;
	for(int i=0;i<b;i++)
	cin>>a[i];
	c[0]=a[0];
	d[b-1]=a[b-1];
	for(int i=1;i<b-1;i++)
	c[i]=__gcd(a[i],c[i-1]);
	for(int i=b-2;i>0;i--)
	d[i]=__gcd(a[i],d[i+1]);
	ans=max(ans,d[1]);
	ans=max(ans,c[b-2]);
	for(int i=1;i<=b-2;i++)
	ans=max(ans,__gcd(c[i-1],d[i+1]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560