akhauriyash/Code-Regression huggingface dataset:
n, l = (int(x) for x in input().split())
if l > 0:
  print(l * n + n * (n - 1) // 2 - l)
elif l > -n:
  print(l * n + n * (n - 1) // 2)
else:
  print(l * n + n * (n - 1) // 2 - l - n + 1)


Measured memory_bytes: 2940
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let h: Vec<u32> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut ans = 0;
    let mut i = 0;
    while i < n {
        let mut j = i + 1;
        while j < n && h[j - 1] >= h[j] {
            j += 1;
        }
        ans = std::cmp::max(j - i - 1, ans);
        i = j;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 6396
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
  	
	void b() {
		int n = sc.nextInt();
		int[] p = new int[n];
		int cnt = 0;
		for(int i = 0;i < n;i ++) {
			p[i] = sc.nextInt();
		}
		for(int i = 1;i < n - 1;i ++) {
			ArrayList<Integer> part = new ArrayList<>();
			part.add(p[i-1]); 
			part.add(p[i]);
			part.add(p[i+1]);
			part.sort(null);
			if(p[i] == part.get(1)) cnt++;
		}
		System.out.println(cnt);
	}
	
	public static void main(String[] args) {
		new Main().b();
	}

}





Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
string s[10],t[10];
int ds[10];
int as[11],bs[11],cs[11];	// ([{
int at[11],bt[11],ct[11];	// ([{
int dots(string s){
	int N=s.size();
	int x=0;
	rep(i,N){
		if(s[i]!='.') break;
		x++;
	}
	return x;
}
int main(){
	while(true){
		int M,N;
		cin>>M>>N;
		if(M==0) break;
		cin.ignore();
		rep(i,M) getline(cin,s[i]);
		rep(i,N) getline(cin,t[i]);
		rep(i,M) ds[i]=dots(s[i]);
		rep(i,M){
			as[i+1]=as[i],bs[i+1]=bs[i],cs[i+1]=cs[i];
			rep(j,s[i].size()){
				if(s[i][j]=='(') as[i+1]++;
				if(s[i][j]==')') as[i+1]--;
				if(s[i][j]=='[') bs[i+1]++;
				if(s[i][j]==']') bs[i+1]--;
				if(s[i][j]=='{') cs[i+1]++;
				if(s[i][j]=='}') cs[i+1]--;
			}
		}
		rep(i,N){
			at[i+1]=at[i],bt[i+1]=bt[i],ct[i+1]=ct[i];
			rep(j,t[i].size()){
				if(t[i][j]=='(') at[i+1]++;
				if(t[i][j]==')') at[i+1]--;
				if(t[i][j]=='[') bt[i+1]++;
				if(t[i][j]==']') bt[i+1]--;
				if(t[i][j]=='{') ct[i+1]++;
				if(t[i][j]=='}') ct[i+1]--;
			}
		}
		set<int> ans[10];
		rep1(A,20) rep1(B,20) rep1(C,20){
			bool ok=1;
			rep(i,M){
				if(A*as[i]+B*bs[i]+C*cs[i]!=ds[i]){
					ok=0;
					break;
				}
			}
			if(ok) rep(i,N) ans[i].insert(A*at[i]+B*bt[i]+C*ct[i]);
		}
		rep(i,N){
			if(ans[i].size()==1) cout<<*ans[i].begin()<<(i==N-1?"\n":" ");
			else cout<<-1<<(i==N-1?"\n":" ");
		}
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>  
using namespace std;
typedef long long ll;
const ll M=1000000007;
int n,k,a[100005],i,j;
ll ans;
int main()
{
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(a[i]>a[j])
				if(i>j)
					ans=(ans+1ll*k*(k-1)/2)%M;
				else
					ans=(ans+1ll*k*(k+1)/2)%M;
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
int n;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	if(n==3)return cout<<2<<" "<<5<<" "<<63<<endl,0;
	if(n==4)return cout<<2<<" "<<5<<" "<<20<<" "<<63<<endl,0;
	for(int i=min(n-1,15000);i>=1;i--)
	{
		if((n-i)%2==0&&((i%3==0)||i%3==2))
		{
			for(int j=1;j<=i;j++)printf("%d ",j*2);
			for(int j=1;j<=n-i;j++)printf("%d ",j*6-3);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int i,j,k;
		i = s.nextInt();
		j = s.nextInt();
		k = s.nextInt();
		int a[][] = new int[i][j];
		int b[][] = new int[j][k];
		for(int cnti = 0;cnti < i;cnti++){
			for(int cntj = 0;cntj < j;cntj++){
				a[cnti][cntj] = s.nextInt();
			}
		}
		for(int cntj = 0;cntj < j;cntj++){
			for(int cntk = 0;cntk < k;cntk++){
				b[cntj][cntk] = s.nextInt();
			}
		}
		long ans = 0;
		for(int cnti = 0;cnti < i;cnti++){
			for(int cntk = 0;cntk < k;cntk++){
				ans = 0;
				for(int cntj = 0;cntj < j;cntj++){
					ans += a[cnti][cntj] * b[cntj][cntk];
				}
				System.out.print(ans);
				if(cntk < k - 1){
					System.out.print(" ");
				}
			}
			System.out.println("");
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 54336
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int fact[200000], invfact[200000];

int invmod(int a, int p){ // a^-1 mod p
  int b = p, u = 1, v = 0;
  while(b){
    int t = a / b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= p;
  if(u < 0) u += p;
  return u;
}

void factmod(int m){
  fact[0] = invfact[0] = 1;
  for(int i = 1; i < 200000; i++){
    fact[i] = (fact[i-1] * i) % m;
    invfact[i] = (invfact[i-1] * invmod(i, m)) % m;
  }
}

int nCrmod(int n, int r, int m){
  return (((fact[n] * invfact[r]) % m) * invfact[n-r]) % m;
}

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

  int N, K, A[100000]; cin >> N >> K;
  REP(i, N) cin >> A[i];
  sort(A, A+N);
  factmod(MOD);
  int P = 0, Q = 0;
  for(int i = 0; i <= N-K; i++){
    Q += (A[i] * nCrmod(N-1-i, K-1, MOD)) % MOD;
    Q %= MOD;
  }
  for(int i = K-1; i < N; i++){
    P += (A[i] * nCrmod(i, K-1, MOD)) % MOD;
    P %= MOD;
  }
  cout << (P+MOD-Q) % MOD << endl;
}


Measured memory_bytes: 4224
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();

		if(S.length()<=K) {
			System.out.println(S);
		}else {
			System.out.println(S.substring(0,K)+"...");
		}




	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 38632
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n, r;
  cin >> n >> r;
  if (n >= 10)
    cout << r << endl;
  else
    cout << r + 100 * (10 - n) << endl;
  return 0;
}


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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int nums[10][10];

int main() {
    int n;
    int ans;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        string s = to_string(i);
        nums[int(s[0] - '0')][int(s[s.size() - 1] - '0')] += 1;
    }

    rep(i, 10) rep(j, 10) {
        ans += nums[i][j] * nums[j][i];
    }

    cout << ans << endl;
}


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

int main(){
	int x,y,step,tmp;
	while(true){
		cin >> x >> y;
		
		if(!x && !y)
			break;
			
		if(x < y){
			tmp = x;
			x = y;
			y = tmp;
		}
		step = 0;
		
		while(y != 0){
			step++;
			
			x = x%y;
			
			tmp = x;
			x = y;
			y = tmp;
			
			if(!y)
				break;
		}
		cout << x << ' ' << step << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest;

  l = 2 * i;
  r = 2 * i + 1;

  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if (H < 1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if (key < A[i]) return;
  A[i] = key;
  while (i > 1 && A[i/2] < A[i]) {
    swap(A[i], A[i/2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  char com[10];

  while (1) {
    cin >> com;
    if (com[0] == 'e' && com[1] == 'n') break;
    if (com[0] == 'i') {
      cin >> key;
      insert(key);
    } else {
      cout << extract() << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;

ll divisor=1e9+7;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if((2*a[2]-a[1]-a[0])%2==1){
		puts((2*a[2]-a[1]-a[0])/2+2);
	}else{
		puts((2*a[2]-a[1]-a[0])/2);
	}
}

Measured memory_bytes: 256
global count


def merge(arr, l, mid, r):
    arr_l = list(arr[l:mid + 1])
    arr_r = list(arr[mid + 1:r + 1])
    l_index = 0
    r_index = 0
    arr_l.append(2 << 64)
    arr_r.append(2 << 64)
    global count
    for i in range(l, r + 1):
        if arr_l[l_index] <= arr_r[r_index]:
            arr[i] = arr_l[l_index]
            l_index += 1
        else:
            arr[i] = arr_r[r_index]
            r_index += 1
        count += 1


def merge_sort(arr, l, r):
    if l >= r:
        return
    mid = (l + r) // 2
    merge_sort(arr, l, mid)
    merge_sort(arr, mid + 1, r)
    merge(arr, l, mid, r)


if __name__ == '__main__':
    count = 0

    n = int(input())
    arr = list(map(int, input().split()))
    merge_sort(arr, 0, len(arr) - 1)
    for i in range(n):
        if i != n - 1:
            print(arr[i], end=' ')
        else:
            print(arr[i])
    print(count)



Measured memory_bytes: 61656
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
int n,a[15],c[15];
vector<int> v[100000];
int ans;
void doit(int k,int b[15])
{
    if(k==n)
    {
        bool flag=0;
        for(int i=0;i<n;i++)
        {
            if(b[i]%2==0)
            {
                flag=1;
                break;
            }
        }
        ans+=flag;
        return;
    }
    for(int i=a[k]-1;i<=a[k]+1;i++)
    {
        b[k]=i;
        doit(k+1,b);
    }
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    doit(0,c);
    cout<<ans<<endl;
    return 0;
}


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

struct SegmentTree{
	vector<long long> seg, lazy;
	int sz;

	SegmentTree(int n){
		sz = 1;
		while(sz < n) sz *= 2;
		seg.assign(2 * sz, 0);
		lazy.assign(2 * sz, 0);
	}

	void push(int k, int len){
		if(k < sz){
			lazy[2 * k + 1] += lazy[k];
			lazy[2 * k + 2] += lazy[k];
		}

		seg[k] += lazy[k] * len;
		lazy[k] = 0;
	}

	void update(int k,int x){
		k += sz - 1;
		seg[k] = x;
		while(k){
			k = (k - 1) / 2;
			seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
		}
	}

	long long get(int a,int b){
		return _get(a, b, 0, 0, sz);
	}

	long long _get(int a, int b, int k, int l, int r){
		push(k, r - l);
		if(b<=l||r<=a) return 0;
		if(a<=l&&r<=b) return seg[k];

		return _get(a, b, 2 * k + 1, l, (l + r) / 2) + _get(a, b, 2 * k + 2, (l + r) / 2, r);
	}

	void add(int a, int b, int x){
		_add(a, b, 0, 0, sz, x);
	}

	void _add(int a, int b, int k, int l, int r, int x){
		push(k, r - l);
		if(b<=l||r<=a) return ;
		if(a<=l&&r<=b){
			lazy[k] += x;
			push(k, r - l);
			return ;
		}
		
		_add(a, b, 2 * k + 1, l, (l + r) / 2, x);
		_add(a, b, 2 * k + 2, (l + r) / 2, r, x);
		seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
	}
};

int main(){
	int n,q;
	cin >> n >> q;
	SegmentTree seg(n);
	
	for(int i = 0;i < q;i++){
		int a;
		cin >> a;
		
		if(a == 0){
			int b, c, d;
			cin >> b >> c >> d;

			seg.add(b-1, c, d);
		}else if(a == 1){
			int b, c;
			cin >> b >> c;

			cout << seg.get(b-1, c) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 7004
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#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;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int n;

string query(const vector<int> &a) {
  cout << "? ";
  REP(i, n) {
    cout << a[i] + 1;
    if (i + 1 == n) {
      cout << endl;
    } else {
      cout << ' ';
    }
  }
  string t; cin >> t;
  if (t == "-1") assert(false);
  return t;
}

string query(int l) {
  vector<int> a(n);
  iota(ALL(a), l);
  return query(a);
}

int main() {
  cin >> n;
  int lb = 0, ub = n;
  string l = query(lb), r = query(ub);
  while (ub - lb > 1) {
    int mid = (lb + ub) / 2;
    (query(mid) == l ? lb : ub) = mid;
  }
  vector<char> ans(n * 2, '?');
  ans[lb] = (l == "Red" ? 'R' : 'B');
  ans[lb + n] = (ans[lb] == 'R' ? 'B' : 'R');
  FOR(i, lb + 1, lb + n) {
    vector<int> a;
    FOR(j, lb, i) a.emplace_back(j);
    FOR(j, i + 1, lb + n + 1) a.emplace_back(j);
    string t = query(a);
    if (ans[lb] == 'R') {
      ans[i] = (t == "Red" ? 'B' : 'R');
    } else { // B
      ans[i] = (t == "Blue" ? 'R' : 'B');
    }
  }
  vector<int> same;
  int red = 0, blue = 0;
  FOR(i, lb, lb + n + 1) {
    if (ans[i] == 'R') {
      if (red < (n - 1) / 2) {
        same.emplace_back(i);
        ++red;
      }
    } else {
      if (blue < (n - 1) / 2) {
        same.emplace_back(i);
        ++blue;
      }
    }
  }
  REP(i, n * 2) {
    if (ans[i] == '?') {
      same.emplace_back(i);
      ans[i] = (query(same) == "Red" ? 'R' : 'B');
      same.pop_back();
    }
  }
  cout << "! ";
  REP(i, n * 2) cout << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 724
N, M = map(int, input().split())
A = tuple(map(int, input().split()))
mini = 10**10
bnf = 0
cnt = 1
for i in range(N):
	mini = min(mini, A[i])
	_bnf = A[i] - mini
	if _bnf > bnf:
		bnf = _bnf
		cnt = 1
	elif _bnf == bnf:
		cnt += 1
print(cnt)

Measured memory_bytes: 14356
n=int(input())
a=list(map(int,input().split()))

cnt=0
aa=[]
for item in a:
  if item<0:
    cnt+=1
    aa.append(-1*item)
  else:
    aa.append(item)
    
if cnt%2==1:
  print(sum(aa)-2*min(aa))
else:
  print(sum(aa))

Measured memory_bytes: 65184
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

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

void Solve() {
	ULL a, b; cin >> a >> b;
	cout << (a * b / gcd(a, b)) << endl;
}
int main() { Solve(); return 0; }


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
long long n;
long long len(long long x)
{
	int size=0;
	while(x)
	{
		size++;x/=10;
	}
	return size;
}
int main()
{
	cin>>n;
	long long b=sqrt(n);
	for(long long i=b;i>=1;i--)
	{
		if(n%i==0){
			cout<<max(len(i),len(n/i));
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b&&a>c)printf("%d",b*c/2);
    else if(b>a&&b>c)printf("%d",a*c/2);
    else if(c>b&&c>a)printf("%d",a*b/2);
    
}

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

using ll = long long;

int main() {
  ll n;
  cin >> n;
  
  if(n == 0){
    cout << 0 << "\n";
    return 0;
  }
  
  vector<int> x;
  ll i = 1;
  while(n != 0){
    if(n % (ll) pow(-2, i) == 0){
      x.push_back(0);
    }
    else{
      x.push_back(1);
      n -= (ll) pow(-2, i - 1);
    }
    i++;
  }
  
  for(int i = x.size() - 1; i >= 0; i--) cout << x.at(i);
  cout << "\n";
}

Measured memory_bytes: 256
# coding:utf-8

import sys


input = sys.stdin.readline


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


def solve():
    H, W, h, w = inpl()

    if H % h == 0 and W % w == 0:
        print('No')
        return -1

    ans = [[1000] * W for _ in range(H)]
    cnt = 0
    for i in range(h - 1, H, h):
        for j in range(w - 1, W, w):
            ans[i][j] = -(h * w - 1) * 1000 - 1
            cnt += 1

    print('Yes')
    for row in ans:
        print(' '.join(map(str, row)))

    return 0


solve()


Measured memory_bytes: 10356
/* ex3_2
   kohei_suzuki */

#include <stdio.h>
int main(void){
    int n, m;

    scanf("%d",&n);
    m = n % 10; //nの一の位を取り出す

    if(m==0 || m==1 || m==6 || m==8){ //mが0,1,6,8の場合
        printf("pon\n");
    }else if(m == 3){ //mが3の場合
        printf("bon\n");
    }else{ //mが2,4,5,7,9の場合
        printf("hon\n");
    }

    return 0;
}

Measured memory_bytes: 1636
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
    void BubbleUp(int Index)
    {
        assert(FArray.size() > Index);
        int Parent;
        while(Index != 1){
            Parent = Index / 2;
            if(FArray[Index] <= FArray[Parent]) return;
            std::swap(FArray[Index], FArray[Parent]);
            Index = Parent;
        }
    }
    void BubbleDown(int Index)
    {
        assert(FArray.size() > Index);
        int Left  = Index * 2;
        int Right = Index * 2 + 1;
        if(Left  >= FArray.size()) return;
        
        int Target = Right >= FArray.size() ? Left : FArray[Left] > FArray[Right] ? Left : Right;
        if(FArray[Target] > FArray[Index]){
            std::swap(FArray[Index], FArray[Target]);
            BubbleDown(Target);
        }
    }
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        FArray.push_back(Value);
        BubbleUp(FArray.size()-1);
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();
        if(FArray.size() == 1) return; // dummy???????????????
        BubbleDown(1);
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6236
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

template<class T>
T pow(T x, ll n, T r = 1) {
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

struct Perm {
    //i -> a[i]
    vector<int> a;
    Perm(int n) {
        a = vector<int>(n);
        iota(begin(a), end(a), 0);
    }
    Perm(vector<int> a) : a(a) {}
    Perm operator*(const Perm &r) const {
        int n = int(a.size());
        Perm res(n);
        for (int i = 0; i < n; i++) {
            res.a[i] = r.a[a[i]];
        }
        return res;
    }
    Perm& operator*=(const Perm &r) {
        return *this = *this*r;
    }
};


using R = double;
const int MN = 100100;
struct Solver {
    R p[MN], d[MN];
    int q[MN];    
    void solve();
};
void Solver::solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n-1; i++) {
        d[i] = p[i+1]-p[i];
    }
    int m; ll k;
    cin >> m >> k;
    Perm v(n-1);
    for (int i = 0; i < m; i++) {
        int c;
        cin >> c; c--;
        swap(v.a[c-1], v.a[c]);
    }
    Perm u = pow(v, k, Perm(n-1));
    R st = p[0];
    cout << st << endl;
    for (int i = 0; i < n-1; i++) {
        st += d[u.a[i]];
        cout << st << endl;
    }
}

int main() {
    cout << setprecision(20);
#ifdef LOCAL
    const string ProbName = "A";
    const int T = 3;
    for (int i = 0; i < T; i++) {
        string fname = ProbName + "in" + to_string(i) + ".txt";
        freopen(fname.c_str(), "r", stdin);
        cerr << "## Start " << i << endl;
        Solver s; s.solve();
    }
#else
    Solver s;
    s.solve();
#endif
    return 0;
}

Measured memory_bytes: 3740
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
int a,s,d,f=0,g,h,j,i;
scanf("%d",&a);
for(i=0;i<a;i++){
scanf("%d %d",&s,&d);
f+=d-s+1;
}
printf("%d\n",f);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <iostream>
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) repi(i,0,a)
using namespace std;
 
using ll = long long;
 
int main() {
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

void solver(int N, vector<int> &h, int &ans){

    int ans_buf = h.at(0);
    for(int i = 0; i != N-1; ++i){
        int dif_value{};
        dif_value = h.at(i+1) - h.at(i);

        if(dif_value > 0) ans_buf += dif_value;
    }
    ans = ans_buf;

    return;
}

int main(){

    int N;
    cin >> N;
    vector<int> h(N);
    for(int i = 0; i != N; ++i) cin >> h.at(i);

    int ans{};
    solver(N, h, ans);

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

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

int main() {
  string S[3];
  for (int i = 0; i < 3; ++i) cin >> S[i];
  
  vector<vector<int>> cards(3);
  for (int i = 0; i < 3; ++i) {
    for (auto &c : S[i]) {
      int n = -1;
      if (c == 'a') n = 0;
      if (c == 'b') n = 1;
      if (c == 'c') n = 2;
      cards[i].emplace_back(n);
    }
  }
  
  for (int i = 0; i < 3; ++i) reverse(cards[i].begin(), cards[i].end());
  int now = 0;
  while (1) {
    if (cards[now].empty()) break;
    int tmp = cards[now].back();
    cards[now].pop_back();
    now = tmp;
  }

  char ans[3] = {'A', 'B', 'C'};
  cout << ans[now] << endl;
}


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

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

    int g[15][15];
    rep(i, N) rep(j, N) g[i][j] = -1;
    rep(i, N) {
        int A;
        cin >> A;
        rep(j, A) {
            int x, y;
            cin >> x >> y;
            x--;
            g[i][x] = y;
        }
    }

    int ans = 0;
    rep(i, 1 << N) {
        vector<int> d(N);
        rep(j, N) if (i >> j & 1) {
            d[j] = 1;
        }
        bool ok = true;
        rep(j, N) if (d[j]) {
            rep(k, N) {
                if (g[j][k] == -1) continue;
                if (g[j][k] != d[k]) ok = false;
            }
        }
        if (ok) ans = max(ans, __builtin_popcount(i));
    }

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


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let h = iter.next().unwrap().parse::<usize>().unwrap();
    let _n = iter.next().unwrap().parse::<usize>().unwrap();

    let mut a_sum = 0_usize;
    for a in iter {
        a_sum += a.parse::<usize>().unwrap();
    }

    if a_sum >= h {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<int>in(n);
    rep(i,n)cin>>in[i];
    int ba=32;
    int i=0;;
    bool bn=true;
    while(ba){
      if(bn){
	ba-=(ba-1)%5;
	if(ba<0)ba=0;
	cout<<ba<<endl;
	bn^=1;
      }else{
	ba-=in[i];
	i++;
	if(i==n)i=0;
	if(ba<0)ba=0;
	cout<<ba<<endl;
	bn^=1;
      }
    }
  }
}

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

int main() { 
  int K, A, B, x;
  x = 0;
  cin >> K >> A >> B;
  for( int i = A; i <= B; i++){
    if(i%K == 0) {cout << "OK" << endl;
                 break;}
    else {x += 1;}
  }
  if (x == B - A + 1){
    cout << "NG" << endl;
  }
}
    

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#ifdef LL
const ll inf = 1e9;
#else 
const ll inf = 1e18;
#endif

const int mod = 1e9 + 7;
const int mod2 = 998244353;

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

// lower bound returns first element greater than the value

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ transform(s.begin(), s.end(), s.begin(), ::toupper); return s; }
template <typename T>
T to_lower(T s){ transform(s.begin(), s.end(), s.begin(), ::tolower); return s; }



int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    int n;
    cin>>n;

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

    vvi sums(n+1, vi(n+1));
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j++)
        {
            if(i==j) sums[i][j] = a[i-1];
            else sums[i][j] = sums[i][j-1] + a[j-1];
        }
    }

    //dp[i][j] is the answer for the range i to j

    vvi dp(n+1, vi(n+1, inf));
    for(int i=n;i>0;i--)
    {
        for(int j=i;j<n+1;j++)
        {
            if(i==j) dp[i][j]=0;
            else
            {
                for(int k=i;k<j;k++)
                {
                    dp[i][j] = min(dp[i][j], sums[i][k]+sums[k+1][j] + dp[i][k]+dp[k+1][j]);
                }
            }
        }
    }

    cout<<dp[1][n]<<endl;

    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


Measured memory_bytes: 5812
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		boolean f = true;
		for(i = 0; i < s.length; i++) {
			if(i%2==0) {
				if(s[i] == 'L') {
					f = false;
					break;
				}
			} else {
				if(s[i] == 'R') {
					f = false;
					break;
				}
			}
		}
		out.println(f?"Yes":"No");
	}
}


Measured memory_bytes: 23764
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register LL
#define RC register char
#define ed puts("") 
#define pair pair<LL,LL>
#define space putchar(' ') 
#define lson l,mid,rt<<1 
#define rson mid+1,r,rt<<1|1  
using namespace std;   
template <typename tp> inline void read(tp & x) 
{	
    x=0;
    RI f=1; 
    RC c=getchar();  
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); } 
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	
    	
template <typename Tp> inline void print(Tp x)  
{			
    if(x<0) x=-x,putchar('-'); 
    if(x>9) print(x/10);
    putchar(x%10+'0');
} 

int n,d;
int ans;
int temp;

int main()
{
	read(n),read(d);
	for(RI i=1;;i++)
	{
		temp+=2*d+1;
		if(temp>=n)
		{
			print(i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    a = list()
    for i in map(int, input().split()):
        a.append(i)

    if len(list(set(a))) == 2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main() {

	string s; int i,n;
	cin>>n>>s;
	if(n%2!=0) { cout<<"No"<<endl; return 0; }
	for(i=0;i<n/2;i++) {
		if(s[i]!=s[(n/2)+i]) {
			cout<<"No"<<endl; break;
		}
	}
	if(i==n/2) cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,temp;
    cin>>a>>b>>c;
    temp=a;
    a=b;
    b=temp;
    temp=a;
    a=c;
    c=temp;
    cout<<a<<' '<<b<<' '<<c;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int hour,minute,second,rest,rh,rm,rs;
    while (1) {
        scanf("%d %d %d\n",&hour,&minute,&second);
        if (hour==-1&&minute==-1&&second==-1) break;
        rest=7200-(hour*3600+minute*60+second);
        rh=rest/3600;
        rest%=3600;
        rm=rest/60;
        rs=rest%60;
        printf("%02d:%02d:%02d\n",rh,rm,rs);
        rest=(7200-(hour*3600+minute*60+second))*3;
        rh=rest/3600;
        rest%=3600;
        rm=rest/60;
        rs=rest%60;
        printf("%02d:%02d:%02d\n",rh,rm,rs);
    }
    return 0;
}

Measured memory_bytes: 616
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	ll n, m;
	cin >> n >> m;
	ll ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

#define MOD 10000

int main(void)
{
    int dp[101][4][2];
    int i, j, k;
    int sch[101];
    int n, m;
    int ans;
    
    memset(sch, 0, sizeof(sch));
    
    scanf("%d%d", &n, &m);
    
    for (i = 0; i < m; i++){
        scanf("%d%d", &j, &k);
        sch[j] = k;
    }
    
    memset(dp, 0, sizeof(dp));
    
    for (i = 1; i <= 3; i++){
        if (sch[1]){
            dp[1][sch[1]][0] = 1;
        }
        else {
            dp[1][i][0] = 1;
        }
    }
    
    for (i = 2; i <= n; i++){
        for (j = 1; j <= 3; j++){
            if (sch[i]){
                dp[i][sch[i]][0] = (dp[i - 1][(sch[i] + 1) % 3 + 1][0] + dp[i - 1][(sch[i] + 1) % 3 + 1][1] + dp[i - 1][sch[i] % 3 + 1][0] + dp[i - 1][sch[i] % 3 + 1][1]) % MOD;
                dp[i][sch[i]][1] = dp[i - 1][sch[i]][0] % MOD;
            }
            else {
                dp[i][j][0] = (dp[i - 1][(j + 1) % 3 + 1][0] + dp[i - 1][(j + 1) % 3 + 1][1] + dp[i - 1][j % 3 + 1][0] + dp[i - 1][j % 3 + 1][1]) % MOD;
                dp[i][j][1] = dp[i - 1][j][0] % MOD;
            }
        }
    }
    
    ans = 0;
    for (i = 1; i <= 3; i++){
        ans += dp[n][i][0] + dp[n][i][1];
        ans %= MOD;
    }
    
    printf("%d\n", ans);
    
    return (0);
}

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

int main()
{
  int a;
  cin >> a;
  vector<int> array(a);
  vector<int> array2(a);

  for (int i = 0; i < a; i++)
  {
    cin >> array[i];
    array2[i] = array[i];
  }

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

  int cnt = 0;
  for (int i = 0; i < a; i++)
  {
    if (array[i] != array2[i])
    {
      cnt++;
    }
  }
  if (cnt < 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if (a < b) {
        if ( b < c) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<fstream>
#include<algorithm>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int height[100000] ={0};
    int aux = n;
    int i=0;
    while(n)
    {
        int x;
        cin >> x;
        height[i] = x;
        i++;
        n--;
    }
    n = aux;
    int miniCost[100000] = {0};
    if(height[1] - height[0] >= 0)
        miniCost[1] = height[1] - height[0];
    else miniCost[1] = height[0] - height[1];
    for(int i = 2; i <= n; i++)
    {
        if(miniCost[i - 2] + abs(height[i] - height[i - 2]) < miniCost[i - 1] + abs(height[i] - height[i - 1]))
            miniCost[i] = miniCost[i - 2] + abs(height[i] - height[i - 2]);
        else
            miniCost[i] =  miniCost[i - 1] + abs(height[i] - height[i - 1]);
    }
    cout << miniCost[n -1];
}

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

const int N = 1000 + 5;

#define st first
#define nd second

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

int dx[4] = {-1, 1, 1, -1};
int dy[4] = {1, 1, -1, -1};
int color[N][N];
int n, m, d, r;

void maluj(int x, int y, int c) {
	if (x < 0 || x >= N || y < 0 || y >= N) return;
	color[x][y] = c;
}

char farba(int x) {
	switch (x) {
		case 1 : return 'R';
		case 2 : return 'G';
		case 3 : return 'B';
		case 4 : return 'Y';
	}
	return '.';
}

int main() {
	scanf("%d%d%d", &n, &m, &d);
	if (d % 2) {
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				color[i][j] = (i + j) % 2 + 1;
			}
		}
	} else {
		r = d/2;
		for (int i = 0; d * (i-1) < n; i ++) {
			int x = d * i;
			for (int j = 0; d * (j-1) < m; j ++) {
				int y = d * j - 1;
				for (int m = 0; m < r; m ++) {
				for (int k = 0; k < r - m; k ++) {
					for (int a = 0; a < 4; a ++) {
						maluj(x + dx[a] * m, y + k * dy[a], (i + j) % 2 + 1);
						maluj(x + dx[a] * m, y + k * dy[a] + 1, (i + j) % 2 + 1);
						
						maluj(x + r + dx[a] * m, y + k * dy[a] + r, 2 + (i + j) % 2 + 1);
						maluj(x + r + dx[a] * m, y + k * dy[a] + r + 1, 2 + (i + j) % 2 + 1);
					}
				}
				}
			}
		}
	}
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			printf("%c", farba(color[i][j]));
		}
		printf("\n");
	}
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  srep(a,1,n+1){
    ans+=(n-1)/a;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S, T;
  cin>>S>>T;
  cout<<T+S<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;import java.math.*;class Main{public static void main(String[]_){Scanner S=new Scanner(System.in);for(BigInteger a,b,c;S.hasNext();System.out.println(c+" "+a.multiply(b).divide(c))){a=S.nextBigInteger();b=S.nextBigInteger();c=a.gcd(b);}}}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define vi vector<int> 
#define vl vector<ll> 
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vpll vector<pair<ll,ll>>
#define umap unordered_map
#define uset unordered_set
#define all(c) c.begin(), c.end()
#define maxarr(A) *max_element(A, A+n) 
#define maxvec(v) *max_element(all(v)) 
#define minarr(A) *min_element(A, A+n);
#define minvec(v) *min_element(all(v));
#define lb(v,elem) lower_bound(all(v),elem)
#define ub(v,elem) upper_bound(all(v),elem)
#define pb push_back 
#define ff first 
#define ss second
#define sz(z) (int)z.size()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; i--)
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define debug(v) for(ll i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define debugn(v,n) for(ll i=0; i<n; i++) cout<<v[i]<<" "; cout<<endl;
#define deb(sum) cout<<"sum = "<<sum<<endl;
#define mod 1000000007
#define INF (ll)1e18
#define endl "\n"
#define pi 3.142857142857143

  
ll binpow(ll a, ll b) {
	if (b == 0)
		return 1;
	ll res = binpow(a, b / 2);
	if (b % 2)
		return res * res * a;
	else
		return res * res;
}

ll modexpo(ll x, ll y, ll p){  
	ll res = 1;  
	x = x % p; 
	if (x == 0) return 0;
	while (y > 0){   
		if (y & 1)  
			res = (res*x) % p;  
		y = y>>1;
		x = (x*x) % p;  
	}  
	return res;  
}

vector<int> getPrimes(int M){
	
	vi p(M,1);
	vector<int>prime;
	for(int i=2; i*i <= M; ++i){
		if(p[i]){
			for(int j = i*i; j<=M; j+=i) 
				p[j] = 0;
		}
	}
	rep(i,2,M) if(p[i]) prime.push_back(i);
	return prime;
}


int main() { 
	FASTIO;
	//freopen("1.in","r",stdin);
	//vi pm = getPrimes(100005);
	int t=1;
	//cin>>t; 
	while(t--){
		int n,k;
		cin>>n>>k;
		vi a(n);
		rep(i,0,n) cin>>a[i];
		sort(all(a));
		ll sm=0;
		rep(i,0,k) sm += a[i];
		cout<<sm<<endl;
	}

  return 0;
} 


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

using Graph = vector<vector<int>>;
bool visited[10];  // 既に見たことがある頂点か記録
bool flag; //判別

int dfs(const Graph &G, int v, int N,bool visited[10]){

    flag = true;
    for (int i = 1; i <= N; i++) {
        if(visited[i] == false) flag = false;
    }
    if(flag) return 1;

    int sum = 0;
    for (auto next : G[v]){
        if(visited[next]) continue; // 訪問済みでなければ探索
        visited[next] = true;
        sum += dfs(G, next, N, visited);
        visited[next] = false;
    }

    return sum;
}
 
int main() {
    int N, M;
    cin >> N >> M;
    int a, b;
    Graph G(N + 1);
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    visited[1] = true;
    ans = dfs(G, 1, N,visited);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256