akhauriyash/Code-Regression huggingface dataset:
S = input()

cnt = 0
cnt2 = []
flag = False
for i in range(3) :
    if S[i] == 'R' :
        if flag == True :
            cnt += 1
        else :
            cnt = 1
            flag = True
    else :
        cnt = 0
        flag = False
    cnt2.append(cnt)

print(max(cnt2))

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  rep(i, N) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a, b, c, S;
    cin >> a >> b >> c;
    if (a > b){
        S = b;
        b = a;
        a = S;
    }
    if (b > c){
        S = c;
        c = b;
        b = S;
    }
    if (a > b){
        S = b;
        b = a;
        a = S;
    }
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int main() {
	cin >> n;
	
	int ans = 1;
	while(ans * 2 <= n) { ans *= 2; }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    lint a, b;
    while(cin >> a >> b){
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


//const int mod = 1000000007;
const int MAX = 20000005;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


ll g(int r, int c) {
    ll res = 0;
    for(int i=1; i<=r+1; ++i) { res += COM(i+c, i); chmod(res); }
    return res;
}


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

    int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
    COMinit();

    ll ans = 0;
    ans += g(r2, c2); chmod(ans);
    ans -= g(r2, c1-1); chmod(ans);
    ans -= g(r1-1, c2); chmod(ans);
    ans += g(r1-1, c1-1); chmod(ans);

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

Measured memory_bytes: 468992
#include <iostream>

using namespace std;

int maximize(int a, int b){
    int ans = a;
    if (a < b){
        ans = b;
    }
    return ans;
}

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

    cout << maximize(a+b, maximize(a - b, a * b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  bool prime[247000]={};
  int i,j;

  for(i=2;i<sqrt(247000);i++){
    if(prime[i])continue;
    for(j=2;i*j<247000;j++)
	prime[i*j]=true;
  }

  while(true){
    cin>>n;
    if(n==0)break;
    if(n==1){
      cout<<"1"<<endl;
      continue;
    }
    int sum=0;
    for(i=n+1;i<=2*n;i++)
      if(prime[i]==false)sum++;
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 3336
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

char field[55][55];
int h, w;

char itoc(int c) {
	switch (c) {
	case 0: return '0';
	case 1: return '1';
	case 2: return '2';
	case 3: return '3';
	case 4: return '4';
	case 5: return '5';
	case 6: return '6';
	case 7: return '7';
	case 8: return '8';
	case 9: return '9';
	default: return 'm';
	}
}

char check_mine(char s, int s1, int s2) //s1・・・高さs2・・・横
{

	int count = 0;
	if (s == '#') {
		return ('#');
	}
	//上
	if (s1 != 0) {
		if (s2 != 0) {
			if (field[s1 - 1][s2 - 1] == '#') {
				count++;
			}
		}
		if (field[s1 - 1][s2] == '#') {
			count++;
		}
		if (s2 != w - 1) {
			if (field[s1 - 1][s2 + 1] == '#') {
				count++;
			}
		}
	}

	//横
	if (s2 != 0 && s2 != w - 1) {
		if (field[s1][s2 + 1] == '#') {
			count++;
		}
		if (field[s1][s2 - 1] == '#') {
			count++;
		}
	}
	if (s2 == 0) {
		if (field[s1][s2 + 1] == '#') {
			count++;
		}
	}
	if (s2 == w - 1) {
		if (field[s1][s2 - 1] == '#') {
			count++;
		}
	}

	//下
	if (s1 != h - 1) {
		if (s2 != 0) {
			if (field[s1 + 1][s2 - 1] == '#') {
				count++;
			}
		}
		if (field[s1 + 1][s2] == '#') {
			count++;
		}
		if (s2 != w - 1) {
			if (field[s1 + 1][s2 + 1] == '#') {
				count++;
			}
		}
	}

	return (itoc(count));
	
}

int main(void)
{

	
	int i, j;
	string temp;
	vector<string> s;
	cin >> h >> w;
	for (i = 0; i < h; i++) {
		cin >> temp;
		for (j = 0; j < w; j++) {
			field[i][j] = temp[j];
		}
		s.push_back(temp);
	}



	for (i = 0; i < h; i++) {

		for (j = 0; j < w; j++) {
			cout << check_mine(field[i][j], i, j);
		}
		cout << endl;
	}


	return (0);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

N = int(input())
s = [int(input()) for i in range(N)]
wa = sum(s)
s.sort()
if wa % 10 != 0:
    print(wa)
else:
    for i in range(N):
        if s[i] % 10 != 0:
            print(wa - s[i])
            break
    else:
        print(0)


Measured memory_bytes: 3316
#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); i++)

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

    int n; cin >> n;
    int x[n]; REP(i, n) cin >> x[i];
    int y[n]; REP(i, n) cin >> y[i];

    int D1 = 0;
    REP(i, n) {
        D1 += abs(x[i] - y[i]);
    }

    double D2 = 0.0;
    REP(i, n) {
        D2 += pow(abs(x[i] - y[i]), 2);
    }
    D2 = sqrt(D2);

    double D3 = 0.0;
    REP(i, n) {
        int tmp = 0;
        tmp += abs(x[i] - y[i]);
        D3 += tmp * tmp * tmp;
    }
    D3 = cbrt(D3);

    double D_INF = 0.0;
    REP(i, n) {
        D_INF = max(D_INF, (double)abs(x[i] - y[i]));
    }

    printf("%.6f\n", (double)D1);
    printf("%.6f\n", D2);
    printf("%.6f\n", D3);
    printf("%.6f\n", D_INF);
    return 0;
}


Measured memory_bytes: 3376
s = list(input())
i = 1

count = 0
if len(s) == 1:
    print(0)
    exit()
while(True):
    if s[i-1] == s[i]:
        s[i] = str(1 - int(s[i]))
        count = count +1
    if i == len(s)-1:
        break
    i = i+1

print(count)

Measured memory_bytes: 6700
#include <bits/stdc++.h>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define yes(i) cout<<(i?"yes":"no")<<endl
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[200000];
	int b[200000];
	int ma=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
		ma=max(ma,a[i]);
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(b[i]==ma){
			cout<<a[n-2]<<endl;
		}else{
			cout<<ma<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,m,l,o;
	cin>>n;
	if(n==1){
		cout<<'1'<<endl;
		return 0;
	}
	else if(n==2){
		cout<<'3'<<endl;
		return 0;
	}
	for(int i=2;i<n;i++){
		if(i==2){
			m=2+1;
			l=1;
			o=2;
		}
			o=l;
			l=m;
			m=o+l;
			
		}
		cout<<m<<endl;
}


Measured memory_bytes: 256
package main

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

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	var A, B int
	fmt.Scan(&A, &B)
	if B%A == 0 {
		fmt.Println(A+B)
	} else {
		fmt.Println(B-A)
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef pair<string, string> PSS;

string reverse(string str) { 
  reverse(str.begin(), str.end()); 
  return str;
}

PSS separate(string str, int n) {
  return PSS( str.substr(0, n), str.substr(n)); }

PSS reverse_car(PSS pss) { return PSS(reverse(pss.first), pss.second); }

PSS reverse_cdr(PSS pss) { return PSS(pss.first, reverse(pss.second));}

PSS reverse_car_cdr(PSS pss) { return reverse_car(reverse_cdr(pss)); }

string concat(PSS pss) { return pss.first + pss.second; }

PSS swap_pps(PSS pss) { return PSS(pss.second, pss.first); }

vector<string> rearrange(string str, int n) {
  PSS pss = separate(str, n), ssp = swap_pps(pss);
  vector<string> ans;

  ans.push_back(concat(reverse_car(pss)));
  ans.push_back(concat(reverse_cdr(pss)));
  ans.push_back(concat(reverse_car_cdr(pss)));
  ans.push_back(concat(ssp));
  ans.push_back(concat(reverse_car(ssp)));
  ans.push_back(concat(reverse_cdr(ssp)));
  ans.push_back(concat(reverse_car_cdr(ssp)));

  return ans;
}

set<string> accumulate(string str) {
  set<string> ans;
  ans.insert(str);
  ans.insert(reverse(str));
  for (int i = 1, len = str.length(); i < len; i++) {
    vector<string> vs = rearrange(str, i);
    REP(j, vs.size()) {
      ans.insert(vs[j]);
    }
  }
  return ans;
}

int main() {
  int m;
  cin >> m;
  REP(M, m) {
    string str;
    cin >> str;

    cout << accumulate(str).size() << endl;
  }
}

Measured memory_bytes: 1300
import math
def A():
    a = input()
    b = input()
    ans = 0
    for i in range(3):
        if a[i] == b[i]:
            ans += 1
    print(ans)

def B():
    temp = [int(i) for i in input().split()]
    a = int(temp[0])
    b = int(temp[1])
    ans = 0
    t = 1
    while (t<b):
        ans += 1
        t += (a-1)
    print(ans)

def C():
    n = int(input())
    nums = [int(i) for i in input().split()]
    start_index = 0
    end_index = 1
    max_len = 0
    le = 0
    while (end_index < len(nums)):
        if nums[end_index] <= nums[end_index-1]:
            le += 1
        else:
            max_len = max(le, max_len)
            start_index = end_index
            le = 0
        end_index += 1
    max_len = max(le, max_len)
    print(max_len)

def D():
    n = int(input())
    # for i in range(1, n+1):
    #     m = 0
    #     s = [i for i in range(1, n+1)]
    #     for j in range(len(s)):
    #         m = max(m, s[0]%i)
    #         del s[0]

    #     print(i, m)
    #     ans += m
    ans = n*(n-1)//2
    print(ans)

B()

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

using namespace std;

string N;
long long sum;

int main() {
    cin >> N;
    for (unsigned int i = 0; i < N.size(); ++i)
        sum += (N[i] - '0');

    if (sum % 9 == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int D;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26));

int get_score(vector<int> &t) {
	int score = 0;
	vector<int> last(26, -1);
	rep(i, t.size()) {
		score += s[i][t[i]];
		last[t[i]] = i;
		rep(j, 26) score -= c[j] * (i - last[j]);
	}
	return score;
}

int evaluate(vector<int> &t, int k) {
	int score = 0;
	vector<int> last(26, -1);
	rep(i, t.size()) {
		score += s[i][t[i]];
		last[t[i]] = i;
		rep(j, 26) score -= c[j] * (i - last[j]);
	}

	for(int d = t.size(); d < min<int>(D, t.size() + k); d++) {
		rep(j, 26) {
			score -= (d - last[j]) * c[j];
		}
	}
	return score;
}

vector<int> solve(int k) {
	vector<int> res;
	rep(i, D) {
		int max_score = LLONG_MIN;
		int type = -1;
		rep(j, 26) {
			res.push_back(j);
			int score = evaluate(res, k);
			if(max_score < score) {
				max_score = score;
				type = j;
			}
			res.pop_back();
		}
		res.push_back(type);
	}
	return res;
}

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	cin >> D;
	rep(i, 26) {
		cin >> c[i];
		c[i]--;
	}
	rep(i, D) {
		rep(j, 26) cin >> s[i][j];
	}

	vector<int> ans;
	int ans_score = LLONG_MIN;
	rep(k, 26) {
		vector<int> out = solve(k);
		int score = get_score(out);
		if(ans_score < score) {
			ans_score = score;
			ans = out;
		}
	}
	rep(i, ans.size()) cout << ans[i] + 1 << endl;
	return 0;
}

Measured memory_bytes: 3740
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = "";
        for(int i = 1; i <= n; i++){
            str += i;
        }
        String a = "";
        for(int i = 0; i < n; i++){
            a += sc.next();
        }
        String b = "";
        for(int i = 0; i < n; i++){
            b += sc.next();
        }
        int ansa = -1;
        int ansb = -1;
        int ind = 1;
        while(ansa < 0 || ansb < 0){
            if(str.equals(a)){
                ansa = ind;
            }
            if(str.equals(b)){
                ansb = ind;
            }
            str = nextPermutation(str);
            ind++;
        }
        System.out.println(Math.abs(ansa-ansb));
    }
    
    static String nextPermutation (String s) {

        ArrayList<Character> list = new ArrayList<>();
        for (int i=0; i<s.length(); i++) list.add(s.charAt(i));

        int pivotPos = -1;
        char pivot = 0;
        for (int i=list.size()-2; i>=0; i--) {
            if (list.get(i) < list.get(i+1)) {
                pivotPos = i;
                pivot = list.get(i);
                break;
            }
        }

        if (pivotPos==-1 && pivot==0) return "Final";

        int L = pivotPos+1, R = list.size()-1;
        int minPos = -1;
        char min = Character.MAX_VALUE;
        for (int i=R; i>=L; i--) {
            if (pivot < list.get(i)) {
                if (list.get(i) < min) {
                    min = list.get(i);
                    minPos = i;
                }
            }
        }

        Collections.swap(list, pivotPos, minPos);
        Collections.sort(list.subList(L, R+1));

        StringBuilder sb = new StringBuilder();
        for (int i=0; i<list.size(); i++) sb.append(list.get(i));

        return sb.toString();

    }
}

Measured memory_bytes: 44940
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
class union_find{
	std::vector<int> parent;
public:
	int root(int a){return parent[a]==a?a:(parent[a]=root(parent[a]));}
	union_find(int n):parent(n+1){for(int i=1;i<=n;i++)parent[i]=i;}
	int same(int a,int b){return root(a)==root(b);}
	int unite(int a,int b){
		int x=root(a),y=root(b);//if(x==y)return 0;
		parent[x]=y;
		return 1;
	}
	int calc(){
		std::map<int,int> m;
		for(int i=1;i<parent.size();i++)m[root(i)]++;
		int r=0;
		for(auto &e:m)r+=e.second>1?1:-1;
		return abs(r);
	}
};
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	union_find uf(n);
	int a,b;
	for(;m--;uf.unite(a,b))scanf("%d%d",&a,&b);
	printf("%d\n",uf.calc());
}

Measured memory_bytes: 2872
import math
import heapq
n,m = map(int,input().split())

a = input()
list1 = list(map(int,a.split()))
list1 = [i*-1 for i in list1]
heapq.heapify(list1)

for i in range(m):
    s = heapq.heappop(list1)
    s = math.ceil(s/2)
    heapq.heappush(list1,s)

print(int(math.fabs(sum(list1))))

Measured memory_bytes: 15228
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 1e5 + 5;
int n, a[N];

int sgn(int x) {
	return (x < 0) ? -1 : (x > 0);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	
	int ans = 1;
	int k = sgn(a[2] - a[1]);
	for (int i = 2; i < n; i++) {
		int t = sgn(a[i + 1] - a[i]);
		if (k == 0) k = t;
		if (t * k == -1) {
			k = 0;
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  deque<char> s;
  ll q;
  string ss;
  cin >> ss >> q;
  for (size_t i = 0; i < ss.length(); i++) {
    s.pb(ss[i]);
  }
  ll re=0;
  for (size_t i = 0; i < q; i++) {
    ll a,f; char c;
    cin >> a;
    if(a == 2){
      cin >> f >> c;
      if(f == 1 && re%2 == 0){
        s.pf(c);
      }else if(re%2 == 0){
        s.pb(c);
      }
      if(f == 1 && re%2 == 1){
        s.pb(c);
      }else if(re%2 == 1){
        s.pf(c);
      }
    }else{
      re++;
    }
  }
  if(re%2 == 1)reverse(all(s));
  while (s.size() > 0) {
    cout << s.front();
    s.pop_front();
  }
  cout << endl;
}


Measured memory_bytes: 896
import math
n, m = raw_input().split()
n = int(n)
m = int(m)
if n < 2 and m < 2:
  print(0)
elif n < 2:
  print(math.factorial(m)//(math.factorial(m-2) * 2))
elif m < 2:
  print(math.factorial(n)//(math.factorial(n-2) * 2))
else:
  print(math.factorial(n)//(math.factorial(n-2)*2) + math.factorial(m)//(math.factorial(m-2)*2))


Measured memory_bytes: 2568
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define endl '\12'
#define eb emplace_back
#define SZ(a) int32_t(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ex_gcd(ll a, ll b, ll& x, ll& y){if(!b){x=1;y=0;return a;}ll ret=ex_gcd(b,a%b,y,x);y-=a/b*x;return ret;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
int norm(int x) { return x >= mod ? (x - mod) : x; }
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
inline ll get_inv(ll a) { ll x, y; ex_gcd(a, mod, x, y); return norm(x + mod);}
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
const double PI = acos(-1.0);
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260817, P_2=999998639;
constexpr int maxn = 1e6+10; // remember to calculate. if tle, check maxn first.

int main()
{
    ll n ,x , t;
    cin >> n >> x >> t;
    cout << (n+x-1)/x*t << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<deque>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

void slide_min(int L, vector<int> &a, vector<int> &ans){
	deque<int> deque;
	
	for(int i = 0, j = 0; i < (int)a.size() - L + 1; i++){
		for(;j < i + L; j++){
			while(deque.size() && a[deque.back()] >= a[j]){
				deque.pop_back();
			}
			deque.push_back(j);
		}
		
		ans.push_back(a[deque.front()]);
		
		if(deque.front() == i) deque.pop_front();
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, L;
	vector<int> a, ans;
	
	cin>>N>>L;
	
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
	}
	
	slide_min(L,a,ans);
	
	for(int i = 0; i < ans.size(); i++){
		if(i) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 19096
#include <bits/stdc++.h>
#define ll long long
#define MAX 100000
#define INF 1000000 
#define M 1000000007
#define PI 2 * acos(0.0)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
   fast_io
   ll n;
   cin>>n;
   ll a[n+2];
   for(ll i = 1;i<=n;i++) cin>>a[i];
   ll dp[MAX];
   dp[1] = 0;
   dp[2] = dp[1]+abs(a[1]-a[2]); 
   for(ll i = 3;i<=n;i++){
       dp[i] = min(dp[i-1] + abs(a[i-1]-a[i]) , dp[i-2] + abs(a[i-2]-a[i]));
      // cout<<dp[i]<<" ";
   }
   cout<<dp[n]<<endl;
   return 0;
}

Measured memory_bytes: 5140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
using namespace std;

template <std::size_t N>
std::string to_string(const std::bitset<N>& bs)
{
  return bs.to_string<char, std::char_traits<char>, std::allocator<char> >();
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long N, K;
	cin >> N >> K;
  	cout << N-(K-1) << endl;
  	return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

const ll mx=1000000000;

ll cnt=0;

ll search(ll s){
    ll l=0,r=9;
    char ans;
    ll ask;
    while(r-l>1){
        ll m=l+(r-l)/2;
        ask=s;
        ask*=10;
        ask+=m;
        while(ask<=mx){ask*=10; ask+=9;}
        cout<<"? "<<ask<<endl;
        cnt++;
        cin>>ans;
        if(ans=='Y'){
            r=m;
        }
        else{
            l=m+1;
        }
    }
    for(ll i=l;i<=r;i++){
        if(s==0 && i==0){continue;}
        ask=s;
        ask*=10;
        ask+=i;
        while(ask<=mx){ask*=10; ask+=9;}
        cout<<"? "<<ask<<endl;
        cnt++;
        cin>>ans;
        if(ans=='Y' && i==0){
            if(s%10!=9){
                ask=0;
                while(ask<s){ask*=10; ask+=9;}
                cout<<"? "<<ask<<endl;
                cnt++;
                cin>>ans;
                if(ans=='Y'){
                    return s;
                }
                else{
                    return s*10;
                }
            }
            else{
                ask=1;
                while(ask<=s){ask*=10;}
                cout<<"? "<<ask<<endl;
                cnt++;
                cin>>ans;
                if(ans=='N'){
                    return s;
                }
                else{
                    return s*10;
                }
            }
        }
        if(ans=='Y'){return s*10+i;}
    }
    return -1;
}



int main(){
    ll ans=0;
    for(int i=0;i<11;i++){
        ll ret=search(ans);
        if(ret==ans){break;}
        ans=ret;
    }
    cout<<"! "<<ans<<endl;
    assert(cnt<=64);
    
    return 0;
}


Measured memory_bytes: 596
#include<iostream>
using namespace std;
#define ll long long int
int main()
{ 
  ll n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  ll sum=0;
  ll mod=1e9+7;
 
  
  for(int i=n-2;i>=0;i--)
  {
      sum=sum+a[i]*a[i+1];
      sum=sum%mod;
      a[i]=a[i]+a[i+1];
      a[i]=a[i]%mod;
  }
  cout<<sum;
  
}


Measured memory_bytes: 5168
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int ab, bc, ca; cin >> ab >> bc >> ca;
  cout << ab * bc / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define  epsiron 1e-2
typedef long long ll;

using namespace std;
int main(void){
  ll n,x;
  ll an[n];
  cin >> n >> x;
  for(ll i=0;i<n;++i){
     cin >>an[i]; 
  }
  std::sort(an,an+n);
  ll sum=0;
  for(int i=0;i<n;++i){
    sum += an[i];
    if(sum>x &&i<n-1){
       cout << i;
       return 0;
    }
    if(i==n-1&&sum==x){
      cout << n;
      return 0;
    }
    if(i==n-1&&sum>x){
      cout << n-1;
       return 0;
    }
  }
    cout << n-1;
return 0;
}


Measured memory_bytes: 256
n=int(input())
#list内包表記で書こう
#速いし、書きやすい
a=sorted([int(i) for i in input().split()],reverse=True)
b=0
for i in range(n):
    if i%2==0:
        b+=a[i]
    else:
        b-=a[i]

print(b)


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 300005;
typedef long long i64;

int N, M, L[MAX_N], R[MAX_N], id[MAX_N];

bool cmp(int x, int y) {
  return R[x] - L[x] < R[y] - L[y];
}

class Fenwick {
public:
  i64 sum1[MAX_N], sum2[MAX_N];
  void update(i64 *sum, i64 x, i64 val) {
    for (; x <= M; x += x & -x)
      sum[x] += val;
  }
  i64 ask(i64 *sum, i64 x) {
    i64 res = 0;
    for (; x; x -= x & -x)
      res += sum[x];
    return res;
  }
  void update2(int l, int r, int val) {
    update(sum1, l, val), update(sum1, r + 1, -val);
    update(sum2, l, -(l - 1) * val), update(sum2, r + 1, r * val);
  }
  i64 ask2(int x) {
    return ask(sum1, x) * x + ask(sum2, x);
  }
  i64 query(int l, int r) {
    return ask2(r) - ask2(l - 1);
  }
} tr;

int main() {
  scanf("%d%d", &N, &M);
  
  for (int i = 1; i <= N; ++i) {
    scanf("%d%d", &L[i], &R[i]);
    id[i] = i;
  }
  
  sort(id + 1, id + N + 1, cmp);

  for (int i = 1, l = 1; i <= M; ++i) {
    while (l <= N && (R[id[l]] - L[id[l]] + 1) < i) {
      tr.update2(L[id[l]], R[id[l]], 1);
      l++;
    }
    
    int now = N - l + 1;
    for (int j = i; j <= M; j += i)
      now += tr.query(j, j);
    printf("%d\n", now);
  }
  
  return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>

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

int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	printf("%d\n", gcd(x, y));
	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    map<string, int> cnt;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        cnt[s] += 1;
    }
    string keys[] = {"AC", "WA", "TLE", "RE"};
    for(auto &k : keys) {
        cout << k << " x " << cnt[k] << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a < b and b < c ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin>>n;
    long long ans = 1;
    vector<long long> vec;
    bool isZero = false;;
    for(int i=0; i<n; ++i){
        long long v; cin>>v;
        ans*=v;
        if(v==0){
            isZero = true;
        }
        vec.push_back(v);
    }
    if(isZero){
        cout<<"0";
        return 0;
    }
    long long tmp = ans;
    for(int i=0; i<n; ++i){
        ans/=(vec[i]);
    }
    if(ans==1 && tmp<=1000000000000000000){
        cout<<tmp;
    }
    else{
        cout<<"-1";
    }
}


Measured memory_bytes: 4320
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0 ; i < n ; i++){
            a[i] = sc.nextInt();
        }
        sc.close();
        for(int i = 0 ; i < n ; i++){
            b[i] = a[i];
        }
        Arrays.sort(b);
        int aa = 0;
        for(int i = 0 ; i < n && aa == 0 ; i++){
            if(b[n - 1] == a[i]){
                aa = i;
            }
        }
        for(int i = 0 ; i < n ; i++ ){
            if(i == aa ){
                System.out.println(b[n - 2]);
            }else{
                System.out.println(b[n - 1]);
            }
        }
    }
}

Measured memory_bytes: 62036
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
ll a[200005],b[200005];
vector<ll> AA,BB;
int main(){
    ll n,m,k;
    cin >> n>> m>> k;
    rep2(i,n){
        ll A;
        cin >> A;
        if(i>0){
            a[i]+=a[i-1]+A;
        }else{
            a[i]=A;
        }
        AA.push_back(a[i]);
    }
    rep2(i,m){
        ll B;
        cin >> B;
        if(i>0){
            b[i]+=b[i-1]+B;
        }else{
            b[i]=B;
        }
        BB.push_back(b[i]);
    }
    ll ans=0;
    rep(i,n+1){
        ll l=upper_bound(BB.begin(),BB.end(),k-a[i])-BB.begin();
        ll temp=l+i;
        if(k-a[i]>=0){
            ans=max(ans,temp);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

struct ELEMENT{
	int value = -1;
	ELEMENT *prev;
	ELEMENT *next;
};


void insert(ELEMENT* dummy, int &value, int &first){
	ELEMENT *new_value = new ELEMENT;
	new_value -> value  = value;

	new_value -> next = dummy -> next;
	new_value -> prev = dummy;
	
	dummy -> next -> prev = new_value;
	dummy -> next = new_value;

	if(first){
		dummy -> prev = new_value;
		first = 0;
	}
}

void delete_(ELEMENT* dummy, int &value){
	ELEMENT *temp = dummy -> next;
	while(temp != dummy){
		int &check = temp -> value;

		if(check == value){
			// Find the first element
			ELEMENT *temp_prev = temp -> prev;
			ELEMENT *temp_next = temp -> next;
			temp_prev -> next = temp_next;
			temp_next -> prev = temp_prev;
			delete temp;
			break;
		}
		temp = temp -> next;
	}
}

void delete_first(ELEMENT* dummy){
	ELEMENT* to_delete = dummy -> next;

	dummy -> next = to_delete -> next;
	to_delete -> next -> prev = dummy;
	delete to_delete;
}

void delete_last(ELEMENT* dummy){
	ELEMENT* temp = dummy -> prev;
	temp -> prev -> next = dummy;
	dummy -> prev = temp -> prev;
}

void show(ELEMENT* dummy){
	ELEMENT *temp = dummy -> next;
	int check = 1;
	while(temp -> value != -1){
		if(check){
			printf("%i", temp -> value);
			check = 0;
		}else{
			printf(" %i", temp -> value);
		}
		temp = temp -> next;
	}
	printf("\n");
}


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

	// Initialization
	ELEMENT *dummy = new ELEMENT;
	dummy -> prev = dummy;
	dummy -> next = dummy;

	// Get commands
	char command[15];
	int value;
	int first = 1;
	for(int i=0; i<n; i++){
		scanf("%s", command);

		if(command[0] == 'i'){
			scanf("%d", &value);
			insert(dummy, value, first);
		}else if(command[6] == 'F'){
			delete_first(dummy);		
		}else if(command[6] == 'L'){
			delete_last(dummy);
		}else if(command[0] == 'd'){
			scanf("%d", &value);
			delete_(dummy, value);
		}
		
	}
	show(dummy);

	return 0;
}


Measured memory_bytes: 33968
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int c=fmax(a,b);
  int d=fmin(a,b);
  if(c==2){
    cout << "3";
  }else{
    if (d==2){
      cout << "1";
    }else{
      cout << "2";
    }
  }
  return 0;
}
    


Measured memory_bytes: 256
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G

n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
G = Graph(ab)
#print(G)

temp_list = G[0]
for next in temp_list:
    if n in G[next - 1]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 66840
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char a; cin >> a ;
  if(a == 'A') cout << 'T';
  else if (a == 'C') cout << 'G';
  else if (a == 'G') cout << 'C';
  else if (a == 'T') cout << 'A';
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

ll quickpower(ll a, ll b) {
  ll res = 1;
  ll mod = 1e9 + 7;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    b = b >> 1;
    a = (a * a) % mod;
  }
  return res % mod;
}

ll fact(ll x) {
  ll res = 1 % mod;
  for (ll i = 1; i <= x; i++) {
    res = res * i % mod;
  }
  return res;
}

long long combine(long long a, long long b) {
  //返回的是 aCb mod 1e9 + 7；
  return fact(a) * quickpower((fact(b) * fact(a - b) % mod), mod - 2) % mod %
         mod;
}

int main() {
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
  } else {
    long long m, n;
    m = x - (x + y) / 3;  // 解方程
    n = y - (x + y) / 3;
    if ((m < 0) || (n < 0))
      cout << 0 << endl;
    else
      cout << combine(m + n, m) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			long A = scan.nextLong();
			long B = scan.nextLong();
			long N = scan.nextLong();

			/*
			for(int x = 0;x<=N;x++) {
				long t = (A*x)/B;
				long s = x/B;

				System.out.println(t-A*s);
			}*/

			long t,s;

			if(N<B-1) {
				 t = (A*N)/B;
				 s = N/B;

			}else {
				 t = (A*(B-1))/B;
				 s = (B-1)/B;
			}


			System.out.println(t-A*s);

		}


	}


}


Measured memory_bytes: 35816
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin >> a>>b>>c;
  int sum[3];
  sum[0]=a+b;sum[1]=a+c;sum[2]=b+c;
  sort(sum,sum+3);
  cout << sum[0]<<endl;
}


Measured memory_bytes: 256
import queue

n,m=map(int,input().split())
path=[[] for i in range(n+1)]
used=[False]*(n+1)
parent=[0]*(n+1)
parent[0]=1
parent[1]=1

for i in range(m):
    a,b=map(int,input().split())
    path[a].append(b)
    path[b].append(a)

q=queue.Queue()
q.put(1)

while not q.empty():
    a=q.get()
    for p in path[a]:
        if not used[p]:
            used[p]=True
            parent[p]=a
            q.put(p)

if 0 in parent:
    print("No")
else:
    print("Yes")
    for i in range(2,n+1):
        print(parent[i])

Measured memory_bytes: 35172
import itertools
(n,_),*a= [[*map(int,i.split())] for i in open(0)]
p=[[1] + list(i) for i in itertools.permutations(range(2,n+1),n-1)]
c = 0
for i in p:
    for j in range(n-1):
        if sorted([i[j],i[j+1]]) not in a:
            break
    else:
        c+=1
print(c)

Measured memory_bytes: 9504
import sys
from io import StringIO
import unittest

def resolve():
    n, k = map(int, input().split())
    ans = 0
    div = 10 ** 9 + 7
    for i in range(k, n + 2):
        tmp = 0
        # if (2 * n - i + 1) * i / 2 < (i - 1) * i / 2:
        #     break
        if i == n + 1:
            ans += 1
        else:
            ans += (2 * n - i + 1) * i / 2 - (i - 1) * i / 2 + 1

    print(int(ans % div))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 2"""
        output = """10"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """200000 200001"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """141421 35623"""
        output = """220280457"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 16336
A, B, C = map(int, input().split())
sum = A
cnt = 1

for i in range(1,101):
  if sum % B == C:
    print('YES')
    exit()
  else:
    cnt += 1
    num = A * cnt
    if num % B == C:
      print('YES')
      exit()
    sum += num
  
  if cnt == 100:
    print('NO')
    exit()

Measured memory_bytes: 3060
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

ans = float("inf")

if N < 3:
  ans = 1
else:   
  for i in range(N):
    x, y = xy[i][0], xy[i][1]
    for j in range(N):
      if i == j:
        continue
      p, q = xy[j][0] - x, xy[j][1] - y
      cnt = 0
      for k in range(N):
        xk, yk = xy[k][0], xy[k][1]
        for l in range(N):
          if k == l:
            continue
          if xy[l][0] - xk == p and xy[l][1] - yk == q:
            cnt += 1
      ans = min(ans, N - cnt)
print(ans)

Measured memory_bytes: 43884
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

int n, m;
bool vis[100010] = {};
vector<int> G[100010], tp;

void dfs(int v) {
    if (!vis[v]) {
        vis[v] = 1;
        for (int i = 0; i < G[v].size(); i++) {
            dfs(G[v][i]);
        }
        tp.push_back(v);
    }
}

int main() {
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
    }

    bool t[n + 5] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < G[i].size(); j++) {
            t[G[i][j]] = 1;
        }
    }

    int root = -1;
    for (int i = 0; i < n; i++) {
        if (!t[i]) {
            root = i;
            break;
        }
    }

    for (int i = 0; i < n; i++) dfs(i);
    reverse(tp.begin(), tp.end());

    for (int i = 0; i < n; i++) cout << tp[i] << endl;

}



Measured memory_bytes: 5872
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	vector<int> v;
	int ans = 0;
	int min = INT_MAX;
	bool flg = true;

	for (int i = 0; i < 5; i++) {
		int tmp;
		cin >> tmp;

		if (tmp < 10) {
			ans += 10;
			if (min > tmp) min = tmp;
			flg = false;
			continue;
		}
		if (tmp % 10 == 0) {
			ans += tmp;
			continue;
		}

		int t = tmp - (tmp / 10)*10;
		ans += tmp - t + 10;
		if (min > t) min = t;
		flg = false;
	}
	if (flg) {
		//none;
	}else {
		ans = ans - 10 + min;
	}

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256