akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	vector<ll> A(N);
	forn(i,0,N)cin >> A[i];
	ll dinero = 1000;
	ll cnt = 0;
	ll res = dinero;
	forn(i,0,N-1){
		if(A[i] < A[i+1]){
			ll puedo = dinero/A[i];
			
			cnt += puedo;
			dinero -= puedo*A[i];
			
			dinero += cnt*A[i+1];
			cnt = 0;
			res = max(res,dinero);
		}
		//else if(A[i] > A[i+1]){
			//ll puedo = dinero/A[i+1];
			//cnt += puedo;
			//dinero -= puedo*A[i+1];
		//}
		//cout << dinero << ' ' << cnt << '\n';
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3644
n = int(input())
lst = list(map(int, input().split()))
s = sum(lst)
ans = None
a = 0
for i, num in enumerate(lst):
  if i == len(lst)-1:
    break
  a = a + num
  b = s - a
  if not ans or abs(a-b) < ans:
    ans = abs(a-b)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>
#include <math.h>
using namespace std;

#define INT_MAX 2002
int ret;
int H,W;
char S[INT_MAX][INT_MAX];
short matrix[INT_MAX][INT_MAX];

void debug_print(){
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            printf("%d", matrix[i][j]);
        }
        
        printf("\r\n");
    }
}

int main(){
    
    // int col[INT_MAX][INT_MAX]={0};
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++){
        scanf("%s", S[i]);
        S[i][W] = '#';
    }
    for (int i = 0; i < W; i++){
        S[H][i] = '#';
    }
    int first,last;
    for(int i = 0; i < H; i++){
        first=-1, last=-1;
        for(int j = 0; j <= W; j++){
            if (S[i][j] == '#' && first > last){
                // printf("(%d,%d)\r\n", i, j);
                for(int k = first; k<j; k++){
                    matrix[i][k] += j-first;
                }
                last = j;
                first = j;
            }else if(S[i][j] != '#'){
                if(first <= last){
                    first = j;
                }
            }
        }
    }
    // debug_print();
    for(int i = 0; i < W; i++){
        first=-1, last=-1;
        for(int j = 0; j <= H; j++){
            if (S[j][i] == '#' && first > last){
                // printf("(%d,%d)\r\n", i, j);
                for(int k = first; k<j; k++){
                    matrix[k][i] += j-first;
                }
                last = j;
                first = j;
            }else if(S[j][i] != '#'){
                if(first <= last){
                    first = j;
                }
            }
        }
    }
    int max = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(matrix[i][j] > max){
                max = matrix[i][j];
            }
        }
    }
    printf("%d\r\n", max-1);
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 12032
var lines = [];
var MOD = Math.pow(10, 9) + 7


var readline = require("readline");
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on("line", function (x) {
    lines.push(x);
});

rl.on("close", function () {
    var N = Number(lines[0]);

    // AGC, ACG, GAC, A?GC, AG?C はNG
    // 0: A, 1: C, 2: G, 3: T
    var dp = Array(N + 1).fill(0).map(value => value = Array(4).fill(0).map(value => value = Array(4).fill(0).map(value => value = Array(4).fill(0))));
    dp[0][3][3][3] = 1;

    for (var i = 0; i < N; i++) {
        for (var w = 0; w < 4; w++) {
            for (var x = 0; x < 4; x++) {
                for (var y = 0; y < 4; y++) {

                    for (var z = 0; z < 4; z++) {
                        if (x === 0 && y === 2 && z === 1) { continue }
                        if (x === 0 && y === 1 && z === 2) { continue }
                        if (x === 2 && y === 0 && z === 1) { continue }
                        if (w === 0 && y === 2 && z === 1) { continue }
                        if (w === 0 && x === 2 && z === 1) { continue }

                        dp[i + 1][x][y][z] += dp[i][w][x][y];
                        dp[i + 1][x][y][z] %= MOD;
                    }
                }
            }
        }
    }

    var result = 0;
    for (var w = 0; w < 4; w++) {
        for (var x = 0; x < 4; x++) {
            for (var y = 0; y < 4; y++) {
                result += dp[N][w][x][y];
                result %= MOD
            }
        }
    }
    console.log(result);
});

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
      cin >> t[i];
    }
    sort(t.begin(), t.end());
    ll ans = 0, last = 0;
    for (int i = 0; i < n; i++) {
      ans += last;
      last += t[i];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3196
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int p = stdIn.nextInt();
		int t = stdIn.nextInt();
		int t1 = stdIn.nextInt();
		
		if(p > t){
			p = t;
		}
		if(p > t1) {
			p = t1;
		}
		
		int j1 = stdIn.nextInt();
		int j2 = stdIn.nextInt();
		if(j1 > j2) {
			j1 = j2;
		}
		
		p += j1;
		p -= 50;
		System.out.println(p);
	}
}

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

int main(){
  int a,b,ans=0;
  cin >> a >> b;
  for(int i=a;i<=b;++i){
    string s=to_string(i);
    if(s[0]==s[4]&&s[1]==s[3])ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
	string str;
	cin >> str;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (str[i] == '+') ans++;
		else ans--;	
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int ans = 0;
		for(int i = 1;i < n;i++){	
			ans += (n-1)/i;
		}
		System.out.println(ans);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 32512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second
//typedef 1000000007 mod

#define mp map<ll,ll>
#define vc vector<ll>
#define MAX  *max_element
#define MIN  *min_element
#define lcm(a,b) (a*b)/__gcd(a,b)
#define des_sort(v) sort(v.begin(),v.end(),greater<int>())
//max xor btw range of two numbers..

#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define c_ones(number) __builtin_popcountll(number)
#define flip_bits(number) static_cast<unsigned>(~number)

#define all(X) X.begin(),X.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(itr,n) for(itr=n.begin();itr!=n.end();itr++)

#define FLUSH fflush(stdout)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb_ds tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007

bool compare(pair<int,int>a , pair<int,int>b){
	return a.first==b.first ? a.second<b.second : a.first < b.first;
}
ll n,k;
vector<ll> dp;
ll find_(ll n,vector<ll> &a){
	if(n==0)return 0;
	if(dp[n]!=1e9)return dp[n];
	for(int i=1;i<=k;i++){
		if(n-i>=0)
		dp[n] = min(dp[n],abs(a[n]-a[n-i])+find_(n-i,a));
	}
	return dp[n];
}

int main(){ 
	cin>>n>>k;
	dp.resize(n,1e9);
	vector<ll> a(n);
	rep(i,n)cin>>a[i];
	cout<<find_(n-1,a)<<endl;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int ans,first=1;
  for(int i=0;i<n;i++){
    if(i==0){
      ans=min(first*2,first+k);
    }else{
      ans=min(ans*2,ans+k);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int K = s.nextInt();
			final int X = s.nextInt();

			for (int i = X - K + 1; i < X + K - 1; i++) {
				System.out.print(i);
				System.out.print(' ');
			}
			System.out.println(X + K - 1);
		}
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(998244353)
#define MAX_N 200005
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


ll factorial[MAX_N];
void make_factorial_tableMOD(){
    factorial[0] = 1;
    for(int i = 1; i < MAX_N; i++){
        factorial[i] = factorial[i-1]*i%MOD;
    }
}

ll bisection_powerMOD(ll x,ll y){
    if(y==0)        { return 1; }
    ll t = bisection_powerMOD(x*x%MOD,y/2);
    if(y%2==1)      { t = t*x%MOD; }
    return t;
}

ll nCrMOD(int n, int r){
    if(n<r || n<=0 || r<0){return 0;}
    ll a = factorial[n];
    ll b = a*bisection_powerMOD(factorial[r],(MOD-2))%MOD;
    ll c = b*bisection_powerMOD(factorial[n-r],MOD-2)%MOD;
    return c % MOD;
}


int main(){
    ll n, m, k;
    cin >> n >> m >> k;

    if(n==1){
        cout << m << endl;
        return 0;
    }
    make_factorial_tableMOD();
    vector<ll> val(n+1, 0);
    val[0] = 1;
    val[1] = m;
    for(int i = 2; i < n+1; i++){
        val[i] = val[i-1]*(m-1)%MOD;
    }
    ll ans = 0;
    for(int i = 0; i <= k; i++){
        ll tmp = nCrMOD(n-1, i);
        tmp *= val[n-i];
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }


    cout << ans << endl;
}


Measured memory_bytes: 6332
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
  
#define NIL NULL
  
struct node {
  int key;  
  struct node *right;
  struct node *left;
  struct node *parent;
};
 
struct node *root;
struct node *find(int);
 
void inOrder(struct node *);
void preOrder(struct node *);
void insert(int);
void delete(struct node *);
 
struct node *min(struct node *);
struct node *successor(struct node *);
  
  
int main()
{
  int i, x, n, key;
  char s[10];
  
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%s", s);
    if(strcmp("insert", s) == 0) {
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp("print", s) == 0) {
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n");
    }
    else if(strcmp("find", s) == 0) {
      scanf("%d", &key);
      if(find(key) != NIL){
    printf("yes\n");
      }
      else{
    printf("no\n");
      }
    }
    else if(strcmp("delete", s) == 0) {
      scanf("%d", &key);
      delete(find(key));
    }
  }
  return 0;
}
  
void inOrder(struct node *T)
{
  if(T != NIL) {
    if(T->left != NIL)
      inOrder(T->left);
    printf(" %d", T->key);
    if(T->right != NIL)
      inOrder(T->right);
  }
}
  
void preOrder(struct node *T)
{
  printf(" %d", T->key);
  if(T != NIL) {
    if(T->left != NIL)
      preOrder(T->left);
    if(T->right != NIL)
      preOrder(T->right);
  }
}
  
void insert(int key)
{
  struct node *y = NIL;
  struct node *x = root;
  struct node *z;
  
  z = (struct node *)malloc(sizeof(struct node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}
  
struct node *find(int key)
{
  struct node *x = root;
  while((x != NIL) && (key != x->key)) {
    if(key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  return x;
}
  
struct node *min(struct node *x)
{
  while(!(x->left == NIL)){
    x = x->left;
  }
  return x;
}
  
struct node *successor(struct node *x)
{
  if(!(x->right == NIL)){
    return min(x->right);
  }
 
  struct node *y = x->parent;
 
  while((y != NIL) && (x == y->right)) {
    x = y;
    y = y->parent;
  }
  return y;
}
  
void delete(struct node *z)
{
  struct node *y;
  struct node *x;
  
  if((z->left == NIL) || (z->right == NIL)){
    y = z;
  }
  else{
    y = successor(z);
  }
  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }
  
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    root = x;
  }
  else {
    if(y == y->parent->left){
      y->parent->left = x;
    }
    else{
      y->parent->right = x;
    }
  }
    
  if(y != z){
    z->key = y->key;
  }
  free(y);
}

Measured memory_bytes: 19360
a,b,c,x,y = map(int,input().split())

sum = a * x + b * y
s = [sum]
for i in range(max(x,y)):
    if (x>0) and (y>0):
        x -= 1
        y -= 1
        sum = sum + (2 * c - a - b)

    elif (x>0):
        x -= 1
        sum = sum + (2 * c - a)

    elif (y>0):
        y -= 1
        sum = sum + (2* c - b)

    s.append(sum)
    #print(sum)
print(min(s))

Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

inline void cmod(int &x) {
    if (x >= MOD)
        x -= MOD;
}

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

    int N, S;
    cin >> N >> S;
    vector<vector<int>> dp(N + 1, vector<int>(S + 3));
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        for (int j = S; j >= 0; --j) {
            dp[i + 1][j] = dp[i][j] << 1;
            cmod(dp[i + 1][j]);
            if (j >= A) {
                dp[i + 1][j] += dp[i][j - A];
                cmod(dp[i + 1][j]);
            }
        }
    }

    cout << dp[N][S] << endl;
    return 0;
}


Measured memory_bytes: 38568
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int X;
    cin >> X;
    
    int now = 0, res = 0;
    FOR(i, 1, X+1) {
        res++;
        now += i;
        if(now >= X) break;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
   
int main() {
  int a, b, c, tmp;
  cin >> a >> b >> c;
  int ary[3] = {a, b, c};
  if (ary[0] > ary[1]) {
    tmp = ary[0];
    ary[0] = ary[1];
    ary[1] = tmp;
  }
  if (ary[1] > ary[2]) {
    tmp = ary[1];
    ary[1] = ary[2];
    ary[2] = tmp;
  }
  if (ary[0] > ary[1]) {
    tmp = ary[0];
    ary[0] = ary[1];
    ary[1] = tmp;
  }
  cout << ary[0] << " " << ary[1] << " " << ary[2] << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
 
int main(){
 
 int a,b,c;
 
 scanf("%d %d %d",&a,&b,&c);

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

Measured memory_bytes: 580
//author : raghav_0901
#include <bits/stdc++.h>
#define int long long int
using namespace std;

// set<int> dp;

// bool is_prime(int n)
// {
//     if(n==2 || n==3)
//         return 1;
//     if(n%2==0 || n%3==0)
//         return 0;
//     if(dp.find(n)!=dp.end())
//         return 1;
//     for(int i=6;i<=sqrt(n)+1;i+=6)
//     {
//         if(n%(i-1)==0 || n%(i+1)==0)
//             return 0;
//     }
//     return 1;
// }

signed main()
{
    int n;cin>>n;
    map<int,int> mp;
    mp[2]=__builtin_ctzll(n);
    n=n>>mp[2];
    for(int i=3;i<=sqrt(n) && n;i+=2)
    {
        while (n%i==0)
        {
            mp[i]++;
            n=n/i;
        }
    }
    int ans=0;
    if(n>2)
        ans++;
    for(auto it:mp)
    {
        int i=1;
        while (it.second>=i)
        {
            ans++;
            it.second-=i;
            i++;
        }
    }
    cout<<ans<<endl;
    return 0;   
}


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

#define ll unsigned long long
#define ma 3000
int dp[ma + 1][ma + 1];


string slcs(string &s1, string &s2, int len) {

	int i = 0;
	int  j = 0;
	string ans;

	while (len) {
		if (s1[i] == s2[j]) {
			if (ans.size() == 0) {
				ans = s1[i];
			} else {
				ans = ans + s1[i];
			}

			i++;
			j++;
			len--;
		} else {

			if (dp[i + 1][j] > dp[i][j + 1]) {
				i++;
			} else {
				j++;
			}

		}
	}

	return ans;




}

int lcs(string &s1, string &s2, int i, int j) {
	if (i >= s1.size() || j >= s2.size()) {
		return 0;
	}

	if (dp[i][j] != -1) {
		return dp[i][j];
	}

	if (s1[i] == s2[j]) {
		return dp[i][j] = 1 + lcs(s1, s2, i + 1, j + 1);
	}

	return dp[i][j] = max(lcs(s1, s2, i + 1, j), lcs(s1, s2, i, j + 1));
}



string solve(string &s1, string &s2) {
	memset(dp, -1, sizeof(dp));
	int len = lcs(s1, s2, 0, 0);
	return slcs(s1, s2, len);
}


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	string s1, s2;
	cin >> s1 >> s2;

	cout << solve(s1, s2);


	return 0;
}

Measured memory_bytes: 39304
#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 ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    vector<int> vec(4);
    rep(i, 6) {
        int tmp;
        cin >> tmp;
        vec[tmp - 1] += 1;
    }
    int one = 0, two = 0;
    rep(i, 4) if (vec[i] == 1) one += 1; else if (vec[i] == 2) two += 1;
    if (two == 2 && one == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int a,b,c,k,i,t;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(a<b)
    {
        t=b;b=a;a=t;
    }
    if(a<c)
    {
        t=c;c=a;a=t;
    }
    for(i=0;i<k;i++)
    {
        a=2*a;
    }
    printf("%d\n",a+b+c);
    return 0;
}


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

int main(){
  int N; 
  cin >> N;
  vector<int64_t> vec(N+1);
  vec.at(0) = 2ll;
  vec.at(1) = 1ll;
  
  if (N==1){
    cout << vec.at(1) << endl;
  } else {
    for (int i = 2; i < N + 1; i++) {
      vec.at(i) = vec.at(i-1) + vec.at(i-2);
    }
    cout << vec.at(N) << endl;
  }
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	int a, b; cin >> a >> b;
	int small = min(a, b);
	int big = max(a, b);

	REP(i,big){
		cout << small;
	}
	cout << endl;


	return 0;

}


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


int a,b,c,d;
int main(){
	bool ok=false,ok2=false;
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='N')a++;
		else if(s[i]=='W')c++;
		else if(s[i]=='S')b++;
		else if(s[i]=='E')d++;
	}
	
	if(a&&b)ok=true;
	else if(!a&&!b)ok=true;
	
	if(c&&d)ok2=true;
	else if(!c&&!d)ok2=true;
	
	cout << (ok&&ok2?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string a,b,c; cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
cnt = 0
def merge_sort(array):
    global cnt
    if len(array) <= 1:
        return array
    mid = len(array) // 2
    left = array[:mid]
    right = array[mid:]
    cnt += len(left) + len(right)
    left = merge_sort(left)
    right = merge_sort(right)
    return merge(left, right)

def merge(left, right):
    list = []
    l_index, r_index = 0, 0
    while l_index < len(left) and r_index < len(right):
        if left[l_index] <= right[r_index]:
            list.append(left[l_index])
            l_index += 1
        else:
            list.append(right[r_index])
            r_index += 1
    if l_index < len(left):
        list.extend(left[l_index:])
    if r_index < len(right):
        list.extend(right[r_index:])
    
    return list

n = int(input())
S = list(map(int, input().split()))
array = merge_sort(S)
print(" ".join(map(str, array)))
print(cnt)


Measured memory_bytes: 74596
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i, N)
    cin >> a[i];
  //ここまで入力

  int MAX = 100000;

  //各数字が何回出てきたかを格納
  int count[MAX + 1];
  rep(i, MAX+1)
    count[i] = 0;
  rep(i, N)
    count[a[i] ]++;

  //初期値は0と1の登場回数の和
  int ans;
  ans = count[0] + count[1];

  //隣接3項間の登場回数の和の最大を見ればよい
  for(int i=1; i<MAX-1; i++){
    int sum = count[i-1] + count[i] + count[i+1];
    if(sum > ans)
      ans = sum;
  }

  //右端2項は例外
  if(count[MAX-1] + count[MAX] > ans)
    ans = count[MAX-1] + count[MAX];

  //解答
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()
a = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for s in S:
    tmp = int(a.index(s))
    tmp = tmp + N
    print(a[tmp % 26], end="")

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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;}

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

  cout << max(a-2*b,0) << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
import math

n,m = map(int,input().split())
MOD = 10**9 + 7

def fac(n):
    if n == 1:
        return 1
    return n*fac(n-1)
#print(fac(3))
    
ans = 0
fn = math.factorial(n)
fm = math.factorial(m)
if n==m:
    ans = fn*fm*2#両側
elif abs(n-m) == 1:
    ans = fn*fm
else:
    ans = 0
print(ans%MOD)

Measured memory_bytes: 5184
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
// const ll mod=1000000007;
const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
inline ll s(ll A,ll B,ll C,ll D){
  return (A/2+C/2+D/2)*2+B+(A&C&D&1)*3;
}
int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,N,ans;
  string s;
  cin>>s;
  N=s.size();
  ans=N*(N-1)/2;
  vec v(26,0);
  rep(i,N)v[s[i]-'a']++;
  rep(i,26)ans-=v[i]*(v[i]-1)/2;
  print(ans+1);
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define int long long  
using namespace std;
const int INF=1000000007;
signed main(){
  int n;
  while(cin>>n,n!=0){
    int mp[21][21]={};
    rep(i,n){
      int x,y;
      cin>>x>>y;
      mp[y][x]=7;
    }
    int m;
    cin>>m;
    int nx=10,ny=10;
    int sum=0;
    rep(i,m){
      char a;
      int b;
      cin>>a>>b;
      if(a=='N'){
	rep(i,b){
	  if(mp[ny+i+1][nx]==7){
	    sum++;
	    mp[ny+i+1][nx]=0;
	  }
	}
	ny+=b;
      }else if(a=='E'){
	rep(i,b){
	  if(mp[ny][nx+i+1]==7){
	    sum++;
	    mp[ny][nx+i+1]=0;
	  }
	}
	nx+=b;
      }else if(a=='S'){
	rep(i,b){
	  if(mp[ny-i-1][nx]==7){
	    sum++;
	    mp[ny-i-1][nx]=0;
	  }
	}
	ny-=b;
      }else if(a=='W'){
	rep(i,b){
	  if(mp[ny][nx-i-1]==7){
	    sum++;
	    mp[ny][nx-i-1]=0;
	  }
	}
	nx-=b;
      }
    }
    cout<<((sum==n)?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  cin>>N>>x;
  int X;
  priority_queue<int,vector<int>,greater<int> > A;
  for(int i=0;i<N;i++){
    cin>>X;
    A.push(X);
  }
  int count=0;
  while(x>=A.top()){
    x-=A.top();
    A.pop();
    count++;
    if(count==N && x>0){
      cout<<count-1;
      return 0;
    }
  }
  cout<<count;
}

  
    
  


Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Double> list = new ArrayList<Double>();
		double al = 0;
		for(;;){
			double n = scan.nextDouble();
			if(n == 0){
				break;
			}
			Double[] s = new Double[(int) n];
			double sum = 0;
			for(int i = 0; i < n; i++){
				s[i]  = scan.nextDouble();
				sum += s[i];
			}
			double m = sum / n;
			double a1 = 0;
			for(int i = 0; i < n; i++){
				a1 += Math.pow(s[i] - m, 2);
			}
			al = Math.sqrt(a1 / n);
			list.add(al);
		}

		for(double d : list){
			System.out.printf("%f\n", d);
		}
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int i;
  int ans = 0;
  rep(i,n) {
    int x;
    cin >> x;
    if (2*x < k) {
      ans+=2*x;
    } else {
      ans+=(k-x)*2;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)((x).size()))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define y0 y2342
#define y1 y2343
#define mset(a,v) memset(a, v, sizeof(a))
#define mcpy(a,b) memcpy(a, b, sizeof(a))
#define X first
#define Y second

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

template<class T> T abs(T x) { return x > 0 ? x : -x; }

const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
const ll mod = 998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

const int md = (int)998244353;
int N,M;
const int maxn = 305;
bitset<maxn> a[maxn],basis[maxn];
inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}
inline int power(int a, long long b) { // a^b mod md
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
int main(void){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;
    int x;
    for(int i=1;i<=N;i++){
    	for(int j=1;j<=M;j++){
    		cin >> x;
    		a[i][j] = x;
    	}
    }
    int r = 0;
    for(int i=1;i<=N;i++){
    	bitset<maxn> v = a[i];
    	for(int j=1;j<=M;j++){
    		if (v[j]){
    			if(basis[j]==0){
	    			basis[j] = v;
	    			r++;
	    			break;
	    		}
	    		v ^= basis[j];
    		}
    		
    	}
    }
    int ans = power(2,N+M-1);
    sub(ans,power(2,N+M-1-r));
    cout << ans << endl;
    //cerr << "time = " << clock()*1.0/CLOCKS_PER_SEC << " s" << endl;
    return 0;
}

/*
g++ -W -O2 -std=c++14
*/



















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n,q;
  cin >> n >> q;
  string s; 
  cin >> s;

  ll count = 0;
  vector<ll> front(n,0);

  rep(i,s.size()) {
    if(i == 0 ) continue;

    if(s.at(i - 1) == 'A' && s.at(i) == 'C') {
      count++;
    }

    front.at(i) = count;
  }

  ll ans;
  
  rep(i,q) {
    ll l,r;
    cin >> l >> r;
    l--;
    r--;

    ans = front.at(r) - front.at(l);

    cout << ans << endl;
    
  }

  
}


Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
using ll = long long;
using P = pair<int, int>;
int main(){
    string s, t;
    cin >> s >> t;
    int i=0,sz;
    if (s.size()==t.size()){
      sz=1;
    } else {
      sz=s.size()-t.size();
    }
    vector<int> zure(sz,0);
    do{
        rep(j, t.size()){
            if(s[i+j]!=t[j]){
                zure[i]++;
            }
        }
        i++;
    }while(i< s.size()-t.size());
    sort(zure.begin(),zure.end());
    cout << zure[0] << endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,a,cnt=1;
	cin >> n;
	rep(i,n){
		cin >> a;
		if(a%2==0) cnt*=2;
	}
	cout << pow(3,n)-cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let mut a: Vec<usize> = readnc();
    for i in 0..n  {
        a[i] -= 1;
    }

    let mut cost = 0;
    for i in 0..n {
        if i != a[i] {
            continue;
        } else {
            cost += 1;
            if i+1 < n && a[i+1] == i+1 {
                a[i+1] = n;
            }
        }
    }
    println!("{}", cost);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    cin >> n;
    int p[20005];
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        p[t] = i;
    }

    for (int i = 1; i <= n; i++) {
        cout << 30000 * i << " ";
    }
    cout << "\n";

    for (int i = 1; i <= n; i++) {
        cout << 30000 * (n - i + 1) + p[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 768
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	static final boolean debugMode = false;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = readInt(sc);
		int m = readInt(sc);
		int total = 0;

		List<Integer> a = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			int tmp = readInt(sc);
			total += tmp;
			a.add(tmp);
		}

		a.sort(Comparator.reverseOrder());
		if (a.get(m - 1) >= (double)total / (double)(4 * m)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (2000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int r[200000],l[200000];

  rep(i,n){
    if(i==0){
      r[i]=1;
      continue;
    }
    if(s[i] == 'R'){
      r[i] = r[i-1]+1;
    }else{
      r[i] = 0;
    }
  }

  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      l[i]=1;
      continue;
    }
    if(s[i] == 'L'){
      l[i] = l[i+1]+1;
    }else{
      l[i] = 0;
    }
  }

  int ans[200000]={};
  rep(i,n-1){
    if(s[i] == 'R' && s[i+1] == 'L'){
      ans[i] = 1;
      ans[i+1] = 1;
      int rig = r[i]-1;
      int lef = l[i+1]-1;

      if(rig%2 == 0){
        ans[i] += rig/2;
        ans[i+1] += rig/2;
      }else{
        ans[i] += (rig-1)/2;
        ans[i+1] += (rig+1)/2;
      }

      if(lef%2 == 0){
        ans[i] += lef/2;
        ans[i+1] += lef/2;
      }else{
        ans[i] += (lef+1)/2;
        ans[i+1] += (lef-1)/2;
      }
    }
  }

  rep(i,n){
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

int A,B,C,D;
map<int,int> M;

int dfs(int N){
    if(M[N]!=0){
        return M[N];
    }
    if(N==2){
        M[2] = min(2*D , A+D);
        return M[2];
    }
    if(N==1){
        M[1] = D;
        return M[1];
    }
    if(N==0){
        return 0;
    }
    if(N<0){
        return INF;
    }
    
    int m=INF;
    
    int d;
    //2-
    d = dfs(N/2);
    m = min(m,A+D*(N%2)+d);//2で寄せて、割る
    if(N<=INF/D){
        m = min(m,D*(N-(N/2))+d);//そのまま行く
    }
    //2+
    d = dfs((N/2)+1);
    m = min(m,A+D*(2-N%2)+d);//2で寄せて、割る
    if(N<=INF/D){
        m = min(m,D*(N-(N/2)-1)+d);//そのまま行く
    }
    
    
    //3-
    d = dfs(N/3);
    m = min(m,B+D*(N%3)+d);//3で寄せて、割る
    if(N<=INF/D){
        m = min(m,D*(N-(N/3))+d);//そのまま行く
    }
    //3+
    d = dfs((N/3)+1);
    m = min(m,B+D*(3-N%3)+d);//3で寄せて、割る
    if(N<=INF/D){
        m = min(m,D*(N-(N/3)-1)+d);//そのまま行く
    }
    
    
    //5-
    d = dfs(N/5);
    m = min(m,C+D*(N%5)+d);//5で寄せて、割る
    if(N<=INF/D){
        m = min(m,D*(N-(N/5))+d);//そのまま行く
    }
    //5+
    d = dfs((N/5)+1);
    m = min(m,C+D*(5-N%5)+d);//5で寄せて、割る
    if(N<=INF/D){
        m = min(m,D*(N-(N/5)-1)+d);//そのまま行く
    }
    
    
    M[N]=m;
    return m;
}

signed main(void){
    
    int T;
    cin >> T;
    REP(_,T){
        //cout << _ << endl;
        int N;
        int a,b,c,d;
        cin >> N >> a >> b >> c >> d;
        A=a;B=b;C=c;D=d;
        M.clear();
        int Ans = dfs(N);
        #if debug 
        if(_<3){
            REP(i,N+3){cout << i << " ";}cout << endl;
            REP(i,N+3){cout << M[i] << " ";}cout << endl;
        }
        #endif
        cout << Ans << endl;
    }
    
    return 0;
}




Measured memory_bytes: 4756
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 1000000007
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
   
  
    int n,k;
    cin>>n>>k;
    int ans =0;
    int temp = (n*(n+1))/2;

    for(int i=k;i<=n+1;i++)
    {
        int jj = n-i;

        int mini = (i*(i-1))/2;
        int maxi = temp-(jj*(jj+1))/2;

       // cout<<i<<" "<<mini<<" "<<maxi<<'\n';
        ans = (ans%mod+(maxi%mod-mini%mod+1+mod)%mod)%mod;
    }
 
    
    cout<<ans<<"\n";
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 3792