akhauriyash/Code-Regression huggingface dataset:
/*MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWO:,'..'xXWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO. .:kOo.,kNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO. .lNWWo..lXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MNOxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMMMMWKxoloxKWNc  .:xxd;  ,dxxxkXMXkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMM
MKc''''''''''''''''.  ..'''''.   .''''.  .''MMMWx..,:. .xXo''.  .''.  ..'';kMk;'''''.  .'.''.  .''''''.  ..''.   .''MM
MWNXNNNNNNNNNNNNNNNO' ;KNNNNNKo. cKNNNd. lXNMMMK; ,0Wx. :NWXXl .dNNO' ;KNNNWMWNNNNNXc .kNNNNx. cXNNNNNO' ;KNN0; 'ONNMM
MMMMMMMMMMMMMMMMMWM0' :NMMMMWMX: .OMWWx. oWMMMMWx. ';. .dNMWWo .xMM0' :NWWMMMMMMMMWWl .OMMMWk. lWWMMWM0' ;XMMX: ,KMMMM
MMMMMMWMWkccccccccc;. :NMWNNNKd. :XMMWx. oWMMMWKo. .',. .,ldx; .dMM0' :NMMMMMMMNNWMWl .OMMMWk. lWMMMMM0' ;XMMX: ,0MMMM
MMWXKNWMWxcc,. .;cc;. :XMk,''..'lKWMMWx. oWMNx:. .lONNKxl.     .xMM0' :NMMMMMM0:,oKO' ,KMMMMk. lWWNkoc,. .;::;. ,KMMMM
MMXc.lXMMWWWNd..xWM0' :NM0;  ;kXWMMMWNl  oWMK:.;xXWWMWXx:. ,c' .dMM0' :NMMMMMMKc. ...;kWMMMMk. lWWc .:;. .clc:. ,KMMMM
MWWx. lXMWMMMK, lWM0' :NMMNx'.,ldxxoc'   oWMWNKNWWWN0o' .:kNWo .dMM0' :NMMMMMMMNO;  ,OWWWMMMk. lWM' lXx. lNMMX: ,KMMMM
MMMWk'.,xKNX0c..kWM0' :NMMMMNkl;,'',:l:  oWMMMMMWMWO' 'l0WMWWo .xMM0' :NMMMMMMMMMNd. .oXWMMMk. lWMd.....;0WMMX: ,KMMMM
MMMMWKo'...'..:kWMM0' :NMMMMMMMWWNNWWWx. oWMMMMMMMMWOxXWMWMWWo .xMM0' :NMMMMMMMMMMMKl. ,kNMMk. lWMWKkxx0NMWMMX: ,KMMMM
MMMMMMMN0kxk0XNWMMWKl;xNMMMMMMMMMMMMWM0c;kWMMMMMMMMMMMWWMMMMWk;:OMMXl,dNMMMMMMMMMMMMWO; .dNM0c;kWWMMMMMMMMMMMNd,oXMMMM
MMMMMMMMWWMWMMMMMMMMMWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWMMWWMMWMMMMMMMMMMMMMMNkxKWMMWWMMMMMMMMMMMMMMWMMWMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM*/

//             Author: Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)                  //


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;

#define         TESTCASES()    cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define         _input(V3C)    for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define   mems(A77AY, V4LU)    memset((A77AY), (V4LU), sizeof((A77AY)))
#define    CH3K(I7, E4, S7)    (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define   for4(I7,S4,E4,S7)    for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))



void solveEachTest(lld T35TC453N = 1) {
	int n; cin >> n;
	int k; cin >> k;
	vector<bool> arr(10, false);
	for4(i, 0, k, 1) {
		int temp; cin >> temp;
		arr[temp] = true;
	}
	while (true) {
		int temp = n;
		bool ok = true;
		while (temp) {
			if (arr[temp % 10]) {ok = false; break;}
			temp /= 10;
		}
		if (ok) {
			break;
		}
		n++;
	}

	cout << n;
	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3636
N = int(input())
S = [str(input()) for i in range(N)]

ans = 0
firstB = 0
lastA = 0
cnt = 0
for s in S:
    if s[0] == 'B':
        firstB += 1
    if s[-1:] == 'A':
        lastA += 1

    if s[0] == 'B' and s[-1:] == 'A':
        cnt += 1

    ans += s.count('AB')
    
if cnt == max([firstB,lastA]) and cnt > 0:
    print(ans + cnt -1)
else:
    print(ans+ min([firstB,lastA]))

Measured memory_bytes: 3700
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  bool test = false;
  REP(i,s.size()-1){
    if(s.substr(i,2)=="AC") test = true;
  }
  Yes(test);
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
using namespace std;
int main(){
  
  int n,a,b,c;
  deque<int> dq;
  cin >> n;

  while(n--){

    cin >> a;
  
    if(a == 0){
      cin >> b >> c;
      if(b == 0) dq.push_front(c);
      if(b == 1) dq.push_back(c);
    }

    if(a == 1){
      cin >> b;
      cout << dq[b] << endl;
    }

    if(a == 2){
      cin >> b;
      if(b == 0) dq.pop_front();
      if(b == 1) dq.pop_back();
    }

  }

  return(0);
}



Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;


int main() {
    int N;
    cin >> N;
    if (N == 1){
        cout << 1 << endl;
        cout << 0 << endl;
        return 0;
    }
    if (N == 2){
        cout << 2 << endl;
        cout << 0 << endl;
        cout << 11 << endl;
        return 0;
    }
    string T = "";
    for (int i = 0; i < N; i++){
        T += '1';
    }
    cout << N - 1 << endl;
    for (int i = 0; i < N - 1; i++){
        cout << T << endl;
        T = T.substr(0, N - i - 1);
        T.at(0) = '0';
        T.at(T.size() - 1) = '0';
    }
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=1; i<=9; i++){
		if (n%i == 0 && n/i <=9) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  int M;
  int a = 0;
  int sum = 0;
  cin>>N;
  cin>>M;
  for(int i = 0;i < M;i++){
    cin>>a;
    sum += a;
  }
  if(sum <= N){
    cout<<N - sum<<'\n';
  }else if(sum > N){
    cout<<-1<<'\n';
  }
}

Measured memory_bytes: 3608
use std::io::*;
use std::str::FromStr;
use std::cmp;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let a: usize = read();
    let b: usize = read();
 
    let mut ans = 0;
    let mut socket = 1;
    while socket < b {
        socket += a - 1;
        ans += 1
    }
 
    println!("{}", ans);	
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{

long long int b[1000000];
long long int n,i,k=0;

scanf("%lld",&n);

for(i=1;i<=n;i++)
{
scanf("%lld",&b[i]);
if(b[i]!=i)
{
k++;
}

}
if(k==0 || k==2)
{
printf("YES\n");
}
else 
printf("NO\n");  
return 0;
}    

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

int main() {
    int n;
    cin >>n;
    vector<int> a(n), b;
    for (int i = 0; i < n; ++i) {
        cin >>a.at(i);
    }
    b = a;
    sort(b.begin(), b.end());
    for (int i = 0; i < n; ++i) {
        cout << ((a.at(i)==b.at(n-1)) ? b.at(n-2) : b.at(n-1)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int64_t minn(int64_t a,int64_t b){
    if(a >= b) return b;
    else return a;
}
int main(){
    string A,B;
    cin >>A>>B;
   if(A.size()>B.size()) cout << "GREATER" << endl;
   if(A.size() == B.size() && A > B) cout << "GREATER" << endl;
    if(A.size() == B.size() && A < B) cout << "LESS" << endl;
   if(A.size()< B.size())cout << "LESS" << endl;
   if(A.size() == B.size() && A == B) cout << "EQUAL" << endl;
   
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef pair <int, int> P;

// implement dfs twice
int tree_diameter_dfs(vector<vector<P>> &edge) {
    int n = edge.size();
    vector<int> dist(n, 0);
    auto dfs = [&](auto dfs, int cur, int par) -> void {
        for (P &e : edge[cur]) {
            if (e.first == par) continue;
            dist[e.first] = dist[cur] + e.second;
            dfs(dfs, e.first, cur);
        }
    };
    dfs(dfs, 0, -1);
    int mx = 0, idx = 0;
    for (int i = 0; i < n; i++) {
        if (dist[i] > mx) {
            mx = dist[i];
            idx = i;
        }
    }
    fill(dist.begin(), dist.end(), 0);
    dfs(dfs, idx, -1);
    for (int i = 0; i < n; i++) mx = max(dist[i], mx);
    return mx;
}

int tree_diameter_dp(vector<vector<P>> &edge) {
    int n = edge.size();
    vector<int> height(n, 0);
    int mx = 0;
    auto dfs = [&](auto dfs, int cur, int par) -> void {
        for (P &e : edge[cur]) {
            if (e.first == par) continue;
            dfs(dfs, e.first, cur);
        }
        int h1 = 0, h2 = 0;
        for (P &e : edge[cur]) {
            if (e.first == par) continue;
            if (height[e.first] + e.second > h1) {
                h2 = h1;
                h1 = height[e.first] + e.second;
            } else if (height[e.first] + e.second > h2) {
                h2 = height[e.first] + e.second;
            }
        }
        height[cur] = h1;
        mx = max(mx, h1 + h2);
    };
    dfs(dfs, 0, -1);
    return mx;
}

// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_A&lang=jp
void AOJ_GRL_5_A() {
    int n;
    cin >> n;
    vector<vector<P>> edge(n);
    for (int i = 1; i < n; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        edge[s].push_back({t, w});
        edge[t].push_back({s, w});
    }
    cout << tree_diameter_dp(edge) << endl;
    // cout << tree_diameter_dfs(edge) << endl;
}

int main() {
    AOJ_GRL_5_A();
    return 0;
}


Measured memory_bytes: 13472
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
int main()
{
    long long n,z,k;
    cin>>n;
    k=n/11;
    z=n%11;
    k*=2;
    if(z!=0) ++k;
    if(z>6) ++k;
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
unordered_map<int,int> um;
unordered_set<int> us;
set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr
//g++ -o Legendary-Grandmaster Legendary-Grandmaster.cpp&Legendary-Grandmaster.exe 
//cd C:\Users\158si\Desktop\Algorithim\codeForces\elite
// for-bash cd C:/Users/158si/Desktop/Algorithim/codeForces/elite

int main(){
	long long k,n;
	cin >> k >> n;
	long long summed = 0;
	for(int i=0;i<n;++i){
		long long x;
		cin >> x;
		if(summed<k){
		summed += x;	
		}
	}
	if(summed>=k){
		cout << "Yes";
	}else{
	   cout << "No";
     }
	return 0;
}

























Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    final int NMAX = 1000;
    final int MMAX = 2000;
    final long INF = Long.MAX_VALUE;
    int[] a = new int[MMAX];
    int[] b = new int[MMAX];
    long[] c = new long[MMAX];

    for (int i = 0; i < M; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextLong();
      c[i] = -c[i]; //スコア逆
    }
    long ans = bellmanFord(a,b,c,N,M);

    if(ans == -INF) System.out.println("inf");
    else System.out.println(-ans);
  }

  public static long bellmanFord(int[] a, int[] b, long[]c, int N, int M){
    final long INF = Long.MAX_VALUE;
    final int NMAX = 1000;
    final int MMAX = 2000;

    long[] dist = new long[NMAX];


    for (int i = 0; i < N; i++) {
      dist[i] = INF; //初期化
    }

    dist[0] = 0L;

    for(int loop = 0; loop < N - 1; loop++) {
      for (int i = 0; i < M; i++) {
        if(dist[a[i] - 1] == INF) continue;

        if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
          dist[b[i] - 1] = dist[a[i] - 1] + c[i];
        }
      }
    }

    long ans = dist[N - 1];

    boolean[] negative = new boolean[NMAX];

    for(int i = 0; i < N; i++) {
      negative[i] = false;
    }

    for (int loop = 0; loop < N; loop++) {
      for (int i = 0; i < M; i++) {
        if (dist[a[i] - 1] == INF) continue;

        if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
          dist[b[i] - 1] = dist[a[i] - 1] + c[i];
          negative[b[i] - 1] = true;
        }

        if (negative[a[i] - 1] == true) {
          negative[b[i] - 1] = true;
        }
      }
    }
    if (negative[N - 1]) return -INF;
    else return ans;
  }
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);

int n;
ll b[MAX_N];

ll a[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n - 1; ++i) {
    a[i] = INF;
    scanf("%lld", &(b[i]));
  }

  for (int i = 1; i <= n; ++i) {
    a[i] = INF;
  }

  for (int i = 1; i <= n - 1; ++i) {
    a[i] = min(a[i], b[i]);
    a[i + 1] = min(a[i + 1], b[i]);
  }

  ll ans = 0LL;

  for (int i = 1; i <= n; ++i) {
    ans += a[i];
  }

  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	D, _ := strconv.Atoi(sc.Text())

	var X = make([]int, N, N)
	var Y = make([]int, N, N)

	count := 0

	for i := 0; i < N; i++ {
		sc.Scan()
		X[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		Y[i], _ = strconv.Atoi(sc.Text())
		if math.Sqrt(math.Pow(float64(X[i]), 2)+math.Pow(float64(Y[i]), 2)) <= float64(D) {
			count++
		}
	}

	fmt.Println(count)

}


Measured memory_bytes: 7388
n = int(input())
a = list(map(int,input().split()))
res=0

if n==1:
	print(res)
else:

	for i in range(1,n):

		if a[i]<a[i-1]:
			res= ( a[i-1] - a[i] ) + res
			a[i] = a[i-1]

	print(res)

Measured memory_bytes: 32156
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

// https://atcoder.jp/contests/abc155/tasks/abc155_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int[] array = new int[3];
		Scanner sc = new Scanner(System.in);
		array[0] = sc.nextInt();
		array[1] = sc.nextInt();
		array[2] = sc.nextInt();
		sc.close();

		// LinkedHashSetオブジェクトを用意
		Set<Integer> linkedHashSet = new LinkedHashSet<Integer>();
		// 配列の要素を順にLinkedHashSetオブジェクトへ追加
		for (int i = 0; i < array.length; i++) {
			linkedHashSet.add(array[i]);
			}
		if(linkedHashSet.size()==2) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22724
#include <iostream>
using namespace std;
#define INF 1000000001
#define MAX 500000
int L[MAX/2+1],R[MAX/2+1],count=0;
void marge(int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1]=INF;
    R[n2]=INF;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
            i+=1;
        }
        else{
            A[k]=R[j];
            j+=1;
        }
        count+=1;
    }
}
void margesort(int A[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        margesort(A,left,mid);
        margesort(A,mid,right);
        marge(A,left,mid,right);
    }
}
int main(){
    int A[MAX]={},n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    margesort(A,0,n);
    for(int i=0;i<n;i++){
        if(i==0){
            cout<<A[i];
        }
        else{
            cout<<" "<<A[i];
        }
    }
    cout<<endl;
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 6956
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


long long mul_inv(long long a, long long b)
{
	long long b0 = b, t, q;
	long long x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

long long division(long long a, long long b, long long p) {		// (a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
	long long ans, inv;
	inv = mul_inv(b, p);
	ans = ((a % p) * inv) % p;
	return ans;
}




int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, k, i, j, a, b, MOD = 1000000007, ans, id, x, xx;
	cin >> n >> k;
	vector<vector<long long>> adj(n + 1);
	for (i = 0; i < n - 1; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	queue<long long> q;
	vector<long long> parent(n + 1, -1), d(n + 1, 0), soncount(n + 1, 0);
	q.push(1);
	parent[1] = 0;
	while (!q.empty()) {
		id = q.front();
		q.pop();
		for (auto p : adj[id]) {
			if (parent[p] == -1) {
				parent[p] = id;
				soncount[id]++;
				d[p] = d[id] + 1;
				q.push(p);
			}
		}
	}

	vector<long long> fact(100010);
	fact[0] = 1;
	for (i = 1; i < 100010; i++) fact[i] = (fact[i - 1] * i) % MOD;

	ans = k;	// # of colors of root 1
	for (i = 1; i <= n; i++) {
		// x = available colors for all its sons
		x = k - 1;
		if (d[i] > 0) x--;

		if ((soncount[i] > 0) && (x < soncount[i])) ans *= 0;
		else if (soncount[i] > 0) {
			xx = division(fact[x], fact[x - soncount[i]], MOD);
			ans = (ans * xx) % MOD;
		}
	}

	cout << ans << "\n";

	return 0;
}


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

int main() {
    int n, l;
    cin >> n >> l;
    int min_a, max_a, sum;
    min_a = l;
    max_a = l+n-1;
    sum = n*(2*l+(n-1))/2;
    if(min_a*max_a <= 0){
        cout << sum << endl;
    }else if(min_a > 0){
        cout << sum-min_a << endl;
    }else if(min_a < 0){
        cout << sum-max_a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
h = [int(i) for i in input().split()]
ans=0
l=0
while True:
	r=l+1
	if(h[l]==0):
		l+=1
		if(l>=n):
			break
		continue
	while(r<n):
		if(h[r]!=0):
			r+=1
		else:
			break
	for i in range(l,r):
		h[i]-=1
	ans+=1
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(){
int a, b, C;
double rad, r, S,L,h;
double PI = acos(-1);

scanf("%d %d", &a, &b);
scanf("%d", &C);
rad = C * PI / 180;
r = sqrt(a*a + b*b - 2*a*b*cos(rad)) ;
S = 0.5*a*b*sin(rad);
L = a+b+r;
h = S/a*2;

printf("%f\n", S);
printf("%f\n", L);
printf("%f\n", h);

   return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	set<int> st;
	int x, n;
	cin >> x >> n;
	FOR(i, 1, n) {
		int tmp;
		cin >> tmp;
		st.insert(tmp);
	}
	int dai;
	FOR(i, x, x + 105) {
		if (st.find(i) == st.end()) {
			dai = i;
			break;
		}
	}
	int sho;
	RFOR(i, x, x - 105) {
		if (st.find(i) == st.end()) {
			sho = i;
			break;
		}
	}
	int res = 0;
	if (dai - x < x - sho) {
		res = dai;
	}
	else {
		res = sho;
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=700;
  for (int i=0;i<3;i++)
    if (s[i]=='o')
      ans += 100;
  cout<<ans;
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 212345;
ll x[MAX_N];
ll y[MAX_N];

typedef pair<ll,ll> P;

int main2() {
  int N = nextInt();
  ll INF = 1001001001;
  ll Gmax = 0, Gmin = INF;
  REP(i, N) {
    x[i] = nextInt();
    y[i] = nextInt();
    chmin(Gmin, x[i]);
    chmin(Gmin, y[i]);
    chmax(Gmax, x[i]);
    chmax(Gmax, y[i]);
  }
  ll Rmax = 0, Rmin = INF;
  ll Bmax = 0, Bmin = INF;

  ll ans = 1LL << 61;
  // Rmin == MIN && Rmax == MAX
  priority_queue< P, vector<P>, greater<P> > que;
  Rmin = Gmin; Rmax = Gmax;
  Bmax = 0;
  REP(i, N) {
    pair<ll, ll> p(min(x[i], y[i]), max(x[i], y[i]));
    chmax(Bmax, p.first);
    que.push(p);
  }
  REP(step, N) {
    auto top = que.top(); que.pop();
    Bmin = top.first;
    // cout << Bmin << " " << Bmax << endl;
    chmin(ans, (Rmax - Rmin)*(Bmax - Bmin));
    if (top.first > top.second) break;
    que.push( {top.second, top.first} );
    chmax(Bmax, top.second);
  }

  // Rmin == MIN && Bmax == MAX
  Rmin = Gmin; Bmax = Gmax;
  Rmax = 0; Bmin = INF;
  REP(i, N) {
    ll ma = max(x[i], y[i]);
    ll mi = min(x[i], y[i]);
    chmax(Rmax, mi);
    chmin(Bmin, ma);
  }
  chmin(ans, (Rmax - Rmin)*(Bmax - Bmin));

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

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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


int main(){
    int N,K;
    cin >> N >> K;
    int l[N];
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }

    sort(l,l+N,greater<int>());
    int ans = 0;

    for (int i = 0; i < K; i++)
    {
        ans += l[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
s = input()
def num(letter):
	return ord(letter) - 97
def let(number):
	return chr(number + 97)

ok = 0
ng = len(s)
used = [False] * 26
tmp = 0
cnt = 0
for i in range(len(s)):
	if used[num(s[i])] == False:
		used[num(s[i])] = True
		tmp += 1
	if tmp == 26:
		cnt += 1
		tmp = 0
		used = [False] * 26

prm = cnt+1

if prm == 1:
	for j in range(26):
		if used[j] == False:
			print(let(j))
			break
else:
	d = []
	used = [False] * 26
	tmp = 0
	for i in range(len(s)-1, -1, -1):
		if used[num(s[i])] == False:
			used[num(s[i])] = True
			tmp += 1
		if tmp == 26:
			tmp = 0
			used = [False] * 26
			d.append(i)
	d = d[::-1]
	ans = ""
	cnt = 0
	i = 0
	skip = False
	used = [False] * 26
	for i in range(len(s)):
		if cnt < prm-1:
			if i == d[cnt]:
				for j in range(26):
					if used[j] == False:
						ans += let(j)
						break
				used = [False] * 26
				cnt += 1
				skip = True			
		if skip:
			if s[i] == ans[-1]:
				skip = False
			continue
		if used[num(s[i])] == False:
			used[num(s[i])] = True

	for j in range(26):
		if used[j] == False:
			ans += let(j)
			break
	print(ans)

Measured memory_bytes: 45148
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define FOR(i,x,y) for(int i=(x),i##END=(y);i<=i##END;++i)
#define DOR(i,x,y) for(int i=(x),i##END=(y);i>=i##END;--i)
template<typename T,typename _T>inline bool chk_min(T &x,const _T y){return y<x?x=y,1:0;}
template<typename T,typename _T>inline bool chk_max(T &x,const _T y){return x<y?x=y,1:0;}
typedef long long ll;
const int N=1e5+5;
const int P=1e9+7;
int cnt[27];
int n;

int calc(int x)
{
	if(x==26)return cnt[26];
	int t=calc(x+1);
	return ((ll)cnt[x]*(1+t)+t)%P;
}

int main()
{
	scanf("%d",&n);
	FOR(i,1,n)
	{
		char ch;
		scanf(" %c",&ch);
		cnt[ch-'a'+1]++;
	}
	printf("%d\n",calc(1));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll T[100010], A[100010];
int main()
{
	int N; cin >> N;
	ll num1 = 0, num2 = 0;
	int p1 = 0, p2 = 0;
	ll ans = 1;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		num1 = max(num1, T[i]);
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		num2 = max(num2, A[i]);
	}
	if (num1 != num2) {
		cout << 0 << endl;
		return 0;
	}
	num1 = 0, num2 = 0;
	for (int i = 0; i < N; i++) {
		if (T[i] > num1) {
			num1 = T[i];
			p1 = i;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] > num2) {
			num2 = A[i];
			p2 = i;
		}
	}
	if (p1 > p2) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < p1; i++) {
		if (T[i] == T[i - 1]) {
			ans = (ans * T[i]) % mod;
		}
	}
	//cout << ans << endl;
	for (int i = N - 2; i > p2; i--) {
		if (A[i] == A[i + 1]) {
			ans = (ans * A[i]) % mod;
		}
	}
	for (int i = 0; i < p2 - p1 - 1; i++) {
		ans = (ans * num1) % mod;
	}
	cout << ans << endl;
}

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

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

int main(){
	int N;
	cin >> N;
	string str = to_string(N);
	int deg=str.size();
	vector<string> S;
	for(int i=1; i<=8; i++){
		for(int j=1; j+i<=9; j++){
			for(int k=1; k+j+i<=10; k++){
				// printf("%d %d %d\n",i,j,k);
				string s;
				rep(a,i)s+='3';
				rep(a,j)s+='5';
				rep(a,k)s+='7';
				do{
					S.push_back(s);
				}while(next_permutation(s.begin(),s.end()));
			}
		}
	}

	ll ans = 0;
	sort(S.begin(),S.end());
	for(int i=0; i<(int)S.size()-1; i++){
		if((int)S[i].size() < deg){
			ans++;
		}
		else if(S[i] != S[i+1] && (int)S[i].size() == deg && S[i]<=str){
			ans++;
		} 
	}

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

Measured memory_bytes: 4724
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

long long a[100010];
long long n;

bool compare(const long long &a, const long long &b)
{
	
	return a < b;
}

long long nimCount[20];	//注意，这个二进制数情况描述是倒序的，nimCount[0]为个位 

int main()
{
	scanf("%lld", &n);
	a[0] = 0;
	for (int i = 1 ; i <= n ; i++)
		scanf("%lld", &(a[i]));
		
	sort(a + 1, a + n + 1, compare);	
	//将堆横置过来，变100000 20000 30000 为 20000个3，10000个2，70000个1
	//然后进行Nim分析
	memset(nimCount, 0, sizeof(nimCount));

	for (int i = 1 ; i <= n ; i++)
	{
//		if (a[i] == a[i + 1])
//		{
//			a[i] = a[i - 1];
//			continue;
//		}
		long long diff = a[i] - a[i - 1];
		
		long long d = 0;
		long long num = n - i + 1;
		while (num > 0) 
		{
			if (num % 2 == 1)
				nimCount[d] = (nimCount[d] + diff) % 2;
			
			num = num / 2;
			d++;
		}
	}
	
	bool isBalance = true;
	for (int i = 0 ; i < 20 ; i++)
	{
		if (nimCount[i] % 2 == 1)
		{
			isBalance = false;
			break;
		}
	}
	
	if (isBalance)
	{
		printf("second\n");
	}
	else
	{
		printf("first\n");
	}
	
	
	return 0;
}

//是一个转置过的NIM取子游戏 
//所以要先变成一个NIM取子游戏才行 

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

intsec = []
for i in range(n[0]):
    intsec.append([int(j) for j in input().split()])
    
ans = 100**1000

for i in range(n[0]):
    for j in range(n[1]):
        count = 0
        for k in range(n[0]):
            for l in range(n[1]):
                if abs(k-i) >= abs(l-j):
                    count+=abs(l-j)*intsec[k][l]
                else:
                    count+=abs(k-i)*intsec[k][l]
        if ans >= count:
            ans = count
            
print(ans)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge*i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline ll rd() {
    ll x;int c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=1e5+11;
int a[N],n;
inline int jud(ll x){
	ll now=x;
	rep(i,1,n)now=(now/a[i])*a[i];
	if(now==2) return 1;
	else if(now>2) return 2;
	return 0;
}
int main(){
	n=rd();
	rep(i,1,n)a[i]=rd();
	ll l=1,r=9000000000000000000LL,ans=-1;
	while(l<=r){
		ll m=l+r>>1;
		if(jud(m)){
			if(jud(m)==1)ans=m;
			r=m-1;
		}
		else l=m+1;
	}
	if(ans==-1){
		puts("-1");
		return 0;
	}
	else cout<<ans<<" ";
	l=1,r=9000000000000000000LL;
	while(l<=r){
		ll m=l+r>>1;
		if(jud(m)==2) r=m-1;
		else if(jud(m)==1){
			ans=m;
			l=m+1;
		}
		else l=m+1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	float data[2];
	int number;
	
	while (scanf("%d,%f,%f", &number, &data[0], &data[1]) != EOF){
		if (data[0] / data[1] / data[1] >= 25.0){
			printf("%d\n", number);
		}
	}
	
	return (0);
}

Measured memory_bytes: 624
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    ll num = 100;
    ll ans = 0;
    while (num < X) {
        ans++;
        num += num / 100;
    }
    cout << ans << endl;
}


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

using f64 = double;
using i64 = long long;

vector<i64> a, ans, pos, perm;
i64 k;
int n, m;

static vector<i64> join(vector<i64> &a, vector<i64> &b) {
	vector<i64> res(a.size());
	for (int i = 0; i < res.size(); ++i)
		res[i] = a[b[i]];

	return res; }

static void exp(vector<i64> &p, i64 e) {
	vector<i64> aux, ans(p.size());
	
	aux = p;
	iota(begin(ans), end(ans), 0);
	for (; e > 0; e/= 2) {
		if (e % 2)
			ans = join(ans, aux);
		aux = join(aux, aux); }

	p = ans; }

int main() {
#ifdef HOME
	freopen("agc6c.in", "r", stdin);
	freopen("agc6c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	pos.resize(n), for_each(begin(pos), end(pos), [&](i64 &x) { cin >> x; });
	cin >> m >> k;
	a.resize(m), for_each(begin(a), end(a), [&](i64 &x) { cin >> x; });

	perm.resize(n - 1);
	iota(begin(perm), end(perm), 0);
	for (int i = 0; i < m; ++i)
		swap(perm[a[i] - 1], perm[a[i] - 2]);

	exp(perm, k);

	ans.resize(n);
	ans[0] = pos[0];
	for (int i = 0; i < n - 1; ++i)
		ans[i + 1]+= pos[perm[i] + 1] - pos[perm[i]];

	for (int i = 1; i < n; ++i)
		ans[i]+= ans[i - 1];

	for (int i = 0; i < n; ++i)
		cout << ans[i] << ".0\n";

	return 0; }


Measured memory_bytes: 4992
#include<stdio.h>
#include <string.h>
int main(){
	int i,n=0,q=0,c[500],a=0,b=0;
	char s[1000],t[500][32],*p;
	fgets(s,1024,stdin);
	while(1){
		p=strchr(s+q,' ');
		if(!p)
			p=s+strlen(s)-1;
		strncpy(t[n],s+q,p-s-q);
		for(i=0;i<n;i++)
			if(strcmp(t[i],t[n])==0){
				c[i]++;
				break;
			}
			if(i==n){ 
				c[i]=1;
				n++; 
			}
			q=p-s+1;
			if(p==s+strlen(s)-1) 
				break;
	}  
	for(i=1;i<n;i++){
		if(c[i]>c[a])  
			a=i; 
		if(strlen(t[i])>strlen(t[b]))    
			b=i; 
	} 
	printf("%s %s\n",t[a],t[b]); 
	return 0;
}

Measured memory_bytes: 972
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;


int main()
{
  FILE *inF, *outF;
  //inF = fopen("in", "r");
  //outF = fopen("out", "w");
  inF = stdin;
  outF = stdout;
  
  ll n;
  fscanf(inF, "%lld", &n);
  
  ll res = 0;
  
  if(n%2==0)
  {
    for(ll i = 10; i <= n; i *= 5)
      res += n/i;
  }
  
  printf("%lld", res);
      
  
  return 0;
}


Measured memory_bytes: 384
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 200010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int a[N],b[N],dp[4],ndp[4];
int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,K,n;
    //double start=clock();
    scanf("%d",&n);
    rep(i,1,n+1)scanf("%d",&a[i]);
    per(i,1,n+1){
        b[i]=b[i+1]+a[i];
        if(b[i]>N)b[i]=N;
    }
    int ans=n;
    ll s=0;
    rep(i,1,n+1){
        rep(j,0,4)ndp[j]=N;
        rep(j,0,4){
            rep(k,0,4){
                if(j==0){
                    if(k==0||k==2){
                        Min(ndp[k],dp[j]+(a[i]%2==0));
                    }
                }
                else if(j==1){
                    if(k==2||k==1){
                        Min(ndp[k],dp[j]+(a[i]%2==0));
                    }
                }
                else if(j==2){
                    if(k==2){
                        Min(ndp[k],dp[j]+(a[i]==0?2:a[i]%2));
                    }
                }
                else{
                    Min(ndp[k],dp[j]+(a[i]==0?2:a[i]%2));
                }
            }
        }
        s+=a[i];
        if(s<N){
            rep(j,0,4)Min(ndp[j],s);
        }
        swap(dp,ndp);
        rep(j,0,4){
            Min(ans,dp[j]+b[i+1]);
        }
    }
    printf("%d\n",ans);
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


Measured memory_bytes: 1792
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - ABC
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4], t[MAX_N + 4];

/* subroutines */

ll merge_sort(char as[], char tmp[], int l, int r) { // [l, r)
  ll ic = 0;

  if (l + 1 < r) {
    int m = (l + r) / 2;
  
    ic = merge_sort(as, tmp, l, m) + merge_sort(as, tmp, m, r);

    int i = l, j = m, k = l;

    while (i < m && j < r) {
      if (as[i] <= as[j]) tmp[k++] = as[i++];
      else tmp[k++] = as[j++], ic += m - i;
    }

    while (i < m) tmp[k++] = as[i++];
    while (j < r) tmp[k++] = as[j++];

    for (int i = l; i < r; i++) as[i] = tmp[i];
  }  

  return ic;
}

/* main */

int main() {
  scanf("%s", s);

  int n = 0;
  for (int i = 0; s[i]; i++) {
    if (i > 0 && s[i - 1] == 'B' && s[i] == 'C')
      s[n - 1] = '.';
    else
      s[n++] = s[i];
  }
  s[n] = '\0';
  //puts(s);

  ll sum = 0;
  for (int i = 0; i < n;) {
    while (i < n && s[i] > 'A') i++;
    if (i >= n) break;

    int j = i + 1;
    while (j < n && s[j] <= 'A') j++;
    sum += merge_sort(s, t, i, j);
    i = j;
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#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 in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;//<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main()
{
	int n;
	cin >> n;
	vector<vector<char> > s(2 * n, vector<char>(2 * n));
	rep(i, n) {
		rep(j, n) {
			cin >> s[i][j];
			s[i + n][j] = s[i][j + n] = s[i + n][j + n] = s[i][j];
		}
	}
	/*
	rep(i, 2 * n) {
		rep(j, 2 * n) {
			cout << s[i][j];
		}
		cout << endl;
	}
	//*/
	ll ans = 0;
	int i0 = 0, j0 = 0;
	while (i0 < n) {
		// DEBUG(i0); DEBUG(j0);
		bool pre = false;
		int k = 0;
		while (true) {
			int a = i0 + k, b = j0 + k;
			if (max(a, b) >= n) {
				break;
			}
			if (!pre) {
				int mi = -1, mj = -1;
				rep(i, n) {
					rep(j, n) {
						if (s[a + i][b + j] != s[a + j][b + i]) {
							mi = i; mj = j;
							i = j = inf;
							break;
						}
					}
				}
				if (mi == -1) {
					ans++;
					pre = true;
					k++;
				}
				else {
					pre = false;
					k += min(mi, mj) + 1;
				}
			}
			else {
				int mi = -1, mj = -1;
				rep (i, n) {
					int j = n - 1;
					if (s[a + i][b + j] != s[a + j][b + i]) {
						mi = i; mj = j;
						i = j = inf;
						break;
					}
				}
				if (mi == -1) {
					ans++;
					pre = true;
					k++;
				}
				else {
					pre = false;
					k += min(mi, mj) + 1;
				}
			}
		}
		if (i0 == 0 && j0 == n - 1) {
			i0 = 1; j0 = 0;
		}
		else if (i0 == 0) {
			j0++;
		}
		else {
			i0++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int N;
    cin >> N;
    ve<pair<int,int>> a(N);
    rep(i,N) cin >> a[i].fi >> a[i].se;
    ve<pair<int,int>> b(N);
    rep(i,N){
        b[i].fi = a[i].fi+a[i].se;
        b[i].se = a[i].fi-a[i].se;
    }
    
    sort(all(b));
    int rob = b[0].fi;
    int ans = 1;
    reps(i,1,N){
        if(rob <= b[i].se){
            ans ++;
            rob = b[i].fi;
        }
    }
    out(ans);
    
  


    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};






int main()
{
    FAST();

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

    int x,n;
    V<int>v;
    cin >> n;
    while(n--)
    {
        cin >> x;
        if(x%2 == 0)v.PSB(x);
    }
    for(int x : v)
    {
        if(x%3 > 0  &&  x%5 > 0)
        {
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
    return 0;
}


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

typedef long long ll;
int main() {
  int x, y;
  cin>>x>>y;
  if(y%2==0 && y>=2*x && y<=4*x) 
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
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; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N;
    int ans = 0;
    int p[N];
    vector<int> V;
    REP(i,N){
        cin >> p[i];
        V.pb(p[i]);
    }
    sort ALL(V);
    int ma = V.size()/2+1;
    int ma2 = V.size()/2;
    if(V[ma-1] == V[ma2-1]){
        cout << 0 << endl;
        return 0;
    }
    
    cout << V[ma-1]-V[ma2-1] << endl;
}

Measured memory_bytes: 1148