akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const ll INF = 1e+18 + 1;
const ll BASE = 1e+9 + 9;

int n, m;
ll k;
char strs[110][210];
int lens[110];
ll dp[2310];
ll num[2310];
char ans[2310];

inline ll Plus(ll lhs, ll rhs) {
  if (lhs + rhs >= INF) { return INF; }
  return lhs + rhs;
}

inline ll Mul(ll lhs, ll rhs) {
  if (rhs == 0) { return 0; }
  if (lhs * rhs / rhs != lhs || lhs * rhs >= INF) { return INF; }
  return lhs * rhs;
}

ll cnts[300];
void CalcNum1(int l) {
  MEMSET(cnts, 0);
  num[l] = 0;
  REP(i, n) {
    ull powBase = 1;
    ull h1 = 0;
    ull h2 = 0;
    ull prev = 0;
    REP(j, min(lens[i], l)) {
      int rest = m - (l - j - 1 + lens[i]);
      ull next = strs[i][j];
      h1 = h1 * BASE + strs[i][j];
      h2 = h2 - prev + next + ans[l - j - 1] * powBase;
      powBase *= BASE;
      prev = next;
      if (h1 != h2 || rest < 0) { continue; }
      ll cnt1 = dp[rest];
      ll cnt2 = num[l - j - 1];
      cnts[next] = Plus(cnts[next], Mul(cnt1, cnt2));
    }
  }
}

void CalcNum2(int l) {
  num[l] = 0;
  REP(i, n) {
    if (lens[i] > l) { continue; }
    ull powBase = 1;
    ull h1 = 0;
    ull h2 = 0;
    REP(j, min(lens[i], l)) {
      h1 = h1 * BASE + strs[i][j];
      h2 = h2 + ans[l - j - 1] * powBase;
      powBase *= BASE;
    }
    if (h1 != h2) { continue; }
    num[l] = Plus(num[l], num[l - lens[i]]);
  }
}

void calc(int depth, ll need) {
  if (depth == m) { return; }
  CalcNum1(depth + 1);
  FOREQ(c, 'a', 'z') {
    ans[depth] = c;
    ll cnt = cnts[c];
    if (cnt >= need) { break; }
    need -= cnt;
  }
  CalcNum2(depth + 1);
  calc(depth + 1, need);
}

int main() {
  while (scanf("%d %d %lld", &n, &m, &k) > 0) {
    MEMSET(ans, 0);
    MEMSET(dp, 0);
    MEMSET(num, 0);
    dp[0] = 1;
    num[0] = 1;
    REP(i, n) {
      scanf("%s", strs[i]);
      lens[i] = strlen(strs[i]);
    }
    FOR(i, 1, 2010) {
      REP(j, n) {
        if (i - lens[j] < 0) { continue; }
        ll cnt = dp[i - lens[j]];
        dp[i] = Plus(dp[i], cnt);
      }
    }
    if (dp[m] < k) {
      puts("-");
      continue;
    }
    calc(0, k);
    printf("%s\n", ans);
  }
}

Measured memory_bytes: 1248
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
	std::io::Read::read_to_string(
		&mut std::io::stdin(),
		&mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
	let mut get = || stdin.next().unwrap();
	macro_rules! get {
		() => (get().parse::<i64>().unwrap());
		($t:ty) => (get().parse::<$t>().unwrap());
	}
    
	let n = get!();
	let d = get!();
	let x = get!();
	let mut ans = x;
	for _ in 0..n {
		let a = get!();
		for i in 0..d {
			if i * a + 1 > d {
				break;
			}
            ans += 1;
		}
	}
	println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;

int h,w,k;
char a[6][6];

bool go(int x,int y){
    int res=0;
    rep(i,0,h){
        if((1<<i)&x) continue;
        rep(j,0,w){
            if((1<<j)&y) continue;
            if(a[i][j]=='#') res++;
        }
    }
    return res==k;
}

void solve(){
    cin>>h>>w>>k;
    rep(i,0,h) rep(j,0,w) cin>>a[i][j];

    int ans=0;

    rep(i,0,1<<h){
        rep(j,0,1<<w){
            ans+=go(i,j);
        }
    }
    cout<<ans;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  rep(i, n) {
    long long a,b;
    cin >> a >> b;
    x[i]=a-b;
    y[i]=a+b;
  }
  sort(x.begin(), x.end());
  long long ans1 = x[n-1]-x[0];
  sort(y.begin(), y.end());
  long long ans2 = y[n-1]-y[0];
  long long ans = max(ans1, ans2);
  cout << ans << endl;
}

Measured memory_bytes: 4908
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B, C, K; cin >> A >> B >> C >> K;
  if(A >= K){
    cout << K << endl;
  }else if(A + B >= K){
    cout << A << endl;    
  }else{
    cout << A - (K-A-B) << endl;
  }
}

Measured memory_bytes: 3668
#include<stdio.h>

/*構造体の定義*/
typedef struct {
	char suit;
	int value;
} Card ;


void swap_Card(Card *x, Card *y)
{
	Card temp = *x;
	*x = *y;
	*y = temp;
}


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

	int i,j;
	Card BC[36];
	Card SC[36];

	for (i = 0; i < N; i++) {
		Card c;
		scanf("%c", &c.suit);
		scanf("%d ", &c.value);
		BC[i] = c;
		SC[i] = c;
	}

	/* Bubble Sort */
    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j > i; j--) {
            if (BC[j].value < BC[j - 1].value)
                swap_Card(&BC[j], &BC[j - 1]);
        }
    }
	
	/* Selection Sort */
    for (i = 0; i < N - 1; i++) {
        int minj = i;
        for (j = i + 1; j < N; j++) {
            if (SC[j].value < SC[minj].value)
                minj = j;
        }
        swap_Card(&SC[i], &SC[minj]);
    }
	
	/* Output */
	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", BC[i].suit, BC[i].value);
	}
	printf("%c%d\n", BC[N - 1].suit, BC[N - 1].value);
	puts("Stable");

	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", SC[i].suit, SC[i].value);
	}
	printf("%c%d\n", SC[N - 1].suit, SC[N - 1].value);

	for (i = 0; i < N; i++) {
		if (BC[i].suit != SC[i].suit) {
			puts("Not stable");
			return 0;
		}
	}
	puts("Stable");

	return 0;
}


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

#include <string.h>


int main(){
	long i,j,k;
	long X,K,D;
	scanf("%ld%ld%ld",&X,&K,&D);
	long tmp=0;
	long a= labs(X)/D;
	if(a<K){
		tmp=a;
		if(X>0)X-=a*D;
		else X+=a*D;
	}
	else {
		tmp=K;
		if(X>0)X-=tmp*D;
		else X+=tmp*D;
		
	}
	for(i=tmp;i<K;i++){
		if(X>0){
			X-=D;
			//("X:%ld,",X);
			if(X<0)break;
		}
		else {
			X+=D;//printf("X:%ld,",X);
			if(X>0)break;
		}
	}
	//printf("i:%ld,K:%ld\n",i,K);
	if(i!=K)
	if((K-i-1)%2!=0){
		if(X>0)X-=D;
		else X+=D;
	//	printf("aX:%ld,",X);
	}
	printf("%ld\n",labs(X));
	return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include<string>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include <time.h>
#include<limits.h>
#include<unordered_map>
#include <set>
using namespace std;

int main() {
    int a,b; cin >> a >> b;
    cout << a * 1ll * b << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> p(n);
    std::vector<int> place(n + 1);
    std::set<int> check;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        place[p[i]] = i;
        if(p[i] == n){
            check.insert(i);
        }
    }
    int out = 0;
    for(int i = n - 1; i >= 1; i--){
        check.insert(place[i]);
        auto nowit = check.find(place[i]);
        int ll,l,r,rr;
        int flagl = 0;
        int flagr = 0;
        if(nowit == check.begin()){
            l = -1;
            ll = -1;
        } else if(std::next(nowit,-1) == check.begin()){
            l = *std::next(nowit,-1);
            ll = -1;
        } else {
            l = *std::next(nowit,-1);
            ll = *std::next(nowit, -2);
        }
        if(nowit == std::next(check.end(),-1)){
            r = n;
            rr = n;
        } else if(std::next(nowit,1) == std::next(check.end(),-1)){
            r = *std::next(nowit,1);
            rr = n;
        } else {
            r = *std::next(nowit,1);
            rr = *std::next(nowit, 2);
        }
        
        out += i * (r - place[i]) * (l - ll) + i * (place[i] - l) * (rr - r);
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str>>str2>>str3;
	if(str[str.length()-1]==str2[0]&&str2[str2.length()-1]==str3[0]){
		cout<<"YES";
	}else{cout<<"NO";}





	cout<<endl;
} 


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

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

int main(){
    char c[1]; cin >> c;
    c[0] = c[0] + 1;
    cout << c[0] << endl;
}

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

int main(){
	int H,W,i,j;
	
	while(1){
		cin>>H>>W;
		if(H==0 && W==0)
			break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i==0 || i==H-1 || j==0 || j==W-1)
					cout<<"#";
				else
					cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
}
	

Measured memory_bytes: 1152
function p(s){
if(process.env.HOGE ){
  console.log(s);
}
}

function Main(args){

  const firstRow = args.split("\n")[0];
  const row = args.split("\n")[1].split(" ").map(v => Number(v));

  for(var i = row.length -1; i > 0; i-- ){

    p("index = "  + i + " : "  + row[i-1] + " vs " + row[i]);

    if( row[i-1] > row[i] ){

      // p( row[i-1] + "->" + String(row[i-1] - 1) );

      row[i-1] -= 1;

      // p("new value = " + row[i-1]);

    }

    if( row[i-1] > row[i] ){

      return console.log("No");
    }
  }

  p(row)
  console.log("Yes");
  p("===========")
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 36192
N=int(input())
ca=0
cw=0
ct=0
cr=0
for _ in range(N):
  a=input()
  if a=='AC':
    ca+=1
  elif a=='WA':
    cw+=1
  elif a=='TLE':
    ct+=1
  elif a=='RE':
    cr+=1
    
print('AC x',ca)
print('WA x',cw)
print('TLE x',ct)
print('RE x',cr)

Measured memory_bytes: 9064
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int k;
  cin>>k;
  cout<<(k/2)*(k-k/2);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

int main(){
  int n; cin >> n;
  bool ans = true;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    if(a % 2 == 1){
      ans = false;
      break;
    }
  }
  if(ans) cout << "second" << endl;
  else cout << "first" << endl;
}

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x = stdIn.nextInt();
        int count = 0;
        int position = 0;
        
        if(x != 0){
            count++;
            while(stdIn.hasNext()){
                int a = stdIn.nextInt();
                position += a;
                
                if(position <= x){
                    count++;
                }else{
                    break;
                }
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


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

    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll n = s.size();
    // a : 前から連続する数, b : 後ろから
    ll a = 1, b = 1;
    while (a <= n && s[a] == s[a - 1]) a++;
    while (b <= n && s[n - 1 - b] == s[n - b]) b++;

    // c コ連続 -> c / 2 回操作が必要
    // 全部同じ文字の場合
    if (a == n) {
        ll res = n * k / 2;
        cout << res << endl;
        return 0;
    }
    // oneset : s 1コにつき必要な操作回数
    ll oneset = 0, c = 1;
    REP(i, n - 1) {
        if (s[i + 1] == s[i]) c++;
        else oneset += c / 2, c = 1;
    }
    oneset += c / 2;
    ll res = k * oneset;
    if (s[n - 1] == s[0]) res += (k - 1) * ((a + b) / 2 - a / 2 - b / 2);
    cout << res << endl;
    return 0;
}

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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> A(n);
  for (int& a : A)
    cin >> a;
  int a0 = A[0];
  for (int i = 0; i < n - 1; ++i)
    A[i] = A[i + 1] - A[i];
  A[n - 1] = k + a0 - A[n - 1];
  sort(A.begin(), A.end());
  cout << k - A[n - 1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// Item :
type Item struct {
	priority, value, index int
}

// PQ :
type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// Push :
func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

// Pop :
func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

// Edge :
type Edge struct {
	to, cost int
}

// Path :
type Path struct {
	edges []Edge
}

// Route :
type Route struct {
	path []int
}

// Dijkstra :
func Dijkstra(N, S int, path [][]int) ([]int, []Route) {
	pq := make(PQ, 0)
	heap.Init(&pq)
	d := make([]int, N+1)
	r := make([]Route, N+1)
	// init
	for i := 0; i <= N; i++ {
		d[i] = math.MaxInt32
	}
	d[S] = 0
	r[S].path = []int{S}
	heap.Push(&pq, &Item{0, S, 0})
	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		v := item.value
		if d[v] < item.priority {
			continue
		}
		for i, c := range path[v] {
			e := Edge{i, c}
			if d[e.to] > d[v]+e.cost {
				d[e.to] = d[v] + e.cost
				r[e.to].path = append(r[v].path, e.to)
				heap.Push(&pq, &Item{d[e.to], e.to, 0})
			}
		}
	}
	return d, r

}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([][]int, N)
	b := make([][]int, N)
	n := make([][]int, N)
	for i := 0; i < N; i++ {
		a[i] = make([]int, N)
		b[i] = make([]int, N)
		n[i] = make([]int, N)
		for j := 0; j < N; j++ {
			a[i][j] = getInt()
			b[i][j] = a[i][j]
			n[i][j] = a[i][j]
		}
	}

	ans := 0
LOOP:
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if b[i][j] > b[i][k]+b[k][j] {
					b[i][j] = b[i][k] + b[k][j]
					ans = -1
					break LOOP
				} else if b[i][j] == b[i][k]+b[k][j] {
					// 経由しても距離が同じなら、ルートを消去
					if i != k && j != k {
						n[i][j] = -1
					}
				}
			}
		}
	}

	if ans == 0 {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if n[i][j] != -1 {
					ans += n[i][j]
				}
			}
		}
		out(ans / 2)
	} else {
		out(-1)
	}
}


Measured memory_bytes: 4608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int n, m, g[51][51];
vector<pair<int, int>> st;
bool path[20][51];

bool dfs(int u, int p, int i) {
    if (u == st[i].second) return true;
    bool f = false;
    for (int v = 1; v <= n; ++v) {
        int e = g[u][v];
        if (v != p && e != 0) {
            if (dfs(v, u, i)) {
                f = true;
                path[i][e] = true;
            }
        }
    }
    return f;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a][b] = g[b][a] = i;
    }
    cin >> m;
    st.resize(m);
    for (int i = 0; i < m; ++i) {
        cin >> st[i].first >> st[i].second;
    }

    for (int i = 0; i < m; ++i) {
        dfs(st[i].first, 0, i);
    }

    i64 co = 0;
    for (int s = 1; s < (1 << m); ++s) {
        int cnt = 0;
        bool f[51] = {};
        for (int i = 0; i < m; ++i) {
            if (s & (1 << i)) {
                ++cnt;
                for (int e = 1; e <= n - 1; ++e) {
                    f[e] |= path[i][e];
                }
            }
        }
        int x = 0;
        for (int e = 1; e <= n - 1; ++e) {
            x += !f[e];
        }
        co += (cnt & 1 ? 1 : -1) * (1ll << x);
    }

    i64 ans = (1ll << (n - 1)) - co;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())
b = list(map(int, input().split()))
ans = []
for i in range(n):
    for j in range(len(b), 0, -1):
        if b[j - 1] == j:
            ans.append(j)
            del b[j - 1]
            break
    else:
        print(-1)
        sys.exit()
ans.reverse()
for i in ans:
    print(i)

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

using namespace std;

int main() {
    string s,t;
    int n = 0;
    cin >> s >> t;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) n++;
    }
    
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    double r;
    // scanf("%d %d",r);
    cin >> r;
    const double pi = 3.141592653589793;
    // cout<< M_PI<<endl;
    printf("%.6f %.6f\n", double(pi*r*r), double(2*pi*r));
    return 0;

}


Measured memory_bytes: 3288
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

const int V = 200;
vector<int> G[V];
int match[V];
bool used[V];

void add_edge(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v]=true;
	REP(i,G[v].size()){
		int u=G[v][i],w=match[u];
		if(w<0||!used[w]&&dfs(w)){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res=0;
	memset(match,-1,sizeof(match));
	REP(v,V){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}

double dist(double x1,double x2,double y1,double y2){
	double dx=x1-x2;
	double dy=y1-y2;
	return sqrt(dx*dx+dy*dy);
}

int main(){
	cout.precision(16);
	int n,m;
	while(cin>>n>>m,n|m){
		vi x(n),y(n),v(n);
		REP(i,n){
			cin>>x[i]>>y[i]>>v[i];
		}
		vi bx(n),by(n);
		REP(i,m){
			cin>>bx[i]>>by[i];
		}

		double lb=-1,ub=20000;
		REP(cnt,1000){
			REP(i,V){
				G[i].clear();
			}
			double mid=(lb+ub)/2;

			REP(i,n){
				REP(j,m){
					if(dist(x[i],bx[j],y[i],by[j])<=mid*v[i]){
						add_edge(i,100+j);
					}
				}
			}

			if(bipartite_matching()>=m){
				ub=mid;
			}else{
				lb=mid;
			}
		}

		printf("%.16f\n",ub);
		//cout<<ub<<endl;
	}
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    int a;
    int d[10]={0};
    for(int i=0;i<6;i++){
        cin>>a;
        d[a]++;
    }
    if(d[1]<3&&d[2]<3&&d[3]<3&&d[4]<3) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        int[] n = new int[10];
        for (int i = 0; i < 3; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            n[ab[0] - 1]++;
            n[ab[1] - 1]++;
        }
        if(n.Max() <= 2)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

class Dijkstra{
private:
    struct edge { int to, cost;};
    vector< vector<edge> > g;
    vvi ee;
    vector<int> prever;
    int n;
public:
    Dijkstra(){};
    Dijkstra(int size){
        n = size;
        g.resize(n);
        ee = vvi(n,vi(n,0));
    }

    vi dist;

    void add_edge(int a, int b, int c){//無向辺
        edge e1 = {b, c}, e2 = {a, c};
        ee[a][b]++;
        g[a].push_back(e1);
    }

    void calc(int s){
        priority_queue< pii, vector<pii>, greater<pii> > q;
        int n = g.size();
        dist = vi (n, INF);
        dist[s] = 0;
        q.push(pii(0, s));
        prever = vector<int>(n,-1);

        while(!q.empty()){
            pii p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first)continue; //更新されていたら何もしない
            for(int i = 0; i < g[v].size(); i++){
                edge e = g[v][i];
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    prever[e.to] = v;
                    q.push(pii(dist[e.to], e.to));
                }
            }
        }
    }

    vector<int> get_path(int t){ //頂点tへの最短路
        vector<int> path;
        for(; t != -1;t=prever[t]){
            path.push_back(t);
        }
        reverse(path.begin(), path.end());
        return path;
    }

    void solve(){
        int mi = INF;
        vi ans;
        rep(i,n){
            calc(i);
            rep(j,n)if(ee[j][i] && dist[j] < INF){
                int len = dist[j]+1;
                if(len < mi){
                    mi = len;
                    ans = get_path(j);
                }
            }
        }
        if(mi == INF){
            cout << -1 << endl;
        }else{
            cout << ans.size() << endl;
            rep(i,ans.size())cout << ans[i]+1 << " ";
        }

    }

};



signed main(void) {
    int n,m;
    cin >> n >> m;
    Dijkstra dij(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        dij.add_edge(a,b,1);
    }
    dij.solve();
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N; std::vector<int> A; std::vector<int> AA;
    int n,nn;
    for(int i=0; i<N;i++){
      int a; cin>>a; A.push_back(a); AA.push_back(a);
    }
    sort(A.begin(), A.end());
    n = A[N-1]; nn = A[N-2];
    for(int i=0; i<N;i++){
      if(AA[i]==n) cout<<nn<<endl;
      else cout<<n<<endl;
    }
    return 0;
}


Measured memory_bytes: 3436
x,y,a,b,c=map(int, input().split())
*P,=map(int, input().split())
*Q,=map(int, input().split())
*R,=map(int, input().split())

P = sorted(P)[-x:]
Q = sorted(Q)[-y:]
H = sorted(P+Q)
R.sort()

ans=0
for h in H:
    if R and R[-1] > h:
        ans += R.pop()
    else:
        ans += h
print(ans)

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    int n=s.length();
    bool ok=true;
    for (int i = 0; i < n/2; i++)
    {
        if(s[i]!=s[n-1-i]) 
        {
            ok=false;
            break;
        }
    }
    for (int i = 0; i < (n-1)/2; i++)
    {
        if(s[i]!=s[(n-1)/2-1-i])
        {
            ok=false;
            break;
        }
    }
    for (int i = (n+3)/2; i < n; i++)
    {
        if(s[i]!=s[n-1-i])
        {
            ok=false;
            break;
        }
    }
    if(ok)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  int ans=0;
  for(int i=0;i<n;i++){
    if(i%2==0 && a.at(i)%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

  return 0;
}

Measured memory_bytes: 580
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

h1,m1,h2,m2,k = map(int,ipt().split())

print((h2-h1)*60+(m2-m1)-k)


Measured memory_bytes: 68736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    string s, t; cin >> s >> t;
    if(t.substr(0, t.size()-1) == s) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
 
public class Solution
{
    public static void Main()
    {
      long N = long.Parse(Console.ReadLine());
      string str1 = Console.ReadLine();
      string str2 = Console.ReadLine();
      string[] strA = str1.Split(' ');
      string[] strB = str2.Split(' ');
      long[] A = new long[N+1];
      long[] B = new long[N];
      for (int i = 0; i < N; i++)
      {
        A[i] = long.Parse(strA[i]);
        B[i] = long.Parse(strB[i]);
      }
      A[N] = long.Parse(strA[N]);
      
      // N+1番目の町はN番目の勇者しか倒せないので
      // N+1からやっていけばよさそう
      long total = 0;
      long amari = 0;
      for (long i = N; i > 0L; i--)
      {
        // 一つ前の処理でN+1番目の勇者が残した倒せる数を処理する
        // モンスターの数が同じか残る場合、
        //  totalに勇者が残した倒せる数を足す、モンスターの数から倒した数をひく
        // モンスターの数より倒せる場合、totalにモンスターの数を足す、モンスターの数を0にする
        if (A[i] - amari >= 0)
        {
          total += amari;
          A[i] -= amari;
        }
        else
        {
          total += A[i];
          A[i] = 0;
        }
        
        // N番目の勇者が倒せるモンスターの数を処理する
        // モンスターの数が同じか残る場合、
        //  totalに勇者が残した倒せる数を足す、勇者あまりを0にする
        // モンスターの数より倒せる場合、
        //  totalにモンスターの数を足す、勇者あまりを勇者からモンスターを引く
        if (A[i] - B[i-1] >= 0)
        {
          total += B[i-1];
          amari = 0;
        }
        else
        {
          total += A[i];
          amari = B[i-1] - A[i];
        }
      }
      // 1番目の町の処理
      if (A[0] - amari >= 0)
      {
        total += amari;
        A[0] -= amari;
      }
      else
      {
        total += A[0];
        A[0] = 0;
      }      
      Console.WriteLine($"{total}");
//      Console.WriteLine($"{p[0]} {p[1]} {p[2]} {p[3]} {p[4]}");
//      Console.WriteLine($"{dst[0]} {dst[1]} {dst[2]} {dst[3]} {dst[4]}");
//      Console.WriteLine($"{cnt}");
    }
}

Measured memory_bytes: 31732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b;
  cin>>a>>b;
  if(a*b<=0)
    cout<<"Zero"<<endl;
  else if(0<a)
    cout<<"Positive"<<endl;
  else{
  if((b-a+1)%2==0)
    cout<<"Positive"<<endl;
    else
      cout<<"Negative"<<endl;
  
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(int argc, char* argv[]) {
  int A, B;
  cin >> A >> B;

  int res = 0;
  for (int i = A; i <= B; ++i) {
    string s = to_string(i);
    bool isit = true;
    for (int j = 0; j < s.size() / 2; ++j) {
      if (s[j] != s[s.size() - j - 1]) {
        isit = false;
        break;
      }
    }
    if (isit)
      ++ res;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


A,B = LI()

gcd = fractions.gcd(A,B)
ans = 1
for facter in factorization(gcd):
    if facter[0] == 1:
        pass
    else:
        ans += 1
print(ans)


'''
12 18
1 2 3 6
1 2 3

6 9
1 3
1 2 3

420 660
210 330
105 165
35 55
7 11

2**2*3
1 2 3 5
'''


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

uint64_t lucas_num(int N)
{
    assert(N >= 0);

    static vector<uint64_t> memo(100, 0);
    if (memo[N] > 0)
    {
        return memo[N];
    }

    auto &ret = memo[N];
    if (N == 0)
    {
        ret = 2;
    }
    else if (N == 1)
    {
        ret = 1;
    }
    else
    {
        ret = lucas_num(N - 1) + lucas_num(N - 2);
    }
    return ret;
}

void main_()
{
    int N;
    cin >> N;
    cout << lucas_num(N) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 892
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    w,a,b = f()
    if a>b:
        a,b = b,a
    aw = a+w
    if aw < b:
        print(b - aw ) 
    else:
        print(0)

solve()


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x; cin >> x;
  ll ans = x / 500 * 1000;
  x = x % 500;
  ans += x / 5 * 5;

  cout << ans << endl;
}


Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	int x, y, z;cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
}

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

Dv = [0]*(A[-1]+1)
Ct = [0]*(A[-1]+1)

for a in A:
  Dv[a] += 1
  Ct[a] += 1
  
for a in A:
  if Dv[a] >= 2:
    Dv[a] = 1
    Ct[a] = 0

for i in range(1,A[-1]+1):
  if Dv[i] == 1:
    for j in range(2,A[-1]+1): 
      if j * i > A[-1]:
        break
      Dv[j*i] = 0
      Ct[j*i] = 0

Ct[0] = 0
ans = sum(Ct)

print(ans)

Measured memory_bytes: 34984
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto abk = aryread();

    foreach (i; 0 .. abk[2])
    {
        abk[(i + 1) % 2] += abk[i % 2] / 2;
        abk[i % 2] /= 2;
    }
    writefln("%d %d", abk[0], abk[1]);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = IOUtils.ReadLong();

            long a = 0;
            while (true)
            {
                var a5 = Math.Pow(a, 5);
                if (a5 > x) break;

                long b = a; //逆の組み合わせはもうやってる
                while (true)
                {
                    var val = a5 + Math.Pow(b, 5);
                    if (x == val)
                    {
                        Console.WriteLine(a + " " + "-" + b);
                        return;
                    }
                    if (val > x) break;

                    b++;
                }

                a++;
            }

            //引くほう
            a = 0;
            while (true)
            {
                var a5 = Math.Pow(a, 5);

                var b = 0;
                while (true)
                {
                    var val = a5 - Math.Pow(b, 5);
                    if (x == val)
                    {
                        Console.WriteLine(a + " " + b);
                        return;
                    }

                    if (a == b) break;
                    b++;
                }

                a++;
            }

        }
    }


    static class IOUtils
    {
        public static (int a, int b) Read2Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1]);
        }
        public static (int a, int b, int c) Read3Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1], vals[2]);
        }
        public static IEnumerable<int[]> ReadIntLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadInts();
            }
        }
        public static IEnumerable<long[]> ReadLongLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadLongs();
            }
        }
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }


}


Measured memory_bytes: 18076
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int k,s; cin >> k >> s;
    int count = 0; 

    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            if(i + j >= s - k && i + j <= s)count++;
        }
    }
    print(count);
}

Measured memory_bytes: 764
open Str;;

let rec multiply base list = match list with
    [] -> base
  | head :: tail -> multiply (base * head) tail;;

let rec syuu base list = match list with
    [] -> base
  | head :: tail -> syuu (base + head * 2) tail;;

let rec toString (a, b) = string_of_int a ^ " " ^ string_of_int b;;

read_line()
|> Str.split (Str.regexp " ") 
|> List.map int_of_string
|> fun list -> (multiply 1 list, syuu 0 list);
|> toString
|> print_endline



Measured memory_bytes: 2136
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b <= c*2:
    ans = a*x+b*y
else:
    if x>y:
        ans = min(2*c*y+(x-y)*a, 2*c*x)
    else:
        ans = min(2*c*x+(y-x)*b, 2*c*y)
print(ans)

Measured memory_bytes: 38256
import bisect
w1=input()
w2=input()
d={}
for i in list("qwertyuiopasdfghjklzxcvbnm"):
  d[i]=[]
for i in range(len(w1)):
  d[w1[i]].append(i+1)
num=len(w1)
for i in w2:
  if d[i]==[]:
    print(-1)
    exit()
now=0#w1の何文字目か
count=0#w1を何回繰り返しているか
num2=len(w2)
for i in range(num2):
  d1=d[w2[i]]
  if d1[-1]<now:
    now=d1[0]+1
    count+=1
  else:
    index=bisect.bisect_left(d1,now)
    now=d1[index]+1
print(count*num+now-1)


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

int main()
{
  int a,b;
  int sum=0;
  cin>>a>>b;
  
  if(a<=9)
  {
    if(b<=9)
    {
      sum=a*b;
    }
    else
    {
      sum=-1;
    }
  }
  else
  {
    sum=-1;
  }
  
  cout<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 26
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Tree_t;

Tree_t T[N];
int n;

void preParse(int u){
if (u == NIL) return;
printf(" %d",u);
preParse(T[u].left);
preParse(T[u].right);
}

void inParse(int u){
if (u == NIL) return;
inParse(T[u].left);
printf(" %d",u);
inParse(T[u].right);
}

void postParse(int u){
if (u == NIL) return;
postParse(T[u].left);
postParse(T[u].right);
printf(" %d",u);
}

int main(){
  int id,left,right,root,i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
     T[i].parent=NIL;
   }

for(i=0;i<n;i++){
  scanf("%d%d%d",&id,&left,&right);
  T[id].left=left;
  T[id].right=right;
  if(left!=NIL) T[left].parent=id;
  if(right!=NIL) T[right].parent=id;
}

for(i=0;i<n;i++){
if(T[i].parent==NIL) root = i;
}

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

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

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

return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll n;
  cin >> n;
  ll sum = 1;
  bool f = 1;
  ll p = 1000000000000000000;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (a == 0) {
      sum = 0;
    }
    else if (p / a < sum) {
      f = 0;
    }
    else sum = sum * a;
  }
  if (f || sum == 0) printf("%lld\n", sum);
  else cout << -1 <<endl;
}

Measured memory_bytes: 3764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int *val, *wei, *dp;
int main(void){
	int W, N, sv, sw, i, j, k;
	scanf("%d",&W);
	for(i = 1;W != 0;i++){
		scanf("%d",&N);
		val = (int *)malloc(sizeof(int) * N);
		wei = (int *)malloc(sizeof(int) * N);
		dp = (int *)malloc(sizeof(int) * (W + 1));
		for(j = 0;j <= W;j++)
			*(dp + j) = -1;
		*dp = 0;
		for(j = 0;j < N;j++)
			scanf("%d %*c %d",val + j,wei + j);
		for(j = 0;j < N;j++){
			for(k = W - *(wei + j);k >= 0;k--){
				if(*(dp + k) != -1 && *(dp + k) + *(val + j) >= *(dp + k + *(wei + j)))
					*(dp + k + *(wei + j)) = *(dp + k) + *(val + j);
			}
		}
		sv = sw = -1;
		for(j = 0;j <= W;j++){
			if(*(dp + j) > sv){
				sv = *(dp + j);
				sw = j;
			}
		}
		printf("Case %d:\n%d\n%d\n",i,sv,sw);
		scanf("%d",&W);
	}
	return 0;
}

Measured memory_bytes: 612
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

class Program {

	public void Proc() {
		int[] inpt = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
		string ans
			= inpt[0] + inpt[1] == inpt[2] ? "Yes"
			: inpt[0] + inpt[2] == inpt[1] ? "Yes"
			: inpt[1] + inpt[2] == inpt[0] ? "Yes"
			: "No";
		Console.WriteLine(ans);
	}

	static void Main(string[] args) {
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 2776