akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if(err != nil) {
		panic(err)
	}
	return num
}

// 読み込みをfloat型へキャスト
func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	k := nextInt()
	s := nextLine()
	if len(s) <= k {
		fmt.Println(s)
	} else {
		modi_s := strings.Split(s, "")
		out_s := make([]string, k, k)
		for i := 0; i < k; i++ {
			out_s = append(out_s, string(modi_s[i]))
		}
		fmt.Println(strings.Join(out_s, "") + "...")
	}
}

Measured memory_bytes: 1780
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int X,A;
    cin >> X >> A;
    if(X<A) cout << 0 << endl;
    else cout << 10 << endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<stack>

int main()
{
	using namespace std;
	stack<int> NumberRow;
	while(true){
		string in;
		cin >> in;
		if(cin.good() == false){
			break;
		}
		if(in == "+"){
			int End     = NumberRow.top();
			NumberRow.pop();
			int SemiEnd = NumberRow.top();
			NumberRow.pop();
			NumberRow.push(SemiEnd + End);
		}else if(in == "-"){
			int End     = NumberRow.top();
			NumberRow.pop();
			int SemiEnd = NumberRow.top();
			NumberRow.pop();
			NumberRow.push(SemiEnd - End);
		}else if(in == "*"){
			int End     = NumberRow.top();
			NumberRow.pop();
			int SemiEnd = NumberRow.top();
			NumberRow.pop();
			NumberRow.push(SemiEnd * End);
		}else{
			int Num;
			stringstream ss;
			ss << in;
			ss >> Num;
			NumberRow.push(Num);
		}
	}
	cout << NumberRow.top() << endl;
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 200005
int a[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"NO\n";
			return 0;
		}
	 } 
	 cout<<"YES\n";
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
int main(){
  int N; cin >> N;
  Graph G(N);
  for (int i = 0; i < N - 1; ++i){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(make_pair(b, i));
    G[b].push_back(make_pair(a, i));
  }
  int max_color = 0;
  rep(i, N) max_color = max(max_color, (int)G[i].size());
  vector<int> ans(N - 1, -1);

  vector<int> dist(N, -1);
  queue<P> que;
  que.push(make_pair(0, -1));
  dist[0] = 0;
  while (!que.empty()){
    auto p = que.front(); que.pop();
    int v = p.first, c = p.second;
    int color = 1;
    if (color == c) ++color;
    for (auto e: G[v]){
      if (dist[e.first] == -1){
        dist[e.first] = dist[v] + 1;
        que.push(make_pair(e.first, color));
        ans[e.second] = color;
        ++color;
        if (color == c) ++color;
      }
    }
  }
  cout << max_color << endl;
  for (auto v: ans) cout << v << endl;
}


Measured memory_bytes: 7552
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Not so Diverse
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	sc.Split(bufio.ScanWords)
	A := make(map[int]int, N)
	var temp int
	for i := 0; i < N; i++ {
		temp = nextInt()
		A[temp]++
	}

	B := make([]int, 0)
	for _, v := range A {
		B = append(B, v)
	}

	sort.Sort(sort.IntSlice(B))

	var count int = len(A)
	var ans int
	for i := 0; i < N; i++ {
		if count > K {
			count--
			ans += B[i]
		} else {
			fmt.Println(ans)
			break
		}
	}
}


Measured memory_bytes: 17512
#include <stdio.h>
int main(void){
    int N, x=0, max=0;
    scanf("%d", &N);
    char S[N+1];
    scanf("%s", S);
    for(int i=0; i<N; i++){
        if(S[i]=='I') x++;
        else if(S[i]=='D') x--;
        if(max<x) max=x;
    }
    printf("%d", max);
    return 0;
}

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

int main(){
  string s,t; cin>>s >>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a+b+2-1)/2<<endl;



}


Measured memory_bytes: 256
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,A,B,C = map(int, input().split())
    array = [A,B,C]
    string = ['A','B','C']
    si = [] # AB:0,BC:1,AC:2
    if A+B+C <= 0:
        print('No')
        return
    for _ in range(N):
        s = input()
        si += (0 if s == 'AB' else 1 if s == 'BC' else 2),

    ans = []
    for i in range(len(si)):
        s = si[i]
        index = -3 if s == 0 else -2 if s == 1 else -1
        if array[index] == 0:
            array[index] += 1
            array[index+1] -= 1
            ans += string[index],
        elif array[index+1] == 0:
            array[index] -= 1
            array[index+1] += 1
            ans += string[index+1],
        elif array[index] == 1 and array[index+1] == 1:
            if i+1 >= len(si):
                array[index] += 1
                array[index+1] -= 1
                ans += string[index],
            else:
                if si[i+1] != (index+1)%3:
                    array[index] += 1
                    array[index+1] -= 1
                    ans += string[index],
                else:
                    array[index] -= 1
                    array[index+1] += 1
                    ans += string[index+1],
        elif array[index] == 1:
            array[index] += 1
            array[index+1] -= 1
            ans += string[index],
        else:
            array[index] -= 1
            array[index+1] += 1
            ans += string[index+1],

        if array[0] < 0 or array[1] < 0 or array[2] < 0:
            print('No')
            return
        
    print('Yes')
    for s in ans:
        print(s)

main()


Measured memory_bytes: 10804
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;




namespace SolutionCS
{
    class Program
    {
        static BigInteger gcd(BigInteger a, BigInteger b)
        {
            if (a < b)
            {
                return gcd(b, a);
            }

            while (b != 0)
            {
                BigInteger rem = a % b;
                a = b;
                b = rem;
            }

            return a;
        }

        static BigInteger lcm(BigInteger a, BigInteger b)
        {
            return a * b / gcd(a, b);
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            BigInteger ans = BigInteger.Parse(Console.ReadLine());
            for (int i = 1; i < N; i++)
            {
                ans = lcm(ans, BigInteger.Parse(Console.ReadLine()));
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13524
def main():
    N = int(input())
    A = list(map(int, input().split()))

    # print(N)
    # print(A)
    d = {i:0 for i in range(1,N+1)}
    d2 = {}
    d3 = {}
    # print(d)
    # return


    for i in A:
        d[i] += 1

    # print(d)
    sum = 0
    for i in range(1,N+1):
        d2[i] = int(d[i] * (d[i]-1) / 2)
        sum += d2[i]

    # print(d2)

    for i in range(1, N+1):
        if d[i] == 0: d3[i] = 0
        else: d3[i] = int((d[i]-1) * (d[i]-2) / 2)

    # print(d3)


    for i in A:
        print(sum - d2[i] + d3[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 82040
// God put a smile upon your face <3

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

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

//    slld(testcase);

//    for(ll cs = 1; cs <= testcase; cs++)
    {
		cin >> n >> m;
		cout << n * m << '\n';
    }


}




Measured memory_bytes: 3636
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int[] L;
	int N;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt(); // N本の棒
		L = nextIntArray(N); // 棒の長さ

		Arrays.sort(L);
		long cnt = 0;
		for(int i=0;i<N-2;i++) {
			for(int j=i+1;j<N-1;j++) {

				int ab = L[i]+L[j];
				int c_i = Search(j+1,ab)-1;
				if(ab <= L[c_i])continue;
				cnt += (c_i-j);

			}
		}
		out.println(cnt);
	}

	//二部探索
	public int Search(int _l, int k) {
		int l = -1+_l;
		int r = N;
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(L[mid] >= k) r = mid;
			else l = mid;
		}
		return r;
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 25564
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static int K;

	public static void main(String[] args) {
		String S = sc.next();

		int A = Integer.parseInt(S.substring(0, 2));
		int B = Integer.parseInt(S.substring(2, 4));

		boolean YYMM = (1 <= B && B <= 12);
		boolean MMYY = (1 <= A && A <= 12);

		if (YYMM) {
			if (MMYY) System.out.println("AMBIGUOUS");
			else System.out.println("YYMM");
		} else {
			if (MMYY) System.out.println("MMYY");
			else System.out.println("NA");
		}
	}

}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var A, B, Q int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d %d", &A, &B, &Q)

	ss := make([]int, A)
	ts := make([]int, B)
	for i := 0; i < A; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &ss[i])
	}
	for i := 0; i < B; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &ts[i])
	}
	sort.Sort(sort.IntSlice(ss))
	sort.Sort(sort.IntSlice(ts))

	xs := make([]int, Q)
	for i := 0; i < Q; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &xs[i])
	}

	var buffer bytes.Buffer

	for _, x := range xs {
		ls := -1
		rs := -1
		lt := -1
		rt := -1

		iS := sort.Search(len(ss), func(i int) bool { return ss[i] >= x })
		if iS < len(ss) {
			rs = iS
			if iS > 0 {
				ls = iS - 1
			}
		} else {
			ls = len(ss) - 1
		}

		iT := sort.Search(len(ts), func(i int) bool { return ts[i] >= x })
		if iT < len(ts) {
			rt = iT
			if iT > 0 {
				lt = iT - 1
			}
		} else {
			lt = len(ts) - 1
		}

		ans := math.MaxInt64
		if lt != -1 && ls != -1 {
			ans = min(ans, max(abs(x-ts[lt]), abs(x-ss[ls])))
		}
		if ls != -1 && rt != -1 {
			ans = min(ans, min(abs(x-ss[ls]), abs(x-ts[rt]))+abs(ss[ls]-ts[rt]))
		}
		if lt != -1 && rs != -1 {
			ans = min(ans, min(abs(x-ts[lt]), abs(x-ss[rs]))+abs(ts[lt]-ss[rs]))
		}
		if rt != -1 && rs != -1 {
			ans = min(ans, max(abs(x-ts[rt]), abs(x-ss[rs])))
		}

		buffer.WriteString(strconv.Itoa(ans))
		buffer.WriteString("\n")
	}
	fmt.Println(buffer.String())
}

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

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}
func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

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

    ll max_cnt = 0;
    ll cnt = 0;
    rep(i, s.size()){
        if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T'){
            cnt++;
        }else{
            cnt = 0;
        }
        if(cnt > max_cnt){
            max_cnt = cnt;
        }
    }

    cout << max_cnt << endl;

}

Measured memory_bytes: 3568
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

def nc(i):
  if i==1 or i==0:
    return 1
  else :
    return nc(i-1)*i

def check(A):
  l=len(A)
  if l==1:
    return 1
  tar=A[0]
  t=0
  for a in A[1:]:
    if tar > a:
      t+=1
  A.pop(0)
  return t*nc(l-1)+check(A)

cp=check(p)
cq=check(q)
d=cp-cq
if d<0:
  d=d*(-1)

print(d)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	map<int, int> mc;
	while (n--)
	{
		int x;
		cin >> x;
		mc[x] = 1;
	}
	cout << mc.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, vector<int> > T;

llint D;
llint c[30], csum;
llint s[400][30];
vector<int> ans;
vector<T> vec;

llint score(vector<int> ans, llint n)
{
	llint last[26];
	for(int i = 0; i < 26; i++) last[i] = 0;
	
	llint ret = 0, sub = 0;
	for(int i = 0; i < n; i++){
		llint x = ans[i];
		ret += s[i][x];
		sub -= (i-last[x]) * c[x];
		sub += csum;
		ret -= sub;
		last[x] = i;
	}
	return ret;
}

void search(vector<int> &ret)
{
	llint cur = score(ret, D);
	for(int t = 0; t < 2; t++){
		llint x = rand() % D, y = rand() % D;
		swap(ret[x], ret[y]);
		llint nxt = score(ret, D);
		if(nxt < cur) swap(ret[x], ret[y]);
		else cur = nxt;
		
		x = rand() % D, y = rand() % 26;
		llint tmp = ret[x];
		ret[x] = y;
		nxt = score(ret, D);
		if(nxt < cur) ret[x] = tmp;
		else cur = nxt;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	srand(time(NULL));
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 0; i < D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < 26; i++) csum += c[i];
	
	ans.resize(D);
	for(int i = 0; i < D; i++){
		llint max_val = -inf, max_j;
		for(int j = 0; j < 26; j++){
			ans[i] = j;
			llint res = score(ans, i+1);
			if(res > max_val){
				max_j = j;
				max_val = res;
			}
		}
		ans[i] = max_j;
	}
	search(ans);
	
	const int M = 100;
	llint res = score(ans, D);
	for(int i = 0; i < M; i++) vec.push_back(T(res, ans));
	
	for(int t = 0; t < 3000; t++){
		vector<T> nvec;
		for(int i = 0; i < vec.size(); i++){
			vector<int> tmp = vec[i].second;
			search(tmp);
			nvec.push_back(vec[i]);
			nvec.push_back(T(score(tmp, D), tmp));
		}
		sort(nvec.rbegin(), nvec.rend());
		nvec.resize(M);
		vec = nvec;
	}
	ans = vec.front().second;
	
	for(int i = 0; i < D; i++) cout << ans[i]+1 << endl;
	
	return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
int ufd[202020];
int Find(int a)
{
  if(a==ufd[a]) return a;
  return ufd[a] = Find(ufd[a]);
}
void Union(int a, int b)
{
  ufd[Find(a)] = Find(b);
}
int main()
{
  int N, M;
  scanf("%d%d", &N, &M);
  for(int i=0; i<=2*N; ++i) ufd[i] = i;
  for(int i=1; i<=N; ++i)
  {
    int t; scanf("%d", &t);
    Union(i, t+N);
  }
  for(int i=0; i<M; ++i)
  {
    int u, v; scanf("%d%d", &u, &v);
    Union(u, v);
  }
  int cnt = 0;
  for(int i=1; i<=N; ++i)
    if(Find(i) == Find(N+i)) ++cnt;
  printf("%d\n", cnt);
}

Measured memory_bytes: 1024
n,k = map(int, input().split())
s = input()

ans = 0

for i in range(n-1):
    if s[i]==s[i+1]=='R':
        ans += 1
for i in range(n-1):
    if s[i]==s[i+1]=='L':
        ans +=1

ans = min(n-1,ans + 2*k)
print(ans)

Measured memory_bytes: 40176
s = []
for x in input().split():
    if x == "+":
        b = s.pop()
        a = s.pop()
        s.append(a+b)
    elif x == "-":
        b = s.pop()
        a = s.pop()
        s.append(a-b)
    elif x == "*":
        b = s.pop()
        a = s.pop()
        s.append(a*b)
    else:
        s.append(int(x))
print(s.pop())
    


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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " ";cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 2e5 + 3;

void solve()
{
	int n, k;
	cin >> n >> k;
	int ans = min(n % k, k - (n % k));
	cout << ans;

	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	//cout << setprecision(9) << fixed;
	clock_t z = clock();
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i = 3; i <= n; i++){
        if(i % 3 == 0){
            cout << " " << i;
        }else{
            int t = 1;
            while(1){
                    if((i / t) % 10 == 3){
                        cout << " " << i;
break;
                    }
                t *= 10;
                if(i / t == 0){
                    break;
            }
        }
    }
    }
cout << endl;
return 0;
}
    

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int ans = 0;
		for(int X=0;X<=Math.min(K, S);X++){
			for(int Y=0;Y<=Math.min(K, S-X);Y++){
				int Z = S-X-Y;
				if(0<=Z && Z<=K){
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 9796
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a = sc.read_vec::<usize>(n);

    if a.iter().any(|&e| e == 0) {
        println!("0");
        return;
    }

    let mut ans = 1;
    for a in a.into_iter() {
        if ans as f64 > 1e18 as f64 / a as f64 {
            println!("-1");
            return;
        }
        ans *= a;
    }
    if ans > 1e18 as usize {
        println!("-1");
        return;
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2344
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N,M,A[100010];cin>>N>>M;
    long long S[100010],ans=0;
    map<int,long long>mp;
    A[0]=S[0]=0;
    mp[0]++;
    for(int i=1;i<=N;i++){
        cin>>A[i];
        S[i]=S[i-1]+A[i];
        mp[S[i]%M]++;
    }

    for(auto itr=mp.begin();itr!=mp.end();itr++)
        ans+=(itr->second)*(itr->second-1)/2;
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5376
N = int(input())
A = [int(a) for a in input().split()]
prev0, prev1 = (A[0], -A[0])
for i in range(N-2):
    curr0 = max(prev0+A[i+1], prev1-A[i+1])
    curr1 = max(prev0-A[i+1], prev1+A[i+1])
    prev0, prev1 = (curr0, curr1)
print(max(prev0+A[-1], prev1-A[-1]))


Measured memory_bytes: 14260
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        char[] SD = S.toCharArray();
        Arrays.sort(SD);
        char[] TD = T.toCharArray();
        Arrays.sort(TD);
        
        String SS = new String(SD);
        String TS = new String(TD);
        String RTS = new StringBuilder(TS).reverse().toString();        

		if(SS.compareTo(RTS) < 0) {
			System.out.print("Yes");
		} else {
			System.out.println("No");
	    }
	}
}


Measured memory_bytes: 23764
nums = list(map(int, input().split()))
nums.sort()
count = nums[2] - nums[1]
nums[0] += nums[2] - nums[1]
if (nums[2]-nums[0])%2 == 0:
  count += (nums[2]-nums[0])//2
else:
  count += (nums[2]-nums[0])//2 + 2
print(count)

Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a=0,b=0,c=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='a')a++;
    else if(s[i]=='b')b++;
    else if(s[i]=='c')c++;
  }
  if(a==1&&b==1&&c==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
    

Measured memory_bytes: 764
#![allow(dead_code)]
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let a: i32 = sc.read();
    let b: i32 = sc.read();

    let ans = std::cmp::max(0, a - 2*b);

    format!("{}\n", ans)
}
#[test]
fn test_solve() {
   assert_eq!(solve("12 4\n"), "4\n");
   assert_eq!(solve("20 15\n"), "0\n");
   assert_eq!(solve("20 30\n"), "0\n");
   assert_eq!(solve("12 4\n"), "4\n");
   assert_eq!(solve("20 15\n"), "0\n");
   assert_eq!(solve("20 30\n"), "0\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
int n,v;
ll x[200005];
ll calc(int v){
	int l=n-v+1,r=n,t=1;
	ll ans=0;
	for (;r>0;l-=v,r-=v,t++){
		l=max(l,1);
		if (2*INF/max(2*t+1,5)<x[r]-x[l-1]) return 2*INF;
		ans+=1ll*max(2*t+1,5)*(x[r]-x[l-1]);
		if (ans>INF) return ans;
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&v);
	for (int i=1;i<=n;i++)
		scanf("%lld",&x[i]),x[i]+=x[i-1];
	ll ans=INF;
	for (int i=1;i<=n;i++)
		ans=min(ans,calc(i)+1ll*i*v);
	printf("%lld\n",ans+1ll*n*v);
}

Measured memory_bytes: 1792
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
N, M = gets_i_list
k_list = []
N.times do
  k = gets_i_list
  k.shift
  k_list.push k
end

k_count_h = k_list.flatten.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

dpp k_count_h
puts k_count_h.values.count(N)


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

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

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	for(int i = 0; i < ty - sy; i++) cout << 'U';
	for(int i = 0; i < tx - sx; i++) cout << 'R';
	for(int i = 0; i < ty - sy; i++) cout << 'D';
	for(int i = 0; i < tx - sx; i++) cout << 'L';
	cout << 'L';
	for(int i = 0; i < ty - sy + 1; i++) cout << 'U';
	for(int i = 0; i < tx - sx + 1; i++) cout << 'R';
	cout << "DR";
	for(int i = 0; i < ty - sy + 1; i++) cout << 'D';
	for(int i = 0; i < tx - sx + 1; i++) cout << 'L';
	cout << 'U' << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define R(a) a=sqrt(a)
#define POW(a,b) a=pow(a,b)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    FAST;
    double d,t,s;
    cin>>d>>t>>s;
    if(t>=d/s){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    

    return 0;
}



Measured memory_bytes: 3732
n = int(input())
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]


count = 0
for i in range(n-1):
    if a[i] - b[i] < 0:
        count += a[i]
        diff = a[i+1] - (b[i] - a[i]) 
        if diff < 0:
            b[i+1] += a[i+1]
        else:
            count += b[i] - a[i]
            a[i+1] -= b[i] - a[i]
    elif a[i] - b[i] >= 0:
        count += b[i]

if b[n-1] - a[n-1] > 0:
    count += a[n-1]
    rest = b[n-1] - a[n-1]
    if rest < a[n]:
        count += rest
    else:
        count += a[n]
else:
    count += b[n-1]


print(count)

Measured memory_bytes: 18624
#include <iostream>

using namespace std;

class A {
	int R;
public:
	void solve()
	{
		cin >> R;
		if (R < 1200) cout << "ABC";
		else if (R < 2800) cout << "ARC";
		else cout << "AGC";

		cout << endl;

	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

int n,m;
char grid[1111][1111];

int dist[1000111];
pair<int,int> q[1000111];
int qL;

bool TFO[1111][1111];

int ABS(int a)
{
    if (a < 0)
        return -a;
    else
        return a;
}

int BFS()
{
    int i,j;
    int uk = 1;

    qL = 0;
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=m;j++)
        {
            if (grid[i][j] == '#')
            {
                TFO[i][j] = true;
                qL++;
                q[qL] = make_pair(i,j);
                dist[qL] = 0;
            }
        }
    }

    while(uk <= qL)
    {
        int x = q[uk].first;
        int y = q[uk].second;

        for (i=x-1;i<=x+1;i++)
        {
            for (j=y-1;j<=y+1;j++)
            {
                if (ABS(x-i) + ABS(y-j) == 1)
                {
                    if (i >= 1 && i <= n && j >= 1 && j <= m && !TFO[i][j])
                    {
                        TFO[i][j] = true;
                        qL++;
                        q[qL] = make_pair(i,j);
                        dist[qL] = dist[uk] + 1;
                    }
                }
            }
        }

        uk++;
    }

    return dist[qL];
}

int main()
{
    int i,j;

    scanf("%d %d",&n,&m);

    for (i=1;i<=n;i++)
    {
        scanf("%s",grid[i]+1);
    }

    printf("%d\n",BFS());

    return 0;
}


Measured memory_bytes: 14080
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int inf = 1e9;
const int mod = 1e9 + 7;

inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }

inline int sub(int a, int b) { return a >= b ? a - b : a - b + mod; }

inline int mul(int a, int b) { return llint(a) * b % mod; }

int powmod(int a, int b) {
  if (b == 0) return 1;
  if (b % 2) return mul(a, powmod(a, b - 1));
  return powmod(mul(a, a), b / 2);
}

int main(void) {
  ios_base::sync_with_stdio(false);

  int N, X, Y;
  cin >> N >> X >> Y;

  vector<int> fact(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; ++i) {
    fact[i] = mul(fact[i - 1], i);
  }

  vector<vector<int>> W(N);
  REP(i, N) {
    int c, w;
    cin >> c >> w;
    W[c - 1].push_back(w);
  }

  int minW1 = inf;
  int minW2 = inf;
  for (auto& w : W) {
    if (w.size() > 0) {
      sort(w.begin(), w.end());
      if (w[0] <= minW1)
        minW2 = minW1, minW1 = w[0];
      else if (w[0] <= minW2)
        minW2 = w[0];
    }
  }

  vector<pair<int, int>> a;
  for (auto& w : W) {
    if (w.size() > 0) {
      int L = X - w[0];
      if (w[0] == minW1) {
        L = max(L, Y - minW2);
      } else {
        L = max(L, Y - minW1);
      }

      while (w.size() > 0 && w.back() > L) w.pop_back();
      if (w.size() > 0) a.push_back({w[0], w.size()});
    }
  }

  if (a.size() == 0) {
    cout << "1\n";
    return 0;
  }

  sort(a.begin(), a.end());
  int r = 1;
  while (r < (int)a.size() && a[r].first + a[0].first <= Y) r++;

  int s = 0, denom = 1;
  REP(i, r) {
    s += a[i].second;
    denom = mul(denom, fact[a[i].second]);
  }

  int ret = mul(fact[s], powmod(denom, mod - 2));
  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 11256
n = int(input())
ans = [0 for a in range(10050)]


for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      
      if v<10050:
        ans[v]+=1

for i in range(n):
  print(ans[i+1])

Measured memory_bytes: 9252
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
using namespace std;

map<string, int> mp;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("A.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        mp[str]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N,M,Q; cin >> N >> M >> Q;
  vector<int> L(M),R(M);
  for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
  
  vector<vector<ll>> Data(N+2, vector<ll>(N+2));
  
  for (int i = 0; i < M; i++) Data[L[i]][R[i]]++;
  
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) Data[i][j] += Data[i][j-1];
  }
  
  for (int j = 1; j <= N; j++) {
    for (int i = 1; i <= N; i++) Data[N-i+1][j] += Data[N-i+2][j];
  }
  
  for (int i = 0; i < Q; i++) {
    int p,q; cin >> p >> q;
    cout << Data[p][q] << endl;
  } 
}

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

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> D(N);
    for(ll i=0;i<N;i++){
        int a,b,c;
        cin >> a >> b >>c;
        D[i].emplace_back(a);
        D[i].emplace_back(b);
        D[i].emplace_back(c);
    }

    ll dp[N+1][3] = {0};

    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            dp[i+1][j] = max(dp[i][(j+1)%3],dp[i][(j+2)%3]) +D[i][j];
        }
    }
    ll ans  = max(dp[N][0],dp[N][1]);
    ans = max(ans,dp[N][2]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
const int N = 3e5 + 500;
int n, m, p[N], ra[N], dir[N], ans[N];
bool cmp(int x, int y) { return p[x]<p[y]; }
ll s;
int main() {
	scanf("%d%d%I64d", &n, &m, &s);
	rep(i, 0, n - 1) {
		char ch[10]; scanf("%d %s", p + i, ch);
		--p[i]; ra[i] = i;
		dir[i] = ch[0] == '2' ? -1 : 1;
	}
	sort(ra, ra + n, cmp);
	int t = 0;
	rep(i, 0, n - 1) {
		if (dir[i] == 1) t += (p[i] + s) / m%n;
		else t += (p[i] - s - m + 1) / m%n;
		t = (t%n + n) % n;
		p[i] = p[i] + s%m*dir[i];
		p[i] = (p[i] % m + m) % m;
	}
	sort(p, p + n);
	rep(i, 0, n - 1) ans[ra[(i + n - t) % n]] = p[i] + 1;
	rep(i, 0, n - 1) printf("%d%c", ans[i] % m, i == n - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>

int main(){
    int N, A;
    int sisa;

    scanf("%d",&N);
    scanf("%d",&A);

    sisa = N % 500;

    if(A >= sisa){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

// 入力の宣言
int n;
string str;

int main() {

  // 回数の入力
  cin >>n;

  // 回数分だけ
  REP(z, n){
    // 入力処理
    cin >>str;
    // 答えのパターンを入れるsetの宣言
    set<string> ans;

    // 0文字目~length-2まで(iとする)
    for(int i = 0; i <= str.length() - 2; ++i){

      // 文字列を0~iとi + 1~最後の文字までの2つのsubstringにする
      string right = str.substr(0, i + 1), left = str.substr(i + 1);
      reverse(right.begin(), right.end());
      reverse(left.begin(), left.end());
      string rright = right, rleft = left;
      reverse(right.begin(), right.end());
      reverse(left.begin(), left.end());

      // debug
      // cout <<right <<", " <<left <<", " <<rright <<", " <<rleft <<endl;

      // 組み合わせパターンについて、setに入れる
      ans.insert(right + left);
      ans.insert(right + rleft);
      ans.insert(rright + left);
      ans.insert(rright + rleft);
      ans.insert(left + right);
      ans.insert(left + rright);
      ans.insert(rleft + right);
      ans.insert(rleft + rright);


    }

    // setの要素数出力
    cout <<ans.size() <<endl;
  }

  return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n; cin >> n;
	vd p(n); REP(i, n) cin >> p[i];

	// dp[i][j] = i 回目に j 個表が出る確率
	vvd dp(n + 1, vd(n + 1, 0));
	dp[0][0] = 1;

	REP(i, n) {
		REP(j, i + 1) {
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
			if (j < n) dp[i + 1][j + 1] += dp[i][j] * p[i];
		}
	}
	double ans = 0;
	FOR(i, n / 2 + 1, n + 1) ans += dp[n][i];
	cout << ans << endl;

}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;int64_t k,t=1,n;int S(int64_t x){int s=0;while(x)s+=x%10,x/=10;return s;}int main(){cin>>k;while(n+=t,cout<<n<<endl,--k)while((n+t)*S(n+t+t)>S(n+t)*(n+t+t))t*=10;}


Measured memory_bytes: 256
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int H = reader.ni(), W = reader.ni();

		if (H == 1 || W == 1) {
			System.out.println("1");
			return;
		}

		long mv_w_a = (long)Math.ceil(1.0 * W / 2);
		long mv_w_b = (long)Math.floor(1.0 * W / 2);
		long mv_h_a = (long)Math.ceil(1.0 * H / 2);
		long mv_h_b = (long)Math.floor(1.0 * H / 2);
		long sum_a = mv_w_a * mv_h_a;
		long sum_b = mv_w_b * mv_h_b;

		long res = sum_a + sum_b;
		System.out.println(res);

		return;
	}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 21460
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String s = mylist.get(0);
        int l = s.length();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < l; i++) {
            sb.append("x");
        }
        System.out.println(sb.toString());

    }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h> 
using namespace std; 
int main()
{
	int a;
	long long b[100001],cnt=1;
	cin>>a;
	for (int i=0;i<a;i++)
	{
		cin>>b[i];
		if (b[i]==0)
		{
			cout<<"0";
			return 0;
		}
	}
	for (int i=0;i<a;i++)
	{
		if (b[i]<=1000000000000000000/cnt)
			cnt*=b[i];
		else
		{
			cout<<-1;
			return 0;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 4412
/*

IDE: DP

DP bisa dikerjakan dari belakang, jadi dari string S kita mencari banyaknya cara membuatnya menjadi string kosong.

Kita punya 2 tipe operasi:
- menghapus karakter terakhir dari S
- menambahkan karakter 0 atau 1 dari S
- tidak melakukan apa-apa (apabila string kosong)

Jadi, DPnya DP[len][k]: banyaknya cara membuat string kosong, dengan panjang sekarang len dan bisa melakukan s operasi lagi.
*/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MAXN 5000

int dp[MAXN+1][MAXN+1];

int solve(int len, int sis) {
	if(len>MAXN || len<0)	return 0;
	if(sis==0)
		return (len==0);

	int &ans = dp[len][sis];
	if(ans!=-1)	return ans;


	// append
	ans = solve(len-1, sis-1);

	//backspace
	ans+= 2*solve(len+1, sis-1)%MOD;

	if(ans>=MOD)
		ans-=MOD;

	// do nothing
	if(len==0)	ans+=solve(len, sis-1);

	if(ans>=MOD)
		ans-=MOD;


	//cout<<len<<" "<<sis<<" "<<dp[len][sis]<<"\n";
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	int n;
	string s;
	cin>>n>>s;
	cout<<solve(s.size(), n)<<"\n";

}

Measured memory_bytes: 98304
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<math.h>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,h;
    ll answer = 0;
    cin >> n >> h;
    vector <ll> a(n),b(n);
    REP(i,n){
        cin >> a[i] >> b[i];
    }

    ll max_a=*max_element(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    ll sum =0;
    REP(i,n){
        if(b[i]>=max_a){
            sum+=b[i];
        }
        else{
            break;
        }
    }
    if(sum < h){
        ll x = (h-sum)/max_a;
        h -= (x*max_a);
        answer+=x;
        if(h > sum){
            h-=max_a;
            answer++;
        }
    }
    //cout << sum << endl;
    
    

    REP(i,n){
        h-=b[i];
        answer++;
        if(h<=0){
            break;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <numeric>
#include <cmath>
#include <bits/stdc++.h>
#include <list>
using namespace std;

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

  int c0=0,c1=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0') c0++;
    else c1++;
  }

  cout<<2*min(c0,c1)<<endl;


}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main ()
{
    int n;
    cin>>n;
    for(int i=1000;;i+=1000)
    {
        if(i>=n)
        {
            cout<<i-n<<endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
  long long n,t,i,res=0;
  cin >> n;
  for(i=1;i<=n;i++){
    t=n/i;
    res+=i*t*(t+1)/2;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a < b){
			if(b < c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}	
	}
}

Measured memory_bytes: 17320