akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
int main()
{
    ll K;
    std::cin >> K;
    std::vector<ll> num(1000 + 1);
    for (ll i = 0; i <= 1000; i++) { num[i] = i * (i + 1) / 2 * (i + 2) / 3 * (i + 3) / 4 * (i + 4) / 5 * (i + 5) / 6 * (i + 6) / 7; }
    auto ok = [&](const int NUM) {  // 何もわからない...
        ll K = 1000000000000000000LL;
        bool usef = false;
        ll L = 0;
        for (int i = NUM; i >= 1; i--) {
            const ll f = K / num[i];
            K %= num[i];
            if (f == 0 and not usef) { continue; }
            usef = true, L += f + 7;
        }
        return L <= 5000;
    };
    int NUM = 1;
    for (; NUM <= 1000; NUM++) {
        if (ok(NUM)) { break; }
    }
    bool usef = false;
    std::string ans;
    for (ll i = NUM; i >= 1; i--) {
        const ll f = K / num[i];
        K %= num[i];
        if (f == 0 and not usef) { continue; }
        usef = true, ans += std::string(f, 'F') + "ESTIVAL";
    }
    assert(ans.size() <= 5000);
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

typedef long long ll;

ll N;
const int MAX = 1e6+1;
ll dp[MAX];
ll kidp[MAX];

ll calc(ll x){
    return x *(x+1) * (x+2) / 6;    
}

int main(){

    vector<ll> nums;
    vector<ll> kinums;
    int k = 1;
    for(int i=0; i<190; i++){
        ll num = calc(k);
        nums.push_back(num);
        if(num % 2==1){
            kinums.push_back(num);
        }
        k++;
        // cout << num << endl;
    }
    fill(dp, dp+MAX, 1e9);
    fill(kidp, kidp+MAX, 1e9);
    sort(nums.begin(), nums.end());
    
    dp[0] = 0;
    kidp[0] = 0;
    for(int i=0; i<MAX; i++){
        for(int j=nums.size()-1; j>=0; j--){
            ll u = nums[j];
            if(i - u >= 0 && dp[i] > dp[i-u]+1){
                dp[i] = dp[i-u] + 1;
            }
        }
        for(int j=kinums.size()-1; j>=0; j--){
            ll u = kinums[j];
            if(i - u >= 0 && kidp[i] > kidp[i-u]+1){
                kidp[i] = min(kidp[i], kidp[i-u] + 1);
            }
        }
    }


    while(1){
        cin >> N;
        if(!N) break;

        cout << dp[N] << " " << kidp[N] << endl;
    }
    return 0;
}


Measured memory_bytes: 18700
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int N;
vector<int> A,B;


int main()
{
	long long ans = 0;
	cin >> N;
	A = vector<int>(N + 1, 0);
	B = vector<int>(N + 1, 0);

	auto c = [](int l, int r) { 
		return B.at(l) - A.at(l) < B.at(r) - A.at(r); 
	};
	priority_queue<int, vector<int>, decltype(c)> q(c);

	for (int i = 1; i < N + 1; i++) {
		cin >> A.at(i);
	}
	for (int i = 1; i < N + 1; i++) {
		cin >> B.at(i);
		q.push(i);
	}


	while (!q.empty()) {
		int tgt = q.top();
		q.pop();
		int n1 = (tgt + N - 2) % N + 1;
		int n2 = tgt % N + 1;

		int minus = B.at(n1) + B.at(n2);

		int div = (B.at(tgt) - A.at(tgt)) / minus;

		if (div > 0) {
			B.at(tgt) -= minus * div;
			ans += div;

			if (B.at(tgt) != A.at(tgt)) {
				q.push(tgt);
			}
		}
		else {
			break;
		}
	}


	bool suc = true;
	for (int i = 1; i < N + 1 && suc; i++) {
		suc = A.at(i) == B.at(i);
	}

	if (suc) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}


	return 0;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	int r,s,p;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	vector<string> t2(k);
	rep(i,n){
		t2[i%k].push_back(t[i]);
	}
	int ans=0;
	map<char,int> cnt;
	cnt['r']=p,cnt['s']=r,cnt['p']=s;
	rep(i,k){
		int now=0;
		rep(j,t2[i].size()){
			if(j!=0 && t2[i][j]==t2[i][j-1]){
				now++;
			}else{
				now=0;
			}
			if(now%2==0){
				ans+=cnt[t2[i][j]];
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5200
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int n;
int a[1005];
signed main(void)
{
	cin>>n;
	for(int i=1;i<=n;++i)
		read(a[i]);
	for(int i=1;i<=n;++i)
		if(!(a[i]&1))
		{
			if(a[i]%3>0&&a[i]%5>0)
			{
				puts("DENIED");
				return 0;
			}
		}
	puts("APPROVED");
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
	int a,n, sum=0,x[1000];
	double ave,sum2=0,ans;
	while (1)
	{
		
		scanf("%d", &n);
		if (n == 0)break;

		for (a = 0; a < n; a++)
		{
			scanf("%d", &x[a]);
			sum = sum + x[a];

		}
		ave = 1.0 * sum / n;
		for (a = 0; a < n; a++)
		{
			sum2 = 1.0*(sum2 + ((x[a] - ave)*(x[a] - ave)));
		}
		ans = 1.0*sum2 / n;
		printf("%f\n", sqrt(ans));
		sum = 0;
		sum2 = 0;
	}
	return 0;
}


Measured memory_bytes: 2044
package main

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

func abs(a int) int {
  if a > 0 {
    return a
  }
  return -a
}

type MyScanner struct {
  sc *bufio.Scanner
}

func NewScanner(r io.Reader) *MyScanner {
  sc := bufio.NewScanner(r)
  sc.Split(bufio.ScanWords)
  return &MyScanner{sc}
}

func (ms *MyScanner) nextInt() int {
  if ms.sc.Scan() {
    i, err := strconv.Atoi(ms.sc.Text())
    if err != nil {
      panic(err)
    }
    return i
  }
  panic("failed to scan")
}

func (ms *MyScanner) nextString() string {
  if ms.sc.Scan() {
    return ms.sc.Text()
  }
  panic("failed to scan")
}

func solve(r io.Reader) {

  sc := NewScanner(r)
  N := sc.nextInt()
  
  h := make([]int, N)
  dp := make([]int, N)

  for i := 0; i < N; i++ {
    h[i] = sc.nextInt()
    if i > 0 {
      dp[i] = abs(h[i-1] - h[i]) + dp[i-1]
      if i > 1 {
        if p := abs(h[i-2] - h[i]) + dp[i-2]; dp[i] > p {
          dp[i] = p
        }
      }
    }
  }
  fmt.Println(dp[N-1])
}

func main() {
  solve(os.Stdin)
}

Measured memory_bytes: 2688
# 文字列に含まれない最も小さい文字
def earliest_letter_not_included(s)
  ('a'..'z').each do |c|
    next if s.include? c
    return c
  end
  return -1
end

# 文字列の接尾辞の内、降順の最大
def longest_trailer_desending(s)
  t = s[-1]
  s.reverse.chars.each_with_index do |c,i|
    next if i == 0
    if t[-1] < c
      t << c
    else
      break
    end
  end
  return t.reverse
end

def next_letter(t,c)
  t.chars.sort.each do |l|
    if c < l
      return l
    end
  end
end

# main
s = gets.chomp

if s.size < 26
  puts s + earliest_letter_not_included(s)
else
  t = longest_trailer_desending(s)
  if t.size == 26
    puts -1
  else
    c = s[s.size - t.size - 1]
    d = next_letter(t,c)
    u = s[0, s.size - t.size - 1]
    puts u + d
  end
end



Measured memory_bytes: 1788
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Max GCD
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500;
const int MAX_M = 2048;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], ps[MAX_M], rs[MAX_N];
ll rsums[MAX_N + 1];

/* subroutines */

/* main */

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

  int sum = 0;
  for (int i = 0; i < n; i++) scanf("%d", as + i), sum += as[i];

  int m = 0;
  for (int p = 1; p * p <= sum; p++)
    if (sum % p == 0) {
      ps[m++] = p;
      int q = sum / p;
      if (q != p) ps[m++] = q;
    }
  sort(ps, ps + m);
  //printf("sum=%d, m=%d\n", sum, m);

  for (int i = m - 1; i >= 0; i--) {
    int &pi = ps[i];

    int l = 0;
    for (int j = 0; j < n; j++) {
      int rj = as[j] % pi;
      if (rj > 0) rs[l++] = rj;
    }
    sort(rs, rs + l);

    rsums[0] = 0;
    for (int j = 0; j < l; j++) rsums[j + 1] = rsums[j] + rs[j];
    
    bool found = false;
    for (int j = 0; ! found && j <= l; j++) {
      ll psum = ((ll)pi * (l - j) - (rsums[l] - rsums[j]));
      ll msum = rsums[j];
      found = (psum <= k && msum <= k && abs(psum - msum) % pi == 0);
    }

    if (found) {
      printf("%d\n", pi);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	return i
}

func selectionSort(arr []int) {
	swapCnt := 0
	for i := 0; i < len(arr); i++ {
		mini := i
		for j := i; j < len(arr); j++ {
			if arr[j] < arr[mini] {
				mini = j
			}
		}

		if i != mini {
			arr[i], arr[mini] = arr[mini], arr[i]
			swapCnt++
		}

	}

	arrStr := fmt.Sprintf("%v", arr)
	arrStr = strings.Trim(arrStr, "[]")

	fmt.Println(arrStr)
	fmt.Println(swapCnt)

}

func main() {
	sc.Split(bufio.ScanWords)
	arrNum := nextInt()
	arr := make([]int, arrNum)
	for i := range arr {
		arr[i] = nextInt()
	}
	selectionSort(arr)
}



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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
    freopen ("E.in", "r", stdin);
    freopen ("E.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n;

pair<int, int> a[N];

multiset<int> R, B;

#define Max(S) *S.begin()
#define Min(S) *S.rbegin()

int main() {

	File();

	n = read();
	For (i, 1, n) {
		int x = read(), y = read(); if (x > y) swap(x, y);
		B.insert(x); R.insert(y); a[i] = make_pair(x, y);
	}
	long long ans = 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B));

	sort(a + 1, a + n + 1);
	For (i, 1, n) {
		B.erase(B.find(a[i].first)); R.insert(a[i].first);
		R.erase(R.find(a[i].second)); B.insert(a[i].second);
		chkmin(ans, 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B)));
	}
	printf ("%lld\n", ans);

	return 0;

}

Measured memory_bytes: 20732
N, M = map(int, input().split())
heights = list(map(int,input().split()))
lose = []

for i in range(M):
  x, y = map(int, input().split())
  if heights[x - 1] > heights[y - 1]:
    lose.append(y)
  elif heights[x - 1] < heights[y - 1]:
    lose.append(x)
  elif heights[x - 1] == heights[y - 1]:
    lose.append(y)
    lose.append(x)

print(N - len(list(set(lose))))

Measured memory_bytes: 20112
#include<vector>
#include <iostream>

using namespace std;

int main(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    int flag = 0;

    if(m1 + 1 == m2 ){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, j, min, tmp,len,count=0;
  int a[1000];
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d",&a[i]);
  }
  for(i=0; i<len; i++){
    min=i;
    for(j=i+1;j<len;j++){
      if(a[j]<a[min]){
        min=j;
      }
    }
    if(min!=i){
      tmp=a[i];
      a[i]=a[min];
      a[min]=tmp;
      count++;
    }

  }
  for (i = 0; i < len-1; i++) {
    printf("%d ", a[i]);
  }
  printf("%d",a[len-1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}


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

int s[2]; 
int n;

bool mm(int mm){
  return 1 <= mm && 12 >= mm;
}

int main() {
  cin >> n;
  for(int i = 0; i < 4; i++){
    if(i % 2 == 0){
      s[i / 2] += n % 10;
    }else if(i % 2 == 1){
      s[i / 2] += (n % 10) * 10;
    }
    n = n / 10;
  }
  
  if(mm(s[0]) && mm(s[1])){
    cout << "AMBIGUOUS" << endl;
  }else if(mm(s[0])){
    cout << "YYMM" << endl;
  }else if(mm(s[1])){
    cout << "MMYY" << endl;
  }else{
    cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int nax = 1e5 + 5;
vector<int> edges[nax];

const int mod = 1e9 + 7;
int mul(int a, int b) {
    return (ll) a * b % mod;
}

// returns a pair {black, white}
pair<int,int> dfs(int a, int parent) {
    int all_white = 1; // means: my vertex can be painted black
    int sth_is_black = 1;
    for(int b : edges[a]) {
        if(b != parent) {
            pair<int,int> p = dfs(b, a);
            // p.first is the number of ways to color the subtree
            // such that 'b' is black
            int memo_all_white = all_white;
            all_white = mul(all_white, p.second);
            sth_is_black = (mul(sth_is_black, p.first + p.second)) % mod;
        }
    }
    return make_pair(all_white, (sth_is_black) % mod);
}

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n - 1; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    pair<int,int> p = dfs(1, -1);
    int answer = (p.first + p.second) % mod;
    printf("%d\n", answer);
}

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

struct Directions
{
	int E[6] = { 2, 1, 5, 0, 4, 3 };
	int W[6] = { 3, 1, 0, 5, 4, 2 };
	int N[6] = { 4, 0, 2, 3, 5, 1 };
	int S[6] = { 1, 5, 2, 3, 0, 4 };
	int Rotate[6] = { 0, 2, 4, 1, 3, 5 };
};

class Dice
{
public:
	int num[6];
	void swap(int*);
	Directions dir_array;
	Dice();
	void roll(char);
	void show_num(int);
};

Dice::Dice()
{
	for (int i = 0; i < 6; i++)
		cin >> this->num[i];
}

void Dice::roll(char c)
{
	switch (c)
	{
	case 'E':
		this->swap(dir_array.E);
		break;
	case 'W':
		this->swap(dir_array.W);
		break;
	case 'N':
		this->swap(dir_array.N);
		break;
	case 'S':
		this->swap(dir_array.S);
		break;
	case 'R':
		this->swap(dir_array.Rotate);
		break;
	}
	return;
}

void Dice::swap(int *dir)
{
	int tmp[6];
	for (int i = 0; i < 6; i++)
		tmp[dir[i]] = num[i];
	for (int i = 0; i < 6; i++)
		num[i] = tmp[i];
	return;
}

void Dice::show_num(int i)
{
	cout << this->num[i] << endl;
	return;
}

int check(Dice dice1, Dice dice2)
{
	int tmpf, flag = 0;
	for (int i = 0; i < 4; i++) {
		tmpf = 1;
		for (int j = 0; j < 6; j++)
			if (dice1.num[j] != dice2.num[j])
			{
				tmpf = 0;
				break;
			}
		if (tmpf)
			flag = 1;
		dice2.roll('R');
	}
	return flag;
}
int dice_comp(Dice dice1, Dice dice2)
{
	int flag = 0;
	for (int i = 0; i < 4; i++)
	{
		flag += check(dice1, dice2);
		dice2.roll('E');
	}
	dice2.roll('N');
	flag += check(dice1, dice2);
	dice2.roll('N');
	dice2.roll('N');
	flag += check(dice1, dice2);
	return flag;
}

int main()
{
	int flag = 0, n;
	cin >> n;
	Dice dice1;
	for (int i = 1; i < n; i++)
	{
		Dice dice2;
		flag += dice_comp(dice1, dice2);
	}
	if (!flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>

void print_order(int a, int b, int c);

int main(void) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if(a <= b && b <= c) {
        print_order(a, b, c);
    }
    else if(a <= c && c <= b) {
        print_order(a, c, b);
    }
    else if(b <= a && a <= c) {
            print_order(b, a, c);
    }
    else if(b <= c && c <= a) {
        print_order(b, c, a);
    }
    else if(c <= a && a <= b) {
        print_order(c, a, b);
    }
    else {
            print_order(c, b, a);
    }
    return 0;
}

void print_order(int a, int b, int c) {
    printf("%d %d %d\n", a, b ,c);
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int i,a,b,c,k,maxn=-1;
	cin>>a>>b>>c>>k;
	for(i=1;i<=k;i++)
	{
		if(a>b&&a>c)
			a*=2;
		else if(b>a&&b>c)
			b*=2;
		else 
			c*=2;
	}
	cout<<a+b+c;
	return 0;
}

Measured memory_bytes: 3540
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

def dfs(i, a, b, c):
    if i == N:
        if min(a, b, c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) - 30
        else:
            return float('inf')
        
    n1 = 10 + dfs(i + 1, a + L[i], b, c)
    n2 = 10 + dfs(i + 1, a, b + L[i], c)
    n3 = 10 + dfs(i + 1, a, b, c + L[i])
    n4 = dfs(i + 1, a, b, c)
    
    return min(n1, n2, n3, n4)
    
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print (a + b)
    elif op == "-":
        print (a - b)
    elif op == "*":
        print (a * b)
    elif op == "/":
        print (a // b)  
    else:
        break


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

long long l[100];

int main() {
  int n; cin >> n;
  l[0]=2;
  l[1]=1;
  for (int i=2; i<=n;i++) {
    l[i]=l[i-1]+l[i-2];
  }
  cout << l[n] << endl;
  return 0;
}

Measured memory_bytes: 256
s,d=input(),int(input())
n=[int(i) for i in s]
l=len(s)
mod=10**9+7
dp=[[[0]*d,[0]*d] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for j in range(d):
            for x in range(10 if smaller else n[i]+1):
                dp[i+1][smaller or x<n[i]][(j+x)%d] += dp[i][smaller][j]
                dp[i+1][smaller or x<n[i]][(j+x)%d]%=mod
print((dp[l][0][0]+dp[l][1][0]-1)%mod)

Measured memory_bytes: 62300
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

s = input()
K = getN()

# K <= 5なのでS[i] ~ s[i:i + k]までを取り出すだけでOK
sub = set()
for k in range(1, 6):
    for i in range(len(s)):
        sub.add(s[i:i + k])

sub = sorted(list(sub))
print(sub[K - 1])

Measured memory_bytes: 39408
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <functional>
typedef long long ll;
using namespace std;
int main(){
    ll n,k;
    cin >> n >> k;

    ll cnt = 1;

    ll now = k;
    while(n / now > 0){
        cnt++;
        now *= k;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    string s,t;
    string n;
    int count=0;
    int maxcount=0;
    cin>>s;
    cin>>t;
    rep(i,s.size()-t.size()+1){
        n=s.substr(i,t.size());
        rep(k,t.size()){
            
            if(t[k]==n[k]){
                count++;
            }
        }
        if(count>maxcount){
            maxcount=count;
        }
        count=0;
    }
    cout<<t.size()-maxcount;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll A;
double B;

int main(){

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

cin>>A>>B;
ll C=round(100*B);
ll D=A*C;
cout<<D/100<<endl;


}
    


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

using namespace std;

const int maxn = 1e5 + 5;

int cnt[maxn];

int get(int x) {
    if (x < 0 || x > 1e5) return 0;
    return cnt[x];
}

int main(int argc, char const *argv[]) {

    int n; cin >> n;
    for (int i = 1; i <= n; i ++) {
        int x; scanf("%d", &x);
        cnt[x] ++;
    }

    int ans = 0;
    for (int i = 0; i <= 1e5; i ++) {
        int tmp = get(i - 1) + get(i) + get(i + 1);
        ans = max(ans, tmp);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll h , w;
    cin>>h>>w;
    ll pos = 0;
    if(h == 1 || w==1){
        pos = 1;
    }
    else if(!(h%2) && !(w%2)){
        pos = w * (h/2);
    }
    else if(h%2 && w%2){
        pos = ((h/2)+1)*((w/2)+1) + (h/2)*(w/2);
    }
    else if(h%2 && !(w%2)){
        pos = ((h/2)+1)*(w/2) + (h/2)*(w/2);
    }
    else if(!(h%2) && w%2){
        pos = w*(h/2);
    }
    cout<<pos;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (auto &e : s) {
    int k;
    cin >> k;
    e = vector<int>(k);
    for (auto &ee : e) {
      cin >> ee;
      ee--;
    }
  }
  vector<int> p(m);
  for (auto &e : p) cin >> e;

  int r = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool b = true;
    for (int j = 0; j < m; j++) {
      int c = 0;
      for (auto e : s[j]) c += (i >> e) & 1;
      b &= c % 2 == p[j];
    }
    r += b;
  }
  cout << r << endl;
}


Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif 30 > m + f:
        print('F')



Measured memory_bytes: 5596
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n, m;
    cin >> n >> m;

    vector<vector<bool>> g(n + 1, vector<bool>(n + 1));
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        g[u][v] = true;
        g[v][u] = true;
    }

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

    int ans = 0;
    do{
        bool tmp = true;
        for(int i = 0; i < n - 1; i++){
            if(!g[t[i]][t[i + 1]]) tmp = false;
        }
        ans += tmp;
    }
    while(next_permutation(t.begin() + 1, t.end()));

    cout << ans << "\n";

    return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for (int i=0; i<H; ++i) cin >> S[i];

    vector<string> ans(H);
    for (int i=0; i<H; ++i) {
        string temp = "";
        for (int j=0; j<W; ++j) {
            if (S[i][j] == '#') temp += '#';
            else {
                int cnt = 0;
                for (int dx=-1; dx<2; ++dx) {
                    for (int dy=-1; dy<2; ++dy) {
                        if ((j+dx>=0) && (j+dx<W) &&
                            (i+dy>=0) && (i+dy<H) &&
                            ((dx != 0) || (dy != 0))) {
                                if (S[i+dy][j+dx] == '#') ++cnt;
                            }
                    }
                }
                temp += to_string(cnt);
            }
        }
        ans[i] = temp;
    }
    for (int i=0; i<H; ++i) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct node *link;

struct node{
  int item;
  link next, prev;
};

int main(void){
  int n, i, j, getitem, size = 0;
  char s[16];
  link head, end;
  head = malloc(sizeof(*head));
  head->item = -1;
  head->next = NULL;
  head->prev = NULL;
  end = head;
  
  scanf("%d", &n); //input number
  
  for(i = 0; i < n; i++){
    scanf("%s", s);
    if(!strcmp(s, "insert")){ //insert
      scanf("%d", &getitem);
      link x;
      x = malloc(sizeof(*x));
      x->item = getitem;
      x->next = head;
      x->prev = NULL;
      head->prev = x;
      head = x;
      size++;
    }else if(!strcmp(s, "delete")){ //delete
      scanf("%d", &getitem);
      link x;
      x = malloc(sizeof(*x));
      x = head;
      if(head->item == getitem){ //head is delete point
	head = head->next;
	head->prev = NULL;
	size--;
	continue;
      }
      while(x->next->item != -1){ //look for delete point
	if(x->next->item == getitem){
	  x->next = x->next->next;
	  x->next->prev = x;
	  size--;
	  break;
	}else{
	  x = x->next;
	}
      }
    }else if(!strcmp(s, "deleteFirst")){ //deleteFirst
      if(size == 0){
	continue;
      }
      head = head->next;
      head->prev = NULL;
      size--;
    }else if(!strcmp(s, "deleteLast")){ //deleteLast
      if(size == 0){ //no element 
	continue;
      }else if(size == 1){ //only one element(same as deleteFirst)
	head = head->next;
	head->prev = NULL;
	size--;
	continue;
      }
      end->prev->prev->next = end;
      size--;
    }
  }


  //output
  link x;
  x = malloc(sizeof(*x));
  x = head;
  for(i = 0; i < size-1; i++){
    printf("%d ", x->item);
    x = x->next;
  }
  printf("%d\n", x->item);
  return 0;
}

Measured memory_bytes: 36044
// Created by Nikolay Budin

#ifdef DEBUG
#  define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ff first
#define ss second
#define szof(x) ((int)x.size())
#ifndef LOCAL
#  define cerr __get_ce
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }


void solve() {
	string s;
	cin >> s;
	int n = szof(s) + 1;
	vector<int> arr(n);
	for (int i = 1; i < n; ++i) {
		if (s[i - 1] == '<') {
			arr[i] = arr[i - 1] + 1;
		}
	}
	for (int i = n - 2; i >= 0; --i) {
		if (s[i] == '>') {
			arr[i] = max(arr[i], arr[i + 1] + 1);
		}
	}
	cout << accumulate(arr.begin(), arr.end(), 0ll) << "\n";
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}

#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
    string s,t;
    cin >> s;
    rep(i,3){
        if(i==2){
            cout << s[i] << endl;
        }else{
            cout << s[i];
        }
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args)throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int nk[]=Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int A[]=Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int n=nk[0];
        int cost[]=new int[n];
        cost[0]=0;
        cost[1]=cost[0]+Math.abs(A[1]-A[0]);
        for(int i=2;i<n;i++)
        {
            cost[i]=Integer.MAX_VALUE;
            for(int j=1;j<=nk[1];j++)
            {
                if(i-j<0)
                break;
                cost[i]=Math.min(cost[i],cost[i-j]+Math.abs(A[i]-A[i-j]));
            }
        }
        bw.write(Integer.toString(cost[n-1]));
        br.close();
        bw.close();
    }
}

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

int main() {
    int H,W; cin >> H >> W;
    vector<string> vec(H);
    for (int i = 0; i < H; i++) cin >> vec[i];
    vector<bool> row(H, false);
    vector<bool> col(W, false);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (vec[i][j] == '#') {
                row[i] = col[j] = true;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        if (row[i]) {
            for (int j = 0; j < W; j++) {
                if (col[j]) cout << vec[i][j];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <array>
 
int main() {
  int N;
  std::cin >> N;
  int t = 0, x = 0, y = 0;
  bool success = true;
  for (int i = 0; i < N; ++i) {
    int ti, xi, yi;
    std::cin >> ti >> xi >> yi;
    int delta_t = ti - t;
    int dst = std::abs(x - xi) + std::abs(y - yi);
    if (dst > delta_t || (delta_t - dst) % 2 != 0) {
      success = false;
      break;
    }
    t = ti;
    x = xi;
    y = yi;
  }
  if (success) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) yes;
    else no;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

int main(){
  int n,r;
  int p,c;
  int a[100],b[100];

  while(1){
    scanf("%d %d",&n,&r);
    if(n==0 && r==0) break;
    rep(i,n) a[i]=n-i;
    rep(i,r){
      scanf("%d %d",&p,&c);
      rep(j,p+c-1){
        b[j]=a[j];
      }
      rep(j,p-1){
        a[j+c]=b[j];
      }
      rep(j,c) a[j]=b[j+p-1];
    }
    printf("%d\n",a[0]);
  }

  return 0;

}

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    a, b, x = LI()

    import math

    if (a*a*b)/2 <= x:
        dprint('a')
        ans = math.atan((2/a) * (b- (x/a**2)))
    else:
        ans = math.atan2(b, 2*x/(a*b))

    print(360 * ans / (2*math.pi))


solve()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
int n,maxs,hi;
char ch;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    	cin>>ch;
    	if(ch=='I') hi++;
    	else hi--;
    	if(hi>maxs) maxs=hi;
	}
	cout<<maxs;
return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    b, h, s, = 0, 0, 1000

    for a in A:
        n_b, n_h = b % a, h + (b // a)
        if s // a == n_h:
            n_b = max(n_b, s % a)
        if s // a > n_h:
            n_h = s // a
            n_b = s % a
        s = max(s, b + h * a)
        b, h = n_b, n_h

    return s

print(main())


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  long long total = 0;
  for(int i=0; i < n; i++){
    cin >> a[i];
    total += a[i];
  }
  long long ans = 2020202040;
  long long sum = 0;
  for(int i=0; i < n; i++) {
    sum += a[i];
    ans = min(ans, abs(total-sum-sum));
  }
  cout << ans << endl;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	string str;
	cin >> str;
	
	ll sum = 0;
	for(int i = 0; i < (int)str.size(); i++){
		sum += str[i]-'0';
		sum %= 9;
	}
	if(sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define  ll long long
const int N = 100005;
const int mod = 1e9+7;
int a[N];
map<ll,ll>dp;
ll f(ll x)
{
   if(dp[x]!=0) //记忆化
   	return dp[x];
   else
   	return dp[x]=(f(x/2)%mod+f((x-1)/2)%mod+f((x-2)/2)%mod)%mod;
}
int main()
{
	ll n;
    scanf("%lld",&n);
    dp[0]=1;
    dp[1]=2;
    cout<<f(n);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll N,X; cin>>N>>X;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  ll ans=N,sum=0;
  sort(ALL(A));
  rep(i,0,N){
    sum+=A[i];
    if(sum>X){
      ans=i;
      break;
    }
  }
  if(sum!=X&&ans==N) ans--;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
import numpy as np

n, m = input().split()
i = [input() for i in range(int(m))]

n_l = [False] * int(n)
w_l = [0] * int(n)

for i_s in i:
    p, c = i_s.split()
    p = int(p) - 1
    if n_l[p] == 1:
        continue

    if c == "AC":
        n_l[p] = True
    else:
        w_l[p] += 1

n_l = np.array(n_l)
w_l = np.array(w_l)
w_l = w_l[n_l]

print("{} {}".format(n_l.sum(), w_l.sum()))


Measured memory_bytes: 20836
import java.util.Scanner;

public class Main {

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

        int a = in.nextInt();
        int b = in.nextInt();

        System.out.println((a * b) + " " + (a * 2 + b * 2));
        System.exit(0);
    }
}



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

const ll INF = 1LL << 60;

ll A, B;

// // 0 ~ x までの xor を求める
// // 周期2を利用するパターン
// ll f(ll x) {
//     ll tmp = (x + 1) / 2;
//     tmp %= 2;
//     // x が偶数の時、はみ出る (0-indexed)
//     if (x % 2 == 0) {
//         tmp ^= x;
//     } 
//     return tmp;
// }

// 0 ~ x までの xor を求める
ll f(ll x) {
    ll ans = 0;

    // 0-indexed なのでたす
    x++;

    for (int i = 0; i < 41; i++) {
        // 0桁目 -> 周期2
        // 1桁目 -> 周期4
        // 2桁目 -> 周期8
        ll loop_cnt = (1LL << (i + 1));

        // 1は周期の半分ずつ出てくる
        ll cnt = (x / loop_cnt) * (loop_cnt / 2);

        // はみ出た分カウントとる
        // 周期の前半は 0 で埋められている
        cnt += max(0LL, (x % loop_cnt) - (loop_cnt / 2));

        // その桁の1の数が奇数なら、足し算 (xor の結果が1になる)
        if (cnt % 2 == 1) {
            ans += (1LL << i);
        }
    }

    return ans;
}

int main() {
    cin >> A >> B;
    // cout << f(A - 1) << endl;
    // cout << f(B) << endl;

    // xor のたし算、引き算は、そのまま xor で ok
    ll ans = f(B) ^ f(A - 1);
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace::std;
using ll = long long;
int main() {
    string S; cin >> S;
    int res=0,t=0;
    for (int i=0;i<S.size();i++){
        if (S[i]=='A'||S[i]=='C'||S[i]=='T'||S[i]=='G'){
            t++;
            res = max(t,res);
        }
        else t = 0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e17;
const int mod=1e9+7;
const int M=100005;
int n,m;
vector<pi>adj[M];
int d[M];
bool vis[M];
 main()

{
    fast
    cin>>n>>m;
    f(i,1,m)
    {
        int lft,rgt,c;
        cin>>lft>>rgt>>c;
        adj[lft].pb(mp(rgt,c));
        adj[rgt].pb(mp(lft,c));
    }
    f(i,2,n)
    {
       adj[i].pb(mp(i-1,0));
    }
    priority_queue<pi,vector<pi>,greater<pi> >pq;
    f(i,1,n)d[i]=inf;
    d[1]=0;
    pq.push(mp(d[1],1));
    while(!pq.empty())
    {
        pi tmp=pq.top();
        pq.pop();
        int u=tmp.si;
        int cost=tmp.fi;
        if(vis[u])continue;
        vis[u]=1;
        for(auto x:adj[u])
        {
            int v=x.fi;
            int c=x.si;
            if(d[v]<=c+cost)continue;
            d[v]=c+cost;
            pq.push(mp(d[v],v));
        }
    }
    if(d[n]>=inf)d[n]=-1;
    cout<<d[n]<<endl;
    return 0;

}





































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

int main() {
ll a,b,c;
  cin>>a>>b>>c;
  ll k;
  cin>>k;
  if(k%2==1){
    cout<<b-a<<endl;}
  else cout<<a-b<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
sum_a = 0
sum = 0

for i in range(N):
  sum_a += A[i] 

for i in range(N):
  sum_a -= A[i]
  sum += A[i] * sum_a
  ans = sum % (10**9 + 7)

print(ans)


Measured memory_bytes: 31552
#include <stdio.h>

typedef struct{
  int id,l,r;
} Node;

int n;
Node t[25];

int search(int x){
  int i;
  for(i=0;i<n;i++){
    if(t[i].id==x)return i;
  }
}

int search2(int x){
  int i;
  for(i=0;i<n;i++){
    if(t[i].l==x||t[i].r==x)return i;
  }
  return -1;
}

void pre(int x){
  printf(" %d",t[x].id);
  if(t[x].l!=-1)pre(search(t[x].l));
  if(t[x].r!=-1)pre(search(t[x].r));
}

void in(int x){
  if(t[x].l!=-1)in(search(t[x].l));
  printf(" %d",t[x].id);
  if(t[x].r!=-1)in(search(t[x].r));
}

void post(int x){
  if(t[x].l!=-1)post(search(t[x].l));
  if(t[x].r!=-1)post(search(t[x].r));
  printf(" %d",t[x].id);
}

int getroot(int x){
  if(search2(x)==-1)return x;
  return getroot(t[search2(x)].id);
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&t[i].id,&t[i].l,&t[i].r);
  }
  int ro = search( getroot(t[0].id) );

  printf("Preorder\n");
  pre(ro);
  printf("\nInorder\n");
  in(ro);
  printf("\nPostorder\n");
  post(ro);
  printf("\n");
  return 0;
}

Measured memory_bytes: 616
x,y,z,k = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))
z_list = list(map(int,input().split()))

ans_list = []

x_list.append(-99999999999)
y_list.append(-99999999999)
z_list.append(-99999999999)

l,m,n = 0,0,0

x_list.sort(reverse=True)
y_list.sort(reverse=True)
z_list.sort(reverse=True)

x1 = x_list[0]
y1 = y_list[0]
z1 = z_list[0]

while (l+1)*(m+1)*(n+1) < 100000 and (l<x and m<y and n<z):
    if x1-x_list[l+1] <= y1-y_list[m+1] and x1-x_list[l+1] <= z1-z_list[n+1]:
        l += 1
    elif y1-y_list[m+1] <= x1-x_list[l+1] and y1-y_list[m+1] <= z1-z_list[n+1]:
        m += 1
    elif z1-z_list[n+1] <= x1-x_list[l+1] and z1-z_list[n+1] <= y1-y_list[m+1]:
        n += 1
    else:
        print(ans_list[9999999])
        break
#print(l,m,n)
for p in range(l+1):
    for q in range(m+1):
        for r in range(n+1):
            ans_list.append(x_list[p]+y_list[q]+z_list[r])

ans_list.sort(reverse=True)
for i in range(k):
    print(ans_list[i])



Measured memory_bytes: 11484
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
	int a[3], b[3];

	for (int i = 0; i < 3; i++) {
		cin >> a[i] >> b[i];
	}

	bool f = false;
	for (int i = 0; i < 3; i++) 
	{ 
		for (int j = 0; j < 3; j++) {
			if (i == j) continue;
			if (a[i] != b[j] && b[i] != b[j]) {
				if (a[j] != a[i] && a[j] != b[i] && a[j] != b[j]) {
					f = true;
					break;
				}
			}
		}
	}

	if (f) printf("YES\n"); else printf("NO\n");
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by kyosuke on 2016/05/27.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
            int num = sc.nextInt();
            if (num == 0) break;
            if (num == 1)
            {
                System.out.println(1);
            }
            else if(num == 2) {
                System.out.println(1);
            }
            else
            {
                System.out.println(prime(num * 2) - prime(num));
            }
        }

    }

    public static int prime(int x) {
        // ?´???°??????????????°
        boolean isPrime = false;
        // ?´???°?????°???????????????
        int count = 1; // 2,3?????\?????????????????§???????????????????????¨????????????????????????
        // 4????´???°??§??????????????§?¨?????????????
        // i += 2 ??????????????¨??§??¶??°????´???°?¨????????????????2??\????????¶??°????´???°??§??????????????????
        for (int i = 3; i <= x; i += 2) {
            // ?´???°??????????±?(i)????´???°??????????±?(j)??????????????\?????§????????????
            for (int j = 2; j * j <= i; j++) {
                // ????????§????????´???????´???°??§????????????????????????????????????
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
                isPrime = true;
            }
            if (isPrime) {
                count++; // ?´???°???????????????
                // ?????????????????§??????????????¢??????
                // System.out.println("PrimeNumber -> " + i);
            }
        }
        return count;
    }
}

Measured memory_bytes: 27276