akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int leap_year(int year)
{
	if ( year % 4 == 0) {
		if ( year % 100 == 0) {
			if ( year % 400 == 0) {
				return 1;
			} else {
				return 0;
			}
		} else {
			return 1;
		}
	} else {
		return 0;
	}
}

int main()
{
	int a, b;
	int first = 0;
	while (true) {
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		if (first != 0) {
			std::cout << std::endl;
		}
		
		first = 1;
		int i = 0;
		
		for (int j = a; j <= b; j++) {
			if (leap_year(j) == 0) {
				i++;
			} else {
				std::cout << j << std::endl;
			}
		}
		if ( i == a - b + 1) {
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
n=int(input())
a=list(map(int,input().split()))
score=[a[0],0,a[1]+a[2],sum(a[3:])]
ans=10**18
i,k=1,3
for j in range(2,n-1):
  score[1]+=a[j-1]
  score[2]-=a[j-1]
  while abs(score[0]-score[1])>abs(score[0]+a[i]-score[1]+a[i]):
    score[0]+=a[i]
    score[1]-=a[i]
    i+=1
  while abs(score[2]-score[3])>abs(score[2]+a[k]-score[3]+a[k]):
    score[2]+=a[k]
    score[3]-=a[k]
    k+=1
  ans=min(ans,max(score)-min(score))
print(ans)

Measured memory_bytes: 24684
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifdef STOPIT
#define debug(...) 0
#else
#define debug(...)\
do {\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;\
} while (false)
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  double a, b, x;
  std::cin >> a >> b >> x;
  double full = a * a * b;
  double t = x < full / 2
    ? std::atan2(a * b * b, 2 * x)
    : std::atan2(2 * (full - x), a * a * a);
  t *= 45 / std::atan2(1, 1);
  std::cout << std::setprecision(10) << t << std::endl;
  return 0;
}


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

   if (a>0){
       cout << "Positive" <<endl;
   }else if (a<0&&b>0){
       cout << "Zero" << endl;
   }else if (b<0&&(b-a)%2==0){
       cout << "Negative" <<endl;
   }else {
       cout << "Positive" <<endl;
   }
}

Measured memory_bytes: 768
import sys
input=sys.stdin.readline

def main():
    n=int(input())
    Edges=[]
    for _ in range(n-1):
        u,v=map(int,input().split())
        if u>v:
            u,v=v,u
        Edges.append((u,v))
    ans=0
    for i in range(n):
        ans+=(i+1)*(n-i)
    for u,v in Edges:
        ans-=u*(n-v+1)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 83232
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>

typedef long long int ll;
using namespace std;
#define vl vector<ll>
#define vi vector<int>
#define ff first
#define ss second

void solve() {
    int n, W;
    cin >> n >> W;
    vl w(n);
    vl val(n);
    ll dp[n + 3][W + 3];
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> val[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = 0;
            if (i == 0) {
                if (j == w[0]) dp[i][j] = val[i];
            } else if (i > 0 && j - w[i] > 0) {
                dp[i][j] = max(dp[i - 1][j - w[i]] + val[i], dp[i - 1][j]);
            }else {
                dp[i][j] = max(dp[i][j] , dp[i-1][j]);
            }
        }
    }
//    for (int i = 0; i < n; i++) {
//        for (int j = 0; j <= W; j++) cerr << dp[i][j] << " ";
//        cerr << endl;
//    }

    ll ans = 0;
    for (int i = 0; i <= W; i++) ans = max(ans, dp[n - 1][i]);
    cout << ans << endl;
}


int main() {
#ifdef _DEBUG // place in cmake-build-debug folder
    freopen("in.txt", "r", stdin);
    freopen(
    for (int i = idx + 1; i < n; i++) {
        res[i] = min(res[i - 1], m[i]);
    }
    for (int i = idx - 1; i >= 0; i--) {
        res[i] = min(res[i + 1], m[i])"out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    int q;
//    cin >> q;
//    for (int i = 1; i <= q; i++) {
//        // cout << "Case #" << i << ": ";
//        solve();
//    }
    solve();

    return 0;
}

Measured memory_bytes: 79872
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

/////////////         qsortのラッピング

int qsort_int_compare_ascend(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int qsort_int_compare_descend(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
void ascendOrder(int size, int *array) {//sho-jun
	qsort(array, size, sizeof(int), qsort_int_compare_ascend);
}
void descendOrder(int size, int *array) {//ko-jun
	qsort(array, size, sizeof(int), qsort_int_compare_descend);
}

int main() {
	int N, *A, *B, *C;
	cin >> N;
	int M = (N + 1) / 2;
	A = new int[N];
	B = new int[M];
	C = new int[M];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i % 2 == 0) {
			B[i / 2] = A[i];
		}
	}
	ascendOrder(N, A);
	ascendOrder(M, B);

	for (int i = 0; i < M; i++) {
		C[i] = A[i * 2];
	}
	int count = 0;
	int b = 0, c = 0;
	while (b < M && c < M) {
		if (B[b] < C[c]) { b++; }
		else if (B[b] > C[c]) { c++; }
		else { count++; b++; c++; }
	}
	cout << M - count;
	return 0;
}

Measured memory_bytes: 1276
n = int(input())
a = [int(e) for e in input().split()]

my_sum = [0]
#print(my_sum)

tmp = 0
c = 0
for i in a:
    my_sum.append(my_sum[c]+i)
    c += 1

#print(my_sum)

my_sum2 = 0
length = len(my_sum)

c = 0
for i in a:
    my_sum2 += i * (my_sum[length-1] - my_sum[c+1])
    c += 1

print(my_sum2 % (10**9 + 7))


Measured memory_bytes: 30840
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  vector< pll > v(n);
  for(int i = 0; i < n; i++){
    v[i] = make_pair(b[i], a[i]);
  }
  sort(v.begin(), v.end());

  bool able = true;
  ll t = 0;
  for(int i = 0; i < n; i++){
    t += v[i].second;
    if(t > v[i].first){
      able = false;
      break;
    }
  }

  if(able) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;

int dp[101][4][4][4];

int main() {
	int N;
	cin >> N;
	dp[0][3][3][3] = 1;

	int mod = 1'000'000'007;
	for (int len = 0; len < N; len++)
	{
		for (int c1 = 0; c1 < 4; c1++)
		{
			for (int c2 = 0; c2 < 4; c2++)
			{
				for (int c3 = 0; c3 < 4; c3++)
				{
					if (dp[len][c1][c2][c3] == 0) continue;
					for (int a = 0; a < 4; a++)
					{
						if (a == 2 && c1 == 1 && c2 == 0) continue;
						if (a == 2 && c1 == 0 && c2 == 1) continue;
						if (a == 1 && c1 == 2 && c2 == 0) continue;
						if (a == 2 && c1 == 1 && c3 == 0) continue;
						if (a == 2 && c2 == 1 && c3 == 0) continue;

						dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
						dp[len + 1][a][c1][c2] %= mod;
					}
				}
			}
		}
	}

	int ans = 0;

	for (int c1 = 0; c1 < 4; c1++)
	{
		for (int c2 = 0; c2 < 4; c2++)
		{
			for (int c3 = 0; c3 < 4; c3++)
			{
				ans += dp[N][c1][c2][c3];
				ans %= mod;
			}
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int i,j,n,k,key;
  int A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  for(i=0;i<n;i++){
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    for(k=0;k<n;k++){
      if(k!=n-1) printf("%d ",A[k]);
      else printf("%d\n",A[k]);
    }
  }
  return 0;
}





Measured memory_bytes: 2056
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
a = li()

stl = sum(a) / (4*m)
cnt = 0
for i in a:
    if i >= stl:
        cnt+=1
if cnt >= m:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
from itertools import product
import numpy as np

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = -1

for books in product(choose, repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if books[i]:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

if min_price == -1:
    print(-1)
else:
    print(min_price)


Measured memory_bytes: 27240
#include <stdio.h>
int main(){
    int a,b,c,i,total;
    scanf("%d %d %d", &a, &b, &c);
    for (i=a;i<=b;i++){
        if ( c % i == 0 ){
            total++;
        }
    }
    printf("%d\n", total);
    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll>a(n), b(n);
  rep(i, 0, n)cin >> a[i];
  ll s = a[0];
  rep(i, 1, n)s= s^a[i];
  rep(i, 0, n)b[i] = s^a[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(a==b)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 4732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		int tmp;

		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;

			tmp = values[a];
			values[a] = values[b];
			values[b] = tmp;
		}
		for (int i = 0; i < w; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26208
N = int(input())
List_N = [i for i in range(1,N+1)]
ODD_N = List_N[::2]
special_number = 0
for i in ODD_N:
    cnt = 0
    for j in range(1, int(i)+1):
        if int(i) % j == 0:
            cnt += 1
    if cnt == 8:
        special_number += 1
print(special_number)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

N = inputI()
A = inputIL()
A.sort()

print(A[-1]-A[0])

Measured memory_bytes: 38384
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		for(int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		int k = sc.nextInt();
		
		//for(int i = 1; i < 5; i++) {
			if(a[4] - a[0] > k) {
				System.out.println(":(");
				return;
			}
		//}
		System.out.println("Yay!");
	}
}


Measured memory_bytes: 22100
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    x = 0
    for a in A: x ^= a
    ans = []
    for a in A:
        ans.append(a ^ x)
    print(*ans)


    return

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;
ll n, a, b;

ll tich(ll a, ll b)
{
    ll t = 1;
    for (ll i = a; i <= b; ++i) t = t * i % MOD;
    return t;
}

ll Pow(ll a, ll n)
{
    if (n == 0) return 1;
    if (n == 1) return a;
    ll tmp = Pow(a, n/2);
    tmp = tmp * tmp % MOD;
    if (n % 2 != 0) tmp = tmp * a % MOD;
    return tmp;
}

ll C(ll n, ll k)
{
    ll C = 1;
    ll tu = tich(n-k+1, n);
    ll mau = Pow(tich(1, k), MOD-2);
    return tu * mau % MOD;
}

int main()
{
    cin >> n >> a >> b;
    ll ans = (Pow(2, n) - C(n, a) - C(n, b) - 1) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans;
    return 0;
}


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

bool prime[1000000];

int main(void) {
  for (int i = 0; i < 1000000; i++) {
    prime[i] = true;
  }
  prime[0] = prime[1] = false;
  for (int i = 2; i*i < 1000000; i++) {
    if (prime[i] == true) {
      for (int j = 2; i*j < 1000000; j++) {
        prime[i*j] = false;
      }
    }
  }

  while (1) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }

    long long sum = 0;
    for (int i = 0; n > 0 && i < 1000000; i++) {
      if (prime[i]) {
        sum += i;
        n--;
      }
    }  
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9
 
signed main()
{
    int n;
    cin >> n;
 
    map<int, int> mp;
 
    int a;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        ans += mp[i - a];
        mp[i + a]++;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 26308
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s;
  cin >> s;
  string t = "AKIHABARA";
  auto dp = vect(s.size() + 1, vect(t.size() + 1, 0));
  dp[0][0] = dp[0][1] = 1;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) {
      if (s[i] == t[j]) dp[i + 1][j + 1] |= dp[i][j];
      if (t[j] == 'A') { dp[i + 1][j + 1] |= dp[i + 1][j]; }
    }
  }
  // for (auto &col : dp) dmp(col);
  if (dp[s.size()][t.size()] == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
        
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    else:
        ret = 0

    for c in '753':
        ret += dfs(s + c)
    return ret
    
    
print(dfs('0'))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

int main(void) {
	using namespace std;
	int N;
	long long int b = 2;
	long long int res = 1;
	long long int tmp;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		tmp = res;
		res = res + b;
		b = tmp;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

x = Counter(d)
y = Counter(t)

res = True
for p,q in y.items():
    if p not in x.keys():
        res = False
        break
    elif x[p] < q:
        res = False
        break
print('YES' if res else 'NO')

Measured memory_bytes: 57056
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			n=n>2000?4000-n:n;
			int a=1;
			int b=3;
			int c=3;
			for(int i=0;i<n;i++){
				a+=b;
				b+=c;
				if(i<998){
					c++;
				}else{
					c-=3;
				}
			}
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 18752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int x, y, ans = 10000000000;
    cin >> x >> y;
    if (x <= y) ans = min(ans, y-x);
    if (-x <= y) ans = min(ans, y+x+1);
    if (x <= -y) ans = min(ans, -y-x+1);
    if (-x <= -y) ans = min(ans, -y+x+2);
    printf("%d\n", ans);
    return 0;
}

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

using ll = long long;

using namespace std;

struct query {
    int a, b, c, d;
};

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    query qs[q];
    for (int i=0, ai, b, c, d; i<q; i++) {
        cin >> ai >> b >> c >> d;
        ai--; b--;
        qs[i] = {ai, b, c, d};
    }
    int a[10];
    int ans = 0;
    for (a[0]=1;    a[0]<=m; a[0]++) 
    for (a[1]=a[0]; a[1]<=m; a[1]++)
    for (a[2]=a[1]; a[2]<=m; a[2]++) 
    for (a[3]=a[2]; a[3]<=m; a[3]++) 
    for (a[4]=a[3]; a[4]<=m; a[4]++) 
    for (a[5]=a[4]; a[5]<=m; a[5]++) 
    for (a[6]=a[5]; a[6]<=m; a[6]++) 
    for (a[7]=a[6]; a[7]<=m; a[7]++) 
    for (a[8]=a[7]; a[8]<=m; a[8]++) 
    for (a[9]=a[8]; a[9]<=m; a[9]++) {
        int cnt = 0;
        for (auto &qi:qs) {
            if (a[qi.b] - a[qi.a] == qi.c) {
                cnt += qi.d;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int K=317000,OO=1e18;
int32_t main(){
    int n,s;
    cin>>n>>s;
    int ans=OO;
    for(int b=2;b<=K;++b){
        int f=0,x=n;
        while(x){
            f+=x%b;
            x/=b;
        }
        if(f==s)upn(ans,b);
    }
    for(int c=1;c<K;++c){
        if((n-s)%c==0){
            int b=(n-s+c)/c;
            if(b>0&&c*b<=n&&(c+1)*b>n&&n/b<b&&n/b+n%b==s)upn(ans,b);
        }
    }
    if(n==s)upn(ans,n+1);
    if(ans==OO)ans=-1;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3664
def gcd(x, y)
  r = x % y
  return y if r.zero?

  gcd(y, r)
end

def lcm(a, l)
  return a if l.size.zero?

  b = l[0]
  n = (a * b) / gcd(a, b)
  lcm(n, l[1, l.size - 1])
end

n = gets.to_i
ts = n.times.map { gets.to_i }

puts lcm(ts[0], ts[1, ts.size - 1])


Measured memory_bytes: 1788
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 1;i <= n;i++){
			ans += i;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> a(N);
  for (i64 i = 0; i < N; i++)
    cin >> a[i];
  i64 sum = 0;
  for (i64 i = 0; i < N; i++)
    sum ^= a[i];
  for (i64 i = 0; i < N; i++)
    cout << (sum ^ a[i]) << " \n"[i + 1 == N];
  return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(vector<T> v){
    cout << "#vdebug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    string s;
    cin >> n >> s;
    int slen = s.length();

    int white = 0, black = 0;
    int wb;
    bool flg;
    if(s[0] == '.'){
        flg = true;
        wb = 1<<1;
    }else{
        flg = false;
        wb = 1<<0;
        black++;
    }

    vector<int> white_v, black_v;
    reps(i, 1, slen-1){
        if(flg && s[i] == '#'){
            flg = false;
            wb = 1<<0;
            black++;
            continue;
        }
        if(flg) continue;
        if(s[i] == '.'){
            if(wb & 1<<1){
                white++;
            }else{
                wb = 1<<1;
                white++;
            }
        }else{
            if(wb & 1<<0){
                black++;
            }else{
                white_v.push_back(white);
                black_v.push_back(black);
                wb = 1<<0;
                black=1, white=0;
            }
        }
    }
    if(s[slen-1] == '.'){
        white_v.push_back(white);
        black_v.push_back(black);
    }

    int w_sum[200010];
    int b_sum[200010];
    int sz = black_v.size();
    w_sum[sz] = b_sum[0] = 0;
    rep(i, sz){
        b_sum[i+1] = b_sum[i] + black_v[i];
        w_sum[sz-i-1] = w_sum[sz-i] + white_v[sz-i-1];
    }

    ll res = inf;
    reps(i, 0, sz){
        ll sum = w_sum[i] + b_sum[i];
        chmin(res, sum);
    }

    cout << res << endl;

    // vdeb(white_v);
    // vdeb(black_v);
    //adeb(w_sum, sz);
    //adeb(b_sum, sz);

    return 0;
}


Measured memory_bytes: 2448
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int w = int.Parse(input[1]);
    long[,] vertexes = new long[n,2];
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
    }
    long[,] dp = new long[n+1, w+1];//x個見て、重さyの時の価値の最大値

    for(int i = 1; i <= n; i++)
    {
      for(int j = 0; j <= w; j++)
      {
        dp[i,j] = Math.Max(dp[i,j], dp[i-1,j]);//取らない

        if(j-vertexes[i-1,0] >= 0)
          dp[i,j] = Math.Max(dp[i,j], dp[i-1,j-vertexes[i-1,0]] + vertexes[i-1,1]);//取る
      }
    }
    long answer = 0;
    for(int i = 0; i <= w; i++)
    {
      answer = Math.Max(answer, dp[n,i]);
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 90848
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,s.size()){
        s[i] = ((s[i] - 'A' + n) % 26) + 'A';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

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

    return 0;
}

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

using namespace std;

const int INF = 1 << 30;
const vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, K;
  cin >> H >> W >> K;
  int sx, sy, gx, gy;
  // cin >> sx >> sy >> gx >> gy;
  cin >> sy >> sx >> gy >> gx;
  sx--, sy--, gx--, gy--;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  vector<vector<int>> D(H, vector<int>(W, INF));
  D[sy][sx] = 0;
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      que;
  que.push(make_pair(0, make_pair(sy, sx)));
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int d = q.first, y = q.second.first, x = q.second.second;
    if (d > D[y][x]) continue;
    for (int i = 0; i < 4; i++) {
      int ny = y, nx = x;
      for (int k = 0; k < K; k++) {
        ny += dy[i], nx += dx[i];
        if (ny < 0 || ny >= H || nx < 0 || nx >= W) break;
        if (S[ny][nx] == '@') break;
        if (D[ny][nx] < D[y][x] + 1) break;
        if (chmin(D[ny][nx], d + 1)) {
          que.push(make_pair(D[ny][nx], make_pair(ny, nx)));
        }
      }
    }
  }
  if (D[gy][gx] == INF) {
    cout << -1 << '\n';
  } else {
    cout << D[gy][gx] << '\n';
  }
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" << endl;
    }else if(a>b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3096
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int a = 0, b = 0;
  st S;
  ci(S);
  for(int i = 0; i < sz(S); i += 2){
    if(S.at(i) == '1'){
      a++;
    }
    else{
      b++;
    }
  }
  for(int i = 1; i < sz(S); i += 2){
    if(S.at(i) == '0'){
      a++;
    }
    else{
      b++;
    }
  }
  co(min(a, b));
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	for(auto i:A){
		if(i%2==0 && i%3!=0 && i%5!=0){
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

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;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  int left = max(a,c), right = min(b,d);
  int ans = right - left;
  if(ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  string s;
  cin >> s;

  vi a(n);
  rep(i,0,n) if (s[i] == 'W') a[i] = 1;

  int ans  =0;
  vvi occ(2);
  rep(i,0,n) occ[a[i]].pb(i);

  int i = sz(occ[0])-1, j = 0;
  while (j < sz(occ[1]) and i >= 0) {
    if (occ[1][j] > occ[0][i]) break;
    ++ans;
    swap(a[occ[1][j]], a[occ[0][i]]);
    ++j;
    --i;
  }

  int rem = 0;
  rep(i,0,n-1) {
    if (a[i] == 1) ++rem;
    if (a[i] == 0) {
      ans += rem;
      rem = 0;
    }
  }

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

Measured memory_bytes: 5612
import java.io.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        String s[]=bu.readLine().split(" ");
        int sh=Integer.parseInt(s[0]),w=Integer.parseInt(s[1]);
        if(sh<=w) System.out.print("unsafe");
        else System.out.print("safe");
    }
}


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

struct st
{
    int id;
    int num;
    bool operator<(const st& p)
    {
        return num<p.num;
    }
};
st a[100000+10];
int main()
{
    int N;
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        a[i].id = i;
        cin>>a[i].num;
    }
    sort(a+1,a+N+1);
    for(int i=1;i<=N;i++)
        cout<<a[i].id<<" ";
}


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

int v[22][22], W, H, turn, m;

void dfs(int h, int w){
    if(turn < 11){
        turn++;
    if(v[h][w+1]==0 || v[h][w+1]==3){
        for(int i=1; w+i<W; i++){
            if(v[h][w+i]==3 && turn<m){
                m = turn;
                break;
            }
            if(v[h][w+i]==1){
                v[h][w+i]=0;
                dfs(h, w+i-1);
                v[h][w+i]=1;
                break;
            }
        }
    }
    if(v[h][w-1]==0 || v[h][w-1]==3){
        for(int i=1; w-i>=0; i++){
            if(v[h][w-i]==3 && turn<m){
                m = turn;
                break;
            }
            if(v[h][w-i]==1){
                v[h][w-i]=0;
                dfs(h, w-i+1);
                v[h][w-i]=1;
                break;
            }
        }
    }
    if(v[h+1][w]==0 || v[h+1][w]==3){
        for(int i=1; h+i<H; i++){
            if(v[h+i][w]==3 && turn<m){
                m = turn;
                break;
            }
            if(v[h+i][w]==1){
                v[h+i][w]=0;
                dfs(h+i-1, w);
                v[h+i][w]=1;
                break;
            }
        }
    }
    if(v[h-1][w]==0 || v[h-1][w]==3){
        for(int i=1; h-i>=0; i++){
            if(v[h-i][w]==3 && turn<m){
                m = turn;
                break;
            }
            if(v[h-i][w]==1){
                v[h-i][w]=0;
                dfs(h-i+1, w);
                v[h-i][w]=1;
                break;
            }
        }
    }
    turn--;
    }
}

int main(void){
    int h1, w1;
    while(cin>>W>>H){
        if(W==0 && H==0)    break;
        m = 11;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cin >> v[i][j];
                if(v[i][j]==2){
                    h1=i; w1=j;
                    v[i][j]=0;
                }
            }
        }
        turn = 0;
        dfs(h1, w1);
        if(m==11)cout << -1 << endl;
        else cout << m << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int N, K, T;
int ask(int a) {


	cout << a + 1 << endl << flush;
	string res;
	cin >> res;
	if (res[0] == 'Y')return 1;
	if (res == "No")return -1;
	if (res == "Near")return 0;

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

	cin >> N >> K;

	T = max((int)0, N - 9);


	vector<pair<int, int> > es;

	for (int i = 0; i < T; i++) {
		for (int j = 0; j < 9; j++) {
			if (i & (1 << j)) {
				es.emplace_back(i, T + j);
			}
		}
	}
	cout << es.size() << endl;
	for (int i = 0; i < es.size(); i++) {
		cout << es[i].first + 1 << " " << es[i].second + 1 << endl;
	}
	cout << flush;

	for (int t = 0; t < K; t++) {
		int X = 0;
		int r;
		int ans = 0;
		for (int i = T; i < N; i++) {
			r = ask(i);
			if (r == 1)break;
			else if (r == 0) {
				ans += (1 << (i - T));
			}
		}
		if (r != 1) {
			ask(ans);
		}



	}


}


Measured memory_bytes: 3304
#include <iostream>

using namespace std;

int main(void){
    int i,j,k,l;
    int data;
    
    while(true){
        cin>>data;
        if(data==0)break;
        
        k=0;
        while(data!=1){
            if(data%2==0){
                data=data/2;
            }
            else{
                data=data*3+1;
            }
            k++;
        }
        cout<<k<<endl;
    }
    return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

struct UnionFind{
  vector<ll> d;
  UnionFind(ll n=0): d(n,-1){}
  ll find(ll x){
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(ll x,ll y){
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
  ll size(ll x) {
    return -d[find(x)];
  }
};

int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> a(m);
  vector<ll> b(m);
  rep(i,m) cin >> a[i] >> b[i];
  a.push_back(0);
  b.push_back(0);
  reverse(a);
  reverse(b);
  vector<ll> ans(m+1,0);
  ans[0] = n*(n-1)/2;
  UnionFind tree(n+1);
  rep1(i,m){
    if(!tree.same(a[i],b[i])){
      ans[i] = ans[i-1] - tree.size(a[i])*tree.size(b[i]);
    }else ans[i] = ans[i-1];
    tree.unite(a[i],b[i]);
  }
  reverse(ans);
  rep1(i,m) cout << ans[i] << endl;
}


Measured memory_bytes: 4448
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n,a,b;
  cin >> n;
  if(n==1){
    cout << "Hello World\n";
  }else{
    cin >>a >> b;
    cout << a + b<<endl;
  }
}


Measured memory_bytes: 256
n, x, y = map(int, input().split())
ans = list(0 for _ in range(n+1))
for i in range(1, n):
    for j in range(i+1, n+1):
        if i < x:
            if j <=x:
                ans[j-i] += 1
            elif x < j < y:
                p = min(j-x, (y-j)+1)
                ans[x-i+p] += 1
            else:
                pos = (x - i) + 1 + (j - y)
                ans[pos] += 1
        elif y < i:
            ans[j-i] += 1
        else:
            if j < y:
                p = (i - x) + (y - j) + 1
                if (j - i) < p:
                    ans[j-i] += 1
                else:
                    ans[p] += 1
            else:
                p = min(y-i, (i - x) + 1)
                ans[p + (j - y)] += 1
for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;
 

int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int a, b, c; cin >> a >> b >> c;
	print(max(a, max(b, c)) - min(a, min(b, c)));
	return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 2e10 + 7;
constexpr ll MOD = 1e9 + 7;


int main()
{
    ll a, b, q;
    ciosup;
    cin >> a >> b >> q;
    vector<ll> s(a+2), t(b+2);
    FOR(i,1,a+1) cin >> s[i];
    FOR(i,1,b+1) cin >> t[i];
    s[0] = t[0] = -INF;
    s[a+1] = t[b+1] = INF;

    ll x;
    REP(i,q){
        cin >> x;
        auto iters = lower_bound(s.begin(), s.end(), x);
        auto itert = lower_bound(t.begin(), t.end(), x);
        ll y;
        y = max(*iters - x, *itert - x);
        y = min(y, max(x - *(iters - 1), x - *(itert - 1)));
        y = min(y, 2 * (*iters - x) + (x - *(itert - 1)));
        y = min(y, (*iters - x) + 2 * (x - *(itert - 1)));
        y = min(y, 2 * (*itert - x) + (x - *(iters - 1)));
        y = min(y, (*itert - x) + 2 * (x - *(iters - 1)));
        cout << y << endl;
    }
}

Measured memory_bytes: 2944
package main

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

func main() {
	S := nextString()

	if S == "AAA" || S == "BBB" {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

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

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi d(n);
    rep(i,n)cin>>d[i];
    d.pb(0);
    SORT(d);
    vi t;
    rep(i,n+1){
        if(i%2)t.pb(d[i]);
        else t.pb((24-d[i])%24);
    }
    SORT(t);
    int m=100;
    REP(i,1,n)m=min(m,t[i]-t[i-1]);
    cout<<m<<endl;
}

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

using namespace std;

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

    long long sum = 0;
    map<long long, long long> mp;
    mp[0] = 1;

    for (int i = 1; i <= n; ++i) {
        int a;
        cin >> a;
        sum += a;
        if (mp.find(sum) == mp.end()) mp[sum] = 0;
        mp[sum]++;
    }

    long long ans = 0;
    for (auto x:mp) {
        ans += x.second * (x.second - 1) / 2;
    }

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

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

int main(int argc, char const *argv[])
{
    int max_1, current_1, current_2;
    cin >> max_1 >> current_1 >> current_2;

    int rest_1 = max_1 - current_1;
    if (rest_1 >= current_2)
    {
        current_2 = 0;
    }
    else
    {
        current_2 -= rest_1;
    }
    cout << current_2 << endl;
    return 0;
}


Measured memory_bytes: 256