akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;
    int Ch, Cw;
    cin >> Ch >> Cw;
    --Ch; --Cw;
    int Dh, Dw;
    cin >> Dh >> Dw;
    --Dh; --Dw;
    vector<string> S(H);
    rep(i, H) {
        string s;
        cin >> s;
        S[i] = s;
    }
    vector<vector<int>> dist(H, vector<int> (W, INF));
    deque<tuple<int, int, int>> que;
    auto update = [&] (int i, int j, int d, bool warp) {
        if (dist[i][j] <= d) return;
        dist[i][j] = d;
        if (!warp) que.emplace_front(i, j, d);
        else que.emplace_back(i, j, d);
    };
    update(Ch, Cw, 0, 0);
    while (!que.empty()) {
        int ci = get<0>(que.front());
        int cj = get<1>(que.front());
        int cd = get<2>(que.front());
        que.pop_front();
        if (dist[ci][cj] < cd) continue;
        rep(dir, 4) {
            int ni = ci + dx[dir];
            int nj = cj + dy[dir];
            if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
            if (S[ni][nj] == '#' || dist[ni][nj] <= dist[ci][cj]) continue;
            update(ni, nj, dist[ci][cj], 0);
        }
        // warp
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int ni = ci + i;
                int nj = cj + j;
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if (S[ni][nj] == '#' || dist[ni][nj] != INF) continue;            
                update(ni, nj, dist[ci][cj] + 1, 1);
            }            
        }
    }
    int ans = dist[Dh][Dw];
    cout << (ans != INF ? ans : -1) << '\n';
    return 0;
}

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

int main() {
    int n,s1=0,s2 =0,ans;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < i; j++){
            s1+=data.at(j);
        }
        for (int j = i; j < n; j++){
            s2+=data.at(j);
        }
        if(i==0){
            ans= abs(s1-s2);
        }
        if(ans > abs(s1-s2))ans=abs(s1-s2);
        s1=0,s2=0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
$stdin = DATA if $stdin.eof?

gets
xn = gets.split.map(&:to_i)
yn = gets.split.map(&:to_i)

[1,2,3].each do |p|
  sum = [xn, yn].transpose.map do |x,y|
    (x - y).abs ** p
  end.inject(0.0, &:+)

  puts sum ** (1.0/p)
end

pi = [xn, yn].transpose.map do |x,y|
  (x - y).abs
end

puts pi.max
__END__
3
1 2 3
2 0 4

Measured memory_bytes: 6184
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    long long n,ans=0;
    scanf("%lld",&n);
    long long l=1,r;
    while(l<=n)
    {
        r=n/(n/l);
        ll x=l,y=r;
        while(x<=y)
        {
            ll m=x+y>>1;
            if(n/m==n%m) {ans+=m;break;}
            else if(n/m>n%m) y=m-1;
            else x=m+1;
        }
        l=r+1;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll dfs(ll n, ll x){
  if(n==0) return 1;
  if(x<0) return (1LL<<(n+1))-1;
  if(x==1) return 0;
  if(x>1&&x<(1LL<<(n+1))-1) return dfs(n-1,x-1);
  if(x==(1LL<<(n+1))-1) return dfs(n-1,-1)+1;
  if(x>(1LL<<(n+1))-1&&x<(1LL<<(n+2))-3) return dfs(n-1,-1)+1+dfs(n-1,x-2-((1LL<<(n+1))-3));
  else return dfs(n-1,-1)+1+dfs(n-1,-1);
}

int main(){
  ll n,x;
  cin >> n >> x;
  cout << dfs(n,x) << endl;
  return 0;
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
vector<string> yesno={"No", "Yes"};
//----------------------------------------------------------------
#define bis(i, j)        i & (1<<j)

int main(void) {
  int n;
  cin >> n;
  arr(a,n);
  sortall(a);

  prt(a[n-1]-a[0]);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, k = inm()
print(*[i for i in range(k-n+1, n+k)])

Measured memory_bytes: 9168
#include <iostream>
#include <math.h>
#include <string>


using namespace std;

int main()
{
	int a, b;

	cin >> a;
	cin >> b;

	if (a == 1 && b == 2 || a == 2 && b == 1) {
		cout << "3";
	}
	else if (a == 1 && b == 3 || a == 3 && b == 1) {
		cout << "2";
	}
	else {
		cout << "1";
	}

	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  rep(i, 0, 9) {
    string a;
    int b, c;
    cin >> a >> b >> c;
    cout << a << " " << b + c << " " << b * 200 + c * 300 << endl;    
  }
}

Measured memory_bytes: 3112
#include <stdio.h>


int main() {
	int H[50] = {};
	int W[50] = {};
	int n = 0;
	for (;;) {
		scanf("%d %d", &H[n], &W[n]);
		if (H[n] == 0)break;
		n++;
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < H[k]; i++) {
			for (int j = 0; j < W[k]; j++) {
				if (i == 0 || j == 0 ||
					i == H[k] - 1 || j == W[k]-1)
					printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2604
import java.util.Scanner;

public class Main {

	static final Integer N = 1000010;
	static Boolean[] prime = new Boolean[N];

	public static void makePrime(){
		for(int i = 0; i < N; i++) prime[i] = true;
		prime[0] = false;
		prime[1] = false;
		for(int i = 0; i * i <= N; i++){
			if(!prime[i]) continue;
			for(int j = i + i; j < N; j += i) prime[j] = false;
		}
	}

	public static void main(String[] args) {
		makePrime();
		Scanner s = new Scanner(System.in);
		while(s.hasNextInt()){
			int n = s.nextInt();
			int cnt = 0;
			for(int i = 0; i <= n; i++) if(prime[i]) cnt++;
			System.out.println(cnt);
		}
		s.close();
	}
}

Measured memory_bytes: 24452
N=int(input())
former=0
ans=0
for i in range(0,N):
    a=int(input())
    if former==0:
        former=a%2
        ans+=a//2
    else:
        if a%2==0:
            if a!=0:
                former=1
                ans+=a//2
            else:
                former=0
        else:
            former=0
            ans+=a//2+1

print(ans)

Measured memory_bytes: 45800
import re
s = input().replace("?",".")
t = input()
for i in range(len(s)-len(t),-1,-1):
  if re.match(s[i:i+len(t)],t):
    s = s.replace(".","a")
    print(s[:i]+t+s[i+len(t):])
    exit()
print("UNRESTORABLE")

Measured memory_bytes: 9824
macro_rules! scan {
    ($($var:ident : $t:ty),*) => {
        let stdin = std::io::stdin();
        let mut stdin = std::io::BufReader::new(stdin.lock());
        let mut s = String::new();
        let mut iter = read_one_line(&mut s, &mut stdin);
        $(
            let mut s = String::new();
            let next = iter.next();
            let x = match next {
                Some(a) => {a},
                None => {
                    
                    iter = read_one_line(&mut s, &mut stdin);
                    iter.next().unwrap()
                }
            };
            let res = x.parse().unwrap();
            #[allow(unused_mut)]
            let mut $var:$t = res;
        )*
    };
}

fn read_one_line<'a>(s:&'a mut String, stdin: &mut std::io::BufReader<std::io::StdinLock>) ->  std::str::SplitWhitespace<'a>{
    use std::io::BufRead;
    s.clear();
    stdin.read_line(s).unwrap();
    let ret = s.split_whitespace();
    ret
}


fn main() {
    scan!(s:String, t:String);
    println!("{}", if &s[..] == &t[..t.len()-1] {
        "Yes"
    } else {
        "No"
    });
}

Measured memory_bytes: 2056
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
 
    const lines = input.split('\n')
    const N = lines[0] - 0
    const A = lines[1].split(' ').map(Number)
    
    let count = 0
    let dir = 0
    for (let i = 1; i < N; i++) {
	    if (A[i] - A[i - 1] > 0) {
          if (dir === -1) {
            dir = 0
            count++
          } else {
            dir = 1
          }
        } else if (A[i] - A[i - 1] < 0) {
          if (dir === 1) {
            dir = 0
            count++
          } else {
            dir = -1
          }
        }
    }
  
  console.log(count + 1)

})(input)


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

int main() {
    double t1, t2;
    while (cin >> t1 >> t2) {
        string output;
        if (t1 < 35.5 && t2 < 71) {
            output = "AAA";
        } else if (t1 < 37.5 && t2 < 77) {
            output = "AA";
        } else if (t1 < 40 && t2 < 83) {
            output = "A";
        } else if (t1 < 43 && t2 < 89) {
            output = "B";
        } else if (t1 < 50 && t2 < 105) {
            output = "C";
        } else if (t1 < 55 && t2 < 116) {
            output = "D";
        } else if (t1 < 70 && t2 < 148) {
            output = "E";
        } else {
            output = "NA";
        }
        cout << output << endl;
    }
}

Measured memory_bytes: 0
/*
 * Matheus Oliveira
 * 09:04:10 12/04/2020
 * b.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

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

int main() {
	int n, ac = 1;
	scanf("%d", &n);
	
	ll ans = 0;

	for(int i = 1; i <= n; i++) {
		if(i%3 == 0 or i%5 == 0);
		else ans += ((ll) i);
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3816
h, w = map(int, input().split())

s = [['.'] * (w+2)]
for i in range(h):
  tmp = list(input())
  tmp.insert(0, '.')
  tmp.append('.')
  s.append(tmp)

ans = 'Yes'
for i in range(1, h):
  for j in range(1, w):
    if s[i][j] == '#' and s[i][j+1] != '#' and s[i+1][j] != '#' and s[i][j-1] != '#' and s[i-1][j] != '#':
      ans = 'No'

print(ans)

Measured memory_bytes: 3064
<?php
list($n, $p) = ints();
$ps = primeFactorization($p);
$ans = 1;
foreach ($ps as $i => $v) $ans *= $i ** intdiv($v, $n);
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 素数かどうか前処理
$is_prime = isPrime($max);

// 累積和
$s = array_fill(0, $max, 0);
for ($i = 1; $i <= $max; $i++) {
    if ($is_prime[$i] && $is_prime[($i + 1) / 2]) {
        $s[$i] = $s[$i - 1] + 1;
    } else {
        $s[$i] = $s[$i - 1];
    }
}

for ($i = 0; $i < $q; $i++) {
    echo ($s[$r[$i]] - $s[$l[$i] - 1]) . PHP_EOL;
}

/**
 * 素数列挙（エラトステネスのふるい）
 * $max以下の素数を格納した配列を返す
 */
function primesArr($max)
{
    $arr = array_fill(2, $max - 1, true);
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        if (!isset($arr[$i])) continue;
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            unset($arr[$j]);
        }
    }
    return array_keys($arr);
}

/**
 * 素数判定（エラトステネスのふるい）
 * $max以下の整数が素数かどうかboolを格納した配列を返す
 */
function isPrimeArr($max)
{
    $arr = array_fill(0, $max + 1, true);
    $arr[0]  = $arr[1] = false;
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            $arr[$j] = false;
        }
    }
    return $arr;
}

// 素因数分解（エラトステネスのふるい）
// インデックスに素数、値に数を格納した配列を返す
// （1は素数ではないので含まない）
function primeFactorization($n)
{
    $res = [];
    if ($n === 1) return $res;

    $primes = primesArr((int) sqrt($n) + 1);

    foreach ($primes as $prime) {
        while ($n % $prime === 0) {
            if (isset($res[$prime])) {
                $res[$prime]++;
            } else {
                $res[$prime] = 1;
            }
            $n /= $prime;
        }
    }

    if ($n > 1) {
        if (isset($res[$n])) {
            $res[$n]++;
        } else {
            $res[$n] = 1;
        }
    }

    return $res;
}

// 素数列挙（試し割り）
function primes($max)
{
    $arr = [];
    for ($i = 2; $i <= $max; $i++) {
        if (isPrime($i)) $arr[] = $i;
    }
    return $arr;
}

// 素数判定（試し割り）
function isPrime($n)
{
    if ($n === 1) return false;
    $rmax = (int) floor(sqrt($n));
    for ($i = 2; $i <= $rmax; $i++) {
        if ($n % $i === 0) return false;
    }
    return true;
}

// 約数列挙
function divisors($max)
{
    $arr = [];
    $rmax = (int) floor(sqrt($max));
    for ($i = 1; $i <= $rmax; $i++) {
        if ($max % $i === 0) {
            $arr[] = $i;
            $arr[] = $max / $i;
        }
    }
    sort($arr);
    return array_unique($arr);
}


Measured memory_bytes: 49504
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> aa(n, vector<int>(m));
  rep(i, n) {
    rep(j, m) {
      cin >> aa[i][j];
      aa[i][j]--;
    }
  }

  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) rep(j, m) a[i][aa[i][j]] = j + 1;
  int ans = inf;
  rep(k, m) {
    vector<int> cnt(m, 0);
    rep(i, n) {
      int res = inf, idx = -1;
      rep(j, m) {
        if (chmin(res, a[i][j])) {
          idx = j;
        }
      }
      cnt[idx]++;
    }
    int res = 0, idx = -1;
    rep(j, m) {
      if (chmax(res, cnt[j])) {
        idx = j;
      }
    }
    //cout << res << '\n';
    //cout << idx << '\n';
    chmin(ans, res);
    rep(i, n) a[i][idx] = inf;
  }
  cout << ans << '\n';




  
  return 0;
}

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

int main(){
  int n,d,i,k;
  int c=0,l=0;
  double h;
  cin>>n>>d;
  int s[n][d];
  
  for(i=0;i<n;i++){
    for(k=0;k<d;k++){
      cin>>s[i][k];
    }
  }
  
  for(i=0;i<n;i++){
    for(k=i+1;k<n;k++){
      l=0;
      for(int j=0;j<d;j++){
        l += (s[i][j]-s[k][j])*(s[i][j]-s[k][j]);
      }
      if(sqrt(l)-(int)sqrt(l)==0) c+=1;
    }
  }
  
  cout<<c<<endl;
  return 0;
}
         
         
    
         

Measured memory_bytes: 256
import sys
mod=10**9+7
input=sys.stdin.buffer.readline
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[ [0 for _ in range(m)] for _ in range(n)]
for i in range(0,n):
    for j in range(0,m):
        ret=0
        if i-1>=0:
            ret+=dp[i-1][j]
        if j-1>=0:
            ret+=dp[i][j-1]
        if i-1>=0 and j-1>=0:
            ret-=dp[i-1][j-1]
        if s[i]==t[j]:
            ret+=1
            if i-1>=0 and j-1>=0:
                ret+=dp[i-1][j-1]
        if ret>=mod:
            ret%=mod
        if ret<0:
            ret+=mod
        dp[i][j]=ret
print((dp[n-1][m-1]+1))



Measured memory_bytes: 75228
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  int n; cin >> n;
  int sum = 0;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  double ave = (double)sum/n;

  double mi = 1000;
  int pos = -1;
  rep(i, n) {
    if (mi > abs(ave-a[i])) {
      mi = abs(ave-a[i]);
      pos = i;
    }
  }
  cout << pos << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        int max = 0;
        for(int i=0;i<N;i++){
            if(sc.nextInt()==sc.nextInt()){
                count++;
            }else{
                if(count>max){
                    max = count;
                }
                count = 0;
            }
        }
        if(count>max){
            max = count;
        }
        System.out.println(max>=3?"Yes":"No");
    }
}

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

a, b = map(int, input().split())

if b != 1:
    div = b // (a-1)
    mod = b % (a-1)

    if a != 2:
        if mod <= 1:
            print(div)
        else:
            print(div+1)
    else:
        print(div-1)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		ll a[n];
		rep(i,n)cin>>a[i];
		string s;
		cin>>s;
		if(s[n-1]=='1'){
			puts(1);
			continue;
		}
		vector<ll> v1;
		for(int i=n-1;i>=0;i--){
			if(s[i]=='0'){
				v1.pb(a[i]);
				rep(j,v1.size()){
					sort(v1.begin(),v1.end(),greater<ll>());
					rep(k,v1.size()){
						if(j==k)continue;
						v1[k]=min(v1[k],v1[k]^v1[j]);
					}
				}
              sort(v1.begin(),v1.end(),greater<ll>());
			}else{
				rep(j,v1.size()){
					a[i]=min(a[i],a[i]^v1[j]);
				}
				if(a[i]!=0){
					puts(1);
					goto end;
				}
			}
			
		}
		puts(0);
      	end:;
	}
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  vi a;
  a.pb(1);
  int tmp = 6;
  while(tmp <= 100000){
    a.pb(tmp);
    tmp *= 6;
  }
  tmp = 9;
  while(tmp <= 100000){
    a.pb(tmp);
    tmp *= 9;
  }
  sort(all(a));
  int n; cin >> n;
  vi dp(n+1,inf);
  dp[0] = 0;
  rep(i,n){
    rep(j,sz(a)){
      if(i+1-a[j] >= 0)
	dp[i+1] = min(dp[i+1], dp[i+1-a[j]]+1);
      else
	break;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  long long  tmp;
  long long mx=1000000000;
  for(long long i=1;i<=sqrt(n);i++){
    if(n%i==0){
      tmp=n/i;
    }
    else continue;
    mx=min(mx,max(i,tmp));
  }
  int cnt=0;
  while(mx!=0){
    mx/=10;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define L long int
#define LL long long int
#define Pi pair<int,int>
#define Pl pair<L,L>
#define vi vector<int>
#define Vi vector<vector<int>>
#define vl vector<long int>
#define Vl vector<vector<long int>>
#define vp vector<Pi>
#define mod 1000000007
using namespace std;
int main(){
	int n,q,b,c;
	cin>>n;
	unordered_map<int,int>mymap;
	L sum=0;
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		sum+=temp;
		mymap[temp]++;
	}
	cin>>q;
	while(q--){
		cin>>b>>c;
		sum+=mymap[b]*(c-b);
		mymap[c]+=mymap[b];
		mymap[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 7032
#include<stdio.h>

int main(void)
{
	int H, W, i, j = 0;
	
	while(1){
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
			for ( i = 0; i < H; i++ ){
				for ( j = 0; j < W; j++ ){
					printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}




Measured memory_bytes: 2084
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define Get(x,y) scanf("%I64d%I64d",&x,&y);
#define get(x) scanf("%I64d",&x);
#define Gett(x,y) scanf("%d%d",&x,&y);
#define gett(x) scanf("%d",&x);																																														
#define f(i,a,b) for(int i=a;i<b;i++)
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define ll long long
#define pb push_back
#define maxm(a,b) a=max(a,b);
#define minm(a,b) a=min(a,b);
#define S second
#define F first
#define mp make_pair
const int N=3e5+20;
ll n,m;
string s;
int main(){
	cin>>s;
	n=int(s.size());
	f(i,0,n/2){
		if(s[i]!=s[i+(n/2)+1])
			return cout<<"No",0;
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int ticket[3];
	int i;
	
	for (i = 0; i < 3; i++){
		scanf("%d", &ticket[i]);
	}
	
	if (ticket[0] == 1 && ticket[1] == 1 || ticket[2] == 1){
		printf("Open");
	}
	else {
		printf("Close");
	}
	
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 588
from decimal import *
a,b,c=map(int,input().split())
a,b,c=Decimal(a),Decimal(b),Decimal(c)
if c**Decimal(0.5)>a**Decimal(0.5)+b**Decimal(0.5): #Decimalモジュールを用いることで十分な精度で平方根の不等式を判定できる
 print('Yes')
else:
 print('No')

Measured memory_bytes: 5332
#include <stdio.h>
int main()
{
	int n,a,b,s1,s2;
	scanf("%d%d%d",&n,&a,&b);
	s1=a*n;
	s2=b;
	if(s1<s2)
	printf("%d\n",s1);
	else
	printf("%d\n",s2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int pre[N];
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int k;
    ll n;
    cin >> n >> k;
    ll ans = 0;
    ll beg = 0;
    ll end = 0;
    for(ll i = 1; i < k; i++){
        beg += (i - 1);
        end += (n - i + 1);
    }
    for(ll i = k; i <= n + 1; i++){
        beg += (i - 1);
        end += (n - i + 1); 
        ans = (ans % mod + (end - beg + 1 + mod) % mod) % mod;
    }
    cout << ans << '\n';
    return 0;
}   

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line;
            br.readLine();
            while((line=br.readLine())!=null){  if(line.equals(""))break;
                String[] splited = line.split(" ");
                int[] ints = new int[10];
                for(int i=0; i<10;i++)ints[i]=Integer.parseInt(splited[i]);
               int tB=ints[0],tC=-1;boolean can=true;
               for(int i=1;i<10;i++ ){
                   if(tB>tC){
                        if(ints[i]>tB){tB=ints[i];continue;}
                       if(ints[i]>tC){tC=ints[i];continue;
                       }can=false;break;
                   }else {
                       if(ints[i]>tC){tC=ints[i];continue;}
                       if(ints[i]>tB){tB=ints[i];continue;}can=false;break;}
                   
               }
                System.out.println((can)?"YES":"NO");
            }         
        }catch(Exception e){e.printStackTrace();}
        
    }
    
}

Measured memory_bytes: 16916
l=int(input())
ll=l
l3=[]
while True:
    if ll//3==0:
        l3.append(ll)
        break
    else:
        l3.append(ll%3)
        ll=ll//3
N=len(l3)+1
edge=[]
for i in range(1,len(l3)):
    edge.append([i,i+1,0])
    edge.append([i,i+1,1*3**(i-1)])
    edge.append([i,i+1,2*3**(i-1)])

a=0
for i in range(len(l3)):
    for j in range(l3[i]):
        edge.append([i+1,N,j*3**i+a])
    a+=l3[i]*3**i

print(N,len(edge))
for i in edge:
    print(i[0],i[1],i[2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int x,y,z,temp;
    cin >> x >> y >> z;
    temp=x;
    x=z;
    z=y;
    y=temp;
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc = [list(map(int,input().split())) for _ in range(q)]
N=[0]*(10**5+1)
for i in a:
    N[i]+=1
ans = 0
for i,x in enumerate(N):
    if x != 0:
        ans += i*x #初期値

for b,c in bc:
    ans += (c-b)*N[b]
    N[c] += N[b]
    N[b] = 0
    print(ans)


Measured memory_bytes: 32152
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(void){

	char a[10];
	int b,c;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
        for(int j=0;j<=8;j++){
            scanf("%c",&a[j]);
        }
        sort(a,a+9);
        b=atoi(a);
        reverse(a,a+9);
        c=atoi(a);

        cout<<c-b<<endl;


	}


	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a[3];
    rep(i,3) cin >> a[i] ;

    sort(a,a+3,greater<int>());
    cout << a[0]*10 + a[1] + a[2] << endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep2(i, 1, n + 1) rep2(j, 1, n + 1) rep2(k, 1, n + 1) {
    ll now = gcd(i, j);
    now = gcd(now, k);
    ans += now;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
void solve()
{
	ll N;
	cin>>N;
	ll a[maxn];
	for(ll i=0;i<N;i++)
	{
		cin>>a[i];
	}
	ll sum=0;
	for(ll i=0;i<N;i++)
	{
		for(ll j=i+1;j<N;j++)
		{
			sum+=a[i]*a[j];
		}
	}
	cout<<sum<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 256
<?php	
  fscanf(STDIN, "%s", $a);
  fscanf(STDIN, "%s", $b);
  $count = 0;

  $a = str_split($a);
  $b = str_split($b);

  for($i = 0; $i < 3; $i++) {
    if($a[$i] == $b[$i]) {
      $count++;
    }
  }

  echo $count;

Measured memory_bytes: 3576
n, m = map(int, input().split())
ks=[list(map(int, input().split()))[1:] for _ in range(m)]
ps = list(map(int, input().split()))
#print(ks)
res=0
perms=[]
for i in range(2**n):
    list2 = []
    for j in range(n):
        if (i >> j) &1 == 1:
            list2.append(1)
        else:
            list2.append(0)
    perms.append(list2)
    ons=0
    for idx,p in enumerate(ps):
        cnt=0
        for k in ks[idx]:
            if list2[k-1]==1:
                cnt+=1
        if cnt%2==p:
            ons+=1
    if ons==m:
        res+=1
print(res)


Measured memory_bytes: 42608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BTimeLimitExceeded {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, T;
	    in >> n >> T;
	    vector<int> c(n), t(n);
	    for(int i=0; i<n; i++){
	        in >> c[i] >> t[i];
	    }

	    int res = 1e6;
	    for(int i=0; i<n; i++){
            if(t[i] <= T){
                chmin(res, c[i]);
            }
	    }

	    if(res == 1e6) out << "TLE" << endl;
	    else out << res << endl;
	}
};


int main() {
	BTimeLimitExceeded solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 11111

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

  FOR(i, 0, n) {
	cin >> temp;
	a.pb(temp);
	b.pb(temp);
  }
  sort(ALL(b));

  FOR(i, 0, n) {
	temp = a[i];
	if (b[n / 2 - 1] >= temp) {
	  cout << b[n / 2] << endl;
	}
	else {
	  cout << b[n / 2 - 1] << endl;
	}
  }

  return 0;
}

Measured memory_bytes: 6116
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int x;
	cin >> x;
	if (x == 0) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}

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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if (A+B>C+D){
    cout <<"Left"<<endl;
  }
  if (A+B==C+D){
	cout <<"Balanced"<<endl;
  }
  if (A+B<C+D){
	cout <<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  string m = str.substr(5,2);
  if(m=="01"||m=="02"||m=="03"||m=="04"){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  // L ~ R
  //(R - L + 1) - (両端とも集合に含まれる辺)
  ll S = 0;
  for(ll i=1;i<=n;i++) S += i*(n-i+1);
  //S - ∑{e}(辺eがカウントされる回数)

  ll cnt = 0;
  for(int i=0;i<n-1;i++){
    ll a, b;std::cin >> a >> b;
    if(a>b) swap(a, b);
    cnt += (a*(n-b+1));
  }
  //std::cout << cnt << '\n';

  std::cout << S - cnt << '\n';
  return 0;
}


Measured memory_bytes: 3196
n = int(input())

check = 0b000
s = [3,5,7]

ans = 0


def rec(now,check):
    global ans

    if now > n :
        return 0

    if check == 0b111:
        ans+=1

    rec(now*10 +3 ,check | (1<<0))
    rec(now*10+5,check | (1<<1))
    rec(now*10+7,check | (1<<2))



rec(0,0b000)

print(ans)

    



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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int m1 = 0;
    int m2 = 0;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A[i];
        if(chmax(m2, A[i]) && m2 > m1) swap(m1, m2);
    }
    for(int i=0; i<N; i++)
    {
        if(A[i]!=m1) cout << m1 << endl;
        else cout << m2 << endl;
    }

    return 0;
}


Measured memory_bytes: 4000
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if(x == 3 || x== 5 || x == 7){
            System.out.println("YES");
        }else{
            System.out.println("NO");
            }
        }
}

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

namespace ABC147A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A1, A2, A3;
            string[] cs = Console.ReadLine().Split(' ');
            A1 = int.Parse(cs[0]);
            A2 = int.Parse(cs[1]);
            A3 = int.Parse(cs[2]);

            if (A1 + A2 + A3 >= 22)
                Console.WriteLine("bust");
            else 
                Console.WriteLine("win");
            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var ans = "pairwise coprime";
        var isSetwiseCoprime = A.Aggregate(A[0], (s, e) => (int)GcdLcm.Gcd(s, e)) == 1;
        if (!isSetwiseCoprime)
            ans = "not coprime";
        else
        {
            var sieve = new SieveOfEratosthenes(1_000_000);
            var set = new HashSet<int>();
            foreach (var a in A)
            {
                foreach (var fact in sieve.GetFactorizeSummary(a).Select(x => x.Factor))
                {
                    if (set.Contains(fact))
                    {
                        ans = "setwise coprime";
                        goto LOOP_END;
                    }
                    set.Add(fact);
                }
            }
        }
    LOOP_END:

        WriteLine(ans);
    }
}
static class GcdLcm
{
    public static long Gcd(long a, long b) => (b != 0) ? Gcd(b, a % b) : a;
    public static long Lcm(long a, long b) => a / Gcd(a, b) * b;
}

class SieveOfEratosthenes
{
    public int MaxN { get; }

    public IEnumerable<int> Primes => primes;
    private List<int> primes = new List<int>();

    private readonly int[] factors;

    public SieveOfEratosthenes(int maxN)
    {
        MaxN = maxN;
        factors = new int[maxN + 1];
        factors[0] = factors[1] = -1;

        for (int i = 2; i <= maxN; i++)
        {
            if (factors[i] != 0)
                continue;

            primes.Add(i);

            for (int j = i; j <= maxN; j += i)
                factors[j] = i;
        }
    }

    public bool IsPrime(int n)
    {
        if (MaxN < n)
            throw new ArgumentException();

        if (n < 2)
            return false;

        return factors[n] == n;
    }

    public IEnumerable<int> GetFactorizeList(int n)
    {
        if (MaxN < n)
            throw new ArgumentException();

        var factorList = new List<int>();
        while (1 < n)
        {
            factorList.Add(factors[n]);
            n /= factors[n];
        }

        for (int i = factorList.Count - 1; i >= 0; i--)
            yield return factorList[i];
    }

    public IEnumerable<(int Factor, int Count)> GetFactorizeSummary(int n)
    {
        var factorSummary = new List<(int, int)>();
        var prevFactor = -1;
        var factorCount = 0;
        foreach (var factor in GetFactorizeList(n))
        {
            if (prevFactor == -1)
                prevFactor = factor;

            if (prevFactor != factor)
            {
                factorSummary.Add((prevFactor, factorCount));
                factorCount = 0;
            }

            factorCount++;
            prevFactor = factor;
        }

        if (prevFactor != -1)
            factorSummary.Add((prevFactor, factorCount));

        return factorSummary;
    }
}


Measured memory_bytes: 108708
n, a, b = map(int, input().split(" "))

total = 0
for i in range(1, n + 1):
  num = i
  sum_i = 0
  while num > 0:
    sum_i += num % 10
    num = int(num/10)
    
  # print(sum_i)    
  if sum_i >= a and sum_i <= b:
    total += i
    
print(total)    

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>


int main()
{
	int n, counter = 0;
	long long int l_array[100];
	int l_array_num[100];
	long long int answer = 0;

	for (int i = 0; i<100; i++)
	{
		l_array_num[i] = 1;
	}

	scanf("%d", &n);

	for (int i = 0; i<n; i++)
	{
		scanf("%lld", &l_array[counter]);

		for (int j = 0; j<counter; j++)
		{
			if (l_array[j] == l_array[counter])
			{
				l_array_num[j] ++;
				break;
			}
			else if (j == (counter - 1)){
				//l_array_num[counter] ++;
				counter++;
				break;
			}
		}

		if (counter == 0)
		{
			counter++;
		}

	}


	for (int i = 0; i<(counter - 2); i++)
	{
		for (int j = (i + 1); j<(counter - 1); j++)
		{
			for (int k = (j + 1); k<(counter); k++)
			{
				if ((l_array[i] < (l_array[j] + l_array[k]))
					&& ((l_array[j] < (l_array[i] + l_array[k]))
						&& ((l_array[k] < (l_array[i] + l_array[j])))))
				{
					answer += l_array_num[i] * l_array_num[j] * l_array_num[k];
				}
			}
		}
	}

	printf("%lld", answer);

	return 0;
}

Measured memory_bytes: 1724
N=int(input())
ans=float("inf")
for i in range(1,N):
  A,B=str(i),str(N-i)
  S=0
  for a in range(len(A)):
    S+=int(A[a])
  for b in range(len(B)):
    S+=int(B[b])
  ans=min(ans,S)
print(ans)  

Measured memory_bytes: 41580
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  int count = 0;
  for (int i = 105; i <= N; i+=2)
  {
    int div_num = 0;
    for (int j = 1; j*j <= i; ++j)
    {
      if (j*j == i)
      {
        ++div_num;
        continue;
      }
      if (i%j == 0) div_num += 2;
    }
    if (div_num == 8) ++count;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N;

//解法
void solve() {

	if (N % 2 == 0) {
		cout << N;
	}
	else {
		cout << N * 2;
	}

	return;
}

int main() {
	//入力
	cin >> N;
	solve();
	cout << endl;
	return 0;
}


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

int main () {
    int n, k;
    cin >> n >> k;
    vector<int> p(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += p[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N;
    scanf("%lld", &N);
    printf("ABC%lld\n", N);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


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

int main() {
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < (int)s.length(); i++) {
        if(s==t) {
            cout << "Yes" << endl;
            return 0;
        }
        s = s[s.length()-1] + s.substr(0, s.length()-1);
    }
    cout << "No" << 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)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i,N) cin >> L[i];

    sort(all(L));
    int ans = 0;
    
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            int a = L[j];
            int b = L[i];

            int s = upper_bound(all(L), a-b) - L.begin();
            int t = max((int)(lower_bound(all(L), b) - L.begin()), i);

            ans += max(t-s, 0);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N;
    ll result = 0;
    cin >> N;
    vector<int> A(N+1), B(N);
    REP(i, N+1) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }
    REP(i, N) {
        if (A[i] <= B[i]) {
            result += A[i];
            B[i] -= A[i];
            if (A[i+1] <= B[i]) {
                result += A[i+1];
                A[i+1] = 0;
            } else {
                result += B[i];
                A[i+1] -= B[i];
            }
        } else {
            result += B[i];
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const long long B=1000000000000000003LL;
const long long P=1000000000000000031LL;

long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=(__int128_t)z*x%mod;
		x=(__int128_t)x*x%mod;
	}
	return z;
}

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

	int T;
	string s;
	cin>>T>>T>>s;
	long long Brev=pow_binary_mod(B,P-2,P);
	set<long long> se;

	int l=0,r=0;
	long long c=s[0];
	for(;T--;){
		string q;
		cin>>q;
		if(q=="L--"){
			l--;
			c=(s[l]*(__int128_t)pow_binary_mod(B,r-l,P)+c)%P;
		}else if(q=="L++"){
			c=((c-s[l]*(__int128_t)pow_binary_mod(B,r-l,P))%P+P)%P;
			l++;
		}else if(q=="R--"){
			c=((c-s[r])%P+P)%P*(__int128_t)Brev%P;
			r--;
		}else if(q=="R++"){
			r++;
			c=(c*(__int128_t)B+s[r])%P;
		}
		se.insert(c);
	}
	printf("%d\n",se.size());
}



Measured memory_bytes: 17248
#
import sys
import math
import itertools

# 整数をいくつか入力
n,k = (int(i) for i in input().split())


lr = [[int(i) for i in input().split()] for i in range(k)] 

dp  = [0] * (n+1)
ans = [0] * (n+1)
dp[1]=1
ans[1]=1

for i in range(2,n+1):
    for a in lr:
        if a[0] < i:
            dp[i] += ans[i-a[0]]
            if a[1] < i-1:
                dp[i] -= ans[i-a[1]-1]
    dp[i] = dp[i] % 998244353
    ans[i]=ans[i-1]+dp[i]

print(dp[n]%998244353)



Measured memory_bytes: 71492
#include<bits/stdc++.h>
using namespace std;
char s[10000];
int use[70];
int lst[70];
bool vis[70]; 
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;i++)
	{
		int x=s[i]-'a'+1;
		use[x]=max(use[x],i-lst[x]-1);
		lst[x]=i;
		vis[x]=1;
	}
	for(int i=0;i<=26;i++)
		use[i]=max(use[i],len-lst[i]);
	int ans=10000;
	for(int i=1;i<=26;i++)
		if(vis[i]) ans=min(ans,use[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256