akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#define FUP(i,x,y) for(register int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(register int i=(x);i>=(y);i--)
#define MAXN 40
#define INF 0x3f3f3f3f
using namespace std;
inline int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int n,m1,m2,a,b,c,ans=INF,cnt=1,suma,sumb,aa,bb;
int f[410][410];
int main(){
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	n=read(),m1=aa=read(),m2=bb=read();
	FUP(i,1,n)
	{
		a=read(),b=read(),c=read();
		suma+=a,sumb+=b;
		FDW(j,suma,a)
		{
			FDW(k,sumb,b)
			{
				f[j][k]=min(f[j][k],f[j-a][k-b]+c);
			}
		}
	}
	while(m1<=suma&&m2<=sumb)
	{
		ans=min(ans,f[m1][m2]);
		//printf("%d,%d:%d\n",m1,m2,f[m1][m2]);
		m1+=aa,m2+=bb;
	}
	printf("%d\n",ans==INF?-1:ans);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <map>
#include <set>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  map<long long, long long> m;
  long long tmp = N;
  for (long long i = 2; i * i <= tmp; ++i) {
    if (tmp % i == 0) {
      tmp /= i;
      m[i] = 1;
      while (tmp % i == 0) {
        tmp /= i;
        ++m[i];
      }
    }
  }
  if (tmp > 1) {
    m[tmp] = 1;
  }

  long long ret = 0;
  for (map<long long, long long>::iterator i = m.begin(); i != m.end(); ++i) {
    long long x = i->second;
    for (long long j = 1; j <= x; ++j) {
      ++ret;
      x -= j;
      if (j > x)
        break;
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 3628
// Write and Erase
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
// #define n 1000000010
#include <map>

int main() {
    int N;
    cin >> N;
    map<int, int> A;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        A[x]++;
    }

    int count = 0;
    for (auto itr = A.begin(); itr != A.end(); itr++) {
        if (itr->second % 2 == 1) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
char graph[105][105];
int visit[105][105];
bool judge(int i, int j, int up, int down, char ch)
{
    if(visit[i][j]) return false;
    for(int dx=-1; dx<=1; dx++)
    {
        for(int dy=-1; dy<=1; dy++)
        {
            if(i+dx<up||i+dx>down||j+dy<1||j+dy>100)  continue;
            if(graph[i+dx][j+dy]==ch) return false;
        }
    }
    graph[i][j]=ch;
    return true;
}
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int a,b,i,j;
    cin>>a>>b;
    for(i=1; i<=50; i++)
    {
        for(j=1; j<=100; j++)
            graph[i][j]='#';
        graph[i][j]='\0';
    }
    for(i=51; i<=100; i++)
    {
        for(j=1; j<=100; j++)
            graph[i][j]='.';
        graph[i][j]='\0';
    }
    for(i=1; i<50; i++)
    {
        for(j=1; j<=100; j++)
        {
            if(a==1) break;
            if(judge(i,j,1,49,'.'))
            a--;
        }
        if(a==1) break;
    }
    for(i=52; i<=100; i++)
    {
        for(j=1; j<=100; j++)
        {
            if(b==1) break;
            if(judge(i,j,52,100,'#'))
                b--;
        }
        if(b==1) break;
    }
    printf("100 100\n");
    for(i=1; i<=100; i++)
        printf("%s\n",graph[i]+1);
    return 0;
}


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

int main(){
    int n,k;
    string s;
    cin >> n;
    cin >> s;
    cin >> k;
    char c=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]!=c)s[i]='*';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
inp = [list(map(int, input().split())) for _ in range(3)]
inputs = inp[0] + inp[1] + inp[2]
one = inputs.count(1)
two = inputs.count(2)
three = inputs.count(3)
four = inputs.count(4)
counts = one, two, three, four
if counts == (1, 1, 2, 2) or counts == (1, 2, 1, 2) or counts == (2, 1, 1, 2) or counts == (1, 2, 2, 1) or counts == (2, 2, 1, 1) or counts == (2, 1, 2, 1):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

const ll mod = 1000000007;

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

  int h, w;
  cin >> h >> w;
  int ch, cw;
  cin >> ch >> cw;
  int dh, dw;
  cin >> dh >> dw;
  vector<string> board(h);
  for (auto &x: board) cin >> x;

  priority_queue<vector<int>, vector<vector<int> >, greater<vector<int> > > pque;
  pque.push(vector<int>({0, ch-1, cw-1}));
  vector<vector<bool> > visited(h, vector<bool>(w));
  while (!pque.empty()) {
    auto now = pque.top();
    pque.pop();
    if (visited[now[1]][now[2]]) continue;
    visited[now[1]][now[2]] = true;

    if (now[1] == dh-1 && now[2] == dw-1) {
      cout << now[0] << endl;
      return 0;
    }

    if (now[1] > 0) {
      if (board[now[1]-1][now[2]] == '.' && !visited[now[1]-1][now[2]]) pque.push(vector<int>({now[0], now[1]-1, now[2]}));
    }
    if (now[1] < h-1) {
      if (board[now[1]+1][now[2]] == '.' && !visited[now[1]+1][now[2]]) pque.push(vector<int>({now[0], now[1]+1, now[2]}));
    }
    if (now[2] > 0) {
      if (board[now[1]][now[2]-1] == '.' && !visited[now[1]][now[2]-1]) pque.push(vector<int>({now[0], now[1], now[2]-1}));
    }
    if (now[2] < w-1) {
      if (board[now[1]][now[2]+1] == '.' && !visited[now[1]][now[2]+1]) pque.push(vector<int>({now[0], now[1], now[2]+1}));
    }

    for (int k = -2; k <= 2; k++) {
      for (int l = -2; l <= 2; l++) {
        if (now[1]+k < 0 || now[1]+k >= h || now[2]+l < 0 || now[2]+l >= w || abs(k)+abs(l) <= 1) continue;
        if (board[now[1]+k][now[2]+l] == '.' && !visited[now[1]+k][now[2]+l]) pque.push(vector<int>({now[0]+1, now[1]+k, now[2]+l}));
      }
    }
  }

  cout << -1 << endl;

  return 0;
}


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

char change[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
  ll n;
  cin >> n;
  vector<char> ans;
  while (n != 0) {
    n--;
    ans.push_back(change[n%26]);
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  rep(i,ans.size()) cout << ans[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

int n;

vector<pii> edges;

void e(int v, int u)
{
    edges.emplace_back(v, u);
}

void build_odd(int x, bool xtra = false)
{
    if (!xtra)
    {
        e(3, 1);
        e(1, 2);
        e(2, 3 + n);
        e(3 + n, 1 + n);
        e(1 + n, 2 + n);
        // T(3) is ready
        for (int y = 4; y + 1 <= x; y += 2)
        {
            e(y, 1);
            e(y + 1, y);
            e(1 + n, y + 1 + n);
            e(y + 1 + n, y + n);
        }
    }
    else
    {
        e(5, 1);
        e(1, 4);
        e(4, 5 + n);
        e(5 + n, 1 + n);
        e(1 + n, 4 + n);
        e(2, 1);
        e(3, 2);
        e(1 + n, 3 + n);
        e(3 + n, 2 + n);
        // T(5) is ready
        for (int y = 6; y + 1 <= x; y += 2)
        {
            e(y, 1);
            e(y + 1, y);
            e(1 + n, y + 1 + n);
            e(y + 1 + n, y + n);
        }
    }
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    cin >> n;
    if (__builtin_popcount(n) == 1)
    {
        cout << "No\n";
        return 0;
    }
    if (n == 6)
    {
        cout << "Yes\n5 4\n4 1\n3 1\n1 2\n2 9\n9 7\n7 8\n8 6\n7 11\n11 10\n11 12\n";
        return 0;
    }
    int u = 0;
    {
        int nn = n;
        while (~nn & 1)
        {
            nn >>= 1;
            ++u;
        }
    }
    if (!u)
    {
        build_odd(n);
    }
    else
    {
        build_odd(n - 1, u == 1);
        int n1 = n - (1 << u);
        e(n, n1);
        e((1 << u) + 1 + n, 2 * n);
    }
    cout << "Yes\n";
    for (auto edge : edges)
    {
        /*if (edge.fi <= n)
            cout << edge.fi;
        else
            cout << "x" << edge.fi - n;
        cout << ' ';
        if (edge.se <= n)
            cout << edge.se;
        else
            cout << "x" << edge.se - n;
        cout << endl;/**/
        cout << edge.fi << ' ' << edge.se << '\n';
    }

    return 0;
}

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

using namespace std;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  
  int ex_start, ex_end;
  ex_start = a + k;
  ex_end = b - k;
  for(int i = a;i <= b;i++){
    if((i<ex_start)||(i>ex_end))cout<< i << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int H1 = scan.nextInt();
		int M1 = scan.nextInt();
		int H2 = scan.nextInt();
		int M2 = scan.nextInt();

		int HA = H2-H1;
		int MA = M2-M1;

		HA = HA*60;
		int t = HA+MA;

		int K = scan.nextInt();

		t = t-K;

		System.out.println(t);

	}

}


Measured memory_bytes: 35732
N = int(input())  # 1行目のNを取得する
Plan = [list(map(int, input().split())) for i in range(N)]  # 複数行の数値の入力を取得


# マス目が白か黒か判定する
def checkCel(x, y):
    if x % 2 == 0:
        if y % 2 == 0:  # 偶、偶
            return "Black"
        else:  # 偶、奇
            return "White"

    else:
        if y % 2 == 0:  # 奇、偶
            return "White"
        else:  # 奇,奇
            return "Black"


OKNG = 'Yes'
x, y = Plan[0][1], Plan[0][2]
remain = Plan[0][0]

for i in range(0, len(Plan)):

    # 残歩数のチェック
    if x + y < remain + 1:

        # 行き先のマス目色
        cel = checkCel(x, y)

        # マス目色に対して残歩数で行けるか偶奇判定
        if not ((remain % 2 == 0 and cel == "Black") or \
                (remain % 2 == 1 and cel == "White")):
            OKNG = 'No'
    else:
        OKNG = 'No'

    if i < len(Plan) - 1:
        remain = Plan[i + 1][0] - remain
        x = Plan[i + 1][1] - x
        y = Plan[i + 1][2] - y

print(OKNG)

Measured memory_bytes: 27300
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];
    LL number[M_N];
 
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            number[i]=1;
        }
    }
 
    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }
 
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            number[y]+=number[x];
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
            number[x]+=number[y];
        }
    }
 
    bool same(int x,int y){
        return find(x)==find(y);
    }
 
    int get(int x){
        return number[find(x)];
    }
 
};

vector<int> v[100001],u[100001];

int main(){
    int n;cin >> n;
    UnionFind uf;
    uf.init(100001);
    for (int i = 0; i < n; i++) {
        int x,y;cin >> x >> y;
        v[x].pb(y);
        u[y].pb(x);
    }
    for (int i = 1; i <= 100000; i++) {
        for (int j = 1; j < u[i].size(); j++) {
            uf.unite(u[i][j],u[i][j-1]);
        }
    }
    LL ans = 0;
    vector<bool> used(100001,false);
    for (int i = 1; i <= 100000; i++) {
        if(used[uf.find(i)]) continue;
        if(uf.get(i)==1){
            ans += (LL)v[i].size();
            continue;
        }
        LL t = 1;
        vector<int> vc(100001,0);
        for (int j = 0; j < v[i].size(); j++) {
            vc[v[i][j]]=1;
        }
        for (int j = i+1; j <= 100000; j++) {
            if(!uf.same(i,j)) continue;
            t++;
            for (int k = 0; k < v[j].size(); k++) {
                vc[v[j][k]]=1;
            }
        }
        int count=0;
        for (int i = 0; i <= 100000; i++) {
            count += vc[i];
        }
        used[uf.find(i)]=true;
        ans += count*t;
    }
    cout << ans-n << endl;
    return 0;
}


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

int main(){
    int a,b,c,d, cnt=0;
    cin>>a>>b>>c>>d;

    while(true){
        if(cnt%2==0){
            c=c-b;
        }else{
            a=a-d;
        }
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }else if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
        cnt++;
    }
}


Measured memory_bytes: 3608
h, w = list(map(int, input().split()))
n = int(input())
a = list(map(int, input().split()))
b = [[0 for i in range(w)] for j in range(h)]
top = 0
bot = h-1
left = 0
right = w-1
x = 0
y = 0
flag = 0

for i in range(n):
  cnt = a[i]
  while cnt>0:
    b[y][x] = i+1
    cnt -= 1
    if flag==0 and x==left and y==bot:
      x += 1
      left += 1
      flag = (flag+1)%4
    elif flag==1 and x==right and y==bot:
      y -= 1
      bot -= 1
      flag = (flag+1)%4
    elif flag==2 and x==right and y==top:
      x -= 1
      right -= 1
      flag = (flag+1)%4
    elif flag==3 and x==left and y==top:
      y += 1
      top += 1
      flag = (flag+1)%4
    elif flag == 0:
      y += 1
    elif flag == 1:
      x += 1
    elif flag == 2:
      y -= 1
    elif flag == 3:
      x -= 1
for row in b:
  print(*row)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007
#define tp tuple<ll,ll,ll>

int main() {
	ll X;
	cin >> X;
	for (int x = X;;x++) {
		bool b = 1;
		for (int i = 2;i * i <= x;i++) {
			if (x % i == 0) {
				b = 0;
				break;
			}
		}
		if (b) {
			cout << x << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H_li = list(map(int, input().split()))

par = [0 for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    if H_li[B-1]>H_li[A-1]:
        par[A-1] = 1
    elif H_li[A-1]>H_li[B-1]:
        par[B-1] = 1
    else:
        par[A-1] = 1
        par[B-1] = 1

print(N-sum(par))


Measured memory_bytes: 20076
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    LL s;cin >> s;
    vector<vector<LL>> dp(s + 1, vector<LL> (s + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i * 3 < s; i++) {
        for (int j = 3 * i; j <= s; j++) {
            if(not dp[i][j]) continue;
            for (int k = 3; k <= s - j; k++) {
                dp[i + 1][j + k] = (dp[i + 1][j + k] + dp[i][j]) %mod;
            }
        }
    }
    LL ans = 0;
    for (int i = 0; i <= s; i++) {
        ans = (ans + dp[i][s])%mod;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> cnt(n, 0);
    int rest = 3;
 
    ll ans = 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == 0) {
            (ans *= rest--) %= MOD;
            ++cnt[0];
        } else {
            (ans *= cnt[a[i] - 1]--) %= MOD;
            cnt[a[i]]++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


ll N, x;
ll ans[2 * 100005];
stack<ll> s, sa;
int main() {
	cin >> N >> x;

	rep(i, 2 * N - 1) {
		if (abs(i - x + 1) > 2)
			s.push(i + 1);
		
	}

	if(N == 2){
		if (x == 2) {
			cout << "Yes" << endl;
			rep(k, 3)
				cout << k + 1 << endl;

		}

		else
			cout << "No" << endl;
			

		return 0;
	}

	



	if (2 * N - 1 == x || x == 1) {

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


	else if(2 * N - 3 >= x && x >= 3) {
		cout << "Yes" << endl;
		sa.push(x + 1);
		sa.push(x - 1);
		sa.push(x);
		sa.push(x + 2);
		sa.push(x - 2);
		
		rep(i, 2 * N - 1) {
			if (abs(i - (N - 1)) <= 2) {
				cout << sa.top() << endl;;
				sa.pop();
			}
			else {
				cout << s.top() << endl;
				s.pop();
			}
		}

	}

	else {
		cout << "Yes" << endl;


		if (x == 2) {
			sa.push(x + 1);
			sa.push(x);
			sa.push(x - 1);
			sa.push(x + 2);
		}

		else {
			sa.push(x - 2);
			sa.push(x + 1);
			sa.push(x);
			sa.push(x - 1);
		}

		rep(i, 2 * N - 1) {
			if (abs(i - (N - 1)) <= 2 && sa.size() != 0) {
				cout << sa.top() << endl;;
				sa.pop();
			}
			else {
				cout << s.top() << endl;
				s.pop();
			}
		}


	}

	return 0;
}

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

int main()
{
    string s1;
    string s2;
    cin >> s1;
    cin >> s2;
    if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0;
}

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

using namespace std;

const int MAX = 1e5 + 10;
int N, P[MAX], pos[MAX];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    pos[--P[i]] = i;
  }

  set<int> se;
  se.emplace(-2);
  se.emplace(-1);
  se.emplace(N);
  se.emplace(N + 1);
  
  se.emplace(pos[N - 1]);
  long long ans = 0;
  for (int i = N - 2; i >= 0; i--) {
    const auto cur = pos[i];
    auto l = se.lower_bound(cur);
    auto r = se.upper_bound(cur);

    long long cnt = 0;
    const int l2 = *--l;
    const int l1 = *--l;
    const int r2 = *r++;
    const int r1 =*r;
    if (l2 >= 0) cnt += (l2 - l1) * (r2 - cur);
    if (r2 < N) cnt += (r1 - r2) * (cur - l2);

    ans += cnt * (i + 1);
    se.emplace(cur);
  }

  cout << ans << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int x; cin>>x;
 int y=x/100;
 if(x<=y*100+y*10+y) cout<<y*100+y*10+y<<endl;
 else cout<<(y+1)*100+(y+1)*10+y+1<<endl;
}


Measured memory_bytes: 256
a, b, c, d, e, f = gets.chomp.split.map(&:to_i)
 
a = 100 * a 
b = 100 * b
 
sugar = []
water = []
 
i = 0
 
while (a * i) < f
  k = 0
  while (b * k) < f
    combiWater = (a * i) + (b * k)
    if combiWater < f
      water << combiWater
    end
    k += 1
  end
  i += 1
end
 
i = 0
 
while (c * i) < f
  k = 0
  while (d * k) < f
    combiSugar = (c * i) + (d * k)
    if combiSugar < f
      sugar << combiSugar
    end
    k += 1
  end
  i += 1
end
 
water.sort!.uniq!
sugar.sort!.uniq!
 
maxdensity = 0
ansSugarWater = 0
ansSugar = 0
 
water.each do |i|
  sugar.each do |k|
    sugarWater = i + k
    limit = i / 100 * e
    if i == 0
      next
    end
    density = (k * 100) / (i + k).to_f
    if sugarWater <= f && k <= limit && maxdensity <= density
      maxdensity = density
      ansSugarWater = sugarWater
      ansSugar = k
    end
  end
end
 
print("#{ansSugarWater}\s#{ansSugar}\n")

Measured memory_bytes: 6136
package main

import (
    "fmt"
    "strings"
)

func main() {
	var S string
	var s []string
	var r []string
	var N int

	N = 0
	r = []string{}

	fmt.Scan(&S)
	s = strings.Split(S, "")

	for i := 0; i < len(s); i++ {
		r = append(r, s[len(s)-i-1])
	}

	for i := 0; i < len(s)/2; i++ {
		if s[i] != r[i] {
			N++
		}
	}
    fmt.Println(N)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    lli n, k;
    cin>>n>>k;
    if(n == 1){
        cout<<1<<"\n";
        return 0;
    }
    double ans = floor (log10(n) / (log10(k)) + 1);
    // if(floor(ans) == ceil(ans))
    //     cout<<ans<<"\n";
    // else
    //     cout<<(int)ans + 1<<"\n";
    cout<<ans<<"\n";
    return 0;
 }
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


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

const long long mod =998244353 ;
const int N = 1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vii vector<int>
#define vpr vector<pair<ll,ll> >
ll pwr(ll x,ll y);
bool isprime(int n) ;

int a[2][N];
ll dp[N][105];
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);

int n,w;
cin>>n>>w;
fr(i,1,n+1)
{
    cin>>a[0][i]>>a[1][i];
}

fr(i,0,w+1)
{
    fr(j,0,n+1)
    {
        if(i==0 || j==0){dp[i][j]=0;}
        else
        {
            if(a[0][j]<=i)
            {
                dp[i][j]=max((ll)a[1][j]+dp[i-a[0][j]][j-1],dp[i][j-1]);
            }
            else
            {
                dp[i][j]=dp[i][j-1];
            }
        }
    }
}

cout<<dp[w][n]<<endl;


return 0;
}
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*(ans%mod))%mod;
    x=(x*x)%mod;
    y=y/2;

    }
    return ans%mod;
}

bool isprime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}


Measured memory_bytes: 82304
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int cnt = 1;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] != S[i - 1]) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N + 1, 1e9);
    int kind = 0;
    rep(i, N) {
        int a;
        cin >> a;
        if (A[a] == 1e9) {
            A[a] = 1;
            kind++;
        }
        else {
            A[a]++;
        }
    }

    ll ans = 0;
    if (kind > K) {
        sort(all(A));
        rep(i, kind - K) {
            ans += A[i];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
    long h,w,n; cin>>h>>w>>n;
    vector<long> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    long mp[h][w];
    int i=0,j=0;
    for(int c=0;c<n;c++){
        while(a[c]>0){
            mp[i][j]=c+1;
            a[c]--;
            if(!(i%2))
                j++;
            else
                j--;
            if(j==w){
                i++;
                j--;
            }
            if(j<0){
                i++;
                j++;
            }
        }
    }
    REP(i,h){
        REP(j,w)
            cout<<mp[i][j]<<" ";
        cout<<endl;
    }
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val baisu = next().toInt()
    val lange = nextIntList()
    var res = "NG"
    for(i in lange[0] .. lange[1]){
        if(i % baisu == 0){
            res = "OK"
            break
        }
    }
    println(res)
}
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun next() = readLine()!!

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll a,b,c,x,y;cin>>a>>b>>c>>x>>y;

  ll result = 2*c*max(x, y);

  // buy i composite pizza
  rep(i, max(x,y)){
    ll tmp = i*2*c + max<ll>(0, (x-i))*a + max<ll>(0, (y-i))*b;
    result = min(result, tmp);
  }

  cout<<result;

  return 0;
}

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

int main() {
	int N;
	cin >> N;
	int max = 0, min = 2e9;
	for (int i = 1; i <= N; i++) {
		int t;
		cin >> t;
		if (max < t) max = t;
		if (t < min) min = t;
	}
	cout << max - min << "\n";
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for _ in range(N):
        s = input()
        if s=='AC':
            ac += 1
        elif s=='WA':
            wa += 1
        elif s=='TLE':
            tle += 1
        else:
            re += 1
    print(*['AC','x',ac])
    print(*['WA','x',wa])
    print(*['TLE','x',tle])
    print(*['RE','x',re])

main()


Measured memory_bytes: 9092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		if (a + b + c <= 21) {
			System.out.println("win");
		} else {
			System.out.println("bust");
		}
	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<vector>
#include<list>
#include<queue>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;


int main(){
  int N, M;
  cin >> N >> M;
 
  priority_queue<double> A;
  double tmp;
  rep(i, N){
    cin >> tmp;
    A.push(tmp);
  }
  
  int rem = M;
  while(rem > 0){
    tmp = A.top()/2.0;
    A.pop();
    A.push(tmp);
    rem--;
  }
 
  long total = 0;
 
  rep(i, N){
    total += (long)floor(A.top());
    A.pop();
  }
 
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	int n,k;
	int m;
	cin>>n>>k;
	int count = 0;
	for(int i = 1;i<=n;++i){
		cin>>m;
		if(m>=k)count+=1;
	} 
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String[] vals = sc.nextLine().split("\\s+");
			Long a = Long.parseLong(vals[0]);
			Long b = Long.parseLong(vals[1]);
			Long g = gcd(a, b);
			a /= g;
			b /= g;
			Long res = a * b * g;
	        System.out.println(res);
		}
	}
	private static Long gcd(Long a, Long b) {
		if (b == 0) return a;
		else return gcd(b, a%b);
	}
}


Measured memory_bytes: 25172
#include<stdio.h>
int A[100000];
int flag[100000];
main(){
    int N;
    scanf("%d",&N);
    for(int i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    int next = 1;
    int count = 0;
    while(next != 2){
        if(flag[next-1]){
            printf("-1");
            return 0;
        }
        flag[next-1] = 1;
        next = A[next-1];
        count++;
    }
    printf("%d",count);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
char rsp[3] = {'r', 's', 'p'};
char const blank = 'z';

int main() {
  ll n, k;
  vector<ll> rsp_point(3);
  string t;

  cin >> n >> k;
  cin >> rsp_point[1] >> rsp_point[2] >> rsp_point[0];
  cin >> t;

  vector<char> record(n);
  ll ans = 0;

  rep(i, k) {
    for(int j = i; j < n; j += k) {
      rep(l, 3) {
        if (t[j] == rsp[l]) {
          if (j - k >= 0) {
            if(record[j-k] == t[j]) {
              record[j] = blank;
              continue;
            }
          }
          ans += rsp_point[l];
          record[j] = rsp[l];
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long lint;
typedef vector<lint> vl;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) REP(i,0,b)
#define maxn 100010

int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		bool fl=true;
		REP(i,1,100000){
			if(a*i%b == c%b&&fl){
				puts("YES");
				fl=false;
			}
		}
		if(fl)puts("NO");
	}
	return 0;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = [-int(x) for x in input().split() ]
heapq.heapify(a)

def pop():
    return -heapq.heappop(a)

def push(x):
    return heapq.heappush(a, -x)

for _ in range(m):
    tmp = pop()
    push(tmp//2)

print(-sum(a))


Measured memory_bytes: 14180
// 2014/07/14 Tazoe

#include <iostream>
using namespace std;

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

	if(a<b && b<c){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 1124
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <set>
#include <cstring>
#include <queue>
using namespace std;

const int N = 500009;
int fw[30][N];
char arr[N];

void add(int j, int i, int v){
    for(; i < N; i += i&(-i)) fw[j][i] += v;
}

int sum(int j, int i){
    int res = 0;
    for(; i; i -= i&(-i)) res += fw[j][i];
    return res;
}

int main(){
    int n, q, a, b, x;
    cin >> n;
    char c;
    for(int i = 1; i <= n; i++){
        cin >> c;
        arr[i] = c-'a';
        add(c-'a', i, 1);
    }
    cin >> q;
    while(q--){
        cin >> x >> a;
        if(x == 1){ // update
            cin >> c;
            add(arr[a], a, -1);
            add(c-'a', a, 1);
            arr[a] = c-'a';
        } else { // query
            cin >> b;
            int s = 0;
            for(int i = 0; i < 26; i++){
                if(sum(i, b) - sum(i, a-1)) s++;
            }
            cout << s << '\n';
        }
    }
}


Measured memory_bytes: 53504
#include<bits/stdc++.h>
#define ll long long
#define xll __int128
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
template <typename T>
void printvec(vector<T> v){ for(int i=0;i<(int)v.size();i++){ cout<<v[i]<<" ";} cout<<endl;}
template <typename T>
void printarr(T a[],int n){ for(int i=0;i<n;i++){ cout<<a[i]<<" ";} cout<<endl;}
//const int N=2e5;
//int arr[N+1];

bool isSame(pair<int,int> a){
	if(a.F==a.S){return true;}
	return false;	
} 
int main(){
	int n;
	cin>>n;
	vector< pair<int,int> > v;
	fo(i,n){
		int a,b;
		cin>>a>>b;
		v.pb(mp(a,b));	
	}
	fo(i,n-2){
		if(isSame(v[i]) && isSame(v[i+1]) && isSame(v[i+2])){
			cout<<"Yes"<<endl;
			return 0;	
		}	
	}
	cout<<"No"<<endl;
	return 0;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


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

#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define init(x) memset(x,0,sizeof(x))
#define abs(x) (x<0?(-x):x)
#define lcm(x,y) ((1ll)*x*y)/__gcd(x,y)
#define maxv(v) *max_element(v.begin(),v.end())
#define minv(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define tie() ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll inf=1e18L +5;



void solve(){

     int n,w;
     cin>>n>>w;
     vector<int> weight,value;
     int tot_value=0;
     for(int i=0;i<n;i++){
        int s,v;
        cin>>s>>v;
        weight.pb(s);
        value.pb(v);
        tot_value+=v;
     }

     vector<ll> dp(tot_value+1,inf);
     dp[0]=0;

     for(int i=0;i<n;i++){
        int s,v;
        s=weight[i];
        v=value[i];
        //cout<<"new item with w and v as"<<s<<" "<<v<<endl;
        for(int j=tot_value; j>0;j--){

            if(v<=j){
                    //cout<<"checking = "<<dp[j]<<" "<<dp[j-v]<<endl;
                dp[j]=min(dp[j],dp[j-v]+s);

            }
            //cout<<"dp["<<j<<"]="<<dp[j]<<endl;
        }
     }

     int ans=0;
     for(int i=1;i<=tot_value;i++){
            //cout<<"dp["<<i<<"]="<<dp[i]<<endl;
        if(dp[i]<=w){
            ans=max(ans,i);
        }
     }

     cout<<ans;




}
int32_t main()
{
    //clock_t st = clock();
    tie();
    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
   // clog<<(long double)((clock() - st)/CLOCKS_PER_SEC)<<endl;
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    char c;
    cin >> c;
    map<char, char> mp;
    mp['C'] = 'G';
    mp['G'] = 'C';
    mp['A'] = 'T';
    mp['T'] = 'A';
    cout << mp[c] << '\n';
}


Measured memory_bytes: 256
from functools import lru_cache
import sys

iMaxStackSize = 5000000
sys.setrecursionlimit(iMaxStackSize)
n = int(input())
heights = [int(x) for x in input().split()]

@lru_cache(None)
def solve(i):
    if i == n - 1:
        return 0
    if i + 2 >= len(heights):
        return abs(heights[i + 1] - heights[i])
    option1 = abs(heights[i] - heights[i + 1])
    option1 += solve(i + 1)
    option2 = abs(heights[i] - heights[i + 2])
    option2 += solve(i + 2)
    return min(option1, option2)

print(solve(0))


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

int main() {
  int D;
  cin >> D;
  string S = "Christmas";
  string E = " Eve";
  cout << S;
  if(D <= 24) cout << E;
  if(D <= 23) cout << E;
  if(D <= 22) cout << E;
  cout << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int N;
    cin >> N;
    if(floor( ceil(N/1.08)*1.08 ) == N){
        cout << ceil(N/1.08) << endl;
    }else{
         cout << ":(" << endl;
    }
}

Measured memory_bytes: 888
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dp[301][301][301];

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


	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> RX[301];
	rep(i, M) {
		int l, r, x;
		cin >> l >> r >> x;
		RX[r].pb(mp(l, x));
	}

	const int mod = 1e9 + 7;
	dp[0][0][0] = 1;
	rep1(i, N) {
		int xm[4], xM[4];
		xm[1] = 1000;
		xm[2] = 1000;
		xm[3] = 1000;
		xM[1] = -1;
		xM[2] = -1;
		xM[3] = -1;
		for (auto p : RX[i]) {
			chmax(xM[p.second], p.first);
			chmin(xm[p.second], p.first);
		}
		rep(j, i) rep(k, i) {
			int jj = j;
			int kk = k;
			int OK = 1;
			if (xm[1] < kk) OK = 0;
			if (xm[2] < jj) OK = 0;
			if (xM[2] >= kk) OK = 0;
			if (xM[3] >= jj) OK = 0;
			if (OK) {
				dp[i][jj][kk] += dp[i - 1][j][k];
				dp[i][jj][kk] %= mod;
			}
			jj = j;
			kk = i;
			OK = 1;
			if (xm[1] < kk) OK = 0;
			if (xm[2] < jj) OK = 0;
			if (xM[2] >= kk) OK = 0;
			if (xM[3] >= jj) OK = 0;
			if (OK) {
				dp[i][jj][kk] += dp[i - 1][j][k];
				dp[i][jj][kk] %= mod;
			}
			jj = k;
			kk = i;
			OK = 1;
			if (xm[1] < kk) OK = 0;
			if (xm[2] < jj) OK = 0;
			if (xM[2] >= kk) OK = 0;
			if (xM[3] >= jj) OK = 0;
			if (OK) {
				dp[i][jj][kk] += dp[i - 1][j][k];
				dp[i][jj][kk] %= mod;
			}
		}
	}

	ll kotae = 0;
	rep(j, N + 1) rep(k, N + 1) {
		kotae += dp[N][j][k];
	}
	co(kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 211328
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;
 
const int N = 1e5 + 5, MOD = 1e9 + 7;
 
int n;
int a[N];
 
int ans;
 
main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    n = 100;
    cin >> n;
    for (int i = 1; i <= n; i++){
        a[i] = i;
        cin >> a[i];
    }
    for (int t = 1; t < n; t++){
        int s = 0;
        for (int i = 1; i <= t; i++)
            s += a[i];
        for (int i = t + 1; i <= n; i++)
            s -= a[i];
        if (s < 0)
            s = -s;
        if (s < ans || t == 1)
            ans = s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make(map[int]int)

	ans := "YES"
	for i := 0; i < N; i++ {
		idx := getInt()
		a[idx]++
		if a[idx] > 1 {
			ans = "NO"
		}
	}

	out(ans)
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int N, Y;
  bool ans = false;
  cin >> N >> Y;
  REP(i, N + 1) {
    REP(n, N + 1) {
      if (10000 * i + 5000 * n + (N - n - i) * 1000 == Y && i + n <= N) {
        cout << i << ' ' << n << ' ' << N - n - i << endl;
        ans = true;
        break;
      }
    }
    if (ans) {
      break;
    }
  }
  if (!ans) {
    cout << "-1 -1 -1" << endl;
  }
}

signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 256
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, m, x, a, left = 0, right = 0;
  scanf("%lld%lld%lld", &n, &m, &x);
  for (int i = 0; i < m; i++)
  {
    scanf("%lld", &a);
    if (a <= x)
    {
      left++;
    }
    else
    {
      right++;
    }
  }
  printf("%lld\n", MIN(left, right));
  return 0;
}

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


int main() {

    int n;
    cin >> n;
    vector<int> a(100100, 0);
    for (int i = 0; i < n; ++i) {
        int num; cin >> num;
        a[num] += 1;
    }
    int mx = 0;
    for(int i = 1; i < 100010; ++i) {
        if (mx < a[i-1]+a[i]+a[i+1]) mx = a[i-1]+a[i]+a[i+1];
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

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

int main(){
    ll a, b; cin >> a >> b;
    ll c = gcd(a, b);
    int cnt = 0;
    
    for(ll i = 2; i * i <= c; i++){
        if(!(c%i)) ++cnt;
        while(!(c%i)) c /= i;
        if(c==1) break;
    }
    if(c!=1) ++cnt;
    cout << ++cnt << "\n";
    return 0;
}

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

using namespace std;

int main(void){

    int N,M,a,total(0);
    cin >> N >> M;
    
    
    for(int i=0;i<M;++i){
        cin >> a;
        total += a;
    }

    if(N >= total){
        cout << N - total << endl;
    }else{
        cout << -1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  	int cnt[n+1];
  memset(cnt,0,sizeof(cnt));
  for(int i=1;i<=n-1;i++){
    int x;cin>>x;
    cnt[x]++;
  }
  for(int i=1;i<=n;i++){
    cout<<cnt[i]<<endl;
    
  }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int mm, dd;

int main() {
    cin >> mm >> dd;
    int ans = 0;
    for (int m = 1; m <= mm; ++m) {
        for (int x = 2; x <= 9; ++x) {
            for (int y = 2; y <= 9; ++y) {
                int d = x * 10 + y;
                if (d <= dd && x * y == m) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256