akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main()
{
    double x1, y1, x2, y2, result, distance;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

    result = (((x2-x1)*(x2-x1)) + ((y2-y1)*(y2-y1)));
    distance = sqrt(result);
    printf("%lf\n", distance);

    return 0;
}





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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    ll N;
    cin >> N;
    ll A[N],ans=N,count=1;
    for(ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A,A+N);
    for(ll i = 0; i < N-1; i++) {
        if(A[i]*2 >=  A[i+1]) {
            A[i+1] += A[i];
            count++;
        }else {
            A[i+1] += A[i];
            ans -= count;
            count = 1;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int a[10] = { 99, 111, 222, 333, 444, 555, 666, 777, 888, 999};
    for (int i = 0; i < 10; i++) {
        if ( N <= a[i] && N > a[i-1]) {
            cout << a[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def get_z(y, x): # y/x (mod 1000000007)
    inv_x = pow(x, MOD - 2, MOD)
    return y * inv_x % MOD

def comb_mod(n, k):
    if n == 0:
        return 0
    k = min(k, n - k)
    a = 1
    b = 1
    for i in range(k):
        a = a * (n - i) % MOD
        b = b * (i + 1) % MOD
    ret = get_z(a, b)
    return ret


def solve(X: int, Y: int):
    d = X - Y
    s = (X + Y) // 3
    x = (s + d) // 2
    y = (s - d) // 2
    if (X + Y) % 3 or (s + d) % 2 or x < 0 or y < 0 \
            or x * 2 + y != X or x + y * 2 != Y:
        print(0)
        return
    ret = comb_mod(x + y, min(x, y))
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100002
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  char bin[MAX];
  scanf("%s", bin);

  int len = strlen(bin);
  lli dp[MAX][2];
  dp[0][0] = 1;
  dp[0][1] = 0;
  rep(i, len)
  {
    if (bin[i] == '0')
    {
      dp[i + 1][0] = dp[i][0];           // a + b == 0
      dp[i + 1][1] = dp[i][1] * 3 % MOD; // a + b == 0 or 1
    }
    else
    {
      dp[i + 1][0] = 2 * dp[i][0] % MOD;              // a + b == 1
      dp[i + 1][1] = (dp[i][0] + dp[i][1] * 3) % MOD; // a + b == 0 or 1
    }
  }
  lli ans = (dp[len][0] + dp[len][1]) % MOD;
  printf("%d\n", ans);
  return 0;
}


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

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

	long int bis = 1;
	if (a + 1 >= b) {
		bis += k;
	}
	else if (a + 1 < b) {
		for (int i = 1; i < a; i++) {
			bis += 1;
			k -= 1;
		}

		while (k >= 2)
		{
			bis -= a;
			bis += b;
			k -= 2;
		}
		if (k == 1) {
			bis += 1;
		}
	}
	cout << bis << endl;
	return 0;
}


Measured memory_bytes: 256
c = [[int(i) for i in input().split()] for _ in range(3)]
flag = False
for i in range(-100,100):
    for j in range(-100,100):
        for k in range(-100,100):
            a11 = c[0][0] - i
            a12 = c[0][1] - j
            a13 = c[0][2] - k
            if  a11!=a12 or a12!=a13:
                continue
            a21 = c[1][0] - i
            a22 = c[1][1] - j
            a23 = c[1][2] - k 
            if a21!=a22 or a22!=a23:
                continue
            a31 = c[2][0] - i
            a32 = c[2][1] - j
            a33 = c[2][2] - k 
            if a31!=a32 or a32!=a33:
                continue
            flag = True
print('Yes' if flag else 'No')
                

Measured memory_bytes: 41708
import collections as cl
n = int(input())


# N: 素因数分解する数

res = []
x = n
y = 2
while y*y <= x:
    while x % y == 0:
        res.append(y)
        x //= y
    y += 1
if x > 1:
    res.append(x)
res = cl.Counter(res)
#print(res)

ans = 0

for i in res.values():
    temp = 1
    while True:
        i -= temp
        if i >= 0:
            ans +=1
            temp += 1
        else:
            break

print(ans)

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

int main(){
    int N,D; cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    for (int i=0; i<N; i++){
        for (int j=0; j<D; j++){
            cin >> X[i][j];
        }
    }
    int ans=0;
    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            int part=0;
            int sum=0;
            for (int k=0; k<D; k++){
                part=abs(X[i][k]-X[j][k]);
                sum+=part*part;
            }
            
            bool flag=false;
            for (int k=0; k<=sum; k++){
                if (k*k==sum){
                    flag=true;
                }
            }
            
            if (flag) ans++;
        }
    }                    
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	sort(v.begin(), v.end());

	int R = N / 2, L = R - 1;
	int ret = v[R] - v[L];

	cout << ret << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int n,k,mod;
void upd(int&x,int y){x=(x+y)%mod;}
int main(){
	cin>>n>>k>>mod;
	if(k%2==0){
		static int f[155][155];
		k=k/2+1;
		f[0][0]=1;
		for(int i=1;i<=n+1;i++){
			f[i][0]=f[i-1][0];
			for(int j=1;j<k;j++){
				f[i][j]=f[i-1][j-1];
				upd(f[i][0],f[i-1][j]);
			}
		}
		cout<<1ll*f[n/2+1][0]*f[n-n/2+1][0]%mod<<"\n";
		return 0;
	}else{
		static int f[155][155][155][2];
		f[0][0][0][0]=1;
		for(int i=0;i<=n;i++){
			auto chk=[&](int x){
				return 1<=x&&x<=n;
			};
			int a=chk(2*i+2-k),b=chk(2*i+2);
			for(int s=0;s<=n;s++)
				for(int r=0;r<=n;r++){
					for(int o=0;o<2;o++){
						if(o&&s>k+1)continue;
						upd(f[i+1][0][0][0],f[i][s][r][o]);
						if(a)upd(f[i+1][s+1][0][o],f[i][s][r][o]);
						if(b)upd(f[i+1][0][r+1][0],f[i][s][r][o]);
						if(a&&b){
							if(o)upd(f[i+1][s+1][r+1][o],f[i][s][r][o]);
							else upd(f[i+1][r+2][r+1][1],f[i][s][r][o]);
						}
					}
				}
		}
		cout<<f[n+1][0][0][0]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 28544
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    while(true){
        int A[2];
        cin >> A[0] >> A[1];
        
        if(A[0]==0 && A[1]==0){
            break;
        }
        else{
            sort(A,A+2);
            cout<<A[0]<<" "<<A[1]<<endl;
        }
        
    }
    return 0;
}




Measured memory_bytes: 3112
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7')Yes;
  else No;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122


int main() {
    string s;
    cin >> s;
    int len = s.size();
    int cnt_0 = 0;
    int cnt_1 = 0;
    rep(i, 0, len) {
        if (s[i] == '0') cnt_0++;
        else cnt_1++;
    }
    cout << 2 * min(cnt_0, cnt_1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  unsigned long long int n, k;
  cin >> n >> k;
  unsigned long long int sum = 0;
  unsigned long long int max = 0;
  unsigned long long int min = 0;
  for (unsigned long long int i = k; i <=n+1; i++){
    min = (1+i)*i /2;
    max= ((n+1)+(n+1-i+1))*i /2 ;
    sum = sum + max - min +1;
  }
  unsigned long long int mod = 1000000007; 
  cout << sum%mod << endl;
  
  
  return 0;
}

Measured memory_bytes: 3624
n,c=map(int,input().split())
d=[[0]*c for _ in [0]*int(1e5)]
for _ in range(n):
    s,t,c=map(int,input().split())
    for j in range(s-1,t):
        d[j][c-1]=1

ans=1
for i in range(int(1e5)):
    s=sum(d[i])
    if s>ans:
        ans=s

print(ans)

Measured memory_bytes: 80092
#pragma region

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (register int i = (begin); i < (end); i++)
#define IFOR(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define MOD 1000000007
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  REP(i, vec.size())
  i == 0
      ? os << vec[i]
      : os << ", " << vec[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &deq) {
  os << "deq[ ";
  REP(i, deq.size())
  i == 0
      ? os << deq[i]
      : os << ", " << deq[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}

#pragma endregion
#define MAX 2147483647

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

  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  REP(i, N) {
    int a;
    cin >> a;
    A[i] = make_pair(a, i + 1);
  }
  sort(ALL(A));
  REP(i, N)
  cout << A[i].second << " ";
}


Measured memory_bytes: 1664
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
   int n,sumb=0,suma=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=n-1 ;i>=0;i-=2)
    {

        suma+=a[i];

    }
     for(int i=n-2 ;i>=0;i-=2)
    {

        sumb+=a[i];

    }
    cout<<suma-sumb;


     return 0;
}


Measured memory_bytes: 256
count = 0
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)


N.times do |i|
  if A[i] >= B[i]
    count += B[i]
  else
    count += A[i]
    B[i] -= A[i]
    if A[i+1] >= B[i]
      count += B[i]
      A[i+1] -= B[i]
    else             
      count += A[i+1]
      A[i+1] = 0
    end
  end
end
puts count


Measured memory_bytes: 15388
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int cnt = 0;
    F0R(i, s.sz()) if(s[i] == 'o') cnt++;
    if(15 - s.sz() + cnt >= 8) cout << "YES";
    else cout << "NO"; 
    return 0;
}

Measured memory_bytes: 256
inp = list(map(int, input().split()))
N, K = inp[0], inp[1]

arr = list(map(int, input().split()))
zero_ind = len(arr)
for i, e in enumerate(arr):
    if e > 0:
        zero_ind = i
        break
    elif e == 0:
        zero_ind = i + 1
        arr = arr[:i] + arr[i+1:]
        K -= 1
        break
if K == 0:
    print(0)
else:
    # 右へ
    min_val = (10**8) * K
    for i in range(1,K+1):
        # i個0以上からK-i個0未満から
        if zero_ind + i - 1 >= len(arr) or zero_ind - (K - i) < 0:
            continue
        if i == K:
            val = arr[zero_ind + i - 1]
        else:
            val = 2 * arr[zero_ind + i - 1] - arr[zero_ind - (K - i)]
        if min_val > val:
            min_val = val

    # 左へ
    for i in range(1,K+1):
        # i個0以上からK-i個0未満から
        if zero_ind + K - i - 1 >= len(arr) or zero_ind - i < 0:
            continue
        if i == K:
            val = -1 * arr[zero_ind - i]
        else:
            val = arr[zero_ind + K - i - 1] - 2 * arr[zero_ind - i]
        if min_val > val:
            min_val = val

    print(min_val)

Measured memory_bytes: 14480
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut edges = vec![vec![]; n + 1];
    for edge_id in 0..n - 1 {
        let vertex_a = get!(usize);
        let vertex_b = get!(usize);
        edges[vertex_a].push(edge_id);
        edges[vertex_b].push(edge_id);
    }
    let color_count = edges
        .iter()
        .map(Vec::len)
        .max()
        .unwrap();
     
     let mut edge_color = vec![0; n - 1];
     
     for vertex in 1..n + 1 {
         let mut used_color = vec![false; color_count + 1];
         for &edge_id in &edges[vertex] {
             used_color[edge_color[edge_id]] = true;
         }
         let mut color_id = 1;
         for &edge_id in &edges[vertex] {
             if edge_color[edge_id] == 0 {
                 while used_color[color_id] {
                     color_id += 1;
                 }
                 edge_color[edge_id] = color_id;
                 color_id += 1;
             }
         }
     }
     
     println!("{}", color_count);
     for color_id in edge_color {
         println!("{}", color_id);
     }
}

Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e5;

vector<vector<ll> > G;
vector<ll> cnt;
const int INF = 1e9;
ll dist[max_n];
ll mod = 1e9 + 7;
int unip[max_n], unir[max_n];
int main(){
  int n,k;
  cin >> n >> k;
  int h[n];
  for(int i=0 ; i<n ; i++){
    cin >> h[i];
  }
  int dp[n];
  fill(dp, dp+n, INF);
  dp[0] = 0;
  ll sum = 0;
  for(int i=0 ; i<n ; i++){
    for(int j=1 ; j<=k && i>=j ; j++){
      dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
import itertools

N = int(input())

mod = 10 ** 9 + 7

dp = [[[[0 for i in range(0,4)] for j in range(0,4)] for k in range(0, 4)] for n in range(0, N + 1)]

dp[0][3][3][3] = 1

# A -> 0
# C -> 1
# G -> 2
# T -> 3

# invalids
# AGC -> 021
# GAC -> 201
# ACG -> 012
# A?GC -> 0?21
# AG?C -> 02?1

for len in range(0,N):
    for c1 in range(0,4):
        for c2 in range(0,4):
            for c3 in range(0,4):
                if dp[len][c1][c2][c3] == 0:
                    continue

                for a in range(0,4):
                    if (c2 == 0 and c3 == 2 and a == 1) or \
                      (c2 == 2 and c3 == 0 and a == 1) or \
                      (c2 == 0 and c3 == 1 and a == 2) or \
                      (c1 == 0 and c3 == 2 and a == 1) or \
                      (c1 == 0 and c2 == 2 and a == 1):
                        continue

                    dp[len + 1][c2][c3][a] += dp[len][c1][c2][c3]


res = 0
for c1 in range(0,4):
    for c2 in range(0,4):
        for c3 in range(0,4):
            res += dp[N][c1][c2][c3] % mod

print(res % mod)



Measured memory_bytes: 3444
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

std::map<char, int > mp[530004*2];
int N, Q;
int leafnum;

void update(char c, int k){
  // k番目の要素をcを追加
  k += leafnum-1;
  /*if (k>=500004*2){
    return;
    }*/
  mp[k][c]++;
  while(k>0){
    k=(k-1)/2;
    mp[k][c]++;
  }
  return;
}

void del(char c, int k){
  // k番目の要素をcを追加
  k += leafnum-1;
  mp[k][c]--;
  //printf("map[%d][%c]-- -> %d\n", k,c, mp[k][c]);
  if (mp[k][c]==0) mp[k].erase(c);
  while(k>0){
    k=(k-1)/2;
    mp[k][c]--;
    if (mp[k][c]==0) mp[k].erase(c);
  }
  return;
}

std::map<char, int> getkind(int k, int a, int b, int l, int r){
  //printf("getkind(%d, %d, %d, %d, %d) called\n", k, a, b, l, r);
  if (r<a || b<l){
    //printf("return None\n");
    return std::map<char, int >();
  } else if (a<=l && r<=b){
    //printf("return full\n");
    return mp[k];
  } else {
    //printf("return partial\n");
    std::map<char, int > mp1 = getkind(k*2+1, a, b, l, (l+r)/2);
    std::map<char, int> mp2 = getkind(k*2+2, a, b, (l+r)/2+1, r);
    //mp1.merge(mp2);
    mp1.insert(mp2.begin(), mp2.end());
    return  mp1;
  }
}


int main(){
  scanf("%d", &N);
  int depth=int(log2(N)+0.999999);
  leafnum=int(pow(2, depth) + 0.0001);
  //printf("depth=%d\n", depth);
  //printf("leafnum=%d\n", leafnum);
  std::string s;
  std::cin >> s;
  scanf("%d", &Q);
  std::vector<int > type(Q), l(Q), r(Q), I(Q);
  std::vector<char > c(Q);
  for (int i=0; i<Q; i++){
    //printf("i=%d\n", i);
    std::cin >> type[i];
    if (type[i]==1){
      std::cin >>  I[i] >> c[i];
      I[i]--;
    } else {
      std::cin >> l[i] >> r[i];
      l[i]--;
      r[i]--;
    }
  }
  
  for (int i=0; i<s.length(); i++){
    update(s[i],i);
  }
  //std::cout << log2(10) << std::endl;
  /*for (int i=0; i<=2*N; i++){
    printf("map[%d] size=%d\n", i, mp[i].size());
    }*/
  for (int i=0; i<Q; i++){
    if (type[i]==1){
      del(s[I[i]], I[i]);
      update(c[i], I[i]);
      s[I[i]]=c[i];
    } else {
      std::map<char, int> ans = getkind(0, l[i], r[i], 0, leafnum-1);
      //for (auto & entry : ans){
	//printf("%c: %d\n", entry.first, entry.second);
	//	}
      std::cout << ans.size() << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 164728
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    set<int64_t> numSet;
    rep(i,n){
        if(numSet.find(a.at(i)) == numSet.end()){
            numSet.insert(a.at(i));
        }else{
            numSet.erase(a.at(i));
        }
    }
    cout << numSet.size() << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
#ifdef CIN
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int x, y;

	cin >> x;

	y = x*x*x;

	cout << y <<endl;

	return 0;
}

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

namespace Question2
{
    class Program
    {
        static void Main(string[] args)
        {
            string strA = Console.ReadLine();
            string strB = Console.ReadLine();

            if (strA.Length > strB.Length)
            {
                Console.WriteLine("GREATER");
            }
            else if (strA.Length < strB.Length)
            {
                Console.WriteLine("LESS");
            }
            else
            {
                if (strA.CompareTo(strB) > 0)
                {
                    Console.WriteLine("GREATER");
                }
                else if (strA.CompareTo(strB) < 0)
                {
                    Console.WriteLine("LESS");
                }
                else
                {
                    Console.WriteLine("EQUAL");
                }
            }
        }
    }
}


Measured memory_bytes: 13280
L, R = map(int, input().split())

if L // 2019 < R // 2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    ans = float('inf')
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            m = i * j % 2019
            ans = min(ans, m)
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    string s;cin>>s;
    for(int i=0; i<s.size(); i++) cout<<'x';
    cout<<endl;


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void computeLPSArray(string pattern, int m, int lps[]){
    int len=0;
    lps[0]=0;   //lps[0] is always 0
    int i=1;
    while(i<m){
        if(pattern[i]==pattern[len]){
            len++;
            lps[i]=len;
            i++;
        }else{
            if(len!=0)
                len=lps[len-1];
            else{
                lps[i]=0;
                i++;
            }
        }
    }
}
void kmpSearch(string str,string pattern){
    int m=pattern.length();
    int n=str.length();
    int lps[m];  //longest prefix suffix array
    computeLPSArray(pattern,m,lps);
    int i=0; //text
    int j=0; //pattern
    bool found=0;
    while(i<n){
        if(pattern[j]==str[i]){
            i++;
            j++;
        }
        if(j==m){
            j=lps[j-1];
            found=1;
            break;
        }else if(i<n && pattern[j]!=str[i]){
            if(j!=0) j=lps[j-1];
            else i=i+1;
        }
    }
    if(!found)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str,pattern;
    while(cin>>str){
        pattern="AC";
        kmpSearch(str,pattern);
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

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


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KEYENCE2019_A solver = new KEYENCE2019_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class KEYENCE2019_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String[] c = new String[4];

            for (int i = 0; i < 4; i++) {
                c[i] = in.next();
            }

            Arrays.sort(c);

            if (String.join("", c).equals("1479")) {
                out.print("YES");
            } else {
                out.print("NO");
            }
        }

    }
}



Measured memory_bytes: 23764
package main

import "fmt"

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if (abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define pii pair<int, int>
#define MOD 1000000007
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
#define int long long

signed main()
{
    int N;
    cin >> N;
    vector<int> p(N + 2);
    FOR(i,0, N)
    {
        int tmp;
        cin >> tmp;
        tmp--;
        p[i] = tmp;
    }
    int ans = 0;
    FOR(i,0,N)
    {
        if (i == p[i])
        {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) ;
#endif


typedef long long ll;
typedef long double ld;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define X first
#define Y second
//#define debug(x) cerr << #x << " : " << (x) << " "
const double PI = 3.14159265358979323846;
const double eps = (1e-9);
//int isGreater(long double x, long double y)
//{
//    if (abs(x - y) < eps)
//        return 0;
//    if (x > y)
//        return 1;
//    return -1;
//}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,0,n)
        cin >> a[i];

    bool done = false;
    vector<int> b(n), rmv(n + 1);
    int op = 0;
    while(k-- && !done)
    {
        done = true;
        int cnt = 0;
        b.assign(n, 0);
        rmv.assign(n + 1, 0);
        for (int i = 0; i < n; ++i)
        {
            cnt++;
            cnt -= rmv[i];
            b[i] += cnt;
            rmv[min(n, i + a[i] + 1)]++;
        }

        rmv.assign(n + 1, 0);
        cnt = 0;
        for (int i = n - 1; i >= 0; --i)
        {
            cnt -= rmv[i];
            b[i] += cnt;
            done &= (b[i] == n);
            if (i - a[i] - 1 >= 0)
                rmv[i - a[i] - 1]++;
            cnt++;
        }
        a.swap(b);
        op++;
    }
//    debug(op);
    for (int i = 0; i < n; ++i)
        cout << a[i] << " \n"[i + 1 == n];
}

Measured memory_bytes: 5580
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
using LL = long long;
const int MOD = 998244353;
class Edge{
public:
    LL from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};
int main(){
    
    string s;cin >> s;
    vector<int> vec(s.size()+1, 0);
    for(int i = 0;i < s.size()-1;i++){
        if(s[i] == '>' && s[i+1] == '<')vec[i + 1] = 0;
    }
    if(s.front() == '<'){
        vec.front() = 0;
    }
    if(s.back() == '>'){
        vec.back() = 0;
    }
    for(int i = 0;i < s.size();i++){
        if(s[i] == '<'){
            vec[i + 1] = vec[i] + 1;
        }
    }
    for(int i = s.size()-1;i >= 0;i--){
        if(s[i] == '>'){
            vec[i] = vec[i+1] + 1;
        }else if(i != s.size()-1){
            if(s[i+1] == '>'){
                vec[i + 1] = max(vec[i] +1 , vec[i+1]);
            }
        }
    }
    cout<<accumulate(vec.begin(), vec.end(), 0LL)<<endl;
    
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define Max(x, y)(max(decltype(x)(0), max((x), (y))))
#define Min(x, y)(max(decltype(x)(0), min((x), (y))))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define all(x) (x).begin(),(x).end()
#define _end '\n'
#define Out(x) cout<<(x)<<_end
template<typename T> inline bool _max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool _min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    string n;
    string s = "";
    ll a = 0;
    ll b = 0;
    ll c;

    cin >> n;

    int i, j, len = n.size();

    rep(i, len) a += n[i] - '0';

    if (1 < n.size()) {
        nep(i, len - 1) {
            if (n[i] != '0') {
                c = n[i] - '0' - 1;

                repi(j, len, i + 1) c += 9;
                nep(j, i) c += n[j] - '0' - 1;

                b = max(b, c);
            }
        }

        Out(max(a, b));
    } else {
        nep(i, n[0] - '0' + 1) {
            Out(i);

            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int s;
            int g;
            int c;
            int d;
           s = a;
           g = b;
            while (a % b != 0) {
                c = a;
                a = b;
                b = c % b;

            }
            System.out.print(b);
                d = s/b*g;
                System.out.print(" ");
                System.out.println(d);
        }

    }
}


Measured memory_bytes: 26244
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

const int N = 100010;
const string ABC = "ABC";

int n, v[3];
string s[N];

bool ok = false;
char ans[N];

set<vector<int>> vis[N];
void dfs(int d, vector<int> x) {
    if (d == n) {
        ok = true;
        return;
    }
    if (vis[d].count(x)) return;
    vis[d].insert(x);

    bool b[3] = {};
    int z = 0;
    for (char c : s[d]) {
        b[c - 'A'] = true;
        z += c - 'A';
    }
    rep(i, 3) if (b[i]) {
        vector<int> nx(x);
        ++nx[i];
        --nx[z - i];

        bool valid = true;
        rep(j, 3) if (abs(nx[j]) > 2 || v[j] + nx[j] < 0) valid = false;

        if (valid) {
            ans[d] = ABC[i];
            dfs(d + 1, nx);
        }
        if (ok) return;
    }
}

int main() {
    cin >> n;
    rep(i, 3) cin >> v[i];
    rep(i, n) cin >> s[i];

    dfs(0, vector<int>(3, 0));

    if (!ok) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
    rep(i, n) cout << ans[i] << "\n";
    return 0;
}


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

int INF=0x3f3f3f3f;
const int N=1e5+111;
int num[N];

int main(){
	ios_base::sync_with_stdio(false);
	int n,tmp,M=-1;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>tmp;
		num[tmp]++;
		if(tmp>M) M=tmp;
	}
	int ans=-1,idx=1;
	for(int i=0;i<=M;i++){
		if(num[i-1]+num[i]+num[i+1]>ans) ans=num[i-1]+num[i]+num[i+1];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=998244353;

int main(){
	long long n,k;
	cin>>n>>k;
	vector<pair<long long,long long>> hoge(k);
	for(long long i=0;i<k;i++) cin>>hoge.at(i).first>>hoge.at(i).second;

	vector<long long> dp(500000,0);
	vector<long long> ruiseki(500000,0);
	dp[1]=1;
	dp[2]=-1;

	for(long long i=1;i<=n;i++){
		ruiseki[i]=ruiseki[i-1]+dp[i];
		if(ruiseki[i]>=inf) ruiseki[i]%=inf;
		else if(ruiseki[i]<0) ruiseki[i]+=inf;
		long long now=ruiseki.at(i);//cout<<dp[i]<<" "<<now<<endl;

		for(auto a:hoge){
			long long l=a.first,r=a.second;
			l+=i;r+=i;//cout<<l<<":"<<r<<endl;

			dp.at(l)+=now;
			dp.at(r+1)-=now;
			dp.at(l)%=inf;
			if(dp.at(r+1)<=inf*-1) dp.at(r+1)=((dp.at(r+1)*-1)%inf)*-1;
			dp.at(r+1)%=inf;
		}
	}

//	for(int i=1;i<=n;i++) cout<<dp[i]<<"+"<<endl;

	cout<<ruiseki[n]<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

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

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


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

int main(){
    using namespace std;
    string s;
    cin >> s;

    auto N = s.size();
    unsigned long ans{0};
    for(unsigned long i = 0; i < N; ++i)ans += (i ^ s[i]) & 1;
    cout << min(ans, N - ans) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

  bool cmp( pair<int,int> a, pair< int ,int> b)
   {
       if(a.second!= b.second) return a.second<b.second;

       return a.first<b.first; 
   }
 
  int main()
  {
     
         ll n ;
         cin>>n;
         vector< pair<int,int> > v(n);
         for( int i=0;i<n;i++)
         {
               cin>>v[i].first>>v[i].second;
         }

         sort(all(v),cmp);


         ll curr =0;

         for(int i=0;i<n;i++)
        {
               if( curr+v[i].first> v[i].second)
               {
                   cout<<"No"<<endl;
                   return 0;
               }

               curr+=(v[i].first);
        }


        cout<<"Yes"<<endl;
  }



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	int a;
	int target = 1;
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		cin >> a;
		
		if( target == a ) target++;
		else ans++;
	}
	
	if( ans == n ) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}


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

int main() {
	char a;
	for(int i = 0;i < 3;i++)
	{
		cin >> a;
		if(a == '1')
		{
			a = '9';
		}
		else
		{
			a = '1';
		}
		cout << a;
	}
	cout << endl;
	return 0;
}


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

using namespace std;

int main () {
  double N,M,sum = 0;
  string answer = "No";
  cin >> N >> M;
  vector<double> A(N);
  
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  if(A.at(M -1) >= sum/4/M){answer = "Yes";}
  cout << answer << endl;
}

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

int sod(int n){
    int sum=0;
    while(n>0){
        sum+= n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int n; cin>>n;
    if(n%10 == 0){
        cout << 10 << endl;
    }else{
        cout << sod(n) << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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; }

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

const ll MOD = 1000000007;

int main() {
	int h, w;
	cin >> h >> w;
	VV<int> a(h, V<int>(w));
	rep(i, h){
		string s;
		cin >> s;
		rep(j, w) {
			if (s.substr(j,1) == ".") a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	VV<ll> dp(h, V<ll>(w, 0));
	dp[0][0] = 1;
	rep(i, h)rep(j, w) {
		if (i > 0)if (a[i - 1][j]) {
			dp[i][j] += dp[i - 1][j];
			dp[i][j] %= MOD;
		}
		if (j > 0)if (a[i][j - 1]) {
			dp[i][j] += dp[i][j - 1];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

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

using namespace std;

int main()
{
  int x,n;
  cin>>x>>n;
  int A[n];

  if(n==0)
    cout<<x<<"\n";
  else
  {
    int p[101],pp[101];
    int min=0,max=101;
    int count = 0;

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

    for(int j=0;j<n;j++)
    {
      if(p[j]<=max)
        max = p[j];
      if(p[j]>=min)
        min = p[j];
    }

    for(int t=0;t<101;t++)
    {
      int c=0;
      for(int s=0;s<n;s++)
      {
        if(t==p[s])
          c=-1;
      }
       if(c == 0)
       {
            pp[count] = t;
             ++count;
       }
    }
    int resp = 101;

        for(int k = 0; k < count; ++k)
        {
             if(abs(pp[k] - x) <= abs(resp - x))
             {
                if(abs(pp[k] - x) == abs(resp - x))
                {
                    if(pp[k] < resp)
                        resp = pp[k];
                }
                else
                    resp = pp[k];
             }
        }
        cout<<resp;
  }

  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long 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; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int N,W;
ll dp[110][100100] = {0};

int main(){
  cin>>N>>W;
  int w[N],v[N];
  for(int i = 0; i < N; i++) cin>>w[i]>>v[i];

  for(int i = 0; i < N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      if(sum_w - w[i] >= 0){
        chmax(dp[i+1][sum_w], dp[i][sum_w-w[i]] + v[i]);
      }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }

  cout<<dp[N][W]<<endl;

  
  return 0;
}


Measured memory_bytes: 79360
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f
def yakusuu(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    # divisors.sort()
    return divisors

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ans=0
    for a in range(1,N):
        ans+=(N-1)//a
    print(ans)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 72856
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = [0] * n
    for i in range(n):
        c[i] = a[i] - b[i]
    c.sort()
    i = 0
    j = n - 1
    cnt = 0
    tmp = c[i] + c[j]
    while i != j:
        if c[i] < 0:
            if tmp >= 0:
                cnt += 1
                i += 1
                tmp += c[i]
            else:
                cnt += 1
                j -= 1
                tmp += c[j]
        else:
            break
    if tmp >= 0:
        print(cnt + 1 if cnt > 0 else 0)
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24412