akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
    int n = 0;
    int l = 0;
    scanf("%d %d", &n, &l);
    int a[n];
    int min = 114514893;
    int min_n = 0;
    int sum = 0;
    int tmp = 0;
    for(int i=0; i<n;i++){
        a[i] = l+i-1+1;
        if(a[i]>=0){
            if(min >= a[i]){
                min = a[i];
                min_n = i;
            }
        }else{
            tmp = a[i]*-1;
            if(min >= tmp){
                min = -1*a[i];
                min_n = i;
            }
        }
    }
    for(int i=0; i<n;i++){
        if(min_n != i)sum += a[i];
    }
    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
//--------------------------------------------------
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//--------------------------------------------------
#include <bits/stdc++.h>
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <stack>
#include <cstring>
//--------------------------------------------------
#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, n) for(int i = n-1; i >= 0; --i)
#define forns(i, n, s) for(int i = s; i < n; i++)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//----------------------------------------------------
using namespace std;
//----------------------------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<ll> lnum;
typedef complex<ld> comp;
//----------------------------------------------------
const ll mod = 1e9 + 7, mod2 = 998244353;
const ld eps = 1e-6;
const ll inf = 1e18;
const int base = 1e9;
const ld PI = 3.1415926;
//----------------------------------------------------
//#define endl '\n';
#ifdef MY_DEBUG
void deb(ld x) { cerr << x << endl; };
#else
void deb(ld x){};
#endif
//----------------------------------------------------
//----------------------------------------------------
ll x;
//----------------------------------------------------
unsigned int bitcount(ull val) { return __builtin_popcount(val) + __builtin_popcount(val >> 32); }

void local() {
    freopen("test.in", "r", stdin);
}

void remote() {
}

void read() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> x;
}


int main() {
#ifdef MY_DEBUG
    local();
#else
    remote();
#endif
    read();

    cout << (x/500)*1000 + ((x%500)/5)*5 << endl;


}

Measured memory_bytes: 256
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = [i for i in range(X+1,Y+1)]
for i in ans:
  if max(x) < i:
    if min(y) >= i:
      print('No War')
      exit()
print('War')

Measured memory_bytes: 9108
#include<iostream>

using namespace std;

#define NMAX 20

int main(){

	int M,N,l;
	int x[NMAX],y[NMAX];
	char d;
	bool ok[21][21];

	while(1){

		cin>>N;

		if(N==0) break;

		for(int i=0;i<N;i++){
			cin>>x[i]>>y[i];
		}

		cin>>M;
		int nx=10,ny=10;
		for(int i=0;i<21;i++){
			for(int j=0;j<21;j++){
				ok[i][j]=false;
			}
		}
		ok[10][10]=true;
		for(int i=0;i<M;i++){
			cin>>d>>l;
			for(int j=0;j<l;j++){
				if(d=='N') ny++;
				if(d=='S') ny--;
				if(d=='W') nx--;
				if(d=='E') nx++;
				ok[ny][nx]=true;
			}
		}
		bool f=true;
		for(int i=0;i<N;i++){
			if(!ok[y[i]][x[i]]) f=false;
		}
		if(f) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

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

using namespace std;

main(){
	int a,b;
	while(cin >> a >> b){
		int s=1;
		int g=0;
		int d=a+b;
	while(d >= 1){
		d=d/10;
		g=g+1;
	}
	printf("%d\n",g);
	}
}


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

long long a[100005];
long long b[100005];
long long c[100005];

int main() {
    //freopen("input.txt", "r", stdin);
    
    int x, y, a1, b1, c1;
    cin >> x >> y >> a1 >> b1 >> c1;

    for (int i = 1; i <= a1; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= b1; i++) {
        cin >> b[i];
    }
    for (int i = 1; i <= c1; i++) {
        cin >> c[i];
    }

    sort(a + 1, a + a1 + 1);
    sort(b + 1, b + b1 + 1);
    sort(c + 1, c + c1 + 1);

    for (int i = 1; i <= x; i++) {
        swap(a[i], a[a1 - x + i]);
    }
    for (int i = 1; i <= y; i++) {
        swap(b[i], b[b1 - y + i]);
    }

    int p = 1;
    int q = 1;
    for (int i = c1; i >= 1; i--) {
        if (p <= x && q <= y) {
            if (c[i] > a[p] || c[i] > b[q]) {
                if (a[p] > b[q]) {
                    b[q] = c[i];
                    q++;
                }
                else {
                    a[p] = c[i];
                    p++;
                }
            }    
        }
        else if (p > x) {
            if (c[i] > b[q]) {
                b[q] = c[i];
                q++;
            }
            if (q == y) {
                break;
            }
        }
        else if (q > y) {
            if (c[i] > a[p]) {
                a[p] = c[i];
                p++;
            }
            if (p == x) {
                break;
            }
        }
    }

    long long res = 0;
    for (int i = 1; i <= x; i++) {
        res += a[i];
        //cout << a[i] << " ";
    }
    //cout << endl;
    for (int i = 1; i <= y; i++) {
        res += b[i];
        //cout << b[i] << " ";
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 2560
from collections import deque
import copy
H,W = map(int,input().split())
grid = [[0]*W for _ in range(H)]
for i in range(H):
    grid[i] = list(input())
ans = 0
for sy in range(H):
    for sx in range(W):
        if grid[sy][sx] == '#':
            continue
        now_grid = copy.deepcopy(grid)
        time_grid = [[-1]*W for _ in range(H)]
        queue = deque()
        queue.append([sy,sx,0])
        now_grid[sy][sx] = '#'
        while queue:
            y,x,t = queue.popleft()
            for next_y, next_x in [[y+1, x],[y,x+1],[y-1,x],[y,x-1]]:
                if 0<= next_y < H and 0 <= next_x < W and now_grid[next_y][next_x] != '#':
                    queue.append([next_y,next_x,t+1])
                    time_grid[next_y][next_x] = t+1
                    now_grid[next_y][next_x] = '#'
        Max= 0
        for i in range(H):
            for j in range(W):
                Max = max(Max,time_grid[i][j])
        ans = max(ans, Max)
print(ans)



Measured memory_bytes: 9628
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e6 + 10;
int a[N];
int b[N];
int c[N];
int d[N];
int flag[N];
int p[N];
int cnt[N];
void init()
{
	for (int i = 1; i < N; i++)
	{
		cnt[i] = cnt[i >> 1] + (i & 1);
	}
}
void check(string &str, int a[], int base, int mod, int flag)
{
	int sz = (str.length());
	int tot = 1 << sz;
	for (int o = 0; o < tot; o++)
	{
		int s1 = 0;
		int s2 = 0;
		int cur = 0;
		if (flag == 2)
			cur = cnt[o];
		for (int i = 0; i < sz; i++)
		{
			if (o >> i & 1) s1 = (1LL * s1*base + str[i]) % mod;
			else s2 = (s2 + 1LL * p[cur++] * str[i]) % mod;
		}
		if (flag == 1) s1 = 1LL * s1*p[sz - cnt[o]] % mod;
		a[o] = s1 - s2;
		if (a[o] < 0) a[o] += mod;
	}
}
vector<pair<int, int>> v[20];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	int n;
	cin >> n;
	cin >> str;
	string s1 = str.substr(0, n);
	string s2 = str.substr(n);
	int mod1 = 99997897;
	int mod2 = 99998111;
	init();
	p[0] = 1;
	for (int i = 1; i < 20; i++) p[i] = p[i - 1] * 131LL % mod1;
	check(s1, a, 131, mod1, 1);
	check(s2, b, 131, mod1, 2);
	for (int i = 1; i < 20; i++) p[i] = p[i - 1] * 131LL % mod2;
	check(s1, c, 131, mod2, 1);
	check(s2, d, 131, mod2, 2);
	for (int i = 0; i < (1 << n); i++)
	{
		v[cnt[i]].push_back({ (mod1 - b[i]) % mod1, (mod2 - d[i]) % mod2 });
	}
	for (int i = 0; i < 20; i++)
	{
		if (v[i].empty()) continue;
		sort(v[i].begin(), v[i].end());
	}
	LL ans = 0;
	for (int i = 0; i < (1 << n); i++)
	{
		auto p = make_pair(a[i], c[i]);
		auto &vv = v[n - cnt[i]];
		ans += upper_bound(vv.begin(), vv.end(), p) - lower_bound(vv.begin(), vv.end(), p);
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  vector<vector<int>> dp(H, vector<int>(W,0));

  REP(i,H)REP(j,W){
    cin >> a[i][j];
  }

  dp[0][0]=1;
  REP(i,H)REP(j,W){
    if(a[i][j]=='#')continue;
    if(i>0){
      dp[i][j] += dp[i-1][j];
      dp[i][j] %= MOD;
    }
    if(j>0){
      dp[i][j] += dp[i][j-1];
      dp[i][j] %= MOD;
    }
  }

  cout << dp[H-1][W-1] << endl;

}



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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    string S;

    cin>>S;

    if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
        cout<<"Bad"<<endl;
    }
    else{
        cout<<"Good"<<endl;
    }


    return 0;
}


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

int H,W,K,ans=0;
char arr[7][7];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>H>>W>>K;
	for(int i = 0;i < H;i++){
		for(int j = 0;j < W;j++){
			cin>>arr[i][j];
		}
	}
    
    for(int mi=0; mi<(1<<H); mi++) { // for every combination of rows (2^H)
        for(int mj=0; mj<(1<<W); mj++) { // for every combination of columns (2^W)
            int total = 0;
            for(int i=0; i<H; i++) {
                for(int j=0; j<W; j++) {
                    // a cell stay black
                    // if the color is black
                    // and i-th row is not colored red
                    // and j-th col is not colored red
                    if (arr[i][j]=='#' && ((mi & (1<<i)) == 0) && ((mj & (1<<j)) == 0)) {
                        total++;
                    }
                }
            }
            if (total == K) {
                ans++;
            }
        }
    }
    
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int dp[100005],n,m;
vector<int>ed[100005];
int dfs(int i){
	if(dp[i]!=-1)return dp[i];
	dp[i]=0;
	for(int j:ed[i]){
		dp[i]=max(1+dfs(j),dp[i]);
	}
	return dp[i];
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		ed[u].pb(v);
	}
	for(int i=1;i<=n;i++)dp[i]=-1;
	int res=0;
	for(int i=1;i<=n;i++)res=max(res,dfs(i));
	cout<<res;
}

Measured memory_bytes: 7424
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n;
  std::cin>>n;
  std::string s;
  std::cin>>s;

  ll cnt[26]={};

  rep(i,0,n)cnt[s[i]-'a']++;

  constexpr ll MOD=1e9+7;

  ll ans=1;
  rep(i,0,26){
    ans*=cnt[i]+1;
    ans%=MOD;
  }

  std::cout<<(ans-1+MOD)%MOD<<"\n";

  return 0;
}

Measured memory_bytes: 3760
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
const int INf = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
int main() {   
    ll n, w, a = 0, b,e,sum,ans = 0,wei; cin >> n >> w;
    vector<ll> v1, v2, v3, v4;
    rep(i, n) {
        cin >> a >> e;
        if (i == 0) {
            b = a;
            v1.push_back(e);
        }
        else if (b == a) v1.push_back(e);
        else if (b + 1 == a)v2.push_back(e);
        else if (b + 2 == a)v3.push_back(e);
        else v4.push_back(e);
    }sort(RALL(v1)); sort(RALL(v2)); sort(RALL(v3)); sort(RALL(v4));
    rep(i, v1.size() - 1) v1[i + 1] += v1[i];
    rep(i, v2.size() - 1)v2[i + 1] += v2[i];
    rep(i, v3.size() - 1)v3[i + 1] += v3[i];
    rep(i, v4.size() - 1) v4[i + 1] += v4[i];
    v1.push_back(0); v2.push_back(0); v3.push_back(0); v4.push_back(0);
    rotate(v1.rbegin(), v1.rbegin() + 1, v1.rend());
    rotate(v2.rbegin(), v2.rbegin() + 1, v2.rend());
    rotate(v3.rbegin(), v3.rbegin() + 1, v3.rend());
    rotate(v4.rbegin(), v4.rbegin() + 1, v4.rend());
    rep(i, v1.size()) {
        rep(j, v2.size()) {
            rep(k, v3.size()) {
                rep(l, v4.size()) {
                    wei = b * i + (b + 1) * j + (b + 2) * k + (b + 3) * l;
                    if (wei > w) continue;
                    sum = v1[i] + v2[j] + v3[k] + v4[l];
                    ans = max(ans, sum);

                }
            }
        }
    }cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

typedef long long ll;

const int N = 1e3 + 10;
const int INF = 0x3f3f3f3f;

typedef pair<int, int> PII;

int main ()
{
	char s[N];
	scanf("%s", s);
	int len = strlen(s);
	s[len - 8] = '\0';
	printf("%s\n", s);
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int MOD = 1000000007;
ll dp[5050][5050]; // i人まででj人選んでる時の座布団の枚数の最小値
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  PP info[N];
  FOR(i,0,N) {
    int h,p; cin >> h >> p;
    info[i] = PP(h+p,P(h,p));
  }
  sort(info, info + N);
  FOR(i,0,N+1) FOR(j,0,N+1) dp[i][j] = 2e9;
  dp[0][0] = 0;
  FOR(i,0,N) {
    FOR(j,0,i+1) {
      if(dp[i][j] <= info[i].second.first) {
        dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + info[i].second.second);
      }
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }
  int ans = 0;
  FOR(i,0,N+1) if(dp[N][i] < 2e9) ans = i;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 199040
using System;

namespace ACpra2
{
    class Program
    {
        static void Main(string[] args)
        {
            var b = Console.ReadLine();
            ;
            if (b == "A")
            {
                Console.Write("T");
            }
            if (b == "G")
            {
                Console.Write("C");
            }
            if (b == "T")
            {
                Console.Write("A");
            }
            if (b == "C")
            {
                Console.Write("G");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define N 300010
using namespace std;
typedef unsigned long long ull;
const ull B = 1777771;
string str;
ull H[N],Pow[N];
ull get(int l,int r){return H[r] - H[l]*Pow[r-l];}


int main(){
  Pow[0] = 1;
  for(int i=1;i<N;i++) Pow[i] = Pow[i-1]*B;

  int n,m;
  cin>>n>>m>>str;
  for(int i=0;i<n;i++) H[i+1] = H[i]*B + str[i]-'a'+1;
  
  set<ull> S;
  int l=0,r=0;
  char s[10];
  while(m--){
    scanf("%s",s);
    if(s[0]=='L')l+= s[1]=='+'? 1:-1;
    else r+= s[1]=='+'? 1:-1;
    S.insert(get(l,r+1));
  }

  cout<<S.size()<<endl;
  return 0;
}

Measured memory_bytes: 21976
#include <iostream>
#include <string>

using namespace std;

class A {
	string s;
public:
	void solve()
	{
		if ((s.find('a') != string::npos) && (s.find('b') != string::npos) && (s.find('c') != string::npos))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}
	A() { cin >> s; }
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        int m = in.nextInt();
        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }

}


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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);

map<int , int > m;

void input(int &n, int &sum){
	cin >> n;
	for(int i = 0;i < n;i++){
		int t;
		cin >> t;
		m[t]++;
		sum += t;
	}
}



main() {
	did_you_calis_enough
	int n, sum = 0, q;
	input(n, sum);
	cin >> q;
	while(q--){
		int p, x;
		cin >> p >> x;
		sum -= m[p] * p;
		sum += m[p] * x;
		m[x] += m[p];
		m[p] = 0;
		cout << sum << '\n';
	}
	return 0;
}

//Coded by LoliThief

Measured memory_bytes: 9600
import bisect

a,b,c,d,e,f = map(int, input().split())

water = set()
for i in range(31):
    for j in range(31):
        w = i*a + j*b
        if w <= f//100:
            water.add(w)
water = sorted(water)

suger = set()
for i in range(1501):
    j = 0
    while i*c + j*d <= 1500:
        suger.add(i*c+j*d)
        j += 1
suger = sorted(suger)

ans = []
for w in water:
    sid = bisect.bisect_right(suger, w*e) - 1
    while suger[sid] + w*100 > f and sid > 0:
        sid -= 1
    if w != 0:
        total = w*100 + suger[sid]
        ans.append([suger[sid]/total, total, suger[sid]])
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])


Measured memory_bytes: 3188
import math
from decimal import *

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [int(10e9)+7 for i in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if(i-j>=0):
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]) )
        else:
            break
print(dp[-1])


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

char T[3][3];

string blackwhite() {
	for (int i = 0; i < 3; i++) {
		if (T[i][0] == T[i][1] && T[i][1] == T[i][2]) {
			if (T[i][0] == 'b') { return "b"; }
			if (T[i][0] == 'w') { return "w"; }
		}
	}
	for (int i = 0; i < 3; i++) {
		if (T[0][i] == T[1][i] && T[1][i] == T[2][i]) {
			if (T[0][i] == 'b') { return "b"; }
			if (T[0][i] == 'w') { return "w"; }
		}
	}
	if (T[0][0] == T[1][1] && T[1][1] == T[2][2]) {
		if (T[0][0] == 'b') { return "b"; }
		if (T[0][0] == 'w') { return "w"; }
	}
	if (T[0][2] == T[1][1] && T[1][1] == T[2][0]) {
		if (T[0][2] == 'b') { return "b"; }
		if (T[0][2] == 'w') { return "w"; }
	}
	return "NA";
}

int main() {
	while (true) {
		cin >> T[0][0];
		if (T[0][0] == '0') { break; }
		cin >> T[0][1];
		cin >> T[0][2];
		for (int i = 1; i < 3; i++) {
			for (int j = 0; j < 3; j++){
				cin>>T[i][j];
			}
		}
		cout << blackwhite() << endl;
	}
}

Measured memory_bytes: 1176
import Data.List
import qualified Data.Vector.Unboxed as UV

main=do
    n<-readLn
    ps<-UV.fromListN n.map read.words<$>getLine::IO(UV.Vector Double)
    print $ f n ps

f :: Int -> UV.Vector Double -> Double
f n = UV.sum . UV.take (n`div`2+1) . UV.foldl' proc (UV.cons 1 $ UV.replicate n 0) where
    proc v0 p = UV.cons (UV.head v0 * p) $ UV.map (\j->(v0 UV.! (j-1))*(1-p) + (v0 UV.! j)*p) $ UV.enumFromTo 1 n

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

int main()
{
    int A,B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
int main(){
    ll N;
    cin >> N;
    ll K = 1;
    while(1){
        if(K * (K + 1) == 2 * N){
            break;
        }else if(K * (K + 1) > 2 * N){
            cout << "No\n";
            return 0;
        }
        K++;
    }
    vector<vector<ll>> v(K + 1);
    ll now = 1;
    for(ll i = 0; i < K + 1; i++){
        ll tmp = now;
        while(v[i].size() < K){
            v[i].push_back(now);
            now++;
        }
        for(ll j = 0; j < now - tmp; j++){
            v[i + j + 1].push_back(tmp + j);
        }
    }
    cout << "Yes\n";
    cout << K + 1 << endl;
    for(auto u : v){
        cout << u.size();
        for(auto w : u) cout << " " << w;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,D;
	cin >> N >> D;
	cout << (N-1)/(D+D+1)+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <iterator>
using namespace std;

#define SIZE 200010

typedef struct _Node
{
    int leftPt, rightPt;
} Node;

Node arr[SIZE];
int leftArr[SIZE], rightArr[SIZE], rangeArr[SIZE];

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

    int num;
    while (cin >> num)
    {
        memset(leftArr, 0, sizeof(leftArr));
        memset(rightArr, 0, sizeof(rightArr));
        memset(rangeArr, 0, sizeof(rangeArr));

        int len = -1;
        for (int i = 0; i < num; i++)
        {
            cin >> arr[i].leftPt >> arr[i].rightPt;

            leftArr[arr[i].leftPt]++;
            rightArr[arr[i].rightPt]++;
            rangeArr[arr[i].leftPt]++;
            rangeArr[arr[i].rightPt]--;

            len = max(len, arr[i].rightPt + 1);
        }

        for (int i = 1; i < len; i++)
        {
            leftArr[i] += leftArr[i - 1];
            rightArr[i] += rightArr[i - 1];
            rangeArr[i] += rangeArr[i - 1];
        }

        int fstAns = 0;
        for (int i = 0; i < num; i++)
        {
            fstAns = max(fstAns, num - rightArr[arr[i].leftPt] - (leftArr[len - 1] - leftArr[arr[i].rightPt - 1]));
        }

        int sndAns = 0;
        for (int i = 0; i < len; i++)
        {
            sndAns = max(sndAns, rangeArr[i]);
        }

        cout << fstAns << " " << sndAns << endl;
    }

    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int count(int x) {
    int cnt = 0;
    for (int i = 1; i <= x; i++) if (x % i == 0) cnt++;
    return cnt;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        if (count(i) == 8) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
A = list(map(int, input().split()))

deq = deque()
for i in range(n):
    if i%2==0:
        deq.appendleft(A[i])
    else:
        deq.append(A[i])
if n%2==0:
    for i in reversed(range(n)):
        print(deq[i],end=" ")
else:
    for i in range(n):
        print(deq[i],end=" ")

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  string s;cin>>s;
  int k ;cin>>k;

  int idx;
  int val;
  rep(i, sz(s)){
    if (s[i]!='1') {
      idx = i;
      val = s[i];
      break;
    }
  }
  dump(idx,val);

  if (idx+1 > k) {
    cout << 1 << endl;
  }
  else{
    cout << (char)val << endl;
  }

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

using namespace std;

const int N = 5e5+5;

const int mod = 1e9+7;

int n;
string a[2];

int main(){
    cin >> n >> a[0] >> a[1];
    long long ways = 1;
    for(int i = 0; i < n; i++){
        if(i == 0){
            if(a[0][0] == a[1][0]){
                ways *= 3;
            } else {
                ways *= 6;
                i ++;
            }
            continue;
        }
        if(a[0][i] == a[1][i]){
            if(a[0][i - 1] != a[1][i - 1])
                ways *= 1;
            else
                ways *= 2;
            ways %= mod;
            continue;
        }
        if(a[0][i - 1] == a[1][i - 1]){
            ways *= 2;
            ways %= mod;
            i++;
            continue;
        }
        ways *= 3;
        ways %= mod;
        i++;
    }
    printf("%lld\n" , ways);
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    ll L = N * M / gcd(N, M);

    unordered_map<ll, char> fix;
    for (ll i = 0; i < N; i++) {
        fix[L/N * i] = S[i];
    }

    for (ll i = 0; i < M; i++) {
        if (fix.count(L/M * i) && fix[L/M * i] != T[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << L << endl;
    return 0;
}



Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
ll dp[405][405],cost[405][405];

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

inline ll solve(int n,ll arr[],int l,int r)
{
    if(l==r){
        dp[l][r]=arr[l];
        return 0;
    }
    if(cost[l][r]!=0) return cost[l][r];
    ll men=inf2;
    rep(i,l,r){
        solve(n,arr,l,i); solve(n,arr,i+1,r);
        men=min(men,dp[l][i]+cost[l][i]+dp[i+1][r]+cost[i+1][r]);
        dp[l][r]=dp[l][i]+dp[i+1][r];
    }
    return cost[l][r]=men;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    ll arr[n];
    rep(i,0,n) cin>>arr[i];
    fill(dp,-1); cout<<solve(n,arr,0,n-1)<<endl;
    /*rep(i,0,n){
        rep(j,0,n) cerr<<dp[i][j]<<" "; cerr<<endl;
    }*/
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    int n,q; cin >> n >> q;
    string s; cin >> s;
    vint l(q),r(q); rep(i,q){cin >> l[i] >> r[i]; --l[i]; --r[i];}

    vint ac(n,0);
    if(s[0] == 'A' && s[1] == 'C')ac[0]=1;

    repp(i,n-1){
        if(s[i] == 'A' && s[i+1] == 'C'){
            ac[i] = ac[i-1] + 1;
        }
        else ac[i] = ac[i-1];
    }

    rep(i,q){
        cout << ac[r[i]-1] - ac[l[i]-1] << endl;
    }



    return 0;
}


Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
using namespace std;

uint_fast16_t d;
uint_fast32_t M = 0;
uint_fast64_t c, sd = 0, sc = 0;
constexpr int cm = 1 << 22;
char buff[cm], *ci;
int main() {
	fread_unlocked(buff, 1, cm, stdin); ci = buff;
    while(*ci>47) M = (M<<1) + (M<<3) + *ci++ - 48;
    while(M--) {
        c = 0;
        d = *++ci - 48;
        ++ci;
        while(*++ci>47) c = (c<<1) + (c<<3) + *ci - 48;
        sc += c;
        sd += c * d;
    }
    printf("%lld", --sc + --sd / 9);
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define scan(a) scanf("%d", &a)
#define scanll(a) scanf("%lld", &a)
#define scanD(a) scanf("%lf", &a)
#define print(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printD(a) printf("%lf\n", a)
#define printTwo(a) printf("%.2lf\n", a);
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	int n;
	scan(n);
	int arr[n];
	int sum = 0;
	rep(i, 0, n) {
		scan(arr[i]);
		sum += arr[i];
	}
	sum /= n;
	int ans = 1e9;
	for(int k : {0, 1}) {
		int ca = 0;
		for (int i = 0; i < n; i++) {
			ca += (arr[i] - sum - k) * (arr[i] - sum - k);
		}
		ans = min(ans, ca);
	}
	print(ans);
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

	solve();

	// __test {
	// 	solve();
	// }

	showTime;
	return 0;
}




Measured memory_bytes: 3728
#include <iostream>
using namespace std;
typedef unsigned long long u64; 
const int MAXN = 2e5 + 10;
u64 MAXNUM = 6e18;
int n = 0;
char op[MAXN]; 
int p[MAXN][3];

void Div(int p1 , int x){
	++ n;
	op[n] = '+'; p[n][0] = 9; p[n][1] = 9; p[n][2] = 10;
	for(int i = 30 ; i >= 0 ; -- i){
		++ n;
		op[n] = '+'; p[n][0] = 10; p[n][1] = 9; p[n][2] = 11;
		++ n;
		op[n] = '+'; p[n][0] = 11; p[n][1] = 100000 + i; p[n][2] = 11;
		++ n;
		op[n] = '<'; p[n][0] = x; p[n][1] = 11; p[n][2] = p1 + i;
		++ n;
		op[n] = '<'; p[n][0] = p1 + i; p[n][1] = 100000; p[n][2] = p1 + i;
		++ n;
		op[n] = '+'; p[n][0] = p1 + i; p[n][1] = 9; p[n][2] = 8;
		for(int j = 1 ; j <= i ; ++ j){
			++ n;
			op[n] = '+'; p[n][0] = 8; p[n][1] = 8; p[n][2] = 8;
		}
		++ n;
		op[n] = '+'; p[n][0] = 8; p[n][1] = 10; p[n][2] = 10;
	}
}

void init(){
	++ n;
	op[n] = '+'; p[n][0] = 0; p[n][1] = 1; p[n][2] = 2;
	++ n;
	op[n] = '<'; p[n][0] = 0; p[n][1] = 2; p[n][2] = 100000;
	++ n;
	op[n] = '+'; p[n][0] = 0; p[n][1] = 3; p[n][2] = 2;
	for(int i = 1 ; i <= 30 ; ++ i){
		++ n;
		op[n] = '+'; p[n][0] = 99999 + i; p[n][1] = 99999 + i; p[n][2] = 100000 + i;
	}
	Div(50000 , 1); //div(B)
	Div(60000 , 2); //div(A)
	++ n;
	op[n] = '+'; p[n][0] = 3; p[n][1] = 3; p[n][2] = 2;
	for(int i = 0 ; i <= 30 ; ++ i){
		++ n;
		op[n] = '<'; p[n][0] = 50000 + i; p[n][1] = 100000; p[n][2] = 50000 + i;
	}
	for(int i = 0 ; i <= 30 ; ++ i){
		++ n;
		op[n] = '+'; p[n][0] = 9; p[n][1] = 9; p[n][2] = 7;
		for(int j = 0 ; j <= 30 ; ++ j){
			++ n;
			op[n] = '<'; p[n][0] = 50000 + j; p[n][1] = 60000 + i; p[n][2] = 8;
			for(int k = 1 ; k <= j ; ++ k){
				++ n;
				op[n] = '+'; p[n][0] = 8; p[n][1] = 8; p[n][2] = 8;
			} 
			++ n;
			op[n] = '+'; p[n][0] = 8; p[n][1] = 7; p[n][2] = 7;
		}
		for(int k = 1 ; k <= i ; ++ k){
			++ n;
			op[n] = '+'; p[n][0] = 7; p[n][1] = 7; p[n][2] = 7;
		}
		++ n;
		op[n] = '+'; p[n][0] = 7; p[n][1] = 2; p[n][2] = 2;
	}
}

/*u64 h[MAXN];
bool check(int A , int B){
	h[0] = A , h[1] = B;
	for(int i = 1 ; i <= n ; ++ i){
		for(int k = 0 ; k < 3 ; ++ k)
			if(p[i][k] >= 200000)
				return 0;
		if(op[i] == '+'){
			h[p[i][2]] = h[p[i][1]] + h[p[i][0]];
			if(h[p[i][2]] > MAXNUM)
				return 0;
		}
		else
			h[p[i][2]] = (h[p[i][0]] < h[p[i][1]]);
	}
	return (h[2] == 1ll * A * B);
}*/

int main(){
	init();
//	int a , b;
//	cin >> a >> b;
//	cout << check(a , b) << endl;
	cout << n << endl;
	for(int i = 1 ; i <= n ; ++ i)
		cout << op[i] << " " << p[i][0] << " " << p[i][1] << " " << p[i][2] << endl;
	return 0;
}

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

int main() {
    int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    int len1 = x2 - x1, len2 = y2 - y1;
    printf("%d %d %d %d", x2 - len2, y2 + len1, x1 - len2, y1 + len1);
    return 0;
}


Measured memory_bytes: 128
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;

ll mod = 1e9+7;

ll add(ll a, ll b) { return (a % mod + b % mod) % mod; }
ll mul(ll a, ll b) { return (a % mod * b % mod) % mod; }
ll debug(vector<int> a) { for(int i: a) cout << i << " "; return puts("\n"), 0;}

ll power(ll base, ll exp) {
    ll res = 1;
    while(exp) {
        if(exp&1) res = mul(res, base);
        base = mul(base, base);
        exp >>= 1;
    }
    return res;
}

ll inv(ll p) {
    return power(p, mod-2);
}



ll numOfDigits(int x) {
    ll d = 0;
    while(x > 0) {
        d++;
        x /= 10;
    }
    return d;
}

int main() {
    fastio
    ll n, k; cin >> n >> k;
    ll a[n+1], x=0, pre=0, ans = 0;
    map<ll, ll> mp;
    mp[0] = 1; a[0] = 0;
    for(int i=1; i<=n; i++) {
        cin >> x; x -= 1;
        pre = (pre + x) % k;
        a[i] = pre;
        if(i >= k) {
            mp[a[i-k]]--;
        }
        if(mp[a[i]] > 0) {
            ans += mp[a[i]];
            mp[a[i]]++;
        }
        else {
            mp[a[i]] = 1;
        }
    }

    cout << ans << "\n";


}



Measured memory_bytes: 14336
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if (  b - a == c - b  ){
    cout << "YES" << endl;
    
}
    else {
    cout << "NO" << endl;
    
    }
}


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

using namespace std;

vector<int> articulation_points;
vector<int> graph[100000];
int ord[100000],low[100000];
bool visited[100000];

int visit_time = 0;

void dfs(int v,int p){
  visited[v] = true;
  ord[v] = visit_time;
  low[v] = ord[v];
  visit_time++;
  bool is_articulation = false;
  int cnt = 0;
  for(int i=0;i<graph[v].size();++i){
    if(!visited[graph[v][i]]){
      cnt++;
      dfs(graph[v][i],v);
      low[v] = min(low[v],low[graph[v][i]]);
      if(p!=-1&&ord[v]<=low[graph[v][i]]) is_articulation = true;
    }else if(graph[v][i]!=p){
      low[v] = min(low[v],ord[graph[v][i]]);
    }
  }

  if(p==-1&&cnt > 1) is_articulation = true;
  if(is_articulation) articulation_points.emplace_back(v);
}

int main(){
  int N , M ;
  cin >> N >> M;
  for(int i=0;i<M;++i){
    int s,t;
    cin >> s >> t;
    graph[s].push_back(t);   
    graph[t].push_back(s);
  }
  
  for(int i=0;i<N;++i){
    if(!visited[i]) dfs(i,-1);
  }
  
  sort(articulation_points.begin(),articulation_points.end());
  for(const auto &a:articulation_points){
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 6836
#include <iostream>
#include <stack>
#include <stdio.h>

#define BUF_SIZE 120000

using namespace std;

int main(){

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

	int S[n];

	for(int i = 0; i < n; i++){
		scanf("%d",&S[i]);
	}

	int q;
	scanf("%d",&q);

	int count = 0;
	int tmp;

	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		for(int k = 0; k < n; k++){
			if(tmp == S[k]){
				count++;
				break;
			}
		}
	}

	printf("%d\n",count);

}



Measured memory_bytes: 3220
using System;
public class Hello{
    public static void Main(){
        string input = Console.ReadLine();
        bool flag = true;
        string[] s = new string[input.Length];
        
        for(int x = 0;x < input.Length;x++){
            s[x] = input.Substring(x,1);
        }
        for(int y = 0;y < input.Length - 1;y++){
            for(int z = y + 1;z < input.Length;z++){
                if(s[y] == s[z]){
                    flag = false;
                    break;
                }
            }
        }
        if(flag == true){
            Console.WriteLine("yes");
        }else{
            Console.WriteLine("no");
        }
       
    }
}

Measured memory_bytes: 11092
X, Y, Z, K = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
z = sorted(list(map(int, input().split())))


import heapq
ans = []
for i in range(X-1, -1, -1):
  for j in range(Y-1, -1, -1):
    for k in range(Z-1, -1, -1):
      if (X-i)*(Y-j)*(Z-k) <= K:
        sub = x[i]+y[j]+z[k]
        ans.append(sub)
      else:
        break
ans = list(map(lambda x: x*(-1), ans)) 
heapq.heapify(ans)
for i in range(K):
  print(heapq.heappop(ans)*(-1))

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

int main() {
    ll n;
    cin >> n;
    int ans = 0;
    for (ll i = 2; i * i <= n; i++) {
        ll z = i;
        while (n % z == 0) {
            n /= z;
            ans++;
            z *= i;
        }
        while(n % i == 0){
            n /= i;
        }
    }
    if (n > 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    string S;
    cin >> S;

    int N = S.size();
    int res = N - 1;

    auto Ok = [&](string T) {
        return set<char>(T.begin(), T.end()).size() == 1;
    };

    for (char x = 'a'; x <= 'z'; x++) {
        auto A = S;
            
        int steps = 0;

        while(true) {
            if (Ok(A))
                break;

            string nA = A;
            nA.pop_back();

            //cerr << x << " " << A << " " << nA << "\n";

            for (int i = 0; i < A.size() - 1; i++)
                if (A[i] == x || A[i + 1] == x)
                    nA[i] = x;
                else
                    nA[i] = A[i];

            A = nA;
            steps++;
        }

        res = min(res, steps);
    }    

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	char op;
	while(1){
		scanf("%d %s %d",&a,&op,&b);
		if(op=='+'){
			printf("%d\n",a+b);
		}
		else if(op=='-'){
			printf("%d\n",a-b);
		}
		else if(op=='*'){
			printf("%d\n",a*b);
		}
		else if(op=='/'){
			printf("%d\n",a/b);
		}
		else if(op=='?'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600