akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
using namespace std;
const long long P=1000000007;
long long n,k,f[10001];
long long qpow(long long a,int x)
{
    if(x<0)return 1;
    long long s=1;
    while(x)
	{
		if(x&1) s=(s*a)%P;
		a=(a*a)%P;
		x>>=1;
	}
    return s;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    f[0]=1;
    for(int i=1;i<n;++i)
	{
		for(int j=i;j;--j)
			f[j]=(f[j+1]+f[j-1])%P;
		f[0]=f[1];
	}
    printf("%lld",f[n-k]*qpow(2,n-k-1)%P);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+7;
ll a[maxn];
int main(){
	int n;
	ll t;
	cin>>n>>t;
	for(int i=0;i<n;i++) cin>>a[i];
	if(n==1){
		cout<<0<<endl;
		return 0;
	}

	ll minn=a[0],maxx=-1,cnt=0;
	for(int i=1;i<n;i++){
		if(a[i]-minn==maxx) cnt++;
		else if(a[i]-minn>maxx) cnt=1;
		maxx=max(maxx,a[i]-minn);
		minn=min(minn,a[i]);
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 1024
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
///#define double long double
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second

using namespace std;
const int MOD = 1e9 + 7;

typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}

const int N = 2 * 1e5 + 1;
const int inf = 1e9 + 7;
const double PI = 3.14159265359;
signed main () {
    ios_base::sync_with_stdio(NULL);  cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int pr = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x = ni();
        ans += (x - 1) / 2;
        if (x == 0) x = 0;
        else if (x % 2 == 0) x = 2;
        else x = 1;
        if (x == 2) {
            if (pr == 2) {
                ans += 2;
                pr = 0;
            }
            else if (pr == 1) {
                ans += 1;
                pr = 1;
            }
            else {
                pr = 2;
            }
        }
        else if (x == 1) {
            if (pr == 2) {
                ans += 1;
                pr = 1;
            }
            else if (pr == 1) {
                ans += 1;
                pr = 0;
            }
            else {
                pr = 1;
            }
        }
        else {
            ans += pr / 2;
            pr = 0;
        }
    }
    ans += pr / 2;
    cout << ans << '\n';
    return 0;
}




















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

int main() {
  ll n, total = 0;
  cin >> n;
  for (ll i = 1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    total += i;
  }
  cout << total << endl;
}


Measured memory_bytes: 3624
S = input()
ans = True
count = 0
for i in range(len(S)):
    if i == 0 and S[0]!='A':
        ans = False
        break
    if 2 <= i <= len(S)-2:
        if S[i] == 'C':
            count += 1
            if count > 1:
                ans = False
                break
        elif ord(S[i])-ord('a') < 0 or ord(S[i])-ord('a') > 25:
            ans = False
            break
    if (i == 1 or i == len(S)-1) and ord(S[i])-ord('a') < 0 or ord(S[i])-ord('a') > 25:
        ans = False
        break
if ans and count==1:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import static java.lang.System.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List<Integer> listX = new ArrayList<Integer>();
    List<Integer> listY = new ArrayList<Integer>();
    while(true)
    {
      int x = sc.nextInt();
      int y = sc.nextInt();
      if(x == 0 && y == 0) break;
      listX.add(x);
      listY.add(y);
    }
    for(int i=0; i<listX.size(); i++)
    {
      int x = listX.get(i);
      int y = listY.get(i);

      for(int j=0; j<x; j++)
      {
        for(int k=0; k<y; k++)
        {
          out.print("#");
        }
        out.println();
      }
      out.println();
    }
  }
}


Measured memory_bytes: 38268
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new Scanner(System.in)
    val N, S = scanner.nextLine()
    println(S.map(char => fun(char, N.toInt)))
  }
  
  def fun(char: Char, num: Int): Char = {
    val str = ('A' to 'Z').toList
    str(((str.indexOf(char) + num ) % str.length))
  }
}


Measured memory_bytes: 38556
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    A, B = map(int, input().strip().split())
    return A, B


def solve(A, B):
    return A * B


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

int N;
string X;
ll t[200000], a[200001], p, res;

int main() {
	cin >> N >> X;
	t[0] = (X[0] == '1');
	for (int i = 1; i < N; ++i) {
		t[i] = (t[i - 1] * 2 + (X[i] == '1')) % mod998;
	}
	for (int i = 2; i <= N; i += 2) {
		if (N % i == i / 2) {
			bool f = true;
			bool g = false;
			for (int j = 0; j < i / 2; ++j) {
				if (X[j] == '0') {
					if (X[j + i / 2] == '0') {
						f = false;
						break;
					}
				}
				else {
					if (X[j + i / 2] == '1') {
						g = true;
						break;
					}
				}
			}
			if (f&&!g) {
				string T;
				for (int j = 0; j < i; ++j) {
					T.push_back(X[j]);
				}
				for (int j = 0; j < i; ++j) {
					if (X[j] == '0') {
						T.push_back('1');
					}
					else {
						T.push_back('0');
					}
				}
				for (int j = 0; j < N; ++j) {
					if (T[j%i] == '0'&&X[j] == '1') {
						break;
					}
					if (T[j%i] == '1'&&X[j] == '0') {
						f = false;
						break;
					}
				}
			}
			if(f) {
				a[i] = t[i / 2 - 1] + 1;
			}
			else {
				a[i] = t[i / 2 - 1];
			}
		}
	}
	p = t[N - 1] + 1;
	for (int i = 2; i <= N; ++i) {
		if (a[i]) {
			res += a[i] * i;
			res %= mod998;
			for (int j = i + i; j <= N; j += i) {
				if (a[j]) {
					a[j] -= a[i];
					a[j] += mod998;
					a[j] %= mod998;
				}
			}
			p -= a[i];
			p += mod998;
			p %= mod998;
		}
	}
	res += p * 2 * N;
	res %= mod998;
	cout << res << endl;
}

Measured memory_bytes: 2232
N = int(input())
people = input()

count = 0
for i in range(1, N):
    if people[i] == 'E':
        count += 1

counts = [count]
for i in range(1, N):
    if people[i - 1] == 'W':
        count += 1
    if people[i]  == 'E':
        count -= 1
    counts.append(count)

print(min(counts))
    

Measured memory_bytes: 15520
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	n = int(input())
	d = list(map(int,input().split()))
	ans = 0
	for i in range(n):
		for j in range(n):
			if(j == i):
				continue
			ans += d[i] * d[j]
	print(ans//2)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 65516
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll  a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll gsy(ll a,ll b)
{
	return b*(a/gcd(a,b));
}
int main()
{
	int n;
	cin>>n;
	ll g = 1;
    while(n--)
    {
        ll a;
        cin>>a;
        g = gsy(g,a);
    }
    cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(void){
    int n, prev, now, sum = 0;
    scanf("%d", &n);
    scanf("%d", &prev);
    for (int i = 1; i < n; i++) {
        scanf("%d", &now);
        if (now > prev) sum++;
        prev = now;
    }
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>=1&&a<=9&&b>=1&&b<=9)
	{
		cout<<a*b;
	}
	else
	{
		cout<<"-1";
	}
	return 0;
}

Measured memory_bytes: 256
m ,d = list(map(int , input().split()))
count = 0

for i in range(m):
  for j in range(d):
    month = i + 1
    days = j + 1
    ten_day = days //  10
    one_day = days - ten_day*10
    
    if one_day >= 2 and ten_day>= 2 and month == ten_day * one_day:
      count += 1
      
print(count)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n, r int
	fmt.Scan(&n, &r)
	for n != 0 || r != 0 {
		arr := make([]int, n)
		for i := range arr {
			arr[i] = len(arr) - i
		}

		for i := 0; i < r; i++ {
			var p, c int
			fmt.Scan(&p, &c)
			mid, top, last := arr[:p-1], arr[p-1:p-1+c], arr[p-1+c:]
			arr = append(append(append([]int{}, top...), mid...), last...)
		}
		fmt.Println(arr[0])
		fmt.Scan(&n, &r)
	}
}



Measured memory_bytes: 2872
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int a, b,c,k,wa=0;
    cin >> a >> b >> c >> k;
    if (k >= a) {
        wa += a;
    }
    else {
        wa += k;
    }
    k -= a+b;
    if (k > 0) {
        wa -= k;
    }
    cout << wa << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string S; ll K; cin >> S >> K;
  ll x, j = 2000000000000000000;
  rep(i, S.size()) {
    if (S[i] != '1') {
      x = S[i] - '0';
      j = i;
      break;
    }
  }
  if (j <= K - 1) {
    cout << x << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;


int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N);
    vector<ll> Cum(N+1);
    Cum[0] = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        Cum[i+1] = Cum[i] + A[i];
    }
    
    vector<ll> B;
    for(int i=0; i<N; i++){
        for(int j=i; j<N; j++){
            B.push_back(Cum[j+1] - Cum[i]);
        }
    }
    sort(B.begin(), B.end(), greater<ll>());
    
    ll mx = B[0];
    ll mx_bit = 0;
    while(mx!=0){
        mx /= 2;
        mx_bit++;
    }
    
    ll bit_flug = 1LL << (mx_bit-1);

    ll ans = 0;
    for(int i=0; i<mx_bit; i++){
        ll bit_cnt = 0;
        for(ll j=0; j<B.size(); j++){
            if(bit_flug & B[j]) bit_cnt++;
        }
        
        if(bit_cnt>=K){
            ans += 1LL<<(mx_bit-(i+1));
            vector<ll> Next;
            for(int j=0; j<B.size(); j++){
                if(bit_flug & B[j]) Next.push_back(B[j]);
            }
            B = Next;
        }  
        
        bit_flug >>= 1;
    }
    
    cout << ans << endl;
    
    return 0;
}





Measured memory_bytes: 6388
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int N, W;
  cin >> N >> W;

  int w1;
  vector<int> v[4];
  cin >> w1;
  int tmp;
  cin >> tmp;
  v[0].push_back(tmp);
  for (int i = 1; i < N; i++) {
    int w;
    cin >> w >> tmp;
    v[w - w1].push_back(tmp);
  }

  sort(v[0].rbegin(), v[0].rend());
  sort(v[1].rbegin(), v[1].rend());
  sort(v[2].rbegin(), v[2].rend());
  sort(v[3].rbegin(), v[3].rend());

  long long ans = 0;
  for (int a = 0; a <= v[0].size(); a++) {
    for (int b = 0; b <= v[1].size(); b++) {
      for (int c = 0; c <= v[2].size(); c++) {
        for (int d = 0; d <= v[3].size(); d++) {
          // cout << a << " " << b << " " << c << " " << d << endl;
          if (
              (long long)w1 * a + (long long)(w1 + 1) * b + (long long)(w1 + 2) * c + (long long)(w1 + 3) * d > W
             ) continue;
          long long tmp = 0;
          for (int i = 0; i < a; i++) {
            tmp += v[0][i];
          }
          for (int i = 0; i < b; i++) {
            tmp += v[1][i];
          }
          for (int i = 0; i < c; i++) {
            tmp += v[2][i];
          }
          for (int i = 0; i < d; i++) {
            tmp += v[3][i];
          }
          // cout << tmp << endl;
          ans = max(ans, tmp);
        }
      }
    }
  }

  cout << ans << endl;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

map<int, int> primeFactorize(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n > 1) ++res[n];
    return res;
}

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

    int p, q;
    cin >> p >> q;
    int g = gcd(p, q);
    p /= g;
    q /= g;

    auto mp = primeFactorize(q);
    int x = 1;
    for (auto p : mp) {
        x = lcm(x, p.first);
    }

    cout << x << endl;

}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  sort(all(a));

  ll vl = *a.begin();
  ll vr = *a.rbegin();
  if (vr - vl > 1) {
    cout << "No" << endl;
    return 0;
  }

  ll nl = distance(a.begin(), upper_bound(all(a), *a.begin()));
  ll nr = n - nl;

  if (nr == 0) {
    // 帽子はvr+1色存在する？
    if (vl == n - 1 || (vl <= n / 2)) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  if (nr == 1) {
    cout << "No" << endl;
    return 0;
  }

  // 帽子はvr色存在する。
  // nl人が1人だけその帽子をかぶっている

  ll num_color = vr;
  ll original = nl;
  ll grp_people = nr;

  bool flag1 = original + grp_people / 2 >= num_color;
  bool flag2 = original + 1 <= num_color;

  if (flag1 && flag2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

const int MAX_N = 8000;
bool dpxy[2][MAX_N][2 * MAX_N];
int main() {
    string s;
    int x, y;
    cin >> s;
    cin >> x >> y;
    const char *str = s.c_str();
    const int n = s.length();
    const int origin = n;
    int p = 0;
    int index = 0;
    int j[] = {0, 0};
    while(*str && *str == 'F') {
        p++;
        str = str + 1;
    }
    dpxy[0][0][p+origin] = true;
    dpxy[1][0][origin] = true;
    while(*str) {
        p = 0;
        while(*str && *str == 'F') {
            p++;
            str = str + 1;
        }
        int jj = j[index];
        for(int i=0;i<2*MAX_N;i++) {
            bool a = dpxy[index][jj][i];
            if(i+p<n+origin) {
                dpxy[index][jj+1][i+p] = dpxy[index][jj+1][i+p] || a;
            }
            if(0<i-p) {
                dpxy[index][jj+1][i-p] = dpxy[index][jj+1][i-p] || a;
            }
        }
        j[index]++;
        index = (index+1)%2;
        if(*str && *str == 'T') {
            str = str + 1;
        }
    }
    if(dpxy[0][j[0]][x+origin] && dpxy[1][j[1]][y+origin]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 127232
#include<cstdio>
long long gcd(long long a,long long b){
  if(b%a==0)return a;
  else return gcd(b%a,a);
}
int main(void){
  long long n,x,g;
  scanf("%lld%lld",&n,&x);
  g=gcd(x,n);
  printf("%lld\n",(n-g)*3);
  return 0;
}
         
         

Measured memory_bytes: 128
#include "iostream"
#include<algorithm>
using namespace std;
int v[1002][1002],a[4],n,i,j,c;

int main()
{
	cin >> n;
	for (c = 0; c < n; c++) {
		cin >> a[0] >> a[1] >> a[2] >> a[3];
		v[a[0]][a[1]] += 1;
		v[a[2]][a[3]] += 1;
		v[a[0]][a[3]] -= 1;
		v[a[2]][a[1]] -= 1;
	}
	c = 0;
	n = 0;
	for (i = 0;i<1002;i++) {
		for (j = 1; j < 1002; j++) {
			v[i][j] += v[i][j-1];
		}
	}
	for (i = 1; i<1002; i++) {
		for (j = 0; j < 1002; j++) {
			v[i][j] += v[i-1][j];
		}
	}
	for (i = 0; i<1002; i++) {
		for (j = 0; j < 1002; j++) {
			c = max(c, v[i][j]);
		}
	}

	cout << c << endl;
	cin >> n;
	return 0;
}


Measured memory_bytes: 7040
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
vector<int> ans;
struct point
{
	int x, y, id;
	point() :x(0), y(0)
	{

	}
};
point* s;
bool cmp_x(point a, point b)
{
	return a.x < b.x;
}
bool cmp_y(point a, point b)
{
	return a.y < b.y;
}
struct treeNode
{
	int loc;
	treeNode* left;
	treeNode* right;
	treeNode()
	{
		left = NULL;
		right = NULL;
		loc = 0;
	}
};
class kdtree
{
private:
	treeNode* root;
	treeNode* mktree(treeNode*& v, int lo, int hi, int depth, point* s)
	{
		if (!(lo < hi)) return NULL;
		v = new treeNode;
		if (depth % 2 == 0)
		{
			sort(s + lo, s + hi, cmp_x);
		}
		else {
			sort(s + lo, s + hi, cmp_y);
		}
		int mid = (lo + hi) / 2;
		v->loc = mid;
		v->left = mktree(v->left, lo, mid, depth + 1, s);
		v->right = mktree(v->right, mid + 1, hi, depth + 1, s);
		return v;
	}
	void search(treeNode* v, int sx, int tx, int sy, int ty, int depth)
	{
		int x = s[v->loc].x;
		int y = s[v->loc].y;
		int id = s[v->loc].id;
		if (sx <= x && sy <= y && y <= ty && x <= tx)
		{
			ans.push_back(id);
		}
		if (depth % 2 == 0)
		{
			if (v->left != NULL)
			{
				if (sx <= x)
				{
					search(v->left, sx, tx, sy, ty, depth + 1);
				}
			}
			if (v->right != NULL)
			{
				if (tx >= x)
				{
					search(v->right, sx, tx, sy, ty, depth + 1);
				}
			}
		}
		else
		{
			if (v->left != NULL)
			{
				if (sy <= y)
				{
					search(v->left, sx, tx, sy, ty, depth + 1);
				}
			}
			if (v->right != NULL)
			{
				if (ty >= y)
				{
					search(v->right, sx, tx, sy, ty, depth + 1);
				}
			}
		}

	}
public:
	kdtree()
	{
		root = NULL;
	}
	void query(int sx, int tx, int sy, int ty)
	{
		ans.clear();
		search(root, sx, tx, sy, ty, 0);
	}
	void init(point* s, int size)
	{
		mktree(root, 0, size, 0, s);
	}
};
int main()
{
	int n, m;
	scanf("%d", &n);
	s = new point[n];
	kdtree T;
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &s[i].x, &s[i].y);
		s[i].id = i;
	}
	T.init(s, n);
	int sx, tx, sy, ty;
	scanf("%d", &m);
	while (m--)
	{
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		T.query(sx, tx, sy, ty);
		sort(ans.begin(), ans.end());
		for (int i = 0; i < ans.size(); i++)
		{
			printf("%d\n", ans[i]);
		}
		printf("\n");

	}

}


Measured memory_bytes: 24028
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    switch(X) {
        case 1:
            ans += 300000;
            break;
        case 2:
            ans += 200000;
            break;
        case 3:
            ans += 100000;
            break;
    }
    switch(Y) {
        case 1:
            ans += 300000;
            break;
        case 2:
            ans += 200000;
            break;
        case 3:
            ans += 100000;
            break;
    }

    if (X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n, k] <- getInts
  _ <- getInts
  print $ (n + k - 3) `div` (k - 1)

getInts :: IO [Int]
getInts = unfoldr (BC.readInt . BC.dropWhile (== ' ')) <$> BC.getLine


Measured memory_bytes: 1660
#include<stdio.h>
int main(void)
{
	int time=0;
	int h,m,s;
	scanf("%d",&time);
	h=time/3600;
	m=(time%3600)/60;
	s=time-(3600*h+60*m);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var xs = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var bin = new byte[1 + (int)1e9];
        for (int i = 0; i < bin.Length; i += 2)
        {
            bin[i] = (byte)(bin[i / 2] + 1);
        }

        var z = xs.Sum(x => bin[x]);
        Console.WriteLine(z);
    }
}

Measured memory_bytes: 990688
#include<stdio.h>
int main(){
  int h,w,i,j;
  char s[51][51];
  scanf("%d%d",&h,&w);
  for(i=0;i<h;i++){
    scanf("%s",s[i]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='.'){
        s[i][j]=48;
        for(int k=0;k<3;k++){
          for(int l=0;l<3;l++){
            s[i][j]+=s[i-1+k][j-1+l]=='#';
          }
        }
      }
    }
  }
  for(i=0;i<h;i++){
    printf("%s\n",s[i]);
  }
}


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

int main() {
    int N;  cin >> N;
    map<long long, long long> mp1, mp2;
    for (int i = 0; i < N; ++i) {
        long long a;  cin >> a;
        ++mp1[a + i];
        ++mp2[a - i];
    }

    long long ans = 0;
    for (auto e : mp1) {
        long long value = e.first;
        ans += mp2[-value] * e.second;
    }
    for (auto e : mp2) {
        long long value = e.first;
        ans += mp1[-value] * e.second;
    }

    cout << ans / 2 << endl;
}


Measured memory_bytes: 49036
import java.util.Scanner;

public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		String ans = "Yes";
		int tka = 0;
		int ao = 0;
		
		while(c > 0) {
			c = c - b;
			tka++;
		}
		
		while(a > 0) {
			a = a - d;
			ao++;
		}
		
		if(ao < tka) {
			ans = "No";
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 27056
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll inf = 1e18; 
mt19937 rnd(time(0));
int n; 
int d[maxn], c[maxn]; 

void solve() { 
    cin >> n;
    int add = 0; 
    int p = 0; 
    for (int i = 0; i < n; ++i) {
        cin >> d[i] >> c[i]; 
        p += c[i]; 
        add += d[i] * c[i];
    }
    cout << p - 1 + (add - 1) / 9; 
}                                   
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}


int N, Q;
string s;
vector<char> t(200005), d(200005);

bool check1(int x){
    if(x==-1) return true;
    if(x==N) return false;

    char c=s[x];
    rep(i, Q) if(c==t[i]) {
        if(d[i]=='L') --x;
        else ++x;

        if(x==-1) return true;
        if(x==N) return false;
        c = s[x];
    }
    return false;
}

bool check2(int x){
    if(x==N) return true;
    if(x==-1) return false;

    char c=s[x];
    rep(i, Q) if(c==t[i]) {
        if(d[i]=='L') --x;
        else ++x;

        if(x==-1) return false;
        if(x==N) return true;
        c = s[x];
    }
    return false;
}

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

    cin >> N >> Q;
    cin >> s;
    rep(i, Q) cin >> t[i] >> d[i];

    int ok=-1, ng=N;
    while(ng-ok > 1){
        int mid=(ok+ng)/2;
        (check1(mid)? ok:ng) = mid;
    }
    int left = ok;

    ok=N, ng=-1;
    while(ok-ng > 1){
        int mid=(ok+ng)/2;
        (check2(mid)? ok:ng) = mid;
    }
    int right=ok;

    cout << N - (N-right) - (left+1) << endl;

    return 0;
} 

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

typedef long long int lint;


int main(){
    lint n;
    cin >> n;
    string s;
    cin >> s;
    lint cntr = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            cntr++;
        }
    }
    cout << n-cntr;
    return 0;

}

Measured memory_bytes: 512
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		long[] dp = new long[200020];

		int N = nextInt();
		int Q = nextInt();

		//List<List<Integer>> list = new ArrayList<>(N+1);
		List<List<Integer>> R_list = new ArrayList<>(N+1);
		for (int i=0;i<=N;i++) {
			//list.add(new ArrayList<>());
			R_list.add(new ArrayList<>());
		}
		//R_list.get(1).add(0);
		for(int i=1;i<N;i++) {
			int a = nextInt();
			int b = nextInt();
			//list.get(a).add(b);
			R_list.get(b).add(a);
		}

		for(int i=0;i<=N;i++) {
			if(R_list.get(i).size()==0) {
				R_list.get(i).add(0);
			}
			//out.println(R_list.get(i));
		}

		for(int i=0;i<Q;i++) {
			int p = nextInt();
			int x = nextInt();
			dp[p] += x;
		}

		for(int i=1;i<=N;i++) {
			dp[i] = dp[i]+dp[R_list.get(i).get(0)];
		}

		StringBuilder buf = new StringBuilder();
		for(int i=1;i<=N;i++) {
			if(i!=1) {
				buf.append(" ");
			}
			buf.append(dp[i]);
		}
		out.println(buf);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 120448
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    int A[Q];
    for(int i=0;i<Q;++i){
        cin >> A[i];
    }
    int ini_pos[N]={0};
    for(int i=0; i<Q;++i){
        ini_pos[A[i]-1]+=1;
    }
    for(int i=0;i<N;++i){
        ini_pos[i]=ini_pos[i]-Q+K;
    }
    for(int i=0;i<N;++i){
        if(ini_pos[i]<=0){
            cout << "No"<<endl;
        }
        else{
            cout << "Yes"<<endl;
        }
    }
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>

using namespace std;

#define MOD 1000000007

int n;

char s[100005];
int psum[100005];
int nxt[100005][2];
int f[100005];

int main()
{
    scanf("%s", s + 1);
    n = strlen(s + 1);
    bool hassame = false;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i+1]) hassame = true;
    }
    if (!hassame) {
        printf("1"); return 0;
    }
    for (int i = 1; i <= n; i++) {
        psum[i] = psum[i-1] + (s[i] == 'a' ? 1 : 2);
        psum[i] %= 3;
    }
    int tmp[3]; /* next acceptable with this psum */
    tmp[0] = tmp[1] = tmp[2] = n + 1;
    int tmp2[3]; /* next with this psum */
    tmp2[0] = tmp2[1] = tmp2[2] = n + 1;
    for (int i = n; i >= 1; i--) {
        if (i != n && s[i] == s[i+1]) {
            for (int j = 0; j < 3; j++) tmp[j] = tmp2[j];
        }
        nxt[i][0] = tmp[(psum[i-1] + 1) % 3];
        nxt[i][1] = tmp[(psum[i-1] + 2) % 3];
        if (s[i] == 'a') {
            nxt[i][0] = i;
        } else {
            nxt[i][1] = i;
        }
        tmp2[psum[i]] = i;
    }
    f[0] = 1;
    for (int i = 0; i < n; i++) {
        if (nxt[i+1][0] <= n) {
            f[nxt[i+1][0]] += f[i];
            if (f[nxt[i+1][0]] >= MOD) f[nxt[i+1][0]] -= MOD;
        }
        if (nxt[i+1][1] <= n) {
            f[nxt[i+1][1]] += f[i];
            if (f[nxt[i+1][1]] >= MOD) f[nxt[i+1][1]] -= MOD;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if ((psum[n] - psum[i] + 3) % 3 == 0) {
            ans += f[i];
            if (ans >= MOD) ans -= MOD;
        }
    }
    printf("%d", ans);
    return 0;
}


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

int main(){
    string S;
    cin >>S;
    int length=S.size();
    bool torf=true;
    for(int i=0;i<length/2;i++){
        if(S[i]!=S[length-1-i]){
            torf=false;
        }
    }
    if(!torf){
        cout <<"No\n";
        return 0;
    }
    for(int i=0,j=(length-3)/2;i<j;i++,j--){
        if(S[i]!=S[j]){
            torf=false;
        }
    }
    if(!torf){
        cout <<"No\n";
        return 0;
    }
    for(int i=(length+1)/2,j=length-1;i<j;i++,j--){
         if(S[i]!=S[j]){
            torf=false;
        }
    }
    if(!torf){
        cout <<"No\n";
        return 0;}
    else{
        cout << "Yes\n";
        return 0;
    }
    return 0;
}

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

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    int sum = 0;
    for (int i = 0; i < n; i++){
        int b;
        cin >> b;
        sum += b;
    }
    vector<int> c(n);
    for (int i = 1; i < n; i++)
        cin >> c[i];
    
    for (int i = 1; i < n; i++){
        if (v[i-1] == v[i] - 1){
            sum += c[v[i]-1];
        }
    }
    cout << sum;
    return 0;
} 


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

int main() {
    string S;
    cin >> S;
    string messages = "No";
    string Ss = S;
    reverse(Ss.begin(), Ss.end());
    string S2 = S.substr(0, (S.size()-1)/2);
    string Ss2 = S2;
    reverse(Ss2.begin(), Ss2.end());
    string S3 = S.substr((S.size() + 2)/2, S.size()-1);
    string Ss3 = S3;
    reverse(Ss3.begin(), Ss3.end());
    if(S == Ss && S2 == Ss2 && S3 == Ss3) {
        messages = "Yes";
    }
    cout << messages << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int a,b,c,d;
  string op;
  cin>>a>>op>>b;
  if(op=="+"){c=a+b;cout<<c;}
  if(op=="-"){d=a-b;cout<<d;}
  return 0;
}

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  int ans = 0;
  while(N > 0){
    if(N % 10 == 2) ans++;
    N /= 10;
  }
  cout << ans << endl;
  return 0;
}


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


long long int ans, x, n;
long long int a[100001];
int main() {

    cin >> n;
    bool foundZero = false;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] == 0)
            foundZero = true;
    }
    if (foundZero) {
        cout << 0;
        return 0;
    }
    ans = a[1];
    for (int i = 2; i <= n; i++) {
        long long int dif = 1000000000000000000/ans;
        if (a[i] > dif) {
            cout << -1;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  COUT(3 * N * N);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,A,B;
  long long int count,ama;
  cin >> N >> A >> B;
  
  count = N / (A+B);
  ama = N % (A+B);
  if(ama>A>0){
    ama = A;
  }
  
  cout << count*A+ama << endl;
}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
   
    int n;
    cin>>n;
    int a[n];
    int sum[3010]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum[a[i]]++;
    }
    sort(a,a+n);
    for(int i=1;i<3010;i++){
        sum[i] += sum[i-1];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ll u = a[j] - a[i];
            ll v = a[i] + a[j];
            ans += sum[v-1] - sum[u];
            if(v-1>=a[i] && a[i]>u) ans--;
            if(v-1>=a[j] && a[j]>u) ans--;
        }
    }
    ans /= 3;
    cout << ans << endl;

}

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int sum=0;
  rep(i,a){
    sum++;
    k--;
    if(k==0){
      cout<<sum<<endl;
      return 0;
    }
  }
  rep(i,b){
    k--;
    if(k==0){
      cout<<sum<<endl;
      return 0;
    }
  }
  rep(i,c){
    sum--;
    k--;
    if(k==0){
      cout<<sum<<endl;
      return 0;
    }
  }
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int dp[4000][16000];
int dp1[4000][16000];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    string s;
    int x, y;
    cin >> s >> x >> y;
    int x0 = 0, y0 = 0;
    int idx = 0;
    while (idx < SZ(s)) {
        if (s[idx] == 'T') break;
        x0++;
        idx++;
    }
    vector<PII> V;
    while (idx < SZ(s)) {
        int cnt = 0;
        while (idx < SZ(s) && s[idx] == 'T') {
            cnt++;
            idx++;
        }
        int cntF = 0;
        while (idx < SZ(s) && s[idx] == 'F') {
            cntF++;
            idx++;
        }
        V.pb({cnt, cntF});
    }
    VI hor, ver;
    bool horiz = 1;
    REP(i, SZ(V)) {
        if (horiz) {
            if (V[i].first % 2 == 1) {
                horiz = 0;
                ver.pb(V[i].second);
            } else {
                hor.pb(V[i].second);
            }
        } else {
            if (V[i].first % 2 == 1) {
                horiz = 1;
                hor.pb(V[i].second);
            } else {
                ver.pb(V[i].second);
            }
        }
    }
    int offset = 8000;
    dp[0][offset] = 1;
    FOR(i, 1, SZ(hor)) {
        FOR(j, 0, 15999) {
            if (dp[i - 1][j] == 1) {
                dp[i][j - hor[i - 1]] = 1;
                dp[i][j + hor[i - 1]] = 1;
            }
        }
    }
    dp1[0][offset] = 1;
    FOR(i, 1, SZ(ver)) {
        FOR(j, 0, 15999) {
            if (dp1[i - 1][j] == 1) {
                dp1[i][j - ver[i - 1]] = 1;
                dp1[i][j + ver[i - 1]] = 1;
            }
        }
    }
    if (dp[SZ(hor)][x - x0 + offset] == 1 && dp1[SZ(ver)][y - y0 + offset] == 1) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << endl;

}

Measured memory_bytes: 252416
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 100005
#define ld long double

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

ld dp[305][305][305];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll cnt[4]={0,0,0,0};
	ll x;
	for(int i=0;i<n;i++){
		cin>>x;
		cnt[x]++;
	}
	dp[0][0][0]=0;
	for(ll three=0;three<=n;three++){
		for(ll two=0;two<=n;two++){
			for(ll one=0;one<=n;one++){
				ld i=three,j=two,k=one;
				ll zero=n-two-three-one;
				ld zero1=zero,n1=n;
				if(zero<0 || zero==n) continue;
				ld value=1.0;
				if(three>0) value+=(i/n1)*dp[three-1][two+1][one];
				if(two>0) value+=(j/n1)*dp[three][two-1][one+1];
				if(one>0) value+=(k/n1)*dp[three][two][one-1];
				//dp[three][two][one]=(value)/(1-1.0*zero/n);
				dp[three][two][one]=(value*n1)/(i+j+k);
			}
		}
	}
	ld ans=dp[cnt[3]][cnt[2]][cnt[1]];
	cout.precision(20);
	cout<<ans;
}

Measured memory_bytes: 216076
//                                               KEEP GRINDING
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define PQ priority_queue
#define LB lower_bound  
#define UB upper_bound   

#define fr first
#define sc second
#define sz(x) (int)(x).size()

#define MAXN 200010
#define INF 9223372036854775807
int power(int x,int y,int m) { 
    if(y==0) return 1; 
    int p=power(x,y/2,m)%m; 
    p=(p*p)%m; 
    return (y%2==0)?p:(x*p)%m; 
} 
int fun(int x){
	if(x==0)return 0;
	int temp=x,cnt=0;
	while(temp){
		if(temp&1)cnt++;
		temp/=2;
	}
	return 1+fun( (x%cnt) );
}
void solve(){
	int n;	cin>>n;
	string s;	cin>>s;
	int a=0,b=0,cnt=0;
	f(i,0,n)if(s[i]=='1')cnt++;
	f(i,0,n)if(s[i]=='1')a=(a+power(2,n-i-1,max((int)1,cnt-1)))%max((int)1,cnt-1),b=(b+power(2,n-i-1,cnt+1))%(cnt+1);
	f(i,0,n){
		int rem;
		if(s[i]=='1')rem=(a-power(2,n-i-1,max((int)1,cnt-1))+cnt-1)%max((int)1,cnt-1);
		else rem=(b+power(2,n-i-1,cnt+1))%(cnt+1);
		cout<<( cnt==1 and s[i]=='1' ? 0 : 1+fun(rem) ) <<endl;
	}
}
signed main(){
    fastio
    int t=1;
    for(;t--;solve());
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long n, d, x1,x2, a =0, i;
  cin >> n >> d;

  for (i=1; i<= n; i++)
  {
    cin >> x1 >> x2;
    if (sqrt((x1*x1) + (x2*x2)) <= d ) a++;
  }
    cout << a << "\n";
  return 0;
}


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

int main()
{
    int N,change,note,change1;

    cin>>N;

    change=N%1000;
    if(change==0)
    {
        cout<<change;
    }
    else if(change1=1000-change)
    {
        cout<<change1;
    }


}


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

int main() {
long int x=0;
long int y=0;
int n=0;
int d=0;
int a=0;
long double far=0;
cin>>n>>d;

for(int i=0;i<n;i++)
{

cin >>x>>y;

 far=sqrt(x*x+y*y);
if(far<=d)
{
a++;
}
}
cout<<a;
}


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

int main() {
  int N;
  scanf("%d", &N);
  vector<int> h(N);
  for (int n = 0; n < N; ++n) scanf("%d", &h[n]);

  int cnt = 0;
  int max_h = *max_element(h.begin(), h.end());
  for (int i = 1; i <= max_h; ++i) {
    bool flag = false;
    for (int n = 0; n < N; ++n) {
      if (!flag && h[n] >= i) {
        ++cnt;
        flag = true;
      }
      else if (flag && h[n] < i) {
        flag = false;
      }
    }
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256