akhauriyash/Code-Regression huggingface dataset:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    v = map(int, input().split())
    c = map(int, input().split())
    l = sorted([i[0]-i[1] for i in zip(v,c) if (i[0]-i[1]) > 0 ])
    print(sum(l))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
while 1:
    n = input()
    if n == 0:
        break
    field = [[0] * n for _ in xrange(n)]
    cnt = 1
    x, y = n / 2, n / 2 + 1
    field[y][x] = cnt
    cnt += 1
    while cnt <= n ** 2:
        y = (y + 1) % n
        x = (x + 1) % n
        while field[y][x] > 0:
            y = (y + 1) % n
            x = (x - 1 + n) % n
        field[y][x] = cnt
        cnt += 1

    for i in xrange(n):
        print ''.join(map("{0:4}".format, field[i]))

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

typedef long long ll;

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

    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i=a;i<=b;i++){
        if(c%i==0) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

long long n,a,b,ans = 0;

void solve();

int main(){
    cin >> n >> a >> b;
    solve();
    if(ans > 0)cout << "Alice" << endl;
    else if(ans < 0)cout << "Borys" << endl;
    else cout << "Draw" << endl;
    return 0;
}

void solve(){
    long long d = b - a - 1;
    if(d % 2)ans = 1;
    else ans = -1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
#define M_E 2.71828182845904523536
#define M_PI 3.14159265358979323846
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    ll n;
    cin>>n;
    ll res=0;
    repA(i,1,n)
    {
        if(i%15!=0 && i%3!=0 && i%5!=0)
            res+=i;

    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

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

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    string ans = "NG";
    for (ll i = A; i <= B;i++) {
        if (i % K == 0) {
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A), q(B), r(C);
  rep(i, A) { cin >> p[i]; }
  rep(i, B) { cin >> q[i]; }
  rep(i, C) { cin >> r[i]; }

  sort(RALL(p));
  sort(RALL(q));

  p.erase(p.begin() + X, p.end());
  q.erase(q.begin() + Y, q.end());

  r.insert(r.end(), all(p));
  r.insert(r.end(), all(q));

  sort(RALL(r));
  int ans = 0;
  rep(i, X+Y){
    ans += r[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 6000
import sys

#+++++
		
def main():
	n, d = map(int, input().split())
	nn=n
	cc=0
	while nn > 0:
		cc+=1
		nn+=-1*(1+2*d)
	print(cc)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define loop(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define pb push_back
#define lim 2750131
using namespace std;
const ll INF=5e18;
ll n,a,b,c,d;
map<ll,ll> mp;
ll recur(ll curr)
{ll i;
	if(!curr)
		return 0;
	if(curr==1)
		return d;
	if(mp.count(curr))
		return mp[curr];
	vector<ll> v{2,3,5};
	vector<ll> cost{a,b,c};
	ll best=INF;
	if(curr<INF/d)
	best=curr*d;
	loop(i,0,3)
	{if(curr%v[i]==0)
		best=min(best,cost[i]+recur(curr/v[i]));
		else
		{
			best=min(best,cost[i]+d*(v[i]-curr%v[i])+recur(curr/v[i]+1));
             best=min(best,cost[i]+d*(curr%v[i])+recur(curr/v[i]));
		}
	}
		mp[curr]=best;
		return best;
		 
}
int main()
{ll t;
	cin>>t;
	while(t--)
	{
		cin>>n>>a>>b>>c>>d;
	cout<<recur(n)<<endl;
	mp.clear();	
		
	}return 0;
}
             

Measured memory_bytes: 4340
#include <stdio.h>
int main(){
    int i,j,person;
    while(scanf("%d",&i) != EOF){
        person=1;
        for(j=0;j<i-1;j++){
            if(person == 39){
                person=1;
            }
            else{
            person++;
            }
        }
        if(person > 0 && person <= 9){
            printf("3C0%d\n",person);
        }
        else{
        printf("3C%d\n",person);
        }
    }
    return (0);
}

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

int N;
typedef pair<int, int> P;
P a[100001];

int main(void) {
    cin >> N;
    int n;
    rep(i, N) {
    scanf("%d", &n);
        if(i%2==0) a[i] = P(n, 0); 
        else a[i] = P(n, 1);
    }
    sort(a, a+N);
    int ans = 0;
    rep(i, N) {
        if(i%2 != a[i].second == 1) ans++;
    }

    cout << ans/2 << endl;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}


int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long double n, k;
    cin >> n >> k;

    long double tot = 0;

    for(long double flip = 1; flip <= n; ++flip){
        long double expected = 1, c = flip;
        while(0 < c && c < k){
            c += c;
            expected *= 0.5;
        }
        tot += expected;
    }

    cout << setprecision(10) << fixed << tot / n;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define ulli unsigned lli
#define ld long double
#define pb push_back
#define mp make_pair
#define bp pop_back
#define vi vector<int>
#define vvi vector< vector<int> >
#define vli vector<lli>
#define vvli vector< vector<lli> >
#define pii pair <int, int>
#define pli pair <lli, lli>
#define forn(i,n) for(i=0;i<n;i++)
#define FORN(i,k,n) for(i=k;i<n;i++)
#define rof(i,k,n) for(i=k;i>=n;i--)
#define wh(k) while(k--)
#define mod 1000000007
#define set(a,s) memset(a,s,sizeof(a))

int main()
{
	fast;
	lli n;
	cin>>n;
	cout<<(n-1)*n/2<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        string s,t; cin >> s >> t;
        cout << t+s << endl;
    }
}


Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
string str[10];
ll row[10],col[10];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    FAST
    cin>>n>>m>>x;
    for(i=0;i<n;i++)
    {
        cin>>str[i];
    }
    ll ans = 0;
    ll total  = n+m;
    for(i=0;i<(1<<total);i++)
    {
        memset(row,0,sizeof row);
        memset(col,0,sizeof col);
        for(j=0;j<n;j++)
        {
            if((1<<j) & i)
            {
                row[j] = 1;
            }
        }
        for(j=n;j<total;j++)
        {
            if((1<<j) & i)
            {
                col[j-n] = 1;
            }
        }
        y = 0;
        for(j=0;j<n;j++)
        {
            if(row[j])
                continue;
            for(k=0;k<m;k++)
            {
                if(col[k])
                continue;
                if(str[j][k]=='#')
                {
                    y++;
                }
            }
        }
        if(y==x)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3604
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
string S = "";

int main() {
	cin >> S;
	if(S == "ABC") {
		cout << "ARC\n";
	}
	else {
		cout << "ABC\n";
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)
#define DBG(x) cerr << #x << ": " << x << "\n"

using namespace std;
typedef long long lint;
const int MOD = 1000000007;


int main() {

	cin.tie(0);
	
	int N;
	cin >> N;

	cout << N * (N + 1) / 2;

	return 0;
}

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

int main(void)
{
    int H,W,K;

    cin >> H >> W >> K;

    int mm[6][6] = {};
    int sumn = 0;

    for(int i = 0; i < H; ++i)
    {
        for(int j = 0; j < W; ++j)
        {
            char tmp;
            cin >> tmp;
            if(tmp =='.')
            {
                mm[i][j] = 0;
            }
            else
            {
                mm[i][j] = 1;
                ++sumn;
            }
        }
    }

    int ans = 0;

    for(int bit = 0; bit < (1<<(H+W)); ++bit)
    {
        int kt = sumn;
        for(int i = 0; i < H; ++i)
        {
            if(bit & (1<<i))
            {
                for(int q = 0; q < W; ++q)
                {
                    if(mm[i][q] == 1) --kt;
                }    
            }
        }
        for(int j = 0; j < W; ++j)
        {
            if(bit & (1<<(j+H)))
            {
                for(int q = 0; q < H; ++q)
                {
                    if(mm[q][j] == 1) --kt;
                }
            }
        }
        for(int i = 0; i < H; ++i)
        {
            for(int j = 0; j < W; ++j)
            {
                if((bit & (1<<i)) && (bit & (1<<(j+H))))
                {
                    if(mm[i][j] == 1) ++kt;
                }
            }
        }
        if(kt == K) ++ans;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
ll dp[2][300][300];
int main(){
	int N,M;
	cin>>N>>M;
	dp[0][0][0]=1;
	rep(i,M){
		rep(a,N) rep(x,N) dp[1-i%2][a][x]=0;
		rep(a,N) rep(x,N) if(dp[i%2][a][x]){
			ll& val=dp[i%2][a][x];
			if(a!=N-1) add(dp[1-i%2][a+1][x],val);
			add(dp[1-i%2][a][a],val*(x+1));
			add(dp[1-i%2][a][x],val*(a-x));
		}
	}
	ll ans=dp[M%2][N-1][N-1];
	rep1(i,N-1) ans=ans*i%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<string> yobi ={"Monday", "Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};

int main(){
	
	int m, d;
	while(cin >> m >> d, m, d){
		ll cnt = 3;
		rep(i, m-1) cnt += days[i];
		cnt += (d-1);
		cout << yobi[cnt%7] << endl;
	}
	


	
	return 0;
}

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

int max(int cnt, int arr[]);
int prime(int n, int arr[]);


int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);
  int targets[n];
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &targets[i]);
  }
  printf("%d\n", prime(n, targets));
  return 0;
}

int prime(int n, int targets[]) {
  int m = max(n, targets) + 1;
  int s = (int) sqrt((double) m);
  char *arr = (char *)malloc(sizeof(char) * m);
  memset(arr, 0, sizeof(char) * m);
  int i,j;
  for (i = 2; i <= s; i++) {
    if (arr[i] == 0) {
      for (j = i + i; j < m; j += i) {
        if (arr[j] == 0) {
          arr[j] = 1;
        }
      }
    }
  }
  int ret = 0;
  for (i = 0; i < n; i++) {
    if (arr[targets[i]] == 0) {
      ret++;
    }
  }
  free(arr);
  return ret;
}

int max(int cnt, int arr[]) {
  int m = -1;
  int i;
  for (i = 0; i < cnt; i++) {
    if (arr[i] > m) {
      m = arr[i];
    }
  }
  return m;
}


Measured memory_bytes: 99184
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        }
        if(count>2){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
    
}


Measured memory_bytes: 23764
while true
  n = gets.chomp.to_i
  break if n == -1

  x = 1.0
  y = 0.0

  (n - 1).times do
    th = Math.atan2(y, x) + Math::PI * 0.5
    x += Math.cos(th)
    y += Math.sin(th)
  end

  printf("%.2f\n", x)
  printf("%.2f\n", y)
end

Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    int n,k;
    cin>>n>>k;
    vi a(n);
    c(a,n);
    vi dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++)
    for(int j=1;j<=k;j++)
    if(i-j>=0)
    dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    cout<<dp[n-1];
    
    
    return 0;
}

Measured memory_bytes: 4748
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {

    string s;
    cin >> s;

    int ans = 0;
    int k = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
            k++;
            ans = max(ans, k);
        } else {
            k = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int res=0, flag=0;
    char ch;
    if((ch=getchar())=='-') flag=1;
    else if(ch>='0'&&ch<='9') res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')  res=res*10+(ch-'0');
    return flag?-res:res;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=2005;
//Code begin...

int pri[N], p=0, fac[N];
bool isprim[N];
inline void get_prim()
{
    int i, j, k;
    for (i=0; i<N; ++i) isprim[i]=1;
    for(i=2; i<N; ++i){
        if(isprim[i]) pri[p++]=i;
        for(j=0; j<p && i*pri[j]<N; ++j){
            k=pri[j]*i; isprim[k]=0;
            if(i%pri[j]==0) break;
        }
    }
}
int main ()
{
    get_prim();
    int n;
    LL ans=1;
    scanf("%d",&n);
    FOR(i,2,n) {
        int temp=i;
        for (int j=0; pri[j]<=temp; ++j) while (temp%pri[j]==0) temp/=pri[j], fac[j]++;
    }
    FO(j,0,p) ans=ans*(fac[j]+1)%MOD;
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
	bool jud[8] = {0};
	int n; cin >> n;
	int num = 0;
	for(int i = 0; i < n; ++i){
		int a; cin >> a;
		if(1 <= a && a <= 399) jud[0] = 1;
		else if(400 <= a && a <= 799) jud[1] = 1;
		else if(800 <= a && a <= 1199) jud[2] = 1;
		else if(1200 <= a && a <= 1599) jud[3] = 1;
		else if(1600 <= a && a <= 1999) jud[4] = 1;
		else if(2000 <= a && a <= 2399) jud[5] = 1;
		else if(2400 <= a && a <= 2799) jud[6] = 1;
		else if(2800 <= a && a <= 3199) jud[7] = 1;
		else ++num;
	}
	int ans = 0;
	for(int i = 0; i < 8; ++i){
		ans += jud[i];
	}
	cout << (ans ? ans : 1) << " " << ans + num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string S; cin >> S;
    int N = S.size() + 1;
    int count = 1;
    vector<pair<char, int> > v;
    repp(i,1,N-1) {
        if (S[i-1] == S[i]) ++count;
        else {
            pair<char, int> p;
            p.first = S[i-1];
            p.second = count;
            v.push_back(p);
            count = 1;
        }
    }
    pair<char, int> p;
    p.first = S[N-2];
    p.second = count;
    v.push_back(p);
    p.first = S[N-2] == '<' ? '>' : '<';
    p.second = 1;
    v.push_back(p);

    ll res = 0;
    int s = 1;
    repp(i,0,v.size()) {
        pair<char, int> x = v[i];
        if (x.first == '<') {
            repp(i,0,x.second) {
                res += i;
            }
            s = x.second;
        } else {
            repm(i, x.second, 0) {
                res += i;
            }
            if (x.second < s) res += s - x.second;
        }
    }
    cout << res << endl;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b, c, sum;
  string result;
  result = "NO";
  cin >> a >> b >> c;
  FOR(i, 1, 101) {
    if((a * i) % b == c) result = "YES";
  }
  cout << result << endl;
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> coin(m);
    for (int i = 0; i < m; ++i) {
        cin >> coin[i];
    }
    vector<vector<int>> dp(30, vector<int>(60000, 1001001001));
    dp[0][0] = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j <= n; ++j) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + coin[i]] = min(dp[i + 1][j + coin[i]], dp[i + 1][j] + 1);
        }
    }
    cout << dp[m][n] << endl;
}



Measured memory_bytes: 10228
s = input()

def mayBeMonth(n):
  if 1 <= n <= 12:
    return True
  else:
    return False

first = int(s[:2])
second = int(s[2:])

if mayBeMonth(first) and mayBeMonth(second):
  print("AMBIGUOUS")
elif mayBeMonth(first) and not mayBeMonth(second):
  print("MMYY")
elif not mayBeMonth(first) and mayBeMonth(second):
  print("YYMM")
else:
  print("NA")

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

#define all(c) (c).begin(),(c).end()
#define FOR(i, x, n) for(int i = x; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) #x << "=" << (x) << "(L" << __LINE__ << ")"
#define show(x) cout << #x << "=" << x << endl
#define show2(x,y) cout << #x << "=" << x << "," << #y << "=" << y <<  endl
#define show3(x,y,z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z <<  endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

const ld eps = 1e-9, pi = acos(-1.0);
const ld EPS = 1e-8;
const int INF = INT_MAX/2;
const ll LINF = LONG_MAX/2;
const int MOD = 1000000007;

template<class T> inline void amin(T &a, const T &b) { if (b<a) a=b; }
template<class T> inline void amax(T &a, const T &b) { if (a<b) a=b; }

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

int main(){
    
    ll n;
    cin >> n;
    
    vector<ll> p;
    
    rep(i,n){
        ll t;
        cin >> t;
        p.emplace_back(t);
    }
    
	int ans = 0;
    //cout << fixed << setprecision(10);
    FOR(i,1,n-1){
        if((p[i-1]>=p[i] && p[i]>=p[i+1]) ||(p[i-1]<=p[i] && p[i]<=p[i+1])){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=611;
const int mod=1e9+7;
int n,k,a[maxn],b[maxn],match[maxn],ff[maxn];

bool ok[maxn][maxn];
int dp[maxn][maxn],sum[maxn][maxn];

int main()
{
	ff[0]=1;
	for(int i=2;i<maxn;i+=2)ff[i]=(LL)ff[i-2]*(i-1)%mod;
	
	get2(n,k);
	for(int i=1;i<=k;i++)
	{
		get2(a[i],b[i]);
		match[a[i]]=b[i];
		match[b[i]]=a[i];
	}
	n*=2;
	for(int l=1;l<=n;l++)for(int r=l;r<=n;r++)
	{
		ok[l][r]=1;
		for(int i=l;i<=r;i++)if(match[i]&&(match[i]<l||match[i]>r))ok[l][r]=0;else if(!match[i])sum[l][r]++;
		if(sum[l][r]%2)ok[l][r]=0;
	}
	int ans=0;
	for(int l=n;l>=1;l--)for(int r=l;r<=n;r++)if(ok[l][r])
	{
		dp[l][r]=ff[sum[l][r]];
		for(int i=l;i<r;i++)dp[l][r]=(dp[l][r]+(LL)(mod-dp[l][i])*ff[sum[i+1][r]])%mod;
		ans=(ans+(LL)dp[l][r]*ff[n-k-k-sum[l][r]])%mod;
	}
	printendl(ans);
	return 0;
}

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

yen = 1000
for i in range(1, n):
	if a[i-1] < a[i]:
		stock = yen // a[i-1]
		yen -= stock * a[i-1]
		yen += stock * a[i]

print(yen)

Measured memory_bytes: 61784
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  t = "CODEFESTIVAL2016";
  REP(i,16){
    if(s[i]!=t[i]) x++;
  }
  OUT(x);
}

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

class Solution {
    public:
        int sol(){
            int n,x,y,z;
            cin>>n;
            vector<int> a;
            vector<int> b;
            vector<int> c;
            for(int i=0;i<n;i++){
                cin>>x>>y>>z;
                a.push_back(x);
                b.push_back(y);
                c.push_back(z);
            }
            int p,q,r,new_p,new_q,new_r;
            p = a[0];
            q = b[0];
            r = c[0]; 
            for(int i=1;i<n;i++){
                new_p = a[i] + max(q,r);
                new_q = b[i] + max(r,p);
                new_r = c[i] + max(p,q);
                p = new_p;
                q = new_q;
                r = new_r;
            }
            return max(max(p,q),r);
        }
};

int main(){
    Solution test;
    cout<<test.sol();
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
const int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int k;cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}


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

int gcd(int a , int b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  int g = gcd(b,a%b);
  return g;
}

int main(){
  int N,ans=1;
  cin >> N;
  vector<int> A(N),Gl(N,-1),Gr(N,-1);
  for(int i=0;i<N;i++) cin >> A[i];
  
  Gl[0] = A[0];
  for(int i=1;i<N;i++) Gl[i] = gcd(A[i],Gl[i-1]);
  Gr[N-1] = A[N-1];
  for(int i=N-2;i>=0;i--) Gr[i] = gcd(A[i],Gr[i+1]);
  
  ans = max(Gr[1],Gl[N-2]);
  for(int i=0;i<N-2;i++) ans = max(ans,gcd(Gl[i],Gr[i+2]));
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#B

import numpy as np
D = int(input())
C = list(map(int,input().split()))
S = np.empty((D,26))
for i in range(D):
    l = list(map(int,input().split()))
    for j in range(26):
        S[i][j] = l[j]
        
#開催日時の記録
R = np.zeros(26)

sc = 0

#与えられたtでスコアを計算
for i in range(1,D+1):
    
    #ランダムに開催するコンテストを選ぶ
    con = int(input()) - 1
    
    #スコア計算
    #コンテスト開催による上昇
    sc += S[i-1][con]
    R[con] = i
    
    #コンテスト非開催による減少
    for j in range(26):
        sc -= C[j]*(i-R[j])
        
    print(int(sc))

Measured memory_bytes: 26992
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)

func next() int {
  sc.Scan()
  i, _ := strconv.Atoi(sc.Text())
  return i
}

func main() {
  sc.Split(bufio.ScanWords)
  n := next()
  tako := make([]int, n, n)
  takoSum := 0
  ans := 0

  for i := 0; i < n; i++ {
    tako[i] = next()
    takoSum += tako[i]
  }
  
  for i := 0; i < n; i++ {
    takoSum -= tako[i]
    ans += takoSum * tako[i]
  }
  fmt.Println(ans)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<string> data = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int num;
    rep(i,7){
        if(s == data[i]){
            num = i;
            break;
        }
    }
    cout << 7 - num << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        final int A = sc.nextInt();
        final int B = sc.nextInt();

        int ans = 0;

        for (int x = A; x <= B; x++) {
            char[] cs = String.valueOf(x).toCharArray();
            if (cs[0] == cs[4] && cs[1] == cs[3]) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 30804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> ls(n);
  int maxl = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    ls.at(i) = l;
    sum += l;
    if (l > maxl) { maxl = l; }
  }
  if (maxl < (sum - maxl)) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

Measured memory_bytes: 256
# 1: O(N*digit(A))
if False:
    B=[int(i) for i in input().split()]
    N=int(input())
    rep={}
    for i,b in enumerate(B):
        rep[str(b)]=str(i)
    # print(rep)
    ans=[]
    for _ in range(N):
        a=input()
        num=''
        for d in a:
            num+=rep[d]
        ans.append((a,int(num)))
    ans.sort(key=lambda x: x[1])
    for i in range(N): print(ans[i][0])

# 2: 366**2
if False:
    N=int(input())
    S=[tuple(map(int,input().split('/'))) for _ in range(N)]
    if len(S)>=366: print(366)
    elif N==0: print(2)
    else:
        cal=[[] for m in range(12)]
        day=6 #0-6: 0-MON
        for m in range(12):
            if m+1==2: e=29
            elif m+1 in (4,6,9,11): e=30
            else: e=31
            for d in range(1,e+1):
                cal[m].append([d,day,day in (5,6)])
                day=(day+1)%7
        for m,d in S:
            m-=1
            d-=1
            while cal[m][d][2]:
                if d+1<len(cal[m]): d+=1
                else:
                    m+=1
                    m%=12
                    d=0
                if (m,d)==(11,30): break
            cal[m][d][2]=True
        ans=-1
        cnt=0
        for m in range(12):
            for d in range(len(cal[m])):
                if cal[m][d][2]:
                    cnt+=1
                else:
                    ans=max(ans,cnt)
                    cnt=0
        ans=max(ans,cnt)
        print(ans)
        # print(cal[11])

#ARC036-B
if False:
    N=int(input())
    H=[int(input()) for _ in range(N)]
    if N==1: print(1); exit()
    ans=0
    cnt=2
    prev=1 if H[0]<H[1] else 0 #1:<,0:>
    for i in range(1,N-1):
        tmp=1 if H[i]<H[i+1] else 0
        if prev<tmp:
            ans=max(ans,cnt)
            cnt=2
        else:
            cnt+=1
        prev=tmp
    ans=max(ans,cnt)
    print(ans)

#D2019PC-C
if False:
    N=int(input())
    S=[input() for _ in range(N)]
    ans=0
    cnt={'BA':0,'BX':0,'XA':0}
    for s in S: ans+=s.count('AB')
    for s in S:
        l=s[0]
        r=s[-1]
        if l=='B' and r=='A': cnt[l+r]+=1
        elif l=='B': cnt[l+'X']+=1
        elif r=='A': cnt['X'+r]+=1 
    if cnt['BA']:
        ans+=cnt['BA']-1
        if cnt['BX'] and cnt['XA']:
            ans+=min(cnt['BX']-1,cnt['XA']-1)+2
        else:
            ans+=int(bool(cnt['BX']))+int(bool(cnt['XA']))
    else:
        ans+=min(cnt['BX'],cnt['XA'])
    print(ans)

#6DQ-A
if True:
    N=int(input())
    M=[input().split() for _ in range(N)]
    X=input()
    for i,m in enumerate(M):
        s,t=m
        if s==X:
            I=i+1
            break
    print(sum(int(t) for s,t in M[I:]) if I!=N else 0)
            

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18;                    //1*10^18
const double PI = 3.141592653589793238; //18桁
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

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

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll n, num = 0;
  cin >> n;
  vector<ll> a(n + 1), saidai(n + 1);
  for (i = 0; i < n + 1; i++)
  {
    cin >> a[i];
  }

  saidai[n] = 0;
  for (i = n - 1; i >= 0; i--)
  {
    saidai[i] = saidai[i + 1] + a[i + 1];
  }

  num = min((ll)1, saidai[0] + a[0]);
  for (i = 0; i < n + 1; i++)
  {
    num -= a[i];
    if (num < 0)
    {
      cout << -1;
      return 0;
    }
    ans += a[i] + num;
    num = min(num * 2, saidai[i + 1] + a[i + 1]);
  }
  cout << ans << endl;
}


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

#define MAXN 100005
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

int N, W;
int dp[MAXN];
int w[105], v[105];

signed main() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= N; i++) {
        for (int j = W; j >= w[i]; j--) {
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
    }
    cout << *max_element(dp, dp+W+1) << endl;
    return 0;
}

Measured memory_bytes: 1024
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<f64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let p_vec = input_vec();
    let mut dp = vec![vec![0f64; (n+1)]; (n+1)];
    dp[0][0] = 1f64;
    for i in 1..(n+1) {
        for j in 0..(n+1) {
            if j == 0 {
                dp[i][j] = dp[i-1][j] * (1f64 - p_vec[i - 1]);
                continue;
            }
            dp[i][j] = dp[i-1][j] * (1f64 - p_vec[i - 1]) + dp[i-1][j-1] * p_vec[i - 1];
        }
    }
    let mut sum = 0f64;
    for j in (n/2 + 1)..(n+1) {
        sum += dp[n][j];
    }
    println!("{}", sum);
}


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

int A, B;

int main() {
    cin >> A >> B;

    int ans = 0;
    int cnt = 1;
    while (cnt < B) {
        cnt--;
        cnt += A;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


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

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 単項演算子
	constexpr ModInt& operator++()
	{
		if (integer_ + 1 == mod_) integer_ = 0;
		else integer_++;
		return *this;
	}

	constexpr ModInt& operator--()
	{
		if (integer_ == 0) integer_ = mod_ - 1;
		else integer_--;
		return *this;
	}

	constexpr ModInt operator+()
	{
		return *this;
	}

	constexpr ModInt operator-()
	{
		if (integer_ == 0) return ModInt(0ll);
		else return ModInt(mod_ - integer_);
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }

	constexpr ModInt getOne() const
	{
		return ModInt(1ll);
	}
	constexpr ModInt getZero() const
	{
		return ModInt(0ll);
	}

	static constexpr int64_t mod{mod_};
};
using Mint = ModInt<>;

int main()
{
	int N;
	scanf("%d", &N);
	constexpr int max_size{1'000'000};
	std::vector<int> prime(max_size);
	std::vector<int64_t> A(N);
	for (auto& e: A) scanf("%lld", &e);
	for (auto e: A)
	{
		for (int j{2}; j * j <= e; j++)
		{
			int count{};
			while (e % j == 0)
			{
				count++;
				e /= j;
			}
			prime[j] = std::max(prime[j], count);
		}
		if (e > 1) prime[e] = std::max(prime[e], 1);
	}
	Mint product{1}, ans{};
	for (int i{}; i < max_size; i++)
		for (int j{}; j < prime[i]; j++)
			product *= Mint(i);
	for (auto& e: A)
		ans += product / Mint(e);
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 4224
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author szawinis
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const int N = 2e5+1;

class TaskC {
	int n, m, cnt[N][2];
	bool removed[N];
	string s;
	vector<int> g[N];

public:
	TaskC() {
		memset(cnt, 0, sizeof(cnt));
		memset(removed, 0, sizeof(removed));
	}
	void solve(istream& cin, ostream& cout) {
		cin >> n >> m >> s;
		for(int i = 0, u, v; i < m; i++) {
			cin >> u >> v;
			--u, --v;
			g[u].push_back(v);
			g[v].push_back(u);
			++cnt[u][s[v] == 'B'];
			++cnt[v][s[u] == 'B'];
		}
		queue<int> q;
		for(int i = 0; i < n; i++) if(!cnt[i][0] || !cnt[i][1]) q.push(i), removed[i] = true;
		while(!q.empty()) {
			int u = q.front();
			q.pop();
			for(int v: g[u]) {
				--cnt[v][s[u] == 'B'];
				if(!removed[v] && (!cnt[v][0] || !cnt[v][1])) {
					q.push(v);
					removed[v] = true;
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < n; i++) ans += !removed[i];
		assert(ans || ans != 1);
		cout << (ans ? "Yes" : "No") << endl;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 12624