akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

ll dp[2][505][505],a[505][505];
ll sum_up[505][505],sum_down[505][505];
int n;

int main(){
	cin >> n;
	repn(i,n) repn(j,n) if(i != j) scanf("%lld",&a[i][j]);
	for(int i=n;i>=1;i--){
		for(int j=i;j<=n;j++){
			sum_up[i][j] = sum_up[i][j-1]+sum_up[i+1][j]-sum_up[i+1][j-1]+a[i][j];
		}
	}
	for(int i=n;i>=1;i--){
		for(int j=i;j<=n;j++){
			sum_down[i][j] = sum_down[i][j-1]+sum_down[i+1][j]-sum_down[i+1][j-1]+a[j][i];
		}
	}
	rep(a,2)rep(b,505)rep(c,505)dp[a][b][c] = -1e18;
	int cur = 0, nxt = 1;
	for(int i=1;i<=n;i++){
		rep(b,505)rep(c,505) dp[nxt][b][c] = -1e18;
		repn(j,i-1) for(int k=j;k<i;k++){
			if(dp[cur][j][k] < -8e17) continue;
			dp[nxt][j][k] = max(dp[nxt][j][k],dp[cur][j][k]);
			//[k+1][i]
			dp[nxt][k+1][i] = max(dp[nxt][k+1][i],dp[cur][j][k]-sum_up[k+1][i]+sum_down[j][i]-sum_down[j][k]);
		}
		dp[nxt][1][i] = max(dp[nxt][1][i],-sum_up[1][i]+sum_down[1][i]);
		swap(cur,nxt);
	}
	ll ans = -1e18;
	repn(i,n) ans = max(ans,dp[cur][i][n]+sum_up[1][n]);
	cout << sum_up[1][n]+sum_down[1][n]-ans << endl;
}

Measured memory_bytes: 10240
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		StringBuilder sb = new StringBuilder();
		String string = sc.next();

		for(int i = 0;i < string.length();i++){
			if(string.charAt(i) == '0'){
				sb.append("0");
			}else if(string.charAt(i) == '1'){
				sb.append("1");
			}else{
				if(sb.length()>0){
					sb.deleteCharAt(sb.length()-1);
				}
			}
		}
		System.out.println(sb.toString());


	}
}

Measured memory_bytes: 23124
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN [IUT CSE(SWE)-19]

#include<bits/stdc++.h>
using namespace std;

#define fastio          ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define read            freopen("blue.txt","r",stdin);
#define write           freopen("red.txt","w",stdout);

using ll=long long;
using ull=unsigned long long;
const double pi = 2*acos(0.0);

int  main()
{

    fastio;
    
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<i+1<<endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 3604
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	int zcount = 0;
	mint count = 1;
	int next[3] = {0,0,0};
	if(a[0]){
		print(0);
		return 0;
	}
	zcount = 1;
	next[0] = 1;
	for(int i=1;i<n;i++) {
		debug(next[0],next[1],next[2]);
		if(a[i]==0) {
			zcount++;
			if(zcount>3) {
				print(0);
				return 0;
			}
			next[zcount-1]++;
			continue;
		}
		int same = 0;
		rep(j,zcount) {
			if(next[j]==a[i]) {
				if(same==0) next[j]++;
				same++;
			}
		}
		debug(same);
		// for(int l=1;l<=same;l++) count*=l;
		count*=same;
		if(same==0) {
			print(0);
			return 0;
		}
	}
	debug(zcount,count);
	for(int i=0;i<zcount;i++) count*=3-i;
	print(count);

	return 0;
}


Measured memory_bytes: 1024
import java.util.Map.Entry;
import java.util.*;
 
//import org.w3c.dom.css.Counter;
 
public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
     final int X = Integer.parseInt(s.next());
     //final int M = Integer.parseInt(s.next());
     int how = X /200;
     System.out.println(10 - how);

 

    
/*
     for(int i=0; i< K;i++){
        int di = Integer.pa rseInt(s.next());
        String blank = s.nextLine();
        String huge = s.nextLine();

        String[] hage = huge.split(" ",0);
        int hageN= hage.length;
        for (int num =0;num<hageN;num++){
            if(!hashSet.contains(hage[num])){
                hashSet.add(hage[num]);
            }
        }

     }
     s.close();

     System.out.println(N-hashSet.size());


}
*/
}
}

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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    int n;
    cin >> n;
    string S[n],tmp="abcdefghijklmnopqrstuvwxyz";
    map<char,int>m;
    map<char,int>ans;
    for(int i = 0; i < n; i++) {
        cin >> S[i];
        for(int j = 0; j < S[i].size(); j++) {
            m[S[i][j]]++;
        }
        if(i >= 1) {
            for(int j = 0; j < 26; j++) {
                ans[tmp[j]] = min(ans[tmp[j]],m[tmp[j]]);
                m[tmp[j]] = 0;
            }
        }else {
            for(int j = 0; j < 26; j++) {
                ans[tmp[j]] = m[tmp[j]];
                m[tmp[j]] = 0;
            }
        }
    }

    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < ans[tmp[i]]; j++) {
            cout << tmp[i];
        }
    }
    cout << endl;
    return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans=0;
  for(int i=1;i<N;i++){
    int sum=0;
    vector<int> flag(N);
    for(int j=0;j<i;j++){
      for(int k=i;k<N;k++){
        bool same=false;
        for(int m=0;m<j;m++){
          if(S.at(j)==S.at(m)){
            same=true;
            break;
          }
        }
        if(same){
          break;
        }
        if(S.at(j)==S.at(k)){
          flag.at(j)=1;
        }
      }
    }
    for(int l=0;l<N;l++){
      if(flag.at(l)==1){
        sum++;
      }
    }
    ans=max(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/**
*    created: 02.08.2020 20:07:33
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    int ans = 0;
    ans += n / 25;
    n %= 25;
    ans += n / 10;
    n %= 10;
    ans += n / 5;
    n %= 5;
    ans += n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <set>
using namespace std;
int main(){
  string s;
  cin >> s;

  set<char> st;
  for(int i=0;i<s.size();i++){
    st.insert(s[i]);
  }

  for(int i=0;i<26;i++){
    char c = 'a'+i;
    auto itr = st.find(c);
    if(itr == st.end()){
      cout << c << endl;
      break;
    }

    if(i == 25){
      cout << "None\n";
    }
  }

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    string s;
    cin >> s;
    int result = 0;
    for(int i=0;i<s.length() / 2;i++){
        if(s[i] != s[s.length()-i-1]){
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
N,M=gets.chomp.split.map(&:to_i)
sc=M.times.map { gets.chomp.split.map(&:to_i) }

flag=1

  if N==1 then
    for i in 0..9 do
      flag=1
      M.times do |j|
        if i.to_s.split("")[(sc[j][0])-1].to_i != sc[j][1] then
          flag=0
        end
      end
      if flag==1 then
        puts i
        exit
      end
    end
  elsif N==2 then
    for i in 10..99 do
      flag=1
      M.times do |j|
        if i.to_s.split("")[(sc[j][0])-1].to_i != sc[j][1] then
          flag=0
        end
      end
      if flag==1 then
        puts i
        exit
      end
    end
  elsif N==3 then
    for i in 100..999 do
      flag=1
      M.times do |j|
        if i.to_s.split("")[(sc[j][0])-1].to_i != sc[j][1] then
          flag=0
        end
      end
      if flag==1 then
        puts i
        exit
      end
    end
  end
  puts '-1'

Measured memory_bytes: 2044
#include <iostream>

int calc(long long start, long long end)
{
    long long a = start;
    int c = 1;
    while(a <= end)
    {
        //std::cout << a << " ";
        a *= 2;
        ++c;
    }
    std::cout << std::endl;
    return c-1;
}

int main(void)
{
    long long s, e;
    std::cin >> s >> e;
    int a = calc(s, e);
    std::cout << a << std::endl;
    return 0;
}


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

ll n,a,b,ans1,ans2;
vector<ll>ar[100005];
ll visit[100005];

ll bfs(ll s,ll p)
{
    visit[s]=1;
    visit[p]=2;
    queue<ll>q;
    q.push(s);
    q.push(p);

    while(!q.empty())
    {
        ll x = q.front();
        q.pop();
        if(visit[x]==1)
            ans1++;
        else ans2++;

        for(int i=0;i<ar[x].size();i++)
        {
            if(visit[ar[x][i] ]==0)
            {
                q.push(ar[x][i]);
                visit[ar[x][i] ]=visit[x];
            }
        }
    }
}

int main()
{
    cin>>n;
    for(int i=1;i<n;i++)
    {
        cin>>a>>b;
        ar[a].push_back(b);
        ar[b].push_back(a);
    }
    memset(visit,0,sizeof(visit));
    bfs(1,n);
    if(ans1>ans2) cout<<"Fennec\n";
    else cout<<"Snuke\n";
}


Measured memory_bytes: 7296
#include<iostream>
#include<vector>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N,M,K;
vector<int>B[1<<17];
main()
{
	cin>>N>>M>>K;
	UF uf(N);
	for(int i=0;i<M;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		uf.unite(a,b);
		B[a].push_back(b);
		B[b].push_back(a);
	}
	for(int i=0;i<K;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		B[a].push_back(b);
		B[b].push_back(a);
	}
	for(int i=0;i<N;i++)
	{
		int ans=uf.size(i)-1;
		for(int v:B[i])
		{
			if(uf.find(i)==uf.find(v))ans--;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 9088
import itertools
H, W, K = map(int, input().split())
grid = []
for _ in range(H):
    line = list(input())
    grid.append(line)
# 横に割る方法は(H-1)**2通り、高々81通り
# これを決め打ちして、縦の割り方はGreedyに

ans = 10**9

# 割る場合を1, 割らない場合を0で表すことにする
for ptn in itertools.product([0, 1], repeat=H - 1):

    # 不可能な場合、そのパターンはスキップする###############
    able = True
    for w in range(W):
        # それぞれのブロックにおける白の数
        lines = [0] * (sum(ptn) + 1)
        # 今、上から何ブロック目か
        line_num = 0
        for h in range(H):
            # 白の場合
            if grid[h][w] == "1":
                lines[line_num] += 1

            # 境界を引く場合
            # h=H-1の時、indexが範囲外になるのでminを使って調整
            if ptn[min(h, H - 2)] == 1:
                line_num += 1
        # 1列でK個を超えるブロックがある場合、その割り方は不適。
        if max(lines) > K:
            able = False
            break
    if able == False:
        continue
    # 以下、実現が可能なものとして考える#####################

    lines = [0] * (sum(ptn) + 1)
    cnt = sum(ptn)
    w = 0
    while w < W:
        line_num = 0
        for h in range(H):
            if grid[h][w] == "1":
                lines[line_num] += 1
            if ptn[min(h, H - 2)] == 1:
                line_num += 1
        # print(ptn, w, lines)
        if max(lines) > K:
            cnt += 1
            lines = [0] * (sum(ptn) + 1)
            w -= 1
        w += 1
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 75612
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    int type = sc.nextInt();
		    int x = sc.nextInt();
		    if (type == 0) {
		        set.add(x);
		        sb.append(set.size()).append("\n");
		    } else if (type == 1) {
		        if (set.contains(x)) {
		            sb.append(1);
		        } else {
		            sb.append(0);
		        }
		        sb.append("\n");
		    } else {
		        set.remove(x);
		    }
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 147156
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl '\n';
#define all(v) ((v).begin()), ((v).end())
#define sz(s)               (int)s.size()
#define Ceil(x,y)             ((x+y-1)/y)
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define vi                    vector<int>
#define pii                 pair<int,int>
#define fx(n)           fixed<<setprecision(n)
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define forr(i, n) for (int i = 0; i < int(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, MOD = 1e9 + 7;
using namespace std;
void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); }
int main()
{
	fast();
	ll n;
	cin>>n;
	vector<ll>v(2*n);
	for(int i=0;i<2*n;i++)
        cin>>v[i];
    sort(all(v));
    ll ans=0;
    for(int i=0;i<2*n;i+=2)
    {
        //cout<<v[i]<<" "<<v[i+1]<<"\n";
        ans+=min(v[i],v[i+1]);
    }
    cout<<ans<<"\n";
	return 0;
}


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

int main() {

    int n;
    cin >> n;
    int a = 0, b = 0, c = 0;
    while (n--) {
        int t, x, y;
        cin >> t >> x >> y;

        int w = abs(x - a) + abs(y - b);

        int q = t - c;
        if (q >= w && abs(q - w) % 2 == 0) {
            a = x;
            b = y;
            c = t;
            continue;
        }
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

}


Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split()))

# Nから順に決めていけば必ず決められる
# 見なければいけない数は、N/2, N/3, ... N/N個 = だいたいNlogN

arr = [0] * (N+1)
ans = []
for i in range(N, 0, -1):
  a = (sum(arr[i::i])+A[i]) % 2
  arr[i] = a
  if a:
    ans.append(i)
print(len(ans))
if len(ans):
  print(' '.join(list(map(str, ans))))

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

string s;
int cnt2;
map<int, int> m;

int main() {
	cin >> s;
	for (auto x : s) {
		++m[x];
		if (m[x] == 2) ++cnt2;
	}
	if (cnt2 == 2) cout << "Yes";
	else cout << "No";
	return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  int min = INF;
  for (int i = 1; i <= 5; i++) {
    int tmp;
    cin >> tmp;
    chmin(min, tmp);
  }

  cout << (N + min - 1) / min + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
  char num[100000] ={0};
  int i;
  scanf("%s",num);
  int len = strlen(num);
  for(i=0;i<len;i++){
    if(num[i] - '0' == num[i+1] - '0' && num[i] - '0' == num[i+2] - '0'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::ios_base::sync_with_stdio(false);
    int a, b;
    std::cin >> a >> b;
    int n = b - a;
    int h = n * (n + 1) / 2;
    std::cout << (h - b) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
using namespace std;
int main() {
	// your code goes here
	string s; cin>>s;
	int n = s.length();
	for(int i=0;i<n;i++) if(!(i&1)) printf("%c",s[i]);
	printf("\n");
	return 0;
}

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

int main(){
  string s;
  cin>> s;
  
  string ans="Good";
  for (int i=0; i<3; i++){
    if (s.at(i)==s.at(i+1)){
      ans="Bad";
      break;
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;


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

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

  vector<int> h(n);
  int max_h = 0; int count = 0;
  rep(i, n) {
      cin >> h[i];
      if (max_h <= h[i]) 
      {
          max_h = h[i];
          count++;
      }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC103_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int[] a = new int[array.Length];

            int max = a[0];

            for (int i = 0; i < a.Length; i++)
            {
                a[i] = int.Parse(array[i]);
                if (max <= a[i])
                {
                    max = a[i];
                }
            }
            int min = a[0];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = int.Parse(array[i]);
                if (a[i] < min)
                {
                    min = a[i];

                }
            }
            int mid = a[0];
            for (int i = 0; i < a.Length; i++)
            {
               a[i] = int.Parse(array[i]);
                if ((a[i] != max) && (a[i] != min))
                {
                    mid = a[i];
                }
            }
            
            
            Console.WriteLine(10 * max + min + mid);

        }

    }
}


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


int main()
{
  ll n;
  string s;
  cin >> n >> s;
  vector<string> suf(n);
  for (ll i = 0; i < n; ++i) {
    suf[i] = s.substr(i);
  }

  sort(suf.begin(), suf.end());
  ll len = 0;
  vector<ll> sufmax(n);
  for (ll i = 0; i < n; ++i) {
    sufmax[i] = (i < suf[0].size()) ? suf[0].size() : -1;
  }
  for (ll i = 1; i < n; ++i) {
    const ll l1 = suf[i].size();
    ll j = 0;
    for ( ; j < l1 && (sufmax[j] != -1); ++j) {
      if (suf[i-1][j] != suf[i][j]) {
        break;
      }
      ll newl = min((j+1), abs(sufmax[j] - l1));
      if (len < newl) {
        len = newl;
      }
      if (l1 > sufmax[j]) {
        sufmax[j] = l1;
      }
    }
    for ( ; j < n; ++j) {
      sufmax[j] = (j < l1) ? l1 : -1;
    }
  }

  for (ll i = 0; i < n; ++i) {
    sufmax[i] = (i < suf[n-1].size()) ? suf[n-1].size() : -1;
  }
  for (ll i = n-2; i >= 0; --i) {
    const ll l1 = suf[i].size();
    ll j = 0;
    for ( ; j < l1 && (sufmax[j] != -1); ++j) {
      if (suf[i+1][j] != suf[i][j]) {
        break;
      }
      ll newl = min((j+1), abs(sufmax[j] - l1));
      if (len < newl) {
        len = newl;
      }
      if (l1 > sufmax[j]) {
        sufmax[j] = l1;
      }
    }
    for ( ; j < n; ++j) {
      sufmax[j] = (j < l1) ? l1 : -1;
    }
  }

  cout << len << endl;
  return 0;
}



Measured memory_bytes: 16128
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

	string S;

	int K;
	
	cin >> S >> K;

	int i = 0;
	while(S[i] == '1')
	{
		i++;
	}

	if (K<=i)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << S[i] << endl;
	}

	
	return 0;
}


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

#define N 200000

int main(void){

  int n, num[N], max_profit=-1000000000, min_val;
  
  scanf("%d", &n);
  
  for(int i=0; i<n; i++){
    scanf("%d", &num[i]);
    if(!i) min_val=num[i];
  }

  for(int i=1; i<n; i++){
    if(num[i]-min_val > max_profit) max_profit=num[i]-min_val;
    if(min_val > num[i]) min_val=num[i];
  }

  printf("%d\n", max_profit);
  
  return 0;
}



Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
#define prl cerr<<"called: "<< __LINE__ << endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int M = 1e9 + 7;
int32_t main(){
  fastio;
  int n;
  cin >> n;
  ll cur = mod(exp(10,n,M) - exp(9,n,M)*2 + exp(8,n,M),M);
  
  cout << cur << endl;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

int N;
int main() {
  while (cin >> N, N) {
	vector<char> mem(N);
	vector<int> num(26, 0);
	for (int i = 0; i < N; ++i) cin >> mem[i], num[mem[i]-'A']++;
    int maxnum = 0;
	vector<int> maxs;
	for (int i = 0; i < 26; ++i) {
	  if (maxnum < num[i]) {
		maxnum = num[i];
		maxs.clear(); maxs.push_back(i);
	  }
	  else if (maxnum == num[i]) maxs.push_back(i);
	}
	if (maxs.size() > 1) cout << "TIE" << endl;
	else {
	  int maxid = maxs[0];
	  cout << (char)('A' + maxid) << " ";
	  int res = 0;
	  vector<int> tnum(26, 0);
	  for (res = 0; res < N; ++res) {
		tnum[mem[res]-'A']++;
		vector<int> nums;
		for (int i = 0; i < 26; ++i) if (i != maxid) nums.push_back(tnum[i]);
		sort(nums.begin(), nums.end(), greater<int>());
		if (tnum[maxid] > nums[0] + (N-1 - res)) break;
	  }
	  cout << res+1 << endl;
	}
  }
}


Measured memory_bytes: 3076
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
    double a,b,x;
    cin>>a>>b>>x;
    if(2*x>a*a*b)
    {
        double k=(2*(a*a*b-x ))/(a*a);
        printf("%.10lf",90-atan(a/k) *180.0/3.1415926535898);
    }
    else
    {
         double k=(2*x)/(a*b);
          printf("%.10lf",90-atan(k/b) *180.0/3.1415926535898);
    }
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){

    int n,r;
    cin>>n>>r;


    //cout<<"running"<<endl;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+100*(10-n)<<endl;
    
    }

return 0;
}

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

int main()
{
	int n, m, t = 0, j = 0;
	long long s = 0;

	cin >> n >> m;

	vector<pair<int, int>> p(n);

	for (int i = 0; i < n; i++)
		cin >> p[i].first >> p[i].second;

	sort(p.begin(), p.end());

	while (t < m && j < n) {
		s += (long long)p[j].first * (long long)p[j].second;
		t += p[j].second;
		j++;
	}

	s -= (long long)p[j - 1].first * (long long)(t - m);

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int[] a = new int[n];
			for(int i=0; i<n; i++) a[i] = sc.nextInt();
			Arrays.sort(a);
			int ans = 1000000;
			for(int i=0; i<n-1; i++) {
				ans = Math.min(ans, a[i+1]-a[i]);
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 48124
import sys
input = lambda: sys.stdin.readline().rstrip()
N, X = map(int, input().split())
P = 998244353

A = [[0] * (2*i+1) for i in range(N+1)] # A[i][j] is the number of permutations of 1's and 2's whose length is i and whose sum is j
A[0][0] = 1
B = [0] * (N + 1) # B[i] is the number of permutations of 1's and 2's with length i none of whose consecutive subsequenses is equal to X
for i in range(N):
    for j in range(i, 2*i+1):
        A[i+1][j+1] += A[i][j]
        A[i+1][j+2] += A[i][j]
        if A[i+1][j+1] >= P: A[i+1][j+1] -= P
        if A[i+1][j+2] >= P: A[i+1][j+2] -= P

# Type 1: Sum is below X
for i in range(N+1):
    for j in range(i, min(2*i+1, X)):
        B[i] += A[i][j]

# Type 2: Sum is 2X or more
if X % 2:
    for i in range(X, N+1):
        B[i] += 1

# Type 3: X <= Sum < 2X
for i in range(1, X):
    a = X - 1 - 2 * i
    if a < 0: continue
    for j in range((a+1) // 2, a + 1):
        k = j + 2 * i
        if k > N: break
        B[k] += A[j][a]
        if B[k] >= P: B[k] -= P

ans = 0
for i, b in enumerate(B):
    ans = (ans + b * A[-1][-1-i]) % P

print(ans)

Measured memory_bytes: 113244
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
 
#define int __int128
#define long __int128
 
ostream &operator<<(ostream &os, __int128_t value) {
    if (ostream::sentry(os)) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[64];
        char *d = end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = end(buffer) - d;
        if (os.rdbuf()->sputn(d, len) != len) {
            os.setstate(ios_base::badbit);
        }
    }
    return os;
}
 
istream &operator>>(istream &is, __int128_t &value) {
    string in;
    is >> in;
    value = 0;
    for (const char &c : in) {
        if ('0' <= c && c <= '9') value = 10 * value + (c - '0');
    }
    if (in[0] == '-') value *= -1;
    return is;
}

signed main(){
    int N;
    cin >> N;
    vector<bool> sieve_of_primes(1e5, true);
    for(int i = 2; i * i < 1e5; i++){
        if(sieve_of_primes[i]){
            for(int j = i * 2; j < 1e5; j += i){
                sieve_of_primes[j] = false;
            }
        }
    }
    vector<long> primes;
    for(int i = 2; i < 1e5; i++){
        if(sieve_of_primes[i]){
            primes.push_back(i);
        }
    }
    map<long, int> nums;
    bool is_in_1 = false;
    for(int i = 0; i < N; i++){
        long num;
        cin >> num;
        for(long j = 0; primes[j] * primes[j] * primes[j] <= num; ){
            if(num % (primes[j] * primes[j] * primes[j]) == 0){
                num /= primes[j] * primes[j] * primes[j];
            }else{
                j++;
            }
        }
        if(num == 1){
            is_in_1 = true;
        }else{
            nums[num]++;
        }
    }
    long ans = 0;
    for(auto item: nums){
        pair<long, int> i = item;
        long i_tmp = i.first;
        long cube_pair_another = 1;
        for(long j = 0; primes[j] * primes[j] * primes[j] <= i.first; j++){
            if(i.first % (primes[j] * primes[j]) == 0){
                cube_pair_another *= primes[j];
                i_tmp /= primes[j] * primes[j];
            }else if(i.first % primes[j] == 0){
                cube_pair_another *= primes[j] * primes[j];
                i_tmp /= primes[j];
            }
        }
        cube_pair_another *= i_tmp * i_tmp;
        ans += max(i.second, nums[cube_pair_another]);
        nums[i.first] = 0;
        if(nums[cube_pair_another]){
            nums[cube_pair_another] = 0;
        }else{
            nums.erase(cube_pair_another);
        }
    }
    cout << ans + is_in_1 << endl;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <iostream>
#include <vector>

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

#define INF 1000000000

using namespace std;

int main() {
    int N, M;
    cin >> N;
    cin >> M;

    vector<int> requirements(N, -1);

    for (int i = 0; i < M; ++i) {
        int s, c;
        cin >> s;
        cin >> c;
        s--;

        if (requirements[s] != -1 && requirements[s] != c) {
            cout << "-1" << endl;
            return 0;
        }

        requirements[s] = c;
    }

    for (int i = 0; i <= 1000; ++i) {
        bool fail = false;
        auto str = to_string(i);

        if (str.length() != N)
            fail = true;

        for (int j = 0; j < N; ++j) {
            int check = str[j] - '0';
            if (check != requirements[j] && requirements[j] != -1)
                fail = true;
        }

        if (!fail) {
            cout << i << endl;
            return 0;
        }
    }

    cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    long long cnt(0);
    std::vector<int> L(N);
    for(int i(0); i < N; ++i) std::cin >> L[i];
    std::sort(std::begin(L), std::end(L));
    for(int mid(1), mid_len(N-1); mid < mid_len; ++mid){
        for(int high(mid+1); high < N; ++high){
            int lowlow(L[high] - L[mid] + 1);
            cnt += std::max(0L, std::distance(std::lower_bound(std::begin(L), std::end(L), lowlow), std::begin(L) + mid));
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	char A, B;
	cin >> A >> B;
	if (A > B) {
		cout << ">" << endl;
	} else if(A==B){
		cout << "=" << endl;
	} else {
		cout << "<" << endl;
	}
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    cout << (a > b ? a - 1 : a) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String X = sc.next();
    	String Y = sc.next();
    	sc.close();
    	if(X.equals(Y)){
    		System.out.println("=");
    	}else if(X.compareTo(Y) < 0){
    		System.out.println("<");
    	}else{
    		System.out.println(">");
    	}
    }
}

Measured memory_bytes: 22868
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author i.mekni
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner read = new Scanner(System.in);

        PrintWriter write = new PrintWriter(System.out);

        int k = read.nextInt();
        int n = read.nextInt();
        
        int max=0;
        int first=read.nextInt();
        int a=first;
        int b;
        for(int i=1;i<n;i++){
            b=read.nextInt();
            if(b-a>max) max=b-a;
            a=b;
        }
        if(k-a+first>max) max=k-a+first;
        write.println(k-max);
        write.close();
    }

}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    double a, b, x;
    cin >> a >> b >> x;
    double pi = atan(1)*4;
    double y = x/a;
    double angle = 0;
    if (2*y >= a*b) {
        // z is remaining triangle
        double z = a*b - y;
        // z <= ab/2.
        // z = ad/2 with d <= b
        double d = 2*z/a;
        // so we have a rectangular triangle with sides a and d.
        angle = pi/2 - atan(d/a);
        
    } else {
        // y <= ab/2
        // y = cb/2 with c <= a
        // so we have a rectangular triangle with sides c and b.
        double c = 2*y/b;
        angle = atan(c/b);
    }
    cout << setprecision(20) << 90 - angle * 180 / pi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define ALL(x) (x).begin(),(x).end()
using namespace std;
const int MAXN = 200005;

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int>A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int flag= 1;
    while(k--&&flag){
        flag = 0 ;
        vector<int>B(n);
        for(int i=0;i<n;i++){
            B[max(0,i-A[i])]++;
            if(i+A[i]+1<n)
                B[i+A[i]+1]--;
        }
        for(int i=1;i<n;i++){
            B[i]+=B[i-1];
            //cout << B[i] <<" \n"[i=n-1];
            if(B[i]!=n)
                flag=1;
        }
        if(B[0]!=n)
            flag=1;
        A=B;
    }
    for(int i=0;i<n;i++)
    cout <<A[i]<<" ";
    return 0;
}


Measured memory_bytes: 4872
#include<stdio.h>
#include<string.h>

int main()
{
 int n,i;
  char s[101],c[101],a[101];
  
(void)scanf("%d %s",&n,s);
  
  if (n % 2 !=0)
  {
    printf("No");
    return 0;
  }
  
  for (i=0;i<n/2;i++)
  {
      //printf("%c\n",s[i]);
      //printf("%c\n",s[n/2+i]);
    
 	if ( s[i]!=s[n/2+i] )
   {
    printf("No");
    return 0;
   }
  }
  
     printf("Yes");
  
return 0;
}

Measured memory_bytes: 1688
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if(a%3==0||b%3==0||(a+b)%3==0) printf("Possible");
	else printf("Impossible");
	return 0;
}


Measured memory_bytes: 128
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 998244353, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q, s;
ll dp[3001][3001];

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

  cin >> n >> s;
  rep(i, n) cin >> a[i];
  dp[0][a[0]] = 1;
  rrep(i, 1, n) {
    dp[i][a[i]] += i + 1;
    rep(j, s + 1) {
      (dp[i][j] += (j < a[i] ? 0LL : dp[i - 1][j - a[i]]) + dp[i - 1][j]) %=
          MOD;
    }
  }
  rep(i, n) { (ans += dp[i][s]) %= MOD; }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 71936
N = int(input())
S = input()

lE = [0] * N
lW = [0] * N
le = lw = 0
for i in range(N):
    if S[i] == "E":
        le += 1
    else:
        lw += 1
    lE[i] = le
    lW[i] = lw

rtn = lE[-1] - lE[0]

for i in range(1, N):
    tmp = lW[i-1] + lE[-1] - lE[i]
    if tmp <= rtn:
        rtn = tmp


print(rtn)

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n;
	cin>>n;
	vii v(n);vi vs(n);iota(all(vs),0);
	for(int i=0;i<n;++i){
		cin>>v[i].ff >> v[i].ss;
	}
	vll dist;
	int tot=0;
	do{
		++tot;
		for(int i=1;i<n;++i){
			ll dx = (v[vs[i]].ff-v[vs[i-1]].ff)*(v[vs[i]].ff-v[vs[i-1]].ff);
			ll dy = (v[vs[i]].ss-v[vs[i-1]].ss)*(v[vs[i]].ss-v[vs[i-1]].ss);
			dist.pb(dx+dy);
		}
	}while(next_permutation(all(vs)) );
	long double pqp=0.0,na=0.0;
	for(int i=0;i<dist.size();++i){
		pqp+=sqrt(dist[i]);
		na+=dist[i];
	}
	cout.precision(10);
	cout<<fixed<<pqp/(double)tot<<endl;
	return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n),b(n+1);
	vector<pair<int,int>> p;
	for(int i=0;i<n;i++){
		cin >> a[i];
		p.push_back(make_pair(abs(12-a[i]),a[i]));
	}
	p.push_back(make_pair(12,0));
	sort(p.begin(),p.end());
	int s=1;
	for(int i=0;i<=n;i++){
		if(s==1){
			b[i]=min(p[i].second,24-p[i].second);
		}
		else{
			b[i]=max(p[i].second,24-p[i].second);
		}
		s^=1;
	}
	sort(b.begin(),b.end());
	int diff=24;
	for(int i=0;i<n;i++){
		diff=min(diff,b[i+1]-b[i]);
	}
	diff=min(diff,24-b[n]+b[0]);
	cout << diff << endl;
}

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

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    int A, B;
    scanf("%d %d", &A, &B);
    printf("%d\n", A*B);
}

/*
in:


out:

*/

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

ll N;

void solve()
{
	ll ans = 0;
	for(long long i = 1; i*i <= N; ++i){
		if(N%i==0){
			if(i>1 && N /(i-1) == N%(i-1)) ans+=i-1;
			if(N/i != i && N/i>1){
				if(N/(N/i-1) == N % (N/i-1)) ans += N/i-1;
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;
ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> M;

    ll Rmin=N;
    ll Lmax=0;

    rep(mi,M){
        cin >> ltmp;
        Lmax = llmax(Lmax,ltmp);

        cin >> ltmp;
        Rmin = llmin(Rmin,ltmp);
    }

    cout << llmax(0,Rmin-Lmax+1) << endl;
    

}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String[] tmp = br.readLine().split(" ");
        int n = Integer.parseInt(tmp[0]);
        int w = Integer.parseInt(tmp[1]);
        int[] vi = new int[n];
        int[] wi = new int[n];
        for(int i = 0; i < n; i++) {
            tmp = br.readLine().split(" ");
            vi[i] = Integer.parseInt(tmp[0]);
            wi[i] = Integer.parseInt(tmp[1]);
        }
 
        int[][] dp = new int[n + 1][w + 1];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= w; j++) {
                if(j >= wi[i]) dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - wi[i]] + vi[i]);
                else dp[i + 1][j] = dp[i][j];
            }
        }
 
        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 29112