akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n;
  cin >> n;
  vector<pair<int, int>> vp;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    vp.emplace_back(a, i + 1);
  }
  sort(ALL(vp));
  set<int> st, st2;
  st.insert(0);
  st.insert(n + 1);

  st2.insert(0);
  st2.insert(-1 * (n + 1));
  int res = 0;
  for (int i = 0; i < n; i++)
  {
    int pos = vp[i].second;
    int l = *st2.upper_bound(-1 * pos) * (-1);
    int r = *st.upper_bound(pos);
    int x = r - l - 1;
    int num = (pos - l) * (r - pos);
    res += vp[i].first * num;
    st.insert(pos);
    st2.insert(pos * -1);
    // DEBUG(l, r, pos, res, "\n");
  }
  cout << res << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

vector<int>v;

int main() {
	int n, m;
	cin >> n >> m;
	int atari = 0;
	int cost = 0;
	for (int i = 0;i < m;i++) {
		int a, b;
		cin >> a >> b;
		if (a >= b) { atari++; }
		else { v.push_back((b - a) / 2); }
	}
	sort(v.begin(), v.end());
	if (atari < m - 1) {
		for (int i = 0;i < m - 1 - atari;i++) {
			cost += v[i];
		}
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();	// Buffer clear
		String S = sc.nextLine();
		sc.close();
		
		boolean flag = false;
		for(int i = 0;i < N;++i)
			if(S.charAt(2*i) == 'Y')
				flag = true;
		if(flag)
			System.out.println("Four");
		else
			System.out.println("Three");
	}
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {
	var H, W, K int
	fmt.Scanf("%d %d %d", &H, &W, &K)

	var total int
	hCounts := make([]int, H)
	wCounts := make([]int, W)
	bord := make([][]int, H)
	for i := 0; i < H; i++ {
		var s string
		fmt.Scanf("%s", &s)
		line := strings.Split(s, "")

		bord[i] = make([]int, W)
		for k, v := range line {
			if v == "#" {
				total++
				hCounts[i]++
				wCounts[k]++
				bord[i][k] = 1
			}
		}
	}
	var ret int
	hKeys := Powerset2(H)
	wKeys := Powerset2(W)

	for _, hk := range hKeys {
		for _, wk := range wKeys {
			v := exec(total, hCounts, wCounts, bord, hk, wk)
			if v == K {
				ret++
			}
		}
	}
	fmt.Println(ret)
}

func exec(total int, hCounts []int, wCounts []int, bord [][]int, hk []int, wk []int) int {
	ret := total
	for k, v := range hk {
		if v == 1 {
			ret -= hCounts[k]
		}
	}
	for k, v := range wk {
		if v == 1 {
			ret -= wCounts[k]
		}
	}

	for hk, hv := range hk {
		for wk, wv := range wk {
			if hv == 1 && wv == 1 && bord[hk][wk] == 1 {
				ret++
			}
		}
	}

	return ret
}

func Powerset2(num int) [][]int {
	length := int(math.Pow(2, float64(num)))
	result := make([][]int, length)

	index := 0
	result[index] = []int{0}
	index++

	result[index] = []int{1}
	index++

	for n := 1; n < num; n++ {
		tmp := index
		for i := 0; i < tmp; i++ {
			result[index] = copyAndAppend(result[i], 1)
			index++
		}

		for i := 0; i < tmp; i++ {
			result[i] = copyAndAppend(result[i], 0)
		}

	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func getKeys(size int) [][]int {
	ret := make([][]int, 0, 0)

	if size == 1 {
		ret = append(ret, []int{0})
		ret = append(ret, []int{1})
		return ret
	}

	childs := make([][]int, 0, 0)
	childs = getKeys(size - 1)
	ret = append(ret, add(childs, 0)...)
	fmt.Println("ch")
	fmt.Println(ret)

	ret = append(ret, add(childs, 1)...)
	fmt.Println("cp")
	fmt.Println(ret)
	return ret
}

func add(a [][]int, n int) [][]int {
	var ret [][]int
	for _, v := range a {
		v = append(v, n)
		ret = append(ret, v)
	}
	return ret
}


Measured memory_bytes: 1852
import java.util.*;

public class Main {
    //-------------------------------------------------------------//
    public static final void main(String[] args) {
        new Main().solve();
    }
    //-------------------------------------------------------------//
    private final Scanner sc = new Scanner(System.in);

    void solve() {
        int n = Integer.parseInt(sc.next() + sc.next() + sc.next());
        if (n % 4 == 0) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 22996
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;

	if(N == 1) {
		cout << "Hello World" << endl;
	}
	else if(N == 2) {
		int a, b;
		cin >> a >> b;

		cout << (a + b) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/*
2020-04-25
atcoder ABC
D: Handstand 2
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N, ans;
    cin >> N;
    vector<vector<int>> data(10, vector<int>(10));
    for(int i = 1; i < N + 1; i++) {
        int k = i;
        int lastDigit = i % 10;
        while(k / 10 > 0) {
            k /= 10;
        }
        int firstDigit = k;
        data[firstDigit][lastDigit] += 1;
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++) {
            ans += (data[i][j] * data[j][i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[31],flg[31],i;
	for(i=0;i<28;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=30;i++){
		flg[i]=0;
	}
	for(i=0;i<28;i++){
		flg[a[i]]=1;
	}
	for(i=1;i<=30;i++){
		if(flg[i]==0){
			printf("%d\n",i);
		}
	}
	return 0;
}

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

int main() {
	int d;
	cin >> d;
	switch (d) {
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;
	case 24:
		cout << "Christmas Eve" << endl;
		break;
	case 25:
		cout << "Christmas" << endl;
		break;
	}
}

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

bool prime(int n) {
	for (int i = 2; i < n; i++)if (n % i == 0)return false;
	return true;
}

int main() {
	int x;
	cin >> x;
	for (int i = x; true; i++) {
		if (prime(i)) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, C, D, E, M, N, K, Q, W, H, T, X, Y;

int main()
{
    string str;
    cin >> str;

    if (str[0] == str[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool sosuu(int n)
{
    int i = n - 1;
    while (i > 1)
    {
        if (n % i == 0)
            return false;
        i--;
    }
    return true;
}

int divide(int i, int k)
{
    int ans = 0;
    if (i <= 1)
        return ans;

    while (k % i == 0)
    {
        ans++;
        k = k / i;
    }
    return ans;
}

void calc(int N)
{
    int map[101] = {};

    for (int i = 1; i <= N; i++)
    {
        for (int j = 2; j <= i; j++)
        {
            if (sosuu(j) == true)
                map[j] += divide(j, i);
        }
    }

    int ans3 = 0, ans5 = 0, ans15 = 0, ans25 = 0, ans75 = 0;
    for (int i = 1; i <= N; i++)
    {
        if (map[i] >= 2)
            ans3++;
        if (map[i] >= 4)
            ans5++;
        if (map[i] >= 14)
            ans15++;
        if (map[i] >= 24)
            ans25++;
        if (map[i] >= 74)
            ans75++;
    }
    cout << ans75 + ans15 * (ans5 - 1) + ans5 * (ans5 - 1) * (ans3 - 2) / 2 + ans25 * (ans3 - 1) << endl;
}

int main()
{
    int N;
    cin >> N;

    calc(N);
}

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

int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if(x==0&&y==0)break;
        if(x>y){
            cout<<y << " " << x << endl;
        }
        else{
            cout << x << " " << y << endl;
            
        }
    }return 0;
}


Measured memory_bytes: 3068
N = int(input())
a = list(map(int, input().split()))

seta = set(a)
if len(seta) == 1:
    if a[0] in (0, N-1) or a[0] <= N // 2:
        print("Yes")
    else:
        print("No")
elif len(seta) == 2:
    a1 = min(seta)
    a2 = max(seta)
    counta1 = a.count(a1)
    if a2 != a1 + 1:
        print("No")
    elif counta1 < a2 and counta1 + 2 * (a2 - counta1) <= N:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 14204
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char T[1000],P[1000];
    scanf("%s %s",T,P);
    //printf("%s ,%s\n\n",T,P);
    int Tlen = strlen(T),Plen = strlen(P),iC;
    //printf("check 1,Tlen=%d,Plen=%d\n",Tlen,Plen);
    for(int i=0;i<=Tlen-Plen;i++)
    {
        //printf("check count=%d\n",i);
        if(T[i] == P[0])
        {
            iC = i;
            for(int m=0;m<Plen;m++)
            {
                if(T[iC] != P[m]) break;
                if(m == Plen-1)
                {
                    printf("%d\n",i);
                    break;
                }
                iC += 1;
            }
        }
    }
}


Measured memory_bytes: 2104
#include <stdio.h>
int main(void){
    
    int H,W,i,j;
    
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0) break;
        
        for(j=1;j<=H;j++){
            for(i=1;i<=W;i++){
                if(j%2!=0){
                    if(i%2!=0) printf("#");
                    else if(i%2==0) printf(".");
                }
                else{
                    if(i%2==0) printf("#");
                    else printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a , b , c , d  ;
      cin >> a >> b >> c >> d ;
      
      if (a + b > c + d){
          cout <<"Left"<< endl;
      }
      else if (a + b < c + d){
          cout <<"Right"<< endl;
      }
      else {
          cout << "Balanced" << endl;
      }
    }

Measured memory_bytes: 256
import math as m
[A, B, H, M] = list(map(int, input().split()))
H_d = H * 30 + 0.5 * M 
M_d = M * 6

C = abs(H_d - M_d)
if C >= 180:
  C = 360 - C
cosC = m.cos(m.radians(C))

answer = (A ** 2 + B ** 2 - 2 * A * B * cosC) ** 0.5
print(answer)


Measured memory_bytes: 9436
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

char tmap[12][12];
int c;

void Terrain(int i,int l){

	if (tmap[i][l] == '0'||i < 0 || i > 11 || l < 0 || l > 11) return;

	tmap[i][l] = '0';

	Terrain(i + 1, l);
	Terrain(i - 1, l);
	Terrain(i, l + 1);
	Terrain(i, l - 1);

	return;

}
int main(){
	int cunt = 0;
	while (cin >> tmap[0]){
		for (int i = 1; i < 12; i++) cin >> tmap[i];
		for (int i = 0; i < 12; i++){
			for (int l = 0; l < 12; l++){
				if (tmap[i][l] == '1'){
					Terrain(i, l);
					cunt++;
				}
			}
		}
		cout << cunt << endl;
		cunt = 0;
	}
	return 0;
}

Measured memory_bytes: 1144
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *
from functools import reduce,partial
from time import time
from pprint import pprint

def readln():
    return list(map(int,input().split(' ')))

def identity(x):
    """Return the input itself."""
    return x

def constant(c):
    """Return an function which always
    returns the input constant c."""
    def const_function(const,*args):
        return const
    return partial(const_function,c)

def inc(c = 1):
    """Return a function which reads an input x and returns x + c as output.
    By default, c equals 1."""
    return lambda x: x + c

def add(*args):
    """Return the sum of the input."""
    def add2(x,y): return x + y
    return reduce(add2,args)

def mapv(f,*lst):
    """Return a vector of the result of map."""
    return list(map(f,*lst))

def vector(*args):
    """Return a vector of input parameters."""
    return args

def sequence(n,f = constant(0)):
    """Return a vector of length n, and initialize the i'th
    item with f(i).By default the vector will initialized with 0."""
    return [f(i) for i in range(0,n)]

def matrix(n,m,f = constant(0)):
    """Return a 2-dim vector which contains n vectors with length m.
    The j's item of vector i will be initialized by f(i,j).By default,
    the vector will be initialized with 0."""
    return [[f(i,j) for j in range(0,m)] for i in range(0,n)]

def flat(v):
    """Return a flat vector which contains the elements of v in their
    origin order.If the input is not a vector, return a vector which
    only contains the input."""
    if not isinstance(v,list): return [v]
    if not v: return []
    return reduce(add,mapv(flat,v))

def partition(v,f = identity):
    """Partition vector v by f(v[i]).
    e.g. partition([1,2,3,1,2,3],identity()) == {1:[1,1,1], 2:[2,2], 3:[3]}
    By default, the vector will be partitioned by identity function."""
    result = {}
    for item in v:
        key = f(item)
        s = result.get(key)
        if s:
            s.append(item)
        else:
            result.update({key:[item]})
    return result

def getValue(key):
    """Return a function which returns the value of key in a hash-map.
    If the key do not exist, it will throw an error."""
    return lambda x: x[key]

def mapValue(f,m):
    """Replace each value in hash-map m with f(value).
    Return the new hash-map."""
    res = {}
    for key in m:
        res.update({key: f(m[key])})
    return res

p = 1000000000 + 7

def existOdd(a):
    for item in a:
        if item % 2 == 1:
            return True
    return False

def calc(a):
    ans = 0
    if existOdd(a): return 0
    if a[0] == a[1] and a[1] == a[2]:
        return -1
    while True:
        s = sum(a) >> 1
        b = [s - (item >> 1) for item in a]
        ans = ans + 1
        if existOdd(b):
            break
        else:
            a = b[:]
    return ans

a = readln()
print(calc(a))


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    if(a[x] == a[y]) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  int k;
  cin >> k;
  if (b - a + 1 <= 2 * k) {
    for (int i = a; i <= b; i++) {
      cout << i << endl;
    }
  } else {
    for (int i = a; i < a + k; i++) {
      cout << i << endl;
    }
    for (int i = b - k + 1; i <= b; i++) {
      cout << i << endl;
    }
  }
  return 0;
}


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

int main(){
    int n,cnt=0;
    cin >> n;
    string f;
    string s[n];
    map<string,bool> dict;
    REP(i,n){
        cin >> f;
        if(dict[f]==false){
            cnt++;
            dict[f] = true;
        }
    }
    cout << cnt << endl;
}

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

int main(){

int a,b;
cin>>a>>b;
vector<int> v;
v.push_back(a+b);
v.push_back(a-b);
v.push_back(a*b);

cout<<*max_element(v.begin(),v.end())<<endl;

}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    root = 1
    if A[0] == 1:
        if N == 0:
            print(1)
        else:
            print(-1)
        return
    B = A[::-1]
    low = high = B[0]
    # Low = []
    Hight = [high]
    
    for b in B[1:]:
        low = max(1, (low+1)//2) + b
        high = high + b
        Hight.append(high)
    if low > 1:
        print(-1)
        return
    ans = 1
    now = 1
    BHight = Hight[::-1]
    for i in range(1,N+1):
        h = BHight[i]
        leaf = A[i]
        # print("h",h)
        now = min(h, now*2)
        ans += now
        now -= leaf
        # print(now)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 20436
#include <stdio.h>
#include <string.h>

int main(void)
{
  int n, i, c;
  char s[100000];

  scanf("%s",s);
  n = strlen(s);

  c=0;
  for(i=1;i<n;i++) {
        if(s[i]==s[i-1]) {
                        if(s[i-1]=='0')  s[i]='1';
                        else if(s[i-1]=='1')  s[i]='0';
                        c++;
                        }
        }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<int>TopologicalSort(int n, vector<int>in, vector<int>e[]) {
	stack<int>st;
	for (int i = 0; i < n; i++)if (!in[i])st.push(i);
	vector<int>ret;
	while (st.size()) {
		int i = st.top();
		st.pop();
		ret.pb(i);
		fore(x, e[i]) {
			in[x]--;
			if (!in[x])st.push(x);
		}
	}
	return ret;
}

int dp[505050];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;
	vector<int>edge[505050];
	map<pair<int, int>, int>mp;
	int num = 0;
	for (int i = 0; i < N; i++)for (int j = i+1; j < N; j++) {
		mp[{i,j}] = num;
		num++;
	}
	
	vector<int>in(mp.size());
	for (int i = 0; i < N; i++){
		int pre;
		for (int j = 0; j < N - 1; j++) {
			if (j == 0) {
				cin >> pre;
				pre--;
			}
			else {
				int temp;
				cin >> temp;
				temp--;
				edge[mp[{min(i,pre),max(i,pre)}]].pb(mp[{min(i, temp), max(i, temp)}]);
				in[mp[{min(i,temp), max(i,temp)}]]++;
				pre = temp;
			}
		}
	}
	vector<int>ord = TopologicalSort(mp.size(),in,edge);
	if (ord.size() != mp.size()) {
		puts(-1);
		return 0;
	}

	int ans = 0;
	for (int i = 0; i < mp.size() - 1; i++) {
		int cur = ord[i];
		fore(to, edge[cur]) {
			dp[to] = max(dp[to], dp[cur] + 1);
			ans = max(ans, dp[to]);
		}
	}
	puts(ans+1);

	return 0;
}



Measured memory_bytes: 66036
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
const int maxn = 1e5 + 5;
ll n, m;
ll w[maxn], v[maxn];
ll dp[105][maxn];

int main () {
    scanl2(n, m);
    FORN(i, 1, n) scanl2(w[i], v[i]);
    FORN(i, 0, n) FORN(j, 0, maxn - 1) dp[i][j] = 1e15;
    dp[0][0] = 0;
    ll ans = 0;
    FORN(i, 1, n) {
        FORN(j, 0, maxn - 1) {
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if ( j >= v[i] ) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            if ( dp[i][j] <= m ) ans = max(ans, (ll) j);
        }
    }
    printl1(ans);
}



Measured memory_bytes: 82728
#include <algorithm>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int64_t N, X;
  cin >> N >> X;

  vector<int64_t> lengths(N);
  vector<int64_t> cnts(N);
  lengths[0] = 1; cnts[0] = 1;
  for (int64_t n = 1; n < N; ++n) {
    lengths[n] = lengths[n-1] * 2 + 3;
    cnts[n] = cnts[n-1] * 2 + 1;
  }

  int64_t res = 0;
  for (int n = N-1; n >= 0; --n) {
    --X;  // B on back
    if (X >= lengths[n] * 2 + 1) {
      res += cnts[n] * 2 + 1;
      break;
    } else if (X >= lengths[n]) {
      res += cnts[n];
      X -= lengths[n];
      if (X > 0) {
        ++res; --X;
      }
    }
    if (X == 0) break;
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3608
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

int arr[100001];
int main() {
	cin >> N >> M;
	rep(i, N) cin >> arr[i + 1];
	UnionFind tree(N + 1);
	rep(i, M) {
		cin >> A >> B;
		tree.merge(A, B);
	}
	int _count = 0;
	rep(i, N) {
		if (tree.issame(i + 1, arr[i + 1])) _count++;
	}
	cout << _count;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



int N;
int P[20202], A[20202], B[20202];
int r[20202];
//-----------------------------------------------------------------
int main() {
	cin >> N;
	rep(i, 0, N) scanf("%d", &P[i]);

	rep(i, 0, N) r[P[i]] = i + 1;
	rep(i, 0, N) A[i] = 30000 * (i + 1);
	rep(i, 0, N) B[i] = 30000 * (N - i + 1) + r[i + 1];

	rep(i, 0, N) printf("%d ", A[i]);
	printf("\n");

	rep(i, 0, N) printf("%d ", B[i]);
	printf("\n");
}

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

int main()
{
    int n;
    scanf("%i", &n);
    unsigned long long res;
    int cnt = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j < n; j++){
            res = i * j;
            if(res >= n) break;
            int rem = n - res;
            if(rem <= n) cnt++;
            else break;
        }
    }

    printf("%i\n",cnt);

    return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  cout << (n+max(h,w)-1)/max(h,w) << endl;
  return 0;
  
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

struct RollingHash{
    static const ull base = 1000000007;
    vector<ull> hash, power;

    RollingHash(const string &s){
        int n = (int)s.size();
        hash.assign(n+1, 0);
        power.assign(n+1, 1);
        for(int i = 0; i < n; i++){
            hash[i+1] = hash[i]*base + s[i];
            power[i+1] = power[i]*base;
        }
    }

    // l, r は 1-originであることに注意
    ull get(int l, int r){
        return hash[r] - hash[l] * power[r-l];
    }
};

int main(){
    int n;
    string s;
    cin >> n >> s;

    RollingHash rh(s);
    auto f = [&](int x)->bool{
        map<ull,vector<int>> m;
        for(int i = 0; i+x <= n; i++){
            ull p = rh.get(i, i+x);
            if(m[p].empty())    m[p].push_back(i);
            else if(i-m[p].front() >= x)    return true;
        }
        return false;
    };

    int l = 0, r = n;
    while(r-l > 1){
        int mid = (l+r)/2;
        if(f(mid))  l = mid;
        else        r = mid;
    }

    cout << l << endl;

    return 0;
}

Measured memory_bytes: 896
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
B.append(0)
ans = 0
num = 0
for i in range(n+1):
  if num != 0:
    if A[i] - num <= 0:
      num = B[i]
      ans += A[i]
    else:
      a = A[i]
      b = num
      A[i] -= num
      num = 0
      if A[i] >= B[i]:
        num = 0
        ans += (B[i]+b)
      else:
        num = B[i]-A[i]
        ans += a
  else:
    if A[i] >= B[i]:
      num = 0
      ans += B[i]
    else:
      num = B[i]-A[i]
      ans += A[i]
print(ans)

Measured memory_bytes: 19004
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N,H;
  cin >> N >> H;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i,N) cin >> A[i] >> B[i];
  sort(rall(A));
  sort(rall(B));
  vector<ll> thd(N+1);thd[0]=0;
  ll tmpsum = 0;
  for(int i=1;i<=N;i++){
    tmpsum += B[i-1];
    thd[i] = tmpsum;
  }
  ll max_sw = A[0];
  ll ans = 1e18;
  for(int th=0;th<=N;th++){
    ll preans = th;
    ll h = H - thd[th];
    if(h>0){
      preans += h/max_sw;
      if(h%max_sw!=0) preans++;
    }
    ans = min(ans,preans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

#include <initializer_list>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

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

    int ret = INF;
    for (int x = 1; x <= W - 1; x++) {
        int a = x * H;

        if ((W - x) % 2 == 0) {
            int b = ((W - x) / 2) * H;
            ret = min(ret, abs(a - b));
        } else if (H % 2 == 0) {
            int b = (H / 2) * (W - x);
            ret = min(ret, abs(a - b));
        } else {
            int b, c;
            if (H > W - x) {
                b = (H / 2) * (W - x);
                c = ((H / 2) + 1) * (W - x);
            } else {
                b = ((W - x) / 2) * H;
                c = ((W - x) / 2 + 1) * H;
            }
            ret = min(ret, max({a, b, c}) - min({a, b, c}));
        }
    }

    for (int y = 1; y <= H - 1; y++) {
        int a = y * W;

        if (W % 2 == 0) {
            int b = (W / 2) * (H - y);
            ret = min(ret, abs(a - b));
        } else if ((H - y) % 2 == 0) {
            int b = ((H - y) / 2) * W;
            ret = min(ret, abs(a - b));
        } else {
            int b, c;
            if (W > H - y) {
                b = (W / 2) * (H - y);
                c = (W / 2 + 1) * (H - y);
            } else {
                b = ((H - y) / 2) * W;
                c = ((H - y) / 2 + 1) * W;
            }
            ret = min(ret, max({a, b, c}) - min({a, b, c}));
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import bisect

S = input()
RL_place_left = []
RL_place_right = []

num = [0]*len(S)

for i in range(1, len(S)):
    if S[i - 1] == 'R' and S[i] == 'L':
        RL_place_left.append(i - 1)
        RL_place_right.append(i)

for i in range(len(S)):
    if S[i] == 'R':
        index = bisect.bisect_left(RL_place_left, i)
        if abs(i - RL_place_left[index]) % 2 == 0:
            num[RL_place_left[index]] += 1
        else:
            num[RL_place_right[index]] += 1
    else:
        index = bisect.bisect_right(RL_place_right, i) - 1
        if abs(i - RL_place_right[index]) % 2 == 0:
            num[RL_place_right[index]] += 1
        else:
            num[RL_place_left[index]] += 1

print(' '.join([str(n) for n in num]))

Measured memory_bytes: 14444
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int X,A;
    private void solve() {
        X = nextInt();
        A = nextInt();
        out.println(X < A ? 0 : 10);
    }

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

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <iostream>

int main()
{
    char c;
    std::cin >> c;

    switch(c) {
        case 'A':
            std::cout << 'T' << std::endl;
            break;
        case 'T':
            std::cout << 'A' << std::endl;
            break;
        case 'C':
            std::cout << 'G' << std::endl;
            break;
        case 'G':
            std::cout << 'C' << std::endl;
            break;
        default:
            std::cout << "unknown" << std::endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.lang.Math;

class Main{

    public static void main(String[] args){
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        
        // 共通変数
        String str;
        boolean debug = false;

        // 課題別変数
        String keyword1 = "the ";
        String keyword2 = "this ";
        String keyword3 = "that ";
        String decodeStr = "";

        try {
            while(debug || reader.ready()){
                str = reader.readLine();

                for (int i = 0; i <= (int)('z' - 'a'); i++) {
                    decodeStr = tryDecode(str, i+1);
                    
                    if (decodeStr.contains(keyword1) || decodeStr.contains(keyword2) || decodeStr.contains(keyword3)){
                        System.out.println(decodeStr);
                    } 
                }
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    // ----- 自作関数 ----- //
    private static String tryDecode(String str, int n){
        char[] words = str.toCharArray();
        String decode_words = ""; 
        
        for (int i = 0; i < words.length; i++) {
            if (words[i] >= 'a' && words[i] <= 'z') {
                words[i] += n;
                if (words[i] > 'z') {
                    words[i] += 'a' - 'z'; // はみ出した部分をカット
                    words[i] += 'a' - 'b'; // １文字文ずらす
                }
            }
            decode_words += String.valueOf(words[i]);
        }

        return decode_words;
    }
}


Measured memory_bytes: 27548
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j in range(len(a_list)):
    if a_list[j] == b_i:
      a_list[j] = -1
if ((a_list[0]==-1 and a_list[1] == -1 and a_list[2] == -1) or
    (a_list[3]==-1 and a_list[4] == -1 and a_list[5] == -1) or
    (a_list[6]==-1 and a_list[7] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[4] == -1 and a_list[8] == -1) or
	(a_list[2]==-1 and a_list[4] == -1 and a_list[6] == -1)):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int N,K; cin >> N >> K;
    vec D(K); rep(i,K) cin >> D[i];

    for(int i = 0; N <= 99999; i++) {
        string temp = to_string(N);
        bool flag = true;
        rep(j,temp.size()) {
            rep(k,K) {
                if(temp[j] == D[k]){
                    flag = false;
                    break;
                }
            }
            if(!flag) break;
        }
        if(flag) {cout << N << endl; return 0;}
        else N++;
    }
    return 0;
    
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)

x = sum(a)
if x > 0:
  x = int(x/N+0.5)
else:
  x = int(x/N-0.5)

total = 0
if a[0] == x and a[-1] == x:
  print(0)
else:  
  for i in range(N):
    total += (x-a[i])**2
  print(int(total))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//階乗（を1000000007で割ったあまり）を求める関数
int fact(int64_t x){
  int64_t y=1;
  for(int64_t i=1;i<=x;i++){
   y*=i;
   y%=1000000007;
  }
  return y;
}
int main() {
  int64_t n,m;
  cin>>n>>m;
  if(abs(n-m)>1){
    cout<<0;
  }
  int64_t ans=0;
  if(abs(n-m)==1){
    int64_t x=fact(n);
    int64_t y=fact(m);
    cout<<(x*y)%1000000007;
  }
  if(abs(n-m)==0){
    int64_t x=fact(n);
    int64_t y=fact(m);
    cout<<(((x*y)%1000000007)*2)%1000000007;
  }
}

Measured memory_bytes: 256
# Aizu Problem 0100: Sale Result
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    N = int(input())
    if N == 0:
        break
    sales = {}
    good = False
    order = []
    for n in range(N):
        i, p, q = [int(_) for _ in input().split()]
        if i not in order:
            order.append(i)
        sales[i] = sales.get(i, 0) + p * q
    good = False
    for i in order:
        if sales[i] >= 1000000:
            print(i)
            good = True
    if not good:
        print("NA")

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let m_angle = (m / 60.0) * 360.0;
    let h_angle = (h / 12.0) * 360.0 + m / 60.0 * 30.0;
    let mut angle: f64 = (h_angle - m_angle).abs();

    if angle > 180.0 {
        angle = 360.0 - angle;
    }

    let theta = angle * std::f64::consts::PI / 180.0;

    let c2 = a * a + b * b - 2.0 * a * b * theta.cos();
    println!("{}", c2.sqrt())
}


Measured memory_bytes: 3004
#include<stdio.h> 
#define MAX 100001

int Partition(int A[],int p,int r){
  int i,j,s,t,u;
  s=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=s){
      i++;
      t=A[i];        /*Exchange A[i] and A[j]*/
      A[i]=A[j];
      A[j]=t;
    }
  }
  u=A[i+1];          /*Exchange A[i+1] and A[r]*/
  A[i+1]=A[r];
  A[r]=u;
  return i+1;
}

int main(){
  int i,n,A[MAX],index;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  index=Partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==index){
      printf("[%d] ",A[i]);
    } else if(i!=n-1) {
      printf("%d ",A[i]);
    }
    else printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 996
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }
        Scanner cin = new Scanner();

        int x;
        void solve() {
            x = cin.nextInt();

            bool isABC = x < 1200;

            Console.WriteLine(isABC ? "ABC" : "ARC");

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public char nextChar() { return char.Parse(next()); }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
            public string[] array() { return Console.ReadLine().Split(' '); }
            public char[] arrayChar() { return Array.ConvertAll(array(), char.Parse); }
            public int[] arrayInt() { return Array.ConvertAll(array(), int.Parse); }
            public long[] arrayLong() { return Array.ConvertAll(array(), long.Parse); }
            public double[] arrayDouble() { return Array.ConvertAll(array(), double.Parse); }
        }

        class Mathf {
            public int mod = 1000000007;//10^9+7
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
            public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
            public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); }
            public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        }
    }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,q;
	string s;
	cin>>n>>q>>s;
	vector<int>map(n,0);
	for(int i=1;i<n;++i){
		map.at(i)+=map.at(i-1);
		if(s.at(i-1)=='A'&&s.at(i)=='C')++map.at(i);
	}
	for(int i=0,l,r;i<q;++i){
		cin>>l>>r;
		cout<<map.at(r-1)-map.at(l-1)<<"\n"s;
	}
}

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

//flagを用いたバブルソート
int bubbleSort(int A[],int N){
    int sw = 0;
    bool flag = 1;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = N-1; j >= i+1; j-- ){
            if(A[j-1] > A[j] ){
                swap(A[j],A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int A[100],N,sw;
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];

    sw = bubbleSort(A,N);

    for(int i = 0; i < N ;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>V;
int main(void){
	int n;
	int i;
	V	v;
	int x;
	cin>>n;
	for(i=0;i<n;i++)	cin>>x,v.push_back(x);
	v.erase(unique(v.begin(),v.end()),v.end());
	for(i=0;i<(int)v.size();i++){
		if(i)	cout<<" ";
		cout<<v[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3536