akhauriyash/Code-Regression huggingface dataset:
import math


A, B, H, M = map(int, input().split())

pi = math.pi
Hrad = (H+(M/60))*2*pi/12
Mrad = M*2*pi/60

d = abs(Hrad-Mrad)

# print(math.degrees(d))

if d >= pi:
    d = 2*pi - d

# print(math.degrees(d))

print(math.sqrt(A**2+B**2-2*A*B*math.cos(d)))

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(m), c(m,0);
    for(i=0;i<m;i++){
        ll b;
        cin >> a[i] >> b;
        for(j=0;j<b;j++){
            ll x;
            cin >> x;
            c[i] += 1ll<< (x-1);
        }
    }

    vector<ll> dp(1 << 12,INF);
    dp[0] = 0;
    for(i=0;i<1<<n;i++){
        if(dp[i]!=INF){
            for(j=0;j<m;j++){
                dp[i|c[j]] = min(dp[i]+a[j],dp[i|c[j]]);
            }
        }
    }
    if(dp[(1<<n)-1]==INF){
        cout << -1 << endl;
    }else{
        cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S, T;
  cin >> S >> T;
  int flag = 0;
  char a;
  for(int i = 0; i < S.size(); i++) {
    if(S == T) {
      flag = 1;
      break;
    }
    a = S.at(S.size() - 1);
    for(int j = 0; j < S.size() - 1; j++) {
      S.at(S.size() - 1 - j) = S.at(S.size() - 2 - j);
    }
    S.at(0) = a;
  }
  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = n;
  for(int i = 0; i < n - 1; i++){
    if(s[i] != s[i + 1] && max(i + 1, n - i - 1) < ans){
      ans = max(i + 1, n - i - 1);
    }
  }
  bool flag = true;
  for(int i = 0; i < n; i++){
    if(s[i] == '1') flag = false;
  }
  if(flag) cout << n << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;
static const int MAX_S = 10000;

int lcs[MAX_S][MAX_S] = {};


int print_lcs(string a, string b, int i, int j)
{
    if(i == 0 || j == 0)return 0;

    if(a[i-1] == b[j-1])
    {
        print_lcs(a,b,i-1,j-1);
        cout << a[i-1];
    }
    else
    {
        //i-1のほうが大きい場合//一致文字数が増えたタイミング->一致している
        if(lcs[i-1][j] >= lcs[i][j-1])
        {
            print_lcs(a, b, i - 1, j);
        }
        else
        {
            print_lcs(a, b, i, j - 1);
        }
    }

    return 0;

}

int main(){

    string s,t;
    cin >> s >> t;


    for(int i = 1; i <= s.size(); ++i)
    {
        for(int j = 1; j <= t.size(); ++j)
        {
            int value = max(lcs[i-1][j], lcs[i][j-1]);
            if(s[i-1] == t[j-1])
            {
                value = max(value,lcs[i-1][j-1] + 1);
            }
            lcs[i][j] = value;
        }
    }


    //cout << lcs[s.size()][t.size()] << endl;
    print_lcs(s,t,s.size(),t.size());
    cout << endl;


    return 0;    
}



Measured memory_bytes: 147968
#include<bits/stdc++.h>
using namespace std;
    
int main()
{
 long long  int n,x,t;
  cin>>n>>x>>t;
  long long int c=0;
  while(n>0)
  {
    n=n-x;
    c++;
  }
  cout<<c*t;
   return 0;
}

Measured memory_bytes: 3636
let p = Array.init (read_int ()) (fun _ -> Scanf.scanf " %d" (fun i -> i))
let _, j, s = Array.fold_left (fun (i, j, s) p -> if p = i then (i + 1, j + 1, s) else (i + 1, 0, s + (j + 1) / 2)) (1, 0, 0) p
let () = Printf.printf "%d\n" (s + (j + 1) / 2)


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll kazu = 0, wa = 0, mini = INF;
    REP(i, n) {
        cin >> a[i];
        wa += abs(a[i]);
        if(abs(a[i]) < mini) mini = abs(a[i]);
        if(a[i] < 0) kazu++;
    }

    if(kazu % 2 == 0) {
        cout << wa << endl;
    } else {
        cout << wa - 2*mini << endl;
    }



    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] v1 = new boolean[N];
        boolean[] v2 = new boolean[N];
        Arrays.fill(v1, false);
        Arrays.fill(v2, false);
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == 1) {
                v1[b] = true;
            }
            if (b == N) {
                v2[a] = true;
            }
        }
        for (int i = 1; i < N; i++) {
            if (v1[i] && v2[i]) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 93464
#!/usr/bin/env ruby

attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

N = attrs[0][0].to_i
A = attrs[1]

flag = true
N.times do |i|
  a_i = A[i].to_i
  next unless a_i % 2 == 0
  next if (a_i % 3 == 0 || a_i % 5 == 0)
  flag = false
  break
end

puts (flag) ? 'APPROVED' : 'DENIED'

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int w, a, b;

int main(void){
    
    scanf("%d %d %d", &w, &a, &b);
    
    if(a + w < b || b + w < a) printf("%d\n", (a + w < b) ? b - (a + w) : a - (b + w));
    else printf("0\n");
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;


int main(void){
    int n,num=0;;
    cin>>n;
    vector<int>p(n),q(n);
    for(int i=0;i<n;i++)cin>>p[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++)q[k]=p[k];
            if(i!=j){
                int tmp=q[i];
                q[i]=q[j];
                q[j]=tmp;
            }
            bool flag=true;
            for(int l=0;l<n-1;l++){
                if(q[l]>q[l+1]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i<b; i++)
typedef long long ll;
int main() {
    string s = "";
    cin >> s;
    map<char, int>mp;
    rep(i, 0, s.size()){
        mp[s[i]]++;
    }
    int maxn = max(max(mp['a'], mp['b']), mp['c']);
    int minn = min(min(mp['a'], mp['b']), mp['c']);
    if(maxn - minn <= 1){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>
 
int main(void){

    int N,M,sum=0;
    int T[100],P,X;
    
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&T[i]);
        sum += T[i];
    }
    scanf("%d",&M);
    for(int i = 0; i < M; i++)
    {
        scanf("%d %d",&P,&X);
        printf("%d\n",sum-T[P-1]+X);
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x,y,step;
};
int n,cnt,a[1001][1001],ind[1001][1001],ans,tot;
vector <node> v[1001][1001];
queue<node> Q;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		for(int j=1; j<n; j++)
			scanf("%d",&a[i][j]);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<n-1; j++) {
			int x=i,y=a[i][j],xx=i,yy=a[i][j+1];
			if(x>y)swap(x,y);
			if(xx>yy)swap(xx,yy);
			v[x][y].push_back((node)<%xx,yy%>);
			ind[xx][yy]++;
		}
	}
	for(int i=1; i<=n; i++) 
		for(int j=i+1; j<=n; j++)
			if(!ind[i][j])Q.push((node)<%i,j,1%>),tot++;
	while(!Q.empty()) {
		node now=Q.front();Q.pop();
		int x=now.x,y=now.y;
		for(int i=0;i<v[x][y].size();i++){
			int xx=v[x][y][i].x,yy=v[x][y][i].y;
			ind[xx][yy]--;
			if(!ind[xx][yy])Q.push((node)<%xx,yy,now.step+1%>),tot++;
		}
		cnt=max(cnt,now.step);
	}
	if(tot==(n-1)*n/2)printf("%d",cnt);
	else  printf("-1");
	return 0;
}

Measured memory_bytes: 47104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Puzzle
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int[] nums = new int[10];

			for (int i = 0; i < line.length(); i++) {
				nums[line.charAt(i) - '0']++;
			}

			String ans = "";

			for (int i = 1; i <= 9; i++) {
				if (nums[i] < 4) {
					nums[i]++;
					if (check(nums)) {
						ans += String.valueOf(i);
					}
					nums[i]--;
				}
			}

			if (ans.length() == 0) {
				System.out.println(0);
			} else {
				System.out.println(String.join(" ", ans.split("")));
			}

		}
	}

	static boolean check(int[] nums) {

		boolean ret = false;

		for (int i = 1; i <= 9; i++) {
			if (nums[i] >= 2) {
				nums[i] -= 2;
				ret |= check3(nums);
				nums[i] += 2;
			}
		}

		return ret;
	}

	static boolean check3(int[] nums) {

		int sum = 0;
		for (int i = 1; i <= 9; i++) {
			sum += nums[i];
		}
		if (sum == 0) return true;

		//
		boolean ret = false;

		for (int i = 1; i <= 7; i++) {
			if (nums[i] > 0 && nums[i + 1] > 0 && nums[i + 2] > 0) {
				nums[i]--;
				nums[i + 1]--;
				nums[i + 2]--;
				ret |= check3(nums);
				nums[i]++;
				nums[i + 1]++;
				nums[i + 2]++;
			}
		}

		for (int i = 1; i <= 9; i++) {
			if (nums[i] >= 3) {
				nums[i] -= 3;
				ret |= check3(nums);
				nums[i] += 3;
			}
		}

		return ret;
	}
}

Measured memory_bytes: 25628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Pll complex<int>
#define X real()
#define Y imag()
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f


int32_t main()
{
	int k, n;
	
	cin >> k >> n;
	vector<int> arr(n);
	for(int &w : arr) cin >> w;
	int mx = k - arr[n - 1] + arr[0];
	for(int i = 0; i < n - 1; i++)
		mx = max(abs(arr[i] - arr[(i + 1) % n]), mx);
	cout << k - mx << endl;	
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	
	ll n,ans = 0;
	cin >> n;
	ll a[n] = {};
	
	rep(i,0,n) cin >> a[i];
	
	rep(i,0,n-1){
		rep(j,i+1,n){
			ans += a[i] * a[j];
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 2e5 + 20;
int a[N], n;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	if (n % 2 == 0) {
		for (int i = n; i >= 2; i -= 2)
			cout << a[i] << ' ';
		for (int i = 1; i <= n - 1; i += 2)
			cout << a[i] << ' ';
		cout << endl;
	}
	else {
		for (int i = n; i >= 1; i -= 2)
			cout << a[i] << ' ';
		for (int i = 2; i <= n - 1; i += 2)
			cout << a[i] << ' '; 
		cout << endl;
	}
}



































Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;

int n;
int a[100002];
int b;
ll k = 0;

int main () {

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

	cin >> n;
	for (int i = 0; i < n+1; i ++) cin >> a[i];
	for (int i = 0; i < n; i ++) {
		cin >> b;
		if (b > a[i]) {
			k += a[i];
			b -= a[i];
			a[i] = 0;
		}
		else {
			a[i] -= b;
			k += b;
			b = 0;
		}
		
		if (b > a[i+1]) {
			b -= a[i+1];
			k += a[i+1];
			a[i+1] = 0;
		}
		else {
			k += b;
			a[i+1] -= b;
			b = 0;
		}
		
	}
	
	cout << k;

	return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    if(a>=1 && a<=9){
        if(b>=1 && b<=9){
            cout << a*b;
            return 0;
        }
    }
    cout << -1;
}

Measured memory_bytes: 256
from math import sqrt
from math import ceil
from math import floor

def divisors(n):
	count=0
	lis=[]
	for i in range(1,ceil(sqrt(n))+1):
		if n%i==0:
			if n//i==i:
				count+=1
				lis.append(i)
			else:
				lis.append(i)
				lis.append(n//i)
				count+=2
	lis=set(lis)
	lis.remove(1)
	return lis

def main():
	n=int(input())
	ol=n-1
	ans=0
	case1div=divisors(ol)
	case2div=divisors(n)
	for i in case2div:
		newn=n
		if newn%i==0:
			while newn%i==0:
				newn//=i
		if newn%i==1:
			ans+=1
	ans+=len(case1div)
	print(ans)
main()

Measured memory_bytes: 39664
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var x, y float64
	angle := 90.0

	for sc.Scan() {
		data := strings.Split(sc.Text(), ",")
		if data[0] == "0" && data[1] == "0" {
			break
		}
		meters, _ := strconv.Atoi(data[0])
		m := float64(meters)
		changedAngle, _ := strconv.Atoi(data[1])
		a := float64(changedAngle)

		radian := angle * math.Pi / 180
		x += m * math.Cos(radian)
		y += m * math.Sin(radian)
		angle -= a
	}
	fmt.Println(int(x))
	fmt.Println(int(y))
}



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

using namespace std;

#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, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


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

}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
xn = list(map(int,input().split()))
ym = list(map(int,input().split()))

for i in range(x+1,y+1):
    cnt = 0
    for j in range(n):
        if xn[j] < i:
            cnt += 1

    for j in range(m):
        if ym[j] >= i:
            cnt += 1
    
    if cnt == n+m:
        print('No War')
        break    
else:
    print('War')

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

public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int times = 0;
		int count = 0;
		int n = sc.nextInt();
		int test = n;
		int i = 1;
		int counter = 0;
		while (n > 0) {
			if (n % 2 == 0) {

				while (test % 2 == 0) {
					test /= 2;
					times++;
				}
				if(count < times) {
					count = times;
				}
				times=0;
			} 
			n--;
			test = n;
		}
		while(counter < count)
		{
			i= i*2;
			counter++;
		}
		System.out.println(i);

	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,prod=1,mod=1e9+7;cin>>n>>k;
  lvector A(n),pos,neg;
  rep(i,n) {
    cin>>A[i];
    if(A[i]<0) neg.emplace_back(A[i]);
    else pos.emplace_back(A[i]);
  }
  ll ps=pos.size(),ns=neg.size();
  bool ispos=false;
  if(ps>0) {
    if(n==k) ispos=(ns%2==0);
    else ispos=true;
  } else ispos=(k%2==0);
  if(!ispos) {
    sort(ALL(A),[](ll x,ll y) {return abs(x)<abs(y);});
    rep(i,k) prod=(prod*A[i])%mod;
    while(prod<0) prod+=mod;
  }
  else {
    sort(ALL(pos));sort(RALL(neg));
    ll q=1,x;
    if(k%2==1) {q=pos.back();pos.pop_back();}
    lvector V;
    while(pos.size()>=2) {
      x=pos.back();pos.pop_back();
      x*=pos.back();pos.pop_back();
      V.emplace_back(x);
    }
    while(neg.size()>=2) {
      x=neg.back();neg.pop_back();
      x*=neg.back();neg.pop_back();
      V.emplace_back(x);
    }
    sort(RALL(V));
    rep(i,k/2) {
      V[i]%=mod;
      prod=(prod*V[i])%mod;
    }
    prod=(prod*q)%mod;
  }
  print(prod);
  return 0;
}

Measured memory_bytes: 8128
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
int n,k,u,v;
vector<int> ga[100100];
long long res;
void dfs(int u,int v,int w,int sib){
	int totmi=(v!=-1)+(w!=-1)+sib;
	if(totmi>=k){
		cout<<0<<endl;
		exit(0);
	}
	res*=(k-totmi);
	res%=1000000007;
	int numsib=0;
	for(int i=0;i<ga[u].size();i++){
		if(ga[u][i]!=v){
			dfs(ga[u][i],u,v,numsib);
			numsib++;
		}
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		ga[u].push_back(v);
		ga[v].push_back(u);
	}
	res=1LL;
	dfs(1,-1,-1,0);
	cout<<res<<endl;
	return 0;
}


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

#define ar array
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define vt vector 
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
  
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
template<class T> bool umin(T& a, const T& b) {
	return b<a?a=b, 1:0;
}
template<class T> bool umax(T& a, const T& b) { 
	return a<b?a=b, 1:0;
} 
 
 
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	EACH(a, x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	EACH(a, x)
		read(a);
}
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b?"true":"false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vt<bool> v) {
	string res;
	FOR(sz(v))
		res+=char('0'+v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	FOR(S)
		res+=char('0'+b[i]);
	return res;
}
template<class T> string to_string(T v) {
    bool f=1;
    string res;
    EACH(x, v) {
		if(!f)
			res+=' ';
		f=0;
		res+=to_string(x);
	}
    return res;
}
 
template<class A> void write(A x) {
	cout << to_string(x);
}
template<class H, class... T> void write(const H& h, const T&... t) { 
	write(h);
	write(t...);
}
void print() {
	write("\n");
}
template<class H, class... T> void print(const H& h, const T&... t) { 
	write(h);
	if(sizeof...(t))
		write(' ');
	print(t...);
}
 
void DBG() {
	cerr << "]" << endl;
}
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const ll LLINF = 1e18 + 10;

void solve()
{
    bool n;
    read(n);
    print(int(!n));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int t=1;
	//read(t);
	FOR(t) {
		//write("Case #", i+1, ": ");
		solve();
	}
}



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

const int dx[7][3] = { {1, 0, 1}, {0, 0, 0}, {1, 2, 3}, {0, -1, -1}, {1, 1, 2}, {0, 1, 1}, {1, 0, -1} };
const int dy[7][3] = { {0, 1, 1}, {1, 2, 3}, {0, 0, 0}, {1,  1,  2}, {0, 1, 1}, {1, 1, 2}, {0, 1,  1} };

bool inrange(int x, int y)
{

      return false;
      return true;
}

int main()
{
  for ( ; ; ) {
    vector<string> f(8);
    for (int i = 0; i < 8; ++i)
      getline(cin, f[i]);

    int sx = -1, sy = -1;
    for (int y = 0; y < 8; ++y) {
      for (int x = 0; x < 8; ++x) {
	if (f[y][x] != '0' && sx == -1 && sy == -1) {
	  sx = x;
	  sy = y;
	}
      }
    }

    for (int i = 0; i < 7; ++i) {
      int cnt = 0;
      for (int j = 0; j < 3; ++j) {
	int xx = sx + dx[i][j];
	int yy = sy + dy[i][j];
	if (xx < 0 || xx >= 8 || yy < 0 || yy >= 8)
	    continue;
	if (f[yy][xx] == '1')
	  ++cnt;
      }
	if (cnt == 3) {
	  cout << static_cast<char>('A'+i) << endl;
	  break;
	}
    }

    // blank
    if (!getline(cin, f[0]))
	break;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#define N 2019
typedef long long LL;
using namespace std;
char s[200005];
short dp[200005][N+1];
int main()
{
    memset(dp,0LL,sizeof(dp));
    scanf("%s",s+1);
    int ls=strlen(s+1);
    int a;
    LL ans=0;
    for(int i=1; i<=ls; i++)
    {
        a=s[i]-'0';
        dp[i][a%N]++;
        for(int j=0; j<N; j++)
            dp[i][(a+j*10)%N]+=dp[i-1][j];
        ans+=dp[i][0];
    }
    printf("%lld\n",ans);
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N,T;
  cin>>N>>T;

  vector<P> v(N);
  FOR(i,0,N){
    ll a,b;
    cin>>a>>b;
    v[i]=P(a,b);
  }

  ll res=1e10;

  FOR(i,0,N){
    if(v[i].second<=T){
      res=min(res,v[i].first);
    }
  }
  if(res==1e10) cout<<"TLE"<<endl;
  else{
    cout<<res<<endl;
  }
}


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

int main(){
	int taste, apple,pi;
	int tmp,min,all=0;
	int aji=0;
	int init;
	scanf("%d %d",&apple,&taste);
	init = taste;
	for(int i = 0; i < apple;i++){
		aji += init;
		init++;
	}
	tmp = taste;
	min = taste;
	for(int i = 0;i < apple-1;i++){
		tmp = abs(taste);
		if(tmp > abs(taste+1)){
			min = taste+1;
		}
		taste++;
	}
	pi = aji - min;
	printf("%d\n",pi);
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[100000];
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    int mx=a[n-1];
    int md;
    for(int i=0; i<n; i++){
        if(mx/2<=a[i]){
            if(i==0){
                md=a[0];
                break;
            }
            if(i==n-1){
                md=a[n-2];
                break;
            }
            if(abs(a[i-1]-mx/2)<abs(a[i]-mx/2)) md=a[i-1];
            else md=a[i];
            break;
        }
    }
    cout<<mx<<" "<<md<<endl;

    return 0;
}


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

const int MAX = 105;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
const int INFTY = (1 << 21);
int n, M[MAX][MAX];
int color[MAX];
int d[MAX];
int p[MAX];

void dijkstra(int root) {
  int u = -1;
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INFTY;
    p[i] = -1;
  }

  color[root] = GRAY;
  d[root] = 0;

  while (true) {
    int min_cost = INFTY;
    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < min_cost) {
        min_cost = d[i];
        u = i;
      }
    }

    if (min_cost == INFTY) {
      break;
    }

    color[u] = BLACK;

    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] > M[u][i] + d[u]) {
        d[i] = d[u] + M[u][i];
        p[i] = u;
        color[i] = GRAY;
      }
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = INFTY;
    }
  }
  int k, s, t, c;
  for (int i = 0; i < n; i++) {
    cin >> s >> k;
    for (int j = 0; j < k; j++) {
      cin >> t >> c;
      M[s][t] = c;
    }
  }
  dijkstra(0);
  for (int i = 0; i < n; i++) {
    cout << i << " " << d[i] << endl;
  }
  return 0;
}



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

namespace question2
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(ch => int.Parse(ch)).ToArray();

            var hmax = 0;
            var c = 0;
            for (int i = 0; i < n; i++)
            {
                if (h[i] >= hmax)
                {
                    c++;
                }
                hmax = Math.Max(hmax, h[i]);
            }

            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 13268
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll N,x=0,y=0,ans=1e10;
    cin>>N;
    vector<ll> v(N);
    rep(i,0,N){
        cin>>v[i];
        (i==0?x:y)+=v[i];
    }
    ans=abs(x-y);
    rep(i,1,N-1){
        x += v[i];
        y -= v[i];
        ans=min(ans, abs(x-y));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){

    int n; ll c; cin >> n >> c;
    vector<ll> x(n), v(n);
    vector<ll> sl(n), sr(n);

    REP(i, n){
        cin >> x[i] >> v[i];
        sr[i] = v[i];
        sl[n-i-1] = v[i];
    }

    REP(i, n){
        if( i == 0 ) continue;
        sr[i] += sr[i-1];
        sl[i] += sl[i-1];
    }

    REP(i, n){
        sr[i] -= x[i];
        sl[i] -= c-x[n-i-1];

        if( i == 0 ) continue;

        // cout << i << " " <<  sr[i] << " " << sl[i] << endl;

        sr[i] = max(sr[i], sr[i-1]);
        sl[i] = max(sl[i], sl[i-1]);
    }

    ll ans = 0;
    REP(i, n){

        ans = max(ans, sr[i]);
        ans = max(ans, sl[i]);

        if( n-i-2>=0 ){
            ll rres = sr[i]+sl[n-i-2]-x[i];
            ll lres = sr[n-i-2]+sl[i]-(c-x[n-i-1]);
            ans = max(ans, rres);
            ans = max(ans, lres);
        }

    }

    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 3328
#include<iostream>
using namespace std ;
int main()
{
    int n,arr[100005],x,temp=0,sub=0,idx,i;
    cin >> n ;
    arr[0]=10000000;
    for( i=1;i<=n;i++)
    {
        cin >> arr[i];
        if(arr[i]<=arr[i-1])
        {
            temp++;
        }
        else
        {
            if(sub<=temp)
            {
                sub=temp;
                idx=i-temp-1;
            }
            temp=1;
        }
    }
    if(temp>sub)
    {
        sub=temp;
        idx=i-temp-1;
    }
    cout << sub-1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  N %= 10;
  if (N == 3) {
    cout << "bon" << endl;
    return 0;
  }
  if (N == 0 || N == 1 || N == 6 || N == 8) {
    cout << "pon" << endl;
    return 0;
  }
  cout << "hon" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
	int n, s = 0;
	scanf("%d", &n);
	int coppy = n;
	while (n)
	{
		s += n % 10;
		n /= 10;

	}

	if (coppy % s == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int p[10];
    rep(i, n){
        cin >> p[i];
    }
    sort(p, p+n);

    int ans = p[n-1] / 2;
    rep(i, n-1){
        ans += p[i];
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
        String s = sc.next();
        int count = 0;
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'L' && i != 0 && s.charAt(i-1) == 'L') count++;
            else if(s.charAt(i) == 'R' && i != n - 1 && s.charAt(i+1) == 'R') count++;
        }

        System.out.println(Math.min(count + 2 * k, n - 1));

    }

}


Measured memory_bytes: 26192
n = int(input())
s = list(input())

al = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
      'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
      'U', 'V', 'W', 'X', 'Y', 'Z']
d_al = {'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 
        'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11,
        'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17,
        'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23,
        'Y': 24, 'Z': 25}

al = al[n:] + al[:n]
ans = [al[d_al[i]] for i in s]
print(''.join(ans))


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

int main() {
    int R,D,X;
    cin >> R >> D >> X; //自然数x
    int a,b,c,d,e,f,g,h,i,j;

    a = R * X - D;
    b = R * a - D;
    c = R * b - D;
    d = R * c - D;
    e = R * d - D;
    f = R * e - D;
    g = R * f - D;
    h = R * g - D;
    i = R * h - D;
    j= R * i - D;
    cout << a << endl;
    cout << b << endl;
    cout << c << endl;
    cout << d << endl;
    cout << e << endl;
    cout << f << endl;
    cout << g << endl;
    cout << h << endl;
    cout << i << endl;
    cout << j << endl;

}


Measured memory_bytes: 256
#include <iostream>

int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}

int main()
{
	int k;
	std::cin >> k;
	int k1 = 9 * k;
	if (k % 7 == 0)
		k1 /= 7;
	if (gcd(10, k1) != 1)
	{
		std::cout << "-1" << std::endl;
		return 0;
	}

	int s = 1;
	for (int i = 1; i < k1; i++)
	{
		s = (s * 10) % k1;
		if (s == 1)
		{
			std::cout << i << std::endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int o = 0;
  while (n > 0)
  {
    if (n % 10 == 2)
    {
      o++;
    }
    n /= 10;
  }
  
  cout << o << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt64()
	l := make([]int64, n)

	cnt := 0
	for i := int64(0); i < n; i++ {
		l[i] = nextInt64()
		div2 := 0
		for {
			if l[i]%2 == 0 {
				l[i] /= 2
				div2++
			} else {
				break
			}
		}
		//fmt.Println(l[i], " can by ", div2, " makes cnt ", cnt+div2)
		cnt += div2
	}

	fmt.Println(cnt)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 2100
#include <stdio.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

long long sum_f[200010];
int P = 1000000007;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n + 1; i++) {
    sum_f[i] = sum_f[i - 1] + i;
  }
  long long sum = 0;
  for (int i = k; i <= n + 1; i++) {
    sum = (sum + ((sum_f[n + 1] - sum_f[n + 1 - i]) - sum_f[i] + 1)) % P;
  }
  printf("%lld", sum);
  return 0;
}

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

int main() {
	// your code goes here
	int n;
	while(cin >> n && n!=0){
		n=1000-n;
		int sum=0;
		int coin[]={500,100,50,10,5,1};
		for(int i=0;i<6;i++)
			while(n>=coin[i]){
				sum++;
				n-=coin[i];
			}
	cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

for i in range(n-1):
    if a[i] == a[i+1]-1:
        b.append(c[a[i]-1])
print(sum(b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
    bool operator()(int a, int b){
        return a>b;
    }
};

///________CODE_STARTS_HERE________\\\

int n,x,cntd,cntr,a[100005];

int main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x;
        if(a[x]) cntr++;
        else cntd++,a[x]=1;
    }
    if(cntr%2){
        cout << cntd-1;
    }
    else{
        cout << cntd;
    }
}


Measured memory_bytes: 640
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"3"# => "2",
r#"6"# => "9",
 // r#"11"# => "30",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        k: usize,
    }
    let mut ans = 0;
    for i in 1..k+1 {
        for j in i+1..k+1 {
            // print!("{} {}", i, j);
            if (i % 2 == 0 && j % 2 != 0) || (i % 2 != 0 && j % 2 == 0) {
                ans += 1;
                // print!(" :ok");
            }
            // println!("");
        }
    }

    ans.to_string()
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << ln;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from itertools import combinations
from functools import reduce
from operator import add

N, M, X = map(int, input().split())

books = [np.array(list(map(int, input().split()))) for _ in range(N)]

success = []


def get_sum_books(args):
    return reduce(add, args)


for i in range(1, N + 1):
    for c in combinations(books, i):
        res = get_sum_books(c)
        if min(res[1:]) >= X:
            success.append(res[0])

if success:
    print(min(success))
else:
    print(-1)


Measured memory_bytes: 27276
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

bool f[1000010];

int main(){
    int s;
    cin >> s;
    rep(i,1000010) f[i] = false;
    f[s] = true;
    
    int tmp = s;
    int cnt = 1;
    if(tmp % 2 == 0){
        tmp = tmp/2;
    }else{
        tmp = 3*tmp+1;
    }

    while(f[tmp] == false){
        f[tmp] = true;
        if(tmp % 2 == 0){
            tmp = tmp/2;
        }else{
            tmp = 3*tmp+1;
        }
        cnt++;
    }
    cnt++;
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4584
def main():
    def f(N):
        S = 0
        tmp = N
        while tmp > 0:
            S += tmp%10
            tmp //= 10
        return N/S
    
    import sys
    input = sys.stdin.readline
    K = int(input())
    Ans = []
    for i in range(1,10):
        Ans.append(i)
    
    tmp = 0
    T = 1
    nine = 1
    while tmp < 10**15:
        N = T*10**nine + 10**nine - 1
        if f(N) <= f(N+10**nine):
            Ans.append(N)
            T += 1
        else:
            nine += 1
            T //= 10
        tmp = T*10**nine + 10**nine - 1
    print(*Ans[:K],sep = "\n")
    
    
main()

Measured memory_bytes: 38768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;
constexpr ll modsize = 0;
vector<ll> fac(modsize);
vector<ll> inv(modsize);
vector<ll> facinv(modsize);

void modcalc() {
	if (modsize == 0) abort();
	fac[0] = 1; fac[1] = 1; inv[1] = 1;
	facinv[0] = 1; facinv[1] = 1;
	for (ll i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modinv(ll a) {
	if (a == 0) abort();
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0 || n == 0 && k > 0) return 0;
	if (n == 0 && k == 0) return 1;
	return fac[n + k - 1] * facinv[k] % mod * facinv[n - 1] % mod;
}

vector<ll> a(100);

P solve(ll l, ll r, ll d) {
	ll s = inf;
	for (int i = l; i < r; i++) chmin(s, a[i]);
	ll dp1 = 1, dp2 = 2;
	for (int i = l; i < r; i++) {
		if (a[i] == s) {
			if (i != l && a[i - 1] != s) {
				P p = solve(l, i, s);
				ll pf = p.first; ll ps = p.second;
				dp1 *= (pf + ps); dp1 %= mod;
				dp2 *= ps; dp2 %= mod;
			}
			l = i + 1;
			dp1 *= 2; dp1 %= mod;
		}
	}
	if (l < r) {
		P p = solve(l, r, s);
		ll pf = p.first; ll ps = p.second;
		dp1 *= (pf + ps); dp1 %= mod;
		dp2 *= ps; dp2 %= mod;
	}
	dp1 += dp2 * modpow(2, s - d - 1) - dp2 + mod; dp1 %= mod;
	dp2 *= modpow(2, s - d - 1); dp2 %= mod;
	return P(dp1, dp2);
}

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

	int n;
	cin >> n;
	rep(i, n) cin >> a[i];
	cout << solve(0, n, 0).first << '\n';
}

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

using namespace std;  
map<int,long long> mp;  
int w;  
int n;  
long long sum;  
typedef struct  
{  
    int w,v;  
}Value;  
Value value[150];  
priority_queue<int> p;//保证大的数先出  
bool compare(Value v1,Value v2)  
{  
    return v1.w>v2.w;  
}  
int main()  
{  
    while(~scanf("%d %d",&n,&w))  
    {  
        for(int i=1;i<=n;i++)  
        {  
            scanf("%d %d",&value[i].w,&value[i].v);  
        }  
        mp[0]=0;//初始化，时间为0时分数为0  
        sum=0;  
        sort(value+1,value+1+n,compare);  
        for(int i=1;i<=n;i++)//01背包模拟  
        {  
            if(value[i].v==0 || value[i].w>w) continue;  
            long long maxx=0;  
            for(map<int,long long>::iterator it=mp.begin();it!=mp.end();++it)//遍历前面的决策  
            {  
                int d=it->first;  
                if((long long)d+(long long)value[i].w<=(long long)w && maxx<=it->second+value[i].v){p.push(d+value[i].w);}  
                maxx=max(maxx,it->second+value[i].v);//重要，没有这个会超内存，保证时间增长的同时，分数也在增长  
            }  
            while(!p.empty())  
            {  
                int d=p.top();p.pop();  
                mp[d]=max(mp[d],mp[d-value[i].w]+value[i].v);  
                if(sum<mp[d]){sum=mp[d];}  
            }  
        }  
        mp.clear();  
        printf("%lld\n",sum);  
    }  
    return 0;  
}  


Measured memory_bytes: 384
#include <stdio.h>
int W,H;
char map[20][20];
int c;

int noru(int x,int y){
        int go[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
        int i;

        if(map[x][y]=='#')
                return;
        if(x<0 || y<0 || x>=W || y>=H)
                return;

        c++;
        map[x][y]='#';
        for(i=0;i<4;i++)
                noru(x+go[i][0],y+go[i][1]);
        return;
}

showmap(){
        int i,j;
        for(i=0;i<H;i++){
                for(j=0;j<W;j++)
                        putchar(map[j][i]);
                puts("");
        }
}
main(){
        int i,j;
        int x,y;

        while(scanf("%d %d",&W,&H)!=EOF){
                if(W==0)
                        break;
                for(i=0;i<H;i++){
                        for(j=0;j<W;j++){
                                scanf(" %c",&map[j][i]);
                                if(map[j][i]=='@'){
                                        x=j;
                                        y=i;
                                }
                        }
                }

                c=0;
                noru(x,y);
                printf("%d\n",c);
        }
        return 0;
}

Measured memory_bytes: 612