akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<list>
using namespace std;
int A[200005];
list<int>::iterator it;
list<int>::reverse_iterator iq;
int main()
{
int n;
cin >> n;
for(int i=0;i<n;i++)
{
	cin >> A[i];
}
list<int> c(1,A[0]);

for(int i=2;i<=n;i++)
{
 if(i%2==0) c.push_back(A[i-1]);
 else c.push_front(A[i-1]);	
}

if(n%2!=0) {
	for(it=c.begin();it!=c.end();it++)
	{
		cout << *it<<" ";
	}
}
else {
for(iq=c.rbegin();iq!=c.rend();iq++)
{
	cout << *iq<<" ";
}
}
return 0;	
}

Measured memory_bytes: 9216
#include <stdio.h>

int main(void){
	int 	w,
		n, 
		a[30]={0},
		b[30]={0},
		w_num[30]={0},
		i, j, x, tmp;

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

	for(i = 0; i < n; i++){
		scanf("%d,%d", &a[i], &b[i]);
	}
	
	for(i = 1; i <= w; i++){
		w_num[i] = i;
	}
	
    for(i = 0; i < n; i++){
        tmp = w_num[a[i]];
        w_num[a[i]] = w_num[b[i]];
        w_num[b[i]] = tmp;
    }

    
	for(i = 0; i < w; i++){
		printf("%d\n", w_num[i+1]);
	}
	
	return 0;
}	
	

Measured memory_bytes: 596
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 200005
using namespace std;

int f[N],buc[N],a[N],pos[N];
int main()
{
	int ans=0;
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]),pos[a[i]]=i;
	for(int i=1;i<=n;i++)
		f[i]=f[pos[a[i]-1]]+1,ans=max(ans,f[i]);
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 2560
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const S  = input.split("");
    var A = 0
    S.forEach(e=>{
    	if(e==="A"){
        	A++
        }
    })
  	if(A == 0 || A ==3){
		console.log('No');
      	return
    }
  	console.log('Yes');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n,k=map(int,input().split())
b,r=k,n-k

mod=10**9+7
f=[1]
for i in range(1,10000):f.append(f[-1]*i%mod)
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod

for i in range(1,k+1):
  a=1
  if r<i-1:print(0);continue
  a*=comb(k-1,i-1)
  a*=comb(n-k+1,i)
  print(a%mod)

Measured memory_bytes: 3700
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int dp[61][2][2][2];

int main(void) {
    Int L,R;

    cin>>L>>R;
    dp[60][0][0][0] = 1;
    for(int i = 59;i >= 0;i--) {
        int lb = L>>i&1;
        int rb = R>>i&1;

        for(int j = 0;j < 2;j++) {
            for(int k = 0;k < 2;k++) {
                for(int s = 0;s < 2;s++) {
                    Int pre = dp[i+1][j][k][s];
                    for(int x = 0;x < 2;x++) {
                        for(int y = 0;y < 2;y++) {
                            if(x&&!y)
                                continue;
                            int nj=j,nk=k,ns=s;
                            //next state
                            if(!s && x != y)
                                continue;
                            if(x && y)
                                ns = 1;
                            if(!j && !x && lb)
                                continue;
                            if(x && !lb)
                                nj = 1;
                            if(!k && y && !rb)
                                continue;
                            if(!y && rb)
                                nk = 1;

                            dp[i][nj][nk][ns] += pre;
                            dp[i][nj][nk][ns] %= MOD;
                        }
                    }
                }
            }
        }
    }

    Int ans = 0;
    for(int j = 0;j < 2;j++) {
        for(int k = 0;k < 2;k++) {
            for(int s = 0;s < 2;s++) {
                ans += dp[0][j][k][s];
                ans %= MOD;
            }
        }
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
d = 2019 - (L % 2019)
ans = 2019 * 2019

l = L % 2019
r = R % 2019
if R < L + d:
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i * j) % 2019)
else:
    ans = 0

print(ans)




Measured memory_bytes: 3060
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 S              PIC X(3).

PROCEDURE DIVISION.
  ACCEPT S.
  IF "ARC" = S
      DISPLAY "ABC"
  ELSE
      DISPLAY "ARC"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3700
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<int> a(n+1);
    REP(i,n) cin >> a[i];
    ll cnt=0;
    rep(i,n){
        if(a[i+1]==0){

        }
        else{
            a[i+1]+=a[i];
            a[i]=0;
        }
    }
    rep(i,n+1){
        cnt+=a[i]/2;
    }
    

    cout<<cnt<<endl;
    
}

Measured memory_bytes: 1024
fn main() {
    proconio::input! {
        n: usize,
        q: usize,
        tuv: [(usize,usize,usize);q],
    }
    let mut uf=vec![-1;n];
    for (t,u,v) in tuv {
        if t==0 {
            union(&mut uf, u, v);
        }
        else {
            println!("{}",if find(&mut uf, u)==find(&mut uf, v) {1} else {0});
        }
    }
}
fn find(uf: &mut Vec<i32>, i: usize) -> usize {
    if uf[i]<0 {
        i
    }
    else {
        uf[i]=find(uf, uf[i]as usize)as i32;
        uf[i]as usize
    }
}
fn union(uf: &mut Vec<i32>, i: usize, j: usize) {
    let mut i=find(uf, i);
    let mut j=find(uf, j);
    if i==j {
        return;
    }
    if uf[i]>uf[j] {
        std::mem::swap(&mut i, &mut j);
    }
    if uf[i]==uf[j] {
        uf[i]-=1;
    }
    uf[j]=i as i32;
}

Measured memory_bytes: 9404
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}


signed main(){
	IOS
	int n;	cin >> n;
	int a[n];
	int sum = 0;
	rep(i,n)	cin >> a[i], sum += a[i];
	int x = round((double)sum / n);
	int ans = 0;
	rep(i,n)	ans += (a[i] - x) * (a[i] - x);
	cout << ans << endl;
}


Measured memory_bytes: 256
#
# abc095 c
#

import sys
from io import StringIO
import unittest


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 = """1500 2000 1600 3 2"""
        output = """7900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1500 2000 1900 3 2"""
        output = """8500"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1500 2000 500 90000 100000"""
        output = """100000000"""
        self.assertIO(input, output)


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

    ans = float("inf")
    for i in range(2*max(X, Y)+1):
        a = max(0, X - i//2)
        b = max(0, Y - i//2)
        ans = min(ans, A*a+B*b+C*i)
    print(ans)


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


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

int main() {
  int N;cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  bool dif=true;
  for(int j=0;j<N-1;j++){
    if(A.at(j)==A.at(j+1)){
      dif=false;
      break;
    }
  }
  if(dif) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
      
}



Measured memory_bytes: 3976
int main(){
	long n,m,i;
  	long *data,total=0,count=0;
  	double cutOff;
  	scanf("%ld%ld",&n,&m);
  	data=(long int*)malloc(sizeof(long int)*n);
  
  	for(i=0;i<n;i++){
    	scanf("%ld",&data[i]);
      	total+=data[i];
    }
  	cutOff=total/(4.0*m);
  
  	for(i=0;i<n;i++){
    	if(data[i]>=cutOff)
          	count+=1;
    }
  
  	if(count>=m)
      	printf("Yes");
  	else
      	printf("No");
  
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    const ll N = S.size();
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<vector<ll>> dp(N, vector<ll>(2, 0));
    dp[0][0] = 1;
    dp[0][1] = INT_MIN;
    if (S[0] == S[1]) {
        dp[1][0] = INT_MIN;
        dp[1][1] = 1;
    } else {
        dp[1][0] = 2;
        dp[1][1] = 1;
    }
    for (ll i = 2; i < N; i++) {
        //一つ前で区切る
        dp[i][0] = dp[i - 1][1] + 1;
        if (S[i] != S[i - 1]) {
            dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
        }

        //二つ前で区切る
        if (i == 1) {
            continue;
        }
        dp[i][1] = max(dp[i - 2][0] + 1, dp[i - 2][1] + (i < 3 || S[i] != S[i - 2] || S[i - 1] != S[i - 3]));
    }

    cout << max(dp[N - 1][0], dp[N - 1][1]) << endl;
}

Measured memory_bytes: 11396
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*四日目*/
//少数も使いたい割り算はしない方がいい(三日目）
// 数値の大きさ
//for文で0代入する場所はforの一文下
	int n; cin >> n;
	int sum = 0;
	int minn;
	vector<int> su(n);
	for (int i = 0;i < n;i++) {
		cin >> su[i];
		if (i == 0)
			minn = su[0];
		if (minn >= su[i]) {
			minn = su[i];
			sum++;
		}
	}cout << sum;


	

}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int m, f, r;
  while(1){
    scanf("%d %d %d\n", &m, &f, &r);
    if      (m == -1 && f == -1 && r == -1) break;
    else if (m == -1 || f == -1) printf("F\n");
    else if (m+f >= 80) printf("A\n");
    else if (m+f >= 65) printf("B\n");
    else if (m+f >= 50) printf("C\n");
    else if (m+f >= 30 && r >= 50) printf("C\n");
    else if (m+f >= 30) printf("D\n");
    else printf("F\n");
  }

  return 0;
}



Measured memory_bytes: 2036
def main():
    from itertools import chain, tee
    s = input()
    n = len(s)

    a = (-1 if c == 'L' else 1 for c in s)
    p = -1
    RL = 1
    ctr = [0] * n

    it = chain(a, (1,))
    g1, g2 = tee(it, 2)
    next(g2)
    for i, (x1, x2) in enumerate(zip(g1, g2)):
        if x1 + x2 == 0:
            if RL:
                cnt = i - p
                ctr[i] += (cnt + 1) // 2
                ctr[i + 1] += cnt // 2
                p = i
            else:
                cnt = i - p
                ctr[p + 1] += (cnt + 1) // 2
                ctr[p] += cnt // 2
                p = i
            RL ^= 1
    print(*ctr)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define dumpArray(array,i,j) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main(void){
	/*input*/
	string s;
	short x,y;
	cin >> s;
	cin >> x >> y;

	#ifdef DEBUG
		cout << "DEBUG INPUT PRINT\n";
		dump(s);
		dump(x);
		dump(y);
	#endif //DEBUG

	/*input end*/

	/*makeData*/
	VI x_move(1,0),y_move(1,0);
	char mode = 0;
	long sum_x = 0;
	long sum_y = 0;
	long count = 0;

	REP(i,s.size()){
		if (s[i] == 'F') ++count;
		else { 
			if ((s[i] == 'T') && (mode == 0)) {
				x_move.push_back(count);
				sum_x += count;
				count = 0;
				mode = 1;
			}

			else { if ((s[i] == 'T') && (mode == 1)) {
				y_move.push_back(count);
				sum_y += count;
				count = 0;
				mode = 0;
			}}

		}
	}

	if (count != 0){
		if (mode == 0){
			x_move.push_back(count);
			sum_x += count;
		}
		else {
			y_move.push_back(count);
			sum_y += count;
		}
	}

	#ifdef DEBUG
		cout << "DEBUG MOVEARRAY PRINT\n";
		REP(i,x_move.size()) dump(x_move[i]);
		REP(i,y_move.size()) dump(y_move[i]);
	#endif//DEBUG

	/*makeData end*/
	short SX = x_move.size();
	short SY = y_move.size();

	#ifdef DEBUG
	dump(SX);
	dump(SY);
	#endif

	VVI dp_x(SX+1,VI(2*sum_x+1,0));
	VVI dp_y(SY+1,VI(2*sum_y+1,0));

	dp_x[0][sum_x] = 1;
	dp_y[0][sum_y] = 1;

	if (x_move[1] != 0){
		dp_x[2][sum_x + x_move[1]] = 1; 

		FOR(i,2,SX){
			REP(j,2*sum_x+1){
				if (((j + x_move[i]) < (sum_x*2+1)) && ((j - x_move[i]) >= 0))
					dp_x[i+1][j] = ((dp_x[i][j + x_move[i]]) | (dp_x[i][j - x_move[i]]));
				else {
					if ((j + x_move[i]) < (sum_x*2+1))
						dp_x[i+1][j] = (dp_x[i][j + x_move[i]]);

					if ((j - x_move[i]) >= 0)
						dp_x[i+1][j] = (dp_x[i][j - x_move[i]]);
				}
			}
		}
	}

	else {
		REP(i,SX){
			REP(j,2*sum_x+1){
				if (((j + x_move[i]) < (sum_x*2+1)) && ((j - x_move[i]) >= 0))
					dp_x[i+1][j] = ((dp_x[i][j + x_move[i]]) | (dp_x[i][j - x_move[i]]));
				else {
					if ((j + x_move[i]) < (sum_x*2+1))
						dp_x[i+1][j] = (dp_x[i][j + x_move[i]]);

					if ((j - x_move[i]) >= 0)
						dp_x[i+1][j] = (dp_x[i][j - x_move[i]]);
				}
			}
		}
	}

	REP(i,SY){
		REP(j,2*sum_y+1){
			if (((j + y_move[i]) < (sum_y*2+1)) && ((j - y_move[i]) >= 0))
				dp_y[i+1][j] = ((dp_y[i][j + y_move[i]]) | (dp_y[i][j - y_move[i]]));
			else {
				if ((j + y_move[i]) < (sum_y*2+1))
				 	dp_y[i+1][j] = (dp_y[i][j + y_move[i]]);

				if ((j - y_move[i]) >= 0)
					dp_y[i+1][j] = (dp_y[i][j - y_move[i]]);
			}
		}
	}

	#ifdef DEBUG
	REP(i,2*sum_x+1)
		dumpArray(dp_x,SX,i);

	REP(i,2*sum_y+1)
		dumpArray(dp_y,SY,i);
	#endif

	if ((abs(x) > sum_x) || (abs(y) > sum_y))
		cout << "No\n";

	else { if ((dp_x[SX][sum_x + x]) && (dp_y[SY][sum_y + y])) cout << "Yes\n";
		   else { cout << "No\n"; }
	}

	return 0;
}

Measured memory_bytes: 63104
Module module1
  Sub main()
    Dim read() as string = split(Console.ReadLine())
    Dim X = read(0)
    Dim K　= read(1)
    Dim D = read(2)
    
    if X < 0 then
      X = -X
    end if
    
    dim n = X \ D
    if n > K then 
      Console.WriteLine(X - D * K)
    else
      K = K - n
      X = X - n * D
      if K mod 2 = 0 then
        Console.Write(X)
      else
        Console.Write(D-X)
      end if
    end if
  end sub
end module

Measured memory_bytes: 28580
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here 

int main() {
	fast;
	read(a)
	read(b)
	read(c)
	read(d)
	ll m=0;
	while(1){
		if(m%2==0){
			c-=b;
		}
		else a-=d;
		if(c<=0 || a<=0 ) break;
		m++;
	}
	if(c<=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

//ends here 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main()
{
	string S;
	cin >> S;
	int S_ln=S.size();
	if(S.at(S_ln-1)=='s')
	{
		S=S+"es";
	}
	else
	{
		S=S+"s";
	}
	
	cout<< S << endl;
}

Measured memory_bytes: 3628
N, Q = gets.split.map(&:to_i)
seq = gets.chomp
lr = Array.new(Q){gets.split.map(&:to_i)}

cnt = 0
array = Array.new(seq.length, 0)

(seq.length-1).times do |i|
  cnt += 1 if seq[i..i+1].match(/AC/)
  array[i+1] = cnt
end

lr.each do |v|
  puts array[v[1]-1]-array[v[0]-1]
end

Measured memory_bytes: 13820
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007
ll n,k,a[2010];
int main(){
  cin>>n>>k;
  ll ans=0;
  for(int i=0;i<n;i++){
      cin>>a[i];
      for(int j=0;j<i;j++){
	  ans+=(a[j]>a[i]);
      }
  }
  ans*=k;
  ll cnt=0;
  for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	  if(a[j]>a[i])cnt++;
      }
  }
  k=k*(k-1)/2; k%=mod;
  cnt=cnt*k%mod;
  ans+=cnt; ans%=mod;
  cout<<ans<<endl;
  
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;

template<typename T>
struct BIT
{
    const int SIZE;
    const function<T(T,T)> op;
    const T e;
    const function<T(T)> inv;
    vector<T> node;
    
    BIT(const vector<T> &ary, const function<T(T,T)> f, const T e_, const function<T(T)> inv_);
    
    const int least_square(const int k) const
    {
        int tmp=k;
        for(int i=1; 64>i; i<<=1)
            tmp |= (tmp >> i);
        return tmp+1;
    }
    
    const void add(const int k, const T x);
    const T fold(const int k) const;
    const T fold(const int a,const int b) const
    {
        return op(fold(b), inv(a==0?e:fold(a-1)));
    }
    
    /*const void print() const
    {
        REP(i, SIZE)
        cout<<node[i]<<" \n"[i==tree_size-1];
    }*/
};

template<typename T>
BIT<T>::BIT(const vector<T> &ary, const function<T(T,T)> f, const T e_, const function<T(T)> inv_):
SIZE(least_square(ary.size()+1)),op(f),e(e_),inv(inv_)
{
    node=vector<T>(SIZE, e);
    
    for(int i=1;i<=ary.size();i++)
        add(i, ary[i-1]);
}


template<typename T>
const void BIT<T>::add(const int k, const T x) //k...0 origin
{
    for(int j=k+1;j<=SIZE;j+=(j&-j))
        node[j]=op(node[j], x);
}
    
template<typename T>
const T BIT<T>::fold(const int k) const
{
    T tmp=e;
    for(int j=k+1;j>0;j=j&(j-1))
        tmp=op(tmp, node[j]);
    return tmp;
}


#define PLUS [](int p,int q){return p+q;},0,[](int x){return -x;}


int main()
{
    int n,k;
    cin>>n>>k;
    vector<LL> a(n),b(n+1),c(n+1),d(n+1);
    REP(i,n)
    {
        cin>>a[i];
        a[i]-=k;
        c[i+1]=a[i]+c[i];
        d[i+1]=c[i+1];
    }
    sort(ALL(c));
    map<LL,int> mp;
    REP(i,n+1)
    {
        if(mp.find(c[i])==mp.end())
        mp[c[i]]=i;
    }
    REP(i,n+1)
        b[i]=mp[d[i]];

    BIT<int> bit(vector<int>(n+1), PLUS);

    LL ans=0;
    REP(i,n+1)
    {
        //cout<<i<<" "<<d[i]<<" "<<b[i]<<endl;
        ans+=bit.fold(b[i]);
        bit.add(b[i],1);
    }
    cout<<ans<<endl;
}


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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D;
  E = A+B;
  F = C+D;

  if (E < F) {
    cout << "Right" << endl;
  }
  else if (E == F) {
      cout << "Balanced" << endl;
    }
  else {
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int total = 0;
  if (A + B > 2 * C) {
    int n = min(X, Y);
    total += n * 2 * C;
    X -= n;
    Y -= n;
  }

  if (A > 2 * C) {
    total += 2 * C * X;
  } else {
    total += A * X;
  }

  if (B > 2 * C) {
    total += 2 * C * Y;
  } else {
    total += B * Y;
  }

  cout << total << endl;

  return 0;
}

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 61;
constexpr int mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  ll ans = 0;
  for(int a = 1; a*a < N; a++){
    ans++;
    for(int b = a+1; a*b < N; b++){
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <math.h>
using namespace std;
using s64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int n,m;
    cin >> n >> m;
    vector<pair<int, int>> ab;
    rep(i,n){
        int a,b; 
        cin >> a >> b;
        ab.push_back({a,b});
    } 

    sort(ab.begin(),ab.end());

    s64 cnt = 0;
    s64 price = 0;
    for(auto abi:ab)
    {
        s64 a = abi.first;
        s64 b = abi.second;

        if(b+cnt >= m)
        {
            price += (m-cnt) * a;
            cnt += (m-cnt);
            break;
        }
        else
        {
            price += b * a;
            cnt += b;
        }
    }

    cout << price << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int arr_wield[100001],arr_throw[100001];
bool mycompare(const int & a,const int & b)
{
	return a>b;
}
int main()
{
	int N,H,i,pos_t=0,ans=0;
	scanf("%d %d",&N,&H);
	for(i=0;i<N;i++)
	{
		scanf("%d %d",&arr_wield[i],&arr_throw[i]);
	}
	sort(arr_wield,arr_wield+N,mycompare);
	sort(arr_throw,arr_throw+N,mycompare);
	while(H>0)
	{
		if(arr_throw[pos_t]>arr_wield[0])
		{
			H-=arr_throw[pos_t++];
			ans++;
		}
		else
		{
			ans+=H/arr_wield[0];
			ans+=H%arr_wield[0]==0?0:1;
			break;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 1024
def main():
  a, b = list(map(int, input().split()))
  if a < b:
    a, b = b, a
  while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

  print(b)

  return 0


if __name__ == '__main__':
  main()

Measured memory_bytes: 7716
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

double getTime() {
    struct timeval s;
    gettimeofday(&s, NULL);
    return s.tv_sec + s.tv_usec * 1e-6;
}



int main() {
    // 入力を受け取る
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        --A[i]; // 0 以上 N-1 以下になるようにする
    }

    // バケットを作る
    vector<long long> B(N, 0);
    for (int i = 0; i < N; ++i) {
        B[A[i]]++;
    }

    // ここまでできてるかな...を確認
    /*
    for (int i = 0; i < N; ++i) {
        cout << B[i] << ", ";
    }
    cout << endl;
    */

    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += B[i] * (B[i] - 1) / 2;
    }

    for (int i = 0; i < N; ++i) {
        cout << ans - (B[A[i]]-1) << endl;
    }
}


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

#define int long long 
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

signed main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(abs(A-B) <= D && abs(B-C) <= D || abs(A-C) <= D) puts("Yes");
    else puts("No");
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

using BS = bitset<64>;

// copy a
bool check(vector<BS> a, const string& s, int64_t idx) {
    assert(s[idx] == '1');

    int64_t n = s.size();

    BS b = a[idx];
    for (auto i : irange(0L, 64L)) {
        BS t;
        bool found = false;
        for (auto j : irange(idx, n)) {
            if (s[j] == '1') {
                continue;
            }

            if (a[j][i]) {
                if (!found) {
                    found = true;
                    t = a[j];
                    if (b[i]) {
                        b ^= t;
                    }
                }

                a[j] ^= t;
            }
        }

        if (b[i]) {
            return false;
        }
    }

    return true;
}

bool check(const vector<BS>& a, const string& s) {
    int64_t n = s.size();
    for (auto i : irange(0L, n)) {
        if (s[i] == '1') {
            if (!check(a, s, i)) {
                return false;
            }
        }
    }

    return true;
}

int main() {
    int64_t t;
    cin >> t;

    for (auto _ : irange(0L, t)) {
        int64_t n;
        cin >> n;

        vector<bitset<64>> a(n);
        for (auto i : irange(0L, n)) {
            uint64_t aa;
            cin >> aa;
            a[i] = aa;
        }

        string s;
        cin >> s;

        if (!check(a, s)) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
int dp[100008];
vector<vector<int>> adj(100008);
int longestPath(int start){
if(adj[start].size()==0) return 0;
if(dp[start]!=-1) return dp[start];
int mx=0;
for(auto i:adj[start])
mx= max(mx,1+longestPath(i));
return dp[start]=mx;
}
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n,m;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<m;i++){
	int x,y;
	cin>>x>>y;
//	cout<<x<<y;
	adj[x].push_back(y);
	}
//	for(auto i:adj[1])
//		cout<<i;

	int ans=0;
	for(int i=1;i<=n;i++){
	 ans=max(ans,longestPath(i));
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 11052
A = list(map(int, input().split()))
x = A[1] - A[0]
y = A[2] - A[1]
f = 0
for i in range(2):
  B = list(map(int, input().split()))
  if B[1] - B[0] != x or B[2] - B[1] != y:
    f = 1
    break
if f == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 61876
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)
#define trb(k,en,st) for(int k = en; k >= st ; k--)
using namespace std;

//int n = 2;
//
//void add_self(int& a, int b){
//    a += b;
//    if (a >= mod) {
//        a-=mod;
//    }
//}
//
//int mul(int a, int b){
//    int c = a*b;
//    return c%mod;
//}
//
//struct M {
//    vector<vector<int>> t;
//    M(){
//        t.resize(n, vector<int>(n));
//    }
//    M operator * (M& b){
//        M c;
//        tr(i,0, n-1){
//            tr(j,0,n-1){
//                tr(k,0,n-1){
//                    add_self(c.t[i][j] , mul(t[i][k] ,b.t[k][j]));
//                }
//            }
//        }
//        return c;
//    }
//};
//M power(M x, int k){
//    M ans;
//    tr(i,0,n-1){
//        ans.t[i][i] = 1;
//    }
//    while (k) {
//        if (k%2) {
//            ans = ans * x;
//        }
//        x = x*x;
//        k/=2;
//    }
//    return ans;
//}


int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double pi = 3.141592653589793238;
    cout<<setprecision(10)<<2*pi*n<<endl;
    return 0;
}




Measured memory_bytes: 3792
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    cunt_b=0
    ans=0
    for ss in s:
        if ss=='B':
            cunt_b+=1
        else:
            ans+=cunt_b
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3500
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a,b,c,sum;
    scanf("%d%d%d",&a,&b,&c);
    sum=b/a;
    if(sum>c){
        printf("%d\n",c);
    }
    else{
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
!
! The below module was made in reference to 
! https://ufcpp.net/study/algorithm/col_heap.html
!
module heappq
  
  implicit none
  integer(8),allocatable :: hp(:)

contains 
subroutine heapinit(n)
  
  integer, intent(in) :: n

  allocate( hp(n) ); hp = 0

end subroutine heapinit

subroutine heappush( newnp, newn )
  
  integer, intent(in)    :: newn
  integer, intent(in)    :: newnp
  integer :: i,ln, tmp
 
  ln = newn
  hp(ln) = newnp
  
  do while ( ln /= 1 )
    i = ln/2
    if ( hp(i) < hp(ln) ) then
      tmp    = hp(ln) 
      hp(ln) = hp(i) 
      hp(i)  = tmp 
    end if
    ln = i
  end do

end subroutine heappush

subroutine heappop( n )
  
  integer :: i,j,tmp
  integer,intent(in) :: n
  
  hp(1) = hp(n)
  
  i = 1 
  do while ( 2*i < n )
    j = 2*i 
    if ( j /= n - 1 .and. hp(j+1) > hp(j) ) j = j + 1
    if ( hp(i) < hp(j) ) then
      tmp    = hp(j) 
      hp(j) = hp(i) 
      hp(i)  = tmp 
    end if
    i = j
  end do

end subroutine heappop
 
end module heappq

program main
  
  use heappq  

  implicit none ! 02;01
  integer :: n, m
  integer, allocatable :: a(:)
  integer :: i,j, tmp, tmpo
  integer(8) :: money
  
  read(*,*) n,m
  allocate( a(n) )
  read(*,*) a
  
  call heapinit(n)
  
  do i = 1, n
    call heappush( a(i), i )
  end do

  do j = 1, m
    tmp = hp(1) / 2 
    call heappop(n)

    call heappush(tmp, n)

  end do

  a = hp 
  money = 0
  do i = 1, n
    money = money + int( a(i), kind = 8 )
  end do
  print*, money

end program main



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

string S;

void solve(){
    int n=S.size();
    vector<vector<int>> dp(n+1,vector<int>(11,0));
    int ans=0;
    for (int i=0;i<n;++i){
        int x=S[i]-'0';
        if (x) dp[i+1][x]+=1;
        for (int j=0;j<11;++j){
            dp[i+1][(j*10+x)%11]+=dp[i][j];
        }
        ans+=dp[i+1][0];
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> S,S!="0"){
        solve();
    }
}


Measured memory_bytes: 10000
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	ll n,k;
	cin >> n >> k;
	int a[n],b[2010];
	rep(i,2010) b[i] = 0;
	rep(i,n){
		cin >> a[i];
		b[a[i]]++;
	}
	rep(i,2005) b[i+1] += b[i];

	ll ans = 0;

	rep(i,n){
		int tmp=0;
		for(int j=i+1;j<n;j++){
			if(a[i] > a[j])tmp++;
		}
		ans += (((k*(k-1)/2)%MAX)*b[a[i]-1])%MAX+(tmp*k)%MAX;
		ans %= MAX;
		//cout << i << ":";
		//cout << ans << endl;
	}

	//rep(i,5) cout << b[i] << " ";
	//cout << endl;
	cout << ans << endl;
	return 0;
}


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

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

  vector<string> s(H);
  
  for (int i = 0; i < H; i++) {
	cin >> s.at(i);
  }

  // 調べつつ書く
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c = s.at(i).at(j);
      if (c == '.') {
        // 数える
        int sum = 0;
        for (int y = -1; y <= 1; y++) {
          for (int x = -1; x <= 1; x++) {
            if (0 == x && 0 == y) {
              continue;
            }
            int posx = j + x;
            int posy = i + y;
            if (posx < 0 || posy < 0 || posx > (W - 1) || posy > (H - 1)) {
              continue;
            }
            if (s.at(posy).at(posx) == '#')
              sum++;
          }
        }
        cout << sum;
      } else {
        cout << "#";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3644
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	
	void solve() {
		String S = sc.next();
		String T = sc.next();
		
		int[] sumS = new int[S.length() + 1];
		for (int i = 0; i < S.length(); i++) {
			sumS[i+1] = sumS[i] + (S.charAt(i) == 'A' ? 1 : 2);
		}
		int[] sumT = new int[T.length() + 1];
		for (int i = 0; i < T.length(); i++) {
			sumT[i+1] = sumT[i] + (T.charAt(i) == 'A' ? 1 : 2);
		}
		int Q = sc.nextInt();
		for (;Q-->0;) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			int c = sc.nextInt()-1;
			int d = sc.nextInt()-1;
			int x = sumS[b+1] - sumS[a];
			int y = sumT[d+1] - sumT[c];
			String ans = x % 3 == y % 3 ? "YES" : "NO";
			out.println(ans);
		}
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 53560
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int lowbit(int x){return x&-x;}
int f1[1<<19],f2[1<<19],n,N,ans,a[1<<19];
bool cmp(int x,int y){return a[x]<a[y];}
signed main(){
	scanf("%lld",&n);
	N=1<<n;
	scanf("%lld",&a[0]);
	a[N]=-1;
	for (int i=1;i<N;i++){
		scanf("%lld",&a[i]);
        f1[i]=i,f2[i]=N;
		int x[4],y=i;
		while (y){
			int _i=i-lowbit(y);
			x[0]=f1[i],x[1]=f2[i];
			x[2]=f1[_i],x[3]=f2[_i];
			sort(x,x+4,cmp);
			f1[i]=x[3];
			f2[i]=x[2]==x[3]?x[1]:x[2];
			y-=lowbit(y);
		}
		ans=max(ans,a[f1[i]]+a[f2[i]]);
		printf("%lld\n",ans);
    }
}

Measured memory_bytes: 9908
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  cout << ((a-c)*(b-c)<0 ? "Yes" : "No") << endk;
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define Mo(a) (a)>=mo?(a)-=mo:(a)
long long l,r;
const int mo=1e9+7;
int Mem[70][2][2][2],len,R[100],cnt,a,ans,L[100];
long long le;
int DFS(int l,int mark,int h,int f) {//mark=  <l  h= >0  f= <r
//	printf("%d %d %d %d %d %d\n",l,mark,h,f,f?R[l]:1,mark?L[l]:0);
	if(l==0)return h;
	if(~Mem[l][mark][h][f])return Mem[l][mark][h][f];
	int re=0,ma=f?R[l]:1,mi=mark?L[l]:0;
	if(ma) {
		if(mi==0&&h) re+=DFS(l-1,mark&&mi==0,h,f&&ma==1);
		re+=DFS(l-1,mark&&mi==1,1,f&&ma==1);
		Mo(re);
	}
	if(mi==0) {
		re+=DFS(l-1,mark&&mi==0,h,f&&ma==0);
		Mo(re);
	}
	Mem[l][mark][h][f]=re;
	return re;
}
int DO() {
	len=0;
	while(r)R[++len]=r&1,r>>=1;
	le=1;
	for(int i=1; i<=len; i++,le<<=1) L[i]=((l&le)>0);
	return DFS(len,1,0,1);
}
int main() {
	memset(Mem,-1,sizeof(Mem));
	scanf("%lld %lld",&l,&r);
	printf("%d",DO());
	return 0;
}

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

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

    map<ll, ll> A;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A[tmp]++;
        sum += tmp;
    }

    int Q;
    cin >> Q;

    vector<int> B(Q);
    vector<int> C(Q);
    for (int i = 0; i < Q; i++) {
        cin >> B[i] >> C[i];
    }

    for (int i = 0; i < Q; i++) {
        int a = A[B[i]];
        A.erase(B[i]);
        A[C[i]] += a;
        sum = sum + (C[i] - B[i]) * a;

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 7916
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
using namespace std;


int main(int argc, char *args[]) {
	int a[3];
	int b[3];
	int c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
			
		}
	}
	for (int i = 0; i < 3; i++) {
		b[i] = c[0][i];
		
	}
	for (int i = 0; i < 3; i++) {
		a[i] = c[i][0] - b[0];
		
	}
	for(int i = 0;i < 3;i++){
		for (int j = 0; j < 3; j++) {
			if (a[i] + b[j] != c[i][j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

}


Measured memory_bytes: 256
s = input()
t = input()

s2t = dict()
t2s = dict()

flg = True
for i, (ss, tt) in enumerate(zip(s, t)):
    a = s2t.get(ss, None)
    if a is None:
        s2t[ss] = tt
    else:
        if a != tt:
            flg = False
            break

    b = t2s.get(tt, None)
    if b is None:
        t2s[tt] = ss
    else:
        if b != ss:
            flg = False
            break
print('Yes' if flg else 'No')


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

pair<int, int> input(){
    string s; int fst = 0, snd = 0;
    cin >>s;
    fst = stoi(s.substr(0, 2)) *60 + stoi(s.substr(3, 2));
    snd = stoi(s.substr(6, 2)) *60 + stoi(s.substr(9, 2));
    return make_pair(snd, fst);
}

int main(){
    int n, m, p, t, ans = 0;
    bool possible[100010];
    fill(possible, possible + 10010, true);
    vector<pair<int, int> > cl, st, te;

    cin >> p;
    for(int i=0; i< p; i++) cl.push_back(input());

    cin >> n;
    for(int i=0; i< n; i++){
        cin >> p;
        for(int j=0; j < p; j++){
            te.push_back(input());
        }
    }
    cin >> m;
    for(int i=0; i< m; i++){
        cin >> p;
        for(int j=0; j < p; j++){
            st.push_back(input());
        }
    }
    sort(te.begin(), te.end());
    sort(cl.begin(), cl.end());
    sort(st.begin(), st.end());

    for(int i=0; i< cl.size(); i++){
        int t = 0, s = 0;
        for(int j=0; j< te.size(); j++){
            if(te[j].second <= cl[i].second && cl[i].first <= te[j].first) t++;
        }
        for(int j=0; j< st.size(); j++){
            if(st[j].second <= cl[i].second && cl[i].first <= st[j].first) s++;
        }
        ans += min(t, s);
    }
    cout << ans << endl;
}

//cl te st
//720 600 720 540 531 468
//12/0 7/48
//1

Measured memory_bytes: 1440
N = int(input())
L = [list(input()) for i in range(N)]
D = {}
for i in range(len(L)) :
    if i == 0 :
        for j in range(len(L[i])) :
            if L[i][j] not in D :
                D[L[i][j]] = 1
            else :
                D[L[i][j]] += 1
    else :
        for k in D :
            if k not in L[i] :
                D[k] = 0
            else :
                D[k] = min(D[k], L[i].count(k))

D = sorted(D.items(),key=lambda x: x[0])
ANS = []
for i in range(len(D)) :
    ANS.append(D[i][0]*D[i][1])
ans = "".join(ANS)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, ans, f[4005][3];
string s;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>s;
	for(int i = 0; i < n; i++){
		f[i][0] += f[i - 1][0];
		f[i][1] += f[i - 1][1];
		f[i][2] += f[i - 1][2];
		if(s[i] == 'R'){
			f[i + 1][0]++;
			for(int j = 0; j < i; j++){
				if(s[j] == 'G')ans +=f[i][2] - f[j][2] - (((i - j + 1) & 1) && s[((i + j) >> 1)] == 'B');
			}
			for(int j = 0; j < i; j++){
				if(s[j] == 'B')ans +=f[i][1] - f[j][1] - (((i - j + 1) & 1) && s[((i + j) >> 1)] == 'G');
			}
		}
		else if(s[i] == 'G'){
			f[i + 1][1]++;
			for(int j = 0; j < i; j++){
				if(s[j] == 'R')ans +=f[i][2] - f[j][2] - (((i - j + 1) & 1) && s[((i + j) >> 1)] == 'B');
			}
			for(int j = 0; j < i; j++){
				if(s[j] == 'B')ans +=f[i][0] - f[j][0] - (((i - j + 1) & 1) && s[((i + j) >> 1)] == 'R');
			}
		}
		else if(s[i] == 'B'){
			f[i + 1][2]++;
			for(int j = 0; j < i; j++){
				if(s[j] == 'R')ans +=f[i][1] - f[j][1] - (((i - j + 1) & 1) && s[((i + j) >> 1)] == 'G');
			}
			for(int j = 0; j < i; j++){
				if(s[j] == 'G')ans +=f[i][0] - f[j][0] - (((i - j + 1) & 1) && s[((i + j) >> 1)] == 'R');
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3692
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll k;
    cin >> k;
    ll ans[50];
    for(int i = 0; i < 50; i++) ans[i] = i + k/50;
    k %= 50;
    for(int i = 0; i < k; i++){
        for(int j = 0; j < 50; j++){
            if(i==j)    ans[j]+=50;
            else        ans[j]--;
        }
    }
    cout << 50 << endl;
    for(int i = 0; i < 50; i++) cout << ans[i] << " \n"[i+1==50];
    return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
  if i % 2019 == 0:
    ans = 0
    break
  for j in range(L+1, R+1):
    if j % 2019 == 0:
      ans = 0
      break
    ans = min(ans, i * j % 2019)
print(ans)

Measured memory_bytes: 3060