akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[1000005];
bool bo;
long long ji;
int main(){
	scanf("%s",&s);
	long long len=strlen(s);
	for(long long i=0;i<len-1;i++){
		if(s[i]!=s[i+1])bo=1;
	}
	if(bo=1){
		if(s[0]!=s[len-1])
			ji=len-2;
		else ji=len-3;
	}
	else ji=0;
	if(ji%2==1)cout<<"First";
	else cout<<"Second";
}


Measured memory_bytes: 384
n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
ma=[a[n-1]]*n
for i in reversed(range(n-1)):
    ma[i]=max(ma[i+1],a[i])
tt=0;cnt=0;u=[]
for i in range(n-1):
    if ma[i+1]-a[i]>=tt:tt=ma[i+1]-a[i]
for i in range(n-1):
    if ma[i+1]-a[i]==tt:u+=[i]
w=max(u)
ans=0
for x in u:
    c=1
    while x+tt in u:c+=2
    ans+=c
print ans


Measured memory_bytes: 25712
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int L { get; set; }
    public int r { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var te = new List<P>();
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            te.Add(new P { L = a, r = b });
        }
        var ps = te.OrderBy(x => x.r).ToArray();
        var ans = new List<int>();
        ans.Add(ps[0].r - 1);
        for (int i = 1; i < m; i++)
        {
            if (check(ans, ps, i)) continue;
            else ans.Add(ps[i].r - 1);
        }
        Console.WriteLine(ans.Count());
    }
    public static bool check(List<int> ans, P[] ps, int i)
    {
        foreach (var x in ans)
            if (x >= ps[i].L && x <= ps[i].r) return true;
        return false;
    }
}


Measured memory_bytes: 27716
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    int t[n];
    int total = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t[i]);
        total += t[i];
    }
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        int p, x;
        scanf("%d %d", &p, &x);
        printf("%d\n", total - t[p - 1] + x);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#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 << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod= 1e9+7;
const int nax=4* 1e5 + 5;
ll c[nax];
ll dwa[nax];
int n;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	rep(i,0,n) cin >> c[i];
	sort(c, c+n);
	dwa[0] = 1;
	rep(i,1,nax) {
		dwa[i] = (dwa[i-1] * 2) % mod;
	}
	ll res = 0;
	rep(i,0,n) {
		res = ( res + (n - i + 1)*c[i]) % mod;
		// debug() << imie(res);
		// res = (res + pom * (pom2 + dwa[n-i-1])) % mod;
	}
	cout << (dwa[2*n - 2] * res) % mod << endl;
}

Measured memory_bytes: 6400
#include <stdio.h>
int main(void)
{
int a;
scanf("%d",&a);
if(a==0)
{printf("0\n");
}
if(a==1||a==10||a==100)
{printf("1\n");
}
if(a==110||a==101||a==11)
{printf("2\n");
}
if(a==111)
{printf("3\n");
}
}

Measured memory_bytes: 128
H, W = map(int, input().split())
a = [input() for _ in range(H)]
yck = [1] * H
xck = [1] * W

for y in range(H):
    for x in range(W):
        if a[y][x] == '#':
            yck[y] = 0
            xck[x] = 0
for y in range(H):
    if yck[y]: continue
    ans = ''
    for x in range(W):
        if xck[x]: continue
        ans += a[y][x]
    print(ans)


Measured memory_bytes: 3060
def prime2_factorize(N):
    cnt = 0
    while N % 2 == 0:
        cnt += 1
        N //= 2
    return cnt


def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    sumA = 0
    for a in A:
        sumA += prime2_factorize(a)
    print(sumA)


resolve()


Measured memory_bytes: 10044
#include<iostream>
using namespace std;
int main(){
  int bell,hess,pasta,juice;
  bell=10000;
  hess=10000;
  for(int i=0;i<3;i++){
    cin >> pasta;
    if(bell>pasta){
      bell=pasta;
    }
  }
  for(int i=0;i<2;i++){
    cin >> juice;
    if(hess>juice){
      hess=juice;
    }
  }
  cout << bell+hess-50 << endl;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
if (n == 1 and m == 0):
    print(0)
    exit()
if (m == 0):
    print('1' + '0' * (n - 1))
    exit()
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ok = False
if (n == 1):
    start = 0
else:
    start = 10 ** (n - 1)
for i in range(start, 10 ** n):
    for k, v in dic.items():
        if (str(i)[k - 1] == str(v)):
            ok = True
        else:
            ok = False
            break
    else:
        if (ok):
            print(i)
            exit()


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

int main() {
  int n, i;
  cin >> n;
  long long arr[3]={2, 1, 0};

  for (i=2; i<=n; i++) {
    arr[i%3]=arr[(i+1)%3]+arr[(i+2)%3];
  }
  i--;
  
  cout << arr[i%3] << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    long Mod = 100000007;

    long cases_five [100001];
    cases_five [0] = 1;
    cases_five [1] = 1;
    cases_five [2] = 2;
    cases_five [3] = 4;
    cases_five [4] = 8;
    cases_five [5] = 16;
    for(int i = 6; i <= 100000; i++) {
        cases_five[i] = (cases_five[i-5] + cases_five[i-4] + cases_five[i-3] + cases_five[i-2] + cases_five[i-1]) % Mod;
    }
    for(int i = 6; i <= 100000; i++) {
        cases_five[i] += cases_five[i-5];
        cases_five[i] %= Mod;
    }

    long cases_three [100001];
    cases_three [0] = 1;
    cases_three [1] = 1;
    cases_three [2] = 2;
    cases_three [3] = 4;
    for(int i = 4; i <= 100000; i++) {
        cases_three[i] = (cases_three[i-3] + cases_three[i-2] + cases_three[i-1]) % Mod;
    }
    for(int i = 4; i <= 100000; i++) {
        cases_three[i] += cases_three[i-3];
        cases_three[i] %= Mod;
    }

    string str;
    while( getline(cin, str)) {
        if (str == "#") break;

        istringstream is(str);
        int len = 1;
        long ans = 1;
        char ch, pch;
        is >> pch;
        while(is >> ch) {
            if (ch == pch) {
                len += 1;
            }
            else {
                if (pch == '8' || pch == '0') {
                    ans = (ans * cases_three[len]) % Mod;
                } else {
                    ans = (ans * cases_five[len]) % Mod;
                }
                len = 1;
                pch = ch;
            }
        }
        if (ch == '8' || ch == '0') {
            ans = (ans * cases_three[len]) % Mod;
        } else {
            ans = (ans * cases_five[len]) % Mod;
        }

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

Measured memory_bytes: 2948
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n;
char s[1000005];
vector<pair<int, int>> p, q;

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);

  int total = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    int m = strlen(s);

    int minn = 0, sum = 0;
    for (int j = 0; j < m; j++) {
      if (s[j] == ')') sum -= 1;
      else sum += 1;
      if (sum < minn) minn = sum;
    }
    if (sum > 0) p.push_back({minn, sum});
    else q.push_back({minn - sum, sum});
    total += sum;
  }
  if (total != 0) {
    puts("No");
    return 0;
  }

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

  bool flag = true;
  int cur = 0;
  for (auto t : p) {
    if (-t.first <= cur) {
      cur += t.second;
    } else {
      flag = false;
    }
  }

  sort(q.begin(), q.end());
  for (auto t : q) {
    if (-(t.first + t.second) <= cur) {
      cur += t.second;
    } else {
      flag = false;
    }
  }

  if (flag) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 11172
n = int(input())
l = list(input())

if "R" not in l or "W" not in l:
    print(0)
    exit()

cnt = 0

i = 0
k = n-1

while i < k:
    if l[i] == "W" and l[k] == "R":
        l[i], l[k] = l[k], l[i]
        cnt += 1
    if l[i] == "R":
        i += 1
    if l[k] == "W":
        k -= 1
print(cnt)

Measured memory_bytes: 10608
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void){
    int N;
    cin>>N;
    int a,sum;
    int min=1000000;
    for(int i=0;i<N;i++){
        sum=0;
        cin>>a;
        while((a%2)==0){
            a/=2;
            sum++;
        }
        if(sum<min){
            min=sum;
        }
    }

    cout<<min<<endl;

}


Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy
from fractions import gcd

def main():
    num = int(input())
    ans = 2 * num / gcd(2,num)
    print(int(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 5148
def bubble_sort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if c[j][1] < c[j-1][1]:
                c[j], c[j-1] = c[j-1], c[j]
    return c

def selection_sort(c, n):
    for i in range(n-1):
        minj = i
        for j in range(i+1, n):
            if c[j][1] < c[minj][1]:
                minj = j
        if i != j:
            c[i], c[minj] = c[minj], c[i]
    return c


def main():
    N = int(input())
    cards1 = input().split()
    cards2 = cards1.copy()

    bubble_sorted = bubble_sort(cards1, N)
    print(*bubble_sorted)
    print("Stable")
    
    select_sorted = selection_sort(cards2, N)
    print(*select_sorted)
    if bubble_sorted == select_sorted:
        print("Stable")
    else:
        print("Not stable")


if __name__ == "__main__":
    main()



Measured memory_bytes: 5616
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - YYMM or MMYY
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

inline bool month(int d) { return d >= 1 && d <= 12; }

/* main */

int main() {
  int s;
  scanf("%d", &s);

  int d0 = s / 100, d1 = s % 100;

  if (month(d0) && month(d1)) puts("AMBIGUOUS");
  else if (month(d0)) puts("MMYY");
  else if (month(d1)) puts("YYMM");
  else puts("NA");
  return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int L = Integer.parseInt(reader.readLine());
        double temp = L/3.0;
        double result = temp * temp * temp;
        System.out.printf("%.12f",result);
    }
}


Measured memory_bytes: 22740
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, INF = 1e9, larg = 1e5;
int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
int max_value = 0, max_index = 0;
int min_value = INF, min_index = 0;

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

int main() {
	cin >> H >> W;
	char m[100][100];
	rep(i, H){
		rep(j, W){
			cin >> m[i][j];
		}
	}

	rep(i, W){
		rep(j, H){
			if(m[j][i] == '#') break;
			if(j == H-1) {
				rep(k, H){
					m[k][i] = '!';
				}
			}
		}
	}

	rep(i, H){
		rep(j, W){
			if(m[i][j] == '#') break;
			if(j == W-1) {
				rep(k, W){
					m[i][k] = '*';
				}
			}
		}
	}

	rep(i, H){
		if(m[i][0]=='*') continue;
		rep(j, W){
			if(m[i][j]!='!'){
				cout << m[i][j];
			}
		}
		cout << endl;
	}
}

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

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

  int arr[] = {a, b, c, d, e};
  sort(arr, arr + 4);
  // for(int i =0; i < 5; i++) {
  //   cout << arr[i] << endl;
  // }

  cout << (arr[4] - arr[0] <= k ? "Yay!" : ":(") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
   char a,b,c;
   cin>>a>>b>>c;

   if(a==b&&b==c&&c==a){
    cout<<"No"<<endl;
   }
   else{
    cout<<"Yes"<<endl;
   }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=1e6+100;
const int N=2e5+10;
const int M=1e6+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll a[N];
int main()
{
#ifdef local
      freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;cout.tie(0);
    int n,k;cin>>n>>k;
    rep1(i,n) cin>>a[i];
    ll sum=1,cnt=0,tag=0;
    for(int i=1;i<=k;++i)
    {
        if(a[i]<0) cnt++;
        else tag++;
    }
    int l=1,r=n;
    if(!tag&&k%2==1)
    {
        sort(a+1,a+1+n,greater<int>());
        for(int i=1;i<=k;++i) sum=sum*a[i]%mod;
    }
    else
    {
       sort(a+1,a+1+n,greater<int>());

       if(k&1) sum=sum*a[l]%mod,l++,k--;
       while(k>=2)
       {
           if(a[l]*a[l+1]>=a[r]*a[r-1])
           {
               sum=sum*a[l]%mod*a[l+1]%mod;
               l+=2;
           }
           else  sum=sum*a[r-1]%mod*a[r]%mod,r-=2;
           k-=2;
       }
    }
    sum=(sum+mod)%mod;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long a,b,c,d;
    cin >>a>>b>>c>>d;
    long long ans1=max(a*c,a*d);
    long long ans2=max(b*c,b*d);
    cout << max(ans1,ans2);
}


Measured memory_bytes: 3632
def count_up(x,n):
  x[n]+=1
  if x[n]>m:
    count_up(x,n-1)
    x[n]=x[n-1]
  return
n,m,q=map(int,input().split())
abcd=[map(int,input().split()) for _ in range(q)]
a,b,c,d=[list(i) for i in zip(*abcd)]
x=[1,1,1,1,1,1,1,1,1,1,1]
ans=0
if m==1:
  temp=0
  for i in range(q):
    if x[b[i]]-x[a[i]]==c[i]:
      temp+=d[i]
  ans=max(ans,temp)
else:
  while x[1]==1:
    temp=0
    for i in range(q):
      if x[b[i]]-x[a[i]]==c[i]:
       temp+=d[i]
    ans=max(ans,temp)
    count_up(x,n)
print(ans)


Measured memory_bytes: 9264
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    int mi = 0, ma = n - 1;
    REP(i,m){
        int x = in() - 1, y = in() - 1;
        chmax(mi, x);
        chmin(ma, y);
    }
    int ans = max(0, ma - mi + 1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;

	long ans;
	foreach (i; 1..N+1)
	{
		if (i % 2 == 0) continue;
		long cnt;
		foreach (j; 1..i+1)
		{
			if (i % j == 0)
				++cnt;
		}
		if (cnt == 8)
			++ans;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
#include  <stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(r<=x && x<=W-r && y>=r && y<=H-r){
        printf("Yes\n");
    }else {
        printf("No\n");
    }
    return 0;
}
    

Measured memory_bytes: 1012
H = int(input())

keys = [None] + input().split()

for i in range(1, H + 1):
    print('node {0}: '.format(i), end = '')
    print('key = {0}, '.format(keys[i]), end = '')
    if i != 1:
        print('parent key = {0}, '.format(keys[i // 2]), end = '')
    left_index = i * 2
    if left_index <= H:
        print('left key = {0}, '.format(keys[left_index]), end = '')
    right_index = left_index + 1
    if right_index <= H:
        print('right key = {0}, '.format(keys[right_index]), end = '')
    print('')

Measured memory_bytes: 7708
SENTINEL = 1e+9
t = 0


def Merge(A, left, mid, right):
    global t
    n1 = mid - left
    n2 = right - mid
    L, R = A[left:left+n1], A[mid:mid+n2]
    L.append(SENTINEL)
    R.append(SENTINEL)
    i, j = 0, 0
    for k in range(left, right):
        t += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def Merge_Sort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        Merge_Sort(A, left, mid)
        Merge_Sort(A, mid, right)
        Merge(A, left, mid, right)


def main():
    global t
    input()
    A = [int(i) for i in input().split()]
    Merge_Sort(A, 0, len(A))
    print(*A)
    print(t)


if __name__ == '__main__':
    main()



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

int main() {
  int X, N;
  cin >> X >> N;
  vector<bool> ans(210, true);

  rep(i, N) {
    int p;
    cin >> p;
    if (p - X >= 0) {
      int a = (p - X) * 2;
      ans.at(a) = false;
    } else {
      int b = (X - p) * 2 - 1;
      ans.at(b) = false;
    }
  }

  rep(i, 210) {
    if (ans.at(i)) {
      if (i % 2 == 0) {
        cout << X + i / 2 << endl;
      } else {
        cout << X - (i + 1) / 2 << endl;
      }
      break;
    }
  }
  return 0;
}

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

//abc163E
void swap(long long *a, long long *b) {
  long long temp=*a;
  *a=*b, *b=temp;
}

void QuickSort(long long A[], long long B[], long long left, long long right) { //クイックソート//
  int Left=left, Right=right, pivot=A[(left + right) / 2];
  while(1){ // ソーティング
    while(A[Left] < pivot)
      Left++; // 基準より小さい値を左から見つけていく
    while(pivot < A[Right])
      Right--; // 基準より大きい値を右から見つけていく
    if(Left >= Right) break; // 見つかった値の順序が逆になったら終了
    swap(&A[Left], &A[Right]); // 値を交換
    swap(&B[Left], &B[Right]);
    Left++, Right--; // 次の値に移動
  }
  if(left < Left - 1) QuickSort(A, B, left, Left - 1); //左群を対象として再帰
  if(Right + 1 < right) QuickSort(A, B, Right + 1, right); //右群を対象として再帰
}

int main(void) {
  long long n, k, i, mod=1000000007, dpl, dpr, dpmax=0;
  scanf(" %lld", &n);
  long long a[n], b[n], dp[n + 1][n + 1]; //dp[左寄せの数][同右]
  for(i=0; i < n; i++){
    scanf(" %lld", &a[i]);
    b[i]=i;
  }
  QuickSort(a, b, 0, n - 1);

  dp[1][0]=a[n - 1] * b[n - 1], dp[0][1]=a[n - 1] * (n - 1 - b[n - 1]);
  for(i=2; i <= n; i++){
    for(k=0; k <= i; k++){
      if(k == 0) dp[i][0]=dp[i - 1][0] + abs(i - b[n - i] - 1) * a[n - i];
      else if(k == i) dp[0][i]=dp[0][i - 1] + abs(n - i - b[n - i]) * a[n - i];
      else{
        dpl=dp[i - k - 1][k] + abs(i - k - 1 - b[n - i]) * a[n - i];
        dpr=dp[i - k][k - 1] + abs(n - k - b[n - i]) * a[n - i];
        dp[i - k][k]=dpl > dpr ? dpl : dpr;
      }
    }
  }
  for(i=0; i <= n; i++) if(dpmax < dp[i][n - i]) dpmax=dp[i][n - i];

  printf("%lld", dpmax);
  return 0;
}

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


int main(){
    int x, base = -2;
    cin >> x;
    if(x == 0){
        cout << "0\n";
        return 0;
    }
    string s;
    while(x != 0){
        if(x % base == -1){
            s += '1';
            x += base;
        }
        else{
            s += (x%base) + '0';
        }
        x /= base;
    }
    reverse(s.begin(),s.end());
    cout << s;
}


Measured memory_bytes: 3584
package main

import "fmt"

func main() {
	var h, n int
	fmt.Scanf("%d", &h)
	fmt.Scanf("%d", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	total := 0
	for _, aa := range a {
		total += aa
	}
	if total >= h {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}


Measured memory_bytes: 5504
N, A, B = [int(i) for i in input().split()]
for s in input():
    if s == "a" and 0 < A + B:
        print("Yes")
        A -= 1
    elif s == "b" and 0 < A + B and 0 < B:
        print("Yes")
        B -= 1
    else:
        print("No")

Measured memory_bytes: 4016
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

num = []
if sorted(x)[-1] < sorted(y)[0]:
    for i in range(sorted(x)[-1] + 1, sorted(y)[0] + 1):
        num.append(i)
else:
    print("War")
    exit()

for i in num:
    if X < i <= Y:
        print("No War")
        exit()

print("War")

Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int solve(){
    int n,d;
    cin>>n>>d;
	int p=(d*2+1);
	if(n%p==0)cout<<n/p;
	else cout<<n/p+1<<endl;
	
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;
static const lint MOD = 1e9 + 7;
static bool debug = true;

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++) {
		cout << s[i];
		cout << t[i];
	}

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,ans,i,j,k;
ll a[305][305];
bool p[305][305];
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
int main(){
    read(n);
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            read(a[i][j]);
    for(k=1;k<=n;k++)      
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++){
                if(k!=j&&k!=i&&i!=j){
                    if(a[i][j]==a[i][k]+a[k][j])
                        p[i][j]=1;
	                    if(a[i][j]>a[i][k]+a[k][j]){
                        puts("-1");
                        return 0;
                    }
                }
            }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(p[i][j]==0)
                ans+=a[i][j];
	printf("%lld\n",ans>>1);
    return 0;
}

Measured memory_bytes: 1024
n,c,k = map(int,input().split())
T = [int(input()) for _ in range(n)]
T.sort()
count = 0
ans = 0
time = 0
for t in T:
  if count == 0:
    time = t
  if time +k < t:
    count = 0
    time = t
    ans += 1
  count += 1
  if count == c:
    ans += 1
    count = 0
    continue
else:
  if count>0:
    ans += 1
print(ans)



Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n, k;
    double sum = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int j = i;
        double pro = 1;
        while (j < k) {
            j *= 2;
            pro /= 2;
        }
        sum += pro;
    }
    sum /= n;
    cout << fixed << setprecision(10) << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9 + 5
int main() {
    int n, k;
    cin >> n >> k;
    vector< int > height(n);
    for (int& i: height) cin >> i;
    vector< int > dp (n, inf);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= i + k; j++) {
            if (j < n) dp[j] = min (dp[j], dp[i] + abs(height[i] - height[j]));
        }
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

ll modpow(ll a, ll n) {
  ll res = 1;
  while(n>0){
    if(n&1) res = res * a;
    a = a * a; // a を 2乗したものに置き換える。（2進数だと1桁上がる）
    n >>= 1; // 2進数で1桁下げる
  }
  return res;
}

int main(void) {
  int n;cin>>n;
  ll ans = 0;
  rep(i,0,9) {
    rep(j,0,9) {

      int ans_i_j = 0;
      int ans_j_i = 0;

      rep(k,1,n) {
        int fig_len = log10(k);
        int f = floor(k/modpow(10,fig_len));
        int k_10 = k%10;

        if (i == f && j == k_10) {
          ans_i_j++;
        }
        if (j == f && i == k_10) {
          ans_j_i++;
        }
      }

      ans += ans_i_j * ans_j_i;

    }
  }
  pr(ans);
}


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

using namespace std;

const long long Mod = 32416187567;
const long long Base = 73;

long long mat[ 650 ][ 650 ], hl[ 650 ], hc[ 650 ], pw[ 650 ];
long long n, ans;

char ch[ 650 ][ 650 ];

void calc_hash (int lin, int col) {
    for (int i = 1; i < n; ++ i) {
        hl[ i ] = hc[ i ] = 0;
    }

    for (int p = 1; p < n; ++ p) {
        for (int i = p - 1; i >= 0; -- i) {
            hl[ p ] = (hl[ p ] * Base + mat[lin - p][col - i]) % Mod;
            hc[ p ] = (hc[ p ] * Base + mat[lin - i][col - p]) % Mod;
        }
    }
}

void recalc_hash (int lin, int col) {
    for (int p = 1; p < n; ++ p) {
        hl[ p ] = (((hl[ p ] - (mat[lin - p][col - p] * pw[p - 1]) % Mod + Mod) % Mod * Base) % Mod + mat[lin - p][ col ]) % Mod;
    }

    for (int p = n - 1; p >= 1; -- p) {
        hc[ p ] = (hc[p - 1] + (mat[lin - p + 1][col - p] * pw[p - 1]) % Mod) % Mod;
    }
}

bool check ( ) {
    for (int i = 1; i < n; ++ i) {
        if (hl[ i ] != hc[ i ])
            return false;
    }

    return true;
}

int main ( ) {

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> (ch[ i ] + 1);
    }

    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            mat[ i ][ j ] = ch[ i ][ j ] - 'a' + 1;
        }
    }

    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            mat[i + n][ j ] = mat[ i ][ j ];
            mat[ i ][j + n] = mat[ i ][ j ];
            mat[i + n][j + n] = mat[ i ][ j ];
        }
    }

    pw[ 0 ] = 1;
    for (int i = 1; i <= n; ++ i) {
        pw[ i ] = pw[i - 1] * Base;
        pw[ i ] %= Mod;
    }

    for (int i = n; i < 2 * n; ++ i) {
        calc_hash(i, n);
        if (check ( ))
            ++ans;

        for (int j = n + 1; j < 2 * n; ++ j) {
            recalc_hash (i, j);
            if (check ( )) {
                ++ans;
            }
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(void){
  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;

  int p;
  string l;
  string r;
  REP(i,n){
    p = 0;
    for(char c='a';c<='z';c++){
        l = s.substr(0,i);
        r = s.substr(i);
        if( count(l.cbegin(), l.cend(), c) > 0 && count(r.cbegin(), r.cend(), c) > 0){
            p++;
          }
      }
    ans = max(p,ans);

    }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int years[1000];
int days[2][11];

void init(){
    int i;
    for(i=0;i<1000;i++){
        years[i]=0;
        if(i%3==0){
            years[i] = 200;
        }else{
            years[i] = 195;
        }
    }
    for(i=1;i<=10;i++){
        days[0][i] = days[1][i] = 20;
        if(i%2==0) days[0][i]=19;
    }
}

void solve(){
    int y,m,d;
    cin >> y >> m >> d;
    int ans = 0;
    for(int i=y+1;i<1000;i++){
        ans += years[i];
    }

    for(int i=m+1;i<=10;i++){
        if(y%3!=0) ans += days[0][i];
        else ans += days[1][i];
    }

    int k=0;
    if(y%3==0) k=1;
    for(int i=d;i<=days[k][m];i++){
        ans++;
    }
    cout << ans << endl;
}

int main(){
    int n;
    cin >> n;
    init();
    for(int i=0;i<n;i++) solve();
}

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

using namespace std;

bool solve(int N, vector<int>& ls)
{
    sort(ls.begin(), ls.end());

    int sum = 0;

    for (int i = 0; i < N - 1; ++i)
        sum += ls[i];

    return ls.back() < sum;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> ls(N);

    for (int i = 0; i < N; ++i)
        cin >> ls[i];

    auto ans = solve(N, ls);

    cout << (ans ? "Yes" : "No") << '\n';

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
MOD = 10**9+7

if N == 1
    puts 0
    exit
end

def modpow x, n
    res = 1
    while n > 0 do
        if n.odd?
            res = (res * x) % MOD
        end
        x = (x * x) % MOD
        n /= 2
    end
    return res
end

res = modpow(10, N) + modpow(8,N) - ( 2 * modpow(9,N) )

puts res % MOD

Measured memory_bytes: 14232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    vector<string> c(n, string(m, '.'));
    if (n % 2 == 1) {
        int i = 0;
        for (int j = m % 2; j < m; j += 2) {
            if (a == 0) break;
            a--;
            c[i][j] = '<';
            c[i][j + 1] = '>';
        }
    }
    if (m % 2 == 1) {
        int j = 0;
        for (int i = 0; i < n - 1; i += 2) {
            if (b == 0) break;
            b--;
            c[i][j] = '^';
            c[i + 1][j] = 'v';
        }
    }
    for (int i = n % 2; i < n; i += 2) {
        for (int j = m - 2; j >= 0; j -= 2) {
            if (n % 2 == 1 && i == n - 2 && j == 1 && a == 1 && b == 1) {
                a--; b--;
                c[i + 1][j - 1] = '<';
                c[i + 1][j] = '>';
                c[i][j + 1] = '^';
                c[i + 1][j + 1] = 'v';
                break;
            }
            if (a >= 2 || (b < 2 && a > 0)) {
                a--;
                c[i][j] = '<';
                c[i][j + 1] = '>';
                if (a > 0) {
                    a--;
                    c[i + 1][j] = '<';
                    c[i + 1][j + 1] = '>';
                }
            } else if (b > 0) {
                b--;
                c[i][j] = '^';
                c[i + 1][j] = 'v';
                if (b > 0) {
                    b--;
                    c[i][j + 1] = '^';
                    c[i + 1][j + 1] = 'v';
                }
            } else {
                break;
            }
        }
    }

    if (a + b > 0) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        for (int i = 0; i < n; i++) {
            cout << c[i] << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std;
# define M_PI           3.14159265358979323846
int main(){
    int r;
    scanf("%d", &r);
    printf("%.20f\n", 2.0*M_PI*r);
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int array[3][3];
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> array[i][j];
        }
    }

    int n; cin >> n;
    int b[n]; for(int i = 0; i < n; ++i) cin >> b[i];

    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            for(int k = 0; k < n; ++k) {
                if(array[i][j] == b[k]) array[i][j] = 0;
            }
        }
    }

    for(int i = 0; i < 3; ++i) {
        int che = 0, che2 = 0;
        for(int j = 0; j < 3; ++j) {
            if(array[i][j] == 0) ++che;
            if(array[j][i] == 0) ++che2;
            if(che == 3 || che2 == 3) {
                cout << "Yes";
                return 0;
            }
        }
    }

    int co = 0;
    for(int i = 0, j = 0; j < 3; ++j, ++i) {
        if(array[i][j] == 0) ++co;
    }
    if(co == 3) {
        cout << "Yes";
        return 0;
    }

    co = 0;
    for(int i = 0, j = 2; i < 3; ++i, --j) {
        if(array[i][j] == 0) ++co;
    }
    if(co == 3) {
        cout << "Yes";
        return 0;
    }

    cout << "No";
}


Measured memory_bytes: 256
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
B = [[0 for _ in range(W)] for _ in range(H)]
col = 1
cnt = 0
y = 0
x = 0
d = "R"
while y<H:
    if cnt<A[col]:
        B[y][x] = col
        cnt += 1
    else:
        col += 1
        cnt = 0
        B[y][x] = col
        cnt += 1
    if x<W-1 and d=="R":
        x += 1
    elif x==W-1 and d=="R":
        y += 1
        d = "L"
    elif d=="L" and x>0:
        x -= 1
    elif d=="L" and x==0:
        y += 1
        d = "R"
for i in range(H):
    print(*B[i])

Measured memory_bytes: 74520
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
 
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}
 
char xx[] = {'.', '#', '.', '#'};
char yy[] = {'.', '.', '#', '#'};
 
int main() {
    int n; cin >> n; cin.ignore();
    string s1 = "", s2 = "", q;
    string t1, t2;
    bool back = false;
    while(1) {
        rep(i,0,4) {
            t1 = s1; t2 = s2;
            if(back) {
                t1 = xx[i] + t1;
                t2 = yy[i] + t2;
            }
            else {
                t1 = t1 + xx[i];
                t2 = t2 + yy[i];
            }
            cout << t1 << endl << t2 << endl; fflush(stdout);
            cin >> q;
            if(q == "end") return 0;
            else if(q == "T") {
                s1 = t1;
                s2 = t2;
                break;
            }
            else if(q == "F" && i == 3) back = true;
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int main()
{
	int n,io;
	cin>>n;
	for(int i=1;i<=n;i++)
	{

		cin>>io;
		if(io%2==0)
		{
			if(io%5==0||io%3==0)
				continue;
			else 
			{
				cout<<"DENIED"<<endl;
				return 0;
			}	
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse (int u) {
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse (int u) {
    if (u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse (int u) {
    if (u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main () {
    int i, v, l, r, root;

    scanf ("%d", &n);
    for (i = 0; i < n; i++) {
        T[i].p = NIL;
    }

    for (i = 0; i < n; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (i = 0; i < n; i++) if (T[i].p == NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}



Measured memory_bytes: 2696
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
Node head, tail;
void inorder(Node node){
  if(node != tail){
    inorder(node->left);
    printf(" %d", node->key);
    inorder(node->right);
  }
}
void preorder(Node node){
  if(node != tail){
    printf(" %d", node->key);
    preorder(node->left);
    preorder(node->right);
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;
    if (z->key < x->key)x = x->left;
    else x = x->right ;
    z->parent = y;
  }
  if (y == NIL)root = z;
	else if (z->key < y->key) y->left = z;
	else y->right = z;
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
   else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
  }
  }

  return 0;
}



Measured memory_bytes: 25180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int N,Q;
string S;
vector<int> l(100010),r(100010);
vector<int> ACl,ACr;
int main() {
	cin>>N>>Q>>S;
	rep(i,Q){
		cin>>l[i]>>r[i];
		l[i]--;r[i]-=2;
	}
	int cnt = 0;
	rep(i,N-1){
		if(S.substr(i,2)=="AC"){
			ACl.push_back(i);
			cnt++;
		}
	}
	sort(all(ACl));
	rep(i,Q){
		auto iter_lower_l = lower_bound(all(ACl), l[i]);
		auto iter_upper_r = upper_bound(all(ACl), r[i]);
		ll idx_lower_l = distance(ACl.begin(), iter_lower_l);
		ll idx_upper_r = distance(ACl.begin(), iter_upper_r);
		int ans = idx_upper_r -idx_lower_l;
		cout<<ans<<endl;
	}
	//cout<<ans<<endl;
}

Measured memory_bytes: 2044
#include <iostream>
#include <vector>
using namespace std;
int n,k,d,temp;
int main(){
  cin>>n>>k;
  vector <int> a(n,1);
  while(k--){
    cin>>d;
    while(d--){
      cin>>temp;
      a[temp-1]=0;
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout<<sum;
}
  

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int mod = 1e9+7;
int main() {
    fast_cin();
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b!=c){
        cout<<"Yes";
    }
    else if(b==c&&b!=a){
        cout<<"Yes";
    }
    else if(a==c&&b!=a){
        cout<<"Yes";
    }
    else {
        cout<<"No";
    }
}    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)


int main() {
	int n;
	cin >> n;
	vector<P> r;

	rep(i, n) {
		ll x, l;
		cin >> x >> l;
		r.pb(mp(x + l,x - l));
	}
	sort(r.begin(),r.end());
	int ans = 0;
	ll end_x = -10000000000000;

	for(auto cur : r) {
		if (cur.second < end_x) {
			continue;
		}
		end_x = cur.first;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3052