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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

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

	int n;
	scanf("%d", &n);

	std::vector<int> v(n);

	priority_queue < double > q;

	for (int &a : v) {
		scanf("%d", &a);	
		q.push(double(-a));
	}

	while (q.size() > 1) {	
		double x = -q.top(); q.pop();
		double y = -q.top(); q.pop();
		q.push (-( (x + y) / 2.0) );
	}

	cout << fixed << setprecision(10) << (-q.top()) << '\n';







	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll N = 1e5+5;

int ans[N];
char s[N];
int main(){
    int a=0,b=0;
    cin>>s;
    int n=strlen(s);
    for(int i=0;i<n;i++){
        if(s[i]=='0')a++;
        else b++;
    }
    printf("%d\n",min(a,b)*2);
    return 0;
}


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

int n;

int main(){
	cin >> n;
	int mx = INT_MAX, cnt = 0;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		mx = min(mx, val);
		if(mx >= val) cnt++;
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 300;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int d[MAX][MAX];

void warshall_floyd(int V){
    rep(i, V){
        rep(k, V){
            rep(j, V)if(k != j) d[k][j] = min(d[k][j], d[k][i] + d[i][j]);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, r;
    cin >> n >> m >> r;
    //-1に入れる
    int rr[r];
    rep(i, r) cin >> rr[i];
    rep(i, r) rr[i] --;
    rep(i, MAX)rep(j, MAX)d[i][j] = INF;
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
    }
    warshall_floyd(n + 1);
    rep(i, MAX) d[i][i] = 0;
    //rep(i, n)rep(j, n)cout << d[i][j] << endl;
    ll ans = INF;
    ll ans_1 = 0;
    sort(rr, rr + r);
    rep(i, r - 1){
        ans_1 += d[rr[i]][rr[i + 1]];
        //cout << d[rr[i]][rr[i + 1]] << endl;
    }
    if(ans_1 < ans) ans = ans_1;
    while(next_permutation(rr, rr + r)){
        ans_1 = 0;
        rep(i, r - 1){
            ans_1 += d[rr[i]][rr[i + 1]];
            //cout << d[rr[i]][rr[i + 1]] << endl;
        }
        if(ans_1 < ans) ans = ans_1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

typedef long long T;
bool check(T mm, T r) {
	T m = mm - 1;
	return m > 0 && r < m;
}

int main() {
	T n; std::cin >> n;
	T ans = 0;
	std::set<T> ms;
	for (T i = 1; i * i <= n; ++i) if (n % i == 0) {
		T a = i, b = n / i;
		if (check(a, b)) ms.insert(a - 1);
		if (check(b, a)) ms.insert(b - 1);
	}
	for (auto m : ms) ans += m;
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
  int N, D, count;
  cin >> N >> D;
  vector<double> x(N);
  vector<double> y(N);
  count = 0;
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
   double a = x[i] * x[i];
   double b = y[i] * y[i];
   double c = sqrt(a+b);
    if(c <= D){
      count++;
   }
   
   }
     
  
cout << count << endl;
   
}

Measured memory_bytes: 6428
S = str(input())

S_zen = list(S[0:len(S)//2])
S_kou = list(reversed(list(S[len(S)//2:])))

#print(S_zen)
#print(S_kou)

cnt =0

for i in range(len(S_zen)):
    if not S_zen[i] == S_kou[i]:
        cnt +=1
print(cnt)



Measured memory_bytes: 3060
#[test]
fn test_solve() {
    assert_eq!(solve("3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n"), "5\n");
    assert_eq!(solve("4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n"), "0\n0\n");
    assert_eq!(solve("5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n"), "0\n5\n0\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let d: usize = sc.read();
    let mut ida = vec![(0, 0); h * w];
    for i in 0..h {
        for j in 0..w {
            let a: usize = sc.read();
            ida[a - 1] = (i, j);
        }
    }
    
    let def = |a, b| {
        if a > b {
            a - b
        } else {
            b - a
        }
    };
    let cst = |a, b| {
        let (i, j) = ida[a];
        let (p, q) = ida[b];
        def(i, p) + def(j, q)
    };

    let mut sum = vec![vec![0; h * w / d + 2]; d];
    for r in 0..d {
        let mut i = 0;
        let mut v = i * d + r;
        while v + d < h * w {
            sum[r][i + 1] = sum[r][i] + cst(v, v+d);
            i += 1;
            v += d;
        }
    }

    let mut ret = String::new();
    use std::fmt::Write;

    let q: usize = sc.read();
    for _ in 0..q {
        let l: usize = sc.read();
        let r: usize = sc.read();
        let (l, r) = (l-1, r-1);
        let rem = l % d;
        writeln!(&mut ret, "{}", sum[rem][r/d] - sum[rem][l/d]).unwrap();
    }

    ret
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


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

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


Measured memory_bytes: 3084
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int count1 = 0;
        int count2 = 0;
        
        for (int i = 0; i < str.length(); i++) {
            String s = String.valueOf(str.charAt(i));
            
            if (i % 2 == 0) {
                if (s.equals("0")) {
                    count1++;
                }
            } else {
                if (s.equals("1")) {
                    count1++;
                }
            }
        }
        
        for (int i = 0; i < str.length(); i++) {
            String s = String.valueOf(str.charAt(i));
            
            if (i % 2 == 1) {
                if (s.equals("0")) {
                    count2++;
                }
            } else {
                if (s.equals("1")) {
                    count2++;
                }
            }
        }
        
        int answer = Math.min(count1, count2);
        System.out.println(answer);
    }
}

Measured memory_bytes: 35168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    char a;
    cin >> a;
    if(isupper(a)){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




string S;

long long solve() {
    string T = "";
    for (int i = 0; i < S.size(); ++i) {
        if (i + 1 < S.size() && S[i] == 'B' && S[i+1] == 'C') {
            T += "D";
            ++i;
        }
        else {
            T += S[i];
        }
    }

    //COUT(S); COUT(T);

    reverse(T.begin(), T.end());
    long long cur = 0;
    long long res = 0;
    for (int i = 0; i < T.size(); ++i) {
        if (T[i] == 'A') res += cur;
        else if (T[i] == 'D') ++cur;
        else cur = 0;
    }
    return res;
}

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

    while (cin >> S) {
        cout << solve() << endl;
    }
}
















Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//UnionFind
//全て添字で扱うこと
struct uf {
  vll parent;

  void init_uf(ll n) {
    for (ll i = 0; i < n; i++) parent.push_back(i);
    return;
  }

  ll root(ll n) {
    if (parent[n] == n) return n;
    return parent[n] = root(parent[n]);
  }

  void unite(ll a, ll b) {
    ll ra = root(a), rb = root(b);
    parent[rb] = ra;
    return;
  }
};

int main() {
  ll n, m;
  cin >> n >> m;

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

  vector<vll> xy(m, vll(2));
  for (ll i = 0; i < m; i++) {
    cin >> xy[i][0] >> xy[i][1];
    if (xy[i][0] > xy[i][1]) swap(xy[i][0], xy[i][1]);
  }

  uf uf1;
  uf1.init_uf(n);

  for (ll i = 0; i < m; i++) {
    uf1.unite(xy[i][0] - 1, xy[i][1] - 1);
  }

  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (uf1.root(i) == uf1.root(p[i] - 1)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 7672
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  string S,msg;
  msg ="Three";
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y"){
      msg = "Four";
      break;
    }
  }
  cout << msg << endl;
}

Measured memory_bytes: 256
x,k,d = map(int, input().split())
n = abs(x)//d 
if n > k:
    ans = abs(x)-k*d
else:
    # print(n)
    rest = n - k
    x_now = abs(x) - n*d
    ans = abs(x_now - d*(rest%2))
print(ans)

Measured memory_bytes: 61732
myArray = list()
for n in range(5):
    myArray.append(int(input()))
Jouyo  = 9
jouyoi = 0

for i,j in enumerate(myArray):
    if 0 < j % 10 <= Jouyo:
        Jouyo = j % 10
        jouyoi = i
times = 0
for i,j in enumerate(myArray):
    if i != jouyoi:
        if j % 10 != 0:
            times += ((j // 10) + 1) * 10
        else:
            times += j
    else:
        times += j
print(times)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
vector<char>Alphabet = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M','N','O','P','Q','R','S','T','U','V','W','X','Z' };
int main() {
	int H, W; cin >> H >> W;
	vector<vector<string>>S(H, vector<string>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S.at(i).at(j);
			if (S.at(i).at(j) == "snuke") {
				cout << Alphabet.at(j) << i + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
program main
Implicit None
	integer(8)::n,i,a
	integer(8),allocatable::c(:),v(:)
	
	read*,n
	allocate(c(n),v(n))
	read*,v
	read*,c
	
	a = 0
	do i = 1,n
		if(v(i) > c(i)) a = a+v(I)-c(i)
	enddo
	
	print "(i0)",a
end program main

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = new int[1000000];
		int s = sc.nextInt();
		sc.close();
		int i = 1;
		int previous = s;
		array[previous-1] = 1;
		while(true) {
			previous = getFN(previous);
			if(array[previous-1] != 1) {
				array[previous-1] = 1;
				i++;
			}else
				break;
		}
		System.out.println(i+1);
		
	}
	
	static int getFN(int n) {
		if(n%2 == 0) {
			return n/2;
		}else {
			return 3*n+1;
		}
	}
}

Measured memory_bytes: 25940
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
n, h_list = gets_n_and_i_list

max_count = 0
count = 0

1.upto(n-1) do |i|
  if h_list[i-1] >= h_list[i]
    count += 1
  else
    max_count = [max_count, count].max
    count = 0
  end

  if i == n -1
    max_count = [max_count, count].max
  end

  dpp [h_list[i-1], h_list[i], count]
end

puts max_count

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

int main(){
  int n,a,w,t,r;
  a=0;w=0;t=0;r=0;
  cin >> n;
  string s[n];
  for(int i=0; i<n; i++){
    cin >> s[i];
  }

  for(int i=0; i<n; i++){
    if(s[i] == "AC")a++;
    else if(s[i] == "WA")w++;
    else if(s[i] == "TLE")t++;
    else if(s[i] == "RE")r++;
  }

  cout << "AC" << " " << "x" << " " <<  a << endl;
  cout << "WA" << " " << "x" << " " <<  w << endl;
  cout << "TLE" << " " << "x" << " " << t << endl;
  cout << "RE" << " " << "x" << " " << r << endl;

  return 0;
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3564
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
ll A[300000];
ll sum[60][300000] ={}; // bit が立っている場所の累積和

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];

    rep(i, N){
        rep(j, 60){
            if(i != 0) sum[j][i] = sum[j][i-1];
            sum[j][i] += (A[i]>>j)&1;
        }
    }

    ll ans = 0;
    rep(i, N-1){
        rep(j, 60){
            if((A[i]>>j)&1){
                ans += (1LL<<j)%MOD*( (N-i-1)-(sum[j][N-1]-sum[j][i]) );
            }
            else{
                ans += (1LL<<j)%MOD*(sum[j][N-1]-sum[j][i]);
            }
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 143232
a =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = gets.to_i

puts a[K-1]


Measured memory_bytes: 1788
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
dp = [ [0]*n for _ in range(2)]
dp[0][0]=a[0][0]
for i in range(1, n):
    dp[0][i] = dp[0][i-1]+a[0][i]

dp[1][0] = dp[0][0]+a[1][0]
for i in range(1,n):
    dp[1][i] = max(dp[0][i], dp[1][i-1])+a[1][i]
print(dp[1][-1])


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
 
int main(){
int n,x,r;

while(true){
	scanf("%d%d",&n,&x);
	if((n==0)&&(x==0))break;
	r=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if((x-i-j>j)&&(x-i-j<=n))r++;
		}
	}
	printf("%d\n",r);
}
//scanf("%d",&n);

return 0;
 
}

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

int main()
{
	int N, K;
	
	cin >> N >> K;
	
	int p[N];
	
	for(int i=0; i<N; i++)
	{
		cin >> p[i];	
	}
	
	sort(p, p+N);
	
	int T = 0;
	
	for(int i=0; i<K; i++)
	{
		T = T + p[i];
	}
	
	cout << T;
	
	return 0;
}

Measured memory_bytes: 3624
package main

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

const N = 1000000007

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	cntZeroZero := 0
	battles := make(map[PairInt][]int)

	for i := 0; i < n; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		ra, rb := Ratio(a, b)
		if ra == 0 && rb == 0 {
			cntZeroZero++
			continue
		}

		if rb <= 0 {
			ra, rb = ReverseRatio(ra, rb)
			pair := PairInt{ra, rb}
			_, exists := battles[pair]
			if !exists {
				battles[pair] = make([]int, 2)
			}
			battles[pair][1]++
		} else {
			pair := PairInt{ra, rb}
			_, exists := battles[pair]
			if !exists {
				battles[pair] = make([]int, 2)
			}
			battles[pair][0]++
		}
	}

	cnt := 1
	for _, battle := range battles {
		cntSub := Pow(2, uint(battle[0])) + Pow(2, uint(battle[1])) - 1
		cnt = cnt * cntSub % N
	}

	cnt = (cnt + cntZeroZero - 1) % N
  	cnt = cnt + N
    cnt = cnt % N

	fmt.Println(cnt)
}

type PairInt struct {
	A int
	B int
}

// util
// *   math/simple

func Ratio(x, y int) (int, int) {
	if x == 0 {
		if y == 0 {
			return 0, 0
		}
		return 0, 1
	} else if y == 0 {
		return 1, 0
	}

	sign := 1
	if x > 0 && y < 0 {
		sign = -1
	} else if x < 0 && y > 0 {
		sign = -1
	}

	x = Abs(x)
	y = Abs(y)
	var small, big int
	if x < y {
		small, big = x, y
	} else {
		small, big = y, x
	}
	gcd := GCD(small, big)
	return x / gcd, sign * y / gcd
}

func ReverseRatio(x, y int) (int, int) {
	sign := -1
	if x == 0 || y <= 0 {
		sign = 1
	}

	return Abs(y), sign * Abs(x)
}

func GCD(smaller, bigger int) int {
	rem := bigger % smaller
	if rem == 0 {
		return smaller
	}
	return GCD(rem, smaller)
}

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer = answer * base % N
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 31164
#include <stdio.h>
#include <limits.h>
#define A 101
#define WHITE 1
#define BLACK 2
#define NIL -2
 
int a[A][A], p[A], w[A][A], n;
 
prim(){
  int mincost,u,v,i,color[n],d[n];
 
  for( u = 0 ; u < n ; u++ ){
    d[u] = INT_MAX;
    p[u] = NIL;
    color[u] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    mincost = INT_MAX;
    for( i = 0 ; i < n ; i++ ){
      if( color[i] != BLACK && d[i] < mincost ){
    mincost = d[i];
    u = i;
      }
    }
     
    if(mincost == INT_MAX){
      break;
    }
 
    color[u] = BLACK;
     
    for( v =  0; v < n ; v++ ){
      if( color[v] != BLACK && w[u][v] < d[v] && w[u][v] != -1 ){
    p[v] = u;
    d[v] = w[u][v];
      }
    }
 
  }
 
} 
 
   
int main(){
  int i, j, sum=0;
 
  scanf("%d",&n);
 
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n; j++ ){
      scanf("%d", &a[i][j]);
      w[i][j] = a[i][j];
    }
  }
 
  prim();
 
  for( i = 0 ; i < n ; i++ ){
    if( w[i][p[i]] != -1 ){
      sum += w[i][p[i]];
    }
  }
 
  printf("%d\n",sum);
 
  return 0;
}

Measured memory_bytes: 680
#include<bits/stdc++.h>
#include<unordered_set>
#define int long long
using namespace std;
vector<vector<int>>g;
vector<vector<int>>dp;
//dp[i][0]-to black dp[i][1]-to white
const int mod = 1e9 + 7;

void dfs(int v,int p) {
	dp[v][0] = dp[v][1] = 1;
	for (auto u : g[v]) {
		if (u == p)continue;
		dfs(u, v);
		dp[v][0] *= dp[u][1];
		dp[v][0] %= mod;
		dp[v][1] *= dp[u][0] + dp[u][1];
		dp[v][1] %= mod;
	}
}
signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	g = vector<vector<int>>(n+1);
	dp = vector<vector<int>>(n+1, vector<int>(2));
	dp[0][0] = 1;
	dp[0][1] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ans = 0;
	dfs(1, 0);
	cout << (dp[1][0] + dp[1][1]) % mod;
	return 0;
}

Measured memory_bytes: 18176
a,b,k=gets.split.map(&:to_i)
def manu(x,y)
	x -= 1 if x%2 == 1
	x%2 == 0
	x /= 2
	y += x
	return x,y
end
k_odd = false
if k%2 == 1 then
	k -= 1
	k_odd = true
end
(k/2).times do
	a,b = manu(a,b)
	b,a = manu(b,a)
end
a,b = manu(a,b) if k_odd
puts [a,b].join(" ")

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V,int NV> class SegTree_1 {
public:
	vector<V> val;
	static V const def=-1LL<<60;
	V comp(V l,V r){ return max(l,r);};
	
	SegTree_1(){val=vector<V>(NV*2,def);};
	V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return def;
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=v;
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};

int N,M,K;
ll A[101010];
ll from[101010],to[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	FOR(i,N) cin>>A[i];
	
	FOR(i,N) from[i]=A[i];
	FOR(i,K-1) {
		deque<pair<ll,int>> Q;
		FOR(j,N) {
			if(Q.empty()) {
				to[j]=-1LL<<60;
			}
			else {
				while(Q.size() && j-Q.front().second>M) Q.pop_front();
				to[j]=(i+2)*A[j] + Q.front().first;
			}
			while(Q.size() && Q.back().first<=from[j]) Q.pop_back();
			Q.push_back({from[j],j});
		}
		swap(from,to);
	}
	
	cout<<*max_element(from,from+N)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  } 
  for (int i = 0; i < M; i++) {
    cin >> y[i];
  } 
  int war = true;
  sort(x.begin(), x.end(), greater<int>());
  sort(y.begin(), y.end());
  dumpv(x);
  dumpv(y);
  for (int i = Y; X < i; i--) {
    if (x[0] < i && i <= y[0]) {
      war = false;
    }
  }
  if (war)
    cout << "War" << endl;
  else
    cout << "No War" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int m,n;
vector<P> st;
vector<P> sts;
map<P,int> mst;
int main(void)
{
  while(1){
    cin >> m;
    if(!m) break;

    st.clear();
    sts.clear();
    map<P,int> mc;
    mst = mc;

    int x,y;
    cin >> x >> y;
    st.push_back(P(0,0));
    for(int i = 1; i < m; i++){
      int a,b;
      cin >> a >> b;
      st.push_back(P(a-x,b-y));
    }
    cin >> n;
    for(int i = 0; i < n; i++){
      int a,b;
      cin >> a >> b;
      mst[P(a,b)] = 1;
      sts.push_back(P(a,b));
    }

    for(int i = 0; i < n; i++){
      bool f =true;
      int nx = sts[i].F;
      int ny = sts[i].S;
      for(int j = 0; j < m; j++){
	if(!mst[P(nx + st[j].F, ny + st[j].S)]){
	  f = false;
	  break;
	}
      }
      if(f){
	cout << nx - x << " " << ny - y << endl;
	break;;
      }
    }
  }
}

Measured memory_bytes: 1308
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    ll n, m;
    cin>>m>>n;
    ll two;
    ll ans = 1;
    ll tmpans;
    while(n>0){
        two = 1;
        tmpans = m;
        while(2*two <= n){
            two *= 2;
            tmpans *= tmpans;
            tmpans %= mod;
        }
        n -= two;
        ans *= tmpans;
        ans %= mod;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3120
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
#define N 1000000
int main(){
  int i, j, k, v, g, cnt=0, m=1, n, A[N], G[N];
 
  scanf("%d",&n);
  if(n > N) exit(1);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  G[0] = 1;
  while(1){
    G[m] = 3*G[m-1]+1;
    if(G[m] > n || m > 100) break;
    m++;
  }
 
  for(i = m-1; i >= 0; i--){
    g = G[i];
 
    for(j = g; j < n; j++){
      v = A[j];
      k = j - g;
      while(k >= 0 && A[k] > v){
    A[k+g] = A[k];
    k = k - g;
    cnt++;
      }
      A[k+g] = v;
    }
  }
   
  printf("%d\n",m);
  for(i = m-1; i >= 0; i--){
    if(i < m-1) printf(" ");
    printf("%d",G[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  for(i = 0; i < n; i++){
    printf("%d\n",A[i]);
  }
  return 0;
}

Measured memory_bytes: 5544
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int n;
int a, odd, even;

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
      cin >> a;
      if (a % 2 == 0) even++;
      else odd++;
   }

   if (odd % 2 == 1) cout << "NO" << endl;
   else cout << "YES" << endl;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
a = ['3','5','7']
ans = 0

#Nの桁数は9以下なので，3,4,...,9桁の整数について七五三数であるかを判定すればよい
3.step(9) {|i| #iは桁数
  ans += a.repeated_permutation(i).count {#3,5,7のいずれかを用いてi桁の整数を作り，条件を満たすものをカウントする
  #3,5,7を1回以上用いる＆N以下
  |b| b.uniq.size == 3 && b.join.to_i <= N
  }
}
puts ans


Measured memory_bytes: 1916
#include <cstdio>
typedef long long ll;
int gcd(int a, int b)
{
    return b == 0? a : gcd(b, a%b);
}
int lcm(int a, int b)
{
    return a*(b/gcd(a,b));
}
int main()
{
    int a, b;
    while(~scanf("%d%d", &a, &b))
    {
        printf("%d %d\n", gcd(a, b), lcm(a, b));
    }
    return 0;
}

Measured memory_bytes: 2608
object Main extends App {
  val NT = io.StdIn.readLine.split(' ').map(_.toInt)
  val N = NT.head
  val T = NT.last
  val cts = (1 to N).map(i => io.StdIn.readLine.split(' ').map(_.toInt))

  val candidates = cts.filter(cti => cti(1) <= T)

  val out = if (candidates.isEmpty) "TLE" else candidates.map(_.head).min

  println(out)
}

Measured memory_bytes: 27312
import java.util.Scanner;

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

	int h = time/(60*60);
	int m = time/60%60;
	int s = time%60;

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



Measured memory_bytes: 26416
S=gets.chomp

arr = [0]*S.length

i = 0
loop do
  idx = S.index('L',i)
  c = idx-i
  arr[idx] += c/2
  arr[idx-1] += c/2+(c%2)
  i = S.index('R',idx) || S.length
  c = i-idx
  arr[idx-1] += c/2
  arr[idx] += c/2+(c%2)
  break if i == S.length
end

puts arr.join(' ')



Measured memory_bytes: 5244
#include <stdio.h>

int main(){
    int n,k;
    scanf("%d %d", &n,&k);

    int d[k];
    int a[n];
    int i,j,tmp, cnt = 0;

    for(i = 0; i < n; i++){
        a[i] = 0;
    }

    for(i = 0; i < k; i++){
        scanf("%d", &d[i]);
        for(j = 0; j < d[i]; j++){
            scanf("%d", &tmp);
            a[tmp-1] = 1;
        }
    }
    for(i = 0; i < n; i++){
        if(a[i] == 0){
            cnt++;
        }
    }
    printf("%d", cnt);
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
using namespace std;
pair<int, int>x[100]; int n;
int main() {
	while(true) {
		cin >> n; if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> x[i].second >> x[i].first;
		}
		sort(x, x + n);
		int cnt = 0, ok = 0;
		for (int i = 0; i < n; i++) {
			cnt += x[i].second;
			if (cnt > x[i].first) {
				ok = 1;
			}
		}
		if (ok == 1) { cout << "No" << endl; }
		else { cout << "Yes" << endl; }
	}
	return 0;
}

Measured memory_bytes: 1156
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> n>>k;
    int ans = 0;
    while(n>0){
        ans++;
        n/=k;
    }
    cout << ans << "\n";
}


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

using namespace std;
typedef long long ll;

const ll maxn = 1e5;
ll n,q;

ll seg[maxn*4+7];

void add(int id, int l, int r, int idx, int val)
{

    if(l+1 == r)
        {
            seg[id]+=val;
            return;
        }

    int mid=(l+r)/2;
    if(idx < mid)
        add(id*2, l, mid, idx, val);
    else
        add(id*2+1, mid, r, idx, val);

    seg[id]+=val;

}

ll ask(int id, int L, int R, int l, int r)
{
    if( l<=L && R<=r)
        return seg[id];

    int mid=(L+R)/2;
    ll x1=0,x2=0;

    if(r > mid)
        x1=ask(id*2+1 ,mid,R, max(l,mid), r);

    if(l<mid)
        x2=ask(id*2, L,mid, l, min(r,mid));

    return x1+x2;
}


int main()
{
    cin>>n>>q;
    while(q--)
    {
        int x,y;
        int type;
        cin>>type>>x>>y;
        if(type==0)
            add(1,1,n+1,x,y);
        else
            cout<<ask(1,1,n+1,x,y+1)<<endl;
    }
}

Measured memory_bytes: 3216
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var W = input[0];
            var H = input[1];
            var x = input[2];
            var y = input[3];

            Console.WriteLine($"{W * H / 2.0} {(2 * x == W && 2 * y == H ? 1 : 0)}");
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
typedef long double ld;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main()
{
    int n,k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (h[i] >= k) count++;
    }
    cout << count << endl;
}

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

public class Main {

	void submit() {
		String s = nextToken();
		out.println(s.indexOf("AC") != -1 ? "Yes" : "No");
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 21332
#include <iostream>
const int money = 100;
const double interest = 1.01;
 
int main()
{
	long long int balance;	
  	std::cin >> balance;
  
    int year = 0;
    for(long long i = money; i < balance; i *= interest)
    {
       ++year;
    }
  
  	std::cout << year << std::endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	
	static int mod = (int)1e9+7;
	
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		for(int i=0;i<N;i++)A[i]=sc.nextLong();
		sc.close();

		long ans = 0;
		for(int i=0;i<60;i++) {
			int cnt = 0;
			for(int j=0;j<N;j++) {
				if(((A[j]>>i)&1)==1) cnt++;
			}
			long tmp = (long)cnt*(N-cnt) %mod;
			//ans += tmp<<i;　これだとオーバーフローする?
			long mul = (1L<<i)%mod;
			//long mul = (long)Math.pow(2, i) % mod;
			ans += (tmp * mul % mod);
			ans %= mod;	
		}
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 97996
using System;

class C
{
	static void Main()
	{
		Console.ReadLine();
		var s = Console.ReadLine();

		for (int i = s.Length - 1; i > 0; i--)
			if (i < s.Length && s[i - 1] == s[i])
			{
				var c = s[i].ToString();
				s = s.Replace(c + c, c);
			}
		Console.WriteLine(s.Length);
	}
}


Measured memory_bytes: 31452
import sys
def saiki(s, siki, n):
  if n == 4 and eval(siki) == 7:
    print(siki+'=7')
    sys.exit(0)
  elif n == 4:
    return

  saiki(s, siki + '+' + s[n], n+1)
  saiki(s, siki + '-' + s[n], n+1)
  

  
s = input()

siki = s[0]

saiki(s, siki, 1)

Measured memory_bytes: 3060
S=input()
Q=int(input())
rev = 0
front, back=[],[]
for i in range(Q):
  q = input()
  if len(q)==1:rev = 1- rev
  else:
    n,f,c=q.split()
    if f=='1' and rev==0:
      front.append(c)
    elif f=='2' and rev==1:
      front.append(c)
    elif f=='1' and rev==1:
      back.append(c)
    elif f=='2' and rev == 0:
      back.append(c)

if rev==0:
  S = ''.join(front[::-1]) + S + ''.join(back)
else:
  S = ''.join(back[::-1]) + S[::-1] + ''.join(front)
print(S)

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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
 vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x;
 while (getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
 template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}
//

int T;
const int N = 2e5 + 10;
int l, r, d;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif
    while (cin >> l >> r >> d)
    {
        int ans = 0;
        for (int i = l; i <= r; i++)
        {
            if (i % d == 0) ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import sys

class UnionFind(object):
    def __init__(self):
        self.node_id = {}
        self.parent_id = []
        self.rank = []

    def find(self, node_id):
        while node_id != self.parent_id[node_id]:
            pp = self.parent_id[self.parent_id[node_id]]
            self.parent_id[node_id] = pp
            node_id = pp
        return node_id

    def add(self, x):
        if x in self.node_id:
            return self.node_id[x]
        node_id = len(self.node_id)
        self.node_id[x] = node_id
        self.parent_id.append(len(self.parent_id))
        self.rank.append(0)
        return node_id

    def union(self, p, q):
        i = self.find(p)
        j = self.find(q)
        if i == j:
            return
        if self.rank[i] < self.rank[j]:
            self.parent_id[i] = j
        elif self.rank[i] > self.rank[j]:
            self.parent_id[j] = i
        else:
            self.parent_id[j] = i
            self.rank[i] += 1

    def dump_groups(self):
        result = []
        group_id = {}
        for x, i in self.node_id.items():
            j = self.find(i)
            if j not in group_id:
                group_id[j] = len(result)
                result.append([])
            result[group_id[j]].append(x)
        return result

    def dump_dot(self):
        result = """digraph { graph [rankdir=LR];\n"""
        for i, target in enumerate(self.parent_id):
            result += """"%s" [label=\"%s\",shape=plaintext,shape=circle];\n""" % (i, i)
            if i != target:
                result += """"%s" -> "%s";\n""" % (i, target)
        result += "}"
        return result

uf = UnionFind()
(n, q) = sys.stdin.readline().split()
for i in range(int(n)):
    uf.add(i)
for i in range(int(q)):
    (c, x, y) = sys.stdin.readline().split()
    if c == "0":
        uf.union(int(x), int(y))
    else:
        print(1 if uf.find(int(x)) == uf.find(int(y)) else 0)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vpll xy(n);
  rep(i,n){
    ll x,y; cin>>x>>y;
    xy[i]={x,y};
  }
  vsort(xy);
  double ans=0;
  do{
    double tmp=0;
    ll px=xy[0].first, py=xy[0].second;
    irep(i,1,n){
      ll X=(px-xy[i].first), Y=(py-xy[i].second);
      tmp+=sqrt(X*X+Y*Y);
    }
    ans+=tmp;
  }while(next_permutation(all(xy)));
  ll fact=1;
  reps(i,n) fact*=i;
  coutd(ans/fact);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int ans[300];
int q[1000][3],qtop;
int main(){
	int n,s,a,b,z,c[3];
	while(true){
	cin>>s>>a>>b;
	s+=a+b;
	if(!s)break;
	cin>>n;
	rep(i,s)ans[i]=2;
	qtop=0;
	rep(i,n){
		rep(j,3){cin>>c[j];c[j]--;}
		cin>>z;
		if(z)rep(j,3)ans[c[j]]=1;
		else{
			rep(j,3)q[qtop][j]=c[j];
			qtop++;
		}
	}
	rep(i,qtop){
		bool f[3]={false};
		rep(j,3)if(ans[q[i][j]]==1)f[j]=true;
		if(f[0]+f[1]+f[2]==2)rep(j,3)if(!f[j])ans[q[i][j]]=0;
	}
	rep(i,s)cout<<ans[i]<<endl;
	}
	return 0;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int x = stoi(a);
    rep(i, 1, 10000) {
        if (i * i == x) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
function main()
	n = parse(Int, readline())
    x = chomp(readline())
	l = 0
	r = 0
	for i in 1:length(x)
		if x[i] == '('
			l += 1
		elseif l == 0
			r += 1
		else
			l -= 1
		end
	end
	for i in 1:r
		print('(')
	end
	print(x)
	for i in 1:l
		print(')')
	end
end

main()

Measured memory_bytes: 110268
#include<stdio.h>

int main(void){
	
	int n,i,j,k,b,f,r,v;
	int count[4][3][10]={0};
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		count[b-1][f-1][r-1]+=v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",count[i][j][k]);
			}
			printf("\n");
		}
		if(i==3){
			break;
		}
		printf("####################\n");
	}	
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

const ll mod = 1e9 + 7;

int main() {
  ll n, res = 0;
  cin >> n;
  vector<ll> ans(65, 0);
  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    for (ll j = 0; j < 65; j++) {
      if (a == 0) break;
      if (a % 2 == 1) {
        ans.at(j)++;
        a--;
      }
      a /= 2;
    }
  }
  for (ll i = 0; i < 65; i++) {
    if (ans.at(i) == 0) continue;
    ll x = pow(2, i);
    ll y = x % mod;
    ll z = ans.at(i) * (n - ans.at(i)) % mod;
    ll tmp = (z * y) % mod;
    res += tmp;
  }
  cout << res % mod << endl;
}

Measured memory_bytes: 384
l = input().split()
N = int(l[0])
S = []
for i in range(N):
    l = input().split()
    S.append(l[0])

# print(N, S)

names = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0,
}

for s in S:
    h = s[0]
    if h in names:
        names[h] += 1

table = ['M', 'A', 'R', 'C', 'H']

# print(names)

ans = 0

for i in range(5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            # print(i, j, k)
            # print(names[table[i]])
            ni = names[table[i]]
            nj = names[table[j]]
            nk = names[table[k]]
            if ni == 0 or nj == 0 or nk == 0:
                continue
            ans += ni*nj*nk

print(ans)

Measured memory_bytes: 54744
N, M = map(int, input().split(' '))

conditions = []
for _ in range(M):
    s, c = input().split(' ')
    conditions.append((int(s) - 1, c))


def check(n):
    sn = str(n)
    if len(sn) != N:
        return False
    for s, c in conditions:
        if sn[s] != c:
            return False
    else:
        return True


for n in range(1000):
    if check(n):
        print(n)
        break
else:
    print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

void pr(bool f){
	if(f)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
};

signed main(){
	int X,Y;
	cin>>X>>Y;
	int ans = 0;
	if(X==1&&Y==1){
		ans+=400000;
	}
	if(X==1)ans+=300000;
	else if(X==2)ans+=200000;
	else if(X==3) ans+=100000;
	if(Y==1)ans+=300000;
	else if(Y==2)ans+=200000;
	else if(Y==3)ans+=100000;
	cout<<ans<<endl;
}

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

int main(void)
{
  char N[2000010];
  int sum = 0;
  int l,m;

  scanf("%s",N);
  l = strlen(N);
  l--;

  while(l >= 0)
  {
    sum += N[l] -'0';
    l--;
  }

  if(sum % 9 == 0)puts("Yes");
  else puts("No");
  
  return 0;
}


Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    int t = 1;
    rep(i, n){
        if(t<k)
            t*=2;
        else
            t+=k;
    }
    cout<<t<<endl;
}

Measured memory_bytes: 256