akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100005];
int p[100005],cc[100005];
main()
{
	int t,st,ed,pp;
	scanf("%d%d",&t,&pp);
	for(int i = 0;i < pp;i++)
	{
		scanf("%d%d",&st,&ed);
		p[ed]++;
		v[st].push_back(ed);
	}
	queue<int>q;
	for(int i = 1;i <= t;i++)
	{
		if(p[i]==0)
		q.push(i);
	}
	while(!q.empty())
	{
		int cur=q.front();
		//printf("%d",cur);
		for(int i = 0;i < v[cur].size();i++)
		{
			p[v[cur][i]]--;
			if(p[v[cur][i]]==0)
			q.push(v[cur][i]);
			cc[v[cur][i]]=max(cc[v[cur][i]],cc[cur]+1);
		}
		q.pop();
	}
	int mx=0;
	for(int i = 1;i <= t;i++)
	mx=max(mx,cc[i]);
	printf("%d",mx);
}

Measured memory_bytes: 6528
N = int(input())
h = list(map(int, input().split()))

def chmin(a, b):
  if a > b:
    return b
  else:
    return a

f_inf = float('inf')
dp = [f_inf] * (10**5 + 10)
dp[0] = 0

for i in range(1,N):
  dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
  if i >1:
    dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

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

struct Graph {
  int n;
  int time;
  vector<vector<int>> g;
  vector<int> num, low;
  vector<vector<int>> scc;
  stack<int, deque<int>> S;
  vector<bool> inS;

  Graph(int n) : n(n), g(n), num(n, -1), low(n, -1), inS(n, false) {}

  void addEdge(int u, int v) {
    g[u].push_back(v);
  }
  void dfs(int u) {
    num[u] = low[u] = time++;
    S.push(u);
    inS[u] = true;
    for (auto&& v : g[u]) {
      if (num[v] == -1) {
        dfs(v);
        low[u] = min(low[u], low[v]);
      } else if (inS[v]) {
        low[u] = min(low[u], num[v]);
      }
    }
    if (low[u] == num[u]) {
      scc.push_back({});
      while (true) {
        int v = S.top(); S.pop();
        inS[v] = false;
        scc.back().push_back(v);
        if (u == v) break;
      }
    }
  }
  void stronglyConnectedComponents() {
    for (int i = 0; i < n; ++i) {
      if (num[i] == -1) dfs(i);
    }
  }
};

int main() {
  int n, m; cin >> n >> m;
  Graph g(n);
  while (m--) {
    int s, t; cin >> s >> t;
    g.addEdge(s, t);
  }
  g.stronglyConnectedComponents();
  reverse(begin(g.scc), end(g.scc));
  for (auto&& x : g.scc) cout << x[0] << endl;
  return 0;
}



Measured memory_bytes: 4176
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner i=new Scanner(System.in);
		int a=i.nextInt();
		String op=i.next();
		int b=i.nextInt();
		while (op.equals("?")==false){
			if(op.equals("+")) System.out.println(a+b);
			else if(op.equals("-"))System.out.println(a-b);
			else if(op.equals("*"))System.out.println(a*b);
			else if(op.equals("/"))System.out.println(a/b);
			a=i.nextInt();
			op=i.next();
			b=i.nextInt();
		}
	}
}

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

using namespace std;
using ll=long long;

void solve() {
    int n; cin >> n;
    map<int,set<int>> mp;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        mp[x].insert(i);
    }
    vector<ll> res(n, 0);
    int sz = 0;
    int i = n;
    for (auto rit = mp.rbegin(); rit != mp.rend(); rit++) {
        auto &ids = rit->second;
        auto j = next(rit);
        sz += ids.size();
        int pre = j==mp.rend()?0:j->first;
        int d = rit->first - pre;
        i = min(i, *ids.begin());
        res[i] += 1ll*d*sz;
    }
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    ll ans = 0, i;
    for(i = 0; i < 3; i++)
        ans += (s[i] == t[i] ? 1 : 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
f = False
f2 = True
c = 0
if s[0] =="A":
    f = True
for x in s[2:len(s)-1]:
    if x == "C":
        c +=1
    else:
        if x.isupper() or s[-1].isupper():
            f2 = False
if not s[1].islower():
    f2 = False
if f and c == 1 and f2:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
    using namespace std;
    map<int,int> m;
    map<int,int>::iterator m_it;
    int main()
    {
    int i,n,k,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%d",&k);
    m.count(k)==0?m[k]=1:m[k]++;
    }
    for(m_it=m.begin();m_it!=m.end();++m_it)
    {
    if(m_it->first<=m_it->second)
    sum+=m_it->second-m_it->first;
    else
    sum+=m_it->second;
    }
    printf("%d",sum);
    return 0;
    }

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll Q;
  cin >> Q;

  priority_queue<ll> Q0;
  priority_queue<ll, vector<ll>, greater<ll>> Q1;
  ll A0 = 0, A1 = 0, B = 0;
  for (ll i = 0; i < Q; i++)
  {
    ll q;
    cin >> q;

    if (q == 1)
    {
      ll a, b;
      cin >> a >> b;
      B += b;

      if (!Q0.empty() && a > Q0.top())
      {
        Q1.push(a);
        A1 += a;
      }
      else
      {
        Q0.push(a);
        A0 += a;
      }

      if (Q0.size() - Q1.size() == 2)
      {
        ll a0 = Q0.top();
        Q0.pop();
        Q1.push(a0);
        A1 += a0, A0 -= a0;
      }
      if (Q1.size() - Q0.size() == 1)
      {
        ll a1 = Q1.top();
        Q1.pop();
        Q0.push(a1);
        A0 += a1, A1 -= a1;
      }
    }
    else
    {
      ll x = Q0.top();
      ll ans = (x * Q0.size() - A0) + (A1 - x * Q1.size()) + B;
      cout << x << " " << ans << endl;
      //cerr << A0 << " " << A1 << " " << B << endl;
    }
  }
}

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int a = sc.nextInt();
			int b = sc.nextInt();
			execute(a, b);
		}
	}

	private static void execute(int a, int b) {
		if(a == b) {
			System.out.println("Draw");
		}  else if (a == 1){
			System.out.println("Alice");

		}  else if (b == 1){
			System.out.println("Bob");

		}  else if (a > b){
			System.out.println("Alice");

		} else {
			System.out.println("Bob");

		}

	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct E{
  int idx, time, lane, s;
  E() {}
  E(int i, int t, int l, int s) :
    idx(i), time(t), lane(l), s(s) {}
  bool operator < (const E& e) const {
    if(time != e.time) return time > e.time;
    if(s != e.s) return s > e.s;
    return idx > e.idx;
  }
};

int main(){
  int N;
  while(cin>>N && N){
    priority_queue<E> que;
    int rest[50] = {};
    REP(i, N){
      int t, c; cin>>t>>c;
      que.push(E(i, 0, 0, t));
      rest[i] = c;
    }
    int last[2] = {};
    while(!que.empty()){
      E e = que.top(); que.pop();
      int rt = e.time + e.s;
      int nl = e.lane ^ 1;
      if(last[nl] < rt){
        last[nl] = rt;
      }else{
        rt = last[nl];
      }
      if(nl == 0 && --rest[e.idx] == 0){
        continue;
      }
      que.push(E(e.idx, rt, nl, e.s));
    }
    cout<<last[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [1] * (M+1)
dpleft = [0] * (M)
MOD = 10 ** 9 + 7
ndp = [1] * (M+1)
for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            ndp[m+1] = ndp[m] + dp[m+1]
            dpleft[m] = dp[m+1]
        else:
            ndp[m+1] = ndp[m] + dpleft[m]
    dp = ndp[:]
print(dp[-1] % MOD)

Measured memory_bytes: 125404
a = [str(x) for x in input()]

N = len(a)
b = []

for i in range(N):
    if a[i] == "0":
        b.extend("0")
        
    elif a[i] == "1":
        b.extend("1")
        
    else:
        if len(b) == 0:
            pass
        else:
            b.pop(-1)
            

print("".join(b))      

Measured memory_bytes: 3064
S = input()
ans = 0
N_list = [0]
for i in range(len(S)) :
    N = S[i:i + 1]
    if N == "A" or N == "T" or N == "C" or N == "G" :
        ans += 1
        N_list.append(ans)
    else :
        ans = 0
print(max(N_list))

Measured memory_bytes: 3060
#include<cstddef>
#include<cstdint>
#include<iostream>
#include<unordered_map>

int main(){
  using usize = std::size_t;
  using u32 = std::uint_fast32_t;
  using i64 = std::int_fast64_t;

  usize n;
  std::cin >> n;

  u32 ans = 0;
  i64 acc = 0;
  std::unordered_map<i64, u32> count;
  ++count[acc];

  for(usize i = 0; i != n; ++i){
    i64 a;
    std::cin >> a;

    acc += a;
    ans += count[acc];
    ++count[acc];
  }

  std::cout << ans << std::endl;

 return 0;
}


Measured memory_bytes: 8520
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def MI(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if directed==False:
            pt[t[i]-1].append(s[i]-1)
    return pt

def shortest_path(pt,s,t):
    n = len(pt)
    used = [False]*n
    pre = [-1]*n
    q = [s]
    while q:
        q1 = []
        for i in q:
            for j in pt[i]:
                if not used[j]:
                    used[j] = True
                    pre[j] = i
                    q1.append(j)
        q = q1

    if used[t]:
        path = [t]
        p = t
        while True:
            p = pre[p]
            path.append(p)
            if p == s:
                break
        return list(reversed(path))
    else:
        return []

N = I()
a,b = MI(N-1,2)

pt = edges_to_pt(a,b,N)
path = shortest_path(pt,0,N-1)

v = path[math.ceil(len(path)/2)]
visited = [False]*N
visited[v] = True
S = [v]
num = 1
while S:
    v1 = S.pop()
    for i in pt[v1]:
        if i == path[math.ceil(len(path)/2)-1]:
            continue
        if not visited[i]:
            visited[i] = True
            num += 1
            S.append(i)

if N-num > num:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 78684
n=int(input())
s=input()
ans=0
for i in range(1,n):
    cnt=0
    a=s[:i]
    b=s[i:]
    for j in range(ord('a'),ord('z')+1):
        if a.count(chr(j)) and b.count(chr(j)): cnt+=1
    ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 3064
// https://agc026.contest.atcoder.jp/tasks/agc026_c
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

seed_seq seq {
    uint64_t(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()),
    uint64_t(__builtin_ia32_rdtsc()),
    uint64_t(uintptr_t(make_unique<char>().get()))
};

mt19937 rng(seq); mt19937_64 rng64(seq);

const size_t RANDOM = uniform_int_distribution<size_t>(0, numeric_limits<size_t>::max())(rng64);
template <class T, class H = hash<T>> struct rand_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator () (const T &x) const { return splitmix64(H()(x) + RANDOM); }
};

template <class T1, class T2, class H1 = rand_hash<T1>, class H2 = rand_hash<T2>> struct pair_hash {
    size_t operator () (const pair<T1, T2> &p) const { return 31 * H1()(p.first) + H2()(p.second); }
};

template <class K, class H = rand_hash<K>, class ...Ts> using hashset = gp_hash_table<K, null_type, H, Ts ...>;
template <class K, class V, class H = rand_hash<K>, class ...Ts> using hashmap = gp_hash_table<K, V, H, Ts ...>;

int N;
string S;
hashmap<pair<string, string>, ll, pair_hash<string, string>> M;

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // freopen("err.txt", "w", stderr);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N >> S;
    for (int i = 0; i < (1 << N); i++) {
        string red, blue;
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) red.push_back(S[j]);
            else blue.push_back(S[j]);
        }
        reverse(blue.begin(), blue.end());
        M[make_pair(red, blue)]++;
    }
    ll cnt = 0;
    for (int i = 0; i < (1 << N); i++) {
        string red, blue;
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) red.push_back(S[N + j]);
            else blue.push_back(S[N + j]);
        }
        reverse(blue.begin(), blue.end());
        cnt += M[make_pair(blue, red)];
    }
    cout << cnt << nl;
    return 0;
}


Measured memory_bytes: 249300
n, m = list(map(int, input().split()))
h_list = list(map(int, input().split()))
hh_list = [1] * n

for mm in range(m):
    a, b = list(map(int, input().split()))
    if h_list[a-1] - h_list[b-1] < 0:
        hh_list[a-1] = 0
    if h_list[b-1] - h_list[a-1] < 0:
        hh_list[b-1] = 0
    if h_list[a-1] == h_list[b-1]:
        hh_list[a-1] = 0
        hh_list[b-1] = 0

counter = 0
for hh in hh_list:
    if hh >= 1:
        counter += 1
print(counter)

Measured memory_bytes: 20136
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    vector<vector<int>> c(3, vector<int>(3, 0));
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    int min_num1 = min({c[0][0], c[0][1], c[0][2]});
    int min_num2 = min({c[1][0], c[1][1], c[1][2]});
    int min_num3 = min({c[2][0], c[2][1], c[2][2]});
    bool ok = true;
    if ( c[0][0] - min_num1 != c[1][0] - min_num2 || c[1][0] - min_num2 != c[2][0] - min_num3 ) {
        ok = false;
    }
    if ( c[0][1] - min_num1 != c[1][1] - min_num2 || c[1][1] - min_num2 != c[2][1] - min_num3 ) {
        ok = false;
    }
    if ( c[0][2] - min_num1 != c[1][2] - min_num2 || c[1][2] - min_num2 != c[2][2] - min_num3 ) {
        ok = false;
    }
    
    if ( !ok ) cout << "No" << endl;
    else       cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:01:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

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

    ll t,i,x;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>x;
        ld p=1.01;
        ll q=100;
        fs(i,1,1e7)
        {
            if(q*p>=x)
            {cout<<i;break;}
            else
                q=q*p;
        }
    }
    return 0;
}













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

public class Main {
	public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	int A = Integer.parseInt(str.split(" ")[0]);
    	int B = Integer.parseInt(str.split(" ")[1]);
    	
    	int total = 0;
    	if (A >= B) {
    		total += A;
    		A--;
    	} else {
    		total += B;
    		B--;
    	}
    	
    	if (A >= B) {
    		total += A;
    	} else {
    		total += B;
    	}
    	
    	System.out.println(total);
    }	
}


Measured memory_bytes: 24532
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		int i,j,wk;

		Scanner scan=new Scanner(System.in);
		int a[]=new int [3];
		
		for( i=0;i<3;i++){
			 a[i]=scan.nextInt();
		}
		
		scan.close();
		
		for( i=0;i<a.length-1;i++){
			wk=i;
			for( j=i+1;j<a.length;j++){
				if(a[wk]>a[j])
					wk=j;
			}
			if(wk!=i){
				int temp=0;
				temp=a[wk];
				a[wk]=a[i];
				a[i]=temp;
			}
		}
		
		for(i=0;i<a.length-1;i++){ 
			System.out.print(a[i]+" ");
		}
	 System.out.print(a[i]+"\n");
	}

}

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

using namespace std;

int main(){
    int n;cin >> n;
    int i;
    int ans = 0;
    for(i = 1 ; i<= n ; i++){
        if((i - 10) < 0 ){
            ans++;
        }else if(i >= 100 && i < 1000){
            ans++;
        }else if(i >= 10000 && i < 100000){
            ans++;
        }
    }




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

Measured memory_bytes: 256
/*input
ABCD
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;++i){
		if(s[i]=='A' && s[i+1]=='C')
			return cout<<"Yes",0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int N, M, t, S_h, S_w, ans, a, b, c, d;
  while (cin >> N >> M, N) {
    vector<int> h, w;
    ans = 0;
    for (int i = 0; i < N; ++i) {
      cin >> t;
      h.push_back(t);
    }
    for (int i = 0; i < M; ++i) {
      cin >> t;
      w.push_back(t);
    }
    for (int i = 2; i < N+1; ++i) {
      t = 0;
      for (int j = 0; j < i; ++j) t += h[j];
      h.push_back(t);
      for (int j = i; j < N; ++j) {
	t += h[j];
	t -= h[j-i];
	h.push_back(t);
      }
    }
    sort(h.begin(), h.end());
    for (int i = 2; i < M+1; ++i) {
      t = 0;
      for (int j = 0; j < i; ++j) t += w[j];
      w.push_back(t);
      for (int j = i; j < M; ++j) {
	t += w[j];
	t -= w[j-i];
	w.push_back(t);
      }
    }
    sort(w.begin(), w.end());
    S_h = h.size();
    S_w = w.size();
    a = 0;
    b = 0;
    while (a < S_h && b < S_w) {
      if (h[a] < w[b]) ++a;
      else if (h[a] > w[b]) ++b;
      else {
	c = a;
	d = b;
	while (h[a] == h[c]) ++a;
	while (w[b] == w[d]) ++b;
	ans += (a-c)*(b-d);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 19708
while True:
    x, op, y = input().split()
    a = int(x)
    b = int(y)
    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    elif op=='/':
        print(a//b)
    elif op=='?':
        break


Measured memory_bytes: 5596
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1716
str = gets.split
N,K = str[0].to_i, str[1].to_i
h = Array.new(N)
a = 0

str = gets.split
for x in 0...N do
    h[x] = str[x].to_i
    if h[x] >= K
        a += 1
    end
end

puts a

Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define vi vector<ll>
# define vvi vector<vi>
# define rep(i, N) for (int i = 0; i < N; i++)
# define Rep(i, N) for (int i = 1; i <= N; i++)
# define deb(x) cerr << #x << ": " << x << endl;
# define deb2(x, i) cerr << #x << "[" << i << "]: " << x[i] << endl;
/*
vi v(10, 2); 
rep(i, 10) deb2(v, i); 
*/

/*
int a; cin >> a;
int a, b; cin >> a >> b;
rep(i, n){cin >> v[i];}
cout <<   << endl;
*/

signed		main()
{
	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k)
	{
		cout << s << endl;
		return 0;
	}
	for (int i = 0; i < k; i++)
	{
		cout << s[i];
	}
	cout << "..." << endl;

}



Measured memory_bytes: 3612
n,m=map(int,input().split())

d={}
for i in range(m):
    p,y=map(int, input().split())
    if p not in d:
        d[p]=[[y,p,i]]
    else:
        d[p].append([y,p,i])

bango_list=['0']*m
for key in d:
    d[key].sort()
    for i in range(len(d[key])):
        p_bango=str(key).zfill(6)
        x_bango=str(i+1).zfill(6)
        bango_list[d[key][i][2]]=p_bango+x_bango

for b in bango_list:
    print(b)


Measured memory_bytes: 46008
#include <iostream> 
using namespace std;
int main()
{
	int b,n; cin>>b>>n;
	int a[n],sum=0;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];
		sum+=a[i];
	}
	
	sum>b?cout<<-1:cout<<b-sum;
}


Measured memory_bytes: 3200
#include <iostream>

int main() {
    int N;
    std::cin >> N;

    int M;
    std::cin >> M;

    char a[] = "Yes";
    char b[] = "No";

    if (N == M) {
        std::cout << a << std::endl;
    }
    else {
        std::cout << b << std::endl;
    }
}

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

int main(){
	string s;
	cin>>s;
	int a=0;
	// 偶数0パターン
	for(int i=0;i<s.size();i++){
		if(i%2==0 && s[i]!='0')a++;
		if(i%2!=0 && s[i]!='1')a++;
	}
	int b=0;
	// 偶数1パターン
	for(int i=0;i<s.size();i++){
		if(i%2==0 && s[i]!='1')b++;
		if(i%2!=0 && s[i]!='0')b++;
	}
	cout<<min(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 512
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[210000];
map<long long,int>M;
long long L[210000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
		p[i]=(p[i]+b-1)%b;
	}
	long long ret=0;
	M[0]=1;
	long long cur=0;
	L[0]=0;
	for(int i=0;i<a;i++){
		if(i+1>=b)M[L[i+1-b]]--;
		cur+=p[i];
		cur%=b;
		ret+=M[cur];
		L[i+1]=cur;
		// printf("%d: %lld %d\n",i,cur,M[cur]);
		M[cur]++;

	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 15104
#include <iostream>
#include <vector>

int partition(std::vector<int>* A, int p, int r) {
  int x = (*A)[r];
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if ((*A)[j] <= x) {
      i = i + 1;
      std::swap((*A)[i], (*A)[j]);
    }
  }
  std::swap((*A)[i + 1], (*A)[r]);
  return i + 1;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> A;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    A.push_back(a);
  }
  int idx = partition(&A, 0, n - 1);
  for (int i = 0; i < n; ++i) {
    std::cout << (i == idx ? "[" : "" ) << A[i] << (i == idx ? "]" : "") <<
      (i == n-1 ? "\n" : " ");
  }
  return 0;
}

Measured memory_bytes: 3448
using System;

namespace ABC172_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            a = a + (int)Math.Pow(a, 2) + (int)Math.Pow(a, 3);
            Console.WriteLine(a);
        }
    }
}


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

using namespace std;
#define int int long long

const int MAX_N = 100000;
int N;
int S[MAX_N + 1];
int A[MAX_N];

bool f(int x) {
    int sz = S[x+1];
    for (int i = x + 1; i < N; i++) {
        if (A[i] > sz * 2) return false;
        sz += A[i];
    }
    return true;
}

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A, A + N);
    for (int i = 0; i < N; i++) S[i+1] = S[i] + A[i];

    // 不可能な色の数をにぶたんでもとめる
    int lb = -1;
    int ub = N + 1;
    while (ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if (f(mid)) ub = mid;
        else lb = mid;
    }

    cout << N - ub << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
    int n, l;
    while (cin >> n >> l) {
        int min = l, max = l + n - 1;
        if (min >= 0) {
            cout << (n - 1) * (min + max + 1) / 2 << endl;
        }
        else if (max <= 0) {
            cout << (n - 1) * (min + max - 1) / 2 << endl;
        }
        else {
            cout << n * (min + max) / 2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
let pn = 1000000007

let pow x n =
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (acc*x)
  in doit 0 1

let str_fold_left f init s =
  let n = String.length s in
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (f acc s.[i])
  in doit 0 init

let () =
  let p = read_line () in
  let t = read_line () in
  let n = String.length p in
  let m = String.length t in
  let h = Array.make (n + 1) 0 in
  String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;
  let ht = str_fold_left (fun acc c -> acc*pn + Char.code c) 0 t in
  let x = pow pn m in
  let rec doit i =
    if i <= n then begin
      if h.(i) - h.(i-m)*x = ht then Printf.printf "%d\n" (i - m);
      doit (i + 1)
    end in
  doit m

Measured memory_bytes: 14392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll Q;
    cin >> Q;
    rep(_, Q){
        ll A, B;
        cin >> A >> B;
        ll C = A * B - 1, sc = (ll)sqrt(A * B - 1 + 0.01L);
        if (A > B) swap(A, B);
        if(sc==0){
            cout << 0 << endl;
            continue;
        }

        ll ans = 0;
        ans = 2 * (sc - 1);
        
        if (A <= sc) ans--;
        ans += (C / sc == sc ? 1 : 2);
        cout << ans << endl;
    }
}   

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

const int MAX = 3;
int main() {
	int N[MAX];
	for (int i = 0;i < MAX;i ++) cin >> N[i];
	sort(N, N + MAX);
	if (N[0] == N[1]) cout << N[2];
	else cout << N[0];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

値のとり方は3C2より全部で3通りしかないので、3個のif文で良いんじゃないかな
上のコードのように一度ソートすれば、先頭か末尾のどちらかになるのでもうちょっと短くなる
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 cin >> N;
 int a[N];
 int i;
 for(i=0;i<N;++i){
   cin >> a[i];}
int count = 0;
int min = 1000000;
 for(i=0;i<N;++i){
    if(min>a[i]){count++;
    min = a[i];}
 }

     cout << count << endl;
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
ll h[maxn],k,n;

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>h[i];
    sort(h,h+n);
    ll ans = 1e18;
    for(int i=0;i+k-1<n;i++)
        ans = min(ans,h[i+k-1]-h[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	vector<int> a(3);
	rep(i,3)std::cin >> a[i];
	sort(all(a));
	rep(i,2)std::cout << a[i] << " ";
	std::cout << a[2] << std::endl;
}


Measured memory_bytes: 3112
import java.util.*;

public class Main {

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

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] S = new String[N];
        for (int i = 0; i < N; i++) {
            S[i] = sc.next();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        System.out.println(ans);
    }
}

Measured memory_bytes: 50536
#include <stdio.h>
int main(void){
    int N, M, C = 0;
    scanf("%d %d %d", &N, &M, &C);
    int B[20] = {0};
    int A[20][20] = {0};
    for(int i = 0; i < M; i++){
        scanf("%d", &B[i]);
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            scanf("%d", &A[i][j]);
        }
    }

    int answer = 0;

    for(int i = 0; i < N; i++){
        int total = 0;
        for(int j = 0; j < M; j++){
            total += B[j] * A[i][j];
        }
        if(total + C > 0) answer++;
    }

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

    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

#define MAX 2000005

const int MOD = 1e9 + 7;

long long power[MAX], fact[MAX], inv[MAX];

void sub(long long &a, long long b) {
    a -= b;
    if (a < 0) a += MOD;
}

long long inverse(long long a) {
    long long ret = 1, b = MOD - 2;
    for (; b>0; b/=2) {
        if (b % 2) ret = ret * a % MOD;
        a = a * a % MOD;
    }
    return ret;
}

long long choose(int n, int k) {
    return fact[n] * inv[k] % MOD * inv[n-k] % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int k;
    string s;
    cin >> k >> s;

    long long ret = 1;
    power[0] = fact[0] = inv[0] = 1;
    for (int i=1; i<=k+s.length(); i++) {
        ret = ret * 26 % MOD;
        power[i] = power[i-1] * 25 % MOD;
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = inverse(fact[i]);
    }

    for (int i=0; i<s.length(); i++)
        sub(ret, choose(k + s.length(), i) * power[k + s.length() - i] % MOD);

    cout << ret << "\n";

    return 0;
}


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

int main()
{
    stack<int> S1;
    stack<pair<int, int> > S2;
    char c;
    int sum = 0;

    for (int i = 0; cin >> c; ++i)
    {
        if (c == '\\')
        {
            S1.push(i);
        }
        else if (c == '/' && S1.size() > 0)
        {
            int j = S1.top();
            sum += i - j;
            int a = i - j;
            S1.pop();

            while (S2.size() > 0 && S2.top().first > j)
            {
                a += S2.top().second;
                S2.pop();
            }

            S2.push(make_pair(j, a));
        }
    }

    cout << sum << endl;

    vector<int> vec;

    while (!S2.empty())
    {
        vec.push_back(S2.top().second);
        S2.pop();
    }

    reverse(vec.begin(), vec.end());

    cout << vec.size();

    for (vector<int>::iterator it = vec.begin(); it != vec.end(); ++it)
    {
        cout << " " << *it;
    }
    
    cout << endl;

    return 0;
}


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

int main()
{
	int a[5];
	for(int i  = 0; i<5;i++)cin >> a[i];
	int ans = 0;
	if(a[0]+a[1]>a[2]*2)
	{
		int mi = min(a[3],a[4]);
		ans += mi*2*a[2];
		a[3] -= mi;
		a[4] -= mi;
	}

	if(a[0]>a[2]*2)
	{
		ans += a[3]*2*a[2];
		a[3]=0;
	}

	if(a[1]>a[2]*2)
	{
		ans += a[4]*2*a[2];
		a[4]=0;
	}
	ans += a[3]*a[0];
	ans += a[4]*a[1];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	max := n
	for l, r := 1, n; l <= r; {
		mid := (r + l) / 2
		max = mid
		if s := sum(mid); l == r || s == n {
			break
		} else if s < n {
			l = mid + 1
		} else {
			r = mid
		}
	}

	rm := sum(max) - n
	for i := 1; i <= max; i++ {
		if i != rm {
			puts(i)
		}
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func sum(a int) int {
	return (a * (a + 1)) / 2
}


Measured memory_bytes: 640
fun main (args : Array<String>) {
	val n = readLine()
	val N : Int = n!!.toInt()
	val list = readLine()!!.split(" ").map(String::toInt)
	var wList : MutableList<Int> = mutableListOf()
	var S1 : Int = 0
	var S2 : Int = 0
	var T : Int = 0
	var calc : Int = 0
	var result : Int = 0
	for (i in 0..N - 1) {
		wList.add(list[i])
	}
	for (i in 0..N - 1) {
		T = i
		for (j in 0..T) {
			S1 += wList[j]
		}
		for (k in N - 1 downTo T + 1) {
			S2 += wList[k]
		}
			
		if (i == 0) {
			result = S2 - S1
		}
		
		calc = S2 - S1
		if (calc < 0) {
			calc = -(calc)
		}
		
		if (result >= calc) {
			result = calc
			S1 = 0
			S2 = 0
		} else {
			S1 = 0
			S2 = 0
		}
		
	}
	println("${result}")
}

Measured memory_bytes: 37932
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;

int code(char c) {
	if (c == '<')return 1;
	else return -1;
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	int i;
	if (N % 2 == 1) {
		cout << "No";
		return 0;
	}
	for (i = 0; i < N / 2; i++) {
		if (S[i] != S[i + (int)(N/2)]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

#define MAX(x,y) (((x)>(y))?(x):(y))

struct node{
  int l,index;
};

void make_pr_queue(struct node *array, int n);
struct node pop_pr_queue(struct node *array,int n);

int main(void){
  struct node *ice,now;
  int *time;
  int i,k=0,n,L;

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

  ice=(struct node *)calloc(n,sizeof(struct node));
  time=(int *)calloc(n,sizeof(int));

  for(i=0;i<n;i++){
    scanf("%d",&ice[i].l);
    ice[i].index=i;
  }

  make_pr_queue(ice,n);
  for(i=0;i<n;i++){
    now=pop_pr_queue(ice,n-i);
    time[now.index]=L-now.l;
    if(now.index==0) time[now.index]+=time[now.index+1];
    else if(now.index==n-1) time[now.index]+=time[now.index-1];
    else time[now.index]+=MAX(time[now.index-1],time[now.index+1]);
    
    if(time[now.index]>k) k=time[now.index];
  }
  printf("%d\n",k);
  free(ice);
    free(time);
  return 0;
}

void make_pr_queue(struct node *array, int n){
  int i,tmp;
  struct node swaps;

  for(i=n-1;i>=0;i--){
    if(2*i+1>=n) continue;
    if(2*i+2<n && array[2*i+2].l>array[2*i+1].l) tmp=2*i+2;
    else tmp=2*i+1;
    if(array[tmp].l>array[i].l){
      swaps=array[i];
      array[i]=array[tmp];
      array[tmp]=swaps;
      i=tmp+1;
      if(i>n-1) i=n-1;
    }
  }
}

struct node pop_pr_queue(struct node *array,int n){
  struct node ret,swaps;
  int i,next,tmp;
  ret=array[0];
  array[0]=array[n-1];

  for(i=0;2*i<n-2;i=next){
    if(2*i+2<n-1 && array[2*i+2].l>array[2*i+1].l) next=2*i+2;
    else next=2*i+1;
    if(array[next].l>array[i].l){
      swaps=array[i];
      array[i]=array[next];
      array[next]=swaps;
    }else break;
  }

  return ret;
}

Measured memory_bytes: 1680
// Problem : C - Ubiquity
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Macros

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(x) (int) x.size()
#define mod 1000000007
#define EPS 1e-9
#define inf 1e10
#define PI acos(-1.0)
#define int long long
#define N 100005

// Solution

void solve() {
  int n;
  cin >> n;
  int a = 1, b = 2, c = 1;
  for (int i = 1; i <= n; i++) {
    a *= 10;
    a %= mod;
    b *= 9;
    b %= mod;
    c *= 8;
    c %= mod;
  }
  int ans = (a - b + mod) % mod;
  ans = (ans + c) % mod;
  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

  int tests;
  tests = 1;
  // cin>>tests;

  for (int test = 1; test <= tests; test++) {
    // cout<<"Case #"<<test<<": ";
    solve();
  }

  return 0;
}

Measured memory_bytes: 3644
import Control.Monad                                                                                                       
import Data.List                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [n,_] <- map read . words <$> getLine :: IO [Int]                                                                        
  ss <- replicateM n getLine                                                                                               
  putStrLn $ concat . sort $ ss

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t,u;
  	int sn,tn;
  	while(cin>>s>>t){
    	cin>>sn>>tn;
      	cin.ignore();
      	cin>>u;
      if(s==u)sn-=1;
      if(t==u)tn-=1;
      cout<<sn<<" "<<tn<<endl;
    }
  	return 0;
}

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

int main(){

    int d;
    cin >> d;

    if (d==22) {
        cout << "Christmas Eve Eve Eve" << endl;
    } else if (d==23) { 
        cout << "Christmas Eve Eve" << endl;
    } else if (d==24) { 
        cout << "Christmas Eve" << endl;
    } else { 
        cout << "Christmas" << endl;
    } 
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

int main()
{
  ll n,d;
  cin >> n >> d;
  ll ans = 0;

  repl(i, n)
  {
    ll p,q;
    cin >> p >> q;
    if(p*p + q*q <= d*d) ans++;
  }

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

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

typedef long long LL;
int A, B, C, D;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	int T; std::cin >> T;
	auto ceil = [] (int a, int b) { return (a + b - 1) / b; };
	while (T --> 0) {
		std::cin >> A >> B >> C >> D;
		const int K = ceil(std::max(A, B), (std::min(A, B) + 1));
		int l = 1, r = std::max(A, B), cnt = 0;
		while (l <= r) {
			int mid = l + r >> 1;
			bool can = true;
			LL preA = (LL) mid * K, preB = mid;
			if (preA > A || preB > B) can = false;
			int sucA = ceil(A - preA, K), sucB = ceil(B - preB, K);
			if (A - preA < sucB || B - preB < sucA - 1) can = false;
			if (can) cnt = mid, l = mid + 1; else r = mid - 1;
		}
		int pre = cnt * (K + 1);
		int succ = ceil(B - cnt, K) - 1;
		int restA = A - (cnt * K + succ), restB = B - (cnt + succ * K);
		// std::cout << "DBG : " << cnt << ' ' << K << ' ' << succ << std::endl;
		// std::cout << "REST " << restA << ' ' << restB << std::endl;
		// C = 1, D = A + B;
		for (int i = C; i <= D; ++i) {
			char ch;
			if (i <= pre) {
				if ((i - 1) % (K + 1) == K) ch = 'B'; else ch = 'A';
			} else if (i > pre + restA + restB) {
				int t = i - pre - restA - restB - 1;
				if (t % (K + 1) == 0) ch = 'A'; else ch = 'B';
			} else if (i <= pre + restA) ch = 'A';
			else ch = 'B';
			std::cout << ch;
		}
		std::cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

template <class T> T addMod(T a, T b, T mod) { T ret = a + b; return ret < mod ? ret : ret - mod; }

template <class T> T subMod(T a, T b, T mod) { T ret = a - b; return 0 <= ret ? ret : ret + mod; }

template <class T> T mulMod(T a, T b, T mod) { return a * b % mod; }

template <class T, class U> T powMod(T base, U pow, T mod) {
  T x = 1;
  for (; pow > 0; pow >>= 1, base = mulMod(base, base, mod)) if (pow & 1) x = mulMod(x, base, mod);
  return x;
}

const ll MOD = 1e9 + 7;

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N;
  cin >> N;
  ll ans = mulMod(2LL, powMod(9LL, N, MOD), MOD);
  ans = subMod(ans, powMod(8LL, N, MOD), MOD);
  cout << subMod(powMod(10LL, N, MOD), ans, MOD) << nl;
  return 0;
}


Measured memory_bytes: 3644