akhauriyash/Code-Regression huggingface dataset:
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <string>

int main() {
	usize n;
	::std::cin >> n;
	::std::string  a, b, c;
	::std::cin >> a >> b >> c;

	usize ans = 0;
	for (const auto i : rep<>(0, n)) {
		if (a[i] == b[i] && b[i] == c[i]) {

		}
		else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
			++ans;
		}
		else {
			ans += 2;
		}
	}
	::std::cout << ans << ::std::endl;
	return 0;
}


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

int main(){

    int a, b, k;
    cin >> a >> b >> k;

    vector<int> v;
    for(int i = 1; i <= min(a,b); i++){
        if(a % i == 0 && b % i == 0){
            v.push_back(i);
        }
    }

    cout << *(v.end() - k) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A;
  cin>> N>> A;
  vector<int>X(N+1,0);
  int S=0;
  for(int i=1; i<=N; i++){
    int x;
    cin >>x;
    X[i]=x;
    S+=x;
  }
  S=max(S, A*N);
  vector<vector<vector<long long>>> Z(N+1, vector<vector<long long>>(N+1, vector<long long>(S+1, 0)));
  for(int i=1; i<=N; i++){//i枚目までを対象
    for(int j=1; j<=i; j++){//カード枚数
      for(int k=j; k<=S+1; k++){//score
        Z[i][j][k]=Z[i-1][j][k];
        if(j==1 &&k==X[i]){
          Z[i][j][k]++;
          continue;
        }
        if(k-X[i]>0) Z[i][j][k]+=Z[i-1][j-1][k-X[i]];
      }
    }
  }
  long long ans=0; 
  for(int i=1; i<=N; i++){
    ans+=Z[N][i][A*i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 52224
function Main(input) {
    var inp = input.split("\n");
    var s = inp[1];
    var ab = inp[0].split(' ').map(n => parseInt(n));
    var a = ab[0];
    var b = ab[1];
    var count = 0;
    for (i = 0; i <= a+b; i++) {
        if(0 <= i && i < a) {
            if(!isNaN(s[i])) {
                count++;
            }
        } else if(a < i && i <= a+b) {
            if(!isNaN(s[i])) {
                count++;
            }
        } else if(i === a) {
            if(s[i] === '-') {
                count++;
            }
        } 
    }
    if (count === a+b+1) {
        console.log('Yes');
    } else {
        console.log('No');
    }
 
    
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }
UINT luin() { UINT x; scanf("%llu", &x); return x;}


int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int N = in();

    int *abIn = new int[N+1];
    int *abExist = new int[1000001];
    for (int i = 0; i <= 1000000; ++i) {
        abExist[i] = 0;
    }
    for (int i = 0; i < N; ++i) {
        int nA = in();
        ++abExist[nA];
        abIn[i] = nA;
    }

    int nAns = 0;
    for (int i = 0; i < N; ++i) {
        int nCheck = abIn[i];
        int nMaxD = sqrt(nCheck);
        for (int j = 1; j <= nMaxD; ++j) {
            bool bDiv = nCheck % j == 0;
            if (bDiv) {
                if (abExist[j] > 0) {
                    if (1 == nCheck) {
                        if (abExist[1] == 1) {
                            continue;
                        }
                    }
                    ++nAns;
                    break;
                }  
                if (abExist[nCheck / j] > 0) {
                    if (1 == j) {
                        if (abExist[nCheck] == 1) {
                            continue;
                        }
                    }
                    ++nAns;
                    break;
                }
            }
        }
    }

    printf("%d", N - nAns);

    delete[] abExist;
    delete[] abIn;

    return 0;
}







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

using namespace std;

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

    // グリッドの初期化
    char g[100][100];
    for (int i = 0; i < 50; ++i) {
        for (int j = 0; j < 100; ++j) {
            g[i][j] = '#';
            g[i + 50][j] = '.';
        }
    }

    // 白を塗る
    int white = 1;
    for (int i = 0; i < 50; i += 2) {
        for (int j = 0; j < 100; j += 2) {
            if (white == w) {
                break;
            } else {
                g[i][j] = '.';
                white++;
            }
        }
    }

    // 黒を塗る
    int black = 1;
    for (int i = 51; i < 100; i += 2) {
        for (int j = 0; j < 100; j += 2) {
            if (black == b) {
                break;
            } else {
                g[i][j] = '#';
                black++;
            }
        }
    }

    // 答えの表示
    cout << 100 << " " << 100 << endl;
    for (auto & i : g) {
        for (char j : i) {
            cout << j;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
char *P[]={"No","Yes"};
char f;

int x, y;
char c;
int main(){
	while((c=getchar())!=10){
		if('0'<=c && c<='9'){
			x = x*10 + (c-'0');
		}
	}
	y = sqrt(x);
	f = y*y == x;
	puts(P[f]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;

	if (N >= 2 * K - 1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 100

int main(void) {
  int n, a, b, c, x0, i, frame, stopped, x;
  int y[MAX_N];
  while (1) {
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &x0);
    if (n == 0) return 0;

    for (i = 0; i < n; i++)
      scanf("%d", &y[i]);

    frame = 0;
    stopped = 0;
    x = x0;
    while (frame <= 10000) {
      if (x == y[stopped]) stopped++;
      if (stopped == n) {
	printf("%d\n", frame);
	break;
      }
      x = (a * x + b) % c;
      frame++;
    }
    if (frame > 10000) printf("-1\n");
  }
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],m,k,ans=0,fl=0;
	string s;
	cin>>n>>s;
	a[0]=1;
	ll j=0,ct=0;
	if(s[0]=='R')
		ct++;
	for(int i=1;i<n;i++)
	{
		if(s[i]=='R')
			ct++;
		if(s[i]==s[i-1])
			a[j]++;
		else
		{
			j++;
			a[j]++;
		}
	}
	j++;
	int i=0;
	if(s[0]=='R' && j<=2)
		ct=0;
	if(s[0]=='R')
	{
		ct-=a[0];
		i++;
	}
	// cout<<ct<<" ";
	while(ct>0 && i<j)
	{
		// cout<<a[i]<<" "<<ct<<endl;
		// if(s[0]=='W')
		// {
			if(a[i]<ct)
			{
				ct-=a[i];
				ans+=a[i];
			}
			else
			{
				ans+=ct;
				ct=0;
			}
			if(i+1<j)
				ct-=a[i+1];
		// }
		i+=2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4520
import java.util.*;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
      	int max = 0;
      	int min = 0;

      	for (int i = 0; i < n; i++) {
          	int a = Integer.parseInt(sc.next());
        	if (i == 0) max = min = a;
          	if (max < a) max = a;
          	if (min > a) min = a;
        }
      	System.out.println(max - min);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <valarray>
#include <iterator>
#include <stack>
#include <set>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <list>
#include <map>

#define def(type,vec) vector<type> vec
#define last(arr) arr.size()-a
#define loop(i,n) for(ll i=0 ; i<n ; ++i)
#define all(v) ((v).begin()),((v).end())
#define pb push_back
#define ll long long
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)

using namespace std;

int main(){
    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    if(arr[0] == 5 && arr[1] ==5 && arr[2] == 7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

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

	long long a;
	cin >> a;
	cout << 3 * a*a << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
  li <- getLine
  let [n,m] = map read $ words li
  co <- getContents
  let (as,bs) = splitAt n $ lines co
  let ans = compute n m as bs
  putStrLn $ if ans then "Yes" else "No"

compute :: Int -> Int -> [String] -> [String] -> Bool
-- compute n m as bs = any (bs ==) $ concatMap (transpose . map (cut n m)) $ cut n m as
compute n m as bs = not $ null
  [ ()
  | as1 <- cut n m as
  , bs1 <- transpose $ map (cut n m) as1
  , bs1 == bs ]

-- cut n m xs : 長さnのリストxsから、長さmの部分リストを全て切り出す
cut :: Int -> Int -> [a] -> [[a]]
cut n m xs = map (take m) $ take (n-m+1) $ tails xs


Measured memory_bytes: 1148
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int64_t sn(int64_t n) {
    int64_t ret = 0;
    while (n > 0) {
        auto r = n % 10;
        n = n / 10;
        ret += r;
    }
    return ret;
}

int main()
{
    int64_t N;
    std::cin >> N;

    if (N % sn(N) == 0) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k=0;
	cin>>n;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		cin>>k;
		mp[k]++;
	}
	int ans=0;
	for(auto i:mp)
	{
		if(i.second<i.first)
		{
			ans+=i.second;
		}
		else
		ans+=i.second-i.first;
	}
	cout<<ans;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647

long gcd(long m, long n);
long lcm(long m, long n);

int main( void ){

	string str;
	cin >> str;
	int ans = 1e8;
	for( int i = 0; i < str.size() - 2; i++ ){
		string tmp = str.substr(i, 3);
		int t = stoi(tmp);
		if( abs(t-753) < ans ) ans = abs(t-753);
	}
	cout << ans;

	return 0;

}

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

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

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

Measured memory_bytes: 256
import math
a_h, b_m, hour, minute = map(int, input().split(" "))
pi = math.pi
arg_h = (hour + minute/60) * 360/12
arg_m = minute * 360/60

diff_arg = abs(arg_h - arg_m)
ans_square = a_h**2 + b_m**2 - 2 * a_h * b_m * math.cos(math.radians(diff_arg)) 
ans = math.sqrt(ans_square)
print(ans)

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

int main(){
	string T, P;
	cin >> T >> P;
	for (long i = 0; i < T.size(); i++){
		for (long j = 0; j < P.size(); j++){
			if (i + j + 1 > T.size()) break;
			if (T[i + j] != P[j]) break;
			if (j == P.size() - 1) cout << i << endl;
		}
	}
	return 0;
}

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

#define ankit_2305 cerr<<"\nTime taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<" sec\n";
#define START clock_t
#define TIMER time_p=clock();
#define ll long long

#define MOD 1000000007

using namespace std;

int main(){
    START TIMER
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin>>n;
	int a;
	map<int, int> mp;
	for(int i=0;i<n;i++){
		cin>>a;
		mp[a]++;
	}
	
	bool flag = true;
	for(auto i: mp){
		if(i.second > 1){
			flag = false;
			break;
		}
	}
	
	if(flag)
		cout<<"YES";
	else
		cout<<"NO";
	
    ankit_2305
    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

int judge(int a,int b,int k)
{
	if (b - a + 1 >= k){
		return 1;
	}else{
		for (int i = a;i <= b;i++){
			if (i % k == 0)return 1;
		}
	}

	return 2;
}

int main()
{
	int A,B,K;

	scanf("%d",&K);
	scanf("%d %d",&A,&B);

	if (judge(A,B,K) == 1){
		printf("OK\n");
	}else{
		printf("NG\n");
	}

	return 0;
}


Measured memory_bytes: 1664
def solve(n, a, b):
    ans = 0
    for i in range(n-1, -1, -1):
        p = (a[i]+ans) % b[i]
        q = (b[i] - p) % b[i]
        ans += q
    return ans

n = int(input())
a, b = [0] * n, [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
print(solve(n, a, b))

Measured memory_bytes: 10868
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  int n;
  cin>>n;
  ll a[n];
  rep(i,n) cin>>a[i];

  int i=n-1;
  while(true)
  {
    cout<<a[i]<<" ";
    i-=2;

    if(i==-1)
    {
      i=0;
      break;
    }
    else if(i==-2)
    {
      i=1;
      break;
    }
  }
  while(i<n-1)
  {
    cout<<a[i]<<" ";
    i+=2;

    if(i>n-1) break;
  }
}

Measured memory_bytes: 3712
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    for(int i = 0; i < N; i++){
      long a = Long.parseLong(S[i]);
      if(a == 0){
        System.out.println(0);
        return;
      }
    }
    BigDecimal now = new BigDecimal("1");
    BigDecimal max = new BigDecimal("1000000000000000000");
    for(int i = 0; i < N; i++){
      BigDecimal A = new BigDecimal(S[i]);
      now = now.multiply(A);
      if(now.compareTo(max) == 1){
        now = new BigDecimal("-1");
        break;
      }
    }
    System.out.println(now.longValue());
  }
}


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

class Dice{
public:
    int *arr;
    Dice(int arr2[]){arr = arr2;}

    void roll(char direction){
        int temp;
        switch(direction){
            case 'N':
                temp = arr[0]; arr[0] = arr[1]; arr[1] = arr[5]; arr[5] = arr[4]; arr[4] = temp;
                break;
            case 'E':
                temp = arr[0]; arr[0] = arr[3]; arr[3] = arr[5]; arr[5] = arr[2]; arr[2] = temp;
                break;
            case 'W':
                temp = arr[0]; arr[0] = arr[2]; arr[2] = arr[5]; arr[5] = arr[3]; arr[3] = temp;
                break;
            case 'S':
                temp = arr[0]; arr[0] = arr[4]; arr[4] = arr[5]; arr[5] = arr[1]; arr[1] = temp;
        }
    }

    int report(){return arr[0];}

    int rightside(int a, int b){
        string line = "WWWNNN";
        for(int i = 0; i < 6; i++){
            if(arr[0] == a) break;
            roll(line[i]);
        }
        roll('N');
        line = "EEE";
        for(int i = 0; i < 3; i++){
            if(arr[0] == b) break;
            roll(line[i]);
        }
        roll('S');
        if(arr[0] != a || arr[1] != b) return -1;
        else return arr[2];
    }

    bool issame(int arr2[]){
        string line = "NNNNENNNNENNNNENNNNNENNNNEENNNN";
        for(int i = 0; i < 31; i++){
            bool same = true;
            for(int j = 0; j < 6; j++){
                if (arr[j] != arr2[j]){
                    same = false;
                    break;
                }
            }
            if(same) return true;
            else roll(line[i]);
        }
        return false;
    }
};

int main(){
    int arr[6], arr2[6];
    for(int i = 0; i < 6; i++) cin >> arr[i];
    Dice dice(arr);
    for(int i = 0; i < 6; i++) cin >> arr2[i];

    string same = "No";
    if(dice.issame(arr2)) same = "Yes";
    cout << same << endl;

    return 0;
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, m; cin>>n>>m;
    cout << n*(n-1) / 2 + m*(m-1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 98620
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}

auto mdist(pair<int, int> a, pair<int, int> b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}

class peak {
public:
	int height;
	int good = 0;
	vector<int> to;

};





int main() {

	int n, m;
	cin >> n >> m;
	vector<peak> peaks(n);
	rep(i, 0, n) {
		cin >> peaks[i].height;
	}
	rep(i,0 , m) {
		int ta, tb;
		cin >> ta >> tb;
		peaks[ta - 1].to.push_back(tb);
		peaks[tb - 1].to.push_back(ta);
	}

	rep(i, 0, n) {
		bool good = true;

		if (peaks[i].good == -1) {
			good = false;
		}
		else {
			rep(j, 0, peaks[i].to.size()) {
				int to = peaks[i].to[j] - 1 ;
				if (peaks[i].height <= peaks[to].height) {
					good = false;
				}
				else {
					peaks[to].good = -1;
				}
			}
		}


		if (good) {
			peaks[i].good = 1; 
		}
		else {
			peaks[i].good = -1;
		}
	}

	int ans = 0;
	rep(i, 0, n) {
		if (peaks[i].good == 1)ans += 1;
	}

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



Measured memory_bytes: 9016
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int n,m; cin >> n >> m;
  vector<int> a(m+1); rep(i,m){cin >> a[i+1];}
  vector<ll> f(n+1,-1);

  if (m==0){f[1]=1;f[2]=2;}
  else{
    if (a[1]>2){f[1]=1;f[2]=2;}
    else if (a[1]==2){f[1]=1;f[2]=0;}
    else if (a[2]==2){f[1]=0;f[2]=0;}
    else if (a[1]==1){f[1]=0;f[2]=1;}
  }

  rep(i,m){f[a[i+1]]=0;}

  for (int i=3; i<=n; i++){
    if (f[i]!=0){f[i]=(f[i-1]+f[i-2])%1000000007;}
  }

  cout << f[n];


  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a < b){
        for(int i = 0; i < b; i++) cout << a;
        cout << endl;
    }
    else{
        for(int i = 0; i < a; i++) cout << b;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;

ll calc_sum(ll n)
{
    return (n * (n + 1) / 2) % MOD;
}

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

    vector<int> v(n);

    for(int i = 0; i < n; ++i)
        cin >> v[i];

    vector<ll> is_less(n);
    vector<ll> inv(n);

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(v[i] > v[j]) {
                ++is_less[i];

                if(j > i)
                    ++inv[i];
            }
        }
    }

    ll sum = calc_sum(k - 1);

    ll out = 0;
    for(int i = 0; i < n; ++i) {
        ll x = (inv[i] * k) % MOD;
        ll y = (sum * is_less[i]) % MOD;
        out = (out + x + y) % MOD;
    }

    cout << out << endl;

    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n, m;
    cin >> n >> m;
    vvi a(n, vi(m));
    rep(i, n) rep(j, m) {cin >> a[i][j]; a[i][j]--;}

    auto valid = [&](int x) {
        vi p(n);
        vector<bool> skipped(m);
        while (true) {
            vi cnt(m);
            rep(i, n) {
                cnt[a[i][p[i]]]++;
            }
            bool piyo = true;
            rep(d, m) {
                if (cnt[d] > x) {
                    skipped[d] = true;
                    rep(i, n) {
                        while (p[i] < m && skipped[a[i][p[i]]]) {
                            p[i]++;
                        }
                        if (p[i] >= m) {
                            return false;
                        }
                    }
                    piyo = false;
                    break;
                }
            }
            if (piyo) return true;
        }
    };

    rep2(x, 1, n + 1) {
        if (valid(x)) {
            cout << x << endl;
            return 0;
        }
    }
}


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    int cl = x - r;
    int cr = x + r;
    int ct = y + r;
    int cb = y - r;

    if (cl >= 0 && cr <= w && ct <= h && cb >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main() {

  int w;

  int fee;


  while(1) {

    cin >> w;

    if(w==-1) break;

    fee=1150;

    if(w>30) fee+=160*(w-30);

    if(w>20) fee+=140*min(w-20,10);

    if(w>10) fee+=125*min(w-10,10);

    cout << 4280-fee << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    string s;cin >> s;
    map<string , int> m;

    for(int i=0; i<s.size() ; i++){
       if(m[s.substr(i,1)]++>0) {
           yes(0)
           return 0;
       }
    }
    yes(1)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
main(){
	bool x;
  cin>>x;
  	if(x) puts("0");
  	else puts("1");
}


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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < n; j++) {
            if (s[i] == 'Z') {
                s[i] = 'A';
                continue;
            }
            else s[i]++;
        }
    }

    for (int i = 0; i < s.size(); i++) {
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string x;
  cin >> x;
  int n = x.length();
  int s = 0, t = 0, ans = n;
  for (int i = 0; i < n; i++){
    if(x[i] == 'S'){
      s++;
    }else if(x[i] == 'T'){
      if(s>0){
        s--;
        ans -= 2;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 640
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
int T[101010], X[101010], Y[101010];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> T[j] >> X[j] >> Y[j];
    }

    int d0 = X[0] + Y[0];
    if ((T[0] - d0) < 0 || (T[0] - d0) % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int j = 0; j < N-1; ++j) {
        int d = abs(X[j] - X[j+1]) + abs(Y[j] - Y[j+1]);
        if ((T[j+1] - T[j] - d) < 0 || (T[j+1] - T[j] - d) % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 07:10:00 2020

@author: liang
"""


# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 00:26:07 2020

@author: liang
"""

"""
コーナーケース１:
    重複があるとき　not coprime
    ただし、1の重複は除く
"""
import math
C = 10**6
N = int(input())
judge = [False]*(C+1)
A = [int(x) for x in input().split()]

f = True
for a in A:
    if judge[a] == True and a != 1:
        f = False
    judge[int(a)]=True


#print(judge[:10])
def solve(f):
    
    ans = A[0]
    #線形探索 O(N)
    for i in range(N):
        ans = math.gcd(ans,A[i])
    #print("ans",a)
    if ans != 1:
        return "not coprime"
    
    flag = True
    #エラトステネスの篩 O(N log N)
    for i in range(2,C+1):
        count = 0
       #if d[i] == True:
        for j in range(i,C+1,i):
            if judge[j] == True:
                count += 1
            if count == 2:
                flag = False
                break
        #        d[j] = False
        if not flag:
            break
    
    if flag == True and f == True:
        return "pairwise coprime"
    
    return "setwise coprime"

print(solve(f))
#print(len(A))

Measured memory_bytes: 194984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 200010;

int father[N];

bool isRoot[N];

int findFather(int x) {

	if (x == father[x]) return x;

	int fa = findFather(father[x]);

	father[x] = fa;

	return fa;

}
//并查集的合并操作 
void Union(int x, int y) {

	int fax = findFather(x);

	int fay = findFather(y);

	if (fax != fay)

		//两者的根节点不一样才进行合并操作

		father[fax] = fay;

}
void init(int n) {

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

		father[i] = i;

		isRoot[i] = false;

	}

}



int main(void) {

	int n, m, a, b;

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

	init(n);
	map<int, map<int, int> > ma;
	for (int i = 0; i < m; ++i) {

		scanf("%d%d", &a, &b);
		if (a>b)swap(a, b);
		if (ma.count(a) && ma[a].count(b))continue;
		ma[a][b]++;
		Union(a, b);
	}
	map<int, int> cnt;
	for (int i = 0; i < n; ++i) {

		//isRoot[findFather(i + 1)] = true;
		cnt[findFather(i + 1)]++;
	}

	int ans = 0;
	for (auto v : cnt) {
		ans = max(ans, v.second);
	}

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

}



Measured memory_bytes: 39100
// abc177_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;
    vector<int> size; // size[i]: iが親なら連結成分の数

    UnionFind(int N) : par(N), rank(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {par[i] = i; rank[i] = 0; size[i] = 1;}
    }

    int find(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = find(x); //xの根をrx
        int ry = find(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        // rank[rx] >= rank[ry] となるように rx と ry を swap
        if(rank[rx] < rank[ry]) swap(rx, ry);

        // 同じ高さだったならばまとめたことによって高さ +1
        if(rank[rx] == rank[ry]) ++rank[rx];

        par[ry] = rx; // root rx に ry の木をつなぐ
        size[rx] += size[ry];
        size[ry] = 0;

    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

    int get_size(int x){
        int rx = find(x);
        return size[rx];
    }
};


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    UnionFind uf(N);
    REP(i, M){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    REP(i, N){
        ans = max(ans, uf.get_size(i));
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 5552
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $c);
if ($a == $b && $b == $c) {
  echo 'No';
  exit;
}
if ($a == $b or $b == $c or $a == $c) {
  echo 'Yes';
  exit;
}

echo 'No';

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
namespace combinatorics
{
	int *fac;
	int *ifac;
	int __Tmod;
	inline int add(int a,int b)
	{
		return (a+b)%__Tmod;
	}
	inline int sub(int a,int b)
	{
		return (a-b+__Tmod)%__Tmod;
	}
	inline int mult(int a,int b)
	{
		return (1LL*a*b)%__Tmod;
	}
	inline int fastpow(int basic,int x)
	{
		int res=1;
		while(x)
		{
			if(x&1)	res=mult(res,basic);
			basic=mult(basic,basic);
			x>>=1;
		}
		return res;
	}
	inline int inv(int x)
	{
		return fastpow(x,__Tmod-2);
	}
	void init(int n,int tmod)
	{
		__Tmod=tmod;
		fac=new int[n+5];
		ifac=new int[n+5];
		fac[0]=1;
		for(int i=1;i<=n;i++)
		{
			fac[i]=mult(fac[i-1],i);
		}
		ifac[n]=inv(fac[n]);
		for(int i=n-1;i>=0;i--)
		{
			ifac[i]=mult(ifac[i+1],i+1);
		}
	}
	inline int C(int n,int m)
	{
		return mult(mult(fac[n],ifac[m]),ifac[n-m]);
	}
	inline int Cat(int x)
	{
		return mult(C(x*2,x),inv(x+1));
	}
};
using namespace combinatorics;
namespace factorization
{
	std::vector <int> getfactors(int x)
	{
		std::vector <int> vec;
		for(int i=1;i*i<=x;i++)
		{
			if(x%i==0)
			{
				vec.push_back(i);
				if(i!=x/i) vec.push_back(x/i);
			}
		}
		sort(vec.begin(),vec.end());
		return vec;
	}
};
using namespace factorization;


#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
const int mod=1e9+7;
using namespace std;
int n,k;
map <int,int> m;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>k;
	init(0,mod);
	vector <int> vec=getfactors(n);
	int res=0;
	for(auto len:vec)
	{
		int &s=m[len];
		if(len&1)
		{
			s=fastpow(k,(len+1)/2);
		}
		else
		{
			s=fastpow(k,len/2);
		}
		vector <int> v=getfactors(len);
		for(auto x:v)
		{
			if(x==len) continue;
			s=sub(s,m[x]);
		}
		if(len&1)
		{
			res=add(res,mult(len,s));
		}
		else
		{
			res=add(res,mult(len/2,s));
		}
	}
	cout<<res<<endl;
	return 0;
}

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

int main(){
    int K, S;

    cin >> K >> S;

    if (S > 3*K) {
        printf("input error");
        return 0;
    }

    int result = 0;
    int z = 0;

    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            z = S - x - y;
            //printf("%d\n",z);
            if (0 <= z && z <= K) {
                result++;
            }
        }
    }

    cout << result << endl;

}


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

typedef long long ll;

ll gcd(ll a, ll b){
    if(b > a) swap(b,a);

    ll r;

    while((r = a%b)){
        a = b;
        b = r;
    }

    return b;
}

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


int main(){
    int N;
    cin>>N;
    vector<ll> T(N);
    for(int i=0; i<N; i++) cin>>T[i];

    ll ans = T[0];

    for(int i=1; i<N; i++){
        ans = lcm(ans,T[i]);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, ans;
int a[N], dp[N];
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	rep(i, 1, n) cin >> a[i];
	
	rep(i, 1, n) {
		dp[a[i]] = max(dp[a[i]], dp[a[i] - 1] + 1);
		ans = max(ans, dp[a[i]]);
	}
	
	cout << n - ans;
	ioi
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, x[100010], sum[100010];

ll ans;

ll gcd(ll x, ll y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	
}

void output()
{
	//cout << ans << endl;
}



void solve()
{
	ll x;
	cin >> x;
	vector<ll> vec;
	for (int i = 2; i <= 200000; i++)
	{
		bool jud = true;
		for (int j = 2; j * j <= i; j++)
		{
			if (i % j == 0) jud = false;
		}

		if (jud)
		{
			vec.push_back(i);
		}
	}
	for (int i = 0; i < vec.size(); i++)
	{
		if (vec[i] >= x)
		{
			cout << vec[i] << endl;
			break;
		}
	}
}

int main()
{
	init();
	
	solve();

	

	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 640
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c;cin>>a;
  rep(i,10)rep(o,10)if(i*o==a){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No";
}



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

int main(){
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]) ans+=1;
    }
    cout<<ans<<endl;
    }

Measured memory_bytes: 256
//
//  How_many_Divisors.c
//  AOJ
//
//  Created by admin on 2014/07/12.
//
//

#include <stdio.h>

main(){
    int a,b,c;
    int i;
    
    scanf("%d %d %d",&a,&b,&c);
    
    for(i=0;a<=b;a++){
        if(c % a == 0){
            i++;
        }
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5)||(a==7 && b==5 && c==5))
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

   return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    cout << 800 * n - 200 * (n / 15) << endl;

    return 0;
}


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

int main(){
	int n; cin >> n;
	int s = INT_MAX;
	int ans = INT_MIN;
	for (int i = 0; i < n; i++) {
		int r; cin >> r;
		ans = max(ans, r - s);
		s = min(s, r);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3120
import string

N=int(input())
S=input()
#N=2
#S='ABCXYZ'
ucase=string.ascii_uppercase
#print(ucase)
ucase=ucase+ucase
outstr=''
for x in S:
    p=ucase.find(x)+N
    outstr=outstr + ''.join(list(ucase)[p] )


print(outstr)




Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > pq;

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

long long nCr(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long MOD) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long Mod) {
    return modpow(a, Mod - 2, Mod);
}


bool IsPrime(int x){
    for (int i = 2; i*i <= x; i++){
        if (x % i == 0){
            return false;
        }
    }
    return true;
}

vector<pair<ll, ll> > PrimeFactor(ll N){
    vector<pair<ll, ll> > prime;
    for (int i = 2; i*i <= N; i++){
        if (N % i != 0) continue;
        int cnt = 0;
        while (N % i == 0){
            cnt++;
            N /= i;
        }
        prime.push_back({i, cnt});
    }
    if (N > 1){
        prime.push_back({N, 1});
    }
    return prime;
}

vector<pair<ll, ll> > CountPrime(ll N){
    vector<pair<ll, ll> > prime;
    for (ll i = 2; i * i <= N; i++){
        if (N % i != 0) continue;
        ll cnt = 0, n = N;
        while (n % i == 0){
            cnt++;
            n /= i;
        }
        prime.push_back({i, cnt});
    }
    prime.push_back({N, 1});
    return prime;
}

int main(){
    ll N; cin >> N;
    vector<ll> h(N), cost(N+2, MM);
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }

    cost[0] = 0;
    for (int i = 0; i < N-1; i++){
        cost[i+2] = min(cost[i+2], cost[i] + abs(h[i+2]-h[i]));
        cost[i+1] = min(cost[i+1], cost[i] + abs(h[i+1]-h[i]));
    }
    cout << cost[N-1] << endl;
}


Measured memory_bytes: 1792