akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int,string>;

int main() {
int a,b,c;
cin >> a >> b >> c;
if(a+b == c || b+c == a || c+a==b) cout << "Yes" << endl;
else cout << "No" << endl ;
 }

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    if(n%10 == 7 || (n/10)%10 == 7 || (n/100) == 7)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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

int main(){
    int h, w; cin >> h >> w;
    vector <string> S(h);
    rep(i, h) cin >> S.at(i);

    vector <int> dx = {0, -1, 0, 1};
    vector <int> dy = {1, 0, -1, 0};
    deque <pair<int, int>> next_masu;

    int ans = 1;
    rep(i, h){
        rep(j, w){
            if (S.at(i).at(j) == '#') continue;
            vector <vector <int>> cnt(h, vector <int> (w, 1000000000));
            cnt.at(i).at(j) = 0;
            rep(k, 4){
                int n_i, n_j;
                n_i = i + dy[k];
                n_j = j + dx[k];
                if (n_i < 0 || n_i > h - 1 || n_j < 0 || n_j > w - 1) continue;
                if (S.at(n_i).at(n_j) == '#') continue;
                next_masu.push_back(make_pair(n_i, n_j));
                cnt.at(n_i).at(n_j) = 1;
            }

            while(!next_masu.empty()){
                auto now_masu = next_masu.front();
                next_masu.pop_front();
                rep(k, 4){
                int n_i, n_j;
                n_i = now_masu.first + dy[k];
                n_j = now_masu.second + dx[k];
                if (n_i < 0 || n_i > h - 1 || n_j < 0 || n_j > w - 1) continue;
                if (S.at(n_i).at(n_j) == '#') continue;
                if (cnt.at(n_i).at(n_j) <= cnt.at(now_masu.first).at(now_masu.second) + 1) continue;
                next_masu.push_back(make_pair(n_i, n_j));
                cnt.at(n_i).at(n_j) = cnt.at(now_masu.first).at(now_masu.second) + 1;

                ans = max(ans, cnt.at(n_i).at(n_j));
                }
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
ll lsum[200001],rsum[200001],sum[200002];
int main()
{
    ll i;
    ll n,k;
    cin>>n>>k;
    for(i=1;i<=n;i++)
        lsum[i]+=lsum[i-1]+i;
    for(i=n;i>=0;i--)
        rsum[i]+=rsum[i+1]+i;
    //cout<<(rsum[n-k+1]-lsum[k-1]+1)%100000009;
    for(i=1;i<=n+1;i++)
        sum[i]=rsum[n-i+1]-lsum[i-1]+1;
    for(i=2;i<=n+1;i++)
        sum[i]+=sum[i-1];
    cout<<(sum[n+1]-sum[k-1])%1000000007;
}


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

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    int n,W; cin>>n>>W; int v[n],w[n],dp[n+1][W+1]={};
    for (int i = 0; i < n; i++)cin>>v[i]>>w[i];
    int ans=0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= W; j++){
            if(j>=w[i])dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout<<dp[n][W]<<'\n';
}


Measured memory_bytes: 7148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

// セグメントツリー
template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

ll gcd(ll x, ll y){
  return y ? gcd(y, x%y) : x;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    SegTree<ll> seg(N,[](ll a, ll b){
        return gcd(a,b);
    },
    0);
    vector<ll> A(N);
    REP(i,N){
        cin>>A[i];
        seg.set(i,A[i]);
    }
    seg.build();

    ll res=0;
    REP(i,N){
        ll left = seg.get(0,i);
        ll right = seg.get(i+1,N);
        chmax(res,gcd(left,right));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define ll long long
#define pp prev_permutation
#define np next_permutation
#define pi acos(-1)
#define  all(v) (v).begin(),(v).end()
#define gcd(x,y)      __gcd(x,y);
#define lcm(x,y)      ( x / __gcd(x,y) ) * y
///---------------STL-------------------
#define b_s(v,n)    binary_search((v).begin(),(v).end(),n)  /// return bool
#define u_b(v,n)   upper_bound((v).begin(),(v).end(),n)    ///return pointer iterator
#define l_b(v,n)    lower_bound((v).begin(),(v).end(),n)   ///return pointer iterator
///---------------VECTOR-----------------
#define pb push_back
#define v_sort(v)  sort((v).begin(),(v).end())
#define rv_sort(v) sort((v).rbegin(),(v).rend())
#define  v_sum(v)  accumulate((v).begin(),(v).end(),0)
#define v_min(v)  *min_element(v.begin(),v.end())
#define v_max(v)  *max_element(v.begin(),v.end())
#define v_unique(v)     v.erase(unique(v.begin(),v.end()),v.end()); ///only for sorted vector.
///----------------STRING-----------------
#define get(s) getline(cin.ignore(),s)

using namespace std;

int main()
{
    ll tc=1,n,a,b,c,d,i,ans=0;
    vector<ll>v,v1;
   // cin>>tc;
    while(tc--)
    {
        cin>>n>>a;
        for(i=0; i<n; i++)
        {
               cin>>b;
               v.pb(b);
        }
        v_sort(v);
       for(i=0; i<a; i++)
              ans+=v[i];
       cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 3632
x = int(input(''))
if x  >=400 and x <= 599:
    print('8')
elif x >=600 and x <= 799:
    print('7')
elif x >=800 and x <= 999:
    print('6')
elif x >=1000 and x <= 1199:
    print('5')
elif x >=1200 and x <= 1399:
    print('4')
elif x >=1400 and x <= 1599:
    print('3')
elif x >=1600 and x <= 1799:
    print('2')
elif x >=1800 and x <= 1999:
    print('1')


Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#include <functional>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <set>
#include <queue>
#include <map>
using namespace std;
int main(){
	string s;
	string a("CODEFESTIVAL2016");
	cin>>s;
	int c=0;
	for(int i=0;i<16;i++){
		if(s[i]!=a[i]){
			c++;
		}
	}
	cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())

ans = ""
X = tx - sx
Y = ty - sy

for i in range(Y):
    ans += "U"
for i in range(X):
    ans += "R"
for i in range(Y):
    ans += "D"
for i in range(X):
    ans += "L"
ans += "L"

for i in range(Y+1):
    ans += "U"
for i in range(X+1):
    ans += "R"
ans += "D"
ans += "R"

for i in range(Y+1):
    ans += "D"
for i in range(X+1):
    ans += "L"
ans += "U"

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

void fuka(int);

int n;
int cnt=1;
int a[101][101],b[101],c[101],d[101];
int main(){
  int i,j,x,y,z;
  scanf("%d",&n);
  b[0]=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    for(j=0;j<y;j++){
      scanf("%d",&z);
      a[x-1][z-1]=1;
    }
  }

  for(i=0;i<n;i++){
    if(b[i]==0)fuka(i);
  }

  for(i=0;i<n;i++)printf("%d %d %d\n",i+1,c[i],d[i]);
  
  return 0;
}

void fuka(int x){
  int i;
  c[x]=cnt;
  cnt++;
  b[x]=1;
  for(i=0;i<n;i++){
    if(a[x][i]==1 && b[i]==0)fuka(i);
  }
  d[x]=cnt;
  cnt++;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int d; cin >> d;
  cout << "Christmas";
  for (int _ = 0; _ < 25 - d; ++_) cout << " Eve";
  cout << endl;
}

Measured memory_bytes: 256
s = str(input())
c1 = "Init"
c2 = "Init"
ans = "Yes"
for i in s:
    if c1 == "Init":
        c1 = i
    elif c1 == i:
        continue
    elif c2 == "Init":
        c2 = i
    elif c2 == i:
        continue
    else:
        ans = "No"
        break
if c2 == "Init":
    ans = "No"
print(ans)

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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

#define int long long

int n, m, r, d[201][201], a, b, c, ans = INF;
vector<int> p;
bool used[201];

int dfs(int v) {
    int ret = INF;

    used[v] = true;
    for (int i = 0; i < r; ++i) {
        if (!used[p[i]]) ret = min(ret, dfs(p[i]) + d[v][p[i]]);
    }
    used[v] = false;
    return (ret == INF ? 0 : ret);
}

signed main() {
    init();
    cin >> n >> m >> r;
    rep(i,n) rep(j,n) d[i][j] = (i == j ? 0 : INF);
    p.resize(r);
    rep(i,r) cin >> p[i], p[i]--;
    rep(i,m) {
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = d[b][a] = c;
    }

    rep(k,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    rep(i,r) ans = min(ans, dfs(p[i]));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
//トランプを並び替えるときに自然で思いつきやすいアルゴリズムのひとつ
//✕
#include <iostream>
using namespace std;

void trace(int A[], int n){
    int i;
    for (i=0; i<n; i++){
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
void insertion_sort(int A[], int n){ //n個の要素を含む0－オリジンの配列
    int v,i,j;
    for (i=1; i<n; i++){
        v = A[i];
        j = i-1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, n);
    }
}

int main(){
    int A[100+1],n,i,j; cin >> n; 
    for (i=0; i<n; i++) cin >> A[i];

    trace(A, n);
    insertion_sort(A,n);
}


Measured memory_bytes: 3088
n = int(input())
p = list(map(int, input().split()))
ans = 0
li = []

for i in range(1, n-1):
  mn = min(p[i-1], p[i], p[i+1])
  mx = max(p[i-1], p[i], p[i+1])
  if p[i]!=mn and p[i]!=mx:
    ans += 1
    
print(ans)

Measured memory_bytes: 9176
n = int(input())
a = list(map(int , input().split()))
b = []
for ai in a:
    b.append('{:0=30b}'.format(ai))

cnt = []
for j in range(30):
    tmp = 0
    for i in range(n):
        tmp += int(b[i][j])
    cnt.append(tmp)
ans = []
for bi in b:
    tmp = 0
    for i in range(30):
        idx = 29 + (-i)
        #print(idx)
        x = int(bi[i])
        if cnt[i] == 0:
            continue
        if cnt[i] % 2 == 0:
            tmp += x << idx
        else:
            if x == 0:
                tmp += 1 << idx
    ans.append(tmp)


#print(ans)
print(' '.join(map(str, ans)))

"""
0000010100
0000001011
0000001001
0000011000

0000011010
0000000101
0000000111
0000010110
"""

Measured memory_bytes: 148412
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

 // dinic
 struct max_flow {//V:頂点数 O(EV^2)だが実際はより高速
     struct edge { LL to, cap, rev; };
     int V;
     vector<vector<edge>> G;
     vector<int> itr, level;

     max_flow(int V) : V(V) { G.assign(V,vector<edge>()); }

     void add_edge(int from, int to, LL cap) {
         G[from].push_back((edge) {to, cap, (int) G[to].size()});
         G[to].push_back((edge) {from, 0, (int) G[from].size()-1});
     }
 //sからの最短距離をbfs計算
     void bfs(LL s) {
         level.assign(V,-1);
         queue<int> q;
         level[s] = 0; q.push(s);
         while (!q.empty()) {
             int v = q.front(); q.pop();
             for(auto &e: G[v]){
                 if (e.cap > 0 and level[e.to] < 0) {
                     level[e.to] = level[v] + 1;
                     q.push(e.to);
                 }
             }
         }
     }
 //増加パスをdfsで探索
     LL dfs(int v, LL t, LL f) {
         if (v == t) return f;
         for (int& i = itr[v]; i < (int) G[v].size(); ++i) {
             edge& e = G[v][i];
             if (e.cap > 0 and level[v] < level[e.to]) {
                 int d = dfs(e.to, t, min(f, e.cap));
                 if (d > 0) {
                     e.cap -= d;
                     G[e.to][e.rev].cap += d;
                     return d;
                 }
             }
         }
         return 0;
     }

     LL run(int s, int t) {//s to t
         LL ret = 0, f;
         while (bfs(s), level[t] >= 0) {
             itr.assign(V,0);
             while ((f = dfs(s, t, mod)) > 0) ret += f;//mod use as inf
         }
         return ret;
     }
 };


int main(){
	int n,a[111]={};
	cin>>n;
	max_flow mf(n+2);//0:破壊,n+1:残存
	LL mx=0;
	FORQ(i,1,n){
		cin>>a[i];
		if(a[i]>=0){
			mx+=a[i];
			mf.add_edge(0,i,a[i]);
		}else{
			mf.add_edge(i,n+1,-a[i]);
		}
		FORQ(j,2,n/i){
			int to=j*i;
			mf.add_edge(to,i,1LL*mod*1000000);
		}
	}
	cerr<<mx<<endl;
	cout<<mx-mf.run(0,n+1)<<endl;

	return 0;
}


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

typedef long long ll;
ll const mod = 998244353;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll power_mod(ll a,ll b,ll mod) {
    if (b == 0) return 1;
    if (b == 1) return a;
    ll c = power_mod(a,b/2,mod);
    if (b%2) return c*c%mod*a%mod;
    else return c*c%mod;
}

int main() {
    int n,m;
    cin >> n >> m;
    bool a[n][m];
    int r = 0;
    for (int i = 0;i < n;++i) for (int j = 0;j < m;++j) cin >> a[i][j];
    for (int i = 0;i < min(n,m);++i) {
        int p = i,q = i;
        for (int j = i;j < n;++j) {
            if (a[p][q]) break;
            for (int k = i;k < m;++k) if (a[j][k]) {
                p = j;q = k;
                break;
            }
        }
        if (!a[p][q]) break;
        r = i+1;
        for (int j = i;j < n;++j) swap(a[j][i],a[j][q]);
        for (int j = i;j < m;++j) swap(a[i][j],a[p][j]);
        for (int j = i+1;j < n;++j) if (a[j][i]) for (int k = i;k < m;++k) a[j][k] ^= a[i][k];
        for (int j = i+1;j < m;++j) if (a[i][j]) for (int k = i;k < n;++k) a[k][j] ^= a[k][i];
    }
    cout << (power_mod(2,n+m-1,mod)-power_mod(2,n+m-r-1,mod)+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 384
use std::io;
use std::cmp::max;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let a = input.next().parse::<i64>().unwrap();
    let b = input.next().parse::<i64>().unwrap();
    println!("{}", solve(a, b));
}

fn solve(a_: i64, b_: i64) -> i64 {
    let mut a = a_;
    let mut b = b_;
    if a == b {
        return 1;
    }
    let c = a ^ b;
    let r = (0..62).filter(|x| ((1i64 << x) & c) > 0i64).max().unwrap();
    let t = 1i64 << r;
    a &= t - 1;
    b &= t - 1;
    let l2 = 1i64 << (0..62).filter(|x| (1i64 << x) > b).min().unwrap();
    return t - a + t - a + l2 - max(l2 - a, 0);
}

fn test(a_: i64, b_: i64) -> i64 {
    let mut a = a_;
    let mut b = b_;
    if a == b {
        return 1;
    }
    let c = a ^ b;
    let r = (0..62).filter(|x| ((1i64 << x) & c) > 0i64).max().unwrap();
    let t = 1i64 << r;
    a &= t - 1;
    b &= t - 1;
    let u = (0..62).filter(|x| (1i64 << x) > b).min().unwrap();
    let mi = a;
    let ma = 1i64 << u;
    return t + t - mi + if ma > mi { 0 } else { ma - mi };
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }
}



Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(X)<<Y<<endl
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;

std::vector<int> div(int n){
	std::vector<int> v;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			v.push_back(i);
			if(i*i!=n){
				v.push_back(n/i);
			}
		}
	}
	return v;
}

signed main(){
	cin>>N;
	int ans=INF;
	vector<int> v=div(N);
	REP(i,v.size()){
		ans=min(ans,v[i]-1+(N/v[i])-1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,m,arr[305][305],idx[305]={},occ[305]={},ans;
bool nyala[405];
int carimaks(){
	//cout<<"cari maks"<<endl;
	int most=-1,ret=-1;
	for(int i=1;i<=m;i++)
	{
		if(!nyala[i])
			continue;
		//cout<<"ada"<<endl;
		if(occ[i]>most)
		{
			most=occ[i];
			ret=i;
		}
	}
	assert(ret!=-1);
	return ret;
}
void carilain(int orang){
	while(!nyala[arr[orang][idx[orang]]])
		idx[orang]++;
	occ[arr[orang][idx[orang]]]++;
}
void hilangkan(int event){
	//cout<<"menghilangkan "<<event<<endl;
	nyala[event]=false;
	for(int i=1;i<=n;i++)
		if(arr[i][idx[i]]==event)
			carilain(i);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		nyala[i]=true;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			scanf("%d",&arr[i][j]);
		idx[i]=1;
		occ[arr[i][idx[i]]]++;
		//cout<<"menambah "<<arr[i][idx[i]]<<endl;
	}
	ans=occ[carimaks()];
	/*cout<<"awalnya "<<ans<<endl;
		for(int i=1;i<=m;i++)
			cout<<((nyala[i])?occ[i]:0)<<" ";
		cout<<endl;*/
	for(int i=0;i<m-1;i++)
	{
		//cout<<"pada step "<<i<<endl;
		hilangkan(carimaks());
		/*for(int i=1;i<=m;i++)
			cout<<((nyala[i])?occ[i]:0)<<" ";
		cout<<endl;*/
		ans=min(ans,occ[carimaks()]);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
int main() {
  int n, x, y, s, t, u, c, d;
  int count[10000] = {};
  n = 1;
  x = 1;
  c = 0;

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

  while(n != 0 || x != 0) {
    for(s = 1;s <= n-2;s++){
      for(t = s+1;t <= n-1;t++){
        for(u = t+1;u <= n;u++){
          y = s + t + u;
          if(x == y) count[c]++;
        }
      }
    }
    scanf("%d%d", &n, &x);
    c++;
  }

  for(d = 0;d < c;d++) printf("%d\n", count[d]);

  return 0;
}

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

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

int main() {
  int N, K, R, S, P, s=0;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int dp[K][(N-1)/K+2][3];
  rep(i,K) {
    rep(k,3) {
      dp[i][0][k]=0;
    }
  }
  rep(i,K) {
    for(int j=0;K*j+i<N;j++) {
      if(T[K*j+i]=='r') {
        dp[i][j+1][0]=max(dp[i][j][1], dp[i][j][2]);
        dp[i][j+1][1]=max(dp[i][j][2], dp[i][j][0]);
        dp[i][j+1][2]=max(dp[i][j][0]+P, dp[i][j][1]+P);
      } else if(T[K*j+i]=='s') {
        dp[i][j+1][0]=max(dp[i][j][1]+R, dp[i][j][2]+R);
        dp[i][j+1][1]=max(dp[i][j][2], dp[i][j][0]);
        dp[i][j+1][2]=max(dp[i][j][0], dp[i][j][1]);
      } else {
        dp[i][j+1][0]=max(dp[i][j][1], dp[i][j][2]);
        dp[i][j+1][1]=max(dp[i][j][2]+S, dp[i][j][0]+S);
        dp[i][j+1][2]=max(dp[i][j][0], dp[i][j][1]);
      }
      if(K*(j+1)+i>=N)
        s+=max(dp[i][j+1][0], max(dp[i][j+1][1], dp[i][j+1][2]));
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3584
S,T = input(), input()

dp = [[0]*(len(T)+1)] + [[0]+[None]*len(T) for _ in range(len(S))]

for i,s in enumerate(S):
  for j,t in enumerate(T):
    dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j], dp[i][j] + int(s==t))

res = []

x,y = len(S),len(T)

while x > 0 and y > 0:
  if dp[x][y] == dp[x-1][y]:
    x -= 1
  elif dp[x][y] == dp[x][y-1]:
    y -= 1
  else:
    x -= 1
    y -= 1
    res.append(S[x])

print(''.join(reversed(res)))

Measured memory_bytes: 121436
import itertools
N = int(input())
a = list(map(int, input().split()))

def all_zero(a):
    for e in a:
        if e != 0:
            return False
    return True

def three_mod_same(a):
    counts = {}
    for e in a:
        if e not in counts:
            counts[e] = 1
        else:
            counts[e] += 1

    for v in counts.values():
        if v != len(a) // 3:
            return False
    return True

def two_elem_one_zero(a):
    if len(set(a)) != 2:
        return False
    counts = {}
    for e in a:
        if e not in counts:
            counts[e] = 1
        else:
            counts[e] += 1
            
    for key, v in counts.items():
        if key == 0:
            if v != len(a) // 3:
                return False
        else:
            if v != (len(a) // 3) * 2:
                return False
    return True

if len(set(a)) != 3:
    if all_zero(a) or ((len(a) % 3 == 0) and two_elem_one_zero(a)):
        print("Yes")
    else:
        print("No")
else:
    p = itertools.permutations(list(set(a)), 3)
    yes = False
    for permed_a in p:            
        good_perm = True
        for i in range(3):
            if permed_a[(i + 1) % 3] != (permed_a[i] ^ permed_a[(i + 2) % 3]):
                good_perm = False
                break
        if good_perm:
            yes = True
            break
    if not yes:
        print("No")
    else:
        if three_mod_same(a):
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 14496
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

vector<vector<int>> graph;
vector<int> d;
int dfs(int v) {
    if (d[v] != -1) return d[v];
    int res = 0;
    for (int to: graph[v]) chmax(res, dfs(to));
    return d[v] = res + 1;
}

int main() {
    int n, m;
    cin >> n >> m;
    graph.resize(n);
    d.assign(n, -1);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
    }
    
    int cv = 0;
    rep(v, n) chmax(cv, dfs(v));
    cout << cv - 1 << endl;
}

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

int main(){
    int K, A, B;

    cin >> K;
    cin >> A >> B;

    string result = "NG";

    for( int n = A; n <= B; ++n ){
        if( n % K == 0 ){
            result = "OK";
        }
    }

    cout << result << endl;

    return 0;
}

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

int main(){
  int n, k;
  cin >> k >> n;
  vector<int> v,dif;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for(int i=0; i<n; i++){
    if(i==n-1){
      dif.push_back(v[0]-v[i]);
      continue;
    }
    dif.push_back(v[i+1]-v[i]);
    v[i]+=k;
  }
  sort(dif.begin(), dif.end(),greater<int>());
  int ans = k - dif[0];
  cout << ans << endl;
  return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    int ans=0;
    int count=0;
    for (int i = 0; i < 1001; ++i) {
        if(int(double(i)*0.08) == A){
            if(int(double(i)*0.10) == B){
                ans = i;
                count++;
                break;
            }
        }
    }
    if(count > 0){
        cout << ans << endl;
    }
    else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        x: usize,
        a: usize,
        b: usize
    };
    let s = if b <= a {
        "delicious"
    } else if b <= a + x {
        "safe"
    } else {
        "dangerous"
    };
    println!("{}", s);
}


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

int main(){
	int inr,inw,c,r;
	while(cin>>inr>>inw>>c>>r){
		if(inr==0)break;
		int ans=0;
		int s =inr/inw;
		for(;;){
			s =inr/inw;
			//cout<<s<<endl;
			if(s<c){
				inr += r;
				ans++;
			}else if(s>c){
//				inw += 1;
				cout<<ans<<endl;
				break;
				//ans++;
			}else{
				cout<<ans<<endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 2984
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#define vi vector<int>
#define lli long long int
#define fo(i,n) for(int i=1;i<=n;i++)
#define foo(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define vii vector<lli>

#define ok ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#define vp vector<pair<lli,lli>>
#include <map>           
lli mod=1000000007;      

//vi r(300003),c(300003);   
vi a(1000009);

int main(){
   lli k;
   cin>>k;
   a[0]=7%k;
   fo(i,k){
   	a[i]=(a[i-1]*10+7)%k;
   }
   
   foo(i,k){
   	if(a[i]==0){
   		cout<<i+1;
   		return 0;
	   }
   }
   cout<<"-1";
}




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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, 0, n) cin >> h[i];
    ll L = 0, R = 1e9+10;
    while(R - L > 1){
        ll M = L + (R - L) / 2;
        ll cnt = 0;
        rep(i, 0, n){
            ll rem = max(0LL, h[i] - b * M);
            if(rem > 0) cnt += (rem + (a-b) - 1) / (a-b); 
        }
        if(cnt <= M) R = M;
        else L = M;
    }
    cout << R << endl;
    return 0;
}

Measured memory_bytes: 4032
#include <cstdio>
#include <cstring>
using namespace std;
const int INf=0x3f3f3f3f;
int a[302][302],p[302],cnt[302];
bool flag[302];
int n,m;
bool check(int x){
	//printf("%d\n",x);
	memset(flag,0,sizeof(flag));
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=n;i++){
		p[i]=1;
		cnt[a[i][1]]++;
	}
	while(true){
		bool qwq=false;
		for(int j=1;j<=m;j++)
			if (cnt[j]>x){
				//printf("%d %d\n",j,cnt[j]);
				flag[j]=qwq=true,cnt[j]=0;
			}
		if (!qwq)
			return true;
		for(int j=1;j<=n;j++){
			//printf("%d\n",a[j][p[j]]);
			bool qwq=false;
			while(flag[a[j][p[j]]]){
				p[j]++;
				qwq=true;
				//printf("%d\n",p[j]);
			}
			if (!a[j][p[j]])
				return false;
			cnt[a[j][p[j]]]+=qwq;
		}
	}
}
int main(){
	//int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	int l=0,r=n;
	//printf("%d\n",check(2));
	while(l<r){
		int mid=(l+r)/2;
		if (check(mid))
			r=mid;
		else l=mid+1;
	}
	printf("%d",l);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
ll dp[100100] ;
int main()
{
    ll n , m ; cin>>n>>m ;
    n*=500 ;
    if (n>=m)
        cout<<"Yes" ;
    else
        cout<<"No" ;
}




Measured memory_bytes: 256
fn main() {
    let s = read::<String>();
    for (i, c) in s.char_indices() {
        if (i+1) % 2 == 1 {
            if c == 'L' {
                println!("No");
                return;
            }
        } else {
            if c == 'R' {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}

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


Measured memory_bytes: 4352
N, X = map(int, input().split())
x = list(map(lambda x:abs(int(x)-X), input().split()))
def gcd_base(a, b):
    while b!=0:
        a, b = b, a%b
    return a

def gcd(num_list):
    ans = 0
    for i in num_list:
        ans = gcd_base(ans, i)
    return ans

print(gcd(x))

Measured memory_bytes: 14252
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h=sc.nextInt();
		
		if(n==h)
		System.out.println("Yes");
        else
          System.out.println("No");



	}

}


Measured memory_bytes: 23508
long bit[3<<17],a,r,H;
n,h[2<<17],i,j;
main(n)
{
	for(scanf("%d",&n);i<n;)scanf("%d",h+i++);
	for(;~scanf("%d",&a);)
	{
		r=0;H=h[j];
		for(;H>0;H-=H&-H)r=fmax(r,bit[H]);
		H=h[j];
		for(;H<=2<<17;H+=H&-H)bit[H]=fmax(bit[H],a+r);
		j++;
	}
	printf("%ld",bit[2<<17]);
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int W,H,N;
char t[1000][1001];
int change(int i,int j){return i*W+j;}
int a[1000][1000];
int d[1000000];

int solve(){
  memset(d,1,sizeof(d));

  priority_queue< P , vector<P> , greater<P> > Q;
  Q.push(P(0,0));
  d[0]=0;
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int i=p.second/W;
    int j=p.second%W;
    int cost=p.first;
    //cout<<i<<' '<<j<<' '<<cost<<endl;
    if(cost > d[p.second])continue;
    if(t[i][j]=='t')return cost;
    for(int k=0;k<4;k++){
      int ni=i+dy[k];
      int nj=j+dx[k];
      int to=ni*W+nj;
      if(ni<0||nj<0)continue;
      if(H<=ni||W<=nj)continue;
      int ncost=max(cost,a[ni][nj]);
      if(ncost < d[to]){
        d[to]=ncost;
        Q.push(P(d[to],to));
      }
    }
  }
  return -1;
}

int main(){
  scanf("%d %d",&W,&H);
  for(int i=0;i<H;i++){
    scanf("%s",t[i]);
    for(int j=0;j<W;j++){
      if(t[i][j]=='#')a[i][j]=1e8;
    }
  }
  scanf("%d",&N);
  for(int A=1;A<=N;A++){
    int i,j;
    scanf("%d %d",&j,&i);
    if(t[i][j]=='#'){
      a[i][j]=A;
      t[i][j]='.';
    }
  }
  printf("%d\n",solve());
  return 0;
}

Measured memory_bytes: 10024
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	vector<int> x(101);
	vector<int> ans(101);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x.at(i);
	}
	for(int i=1;i<=100;i++){
		ans.at(i)=0;
		for(int j=1;j<=n;j++){
			ans.at(i)+=(x.at(j)-i)*(x.at(j)-i);
		}
	}
	sort(ans.begin()+1, ans.end());
	cout<<ans.at(1)<<endl;
}

Measured memory_bytes: 256
S = input()
n = len(S)
i = n%2
As = []
Bs = []
if i == 0:
    As = "01"*(n//2)
    Bs = "10"*(n//2)
elif i == 1:
    As = "01"*(n//2)+"0"
    Bs = "10"*(n//2)+"1"
count_A,count_B = 0,0
for A,B,s in zip(As,Bs,S):
    count_A += (int(A)+int(s))%2
    count_B += (int(B)+int(s))%2
print(min(count_A,count_B))

Measured memory_bytes: 3316
a=-1,A=65,d;
char
*N="GKSOCNWLDFVTBRXHAJUPEMQI",
*E="PHLTIDOXQAGWECSUMBKVJFNR",
s[9];
main(c)
{
for(;c-48&&scanf("%s",s);a+=d/4+1)
{
(c=*s)<A?~a&&printf("%d\n",a),a=d=0:0;
if(c==78)d=N[d]-A;
if(c==69)d=E[d]-A;
if(c==87)d=E[E[E[d]-A]-A]-A;
if(c==83)d=N[N[N[d]-A]-A]-A;
if(c==82)d=d&28|d%4+1&3;
if(c==76)d=d&28|d%4+3&3;
}}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3632
N,M,Q = map(int,input().split())

abcd = tuple(tuple(map(int,input().split())) for _ in range(Q))

A = [1]

def rec():
    if len(A) == N:
        return sum(d for a,b,c,d in abcd if A[b-1] == A[a-1]+c)

    t = 0
    for x in range(A[-1],M+1):
        A.append(x)
        t = max(t, rec())
        A.pop()
    return t

print(rec())

Measured memory_bytes: 9204
def main():
    N = int(input())
    ans = (N - 1) * N // 2
    # X % K の最大値は K-1
    # 1,2,3,...,Nで割った余りの最大値は
    # 0,1,2,...,N-1
    # 1,2,...,Nを
    # 2,3,...,N,1で割ることで
    # 余りは1,2,...,N-1,0となり、
    # 最大値を達成できる
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int N=1000005,mu=998244353;
int n,x,ans,M,s[N],Ans[N],inv[N];
long long a[N];
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*1ll*x%mu)
		if (y&1) ans=1ll*ans*x%mu;
	return ans; 
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		int q=(int)sqrt(x);
		for (int j=1;j<=q;j++)
			if(x%j==0) a[j]+=x,a[x/j]+=x;
		if (q*q==x) a[q]-=x;
		ans=(ans-x+mu)%mu;
		M=std::max(x,M);
	}
	for (int i=1;i<=M;i++) a[i]=a[i]%mu;
	for (int i=1;i<=M;i++) inv[i]=ksm(i,mu-2);
	for (int i=M;i;i--){
		if (!a[i]) continue;
		Ans[i]=(Ans[i]+1ll*a[i]*a[i]%mu*inv[i]%mu)%mu;
		
		int q=(int)sqrt(i);
		if (i!=1) Ans[1]=(Ans[1]-1ll*Ans[i]*i%mu+mu)%mu; 
		for (int j=2;j<=q;j++){
			if (i%j==0) Ans[j]=(Ans[j]-1ll*Ans[i]*i%mu*inv[j]%mu+mu)%mu;
			if (j!=i/j && i%j==0) Ans[i/j]=(Ans[i/j]-1ll*Ans[i]*i%mu*inv[i/j]%mu+mu)%mu;
		}
		ans=(ans+Ans[i])%mu;
	}
	//for (int i=1;i<=M;i++) printf("%d %d\n",i,Ans[i]);
	printf("%d",ans*499122177ll%mu);
} 

Measured memory_bytes: 16768
S=input()
start=1
end=0
ans=[]
for _ in range(len(S)):
    for i in range(len(S))[end:]:
        if S[i] in {"A","C","G","T"}:
            start=i
            break
    for j in range(len(S))[start:len(S)]:
        end=len(S)
        if S[j] not in {"A","C","G","T"}:
            end=j
            break
    ans.append(end-start)
if max(ans)<0:print(0)
else:print(max(ans))

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        set<string> all;
        all.insert(S);
        for (int j = 1; j < S.size() + 1; j++) {
            string L = S.substr(0, j);
            string R = S.substr(j);
            string L2 = L;
            reverse(L2.begin(), L2.end());
            string R2 = R;
            reverse(R2.begin(), R2.end());
            all.insert(R + L);
            all.insert(L + R2);
            all.insert(R2 + L);
            all.insert(L2 + R);
            all.insert(R + L2);
            all.insert(L2 + R2);
            all.insert(R2 + L2);
        }
        cout << all.size() << endl;
    }
}



Measured memory_bytes: 3068
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define y1 Emilia
#define forit(s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)


#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;
int a[N];
int main(){
    dracarys
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    vector<int> v1, v2;
    for(int i = 2; i <= n - 1; ++i){
        if(a[i] > 0) v1.push_back(a[i]);
        else v2.push_back(a[i]);
    }
    int ans = 0, mn = a[1], mx = a[n];
    forit(v1){
        mn -= *it;
    }
    forit(v2){
        mx -= *it;
    }
    cout << mx - mn << "\n";
    int res = a[1];
    forit(v1){
        cout << res << " " << *it << "\n";
        res -= *it;
    }
    res = a[n];
    forit(v2){
        cout << res << " " << *it << "\n";
        res -= *it;
    }
    cout << mx << " " << mn << "\n";
    return 0;
}


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

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int arr[n+1];
    for(int i=1;i<=n;i++) cin>>arr[i];
    int dp[n+1];
    for(int i=0;i<=n;i++) dp[i] = INT_MAX;
    dp[1] = 0, dp[2] = abs(arr[2] - arr[1]);
    
    for(int i=3;i<=n;i++){
        for(int j=1;i-j>=1 && j<=k;j++){
            dp[i] = min(dp[i],dp[i-j] + abs(arr[i] - arr[i-j]));
        }
    }
    
    cout<<dp[n];
}

Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <iomanip>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-7
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(n) ((n) * (n))

int main(void) {
  FOR(i, 1, 10) {
    FOR(j, 1, 10) {
      printf("%dx%d=%d\n", i, j, i * j);
    }
  }
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 4e2+1;
const int mod = 1e9+7;
ll pref[upperlimit][upperlimit];
ll dp[upperlimit][upperlimit];
int a[upperlimit];
int b[upperlimit];
ll rngsum(int l,int r,int pw){
	ll ans=pref[r][pw]-pref[l-1][pw];
	if(ans<0) ans+=mod;
	return ans;
}
int main() {
	for(int i = 1; i < upperlimit; i++){
		ll temp=1;
		for(int j = 0; j < upperlimit; j++){
			pref[i][j]=pref[i-1][j];
			pref[i][j]+=temp;pref[i][j]%=mod;
			temp*=i;temp%=mod;
		}
	}
	int n,c;
	sd(n);sd(c);
	for(int i = 1; i <= n; i++) sd(a[i]);
	for(int i = 1; i <= n; i++) sd(b[i]);
	dp[0][0]=1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= c; j++){
			for(int k = 0; k <= j; k++){
				dp[i][j]+=(dp[i-1][k]*rngsum(a[i],b[i],j-k))%mod;
				dp[i][j]%=mod;
			}
		}
	}
	plld(dp[n][c]);
	return 0;
}

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;

namespace B
{
	class Program
	{
		static void Main()
		{
			var S = Console.ReadLine().ToList();
			
			int maxLen = 0;
			for (int winSize = 1; winSize <= S.Count; winSize++) {
				// winSizeは部分文字列の長さ(窓のサイズ)
				
				for (int i = 0; i + winSize <= S.Count; i++) {
					// Console.WriteLine(i + " ~ " + (i + winSize));
					var subS = S.GetRange(i, winSize);

					int count = 0;
					foreach (var c in subS) {
						// Console.Write(c);
						if (c != 'A' && c != 'C' && c != 'G' && c != 'T')
							break;
						count++;
					}
					// Console.WriteLine();

					if (count == subS.Count) maxLen = count;
				}
			}
			
			Console.WriteLine(maxLen);
		}
	}
}


Measured memory_bytes: 13268
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353
import numpy

S  = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Rainy":
    print("Sunny")
else:
    print("Rainy")

Measured memory_bytes: 27152