akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    if (a <= b) {
        for (int i = 0; i < b; i++) cout << a;
    }
    else {
        for (int i = 0; i < a; i++) cout << b;
    }
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<PP,vector<PP>,greater<PP>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
vvi g;
vi di;
ll depth,k,a,b,from,f;
vi use;
bool dfs(ll i,ll p){
  use[i]=1;
  if(i==a){
    depth=di[i];
    return true;
  }
  for(ll u:g[i]){
    if(u!=p)if(dfs(u,i))return true;
  }
  use[i]=0;return false;
}
void dis(ll i,ll p){
  if(p!=-1)di[i]=di[p]+1;
  for(ll u:g[i])if(u!=p)dis(u,i);
}
int main(){
  ll n;cin>>n>>a>>b;
  g=vvi(n);
  use=vi(n);
  a--;b--;
  rep(i,n-1){
    ll c,d;cin>>c>>d;c--;d--;
    g[c].pb(d);
    g[d].pb(c);
  }
  di=vi(n);
  dis(b,-1);
  dfs(b,-1);
  rep(i,n)if(use[i]&&depth/2+1==di[i])from=i;
  for(ll o:g[from])if(di[o]<di[from])f=o;
  di=vi(n);di[f]=-1;
  dis(from,f);ll ma=0;
  rep(i,n)chmax(ma,di[i]);
  ll ans=depth/2+1+ma;
  ans--;
  cout<<ans<<endl;
}

Measured memory_bytes: 12032
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int num = 0;
		while(sc.hasNext()) {
			int a = sc.nextInt();
			if (a == 0) {
				break;
			}
			System.out.println(String.format("Case %d: %d", ++num, a));
		}
	}
}


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

bool check(int l, int r, const vector<bool> vec){
  for(int i = l - 1; i < r - 2; i++){
    if(vec[i]&&vec[i + 1])return false;
  }
  return true;
}
  
int main()
{
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  vector<bool > isRock(N);
  char c;
  REP(i, N){
    cin >> c;
    if(c == '#'){
      isRock[i] = true;
    }else{
      isRock[i] = false;
    }
  }
  // REP(i, N) cout << isRock[i];
  bool flag = false;
  if(C < B){
    // cout << "case 1 A < C < B < D" << endl;
    if(check(A, C, isRock)&&check(B, D, isRock)){
      cout << "Yes" << endl;
      return 0;
    }
  }else if(C < D){
    // cout << "case 2 A < B < C < D" << endl;
    if(check(A, D, isRock)){
      cout << "Yes" << endl;
      return 0;
    }
  }else if(check(A, C, isRock)){
    // cout << "case 3 A < B < D < C" << endl;
    for(int i = B - 2;i < D - 1;i++){
      if(isRock[i] == false && isRock[i + 1] == false && isRock[i + 2] == false){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;

  

  // for(int i = B - 1; i < D - 2; i++){
  //   if(isRock[i]&&isRock[i + 1]){
  //     flag = false;
  //     cout << "No" << endl;
  //     return 0;
  //   }
  // }
  // isRock[D - 1] = true;
  // for(int i = A - 1; i < C - 2; i++ ){
  //   if(isRock[i]&&isRock[i + 1]){
  //     flag = false;
  //     cout << "No" << endl;
  //     return 0;
  //   }
  // }
  // cout << "Yes" << endl;
}


Measured memory_bytes: 256
n = int(input())
heights = list(map(int, input().split()))

ans_list = [0]*n
for i in range(n):
  if i == 0:
    continue
  else:
    if heights[i] <= heights[i-1]:
      ans_list[i] = ans_list[i-1]+1
    else:
      ans_list[i] = 0
      
ans_list.sort()
ans = ans_list[-1]
print(ans)

Measured memory_bytes: 20648
use std::io::BufRead;

const DEBUG: bool = false;

fn main() {
    let stdin = std::io::stdin();
    let mut stdinlock = stdin.lock();
    let mut n = String::new();
    let _ = stdinlock.read_line(&mut n);
    // let mut path: Vec<(i32, i32, i32)> = Vec::with_capacity((&n).trim().parse().expect("N"));
    let path: Vec<(i32, i32, i32)> = stdinlock
        .lines()
        .map(|l| {
            let lineinfo: Vec<i32> = l
                .expect("line?")
                .trim()
                .split_whitespace()
                .map(|n| n.parse().expect("parse n error"))
                .collect();
            (lineinfo[0], lineinfo[1], lineinfo[2])
        })
        .collect();
    if solve(&path) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn solve(path: &[(i32, i32, i32)]) -> bool {
    let mut current: (i32, i32, i32) = (0, 0, 0);
    for &(tN, xN, yN) in path {
        if DEBUG {
            println!("{:?}\t---\t{} {} {}", current, tN, xN, yN);
        }
        if !can_go(tN - current.0, xN - current.1, yN - current.2) {
            return false;
        }
        current = (tN, xN, yN);
    }
    true
}

fn can_go(dt: i32, dx: i32, dy: i32) -> bool {
    let dist = dx.abs() + dy.abs();
    if DEBUG {
        println!("dist: {} in dt {}", dist, dt);
    }
    (dist <= dt) && (dt - dist) % 2 == 0
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int x,y;
	cin >> x >> y;
	rep(i,0,x+1){
		if(2 * i + 4 * (x - i) == y){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    //ぐうぐうき、ききぐうのとき、
    //ぐうぐうの値を同じにして、きの値をぐうぐう以上にして、ぐうぐうの値を調節する
    //逆も同じ
    //ぐうぐうぐうのとき、最もおおきな値に寄せたらOK
    if(a%2==c%2&&a%2!=b%2)swap(b,c);
    if(a%2!=c%2&&a%2!=b%2)swap(a,c);
    if(a>b)swap(a,b);
    ans+=(b-a)/2;
    a=b;
    if(a>c){
        int count=(a-c+1)/2;
        ans+=count;
        c+=count*2;
    }
    if(a<c){
        ans+=c-a;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isPalindrome(const string &s) {
  int n = (int)s.size();
  for(int i = 0; i < n/2; ++i) {
    if(s[i] != s[n-i-1])return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b;
  cin >> a >> b;
  for(long long k = 1; k <= 100000; ++k){
    long long aa = k * 0.08;
    long bb = k * 0.1;
    if(aa == a && bb == b){
      cout << k << endl;
      exit(0);
    }
  }
  cout << "-1\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int b[1000],ans[1000];
bool check(int n){
    if(!n)return 1;
    for(int i=n;i;--i)
        if(b[i]==i){
            ans[n]=i;
            for(int j=i;j<n;++j)b[j]=b[j+1];
            return check(n-1);
        }
    return 0;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&b[i]);
    if(!check(n))puts("-1");
    else for(int i=1;i<=n;++i)printf("%d\n",ans[i]);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String, Integer> map = new HashMap<>();

        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String key = sc.next();
            if (map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            } else {
                map.put(key, 1);
            }
        }

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String key = sc.next();
            if (map.containsKey(key)) {
                map.put(key, map.get(key) - 1);
            } else {
                map.put(key, 1);
            }
        }

        int max = 0;
        for (String key : map.keySet()) {
            if (map.get(key) > max) {
                max = map.get(key);
            }
        }
        System.out.print(max);
    }
}

Measured memory_bytes: 21716
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ny = br.readLine().split(" ");
        int n = Integer.parseInt(ny[0]);
        int y = Integer.parseInt(ny[1]);
        int a10000 = -1;
        int a5000 = -1;
        int a1000 = -1;
        
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                if (10000*i + 5000*j + 1000*(n-i-j) == y && n-i-j >= 0) {
                    a10000 = i;
                    a5000 = j;
                    a1000 = n-i-j;
                    break;
                }
            }
        }
        
        
        System.out.println(a10000 + " " + a5000 + " " + a1000);
    }
}





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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    ll res = 0;
    for (int bit = 0; bit < (1<<(N-1)); ++bit) {
        ll tmp = 0;
        for (int i = 0; i < N-1; ++i) {
            tmp *= 10;
            tmp += S[i] - '0'; //文字列を整数にしている。
            if (bit & (1<<i)) res += tmp, tmp = 0;
        }
        tmp *= 10;
        tmp += S.back() - '0';
        res += tmp;
    }

    cout << res << endl;

}

//bit全探索で数字のどこに＋が入るかを決める
// 前から順に見ていって、「数字があるたびに現在の値を 10 倍して今書いてある数字
//だけ足す」「‘+(’ が出てきたら現在の値が ‘+(’ の直前の整数に等しいので、それを答え
//に足す」「最後は ‘+(’ が登場せずに数式が終わるので、そこは別に足す」とすると、新し
//く出来た式の値を求めることができます。

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int value;

    List<Integer>list = new ArrayList<Integer>();

    while(N > 0){
      if(N % 10 == 1)
        value = 9;
      else
        value = 1;
      list.add(value);
      N /= 10;
    }

    for(int i=list.size()-1; i>=0; i--){
      System.out.print(list.get(i));
    }
    System.out.println();

  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

vector<vector<ll>> edges(1e5);
vector<bool> used(1e5, false);

ll dfs(ll now){
    ll ret = 1;
    used[now] = true;
    for(ll nxt : edges[now]) if(!used[nxt]) ret += dfs(nxt);
    return ret;
}

int main(){
    ll N, M;
    cin >> N >> M;
    for(ll i = 0; i < M; i++){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    ll num_zero = dfs(0);
    ll num_one = dfs(1);
    ll rest = N - num_zero - num_one;
    (num_zero > num_one ? num_zero : num_one) += rest;
    cout << num_zero * (num_zero - 1) / 2 +
            num_one * (num_one - 1) / 2 - M << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int c[20], d[30], e[30], ans = INT_MIN;

int asc(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

void dfs(int i, int k)
{
  if (i == 12) {
    if (c[12] == 1) d[k++] = 12;
    
    for (int j = 0; j < k; j++) e[j] = d[j];
    qsort(e, k, sizeof(int), asc);
    //for (int j = 0; j < k; j++) printf("%d ", e[j]); endl;
    int min = INT_MAX;
    for (int j = 0; j < k - 1; j++) {
      min = Min(min, e[j + 1] - e[j]);
    } min = Min(min, 24 + e[0] - e[k - 1]);
    ans = Max(ans, min);
    return;
  }

  if (c[i] == 2) {
    d[k++] = i;
    d[k++] = -i;
    dfs(i + 1, k);
  }
  if (c[i] == 1) {
    d[k++] = i;
    dfs(i + 1, k);
    d[k - 1] = -i;
    dfs(i + 1, k);
  }
  if (c[i] == 0) {
    dfs(i + 1, k);
  }
  return;
}
  
  

int
main(int argc, char *argv[])
{
  int n, d;
  scanf("%d", &n);
  c[0]++;
  for (int i = 0; i < n; i++) {
    scanf("%d", &d);
    c[d]++;
    if (c[d] >= 3 || c[0] >= 2 || c[12] >= 2) {
      printf("0\n");
      return 0;
    }
  }

  dfs(0, 0);
  printf("%d\n", ans);

  return 0;
}

  


Measured memory_bytes: 128
#include<cstdio>
#include<map>
#include<functional>
#include<algorithm>
using namespace std;

map< pair<int,int>, int > mymap;
int cnt[10] = {0};

int main(){
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for(int i = 0 ; i < k ; i++){
    int x, y;
    scanf("%d %d", &x, &y);
    for(int j = max(3, x) ; j < min(n+1, x+3) ; j++){
      for(int p = max(3, y) ; p < min(m+1, y+3) ; p++){
        mymap[ make_pair(j, p) ]++;
      }
    }
  }
  map< pair<int,int>, int >::iterator itr;
  for(itr = mymap.begin() ; itr != mymap.end() ; itr++){
    cnt[itr->second] ++;
  }
  long long sum = (long long)(n-2) * (m-2);
  for(int i = 1 ; i <= 9 ; i++){
    sum -= cnt[i];
  }
  printf("%lld\n", sum);
  for(int i = 1 ; i <= 9 ; i++){
    printf("%d\n", cnt[i]);
  }
  return 0;
}


Measured memory_bytes: 56448
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int a[5];
	for (int i = 0; i < 5; i++){
		cin >> a[i];
	}
	int ans = 0, temp = 0;
	for (int i = 0; i < 5; i++){
		ans += 10*((a[i]+9)/10);
		temp = max(10*((a[i]+9)/10)-a[i], temp);
	}
	cout << ans - temp << endl;
 	return 0;
 }



Measured memory_bytes: 256
a, b, c, d = gets.chomp.split('').map(&:to_i)

[:+,:-].repeated_permutation(3).each do |op1, op2, op3|
  if a.public_send(op1, b).public_send(op2, c).public_send(op3, d) == 7
    puts "#{a}#{op1}#{b}#{op2}#{c}#{op3}#{d}=7"
    exit
  end
end

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			cnt++;
		}
	}
	cout << cnt << '\n';
	
	
	return 0;
}


Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > G;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};
string Psb[2] = {"Impossible", "Possible"};
string psb[2] = {"impossible", "possible"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    map<int, int> mm;
    forn(i, n)
    {
        ll y;
        cin >> y;
        mm[y]++;
    }
    ll ans = 0;
    for (auto it : mm)
    {
        ans += it.second % 2;
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 4992
// AtCoder Regular Contest 066
// D - Xor Sum

#include <cstdio>
#include <cstring>
#define MAX_D 64
#define MOD ((ll)1e9 + 7)
using namespace std;
typedef long long int ll;


ll N;
ll dp[MAX_D][3];
ll ans;

int main() {

  int next_j;

  scanf("%lld", &N);

  memset(dp, 0, sizeof(dp));
  dp[MAX_D - 1][0] = 1;
  for (int i = MAX_D - 1; i > 0; i--) {
    for (int j = 0; j <= 2; j++) {
      for (int dv = 0; dv <= 2; dv++) {
        next_j = j * 2 + ((N >> (i - 1)) & 1) - dv;
        if (next_j < 0) {
          continue;
        }
        next_j = next_j > 2 ? 2 : next_j;
        dp[i - 1][next_j] += dp[i][j];
        dp[i - 1][next_j] %= MOD;
      }
    }
  }

  ans = 0;
  for (int j = 0; j <= 2; j++) {
    ans += dp[0][j];
    ans %= MOD;
  }

  printf("%lld\n", ans);

  return 0;

}




Measured memory_bytes: 128
import math
from itertools import permutations 
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
ans_ = 0
count = 0
sum_list = list(permutations(range(N), N))
for nums in sum_list:
    for i in range(len(nums)-1):
        x1, y1 = xy[nums[i]]
        x2, y2 = xy[nums[i+1]]
        ans_ += math.sqrt((x1-x2)**2+(y1-y2)**2)
    count += 1
print(ans_ / count)

Measured memory_bytes: 13712
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		int i = scan.nextInt();

		int h = i / 3600;
		i = i - h * 3600;



		int m = i / 60;

		int s = i - m * 60;

		System.out.println(h + ":" + m + ":" + s);

		scan.close();


	}

}

Measured memory_bytes: 26216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string mp[400];
pii boss[405][405];
int cnt[2][405][405],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},h,w;

pii finds(pii x)
{
	if(boss[x.F][x.S]==x) return x;
	return boss[x.F][x.S]=finds(boss[x.F][x.S]);
}

bool check(int x,int y,char c)
{
	return !(x<0||y<0||x>=h||y>=w||mp[x][y]==c);
}

void Union(pii x,pii y)
{
	x=finds(x),y=finds(y);
	boss[x.F][x.S]=y;
}

int main()
{jizz
	ll ans=0;
	cin >> h >> w;
	for(int i=0;i<h;++i)
	{
		cin >> mp[i];
		for(int j=0;j<w;++j)
			boss[i][j]=MP(i,j);
	}
	for(int i=0;i<h;++i)
		for(int j=0;j<w;++j)
			for(int k=0;k<4;++k)
				if(check(i+dx[k],j+dy[k],mp[i][j]))
					Union(MP(i,j),MP(i+dx[k],j+dy[k]));
	for(int i=0;i<h;++i)
		for(int j=0;j<w;++j)
		{
			boss[i][j]=finds(MP(i,j));
			if(mp[i][j]=='#') ++cnt[0][boss[i][j].F][boss[i][j].S];
			else ++cnt[1][boss[i][j].F][boss[i][j].S];
		}
	for(int i=0;i<h;++i)
		for(int j=0;j<w;++j)
			ans+=(ll)cnt[0][i][j]*cnt[1][i][j];
	cout << ans << "\n";
}

Measured memory_bytes: 2944
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>


using namespace std;


typedef long long ll;


int main() {

	char X[200001];
	scanf("%s", X);

	const int len = strlen(X);


	int result = len;
	int afford_counter = 0;

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

		switch (X[i]) {

		case 'S':
			afford_counter++;
			break;

		case 'T':
			if (afford_counter > 0) {
				afford_counter--;
				result -= 2;
			}
			break;

		}
	}

	printf("%d", result);

	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    ll N,M;
    cin >> N >> M;

    if (abs(N-M) > 1) {
        cout << 0 << endl;
        return;
    }

    ll n = min(N, M);
    ll nfacrem = 1;
    for (int i = 2; i <= n; i++) {
        nfacrem = (nfacrem % 1000000007) * (i % 1000000007);
    }

    nfacrem %= 1000000007;
    if (N == M) {

        cout << (2 * nfacrem * nfacrem) % 1000000007 << endl;
    }else{
        cout << (nfacrem * ((nfacrem * (n+1)) % 1000000007)) % 1000000007 << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    string s;
    cin >> s;

    int n = s.size()-1;
    if(s[n] == '2' || s[n] == '4' || s[n] == '5' || s[n] == '7' || s[n] == '9'){
        cout << "hon" << endl;
    }else if(s[n] == '0' || s[n] == '1' || s[n] == '6' || s[n] == '8'){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }

    return 0;
}

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;

int a,b,c,d;
double l,r,e,f;
double mx;
vector <double> x,y;

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

        a *= 100;
        b *= 100;

        for (int i = 0; i <= 400; i ++) {
                for (int j = 0; j <= 400; j ++) {
                        if (i == 0 && j == 0)
                                continue;
                        if (i * a + j * b <= f)
                                x.pb(i * a + j * b);
                        else
                                break;
                }
        }
         for (int i = 0; i <= 400; i ++) {
                for (int j = 0; j <= 400; j ++) {
                        if (i == 0 && j == 0)
                                continue;
                        if (i * c + j * d <= f)
                                y.pb(i * c + j * d);
                        else
                                break;
                }
        }
        l = a;r = 0;
        for (int i = 0; i < x.size(); i ++) {
                for (int j = 0; j < y.size(); j ++) {
                        if (x[i] + y[j] <= f && e * x[i] >= y[j] * 100) {
                                if (y[j] * l > r * x[i])
                                        l = x[i],r = y[j];
                        }

                }
        }
        cout << l + r << " " << r << endl;
}


Measured memory_bytes: 2420
# coding: utf-8
# Your code here!
N = int(input())#全部でN段
h = list(map(int,input().split())) #高さリスト
dp = [99999 for i in range(N)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for j in range(1,N-1):
    dp[j+1]=min(dp[j]+abs(h[j]-h[j+1]),dp[j-1]+abs(h[j+1]-h[j-1]))
print(dp[N-1])

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

int		main(void)
{
	int N, L;

	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; i++)
		cin >> S[i];
	string tmp;
	int min;

	for (int i = 0; i < N - 1; i++)
	{
		min = i;
		for (int j = i + 1; j < N; j++)
		{
			if (strcmp(S[min].c_str(), S[j].c_str()) > 0)
				min = j;
		}
		tmp = S[i];
		S[i] = S[min];
		S[min] = tmp;
	}
	for (int i = 0; i < N; i++)
		cout << S[i];
}


Measured memory_bytes: 256
S = input()
test = S.split("/")
x = int(test[0])
y = int(test[1])
if x <= 2018 :
  print('Heisei')
if x == 2019:
  if y <= 4:
    print('Heisei')
  else:
    print('TBD')
else:
    print('TBD')

Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    vector<int> hoge(n);
    bool able=false;
    
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
        if(hoge.at(i)==1) able=true;
    }
    
    if(able){
        long long ans=0;
        long long count=1;
        
        for(int i=0;i<n;i++){
            if(hoge.at(i)==count){
                count++;
            }else{
                ans++;
            }
        }
        
        cout<<ans<<endl;
        
    }else{
        cout<<-1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n, k, h int
	fmt.Scanln(&n, &k)
	ans := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&h)
		if h >= k {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
vector<Long> pr, ex;
void fact(Long x) {
  for (Long i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      Long cnt = 0;
      while (x % i == 0) {
        x /= i;
        cnt++;
      }
      pr.pb(i);
      ex.pb(cnt);
    }
  }
  if (x > 1) {
    pr.pb(x);
    ex.pb(1);
  }
}
Long f(Long x) {
  Long ans = 0;
  Long cur = 1;
  while (x >= cur) {
    ans++;
    x -= cur;
    cur++;
  }
  return ans;
}
void solve() {
  Long num;
  cin >> num;
  fact(num);
  Long ans = 0;
  fore(i, 0, SZ(ex)) {
    ans += f(ex[i]);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  while (t--) solve();

  return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long CONST = 1000000007;

		int n = sc.nextInt();
		int k = sc.nextInt();
		
		System.out.println(n-k+1);
		FermatCombination fc = new FermatCombination(Math.max(n-k+1, k-1), CONST);
		for (int i = 2; i <= k; i++) {
			if(n-k < i-1) {
				System.out.println(0);
			}else {
				long temp1 = fc.combine(n-k+1, i);
				long temp2 = fc.combine(k-1, i-1);
				System.out.println(temp1 * temp2 % CONST);
			}
		}
	}

}
class FermatCombination {
	
	long factrial[]; //階乗を保持
	long inverse[];  //逆元を保持
	long MOD;
	
	FermatCombination(int size, long mod) {
		
		this.factrial = new long[size + 1];
		this.inverse = new long[size + 1];
		this.MOD = mod;
		
		this.factrial[0] = 1;
		this.inverse[0] = 1;
		
		for (int i = 1; i <= size; i++) {
			factrial[i] = (factrial[i - 1] * i) % MOD;  //階乗を求める
			inverse[i] = pow(factrial[i], (int) MOD - 2) % MOD; // フェルマーの小定理で逆元を求める
		}
	}
	
	long combine(int n, int k) {
		return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
	}
	
	long pow(long x, int n) { //x^n 計算量O(logn)
		long ans = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				ans = ans * x % MOD;
			}
			x = x * x % MOD; //一周する度にx, x^2, x^4, x^8となる
			n >>= 1; //桁をずらす n = n >> 1
		}
		return ans;
	}
}


Measured memory_bytes: 21204
while True:
  n,x = map(int,input().split())
  numbers =[]
  if n==0 and x==0:
    break;
  
  for i in range(1,n+1):
    numbers.append(i)
    
  count=0
  
  for i in range(len(numbers)):
    for j in range(i+1,len(numbers)):
      for m in range(j+1,len(numbers)):
        if (numbers[i] + numbers[j] + numbers[m]) == x:
          count = count + 1
          
  print(count)


Measured memory_bytes: 5600
def solve():
  s = input()
  n  = len(s)
  mod = 10**9+7
  reverses = s[::-1]
  if reverses[0] != "?":
    tmp = int(reverses[0])
    query = [0 for i in range(13)]
    query[tmp] += 1
  else:
    query = [0 for i in range(13)]
    for i in range(10):
      query[i] += 1
      
  digit = 1
  tmp = [0 for i in range(13)]
  for i in range(1,n):
    digit *= 10
    digit %= 13
    tmp = [0 for i in range(13)]
    
    if reverses[i] =="?":
      for k in range(10):
        for j in range(13):
          tmp[(k*digit + j)%13] += query[j]
      
    else:
      for j in range(13):
        tmp[(digit*int(reverses[i])+j)%13] += query[j]

    for i in range(13):
      tmp[i] %= mod
    query = tmp 
      
  print(query[5])
if __name__ == '__main__':
  solve()

Measured memory_bytes: 42972
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
struct Node{int p,l,r;};
Node T[MAX];
int n,D[MAX];
void print(int u){
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p==-1)cout << "root, ";
  else if(T[u].l==-1)cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  for(int i=0, c=T[u].l; c!=-1;i++,c=T[c].r){
    if(i)cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}
void rec(int u,int p){
  D[u]=p;
  if(T[u].r != -1)rec(T[u].r,p);
  if(T[u].l != -1)rec(T[u].l,p+1);
}
int main(){
  int d,v,c,l,r;
  cin >> n;
  for(int i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r =-1;
  }
  for(int i=0;i<n;i++){
    cin >> v >> d;
    for(int j=0;j<d;j++){
      cin >> c;
      if(j==0)T[v].l=c;
      else T[l].r = c;
      l=c;
      T[c].p = v;
    }
  }
  for(int i=0;i<n;i++){
    if(T[i].p==-1)r=i;
  }
  rec(r,0);

  for(int i=0;i<n;i++)print(i);
  return 0;
}


  
  

Measured memory_bytes: 7736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,a;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    cin>>a;
    n%=500;
    if(a>=n){cout<<"Yes\n";}
    else{cout<<"No\n";}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define str string
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() {
    fast();

    ll n;
    cin >> n;
    ll x,y,s=0;
    f(i,0,n)
    {
        cin >> x >> y;
        s+=y-x+1;
    }
    cout<<s;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 512
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    _min = A*(N-1)+B
    _max = A+B*(N-1)
    cnt = max(_max-_min+1,0)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
	ll f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
//**********head by yjjr**********
const int maxn=2e5+6;
int n,v,tot=-1,bin[26],R[26][maxn],num[26],f1[maxn<<2],f2[maxn<<2],a[maxn];
int main()
{
	n=read(),v=read();bin[0]=1;
	rep(i,1,20)bin[i]=bin[i-1]<<1;
	rep(i,1,n)a[i]=read();int x=v*2;
	while(x){
		x>>=1,tot++;
		rep(i,1,n-1){
			if(a[i+1]-a[i]<=x)continue;
			R[tot][++num[tot]]=i;
		}
		R[tot][++num[tot]]=n;
	}
	if(num[0]>tot+1){
		rep(i,1,n)puts("Impossible");
		return 0;
	}
	rep(s,0,bin[tot]-1)f2[s]=n+1;
	rep(s,0,bin[tot]-1)
        rep(i,1,tot){
            if(s&bin[i-1])continue;
            f1[s|bin[i-1]]=max(f1[s|bin[i-1]],*upper_bound(R[i]+1,R[i]+num[i]+1,f1[s]));
            f2[s|bin[i-1]]=min(f2[s|bin[i-1]],R[i][lower_bound(R[i]+1,R[i]+num[i]+1,f2[s]-1)-R[i]-1]+1);
        }
	rep(i,1,num[0]){
        bool flag=0;
        rep(s,0,bin[tot]-1)
            if(f1[s]>=R[0][i-1]&&f2[bin[tot]-1-s]<=R[0][i]+1){flag=1;break;}
        rep(j,R[0][i-1]+1,R[0][i]){
			if(flag)puts("Possible");else puts("Impossible");
		}
    }
	return 0;
}

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

int N;
vector<pair<long long, long long>> range;

inline long long digit(int i){ // i 桁目を求める これを作っておくと楽です
    return (1LL << i) * (i & 1 ? -1 : 1);
}

int main(){
    range.emplace_back(0, 1);
    for(int i = 1; i < 40; ++i){ // i 桁以下で表現できる範囲を計算します
        range.emplace_back(range.rbegin()->first + (i & 1 ? digit(i) : 0), range.rbegin()->second + (i & 1 ? 0 : digit(i)));
    }
    cin >> N;
    bool f = false; // 上の桁がずっと0ならfalse
    for(int i = 39; i >= 0; --i){
        if(range[i].first > N || range[i].second < N){
            putchar('1');
            f = true;
            N -= digit(i + 1);
        }else if(f){
            putchar('0'); // 上に何かあるので0を出力する
        }
    }
    cout << N << endl; // 一番下の桁
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include<cstdio>

int main(){
  int N;
  scanf("%d", &N);
  int in;
  int m_in = 200000;
  int cn = 0;
  for(;N-->0;){
    scanf("%d", &in);
    if(m_in >= in){
      cn++;
      m_in = in;
    }
  }
  
  printf("%d\n", cn);
  
  return 0;
}

Measured memory_bytes: 384
from heapq import heappop, heappush, heapify

def main():
    N, M, S = map(int, input().split())
    S = min(S, 2500)
    edge = [[] for _ in range(N)]
    for _ in range(M):
        U, V, A, B = map(int, input().split())
        U -= 1
        V -= 1
        edge[U].append((V, A, B))
        edge[V].append((U, A, B))
    exchange = []
    for _ in range(N):
        C, D = map(int, input().split())
        exchange.append((C,D))

    dp = [[float('inf')] * 2510 for _ in range(N)]
    dp[0][S] = 0

    q = [(0,0,S)]
    while q:
        dist, v, money = heappop(q)
        if dp[v][money] < dist:
            continue
        for nv, fare, cost in edge[v]:
            nm = money - fare
            if nm < 0:
                continue
            if dp[nv][nm] > dp[v][money] + cost:
                dp[nv][nm] = dp[v][money] + cost
                heappush(q, (dp[nv][nm], nv, nm))
        
        nm = min(money+exchange[v][0], 2500)
        if dp[v][nm] > dp[v][money] + exchange[v][1]:
            dp[v][nm] = dp[v][money] + exchange[v][1]
            heappush(q, (dp[v][nm], v, nm))

    for i in range(1,N):
        print(min(dp[i]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 96084
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 250002
#define in(x)  cin>>x
#define o(x)  cout<<x
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<P>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS];
ll board[502][502];
int main()
{
    fast;
    S s;
    in(s);
    if(s[0]==s[1] and s[1]==s[2] and s[0]=='R')c=3;
    else if(s[0]==s[1] and s[0]=='R')c=2;
    else if(s[1]==s[2] and s[1]=='R')c=2;
    else if(s[0]=='R' or s[1]=='R' or s[2]=='R')c=1;
    o(c);
}


Measured memory_bytes: 3664
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.datetime;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto l = readInts();
		foreach(li; l) {
			if(li < 0) {
				return;
			}
		}
		auto d1 = Date(l[0], l[1], l[2]);
		auto d2 = Date(l[3], l[4], l[5]);
		writeln((d2-d1).total!"days");
	}
}

Measured memory_bytes: 1232
function check(x){
if(x%4!=0)return false;
if(x%400==0)return true;
if(x%100==0)return false;
return true;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
   if(Arr[i]=="0 0")break;
   if(i!=0)console.log("");
   var a=(Arr[i].split(" "))[0]-0;
   var b=(Arr[i].split(" "))[1]-0;
   var arr=[];
   for(var j=a;j<=b;j++){
      if(check(j))arr.push(j);
   }
   if(arr.length==0)console.log("NA");
   if(arr.length!=0)arr.forEach(function(v){console.log(v);});
}

Measured memory_bytes: 10572
class Array
	def avg
		inject(0.0){|r, i| r += i.to_i} / size
	end
	def variance
		a = avg
		inject(0.0){|r, i| r += (i.to_i - a) ** 2} / size
	end
	def standard_deviation
		Math.sqrt(variance)
	end
end

while true do 
	n = gets.to_i
	break if n == 0
	puts gets.split.map(&:to_i).standard_deviation
end

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h,w;
    cin>>h>>w;
    vector<vector<int>> g(h,vector<int>(w,inf));
    map<pair<int,int>,pair<int,int>> m;
    vector<string> f(h);
    for(int i=0;i<h;++i)cin>>f[i];
    m[{0,0}] = {-1,-1};
    g[0][0] = 0;
    queue<pair<int,int>> q;
    q.push({0,0});
    vector<pair<int,int>> dv = {{0,-1},{-1,0},{1,0},{0,1}};
    while(!q.empty()){
        auto cur = q.front();q.pop();
        int y = cur.first;
        int x = cur.second;
        for(auto & d : dv){
            int dy = y + d.first;
            int dx = x + d.second;
            if(dy < 0 or dx < 0 or dy > h-1 or dx > w-1 or f[dy][dx] == '#')continue;
            if(g[dy][dx] > g[y][x] + 1){
                m[{dy,dx}] = {y,x};
                g[dy][dx] = g[y][x] + 1;
                q.push({dy,dx});
            }
        }
    }

    if(g[h-1][w-1] == inf){
        cout << -1 << endl;
        return 0;
    }
    for(pair<int,int> cur = {h-1,w-1};;cur = m[cur]){
        f[cur.first][cur.second] = '#';
        if(cur.first == 0 and cur.second == 0)break;
    }
    int ret = 0;
    for(int i=0;i<h;++i)for(int j=0;j<w;++j){
        if(f[i][j] != '#')ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3768
import java.util.*;

class Main {
    
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int datasets = in.nextInt();
        for(int k = 0; k < datasets; k++){
            String s1 = in.next();
            String s2 = in.next();
            int len1 = s1.length();
            int len2 = s2.length();
            int[][] arr = new int[len1 + 1][len2 + 1];
            int lcs = 0;
            
            for(int i=1; i<=len1; i++) {
					for(int j=1; j<=len2; j++) {
						if(s1.charAt(i-1) == s2.charAt(j-1)){
						    arr[i][j] = arr[i-1][j-1] + 1;
						}
						else {
							arr[i][j] = Math.max(arr[i][j-1], arr[i-1][j]);
						}
						lcs = arr[i][j];
					}
					
            }
            System.out.println(lcs);
        }
        in.close();
    }
}


Measured memory_bytes: 64292
N, K = map(int, input().split())
d = []
A = []
for _ in range(K):
  d.append(int(input()))
  A.append(list(map(int, input().split())))

l = [1]*N
for i in range(K):
  for j in range(d[i]):
    l[A[i][j]-1] = 0
    
print(sum(l))

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

int N, T, A;
int main() {
    cin >> N >> T >> A;
    A *= 1000;

    int ans = -1;
    int diff = 1000000.0;
    for(int i = 0; i < N; ++i) {
        int h;
        cin >> h;
        int temp = 1000 * T - (h * 6);
        if(diff > abs(A - temp)) {
            diff = abs(A - temp);
            ans = i;
        }
    }
    cout << ans + 1 << endl;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n;

    cin>>n;

    li a[n];

    li tp=0;

    f(i,0,n-1)
    {
        cin>>a[i];
        tp^=a[i];
    }

    vi ans(n);

    f(i,0,n-1)
    {
        ans[i]=tp^a[i];
    }

    for(li i:ans)
        cout<<i<<" ";
}

int main()
{    
    

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 6276
import sys
sys.setrecursionlimit(10 ** 9)

n,m = map(int,input().split())

root = [-1]*n

def find(x):
    if root[x] < 0:
        return x
    else:
        root[x] = find(root[x])
        return root[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 
    root[x] += root[y]
    root[y] = x

def size(x):
    x = find(x)
    return -root[x]

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)

ans = 0
for i in range(n):
    ans = max(ans, size(i))

print(ans)



Measured memory_bytes: 35884
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 0;i * i <= n;i++){
    ret.push_back(i);
    if(i*i != n) ret.push_back(i);
  }
  sort(ALL(ret));
  return ret;
}

signed main()
{
  ios();
  int M,N;
  cin >> N >> M;
  int maxL = -1 ,minR = N;
  rep(i,M) {
    int L,R;
    cin >> L >> R;
    chmax(maxL,L);
    chmin(minR,R);
  }  
  cout << max(minR - maxL +1  ,0LL) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
using namespace std;
const int mod=1e9+7;

int solve(){
    int n;
    cin>>n;
    return !n;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,a;
    cin>>h>>a;
    cout << (h+a-1)/a<<endl;
    return 0;
}


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

int main() {
  int K,X;
  cin >> K >> X;
  
  if (500 * K >= X) {
    cout << "Yes" << endl;
  }
  
  if (500 * K < X) {
    cout << "No" << endl;
  }
}

 













Measured memory_bytes: 256
import heapq  # heapqライブラリのimport

N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(len(A)):
  A[i] = A[i] * (-1)

heapq.heapify(A)  # リストを優先度付きキューへ

for i in range(M):
  work = heapq.heappop(A)
  work = (((-1) * work ) // 2) * (-1)
  heapq.heappush(A, work)
  
print(sum(A) * (-1))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
long long n;
long long s;
bool check(long long x){
	long long d=0;
	long long m=n;
	while(m){
		d+=m%x;
		m/=x;
	}
	return d==s;
}
long long get(){
	long long m=sqrt(n)+1;
	for(long long i=2;i<=m;++i)
		if(check(i))
			return i;
	long long d=n-s;
	if(d<0) return -1;
	if(d==0) return n+1;
	long long r=1e11;
	for(long long i=1;i<=m;++i)
		if(d%i==0){
			long long a0=s-i,b=d/i+1;
			if(a0>=0&&a0<b&&i<b&&b>=2) r=min(r,b);
		}
	return r==1e11?-1:r;
}
int main(){
    cin>>n>>s;
    cout<<get();
	return 0;
}

Measured memory_bytes: 256
a,b,c,k = map(int,input().split())
res = 0

if a > 0:
    if a <= k:
        res += a
        k -= a
    elif a > k:
        res += k
        k = 0

if k > 0 and b > 0:
    if b <= k:
        k -= b
    elif b > k:
        k = 0

if k > 0 and c > 0:
    if c <= k:
        res -= c
        k -= c
    elif c > k:
        res -= k
        k = 0

print(res)

Measured memory_bytes: 61740