akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define inf 1000000007

using namespace std;

signed main() {
  IOS;
  int i=0, cur=0,ans=0;
  string s;
  cin >> s;

  for (auto c: s) {
    if (c == 'A' or c =='C' or c=='G' or c=='T') {
      cur++;
    } else {
      ans = max(ans, cur);
      cur = 0;
    }
  }
  ans = max(ans, cur);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
vector<int> G[MAXN];
int dep[MAXN];

void bfs(int cur, vector<int> &dis) {
    dis[cur] = 0;
    queue<int> qu;
    qu.push(cur);
    while (!qu.empty()) {
         int tp = qu.front();
         qu.pop();
         for (auto i : G[tp]) {
             if (!dis[i] && i != cur) {
                 qu.push(i);
                 dis[i] = dis[tp] + 1;
             }
         }
    }
}

int dfs(int cur, int par) {
    int ans = 0;
    for (int i : G[cur]) {
        if (i != par) {
            ans = max(dfs(i, cur), ans);
        }
    }
    return dep[cur] = ans;
}

int main() {
    int N, u, v;
    scanf("%d %d %d", &N, &u, &v);
    u--, v--;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> disu(N, 0), disv(N, 0);
    bfs(u, disu);
    bfs(v, disv);
    dfs(v, v);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (disu[i] > disv[i]) continue;
        if (disu[i] == disv[i]) ans = max(ans, disu[i] - 1);
        ans = max(ans, disv[i] + dep[i] - 1);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));


signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,t; cin >> n >> t;
    vector<P> v(n);
    rep(i,n){
        cin >> v[i].fi >> v[i].se;
    }
    sort(ALL(v));
    
    int dp[n+1][t+1];
    rep(i,n+1)rep(j,t+1)dp[i][j]=0;
    
    rep(i,n){
        rep(j,t+1){
            dp[i+1][j]=dp[i][j];
            if(j-v[i].fi>=0) chmax(dp[i+1][j],dp[i][j-v[i].fi]+v[i].se);
        }
    }
    
    int ans=0;
    rep(i,t+1){
        chmax(ans,dp[n][i]);
    }
    //cout << ans << endl;
    vector<int> sum(n,0);
    sum[n-1]=v[n-1].se;
    rrep(i,n-1){
        sum[i]=max(sum[i+1],v[i].se);
    }
    rep(i,n){
        rep(j,t){
            chmax(ans,dp[i][j]+sum[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 38816
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <cassert>
#include <tuple>
#include <list>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef long double ld;

template<class htpe, class cmp>
using heap = priority_queue<htpe, vector<htpe>, cmp>;

template<class htpe>
using min_heap = heap<htpe, greater<htpe> >;

template<class htpe>
using max_heap = heap<htpe, less<htpe> >;

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define ff first
#define ss second

#define forn(i, n) for (int i = 0; i < ((int)(n)); ++i)
#define forrn(i, s, n) for (int i = (int)(s); i < ((int)(n)); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))

const int INF = 1791791791;
const ll INFLL = 1791791791791791791ll;


int main() {
    // Code here:

    int a, b;
    cin >> a >> b;
    stringstream ss;
    ss << a << b;
    int x;
    ss >> x;

    for (int y = 1; y * y <= x; y++)
        if (y * y == x) {
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;
int main() {
    fastIO;
    int h, w;
    cin >> h >> w;
    vector<vector<char>> cells(h);

    rep(i, h) {
        rep(j, w) {
            char c;
            cin >> c;
            cells.at(i).push_back(c);
        }
    }

    vector<bool> hi(h);
    vector<bool> wi(w);
    fill(hi.begin(), hi.end(), true);
    fill(wi.begin(), wi.end(), true);

    // trace row
    rep(i, h) {
        bool removable = true;
        rep(j, w) {
            if (cells.at(i).at(j) == '#')
                removable = false;
        }
        if (removable == true) {
            hi.at(i) = false;
        }
    }

    // trace col
    rep(j, w) {
        bool removable = true;
        rep(i, h) {
            if (cells.at(i).at(j) == '#') {
                removable = false;
            }
        }
        if (removable == true) {
            wi.at(j) = false;
        }
    }

    // output
    rep(i, h) {
        bool newLine = false;
        rep(j, w) {
            if (hi.at(i) == true && wi.at(j) == true) {
                cout << cells.at(i).at(j);
                newLine = true;
            }
        }
        if (newLine)
            cout << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    
    //変数：アイズ温泉施設に訪問回数「 N 」と置く
    int N;
    //変数：風呂金額「 bathMoney 」とプール金額「 poolMoney 」と風呂剣「 bathTicket 」とプール剣「 poolTicket 」と置く
    int bathMoney, poolMoney, bathTicket, poolTicket;
    
    //入力：アイズ温泉施設に訪問回数「 N 」を入力
    cin >> N;
    
    
    //繰返し：アイズ温泉施設に訪問回数「 N回」繰り返す
    for(int i = 0; i < N; i++){
        
        //入力：風呂金額「 bathMoney 」とプール金額「 poolMoney 」と風呂剣「 bathTicket 」とプール剣「 poolTicket 」を入力
        cin >> bathMoney >> poolMoney >> bathTicket >> poolTicket;
        
        //計算：そのままのアイズ温泉施設に訪問費を計算
        int ans = ( bathMoney * bathTicket ) + ( poolMoney * poolTicket );
        
        //比較：アイズ温泉施設に訪問費と割引条件でアイズ温泉施設に訪問費の比較
        ans = min(ans, 4*( bathMoney * max(bathTicket, 5 ) + poolMoney * max(2, poolTicket) ) / 5 );
        
        //出力：答え表示
        cout << ans << endl;

        
        
    }
    
}



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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

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

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << c << " "  << a << " "<< b;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for(int i = 0;i < n;i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll left = max((ll)0, v.back() / a - 2);
    ll right = v.back() / b + 2;
    const ll diff = a - b;
    while(right - left > 1)
    {
        const ll middle = (left + right) / 2;
        ll sum = 0;
        for(int i = 0;i < n;i++)
        {
            ll r = v[i] - b * middle;
            if(r > 0)
            {
                ll p = r / diff;
                if(r % diff > 0)
                {
                    p++;
                }
                sum+=p;
            }
        }
        if(sum > middle)
        {
            left = middle;
        }
        else
        {
            right = middle;
        }
    }
    cout << right << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;

string makes[5001] = {};

bool compare(string u, string v) {
  if(u.size() > v.size()) {
    int diff = u.size() - v.size();
    v += makes[diff];
  }
  else if(u.size() < v.size()) {
    int diff = v.size() - u.size();
    u += makes[diff];
  }
  return u < v;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int K;
  cin >> K;
  vector<string> arr;
  for(int i = 1 ; i <= 5000 ; i++) {
    makes[i] = makes[i - 1] + 'a';
  }
  for(int i = 0 ; i < s.size() ; i++) {
    string tmp;
    for(int j = i ; j < s.size() ; j++) {
      tmp += s[j];
      if(tmp.size() > K) break;
      arr.pb(tmp);
    }
  }

  sort(arr.begin(), arr.end());
  arr.erase(unique(arr.begin(), arr.end()), arr.end());
  sort(arr.begin(), arr.end(), compare);
  cout << arr[K - 1] << endl;
} 


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

int main(){
	int N=0;
	cin >>N;
	string a[N];
	int time[N];
	string title;
	int ans=0;
	int total=0;

	for(int i=0;i<N;i++){
		cin>>a[i];
		cin>>time[i];
	}
	
    cin>>title;
      
    for(int i=0;i<N;i++){
        total=total+time[i];
    }

    
	for(int i=0;i<N;i++){
		if(title==a[i]){
		    	for(int j=0;j<i+1;j++){
		ans=ans+time[j];



	}
	cout <<total-ans<<endl;


	return 0;
	}
	}
}

	







Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
ll n,m;
cin>>n>>m;
vector<p>v;
for(ll i=0;i<n;i++)
{
    ll a,b;
    cin>>a>>b;
    if(m-a>=0)
    {
    v.pb({a,b});
    }
}
sort(v.begin(),v.end());
ll ans=0;
priority_queue<ll>pq;
ll j=0;
for(ll i=1;i<=m;i++)
{
    while(j<v.size()&&v[j].fi<=i)
    {
        pq.push(v[j].se);
        j++;
    }
    if(pq.size()!=0)
    {
        ans+=pq.top();
        pq.pop();
    }
}
cout<<ans<<endl;
return 0;
}


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

Num = []
for i in range(M):
  s,c = map(int,input().split())
  Num.append([s-1,c])

ans = 1000
for i in range(1000):
  num = str(i)
  if(len(num) == N):
    judge = 1
    for j in range(len(Num)):
      s,c = Num[j][0], Num[j][1]
      judge = judge*(num[s] == str(c))
    if(judge == 1):
      ans = min(ans,int(num))        
      break

if(ans == 1000): ans = -1
print(ans)

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

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

const long long INF = pow(10, 9);

long long h[100010];

long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

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

    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // answer
    cout << dp[N-1] << endl;

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

const double EPS = 1e-9;

int main() {
	int m;
	while(cin >> m, m) {
		vector<int> v0, v1;
		int n;

		int sum = 0;
		for(int i = 0; i < m - 1; i++) {
			int tmp;
			cin >> tmp;
			v0.push_back(tmp);
			sum += tmp;
		}
		v0.push_back(360 - sum);

		cin >> n;
		sum = 0;
		for(int i = 0; i < n - 1; i++) {
			int tmp;
			cin >> tmp;
			v1.push_back(tmp);
			sum += tmp;
		}
		v1.push_back(360 - sum);

		double s0 = 0, s1 = 0;
		for(int i = 0; i < v0.size(); i++) {
			s0 += sin(M_PI * v0[i] / 180.0);
		}
		for(int i = 0; i < v1.size(); i++) {
			s1 += sin(M_PI * v1[i] / 180.0);
		}

		if(fabs(s0 - s1) < EPS)
			cout << 0 << endl;
		else if(s0 > s1)
			cout << 1 << endl;
		else
			cout << 2 << endl;
	}
}

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

using namespace std;

vector <int> x[2],y[2];
int sn[2][2][2];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    int ans=0;
    for(int i=0;i<29;i++){
        x[0].clear();x[1].clear();y[0].clear();y[1].clear();
        for(int j=0;j<n;j++){
            x[(a[j]>>i)&(1)].push_back(a[j]&((1<<i)-1));
            y[(b[j]>>i)&(1)].push_back(b[j]&((1<<i)-1));
        }
        sort(x[0].begin(),x[0].end(),greater<int>());
        sort(x[1].begin(),x[1].end(),greater<int>());
        sort(y[0].begin(),y[0].end());
        sort(y[1].begin(),y[1].end());
        memset(sn,0,sizeof(sn));
        for(int l=0;l<2;l++){
            for(int r=0;r<2;r++){
                int k=0;
                for(int j=0;j<x[l].size();j++){
                    while(k<y[r].size() && (x[l][j]+y[r][k]<(1<<i))){
                        k++;
                    }
                    sn[l][r][0]+=k;
                    sn[l][r][1]+=y[r].size()-k;
                }
            }
        }
        int val=0;
        val+=sn[0][0][1];
        val+=sn[0][1][0];
        val+=sn[1][0][0];
        val+=sn[1][1][1];
        ans+=(1<<i)*(val&1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4636
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;

    // 分割位置をずらして、順番に調べていく
    for(int i = 1; i < n; i++)
    {
        int cnt = 0;

        // アルファベットが分割された両方に存在するか確認する
        for(char c = 'a'; c <= 'z'; c++)
        {
            bool left=false,right=false;

            // 分割された左側
            for(int j = 0; j < i; j++)
            {
                if( s[j] == c )
                {
                    left=true;
                }
            }

            // 分割された右側
            for(int j = i; j < n; j++)
            {
                if( s[j] == c )
                {
                    right=true;
                }
            }

            if( left && right )
            {
                cnt++;
            }
        }

        if( ans < cnt )
        {
            // 最大値を求める
            ans=cnt;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
int n,mod;
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
int f[3010][3010],F[3010],C[3010][3010],p2[3010],P2[9000010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi(),mod=gi();
	for(int i=0,p=1;i<=n;++i,p=p*2%(mod-1))p2[i]=pow(2,p);
	C[0][0]=1;
	for(int i=1;i<=n;++i){C[i][0]=1;for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;}
	f[0][0]=1;
	P2[0]=1;for(int i=1;i<=n*n;++i)P2[i]=P2[i-1]*2%mod;
	for(int i=1;i<=n+1;++i)
		for(int j=1;j<=i;++j)
			f[i][j]=(f[i-1][j-1]+1ll*f[i-1][j]*j)%mod;
	int ans=0;
	for(int i=0;i<=n;++i)
		for(int k=0;k<=i;++k)
			inc(ans,1ll*C[n][i]%mod*(i&1?mod-1:1)%mod*f[i+1][k+1]%mod*P2[(n-i)*k]%mod*p2[n-i]%mod);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 106112
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int a  = sc.nextInt();
        String s = sc.next();
        if(a>=3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 22612
N = int(input())
D = list(map(int, input().split()))
DL = [0] * N
mod = 998244353
if D[0] != 0:
    print(0)
    exit()

for d in D:
    DL[d] += 1

if DL[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(1, N):
    if DL[i] == 0:
        if sum(DL[i:]) != 0:
            print(0)
            exit()
        else:
            print(ans%mod)
            exit()

    ans *= pow(DL[i-1], DL[i], mod)
    ans %= mod
print(ans % mod)


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

int main() {
	int n;
	cin >> n;
	vector<int> c(n-1), s(n-1), f(n-1);
	rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
	for (int i=0;i<n-1;i++) {
		int t = 0;
		for (int j=i;j<n-1;j++) {
			if (t <= s[j]) t = s[j] + c[j];
			else {
				int r = t % f[j];
				if (r==0) t = t + c[j];
				else t = t + f[j] - r + c[j];
			}
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;
constexpr double TL = 1.85;

random_device seed_gen;
mt19937 mt(seed_gen());
uniform_int_distribution<int> con(0,26-1);
uniform_int_distribution<int> day(0,365-1);
uniform_int_distribution<int> num(0,20);
uniform_real_distribution<double> pro(0.0,1.0);

clock_t start,fin;
int D;
int c[26];
int s[365][26];
int last[26];
int answer[365];
ll before_max;
int score_contest[26];

ll compute_res() {
    ll ans = 0;
    vector<int> before2(26,-1);
    rep(i,D) {
        int t = answer[i];
        ans -= (i - before2[t]) * (i - before2[t] - 1)/2 * c[t];
        before2[t] = i;
        ans += s[i][t];
    }
    rep(i,26) {
        ans -= (D - before2[i]) * (D - 1 - before2[i])/2 * c[i];
    }
    return ans;
}

ll compute_swap() {
    ll ans = 0;
    vector<int> before2(26,-1);
    rep(i,D) {
        int t = answer[i];
        before2[t] = i;
        ll ret = s[i][t];
        rep(j,26) {
            ret -= (i - before2[j]) * c[j];
        }
        ans += ret;
    }
    return ans;
}

int calc_score(int d,int i) {
    int bf = last[i];
    last[i] = d;
    int res = s[d][i];
    rep(j,26) {
        res -= (d - last[j]) * c[j];
    }
    last[i] = bf;
    return res;
}

void optimization() {
    rep(d,D) {
        int max_score = -INF;
        int best_i = -1;
        rep(i,26) {
            int x = calc_score(d,i);
            if (x > max_score) {
                max_score = x;
                best_i = i;
            }
        }
        last[best_i] = d; 
        answer[d] = best_i;
    }
}

void change_day() {
    int d = day(mt);
    int q = con(mt);

    if (answer[d] == q) return;
    int old = answer[d];
    answer[d] = q;
    ll score = compute_res();
    if (before_max < score) {
        before_max = score;
        return;
    }
    else {
        answer[d] = old;
        return;
    }
}

void two_swap() {
    int d1 = day(mt);
    int d2 = min(d1 + num(mt),D);
    swap(answer[d1],answer[d2]);
    ll score = compute_res();
    if (before_max < score) {
        before_max = score;
        return;
    }
    else {
        swap(answer[d1],answer[d2]);
        return;
    }
}

int main() {
    clock_t start = clock();
    cin >> D;
    rep(i,26) cin >> c[i];
    rep(i,D)rep(j,26) cin >> s[i][j];
    fill(last,last + 26,-1);
    
    /*
    //答え確認用
    printf("%d\n",D);
    rep(i,26) printf("%d ",c[i]); 
    cout << '\n';
    rep(i,D){
        rep(j,26) printf("%d ",s[i][j]);
        cout << '\n';
    }
    */

    optimization();
    before_max = compute_res();
    fin = clock();
    while ((double)(fin - start)/CLOCKS_PER_SEC < TL) {
        if (pro(mt) <= 0.4) change_day();
        else two_swap();
        fin = clock();
    }
    rep(i,D) printf("%d\n",answer[i] + 1);
    return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>

int main(){
    std::string S, S_R, S_p1, S_p2, S_p1R, S_p2R;
    std::cin >> S;

    int N = S.size();
    
    S_p1 = S.substr(0,(N-1)/2);
    S_p2 = S.substr((N+3)/2-1,N-(N+3)/2+1);

    S_R = S;
    S_p1R = S_p1;
    S_p2R = S_p2;
    std::reverse(S_R.begin(),S_R.end());
    std::reverse(S_p1R.begin(),S_p1R.end());
    std::reverse(S_p2R.begin(),S_p2R.end());

    if(S==S_R&&S_p1==S_p1R&&S_p2==S_p2R) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define M 1001
int dist[M][M];
int main(){
	int n,m,s,g1,g2,i,j,k,l;
	for(;scanf("%d%d%d%d%d",&n,&m,&s,&g1,&g2),n;){
		for(i=1;i<=n;i++)for(j=1;j<=n;j++)dist[i][j]=(i!=j)*(1<<29);
		for(i=0;i<m;i++)scanf("%d%d%d",&j,&k,&l),dist[j][k]=l;
		for(k=1;k<=n;k++)for(i=1;i<=n;i++)for(j=1;j<=n;j++){
			if(dist[i][j]>dist[i][k]+dist[k][j])dist[i][j]=dist[i][k]+dist[k][j];
		}
		for(m=1<<29,i=1;i<=n;i++){
			if(m>dist[s][i]+dist[i][g1]+dist[i][g2])m=dist[s][i]+dist[i][g1]+dist[i][g2];
		}
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    ll x;
    cin >> x;
    ll ans = 1000 * (x / 500);
    x -= 500 * (x / 500);
    ans += 5 * (x / 5);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int a,b,c; cin >> a >> b >> c;
  if(a==b) { if(b==c) cout << "1\n"; else cout << "2\n"; }
  else if(b==c) cout << "2\n";
  else if(a==c) cout << "2\n";
  else cout << "3\n";
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    input!{
        A: usize,
        B: usize,
        C: usize
    };

    if (A == B && B == C) {
        println!("No");
    } else if (A == B || B == C || A == C) {
        println!("Yes");
    } else {
        println!("No");
    }

}

fn main() {
    solve();
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s;
  cin >> s;

  for(int i = 0; i < s.size() * 0.5; i++){
    if(s.at(i) != s.at(s.size() - i - 1)){
      cout << "No";
      return 0;
    }
  }

  string ss = s.substr(0, (s.size() - 1) * 0.5);
  string sss = s.substr((s.size() + 2) * 0.5, s.size() - 1);

  for(int i = 0; i < ss.size() * 0.5; i++){
    if(ss.at(i) != ss.at(ss.size() - i - 1)){
      cout << "No";
      return 0;
    }
  }

  for(int i = 0; i < sss.size() * 0.5; i++){
    if(sss.at(i) != sss.at(sss.size() - i - 1)){
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";

  return 0; 
}


Measured memory_bytes: 256
nw=list(map(int, input().split(" ")))
dp=[[0]*(nw[1]+1) for _ in range(nw[0]+1)]
w=[]
v=[]
i=0
ww=0
for _ in range(nw[0]):
    wv=list(map(int, input().split(" ")))
    w.append(wv[0])
    v.append(wv[1])
for i in range(nw[0]):
    for ww in range(nw[1]+1):
        if w[i] <= ww:
            dp[i+1][ww]=max(dp[i+1][ww], dp[i][ww-w[i]]+v[i])
        dp[i+1][ww]=max(dp[i+1][ww], dp[i][ww])
print(dp[nw[0]][nw[1]])

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

int main() {
  int N;
  cin >> N;
  vector <int> p(N);
  vector <int> q(N);
  int cnt = 0;
  for (int i = 0; i < N; i++){
    cin >> p[i];
    q[i] = p[i];
  }
  sort(q.begin(), q.end());
  for (int i = 0; i < N; i++){
    if (p[i] != q[i]){
      cnt++;
    }
  }
  if (cnt <= 2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

    def combination2(self, k, r):
        """kCrを求める O(r) kが大きいが、r <= nを満たしているときに使用"""
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.MOD
        return (res * self.inv_fact[r]) % self.MOD


n, m, k = map(int, input().split())
MOD = 998244353

comb = Combination(10 ** 6, MOD)
ans = 0

for i in range(n + 1):
    same_cnt = n - i
    diff_cnt = i + 1
    if same_cnt > k:
        continue
    box = n - 1
    shikiri = box - same_cnt

    tmp = comb.combination(box, shikiri)

    # tmp *= m * ((m - 1)**(shikiri))
    tmp *= m * pow(m - 1, shikiri, MOD)
    
    ans += tmp
    ans %= MOD

print(ans % MOD)

Measured memory_bytes: 151312
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        a: usize,
        b: usize
    }
    let d = 1000000007;
    println!("{}", (pow_m(2, n, d) - 1 + 2 * d - comb_m(n, a, d) - comb_m(n, b, d)) % d);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}

fn comb_m(n: usize, r: usize, d: usize) -> usize {
    (n - r + 1..n+1).fold(1, |ac, x| ac * x % d) * inv_m((1..r+1).fold(1, |ac, x| ac * x % d), d) % d
}


Measured memory_bytes: 4352
#include<cstdio>
using namespace std;
int a[110];
int main()
{
	int n,sum=0,p,ans;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	p=double(sum)/n;
	ans=0;
	for(int i=0;i<n;++i)
		ans+=(p-a[i])*(p-a[i]);
	sum=0;
	for(int i=0;i<n;++i)
		sum+=(p+1-a[i])*(p+1-a[i]);
	if(sum<ans)ans=sum;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
    ll N,H,W;
    ll count=0;
    cin >> N >> H >> W;
    int a[N],b[N];
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i];
        if(a[i]>=H&&b[i]>=W){
            count++;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

string s;
string stacksss[5];
string t;
int top=0;
int k,n;
int main()
{
    cin>>s;
    cin>>k;
    n=s.length();
    stacksss[0]+=s[0];
    for(int i=0;i<n;i++)
    {
        t="";
        for(int j=0;j<min(k,n);j++)
        {
            if(i+j<n) t=t+s[i+j];
            else break;
            if(top<4)
            {
                int add=1;
                for(int l=0;l<=top;l++)
                    if(t==stacksss[l]) add=0;
                if(add)
                {
                    top++;
                    stacksss[top]=t;
                    sort(stacksss,stacksss+top+1);
                }
            }
            else if(top==4)
            {
                int add=1;
                for(int l=0;l<=top;l++)
                    if(t==stacksss[l]) add=0;
                if(add)
                {
                    if(t<stacksss[top]) stacksss[top]=t;
                    sort(stacksss,stacksss+top+1);
                }
            }
        }
    }
    cout<<stacksss[k-1]<<endl;
	return 0;
}

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

int main(){
  int P; scanf("%d", &P);
  int Q; scanf("%d", &Q);
  int R; scanf("%d", &R);

  int max = P + Q;
  if(max > Q + R) max = Q + R;
  if(max > P + R) max = P + R;

  printf("%d", max);
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<(b);i++)
#define ll long long
#define re return
#define mp map<int,int>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	vector<int> Typical(n+1);
	rep(i,0,m){
		int x;
		cin>>x;
		Typical[x]=1;
	}
	vector<int> ans(n+2);
	int mod=1000000007;
	ans[n]=1;
	ford(i,n-1,0){
		if(Typical[i]) {
			ans[i]=0;
			continue;
		}
		ans[i]=(ans[i+1]+ans[i+2])%mod;
	}
	cout<<ans[0];
	re 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll ans = 0;
    ll n,x,t;
    
    cin >> n  >> x >> t;

    ans = (n/x)*t;
    if(n%x!=0)
        ans += t;
    
    cout << ans << endl;
 
    return 0;
}



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

using namespace std;

int n, a[10], b[10];

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    
    int x = 0, y = 0;
    vector <int> vec;
    for (int i = 1; i <= n; i++) vec.push_back(i);
    
    do {
        x++;
        bool ok = true;
        for (int i = 1; i <= n; i++) {
            if (a[i] != vec[i - 1]) {
                ok = false;
                break;
            }
        }
        
        if (ok) break;
    } while (next_permutation(vec.begin(), vec.end()));
    
    vector <int> vec2;
    for (int i = 1; i <= n; i++) vec2.push_back(i);
    
    do {
        y++;
        bool ok = true;
        for (int i = 1; i <= n; i++) {
            if (b[i] != vec2[i - 1]) {
                ok = false;
                break;
            }
        }
        
        if (ok) break;
    } while (next_permutation(vec2.begin(), vec2.end()));
    
    cout << abs(x - y);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ld, ll, ll>> vtll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  str s; cin >> s;
  vs f = {"Sunny", "Cloudy", "Rainy"};
  if(s == f[0]) fin(f[1]);
  else if(s == f[1]) fin(f[2]);
  else fin(f[0]);
  return;
}

//前処理
int main()
{
  int ti = clock();
  srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

void solve(){
  int h1, m1, h2, m2, k, t1, t2, ans; cin >> h1 >> m1 >> h2 >> m2 >> k;
  t1 = h1 * 60 + m1;
  t2 = h2 * 60 + m2;
  ans = max(t2 - t1 - k, 0);
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 3636
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

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

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

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


int32_t main() {
	boost; IO();

	int N; cin>>N;
	vi a(N);
	vi cum(N,0);
	for(int i=0; i<N; i++) cin>>a[i],cum[i]=a[i];

	

	for(int i=N-2; i>=0; i--) cum[i]+=cum[i+1],cum[i]%=MOD;

	int x=0;
	for(int i=0; i<N-1; i++){
		int v=(a[i]*cum[i+1])%MOD;
		x+=v; x%=MOD;
	}
	cout << x << endl;
	//cout << x << endl;



	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


Measured memory_bytes: 6356
#include <iostream>
#include <cstdio>
#include <string>

int main() {
    std::string str;   std::cin >> str;
    std::string ans;
    for (auto s: str) {
        if (s != 'B') ans += s;
        else if (!ans.empty()) {
            auto it = ans.end();
            ans.erase(--it);
        }
    }
    printf("%s\n", ans.c_str());
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    //super header :標準ライブラリ,STLを全てインクルード
using namespace std;

int main(){
    int N,M,C;
    int b[20] = {};
    cin >> N >> M >> C;
    for(int i = 0; i < M; i++)
    {
        int tmp;
        cin >> tmp;b[i] = tmp;
    }
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        int sum = 0;
        for(int j = 0; j < M; j++){
            int tmp;cin >> tmp;
            sum += tmp * b[j];
        }
        if(sum + C > 0)ans++;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int i, j, k, n, t, m, h, w, g;
	int l1, r1;
	int f = 0;
	int l, r;

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

	l = 1;
	r = n;

	for (i = 0;i < m;i++) {
		scanf("%d %d", &l1, &r1);
		if (l1 > l) {
			l = l1;
		}
		if (r1 < r) {
			r = r1;
		}

	}

	f = r - l + 1;

	if (f < 0) {
		f = 0;
	}

	printf("%d", f);


	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Main main = new Main();
	main.solveC();
    }
    private void solveC() {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	String s = sc.next();
	int[] dpw = new int[n];
	int[] dpe = new int[n];

	if (s.charAt(0) == 'W'){
	    dpw[0] = 1;
	}
	else{
	    dpw[0] = 0;
	}	
	for(int i=1; i<n; i++){
	    if (s.charAt(i) == 'W'){
		dpw[i] = dpw[i-1] + 1;
	    }
	    else{
		dpw[i] = dpw[i-1];
	    }
	}

	if (s.charAt(n-1) == 'E'){
	    dpe[n-1] = 1;
	}
	else{
	    dpe[n-1] = 0;
	}	
	for(int i=n-2; i>=0; i--){
	    if (s.charAt(i) == 'E'){
		dpe[i] = dpe[i+1] + 1;
	    }
	    else{
		dpe[i] = dpe[i+1];
	    }
	}
	
	int ans = 1000000;
	for(int i=0; i<n; i++){
	    ans = Math.min(ans,dpw[i] + dpe[i] - 1);
	}	
	System.out.println(ans);
    }
}


Measured memory_bytes: 31144
/*
 * Author:heroming
 * File:heroming.cpp
 * Time:2017/01/07 08:04:35
 */
#include <vector>
#include <list>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <unordered_map>
using namespace std;

#define px first
#define py second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define clr(v, e) memset(v, e, sizeof(v))
#define rep(it, v) for (auto it : v)
#define forn(i, n) for (int i = 0; i < (n); ++ i)
#define rforn(i, n) for (int i = (n) - 1; i >= 0; -- i)
#define form(i, a, b) for (int i = (a); i <= (b); ++ i)
#define rform(i, a, b) for (int i = (b); i >= (a); -- i)
#define forv(i, v) for (int i = 0; i < sz(v); ++ i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++ it)

typedef long long lint;
typedef vector<int> vint;
typedef vector<string> vstring;
typedef pair<int, int> pint;
typedef vector<lint> vlint;
typedef vector<pint> vpint;

int main() {
    int n, s;
    while (cin >> n >> s) {
        lint ans = 0;
        form (x, 0, n) form (y, 0, n) {
            int z = s - x - y;
            if (0 <= z && z <= n) ++ ans;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <__msvc_all_public_headers.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
 
typedef long long  ll;

#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define halt {cout<<"NO"; return 0;}

const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int N = 200010;
const int INF = 1e8;
const ll LL_INF=1e10;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int questions=1;
// cin>>questions;
 
 while(questions--)
 {
       int n;
       cin>>n;
       if(n>=30) puts("Yes");
       else cout<<"No";
 }
 
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3608