akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


ll calc(ll a, ll c = 0) {
    if (a <= 0 || a % 2 != 0) {
        return c;
    }
    return calc(a / 2, c + 1);
}

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a;
    rep(i, N) {
        ll a_;
        cin >> a_;
        a.pb(a_);
    }
    ll ans = 0;
    rep(i, N) {
        if (a[i] % 2 == 0) {
            ans += calc(a[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int cn,sn,k;
string n;
int main(){
    cin>>n;
    for(int i=0;i<n.length();i++){
            if(i==0)k=n[0]-'0';
        else k=(n[i]-'0')+(k*10);
    }
    for(int i=0;i<n.length();i++){
        sn+=n[i]-'0';
    }

    if(k%sn==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}


Measured memory_bytes: 256
N = int(input())

arg = 1
maxscore = 0
for i in range(2, N+1):
    score = 0
    org = i
    while True:
        m = i % 2
        if m == 0:
            score += 1
            i //= 2
        else:
            if maxscore < score:
                arg = org
                maxscore = score
            break

print(arg)

Measured memory_bytes: 9040
S = input().split(" ")
N = int(S[0])
M = int(S[1])
ARR = []
for i in range(M):
    ARR.append([int(s) for s in input().split(" ")])



def prepare(n, m, arr):
    nodes = [[] for i in range(n)]
    nodeStates = [0 for i in range(n)]
    for i in range(m):
        nodeFrom = arr[i][0] - 1
        nodeTo = arr[i][1] - 1
        nodes[nodeFrom].append(nodeTo)
        nodes[nodeTo].append(nodeFrom)

    return nodes, nodeStates


nodes, nodeStates = prepare(N, M, ARR)


def dfs(currentNodeIndex, arr, nodeStates):
    if nodeStates[currentNodeIndex] == 0:
        nodeStates[currentNodeIndex] = 1

    childNodes = arr[currentNodeIndex]
    for childNodeIndex in childNodes:
        if nodeStates[childNodeIndex] == 0:
            dfs(childNodeIndex, arr, nodeStates)

    return nodeStates


# dfs(0, nodes)


def calculate(n, m, arr):
    arr = list(arr)
    result = 0
    for ar in arr:
        brr = arr.copy()
        brr.remove(ar)
        nodes, nodeStates = prepare(n, m-1, brr)
        nodeStatesResult = dfs(0,nodes,nodeStates)
        if sum(nodeStatesResult) != n:
            result = result + 1
    print(result)


calculate(N,M,ARR)


Measured memory_bytes: 3064
//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h> 

using namespace std;


#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")


pii a[100010];


bool comp(pii a,pii b){
	if(a.f1==b.f1){
		return a.f2>b.f2;
	}
	else{
		return a.f1 < b.f1;
	}
}
int main(){
	ll n,m;
	sfl(n),sfl(m);
	FOR(i,n){
		sfl(a[i].f1),sfl(a[i].f2);
	}

	sort(a+1,a+n+1,comp);

	ll ans=0;
	for(ll i=1;i<=n and m>0;i++){
		ll t=min(m,a[i].f2);
		ans += t*a[i].f1;
		m-=t;
	}	

	pfl(ans);
}



Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        boolean[] prime = new boolean[55_556];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 0; i < prime.length; i++) {
        	if (prime[i]) {
        		for (int j = i+i; j < prime.length; j += i) {
        			prime[j] = false;
        		}
        	}
        }
        
        List<Integer> list = new ArrayList<>();
        for (int i = 6; i < prime.length; i++) {
        	if (prime[i] && i % 5 == 1) {
        		list.add(i);
        	}
        	
        	if (N <= list.size()) {
        		break;
        	}
        }
        
        list.stream().forEach(System.out::println);
    }
}

Measured memory_bytes: 26708
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	X, Y, A, B, C := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	P := sc.nextIntSlice(A)
	Q := sc.nextIntSlice(B)
	R := sc.nextIntSlice(C)
	sort.Sort(sort.Reverse(sort.IntSlice(P)))
	sort.Sort(sort.Reverse(sort.IntSlice(Q)))
	sort.Sort(sort.Reverse(sort.IntSlice(R)))
	arr := []int{}
	for i := 0; i < X; i++ {
		arr = append(arr, P[i])
	}
	//fmt.Fprintln(wtr, "after P", arr)
	for i := 0; i < Y; i++ {
		arr = append(arr, Q[i])
	}
	sort.Ints(arr)
	//fmt.Fprintln(wtr, arr)
	idx := 0
	for i := 0; i < len(arr); i++ {
		if arr[i] < R[idx] {
			arr[i] = R[idx]
			idx++
			if idx == C {
				break
			}
		} else {
			break
		}
	}
	ans := 0
	for i := 0; i < len(arr); i++ {
		ans += arr[i]
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int l, r;
  int sum = 0;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<stack>
#include<climits>
#include<cmath>

using namespace std;

#define int long long
#define MOD (1000000007)
#define MINF (-1*(LLONG_MAX-10))
#define INF (LLONG_MAX-10)

signed main(){
    int a,b;

    cin>>a>>b;

    if(a<b){
        for(int i=0;i<b;i++){
            cout<<a;
        }
    }
    else{
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }
    cout<<endl;
}


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


void solve() {
  long A,B;
  cin >> A >> B;
  if ((A+B) % 2 == 0) {
    std::cout << (A+B)/2 << '\n';
  } else {
    std::cout << "IMPOSSIBLE" << '\n';
  }

}

int main() {
  solve();
  return 0;
}


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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  string s, t;
  cin >> s >> t;

  static int cs[101010], ct[101010];
  cs[0] = ct[0] = 0;
  for (int i = 1; i <= s.size(); i++) {
    cs[i] += cs[i - 1];
    if (s[i - 1] == 'A') {
      cs[i] += 2;
    } else {
      cs[i]++;
    }
    cs[i] %= 3;
  }

  for (int i = 1; i <= t.size(); i++) {
    ct[i] += ct[i - 1];
    if (t[i - 1] == 'A') {
      ct[i] += 2;
    } else {
      ct[i]++;
    }
    ct[i] %= 3;
  }

  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((cs[b] - cs[a - 1] + 3) % 3 == (ct[d] - ct[c - 1] + 3) % 3) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2512
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int R;
	scanf("%d", &R);

	if (R < 1200)printf("ABC\n");
	else if (R < 2800)printf("ARC\n");
	else printf("AGC");

	return 0;
}
 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
 
typedef long long ll;
 
ll ans=0;

void solve(string s, int id, ll sum) {
  if(id == s.size()) {
    ans += sum;
    //return;
  }
 
  for(int i = 1; i+id <= s.size(); i++) {
    solve(s, id+i, sum + stoll(s.substr(id, i)));
  }
}
 
int main() {
  string s;
  cin >> s;

  solve(s, 0, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

set <int> s[26];
int main()
{
	boost;
	int n, q, i;
	cin >> n;
	string ss;
	cin >> ss;
	
	fo(i, 0, n) {
		int x = ss[i] - 'a';
		s[x].insert(i);
	}
	cin >> q;
	while(q--) {
		int t, x, y;
		char c;
		cin >> t;
		if(t == 1) {
			cin >> x >> c;
			--x;
			int v = ss[x] - 'a';
			s[v].erase(x);
			s[c - 'a'].insert(x);
			ss[x] = c;
		}
		else {
			cin >> x >> y;
			--x, --y;
			int ans = 0;
			fo(i, 0, 26) {
				auto it = s[i].lower_bound(x);
				if(it != s[i].end()) {
					if(*it <= y) 
					++ans;
				}
			}
			cout << ans << '\n';
		}
	}
}


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

int main()
{
    string s;
    cin >> s;
    string ans = "Bad";
    if (s[0] != s[1] && s[1] != s[2] && s[2] != s[3])
        ans = "Good";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int i;
		for(i = 1;;++i){
			int x = scan.nextInt();
			if(x == 0)
				break;
			System.out.println("Case "+i+": "+x);
		}
	}
}

Measured memory_bytes: 42252
import math

n, x, y = map(int, input().split(" "))

ans = [0 for _ in range(n)]
for i in range(1, n):
    for j in range(i + 1, n + 1):
        ans[min(j - i, abs(i - x) + abs(j - y) + 1)] += 1

print(*ans[1:])

Measured memory_bytes: 3444
N = int(input())
S = list(input())

ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
    for j in range(i+1,N):
        k = j-i+j
        if k<N and S[k]!=S[i] and S[k]!=S[j] and S[i]!=S[j]:
            ans -= 1

print(ans)

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N, D, X;

int main() {
	cin >> N >> D >> X;
	for (ll n = 0; n < N; n++) {
		ll a;
		cin >> a;
		X += floor((ld)(D - 1) / a) + 1;
	}
	cout << X << endl;
	return 0;
}

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

#define int long long

int max(int a,int b){
    return (a>b?a:b);
}
const int N = 3005;
int dp[N][N];
int n, arr[N];
int32_t main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }
    for(int i = n;i>0;i--){
        for(int j=i;j<=n;j++){
            dp[i][j] = max(arr[i]-dp[i+1][j],arr[j]-dp[i][j-1]);
        }
    }
    cout<<dp[1][n]<<endl;
}

Measured memory_bytes: 49664
import java.util.*;

public class Main{
    static int H,W,A,B;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        H = sc.nextInt();
        W = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        sc.close();

        String str1 = "";
        String str2 = "";
        for(int i = 0; i < A; i++){
            str1 += "1";
            str2 += "0";
        }
        for(int i = 0; i < W-A; i++){
            str1 += "0";
            str2 += "1";
        }
        for(int i = 1; i <= H; i++){
           
            if(i <= B){
                System.out.println(str1);
            } else {
                System.out.println(str2);
            }
        }
        
    }
}

Measured memory_bytes: 31956
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>


using ll =  long long;

#define rep(i,n) for(int i= 0; i< (n); i++)

using namespace std;

int main(){

    int k, s;
    cin >> k >> s;

    int cnt=0;
    for(int x=0; x<=k; ++x){
        for(int y=0; y<=k; ++y){
            int z=s-x-y;
            if(0<=z and z<= k){
                cnt++;
            }
        }
    }


    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop


X, Y, A, B, C = map(int, input().split())

red = list(map(int, input().split()))
green = list(map(int, input().split()))
colorless = list(map(int, input().split()))

red.sort(reverse=True)
green.sort(reverse=True)
colorless.sort(reverse=True)

red = red[:X]
green = green[:Y]
colorless = colorless[:(X + Y)]

heapify(red)
heapify(green)

for m in colorless:
  if m < red[0] and m < green[0]:
    break
  
  if red[0] < green[0]:
    heappop(red)
    heappush(red, m)
  else:
    heappop(green)
    heappush(green, m)
    
print(sum(red) + sum(green))
           

Measured memory_bytes: 110888
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque([])
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.appendleft(list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

Measured memory_bytes: 25412
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

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




    return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;

int head[maxn],cnt,vis[maxn];ll cnt1,cnt2,n,m;

struct edge{
	int to,nxt;
}e[maxn<<1];

void add(int u,int v){
	e[++cnt]=(edge){v,head[u]};
	head[u]=cnt;
}

void dfs(int u,int fa,int col){
	if(!vis[u]) vis[u]=col;
	else {
		if(vis[u]!=col){
			printf("%lld",(n-1)*n/2-m);
			exit(0);
		}
		return ;
	}
	col&1?cnt1++:cnt2++;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,u,(col&1)+1);
	}
}

int main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	dfs(1,0,1);
	printf("%lld",cnt1*cnt2-m);
}

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

pair<int,int> get_mid(string t) {
    int mid_s = t.size();
    int mid_e = 0;

    for (int i = 1, c = 1; i < t.size(); i++) {
        if (t[i] == ')') c--;
        else if (t[i] == '(') c++;
        else if (!c) {
            mid_s = min(mid_s, i);
            mid_e = max(mid_e, i);
        }
    }

    return make_pair(mid_s, mid_e);
}

pair<string,string> get_subtree(string t, int mid_s, int mid_e) {
    string a;
    string b;

    a = string(t.begin() + 1, t.begin() + mid_s -1);
    b = string(t.begin() + mid_e + 2, t.end() - 1);

    return make_pair(a,b);
}

string get_tree(string a, string b) {
    if (a.size() == 0 || b.size() == 0) {
        return "";
    }

    auto ma = get_mid(a);
    auto sta = get_subtree(a, ma.first, ma.second);

    auto mb = get_mid(b);
    auto stb = get_subtree(b, mb.first, mb.second);

    stringstream ss, cc;
    ss << string(a.begin() + ma.first + 1, a.begin() + ma.second)
        + " "
        + string(b.begin() + mb.first + 1, b.begin() + mb.second);

    int A, B;
    ss >> A >> B;
    cc << (A+B);
    string m;
    cc >> m;

    string ret = "(" + get_tree(sta.first, stb.first) + ")["
        + m + "](" + get_tree(sta.second, stb.second) + ")";

    return ret;
}


int main() {
    string a, b;
    cin >> a >> b;

    cout << get_tree(a, b) << endl;

    return 0;
}

Measured memory_bytes: 3484
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {s:String}
    let mut ans = 0;
    for c in s.chars() {
        if c == '1' {
            ans += 1
        }
    }
    println! {"{}",ans};
}


Measured memory_bytes: 4352
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N, K;  cin >> N >> K;

    int ans = N - K + 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1000000007;
// const int MAXN = 3e5;
const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("mxnl.in", "r", stdin);
       // freopen("mxnl.out", "w", stdout);
#endif
}


void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b && b!=c){
        cout << "Yes" << endl;
    } else if(a==c && b!=c){
        cout << "Yes" << endl;
    } else if(b==c && a!=b){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
    int n;  cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    int cnt = 0;
    int now = 0;
    for (int i = 0; i <= n; i++){
        if (now == 1){
            cout << cnt << endl;
            break;
        }
        if (cnt == n){
            cout << "-1" << endl;
            break;
        }
        cnt++;
        now = a[now] - 1;
    }
    return 0;
}


Measured memory_bytes: 640
X = int(input())

quint = [0] * 1001

for i in range(1, 1001):
  quint[i] = i ** 5
  
for i in range(0, 1001):
  a = X - quint[i] 
  b = X + quint[i]
  try:
    c = quint.index(a)
    print("{} {}".format(c, -i))
    break
  except:
    try:
      c = quint.index(b)
      print("{} {}".format(c, i))
      break
    except:
      continue

Measured memory_bytes: 62312
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <bitset>

using namespace std;

const int maxn = 2010;
int n,a[maxn],sum,ans;
bitset<maxn * maxn> B;

int main()
{
    scanf("%d",&n);
    B[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d",&x);
        B |= (B << x);
        sum += x;
    }
    for (int i = (sum + 1) / 2; ; i++)
        if (B[i])
        {
            ans = i;
            break;
        }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vl vector<long long>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define vs vector<string>
#define mx INT_MAX
#define mn INT_MIN
#define all(z) z.begin(),z.end()
#define mcc 1000000007
#define mcf 998244353
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
using namespace std;

//ll maxl(ll a,ll b) {return (a>b)? a:b;}
//ll minl(ll a,ll b) {return (a<b)? a:b;}
//ll gcdl(ll a,ll b) {return b ? gcdl(b,a%b):a;}
//bool sortc(const vi &v1,const vi &v2) {return v1[0]>v2[0];}

void solve()
{
    ll n,sum=0;
    cin>>n; n++;
    while(n--)
    {
        if (n%3!=0 && n%5!=0)
        {
            sum+=n;
        }
    }
    cout<<sum;
}


#if 1
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
#endif

//------------------------Google-------------------
#if 0
int main()
{
    #ifdef __WIN32
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,ct=0;
    cin>>t;
    while(t--)
    {
        cout<<"Case #"<<++ct<<": ";
        solve();
    }
    return 0;
}
#endif


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    string s;
    cin >>s;
    if(s.size() % 2 == 1){
        cout <<"No"<<endl;
        return 0;
    }
    
    bool ans=true;
    int a=n/2;
    for(int i=0;i<a;i++){
        if(s.at(i)!= s.at(a+i)){
        ans=false;
        continue;
        }
    }    
    if(ans)cout << "Yes"<<endl;
    else cout<<"No"<<endl;    
    
}

Measured memory_bytes: 256
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

t = []

for x in range(101):
    for y in range(101):
        H = []
        for i in array:
            if i[2] > 0:
                H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            t.append([x,y,H])

if len(t) >= 2:
    t = []
    for x in range(101):
        for y in range(101):
            H = []
            for i in array:
                if True:
                    H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                    H.append(H_i)
            Hset = set(H)
            H = list(Hset)[0]
            if(len(Hset)==1 and H>=0):
                t.append([x,y,H])
            
print("{0[0]} {0[1]} {0[2]}".format(t[0]))


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

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

	for(int i = 0 ; i< n ; i ++){
		ll x; cin>>x;
		num.push(x);
	}

	for(int i = 0 ; i<m ; i++){
		ll x= num.top()/2;
		num.pop();
		num.push(x);
	}

	

	ll sum=0;
	for(int i = 0 ; i< n ; i ++){
		sum=sum+num.top();
		num.pop();
	}

	cout<<sum;


 	int l ;cin>>l;
 
	
}

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

class Program
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int Row = int.Parse(str[0]);
        int Colum = int.Parse(str[1]);

        int[,] matrix = new int[Row, Colum];

        for (int i = 0; i < Row; i++)
        {
            string[] str2 = Console.ReadLine().Split(' ');

            for (int j = 0; j < Colum; j++)
            {
                matrix[i, j] = int.Parse(str2[j]);
            }

        }

        int[] SumRow = new int[Row];
        int[] SumColum = new int[Colum];
        int Sum = 0;

        for (int i = 0; i < Row; i++)
        {
            for (int j = 0; j < Colum; j++)
            {
                SumRow[i] += matrix[i, j];
                SumColum[j] += matrix[i, j];
                Sum += matrix[i, j];

            }
        }

        int[,] Answer = new int[Row + 1, Colum + 1];

        for (int i = 0; i < Row; i++)
        {
            for (int j = 0; j < Colum; j++)
            {
                Answer[i, j] = matrix[i, j];
            }
        }

        Answer[Row, Colum] = Sum;

        for (int i = 0; i < Row; i++)
        {
            Answer[i, Colum] = SumRow[i];
        }

        for (int i = 0; i < Colum; i++)
        {
            Answer[Row, i] = SumColum[i];
        }

        for (int i = 0; i < Answer.GetLength(0); i++)
        {
            for (int j = 0; j < Answer.GetLength(1); j++)
            {
                if (j == 0)
                    Console.Write("{0}", Answer[i, j]);
                else
                    Console.Write(" {0}", Answer[i, j]);
            }
            Console.WriteLine();
        }
    }



   
}

Measured memory_bytes: 9352
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    A = [0] * M
    C = [0] * M
    for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = sum(1 << (int(s) - 1) for s in readline().split())

    dp = [[INF] * (1 << N) for _ in range(M + 1)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1 << N):
            if dp[i + 1][j] > dp[i][j]:
                dp[i + 1][j] = dp[i][j]
            if dp[i + 1][j | C[i]] > dp[i][j] + A[i]:
                dp[i + 1][j | C[i]] = dp[i][j] + A[i]

    ans = dp[M][(1 << N) - 1]
    if ans < INF:
        print(ans)
    else:
        print(-1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 94200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    int n, c; ll k;
    cin>>n>>c>>k;
    ll t[100001];
    for(int i=0; i<n; i++){
        cin>>t[i];
    }
    sort(t, t+n);
    int ans=0;
    int i=0;
    while(i<n){
        int j=i;
        while(j<min(n, i+c) && t[j]<=t[i]+k){
            j++;
        }
        i=j;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
bool comp(pii a,pii b){
    if(a.first<b.first)return true;
    else if(a.first==b.first)return a.second<b.second;
    else return false;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,w,i,j;
    cin>>n>>w;
    vector <pii> v(n+1);
    v[0].first=0;
    v[0].second=0;
    for(i=1;i<n+1;i++)cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end(),comp);
    vector <vi> dp(n+1,vi(w+1,0));
    for(i=1;i<=n;i++){
        for(j=0;j<=w;j++){
            if(j>=v[i].first){
                dp[i][j]=max(dp[i-1][j-v[i].first]+v[i].second,dp[i-1][j]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w];
    return 0;
}


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

int main(){
	int n;

	cin >> n ;
	int f[6] = {};
	for(int i=0 ; i<n ; ++i ){
		double a;
		cin >> a;
		if( a < 165.0 )
			f[0]++;
		else if( a < 170.0 )
			f[1]++;
		else if( a < 175.0 )
			f[2]++;
		else if( a < 180.0 )
			f[3]++;
		else if( a < 185.0 )
			f[4]++;
		else
			f[5]++;
	}
	for(int i=0 ; i<6 ; ++i ){
		cout << i+1 << ":";
		for(int j=0 ; j<f[i] ; ++j){
			cout << "*";
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int f(int);
int main(){
  int E,O,sum = 0;
  cin >> E >> O;

  sum += f(E);
  sum += f(O);
  cout << sum << endl;
}	

int f(int num){
	int sum = 0;
  	for(int i = 1;i < num;i++ ){
    	sum+= i;
    }
  return sum;
}

Measured memory_bytes: 256
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
ans = 'Yes'
t_diff = 0
x_diff = 0
y_diff = 0
for i in p:
  t_diff = i[0] - t_diff
  x_diff = abs(i[1] - x_diff)
  y_diff = abs(i[2] - y_diff)
  if t_diff >= x_diff + y_diff:
    if (t_diff - x_diff - y_diff)%2 != 0:
      ans = 'No'
      break
  else:
    ans = 'No'
    break
print(ans)

Measured memory_bytes: 27056
import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N = int(input())
    h = list(map(int, input().split()))
    #h = [int(x) for x in input().split()]
    inf = float("inf")
    dp = [inf]*(N)

    #2:初期値
    dp[0] = 0

    #3:dp実行部(貰うDP)
    for i in range(1,N):
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
        if(i>1): #2つ目の足場には二個前の足場がないので．
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

    # #3:dp実行部(配るDP)
    # for i in range(N):
    #     if(i+1<N):
    #         dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]))
    #     if(i+2<N):
    #         dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]))

    #4:出力
    print(dp[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 13592
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

 
int vector_finder(std::vector<int> vec, int number) {
  size_t index = std::distance( vec.begin(), std::find(vec.begin(), vec.end(), number) );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int vector_finder(std::vector<string> vec, string number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

int N,K;
ll ans = 0;

void counter(int n){
	while(1){
		if(n%2==0){
			n /= 2;
			ans++;
		}
		else{
			break;
		}
	}
}

int main()
{
	string s;
	vector<string> S;
	int K;
	cin >> s >> K;

	REP(i,K){
		REP(j,s.size()-i){
			string ss = s.substr(j,i+1);
			if(!vector_finder(S,ss)){
			S.push_back(ss);
			}
		}
	}
	sort(S.begin(), S.end());



	cout << S[K-1]<< endl;

	return 0;
}

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

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	tx -= sx;
	ty -= sy;
	if(tx == 0){
		for(auto i = 0; i < ty; ++i){
			cout << 'U';
		}
		cout << 'R';
		for(auto i = 0; i < ty; ++i){
			cout << 'D';
		}
		cout << "LL";
		for(auto i = 0; i < ty; ++i){
			cout << 'U';
		}
		cout << "RURR";
		for(auto i = 0; i < ty + 2; ++i){
			cout << 'D';
		}
		cout << "LLU" << endl;
	}else if(ty == 0){
		for(auto i = 0; i < tx; ++i){
			cout << 'R';
		}
		cout << 'D';
		for(auto i = 0; i < tx; ++i){
			cout << 'L';
		}
		cout << "UU";
		for(auto i = 0; i < tx; ++i){
			cout << 'R';
		}
		cout << "DRDD";
		for(auto i = 0; i < tx + 2; ++i){
			cout << 'L';
		}
		cout << "UUR" << endl;
	}else{
		for(auto i = 0; i < ty; ++i){
			cout << 'U';
		}
		for(auto i = 0; i < tx; ++i){
			cout << 'R';
		}
		for(auto i = 0; i < ty; ++i){
			cout << 'D';
		}
		for(auto i = 0; i < tx; ++i){
			cout << 'L';
		}
		cout << 'L';
		for(auto i = 0; i < ty + 1; ++i){
			cout << 'U';
		}
		for(auto i = 0; i < tx + 1; ++i){
			cout << 'R';
		}
		cout << "DR";
		for(auto i = 0; i < ty + 1; ++i){
			cout << 'D';
		}
		for(auto i = 0; i < tx + 1; ++i){
			cout << 'L';
		}
		cout << 'U' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(){
	long long a;scanf("%lld",&a);
	long long ret=0;
	for(int i=1;i<=1000000;i++){
		if(a%i==a/i)ret+=i;
	}
	for(int i=1;i<=1000000;i++){
		if((a-i)%i==0){
			long long t=(a-i)/i;
			if(t>1000000)ret+=t;
		}
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 128
n,m=map(int,input().split())
s=list(input())
s=list(map(int,s))

i=n
ans=[]
while i>0:
    if i<=m:
        ans.append(i)
        break
    j=m
    while True:
        if j==0:
            print(-1)
            exit()
        if s[i-j]:
            j-=1
        else:
            ans.append(j)
            i-=j
            break


ans.reverse()
print(*ans)


Measured memory_bytes: 56056
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdio>

using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); ++i)
#define rep(i,n) REP(i,0,n)

vector<int> g[1010];
int n, m;
 
vector<bool> visited, matched;
vector<int> levels, matching;
 
bool augment(int left) {
  if(left == n) return true;
  if(visited[left]) return false;
  visited[left] = true;
  rep(i, g[left].size()) {
    int right = g[left][i];
    int next = matching[right];
    if (levels[next] > levels[left] && augment(next)) {
      matching[right] = left;
      return true;
    }
  }
  return false;
}
 
int bimatch() {
  matching.assign(m, n);
  matched.assign(n, false);
  int ret = 0;
  bool cont;
  do {
    levels.assign(n+1, -1);
    levels[n] = n;
    queue<int> q;
    rep(left, n) if (!matched[left]) {
      q.push(left);
      levels[left] = 0;
    }
    while(!q.empty()) {
      int left = q.front();
      q.pop();
      rep(i, g[left].size()) {
        int right = g[left][i];
        int next = matching[right];
        if (levels[next] < 0) {
          levels[next] = levels[left] + 1;
          q.push(next);
        }
      }
    }
    visited.assign(n, false);
    cont = false;
    rep(left, n) if(!matched[left] && augment(left)){
      matched[left] = cont = true;
      ret++;
    }
  } while(cont);

  return ret;
}

int blue[510],red[510];

int main(){
  while(scanf("%d%d",&n,&m),n|m){
    //init
    rep(i,n+m)g[i].clear();
    //visited.clear();
    //matched.clear();
    //levels.clear();
    //matching.clear();
    
    
    
    rep(i,n)scanf("%d",blue+i);
    //rep(i,m)scanf("%d",red+i);
    rep(i,m){
      int a; scanf("%d",&a);
      rep(j,n)if( __gcd(blue[j],a)!=1 ){
        g[j].push_back(n+i);
        g[n+i].push_back(j);
      }
    }
    /*
    rep(i,n){
      rep(j,m)if( __gcd(blue[i],red[j])!=1 ){
        g[i].push_back(n+j);
        g[n+j].push_back(i);
      }
    }
      */
    m += n;
    printf("%d\n",bimatch());
  }
  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF = 1LL << 60;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];

    vector<vector<long long>> dp(N + 1, vector<long long>(H + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[i + 1][j], dp[i][j]);
            if (j >= A[i]) {
                chmin(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
            } else {
                chmin(dp[i + 1][j], dp[i + 1][0] + B[i]);
            }
        }
    }
    cout << dp[N][H] << endl;
}


Measured memory_bytes: 78592
#include<iostream>
int main(){
    int n,k,x,y;
    std::cin >> n >> k >> x >> y;
    int ret = 0;
    for(int i = 0;i<k&&i<n;i++){
        ret += x;
    }
    for(int i = k+1;i<=n;i++){
        ret += y;
    }
    std::cout << ret << std::endl;
    return 0;
}

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

/**
 * https://abc053.contest.atcoder.jp/tasks/arc068_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] card = new int[100001];
		for(int i=0; i<N; i++){
			card[sc.nextInt()]++;
		}
		sc.close();
		
		int remove = 0;
		for(int c:card){
			if(c>=2) remove += c-1;
		}
		if(remove%2==1) remove++;
		
		/*
		int num=0;
		int remove=0;
		int l=1;
		int r=100000;
		while(l<=r){
			while(card[l]<2){
				num+=card[l];
				l++;
			}
			while(card[r]<2){
				num+=card[r];
				r--;
			}
			System.out.println("========");
			System.out.println(l+":"+r);
			if(card[l]+card[r]+num+remove==N){
				remove+=(card[l]-1)*2;
				num = num -(card[l]-1);
				card[l]=1;
				l++;
				if(card[r]>=2){
					remove+=(card[r]-1)*2;
					num = num -(card[r]-1);
					card[r]=1;
					r--;
				}
			}else{
				if(card[l]>card[r]){
					remove+=(card[r]-1)*2;
					card[l]=card[l]-card[r]+1;
					num++;
					r--;
				}else{
					remove+=(card[l]-1)*2;
					card[r]=card[r]-card[l]+1;
					num++;
					l++;
				}
			}
			System.out.println(remove);
		}*/
		
		System.out.println(N-remove);

	}

}

Measured memory_bytes: 49176
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), m = next();
  var g = xArray("[]",n);
  for(var i = 0; i < m; i++){
    var a = next()-1, b = next()-1;
    g[a].push(b);
    g[b].push(a);
  }
  var q = next();
  var r = nextm(q,3);
  var dp = xArray(-1,11,n);
  for(var i = q; i--;){
    var x = [r[i][0]-1,r[i][1]],id=0;
    while(x.length > id){
      var v = x[id], d = x[id+1];
      id += 2;
      if(dp[d][v] >= i)continue;
      for(var j = d; j >= 0; j--){
        if(dp[j][v] < i)dp[j][v] = i;
      }
      if(d-- === 0)continue;
      for(var j = 0; j < g[v].length; j++){
        var V = g[v][j];
        if(dp[d][V] < i)x.push(V,d);
      }
    }
  }
  var ans = Array(n);
  for(var i = 0; i < n; i++)ans[i] = dp[0][i] < 0 ? 0 : r[dp[0][i]][2];
  return ans.join("\n");
}

Measured memory_bytes: 122024
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
const long long maxn = 1e8;
long long n;
long long k;
long long q;
long long score[maxn],num;
int main(void)
{
	scanf("%ld %ld %ld",&n,&k,&q);
	int i,j;
	for(i = 1;i<=n;i++) score[i] = k - q;
	for(i = 1;i<=q;i++)
	{ 
		scanf("%d",&num);
		score[num]++; 
	} 
	for(i = 1;i<=n;i++){
		if(score[i] <= 0) printf("No\n");
		else printf("Yes\n");
	}
	return 0;
} 

Measured memory_bytes: 1408