akhauriyash/Code-Regression huggingface dataset:
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    char a;
    char b;
    char c;
    cin >> a >> b >> c;
    cout << a + b + c - 3 * '0'<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	vector<int> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	int cnt[1005];
	memset(cnt, 0, sizeof(cnt));

	rep(i, m) {
		rep(j, n) {
			if(a[j] <= b[i]) {
				cnt[j]++;
				break;
			}
		}
	}

	int res = 0, id = 0;
	rep(i, n) {
		if(cnt[i] > res) {
			res = cnt[i];
			id = i;
		}
	}

	cout << id + 1 << endl;

	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, N) for(int i = 0; i < N; ++i)

typedef long long ll;
using namespace std;

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

    vector<int> boss(n, 0);
    rep(i, n-1)
    {
        int x;
        cin >> x;
        boss[x-1]++;
    }

    rep(i, n)
    {
        cout << boss[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3996
cnt = Array.new(26,0)
while str = gets
    str.each_char { |c|
        if (c>='a' && c<='z') || (c>='A' && c<='Z')
            cnt[c.downcase.ord-'a'.ord]+=1
        end
    }
end

26.times { |i|
    print( (i+'a'.ord).chr, " : ",cnt[i],"\n")
}

Measured memory_bytes: 8724
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long

int n;


int main() {
	int n, p[60], num = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	for (int i = 1; i <= n; i++) {
		if (p[i - 1] != i)num++;
	}
	if (num == 2 || num == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("story.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	//File();
	string s;
	cin >> s;
	int lo = 0, hi = sz(s) - 1;
	while (lo<=hi)
	{
		if (s[lo] != s[hi])
			return cout << "No" << endl, 0;
		lo++, hi--;
	}
	lo = 0, hi = (sz(s) - 1) / 2 - 1;
	while (lo <= hi)
	{
		if (s[lo] != s[hi])
			return cout << "No" << endl, 0;
		lo++, hi--;
	}
	lo = (sz(s) + 3) / 2 - 1, hi = sz(s) - 1;
	while (lo <= hi)
	{
		if (s[lo] != s[hi])
			return cout << "No" << endl, 0;
		lo++, hi--;
	}
	cout << "Yes\n";
	return 0;
}


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

int main(){
  string A,B,C;
  cin>>A>>B>>C;
  char c=A[0];
  A.erase(0,1);
  while(1){
    if(c=='a'){
      if(A.size()==0){
        cout<<'A'<<endl;
        return 0;
      }
      c=A[0]; A.erase(0,1);
    }else if(c=='b'){
      if(B.size()==0){
        cout<<'B'<<endl;
        return 0;
      }
      c=B[0]; B.erase(0,1);
    }else{
      if(C.size()==0){
        cout<<'C'<<endl;
        return 0;
      }
      c=C[0]; C.erase(0,1); 
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
#define N 2000001
#define k 10000
 
int main(){
 
    int n,i,j;
    int *A,*B,C[N];
 
    scanf("%d",&n);
 
    A = malloc(sizeof(int) *n+1);
    B = malloc(sizeof(int) *n+1);
 
    for(i=0 ; i<k ; i++) C[i]=0;
 
    for(i=0 ; i<n ; i++){
      scanf("%d",&A[i]);
      C[A[i]]++;
    }
 
    for (i=1; i <=k ; i++) {
      C[i]+=C[i-1];
    }
 
    for(j=n-1 ; j>=0 ; j--){
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
 
    for(i=1 ; i<=n ; i++){
      printf("%d",B[i]);
      if(i<n) printf(" ");
    }
 
    printf("\n");
 
    return 0;
 
}


Measured memory_bytes: 17476
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
const int N=2e5;
int n, p[N], ass[N];
V<int> ch[N];
bitset<N> vis;

int se(V<int> a) {
    sort(ALL(a));
    int cur = 0;
    F(i,S(a)) {
        if (a[i] > cur)
            break;
        cur = a[i]+1;
    }
    return cur;
}

// false if cycle
bool assign(int u, int root) {
    if (vis[u]) return true;
    vis[u] = true;
    V<int> chv;
    for (int v : ch[u]) {
        if (v == root)
            return false;
        else if (!assign(v, root))
            return false;
        else {
            chv.pb(ass[v]);
        }
    }
    ass[u] = se(chv);
    return true;
}

bool test(V<int> cy, int x) {
    //P(x);
    int val[S(cy)+1];
    val[0] = x;
    F(i,S(cy)+1) if (i) {
        int pre = cy[i-1], cur = cy[i%S(cy)];
        V<int> chv;
        for (int v : ch[cur]) if (v != pre)
            chv.pb(ass[v]);
        chv.pb(val[i-1]);
        val[i] = se(chv);
    }
    //F(i,S(cy)+1) cout<<val[i]<<" \n"[i==S(cy)];
    return (val[S(cy)] == x);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    F(i,n) {
        cin>>p[i];
        p[i]--;
        ass[i] = -1;
        ch[p[i]].pb(i);
    }
    F(i,n) assign(i, i);
    //F(i,n) cout<<ass[i]<<" \n"[i==n-1];
    int start=-1;
    F(i,n) if (ass[i]==-1) {
        start = i;
        break;
    }
    V<int> cy;
    cy.pb(start);
    int cur=p[start];
    while (cur != start) {
        cy.pb(cur);
        cur = p[cur];
    }
    //for (int u : cy) P(u);
    //P("");
    V<int> chstart;
    for (int v : ch[start]) if (ass[v] != -1)
        chstart.pb(ass[v]);
    int sse = se(chstart);
    chstart.pb(sse);
    int sse2 = se(chstart);
    if (!(test(cy, sse) || test(cy, sse2)))
        cout<<"IM";
    P("POSSIBLE");
}

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

const int N = 2e5 + 10;
struct E {int v, nt;} e[N<<1];
struct data {int u, v;} a[N<<1];
int n, ans, tot, h[N], q[N], fa[N], dep[N];
int num, dfn[N], dis[N], low[N], win[N], vis[N];

inline int max(int a, int b) {return a > b ? a : b;}
inline int min(int a, int b) {return a < b ? a : b;}
inline void swap(int &a, int &b) {int t = a; a = b, b = t;}
inline void add(int u, int v) {
	e[++tot] = (E){v, h[u]}, h[u] = tot;
	e[++tot] = (E){u, h[v]}, h[v] = tot;
}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline int calc(int a, int b) {
	if (dfn[a] > dfn[b]) swap(a, b);
	if (dfn[a] < dfn[b] && low[a] >= dfn[b]) return dep[b] - dep[a] > 2;
	if (fa[a] == fa[b]) return 0; return 1;
}

inline void dfs(int x, int f) {
	fa[x] = f, dfn[x] = ++num;
	for (int v, i = h[x]; i; i = e[i].nt)
		if ((v = e[i].v) != f) dep[v] = dep[x] + 1, dfs(v, x);
	low[x] = num;
}

inline void bfs(int s) {
	int u, v, l = 0, r = 0;
	for (q[++r] = s, vis[s] = 1; l < r;)
		for (int i = h[u = q[++l]]; i; i = e[i].nt)
			if (!vis[v = e[i].v]) {
				dis[v] = dis[u] + 1;
				if (dis[v] < dep[v]) vis[v] = 1, q[++r] = v;
			}
}

int main() {
	int u, v, sx, sy; in(n), in(sx), in(sy);
	for (int i = 1; i < n; ++i) in(a[i].u), in(a[i].v);
	for (int i = 1; i < n; ++i) in(u), in(v), add(u, v);
	dfs(sy, 0), tot = 0, fill(h, h + N, 0);
	for (int i = 1; i < n; ++i) {
		if (calc(a[i].u, a[i].v)) win[a[i].u] = win[a[i].v] = 1;
		else add(a[i].u, a[i].v);
	}
	bfs(sx);
	for (int i = 1; i <= n; ++i) if (vis[i] && win[i]) {puts("-1"); return 0;}
	for (int i = 1; i <= n; ++i) if (vis[i]) ans = max(ans, dep[i] << 1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 17792
import sys

w,h,n = (int(_) for _ in input().split())
xa = ya = 0
xb = w
yb = h

for i in range(n):
    x,y,a=(int(_) for _ in input().split())
    if(a == 1):
        if(x > xa):
            xa = x
    elif (a == 2):
        if (x < xb):
            xb = x
    elif (a == 3):
        if (y > ya):
            ya = y
    elif (a == 4):
        if (y < yb):
            yb = y
    else:
        sys,exit(1)


xx = xb-xa
yy = yb-ya
ans = (xb-xa)*(yb-ya)
print('0') if (ans < 0) or (xx < 0) or(yy < 0) else print(ans)

Measured memory_bytes: 3064
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll x;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n=100;
	cin>>x;
	ll cnt=0;
	while(n<x)
	{
	    n+=(n/100);
	    ++cnt;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3680
n, k = map(int, input().split())
L= list(map(int, input().split()))
S=[]
S.append(1)
Q=set()
Q.add(1)
p=0
cnt=0
for i in range(n):
	if L[p] in Q:
		cnt+=1
		S.append(L[p])
		break
	else:
		cnt+=1
		S.append(L[p])
		Q.add(L[p])
		p=L[p]-1

cnt2=0
for i in range(n):
	if S[i]!=L[p]:
		cnt2+=1
	else:
		S2=S[i:]
		break
loop=len(S)-cnt2-1


if cnt>=k:
	print(S[k])
else:
	print(S2[(k-cnt)%loop])


Measured memory_bytes: 32656
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		if(b <= a) {
			System.out.println("delicious");
		} else if(a+x >= b) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
		
	}
	
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int cnt = 0;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    if(a.at(i)%4==0){
      cnt += 2;
    }else{
      if(a.at(i)%2==0){
        cnt++;
      }
    }
  }
  if(N%2==0){
    if(cnt>=N){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(cnt>=N-1){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  int num[100010]={};
  int cnt=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a>100000){
      cnt++;
    }else{
      num[a]++;
    }
  }
  for(int i=1;i<=100000;i++){
    if(num[i]!=i){
      if(num[i]>i)
	cnt+=num[i]-i;
      else if(num[i]<i)
	cnt+=num[i];
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, c=0; string S; cin >> N >> S;
for(i=0; i<N-2; i++){ if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){c++;} }
cout << c << "\n";
}

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

long long sum(long long i) {
  return ((i * (i + 1)) / 2);
}

int main(){
  int n;
  cin >> n;
  long long ans = 0;
  for(int i = 1; i <= n; i++) {
    ans += i * sum(n / i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        
        s = s.replaceAll("eraser","_");
        s = s.replaceAll("erase","_");
        s = s.replaceAll("dreamer","_");
        s = s.replaceAll("dream","_");
        s = s.replaceAll("_","");
        
        if(s.length() == 0){
            System.out.println("YES");
        }else{
            
            System.out.println("NO");
        }
            
    }
}


Measured memory_bytes: 28884
use List::Util qw/first/;
$hash{<>}++ for (0..<>-1);
$hash{<>}-- for (0..<>-1);

$count = first { $_ } map { $hash{$_} } sort { $hash{$b} <=> $hash{$a} } keys %hash;
print $count > 0 ? $count : 0;


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;



namespace free
{
    class Node
    {
        public int value;
        public Node next, prev;
        public Node(int _value, Node _next, Node _prev)
        {
            value = _value;
            next = _next;
            prev = _prev;
        }
    }

    class DL
    {
        public Node last, head;
        public int cnt; 
        public DL()
        {
            last = new Node(-1, null, null);
            head = new Node(-2, null, null);
            last.next = head;
            head.prev = last;
            cnt = 0;
        }
        public void Insert(int value)
        {
            Node newNode = new Node(value, head, head.prev);
            head.prev.next = newNode;
            head.prev = newNode;
            cnt++;
        }
        public void DeleteLast()
        {
            if (cnt == 0) return;
            Node target = last.next;
            last.next = target.next;
            target.next.prev = last;
            cnt--;
        }
        public void DeleteFirst()
        {
            if (cnt == 0) return;
            Node target = head.prev;
            head.prev = target.prev;
            target.prev.next = head;
            cnt--;
        }
        public void Delete(int value)
        {
            Node p = head.prev;
            while (p.value != -1)
            {
                if (p.value != value)
                {
                    p = p.prev;
                    continue;
                }
                p.prev.next = p.next;
                p.next.prev = p.prev;
                cnt--;
                break;
            }
        }
        public void Show()
        {
            Node p = head.prev;
            bool addSpace = false;
            while(p.value != -1)
            {
                if (!addSpace) addSpace = true;
                else Console.Write(" ");
                
                Console.Write("{0}",p.value);
                p = p.prev;
            }
            Console.WriteLine();
        }
    }

    class Program4
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var dl = new DL();
            
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Split(' ');
                if (line[0] == "insert")
                {
                    dl.Insert(int.Parse(line[1]));
                }
                else if (line[0] == "deleteFirst")
                {
                    dl.DeleteFirst();
                }
                else if (line[0] == "deleteLast")
                {
                    dl.DeleteLast();
                }
                else
                {
                    dl.Delete(int.Parse(line[1]));
                }
            }

            dl.Show();
        }
    }
}



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

int main() {
  string s;
  cin >> s;
  string ans = "";

  rep(i, s.size()) {
    if (s[i] == '?') {
      ans.push_back('D');
    } else {
      ans.push_back(s[i]);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3820
s = input()
count = 0

if s[0] != "A" or s[1].isupper() or s[-1].isupper():
    print("WA")
    exit()

for i in range(2, len(s) - 1):
    if s[i] == "C":
        count += 1

    elif s[i].isupper():
        print("WA")
        exit()

if count != 1:
    print("WA")

elif count == 1:
    print("AC")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n,m;
    cin >> n >> m;
    std::vector<pii> query;
    std::vector<int> a(n);
    std::vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < m; i++){
        int b,c;
        cin >> b >> c;
        query.pb(pii(b,c));
    }
    std::sort(a.begin(),a.end());
    std::sort(query.begin(),query.end(),[](const pii &a,const pii &b){return a.second > b.second;});

    int st = 0;
    int num = 0;
    int index = 0;
    for(int i = 0; i < n; i++){
        if(st == 0){
            if(index == m){
                num = -1;
                st = MOD;
                i--;
                continue;
            }
            st = query[index].first;
            num = query[index].second;
            index++;
            i--;
            continue;
        } else {
            st--;
            b[i] = num;
        } 
    }
    int out = 0;
    for(int i = 0; i < n; i++){
        out += max(a[i],b[i]);
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, x, y, a[200005], b[200005];
int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b, b+n);
	x = b[n/2-1];
	y = b[n/2];
	for(i=0; i<n; i++) printf("%d\n", a[i]<=x ? y:x);
	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll H;

int main()
{
  scanf( "%lld", &H );

  ll cnt = 1, ans = 0;

  while( H > 0 )
  {
    ans += cnt;

    cnt <<= 1;
    H >>= 1;
  }

  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
using std::min;
using std::max;
typedef long long ll;
const int INF=1e+9;
const ll INFLL=1e+17;
int N;
ll A[200010];
ll sum[200010];
void addsum(){
  sum[0]=0;
  rep1(i,N){
    sum[i]=sum[i-1]+A[i-1];
  }
}
ll B(int l){
  return sum[l+1];
}
ll C(int l,int i){
  return sum[i+1]-sum[l+1];
}
ll D(int r,int i){
  return sum[r+1]-sum[i+1];
}
ll E(int r){
  return sum[N]-sum[r+1];
}
ll delL(int l,int i){
  return std::abs(B(l)-C(l,i));
}
int searchL(int s,int i){
  while(delL(s-1,i)-delL(s,i)>=0) s++;
  return s-1;
}
ll delR(int r,int i){
  return std::abs(D(r,i)-E(r));
}
int searchR(int s,int i){
  while(delR(s-1,i)-delR(s,i)>=0) s++;
  return s-1;
}
ll solve(){
  ll res=INFLL;
  addsum();
  int sl=0,sr=2;
  for(int i=1;i<=N-1;i++){
    sl=searchL(sl,i);
    sr=searchR(sr,i);
    ll b=B(sl),c=C(sl,i),d=D(sr,i),e=E(sr);
    ll mi=min(min(b,c),min(d,e)),ma=max(max(b,c),max(d,e));
    res=min(res,ma-mi);
  }
  return res;
}
int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  prin(solve());
  return 0;
}


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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> c(h);
  for(int i = 0;i<h;i++){
    cin>>c[i];
  }
  for(int i = 0;i<h*2;i++){
    cout<<c[i/2]<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 5000005;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

#define lsb(x) (x&(-x))

int n;

struct BIT
{
	int aib[NMAX] = {0};

	void update(int pos, int val)
	{
		for(int i = pos; i<= n; i+=lsb(i))
		{
			aib[i]+=val;
		}
	}

	int query(int pos)
	{
		int res =0;
		for(int i = pos; i>=1; i-=lsb(i))
		{
			res+=aib[i];
		}
		return res;
	}
};

BIT litere[26];

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

	cin >> n;
	string s;
	cin >> s;
	for(int i =0; i< n; ++i)
	{
		int c_int = s[i] - 'a';

		litere[c_int].update(i+1,1);
	}

	int q;
	cin >> q;
	while(q--)
	{
		int type;
		cin >> type;
		if(type == 1)
		{
			int pos;
			char to_change;
			cin >> pos >> to_change;

			if(s[pos-1] == to_change)
				continue;
			else
			{
				litere[s[pos-1] - 'a'].update(pos,-1);
				s[pos-1] = to_change;
				litere[s[pos-1] - 'a'].update(pos, 1);
			}
		}
		else
		{
			int l,r;
			cin >> l >> r;

			int ct = 0;

			for(int i =0; i< 26; ++i)
			{
				if(litere[i].query(r) - litere[i].query(l-1) > 0)
				{
					ct++;
				}
			}
			cout << ct << '\n';	
		}
	}


    return 0;
}

Measured memory_bytes: 105244
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

const int MAX_N=400,MAX_M=1e5;

int N,M,x[MAX_M],y[MAX_M];

bool flg[MAX_N];
bool flg2[MAX_N][MAX_N];

int main(){
	cin>>N>>M;
	REP(i,M){
		cin>>x[i]>>y[i];
		x[i]--;
		y[i]--;
	}
	REP(i,N){
		flg2[i][i]=true;
		REP(j,M){
			bool &f1=flg2[i][x[M-1-j]],&f2=flg2[i][y[M-1-j]];
			if (f1){
				if (f2){
					flg[i]=true;
					break;
				}else{
					f2=true;
				}
			}else{
				if (f2){
					f1=true;
				}
			}
		}
	}
	int ans=0;
	REP(i,N){
		if (flg[i]){
			continue;
		}
		FOR(j,i+1,N){
			if (flg[j]){
				continue;
			}
			bool f=false;
			REP(k,N){
				if (flg2[i][k] && flg2[j][k]){
					f=true;
					break;
				}
			}
			if (!f){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
import java.util.ArrayDeque;

public class Main {
  private static void solve() {
    int n = ni();
    int[] p = na(n);
    
    ArrayDeque<Integer> q = new ArrayDeque<>();
    StringBuilder sb = new StringBuilder();
    int now = 1;
    for (int v : p) {
      for (; now <= v; now ++) {
        sb.append("(");
        q.addLast(now);
      }
      sb.append(")");
      if (q.pollLast() != v) {
        System.out.println(":(");
        return;
      }
    }
    System.out.println(sb);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<int> ans;
    for(int d=0; d<=9; d++){
        int h = 0;
        for(int i=1; i<=11; i++){
            int digit = (s[i]=='?')? d: s[i]-'0';
            if(i <= 6){
                h += digit *(i+1);
            }else{
                h += digit *(i-5);
            }
        }
        int cd = 11 - h%11;
        if(cd > 9) cd = 0;
        int digit = (s[0]=='?')? d: s[0]-'0';
        if(digit == cd){
            ans.push_back(d);
        }
    }
    if((int)ans.size() > 1){
        cout << "MULTIPLE" << endl;
    }else{
        cout << ans[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

bool dp[6000][1<<13];

ll const B = 1000000007;
ull p[6000], thash[6000];
ull shash[13];

int n,m;
int len;
char t[6000];
char ss[13][6000];
int sslen[13];

int solve(){
    rep(i,n){
        ull x = 0;
        for(int j=0;ss[i][j];j++){
            x = x*B + ss[i][j];
        }
        shash[i] = x;
    }
    p[0] = 1;
    thash[0] = 0;
    rep(i,len){
        p[i+1] = p[i]*B;
        thash[i+1] = thash[i]*B + t[i];
    }

    rep(i,len+1)rep(j,1<<n) dp[i][j] = false;
    rep(i,len+1) dp[i][0] = true;
    rep(pos,len){
        rep(mask,1<<n){
            if(!dp[pos][mask]) continue;
            rep(i,n){
                if(mask>>i&1) continue;
                if(pos+sslen[i] > len) continue;
                ull h1 = shash[i];
                ull h2 = thash[pos+sslen[i]] - thash[pos] * p[sslen[i]];
                // if(h1 != h2) continue;
                dp[pos+sslen[i]][mask|1<<i] |= h1 == h2; // t.substr(pos,ss[i].size()) == ss[i];
            }
        }
    }

    int ans = 0;
    rep(i,len+1){
        if(dp[i][(1<<n)-1]){
            ++ans;
        }
    }
    return ans;
}

signed main(){
    while(scanf("%d%d",&n,&m), n){
        len = 0;
        rep(i,n){
            scanf("%s",ss[i]);
            sslen[i] = strlen(ss[i]);
        }
        rep(i,m){
            static char buf[6000];
            scanf("%s",buf);
            int l = strlen(buf);
            rep(i,l) t[i+len] = buf[i];
            len += l;
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 42128
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
        //int input=int.Parse(Console.ReadLine());
        //string a = Console.ReadLine();
        Console.WriteLine(input[1]-input[0]==input[2]-input[1]?"YES":"NO");
        Console.ReadLine();
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

typedef struct _tagFood {
  int s;
  int p;
  int q;
  int r;
  int sum;
} Food;

int main() {
  int n, s, p, q, r, P, Q, R, C;
  Food f[1000];
  for(;;) {
    cin >> n;
    if(n == 0) break;
    for(int i=0; i<n; ++i) {
      int sum = 0;
      cin >> s >> p >> q >> r;
      sum += p * 4 + q * 9 + r * 4;
      f[i].s = s; f[i].p = p; f[i].q = q; f[i].r = r; f[i].sum = sum;
    }
    cin >> P >> Q >> R >> C;
    bool flag = false;
    for(int i=0; i<n; ++i) {
      if(f[i].p <= P && f[i].q <= Q && f[i].r <= R && f[i].sum <= C) {
        flag = true;
        cout << f[i].s << endl;
      }
    }
    if(!flag) cout << "NA" << endl;
  }
}




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

int main(){
	int area[14][14];
	int x, y;
	char a, b;
	int size;
	for(int i = 0; i < 14; i++){
		for(int j = 0; j < 14; j++){
			area[i][j] = 0;
		}
	}
	while(cin >> x >> a >> y >> b >> size){
		x += 2;
		y += 2;
		area[x][y]++;
		area[x+1][y]++;
		area[x-1][y]++;
		area[x][y+1]++;
		area[x][y-1]++;
		if(size >= 2){
			area[x+1][y+1]++;
			area[x+1][y-1]++;
			area[x-1][y-1]++;
			area[x-1][y+1]++;
			if(size == 3){
				area[x+2][y]++;
				area[x-2][y]++;
				area[x][y+2]++;
				area[x][y-2]++;
			}
		}
	}
	int count = 0;
	int kmax = 0;
	for(int i = 2; i < 12; i++){
		for(int j = 2; j < 12; j++){
			if(area[i][j] == 0) count++;
			kmax = max(kmax, area[i][j]);
		}
	}
	cout << count << endl;
	cout << kmax << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool srt( pair < int , int > a, pair < int , int > b){
    return a.first != b.first ? a.first>b.first : a.second<b.second;
}
const ll oo=1e18;
int dx[8]={1,-1,0,0,1,-1,-1,1};
int dy[8]={0,0,1,-1,1,-1,1,-1};

int main(){
    int n;
    set<char>s;
    cin>>n;
    for(int i=0;i<n;i++){
        char a;
        cin>>a;
        s.insert(a);
    }
    if(s.size()==3)puts("Three");
    else puts("Four");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <random>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[30];
ll c[30],s[400][30],ans[55555];

int main(void){
	int d,i,j,n=26,k,m=50000;
	ll ansm = -INFLL;
	std::vector<int> v[m];
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			v[k].push_back(j);
		}
		std::random_device seed_gen;
		std::mt19937 engine(seed_gen());
		std::shuffle(v[k].begin(), v[k].end(), engine);
	}
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
	}
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			l[j] = -1;
		}
		for(i=0; i<d; ++i){
			ans[k] += s[i][v[k][i%26]];
			l[v[k][i%26]] = i;
			for(j=0; j<n; ++j){
				ans[k] -= c[j]*(i-l[j]);
			}
		}
		ansm = std::max(ansm,ans[k]);
		// std::cout << ans[k] << std::endl;
	}
	for(k=0; k<m; ++k){
		if(ans[k] == ansm){
			for(i=0; i<d; ++i){
				std::cout << v[k][i%26]+1 << std::endl;
			}
			break;
		}
	}
	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long double ld;

const int MAX = 501,IINF = INT_MAX;
const ld LDINF = 1e100;
int H,W,sx,sy,gx,gy;
ld mincost[MAX][MAX][2]; // mincost[][][0] => from start, [1] = > from star
char c[MAX][MAX];
bool ban[MAX][MAX];
vector<int> star,plane;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

inline bool isValid(int x,int y) { return 0 <= x && x < W && 0 <= y && y < H; }

inline void bfs(vector<int> sp,vector<int> Forbidden,int type){
  rep(i,H)rep(j,W) mincost[i][j][type] = LDINF, ban[i][j] = false;
  queue<int> que;
  rep(i,(int)sp.size()) que.push(sp[i]), mincost[sp[i]/W][sp[i]%W][type] = 0;
  rep(i,(int)Forbidden.size()) ban[Forbidden[i]/W][Forbidden[i]%W] = true;

  while(!que.empty()){
    int cur = que.front(); que.pop();
    rep(i,4){
      int nx = cur % W + dx[i], ny = cur / W + dy[i];
      if( c[ny][nx] == '#' ) continue;
      if( ban[ny][nx] ) continue;
      if( mincost[ny][nx][type] == LDINF ) {
        mincost[ny][nx][type] = mincost[cur/W][cur%W][type] + 1;
        que.push(nx+ny*W);
      }
    }
  }
}

bool check(ld E){
  ld T = 0;

  rep(i,(int)plane.size()){
    int x = plane[i] % W, y = plane[i] / W;
    T += min(mincost[y][x][0],mincost[y][x][1]+E);
  }

  ld len = plane.size();
  return len * E > T;
}

int main(){
  cin >> W >> H;
  rep(i,H)rep(j,W){
    cin >> c[i][j];
    if( c[i][j] == 's' ) sx = j, sy = i, c[i][j] = '.';
    if( c[i][j] == 'g' ) gx = j, gy = i;
    if( c[i][j] == '*' ) star.push_back(j+i*W);
    if( c[i][j] == '.' ) plane.push_back(j+i*W);
  }

  vector<int> sp,forbidden;
  sp.push_back(gx+gy*W);
  forbidden = star;
  forbidden.push_back(gx+gy*W);
  bfs(sp,forbidden,0);

  sp = star;
  forbidden.push_back(gx+gy*W);
  //forbidden.clear();
  bfs(sp,forbidden,1);

  ld L = 0, R = 1e10, M = 0;
  rep(i,80){
    M = ( L + R ) * (ld)0.5;
    if( check(M) ) R = M;
    else           L = M;
  }

  cout << setiosflags(ios::fixed) << setprecision(20) << min((ld)mincost[sy][sx][0],(ld)mincost[sy][sx][1]+L) << endl;

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i);
    }
    sort(l.begin(), l.end());

    int ans = 0;
    for (int a = 0; a < n; a++) {
        for (int b = a + 1; b < n; b++) {
            int ab = l.at(a) + l.at(b);
            int left = b + 1;
            int right = lower_bound(l.begin(), l.end(), ab) - l.begin();
            ans += right - left;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	vector<string> v(2);
	cin >> v[0] >> v[1];

	ll ans = 3;
	if(N == 1) {
		cout << ans << "\n";
		return 0;
	}
	bool yoko = false;
	for(int i = 0; i < N; i++) {
		if(i == 0) {
			if(v[0][i] != v[1][i]) {
				ans *= 2;
				i++;
				yoko = true;
			}
			continue;
		}

		if(v[0][i] != v[1][i]) {
			if(yoko)
				ans *= 3;
			else
				ans *= 2;
			i++;
			yoko = true;
		} else {
			if(yoko) {
				yoko = false;
				continue;
			} else {
				ans *= 2;
			}
		}
		ans %= mod;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

for i in range(len(a)):
  if a[i] % 2 == 0:
    if a[i] % 3 == 0 or a[i] % 5 ==0:
      pass
    else:
      print("DENIED")
      break

  if i == len(a) -1:
    print("APPROVED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main(){
    ll n; cin >> n;
    ll t[n],a[n];
    for(ll i = 0; i < n; i++){
        cin >> t[i] >> a[i];
    }
    ll x = t[0], y = a[0];
    
    for(ll i = 1; i < n; i++){
        ll b,c;
        if(x%t[i] == 0) b = x/t[i];
        else b = x/t[i]+1;
        if(y%a[i] == 0) c = y/a[i];
        else c = y/a[i]+1;

        ll n = max(b, c);
        x = n*t[i];
        y = n*a[i];
    }
    cout << x+y << endl;
}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    map<i64, i64> mns, pls;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        mns[i - a]++, pls[i + a]++;
    }

    i64 ans = 0;
    for (auto& e : mns) {
        i64 k, v;
        tie(k, v) = e;
        ans += v * pls[k];
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 37780
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll h;
	cin>>h;
	ll ans=0,i=1;
	while(h!=0){
		ans+=i;
		i*=2;
		h/=2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [int(x) for x in input().split()]
flag = 0

for i in range(n):
    if i == 0 and h[i] != 1:
        h[i] -= 1
    elif i != 0:
        if h[i] < h[i-1]:
            print('No')
            flag = 1
            break
        elif h[i] > h[i-1]:
            h[i] -= 1

if flag == 0:
    print('Yes')


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

typedef long long ll;

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2 == 0)    c = a-b;
    else            c = b-a;

    if(abs(c)>10e18)    cout << "Unfair" << endl;
    else                cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
module UIntegerSort
  implicit none
 
  private
 
  public QuickSortInteger
 
contains
    
  !!
  ! ピボット値の取得
  !
  subroutine GetPivotIntegerValue(array, n, a, b, pivot_value)
    integer, intent(inout) :: array(:), pivot_value
    integer, intent(in) :: n, a, b
 
    pivot_value = array((a + b) / 2)
  end subroutine
 
  !!
  ! ピボット値に従って値を分離
  !
  subroutine GetPartitionInteger(array, n, a, b, pivot)
    integer, intent(inout) :: array(:)
    integer, intent(in)  :: n, a, b
    integer, intent(out) :: pivot
 
    integer :: buffer, pivot_value
    integer :: l, r
 
    if (a == b) then
      pivot = 0
      return
    end if
 
    call GetPivotIntegerValue(array, n, a, b, pivot_value)
 
    l = a
    r = b
 
    do while(.true.)
      do while(array(l) < pivot_value)
        if (l >= b) exit
        l = l + 1
      end do
 
      do while(pivot_value < array(r))
        if (r <= a) exit
        r = r - 1
      end do
 
      if(r <= l) exit
 
      buffer   = array(l)
      array(l) = array(r)
      array(r) = buffer
 
      l = l + 1
      r = r - 1
    end do
 
    pivot = r
  end subroutine
 
  !!
  ! 配列の一部分をソートする。
  !
  recursive subroutine QuickSortIntegerSubarray(array, n, a, b)
    integer, intent(inout) :: array(:)
    integer, intent(in)    :: n, a, b
 
    integer :: pivot
 
    call GetPartitionInteger(array, n, a, b, pivot)
    if (pivot /= 0) then
      call QuickSortIntegerSubarray(array, n, a, pivot)
      call QuickSortIntegerSubarray(array, n, pivot + 1, b)
    end if
  end subroutine
 
  !!
  ! 配列全体をソートする
  !
  subroutine QuickSortInteger(array, n)
    integer :: array(:)
    integer :: n
 
    call QuickSortIntegerSubarray(array, n, 1, n)
  end subroutine
 
end module
 
program TestIntegerSort
  use UIntegerSort
 
  implicit none
  integer,allocatable::a(:)
  integer :: N,i
  real(8)::ans
  read*,N
  allocate(a(N))
  read(*,*)(a(i),i=1,N)
  call QuickSortInteger(a, N)
  ans=a(1)
  do i=2,N
  ans=(ans+a(i))/2
  end do
print*,ans
end program

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	int q;  cin >> q;
	int t, u, v;
	dsu d(n);
	REP(i, q ){
		cin >> t >> u >> v;
		if(t==0){
			d.merge(u, v);
		}
		else{
			if(d.same(u, v)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
	//cout << ans << endl;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    int ans = 0;
    if(n%2 != 0) OUT(0);
    else{
        for(int d = 10; d <= n; d *= 5) ans += n/d;
        ANS;
    }

    return 0;
}

Measured memory_bytes: 256