akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int main(){
  int n,m,a,b,c,i,j,k;
  long long ret=0,cnt,ret2=0;
  string s;
  cin >> s;
  cnt=0;
  for(i=0;i<s.size();i++){
    //wwwbbbで並べる
    if(s[i]=='W'){
      ret+=(long long)(i-cnt);
      cnt++;
    }
  }
  /*cnt=0;
  for(i=0;i<s.size();i++){
    //wwwbbbで並べる
    if(s[i]=='B'){
      ret2+=i-cnt;
      cnt++;
    }
  }*/
  cout << max(ret,ret2) << endl;
  return 0;
}


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

int main(){
    int n, c, k;
    cin >> n >> c >> k;

    vector<int> t(n+2);
    for(int i = 1; i <= n; i++) cin >> t[i];

    sort(t.begin()+1, t.end()-1);

    int ans = 0, time = 0, p = 0;
    for(int i = 1; i <= n; i++){
        if(time < t[i] || p >= c){
            time = t[i] + k;
            p = 0;
            ans++;
        }
        p++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 640
m,d=input().split()
a=[]
b=[]
c=0
for i in range(1,int(m)+1):
    a.append(i)
for i in range(10,int(d)+1):
    b.append(str(i))
# print(a)
# print(b)
for i in a:
    for j in range(len(b)):
        if(int(b[j][0])>=2 and int(b[j][1])>=2 and int(b[j][0])*int(b[j][1])==i):
            c+=1
print(c)

Measured memory_bytes: 39408
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int M, K;
  cin >> M >> K;

  if((1 << M) <= K){
    cout << -1 << "\n";
    return 0;
  }

  if(M == 0){
    cout << "0 0" << "\n";
    return 0;
  }
  if(M == 1){
    if(K == 0) cout << "0 0 1 1" << "\n";
    else cout << -1 << "\n";
    return 0;
  }

  REP(i, (1<<M)){
    if(i != K) cout << i << " ";
  }
  cout << K << " ";
  RREP(i, (1<<M)){
    if(i != K) cout << i << " ";
  }
  cout << K << "\n";

  return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l - 1) / d << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll X,N;
    cin >> X >> N;
    vl p(N);
    rep(i, N) cin >> p[i];
    sort(all(p));

    ll d = INF, ans = -1;
    repe(i, -1, 102){
        if (lower_bound(all(p), i) != p.end() and *lower_bound(all(p), i) == i) continue;

        if (chmin(d, abs(X - i))) ans = i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int arr[200001], arr2[200001], arr3[400001], reps[200001];

int main()
{
    int n, m, len, s1, s2, idx, idx2;
    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    for (int i = 0; i < m; i++) scanf("%d", &arr2[i]);

    len = n + m, s1 = s2 = idx = idx2 = 0;
    while (s1 < n && s2 < m) {
        if (arr[s1] == arr2[s2]) { reps[idx2++] = arr[s1]; arr3[idx++] = arr[s1++]; s2++; }
        else if (arr[s1] < arr2[s2]) arr3[idx++] = arr[s1++];
        else if (arr2[s2] < arr[s1]) arr3[idx++] = arr2[s2++];
    }
    if (s1 <= n - 1) while (s1 < n) arr3[idx++] = arr[s1++];
    if (s2 <= m - 1) while (s2 < m) arr3[idx++] = arr2[s2++];
    printf("%d %d\n", idx2, len - idx2);
    for (int i = 0; i < idx2; i++) printf("%d\n", reps[i]);
    for (int i = 0; i < idx; i++) printf("%d\n", arr3[i]);
     return 0;
}


Measured memory_bytes: 4616
a,b = map(int, input().split())
List = [list(map(int, input().split())) for i in range(2*b)]
list_all=[]
Output = 0
for i in range(b):
  list_all = list_all+List[2*i+1]
set_a = set(list_all)
Output = a- len(set_a)
print(Output)

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

using namespace std;

const int maxn = 1e5 + 100;

int n, m, cnt[3], tot;
vector<int> g[maxn], rg[maxn];
int lvl[maxn];
long long ans;
bool flag;

void dfs(int u, int c) {
	if(~lvl[u]) {
		if(lvl[u] != c) {
			flag = 1;
		}
		return;
	}
	++cnt[lvl[u] = c];
	tot += g[u].size();
	for (int v: g[u]) {
		dfs(v, (c + 1) % 3);
	}
	for (int v: rg[u]) {
		dfs(v, (c + 2) % 3);
	}
	return;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		rg[v].push_back(u);
	}
	memset(lvl + 1, -1, sizeof(lvl[0]) * n);
	for (int i = 1; i <= n; ++i) {
		if(!~lvl[i]) {
			memset(cnt, 0, sizeof(cnt));
			flag = 0;
			tot = 0;
			dfs(i, 0);
			if(flag) {
				cnt[0] += cnt[1] + cnt[2];
				ans += 1ll * cnt[0] * cnt[0];
			}
			else {
				if(cnt[0] && cnt[1] && cnt[2]) {
					ans += 1ll * cnt[0] * (cnt[1] + cnt[2]) + 1ll * cnt[1] * cnt[2];
				}
				else {
					ans += tot;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 16256
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, K = read_values()
    S = set(i for i in range(N))

    for _ in range(K):
        input()
        A = tuple(read_index())
        for a in A:
            if a in S:
                S.remove(a)
    
    print(len(S))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9892
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	string s;
	long long k;
	cin >> s >> k;
	int oneNum=0;
	for(int i=0; s[i]=='1'; i++)
		oneNum++;
	if(k>oneNum)
		cout << s[oneNum] << endl;
	else
		cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<28
#define mk make_pair
using namespace std;
int main(){
  int n,m,t;
  cin>>n>>m>>t;
  vector<pair<int,int> >a[n];
  rep(i,m){
    int q,w,e;
    cin>>q>>w>>e;
    a[q].push_back(mk(w,e));
  }
    priority_queue<P,vector<P>,greater<P> >q;
    int d[n];
    fill(d,d+n,INF);
    q.push(mk(0,t));
    d[t]=0;
    while(!q.empty()){
      P p=q.top();q.pop();
      int v=p.second;
      if(d[v]<p.first)continue;
      for(int i=0;i<a[v].size();i++){
        P ed=a[v][i];
        if(d[ed.first]>d[v]+ed.second){
          d[ed.first]=d[v]+ed.second;
          if(d[ed.first]<-200000)goto L;
          q.push(mk(d[ed.first],ed.first));
        }
      }
    }
  rep(i,n){
    if(d[i]==INF)cout<<"INF"<<endl;
    else cout<<d[i]<<endl;
  }
if(0)L:cout<<"NEGATIVE CYCLE"<<endl;
}

Measured memory_bytes: 6888
#include <stdio.h>
#define MAX 100

void Preorder(int);
void Inorder(int);
void Postorder(int);

struct Node{
  int parent, left, right;
};
 
struct Node Tree[MAX];
int n;

void Preorder(int i){
  printf(" %d",i);
  if ( Tree[i].left != -1 ) Preorder( Tree[i].left );
  if ( Tree[i].right != -1 ) Preorder( Tree[i].right );
}

void Inorder(int i){
  if( Tree[i].left != -1 ) Inorder( Tree[i].left );
  printf(" %d",i);
  if( Tree[i].right != -1 ) Inorder( Tree[i].right);
}
  
void Postorder(int i){ 
  if( Tree[i].left != -1 ) Postorder( Tree[i].left );
  if( Tree[i].right != -1 ) Postorder( Tree[i].right );
  printf(" %d",i);
  
}

int main(){
  int root = 0,i,j,a;
  scanf("%d",&n);
 
  for( i = 0 ; i < n ; i++ ){
    Tree[i].parent = -1;
    Tree[i].left = -1;
    Tree[i].right = -1;
  }

  for( i = 0; i < n ; i++ ){
    scanf("%d", &a);
    scanf("%d %d", &Tree[a].left, &Tree[a].right);
    if(Tree[a].left != -1) Tree[Tree[a].left].parent = a;
    if(Tree[a].right != -1) Tree[Tree[a].right].parent = a;
  }

  for( i = 0 ; i < n ; i++ ){
    if( Tree[i].parent == -1 ) root = i;
  }

  printf("Preorder\n");
  Preorder(root);

  printf("\nInorder\n");
  Inorder(root);

  printf("\nPostorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 616
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        if (a == b && b == c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
a,b,q = map(int, input().split())
s = [-5*10**10] + [int(input()) for _ in range(a)] + [5*10**10]
t = [-5*10**10] + [int(input()) for _ in range(b)] + [5*10**10]
a += 2
b += 2

def bis(x,lis,num):
    ok = 0
    ng = num
    while ng - ok > 1:
        mid = (ok+ng)//2
        if lis[mid] > x:
            ng = mid
        else:
            ok = mid
    return ok
for _ in range(q):
    x = int(input())
    sl = bis(x,s,a)
    tl = bis(x,t,b)
    sr = sl + 1
    tr = tl + 1
    sl = x-s[sl]
    sr = s[sr]-x
    tl = x-t[tl]
    tr = t[tr]-x
    dis = min(max(sr,tr),max(sl,tl),sr+tl+min(sr,tl),sl+tr+min(sl,tr))
    print(dis)

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

int convert(string s)
{
    long long int result=0;
    for(int i=0;i<s.size();i++)
    {
        result=result*10+(s[i]-'0');
    }
    return result;
}
int main()
{
    string s;
    cin>>s;
    long long int n,sum=0;

    n=convert(s);
    long long int k=n;
    while(n!=0)
    {

        sum=sum+n%10;

        n=n/10;
    }

    if(k%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    vector<int> A;
    for (int i = 0; i < 3; i++) {
        int Ai;
        cin >> Ai;
        A.push_back(Ai);
    }
    sort(A.begin(), A.end());
    int res = (A[1]-A[0])+(A[2]-A[1]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}

//小数点9桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }
    else{
        cout<<100*(10-n)+r<<endl;
    }

    
}


Measured memory_bytes: 256
package main

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

type Balls [][]int

func (b Balls) Len() int {
	return len(b)
}

func (b Balls) Less(i, j int) bool {
	if b[i][0] != b[j][0] {
		return b[i][0] < b[j][0]
	}
	return b[i][1] < b[j][1]
}

func (b Balls) Swap(i, j int) {
	b[i], b[j] = b[j], b[i]
}

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	balls := make(Balls, n)
	point := make(map[int]map[int]bool)
	for i := 0; i < n; i++ {
		scanner.Scan()
		x, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		y, _ := strconv.Atoi(scanner.Text())
		balls[i] = []int{x, y}
		if _, ok := point[x]; !ok {
			point[x] = make(map[int]bool)
		}
		point[x][y] = true
	}
	sort.Sort(balls)

	groups := make(map[int]map[int][][][]int)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			p := balls[j][0] - balls[i][0]
			q := balls[j][1] - balls[i][1]

			if _, ok := groups[p]; !ok {
				groups[p] = make(map[int][][][]int)
			}
			if _, ok := groups[p][q]; !ok {
				groups[p][q] = [][][]int{}
			}

			var found bool
			for _, g := range groups[p][q] {
				for _, ball := range g {
					if balls[j][0] == ball[0] && balls[j][1] == ball[1] {
						found = true
						break
					}
				}
				if found {
					break
				}
			}
			if found {
				continue
			}

			group := [][]int{
				{balls[i][0], balls[i][1]},
				{balls[j][0], balls[j][1]},
			}
			x := balls[j][0] + p
			y := balls[j][1] + q
			for point[x][y] {
				group = append(group, []int{x, y})
				x += p
				y += q
			}
			groups[p][q] = append(groups[p][q], group)
		}
	}

	min := n
	for _, val := range groups {
		for _, group := range val {
			cost := n
			for _, g := range group {
				cost -= len(g) - 1
			}
			if cost < min {
				min = cost
			}
		}
	}

	fmt.Println(min)
}


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

int main()
{
	while (true)
	{
		int H, W;
		char chr;

		cin >> H >> W;

		if (H == 0 && W == 0)
		{
			break;
		}

		for (int i = 0;i < H;i++)
		{
			for (int j = 0;j < W;j++)
			{
				if (i % 2 == 0)
				{
					chr = (j % 2 == 0) ? '#' : '.';
					cout << chr;
				}
				else
				{
					chr = (j % 2 == 0) ? '.' : '#';
					cout << chr;
				}
			}
			cout << '\n';
		}
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_map>

int main() {
    int n;
  	long ans = 0;
    std::unordered_map<std::string, int> string_map;
    std::cin >> n;
    std::string s;
    for (int i = 0; i < n; i++) {
        std::cin >> s;
        std::sort(s.begin(), s.end());
        if (string_map.find(s) == string_map.end()) string_map[s] = 0;
        else string_map[s] += 1;
    }
    for (auto &i: string_map) {
        long x = i.second;
        ans += x * (x + 1) / 2;
    }
    std::cout << ans << std::endl; 
}

Measured memory_bytes: 10660
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

R = get_int

puts 2 * Math::PI * R


Measured memory_bytes: 14408
S = input()

bf = ''
idx = []
bdiff = 0
diff = 0
rlt = 0

for i in range(len(S)):
  if bf != S[i]:
    idx.append(i)
  bf = S[i]

idx.append(len(S))
for i in range(len(idx)-1): 
  diff = idx[i+1] - idx[i]
  rlt += diff*(diff+1)//2
  if S[idx[i]] == '>':
    if bdiff < diff:
      rlt -= bdiff
    else:
      rlt -= diff
  bdiff = diff

print(rlt)

Measured memory_bytes: 52936
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		String s = r.str();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i<s.length(); i++)
			if((i%2)==0)
				sb.append(s.charAt(i));
		print(sb.toString());		
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


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

long long ns[51], ps[51];

long long count(int n, long long x){
    if(n == 0) return (x > 0) ? 1 : 0;

    if(x <= 0) return 0;
    if(x < ns[n-1] + 1) return count(n-1, x-1);
    if(x == ns[n-1] + 1) return ps[n-1];
    if(x == ns[n-1] + 2) return ps[n-1] + 1;
    if(x < 2*ns[n-1] + 2) return ps[n-1] + 1 + count(n-1, x-ns[n-1]-2);
    return ps[n];
}


int main(void){
    ns[0] = 1, ps[0] = 1;
    for(int i = 1; i <= 50; i ++){
        ns[i] = 2*ns[i-1] + 3;
        ps[i] = 2*ps[i-1] + 1;
    }
    
    int n;
    long long x;
    cin >> n >> x;
    cout << count(n, x) << "\n";
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

auto P = 10L^^9+7;

long[100][5][5][5] MEMO;

void main()
{
    auto N = readln.chomp.to!int;

    foreach (ref xx; MEMO) foreach (ref yy; xx) foreach (ref zz; yy) foreach (ref memo; zz) memo = -1;

    long solve(int i, int x, int y, int z) {
        if (i == N) return 1;
        if (MEMO[z][y][x][i] != -1) return MEMO[z][y][x][i];
        long r = (solve(i+1, y, z, 1) + solve(i+1, y, z, 4)) % P;
        if ( !(
            (y == 1 && z == 3) ||
            (x == 1 && z == 3) ||
            (y == 3 && z == 1) ||
            (x == 1 && y == 3)) ) r = (r + solve(i+1, y, z, 2)) % P;
        if ( !(y == 1 && z == 2) ) r = (r + solve(i+1, y, z, 3)) % P;
        return MEMO[z][y][x][i] = r;
    }

    writeln(solve(0, 0, 0, 0));
}

Measured memory_bytes: 384
n = int(input())
s = input()
q = int(input())
k = list(map(int, input().split()))
def solve(ki):
    D=M=DM=C=0
    for i in range(n):
        if s[i] == "D":
            D += 1
        elif s[i] == "M":
            M += 1
            DM += D
        elif s[i] == "C":
            C += DM
        if i >= ki-1:
            j = i-ki+1
            if s[j] == "D":
                D -= 1
                DM -= M
            elif s[j] == "M":
                M -= 1
    return C
for ki in k:
    print(solve(ki))

Measured memory_bytes: 60140
#include<stdio.h>
int main()
{
 int a,b,c;
 scanf("%d %d %d",&a,&b,&c);
 if((a>=b)&&(a>=c))
 {
    if(b>=c)
    {
     printf("%d %d %d\n",c,b,a);
    }
    else
    {
     printf("%d %d %d\n",b,c,a);
    }
 }
 else if((b>=a)&&(b>=c))
 {
    if(a>=c)
    {
     printf("%d %d %d\n",c,a,b);
    }
    else
    {
     printf("%d %d %d\n",a,c,b);
    }
 }
 else if((c>=a)&&(c>=b))
 {
  if(a>=b)
  {

     printf("%d %d %d\n",b,a,c);
  }
  else
  {
     printf("%d %d %d\n",a,b,c);
  }
}
return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (110)

/////////////////////////////////////////////////////////

void Main() {
  vector<int> bad3 = {9, 6, 33};
  vector<int> bad4 = {9, 73, 137, 201, 6, 70, 134, 198, 33, 97, 161, 225, 25, 41, 57, 37, 45};
	int N; cin >> N;
  
  vector<vector<int>> dp(MAX, vector<int>(64, 0));
  rep(i, 0, 64){
    if(find(all(bad3), i) != bad3.end()) continue;
    dp[3][i] = 1;
  }
  rep(i, 4, N + 1){
    rep(j, 0, 4){
      rep(k, 0, 64){
        int key = 4 * k + j;
        if(find(all(bad4), key) != bad4.end()) continue;
        key %= 64;
        dp[i][key] += dp[i - 1][k];
        dp[i][key] %= MOD;
      }
    }
  }
  
  int res = 0;
  rep(i, 0, 64){
    res += dp[N][i];
    res %= MOD;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    int cnt=0;
    rep(i,n-1){
        if(s[i]!=s[i+1]){cnt++;}
    }
    cout << min(n-1-cnt+k*2,n-1) << endl;
    return 0;
}


Measured memory_bytes: 512
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


string str;
int k;


int main(){

    ios_base::sync_with_stdio(0);

    cin>>str>>k;
    int n = str.length();
    for(int i=0;i<n&&k>0;i++){
        if(str[i] == 'a')   continue;
        int needed = 26 - (str[i]-'a');
// cout<<needed<<" "<<k<<endl;
        if(needed <= k){
            str[i] = 'a';
            k -= needed;
        }
    }

// cout<<str<<endl;

    k %= 26;
    for(int i=n-1;i>=0 && k>0;i--)
        if(true){
            while(k--)
                str[i]++;
        }

    cout<<str;
    return 0;
}






Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;
typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef map<int, int> M;
typedef pair<int, int> P;

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

    int n;
    cin >> n;
    int nmin = 2000000000;
    int nmax = -1;
    for (itn i = 0; i < n; ++i) 
    {
        int a;
        cin >> a;
        nmax = max(nmax, a);
        nmin = min(nmin, a);
    }
    cout << nmax - nmin << endl;

    return 0;
}

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

using namespace std;

typedef long long int64;

int main()
{
  int64 A, B, C, N, X[1000], Y[1000], Z[1000];

  cin >> A >> B >> C >> N;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> Z[i];
  }

  int add = 0;
  for(int i = 0; i < N; i++) {
    add += X[i] == 0;
    add += X[i] == A - 1;
    add += Y[i] == 0;
    add += Y[i] == B - 1;
    add += Z[i] == 0;
    add += Z[i] == C - 1;
    for(int j = 0; j < i; j++) {
      add += abs(X[i] - X[j]) + abs(Y[i] - Y[j]) + abs(Z[i] - Z[j]) == 1;
    }
  }
  cout << 2 * (A * B + B * C + A * C) + 6 * N - add * 2 << endl;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

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


int main() {
    const int MAX_N = 3e3 + 10;
    int dp[MAX_N][MAX_N];
    string S, T;
    cin >> S >> T;
    int s = S.length();
    int t = T.length();
    for (int i = 1; i <= s; ++i){
        for (int j = 1; j <= t; ++j){
            if (S[i-1] == T[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    // cout << dp[s][t] << endl;
    int a = dp[s][t]-1;
    string ans = S;

    int i = s;
    int j = t;
    while(i != 0 && j != 0){
        if (S[i-1] == T[j-1]) {
            ans[a--] = S[i-1];
            i--; j--;
        }else{
            if (dp[i-1][j] < dp[i][j-1]) j--;
            else i--;
        }
    }
    cout << ans.substr(0, dp[s][t]) << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define ll unsighned long int(

int main(){
    char h[4] = {'A','T','C','G'};
    char x;
    cin >> x;
    for(int i = 0; i < 4; ++i){
        if(x == h[i]){
            if(i % 2 == 0)cout << h[i + 1] << endl;
            else cout << h[i - 1] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys
x = input()
for i in ['+','-']:
    for j in ['+','-']:
        for k in ['+','-']:
            ans_str = x[0]+i+x[1]+j+x[2]+k+x[3]
            ans = eval(ans_str)
            if ans == 7:
                print(ans_str+'=7')
                sys.exit()


Measured memory_bytes: 3060
H,W=map(int,input().split())
field=[["."]*(W+2)]
for i in range(H):
    field.append(["."])
    field[-1].extend(list(input()))
    field[-1].append(".")
field.append(["."]*(W+2))
for i in range(1,H+1):
    for j in range(1,W+1):
        if field[i][j]=="#":
            print("#",end="")
        else:
            cnt=0
            for dy in range(-1,2):
                for dx in range(-1,2):
                    if field[i+dy][j+dx]=="#":
                        cnt+=1
            print(cnt,end="")
    print("")

Measured memory_bytes: 3444
// input に入力データが全部入る
function Main(input) {
    // // 1行目がinput[0], 2行目がinput[1], …に入る
    // input = input.split("\n"); //複数行入力がある場合に使用
    // tmp = input[1].split(" "); 

    // // 文字列から10進数に変換するときはparseIntを使います
    // var a = parseInt(input[0], 10);
    // var b = parseInt(tmp[0], 10);
    // var c = parseInt(tmp[1], 10);
    // var s = input[2];

    // // 出力
    // console.log('%d %s', a+b+c, s);

var number = parseInt(input);

console.log(number*number*number);
}

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug() {
    var input = document.getElementById("input").value;
    Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15376
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	map <int, int> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		m[x]++;
	}
	int mx1 = 0, mx2 = 0;
	for (auto g : m) {
		if (g.ss >= 4) {
			mx1 = g.ff;
			mx2 = g.ff;
		}
		else if(g.ss >= 2) {
			mx2 = mx1;
			mx1 = g.ff;
		}
	}
	cout << 1LL * mx1 * mx2;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

vector<i64> factor(i64 x){
    vector<i64> res;
    for(i64 i=1; i*i<=x; ++i){
        if(x%i!=0) continue;
        res.push_back(i);
        if(i*i!=x) res.push_back(x/i);
    }
    return res;
}

void solve(){
    i64 N,M;
    cin >> N >> M;
    
    auto fs=factor(M);
    i64 ans=1;
    for(i64 f:fs){
        if(N>M/f) continue;
        ans=max(ans,f);
    }
    
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy\n";
	else if(s == "Cloudy") cout << "Rainy\n";
	else cout << "Sunny\n";
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define N -1
#define M 101
 
int main(){
  int A[M][M];
  int V[M]={0};
  int Aij[M];
  int E[M]={N};
  int i,j,n,sum=0,max=0,min=0;
 
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&A[i][j]);
    }
  }
 
  Aij[0] = 0;
  for(i=1; i<n; i++) Aij[i] = 2001;
 
  while(max != 2001){
    max = 2001;
    for(i=0 ; i<n ; i++){
      if(V[i] != 2 && Aij[i] < max){
        max = Aij[i];
        min = i;
      }
    }
    V[min] = 2;
    for(i=0 ; i<n ; i++){
      if(A[min][i] != N && V[i] != 2 && A[min][i] < Aij[i]){
        E[i] = min;
        Aij[i] = A[min][i];
        V[i] = 1;
      }
    }
  }
 
  for(i=0 ; i<n ; i++){
    if(E[i] != N) sum += A[i][E[i]];
  }
 
  printf("%d\n",sum);
 
  return 0;
}


Measured memory_bytes: 2052
import numpy as np

n,m = map(int,input().split())
on_list = [[0 for i in range(m)]for i in range(n)]
off_list = [[0 for i in range(m)]for i in range(n)]
for i in range(m):
    tmp = list(map(int,input().split()))
    for j in range(1,len(tmp)):
        on_list[tmp[j]-1][i] = 1
        

p_list = list(map(int,input().split()))
on_list = np.array(on_list)
off_list = np.array(off_list)


cnt = 0
for i in range(2**n):
    tmp = np.zeros((m),dtype  =int)
    for j in range(n):
        if ((i >> j)& 1):
            tmp += on_list[j]
        else:
            tmp += off_list[j]
    flag = True
    for i in range(len(tmp)):
        if p_list[i] == tmp[i]%2:
            continue
        else:
            flag = False
    if flag:
        cnt += 1
print(cnt)

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

typedef long long ll;

int main() {
  ll a, b, c, k; cin >> a >> b >> c >> k;
  ll res = 0;
  res += min(k, a);
  k -= min(k, a);
  k -= min(b, k);
  res -= min(k, c);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int A;
    int B;

    scanf("%d\t%d", &A, &B);

    if(A>B && (B!=1)){
        printf("Alice");
    }
     else if((A==1&&A!=B)){
        printf("Alice");
     }
    else if(A<B){
        printf("Bob");
        }
    else if((A!=B&&B==1)){
        printf("Bob");
    }
    else if(A==B){
        printf("Draw");
    }



}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 45+10;
const int mod = 1e9+7;

using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

	ll n,d,ans=0;

	cin >> n >> d;

	for(int i=0;i<n;++i){
		ll a,b;
		cin >> a >> b;
		ans+=((a*a+b*b)<=(d*d));
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>
// int dp[51][51];

vector<vector<ll>> multiply(vector<vector<ll>>a, vector<vector<ll>> b)
{
	ll n=a.size();
	vector<vector<ll>> ans(n, vector<ll>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				ans[i][j]= (ans[i][j]+(a[i][k]*b[k][j])%mod)%mod;
			}
		}
	}
	return ans;
}

vector<vector<ll>> power(vector<vector<ll>>mat, ll k)
{
	if(k==1)
		return mat;

	vector<vector<ll>>ans=power(mat,k/2);
	ans=multiply(ans, ans);
	if(k&1)
		ans=multiply(mat, ans);
	return ans;
}

ll solve(vector<vector<ll>>arr, ll n, ll k)
{
	ll sum=0;
vector<vector<ll>>ans=power(arr,k);

// for(int i=0;i<n;i++)
// {
// 	for(int j=0;j<n;j++)
// 		cout<<ans[i][j]<<" ";
// 	cout<<"\n";
// }

for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
		sum= (sum+ans[i][j])%mod;

}
return sum;

}

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

ll n,k, x;
cin>>n>>k;
// memset(dp,0,sizeof(dp));
vector<vector<ll>>arr;
vector<ll>v;
for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
		{cin>>x;
			v.push_back(x);
		}
	arr.push_back(v);
	v.clear();
}
ll ans=solve(arr, n, k);
cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 1664
/* code by AbhiTaker  */
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 5000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;

    if((b-a-1)%2 == 0)
        cout<<"Borys\n";
    else
        cout<<"Alice\n";


    return 0;
}


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

#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math,-ffp-contract=off")
#define lli long long int

const int maxn = 60;
int n, m, sz, h[maxn], pl[maxn], par[maxn], s, cnt[maxn], cn;
lli ans, zarib;
bool ch[maxn];
vector<int> ad[maxn];
vector<pair<int, int> > V;

void merge(int, int, int);
void dfs(int);

int main(){
	cin >> n;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        ad[u].push_back(v);
        ad[v].push_back(u);
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        int u, v;
		cin >> u >> v;
		u--, v--;
        V.push_back(pair<int, int>(u, v));
    }
    dfs(0);
    for(int i = 0; i < (1 << m); i++){
        for(int j = 0; j < m; j++){
            if((1 << j) & i){
				cn++;
                merge(V[j].first, V[j].second, i + 1);
            }
        }
        if(cn % 2) zarib = -1ll;
        else zarib = 1ll;
        ans += zarib * (1ll << (n - s - 1));
        cn = 0;
        s = 0;
    }
    cout << ans;
    return 0;
}

void dfs(int root){
    ch[root] = 1;
	for (auto x : ad[root]) {
        if(ch[x]) continue;
        h[x] = h[root] + 1;
        par[x] = root;
        pl[x] = sz++;
        dfs(x);
    }
    return;
}

void merge(int u, int v, int now){
    if(h[u] > h[v])
        swap(u, v);
    while(h[v] > h[u]){
        if(cnt[pl[v]] != now) s++;
        cnt[pl[v]] = now;
        v = par[v];
    }
    while(u != v){
        if(cnt[pl[u]] != now) s++;
        if(cnt[pl[v]] != now) s++;
        cnt[pl[u]] = cnt[pl[v]] = now;
        u = par[u];
        v = par[v];
    }
    return;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int x,y; cin>>x>>y;
    int b=y-2*x;
    if(b%2){
        cout<<"No";
        return 0;
    }
    b/=2;
    int a=x-b;
    if(a>=0&&b>=0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3656
import numpy as np
N=input()
x=[]
dict={}
for i in range(N):
    a=raw_input()
    if a in dict:
        if dict[a]==1:
            dict[a]=0
        else:
            dict[a]=1
    else:
        dict[a]=1

print np.sum(np.array(dict.values())%2)


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

int main()
{
	double a, height, x;
	cin >> a >> height >> x;
	double water_level = x / a / a;
	cout << fixed << setprecision(10);
	if (water_level <= height / 2)
	{
		double area = water_level * a;
		cout << atan(height * height / 2 / area) * 180 / acos(-1) << '\n';
	}
	else
	{
		cout << atan(2 * (height - water_level) / a) * 180 / acos(-1) << '\n';
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }

//小さい順に実装しても間に合うとは限らないよ？
int main() {
    ll n, m, k, A, B;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    rep1(i, n){
        cin >> A;
        a[i+1] += A + a[i];
    }
    rep1(i, m){
        cin >> B;
        b[i+1] += B + b[i];
    }
    a[0] = 0; b[0] = 0;
    ll ans = 0;
    ll j = m;
    rep2(i, 0, n+1){
        if (a[i] > k) break;
        while (b[j] > k - a[i] && j > 0){
            j--;
        }
        if (a[i]+b[j]<=k) ans = max(ans, i+j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6404
import Data.Text
main = do
  s <- getLine
  let date = Prelude.map unpack (splitOn (pack "/") (pack s))
  let ans = if (read (date !! 0)) <= 2019 && (read (date !! 1)) <= 4 && (read (date !! 2)) <= 30
               then "Heisei"
               else "TBD"
  putStrLn ans


Measured memory_bytes: 508
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [(f64, f64); n],
    }

    let mut p: Vec<_> = p.iter().filter(|t| t.0 != 0.0 || t.1 != 0.0).collect();
    p.sort_by(|t0, t1| t0.0.atan2(t0.1).partial_cmp(&t1.0.atan2(t1.1)).unwrap());
    let n = p.len();

    let mut ans = 0.0;
    for b in 0..n {
        for e in 0..n {
            // [b, e)
            let mut x = 0.0;
            let mut y = 0.0;
            for i in 0..n {
                if (b <= e) == ((b <= i) ^ (i < e)) {
                    x += p[i].0;
                    y += p[i].1;
                }
            }
            let mut tmp = x.hypot(y);
            if tmp > ans {
                ans = tmp;
            }
        }
    }
    println!("{}", ans);
}


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



int main(){
    int a,b;
    cin >> a >> b;
    int sa  = b-a;
    int trueA = 0;
    for(int i = 0;i<sa;i++){
        trueA = trueA + i;
    }

    cout << trueA - a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
void p(int* x, int* y, int n)
{
    *x = n % 10;
    while (n) 
    {
        if (n / 10 == 0)
        {
            *y = n;
        }
        n /= 10;
    }
}
int main()
{
    int  count = 0, i, j, n;
    int std;
    int x1, y1, x2, y2;
    scanf("%d", &n);
    if(n < 10)
    {
        printf("%d\n", n);
    }
    else
    {
        std = (n / 10) * (n / 10) + 8;
        for (i = n / 10 * 10 + 1; i <= n; i++)
        {
            p(&x1, &y1, i);
            for (j = 1; j <= n; j++) 
            {
                p(&x2, &y2, j);
                if (x1 == y2 && x2 == y1)
                {
                    if (j == i)
                    {
                        count++;
                    }
                    else
                    {
                        count += 2;
                    }
                }
            }
        }
        printf("%d\n", count + std);
    }
    return 0;
}

Measured memory_bytes: 128
program AGC005A
    implicit none
    integer(8)::i,xlen,sc,tc,ans
    character(200000)::X
    character(1),allocatable,dimension(:)::stack
    read*,X
    xlen=len_trim(X)
    allocate(stack(xlen))
    ans=xlen
    sc=1
    tc=1

    do i=1,xlen
        if(X(i:i)=="T")then
            if(tc-sc==0.or.stack(tc-1)=="T")then
                stack(tc)="T"
                tc=tc+1
            else if(stack(tc-1)=="S")then
                tc=tc-1
            end if
        else
            stack(tc)="S"
            tc=tc+1
        end if
    end do
    print'(i0)',tc-sc
end program AGC005A

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

int main(){
    int N;
    string S;
    int ans=0;
    cin>>N>>S;
    
    for (int i=0;i<=999;i++){
        int c[3]={i/100,(i/10)%10,i%10};
        int f=0;
        for (int j=0;j<N;j++){
           //cout<<S[j]<<" "<<c[f]<<endl;
            if(S[j]==('0'+c[f])) f++;//'0'は文字コード、数値としては48になる。つまりS[j]の中身の文字コード(数値）とc[f]の文字コード(数値)を比較している。
            if(f==3) break;
        }
        if (f==3) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656