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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007

const int mxn = 1e5+500;
int dp[mxn][3];


int main(){
	NINJA;
	int n; cin >> n;
	fo(i,n) fo(j,3) cin >> dp[i][j];

	for(int i=1;i<n;i++){
		
		dp[i][0] = max(dp[i-1][1] + dp[i][0], dp[i-1][2] + dp[i][0]);
		dp[i][1] = max(dp[i-1][0] + dp[i][1] , dp[i-1][2] + dp[i][1]);
		dp[i][2] = max(dp[i-1][1] + dp[i][2], dp[i-1][0] + dp[i][2]);
	}

	int ans = INT_MIN;

	fo(i,3){
		if(dp[n-1][i] > ans) ans = dp[n-1][i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
const int INF = 1001001001;
int main(){
    int n,m; cin >> n >> m;
    int d[n][n];
    int cost[n][n];
    memset(d,INF,sizeof(d));
    memset(cost,0,sizeof(cost));
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        d[a][b]=d[b][a]=c;
        cost[a][b]=cost[b][a]=c;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(d[i][j]<cost[i][j]) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int main (){
int i=0,k=0,a,b;
char s[20];
  scanf ("%d%d%s",&a,&b,s);
  for (i=0;s[i]!=0;i++){
  if (i!=a && s[i]<'9'+1 && s[i]>'0'-1){
  ;
  }
  else if (i==a && s[i]=='-'){
    ;
  }
    else {
      k++;
    break;
    }
  }
  if (k==0){
  printf ("Yes");
  }
  else {
  printf ("No");
  }
return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] S = new String[N];
		int[] P = new int[N];
		String[] T = new String[N];
		
		for(int i = 0; i < N; i++) {
			S[i] = sc.next();
			P[i] = sc.nextInt();
			T[i] = S[i];
		}
		
		Arrays.sort(T);
		Map<Integer, Integer> x = new TreeMap<>(Collections.reverseOrder());
		
		for(int i = 0; i < N; i++) {
			if(i == 0 || !T[i].equals(T[i - 1])) {
				for(int j = 0; j < N; j++) {
					if(T[i].equals(S[j])) {
						x.put(P[j], j);
					}
				}
				for(Integer k : x.values()) {
					System.out.println(k + 1);
				}
			}
			x.clear();
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	for(int i=0;i<h;i++){
		cin >> s[i];
	}

	vector<string> res = s;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int ct = 0;
			if(s[i][j]=='#'){
				res[i][j] = '#';
				continue;
			}
			if(j-1>=0){
				if(s[i][j-1]=='#') ct ++;
				if(i+1<h){
					if(s[i+1][j-1]=='#') ct ++;
				}
				if(i-1>=0){
					if(s[i-1][j-1]=='#') ct ++;
				}
			}
			
			if(i-1 >= 0){
			if(s[i-1][j]=='#') ct ++;
			}

			if(i+1<h){
			if(s[i+1][j]=='#') ct ++;
			}

			if(j+1<w){
				if(s[i][j+1]=='#') ct ++;
				if(i+1<h)
				if(s[i+1][j+1]=='#') ct ++;
				
				if(i-1>=0)
				if(s[i-1][j+1]=='#') ct ++;
			}
			res[i][j] = (char)('0'+ct);
		}
	}
	for(int i=0;i<h;i++){
		cout <<res[i] << endl;
	}
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    ll N;
    cin>>N;
    vll A;
    for(int i=0;i<N;i++){
        ll a;
        cin>>a;
        A.pb(a);
    }

    ll DP[SIZE][3]={};
    for(int i=0;i<SIZE;i++){
        for(int j=0;j<3;j++)
            DP[i][j]=-INFLL;
    }
    DP[0][0]=A[0];
    DP[1][1]=A[1];
    DP[2][2]=A[2];
    for(int i=2;i<N;i++){
        DP[i][0]=max(DP[i][0], DP[i-2][0]+A[i]);
        DP[i][1]=max(DP[i][1], DP[i-2][1]+A[i]);
        DP[i][2]=max(DP[i][2], DP[i-2][2]+A[i]);
        if(i-3<0)
            continue;
        DP[i][1]=max(DP[i][1], DP[i-3][0]+A[i]);
        DP[i][2]=max(DP[i][2], DP[i-3][1]+A[i]);
        if(i-4<0)
            continue;
        DP[i][2]=max(DP[i][2], DP[i-4][0]+A[i]);
    }

    ll ans=-INFLL;

    // for(int i=0;i<3;i++){
    //     for(int j=0;j<N;j++)
    //         cout<<DP[j][i]<<" ";
    //     cout<<endl;
    // }

    for(int i=0;i<3;i++){
        for(int j=0;j<N;j++){
            if(j+1==(N/2)+(N/2)-1+i)
                ans=max(ans, DP[j][i]);
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int main(){
	int n,x;
	while(1){
		cin >> n >> x;
		if(n == 0 and x == 0) break;
		int count = 0;
		for(int i = 1; i <= n; i++){
			for(int j = i+1; j <= n; j++){
				for(int k = j+1; k <= n; k++){
					if(i+j+k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}						

Measured memory_bytes: 3068
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int x;

int main()
{
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> x;
  cout << 1 - x << E;
  //system("pause");
  return 0;
}

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

#define ll long long
#define ull unsigned long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}

ll v[100010];
ll w[100010];
ll dp[101][100010];

int main ()
{
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n, cap;

    while(sl(n) != EOF)
    {
        sl(cap);
        for (i = 1; i <= n; i++)
        {
            sl(w[i]);
            sl(v[i]);
        }

        ll ans = 0;

        memset(dp, -1, sizeof(dp));

        dp[0][0] = 0;

        for (i = 1; i <= n; i++)
        {
            for (j = 0; j <= 1e5; j++)
            {
                 dp[i][j] = dp[i-1][j];
                 if (j-v[i] >= 0 && dp[i-1][j-v[i]] != -1 && dp[i-1][j-v[i]]+w[i] <= cap)
                {
                    if (dp[i][j] >= 0)
                    dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
                    else dp[i][j] = dp[i-1][j-v[i]]+w[i];
                }
                 if (i == n && dp[i][j] >= 0)
                    ans = max(ans,j);

           //     if (j <= 7)
           //     cout << i << " " << j << " " << dp[i][j] << endl;
            }
        }

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


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

class Solution
{
public:
    string odd_even(int a, int b)
    {
        int multi = a * b;

        string ans;

        if (multi % 2 == 0)
        {
            ans = "Even";
        }
        else
        {
            ans = "Odd";
        }
        // return (multi % 2 == 0) ? "Even" : "Odd";
        return ans;
    }
};

int main()
{
    int a, b;
    cin >> a >> b;
    Solution s;
    cout << s.odd_even(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
int js(int n,int m)
{
	int c;
	c=(n-1)*(m-1);
	return c;
}
int ans,n,m;
int main()
{
	scanf("%d %d",&n,&m);
	ans=js(n,m);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+20;
ll n,fa[N],sz[N];
vector<int> e[N];
void dfs(int u,int par)
{
	fa[u]=par;
	sz[u]=1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v==par)	continue;
		dfs(v,u);
		sz[u]+=sz[v];
	}
}
int main()
{
	while(cin>>n)
	{
		for(int i=0;i<=n;i++)
			e[i].clear(); 
		int u,v;
		for(int i=1;i<=n-1;i++)
		{
			scanf("%d%d",&u,&v);
			e[u].push_back(v);
			e[v].push_back(u);
		}
		dfs(1,0);
		int k=0;
		u=n;
		while(u!=1)
			u=fa[u],k++;
		k=(k-1)/2,u=n;
		int x=0,y; 
		for(int i=1;i<=k;i++)
			u=fa[u];
		y=sz[u]; 
		x=n-y;
		if(y>=x)
			puts("Snuke");
		else
			puts("Fennec");	
	}
	
	
	return 0;
}

Measured memory_bytes: 23424
N, M = map(int, input().split())

num = [1] * N
red = [False] * N
red[0] = True

for i in range(M):
    x, y = map(int, input().split())
    if red[x-1]:
        red[y-1] = True
    num[x-1] -= 1
    num[y-1] += 1
    if num[x-1] == 0:
        red[x-1] = False
print(red.count(True))


Measured memory_bytes: 4596
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    adj = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, input().split())
        adj[u-1].append((v-1,w))
        adj[v-1].append((u-1,w))
    
    queue = deque([0])
    visit = [-1] * N
    visit[0] = 1
    
    while queue:
        now = queue.popleft()
        for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
    [print(v) for v in visit]


if __name__ == "__main__":
    main()


Measured memory_bytes: 43828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	if(n%2 == 0){
		ans = (n+1)*(n/2) - n;
	}else{
		ans = ((n-1) + 1)*((n-1)/2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <map>

template <typename T>
void read(T& x)
{
    x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar());
    for (; isdigit(c); x = x * 10 + (c ^ 48), c = getchar());
}

int n, flag = 0;
std::map <int, int> map;

int main()
{
    std::ios::sync_with_stdio(0);
    read(n);
    for (int i = 1; i <= n; ++i)
    {
        int x = 0;
        read(x);
        if (map.count(x))
            flag = 1;
        else
            map[x] = 1;
    }
    if (flag)
        std::cout << "NO" << std::endl;
    else
        std::cout << "YES" << std::endl;
    return 0;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  if (N==2) {
    cout << 1 << endl;
  } else {
    cout << (N-1)*N/2 << endl;
  }
}

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




double func(pair<int,int> p1, pair<int,int> p2)
{
	double dist = pow((p1.first-p2.first)*(p1.first - p2.first) + (p1.second- p2.second)*(p1.second- p2.second),0.5 );
	return dist;
}


long long  fact(int n)
{
	long long s =1;
	for(int i=1;i<=n;i++)
	{
		s  = s*i;
	}

	return s;
}

int main()
{
	int n;
	cin>>n;
	double ans = 0;

	pair<int , int>p[n];
	for(int i=0;i<n;i++)
	{
		cin>>p[i].first;
		cin>>p[i].second;
	}

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			ans+= func(p[i], p[j])*2/n;
		}
	}


	    cout<<fixed<<setprecision(10)<<ans<<endl;

	}

Measured memory_bytes: 256
n, m = map(int, input().split())

graph = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

visited = [False] * (n+1)

stack = [(1, 1, visited)]

count = 0
while stack:
    now, dist, visited_ = stack.pop()
    visited = visited_.copy()
    visited[now] = True
    if dist == n:
        count += 1
    for neighbor in graph[now]:
        if not visited[neighbor]:
            stack.append((neighbor, dist + 1, visited))

print(count)


Measured memory_bytes: 3064
import math

n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    x, y = info[i]
    info[i] = (math.atan2(y, x), x, y)
info = sorted(info)

info = info + info
ans = 0
for i in range(n):
    x, y = 0, 0
    for j in range(i, i + n):
        _, xp, yp = info[j]
        x += xp
        y += yp
        ans = max(ans, (x ** 2 + y ** 2) ** 0.5)

print(ans)

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll a,b,c,s,t,x,y,z;
 ll A,B,C,S,T,X,Y,Z;

 ll cnt;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){

	cin>>a>>b>>c>>x>>y;
	
	t=min(a*x+b*y,max(c*x*2+(y-x)*b,c*y*2+(x-y)*a));

	t=min(t,c*max(x,y)*2);

	cout<<t;

	return 0;

}


Measured memory_bytes: 3604
N, M = map(int, input().split())
set_a = set([int(input()) for _ in range(M)])
MOD = 10**9 + 7

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in set_a else 1
for i in range(2, N+1):
    dp[i] = 0 if i in set_a else dp[i-1] + dp[i-2]
    dp[i] %= MOD
ans = dp[N] % MOD

print(ans)

Measured memory_bytes: 13212
import sys
input = sys.stdin.readline
n,m=(int(i) for i in input().split())

aa=[0 for i in range(100000+10)]
for i in range(m):
  a=int(input())
  aa[a]=1
#print(aa)

d=[0 for i in range(100000+10)]
p=1000000007

d[0]=1
if aa[1] == 0:
    d[1]=1
    
if aa[2] == 0:
    d[2]=d[1]+d[0]
    
for i in range(2,n+1):
    if aa[i] == 0:
        d[i]=d[i-1]+d[i-2]
        d[i]=d[i]%p
    

print(d[n]%p)



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

#define rep(ii,aa,bb) for(int (ii)=int(aa);(ii)<(int)(bb);++(ii))
#define ll long long
#define NL '\n'
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define eps 1e-11
#define sz(x) x.size()
#define FIN freopen("input.txt", "r", stdin);
#define FOUT freopen("output.txt", "w", stdout);

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a > b){
        swap(a,b);
    }
    int aw = a + w , bw = b + w;

    if(a <= b && aw >= bw) cout << 0 << NL;
    else if(b - aw > 0) cout << b - aw << NL;
    else if(b - aw <= 0) cout << 0 << NL;



}








Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


typedef map<string, int> map_type;
typedef pair<string, int> value_type;

struct second_order {
  bool operator()(const value_type& x, const value_type& y) const {
    if( x.second != y.second) return x.second < y.second;
    return x.first > y.first;
  }
};

typedef priority_queue<value_type, vector<value_type>, second_order> pqueue_type;


pqueue_type map_to_pqueue(map_type m) {
    pqueue_type que;
    for(auto it=m.begin(); it!=m.end(); ++it) {
        que.push(*it);
    }
    return que;
}

ll lucas[100];
void calc_lucas(int n) {
    lucas[0] = 2;
    lucas[1] = 1;
    FOR(i, 2, n) {
        lucas[i] = lucas[i-1] + lucas[i-2];
    }
}

int main(void){
    int n;
    cin >> n;
    calc_lucas(n);
    cout << lucas[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n,m,k;
  cin>>n>>m>>k;
  ll a[n],b[m];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<m;i++)
    cin>>b[i];
  ll sum=0,count=0,temp=0,i=0,j=0;   
  while(i<n && sum+a[i]<=k){
    sum+=a[i];
    i++;
  }
  count=i;        
  while(j<m && i>=0){ 
    sum+=b[j];             
    j++;
    while(sum>k && i>0){
      i--;
      sum-=a[i];
    }
    if(sum<=k && i+j>count)
      count=i+j;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 6760
n = int(input())
h = [int(i) for i in input().split()]
count = 0
current = h[0]
maxval = 0
for i in range(1,n):
    if h[i] <= current:
        count += 1
    else:
        if count > maxval:
            maxval = count
        count = 0
    current = h[i]
if count > maxval:
    maxval = count

print(maxval)

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

int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') cout << a+b << endl;
  else cout << a-b << endl;
}


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

int main() {
	int n, C; cin>>n>>C;
	vector<int> s(n), t(n), c(n);
	vector<vector<int>> channels(31,vector<int>(100002));
	for (int i=0; i<n; i++) {
		cin>>s[i]>>t[i]>>c[i];
		for (int j=s[i]; j<=t[i]; j++) {
			channels[c[i]][j]++;
		}
	}

	int ans=0;
	for (int i=1; i<=100000; i++) {
		int current=0;
		for (int j=0; j<=30; j++) {
			if (channels[j][i]) {
				current++;
			}
		}
		if (current>ans) {
			ans=current;
		}
	}

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


Measured memory_bytes: 14080
N = int(input())
M = 10**9 + 7

dp = [
    [[[1 if i==0 else 0 for i in range(N-2)] for j in range(4)] for k in range(4)] for l in range(4)
]
#print([1 if i==0 else 0 for i in range(N-2)])

dp[0][1][2][0] = 0 # AGC
dp[0][2][1][0] = 0 # GAC
dp[1][0][2][0] = 0 # ACG

for m in range(N-3):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    # 問題ないのものは１
                    dp[j][k][l][m+1] += dp[i][j][k][m]
                    #dp[j][k][l][m+1] %= M
                    # AGC,GAC,ACGは全部０にする
                    dp[0][1][2][m+1] = 0
                    dp[0][2][1][m+1] = 0
                    dp[1][0][2][m+1] = 0

                    if (i==0):
                        for o in range(4):
                            dp[o][1][2][m+1] = 0
                            dp[1][o][2][m+1] = 0

total = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            total += dp[i][j][k][N-3]
            total %= M
print(total)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int A, B, C;
  cin >> A >> B >> C;
  if(A == B && B != C) cout << "Yes";
  else if(A == C && B!= C)cout << "Yes";
  else if(B == C && A!=B) cout << "Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			 var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            Array.Sort(input);
            int countEven = 0;

            for(int i=0; i<input.Length; i++)
            {
                if (input[i] % 2 == 0) countEven++;
            }

            if (countEven == 3 || countEven == 1) Console.WriteLine(0);
            else Console.WriteLine(input[0] * input[1]);
            
		}

	}
}

Measured memory_bytes: 3288
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

value = [[0 for i in range(W+1)] for i in range(N)]
for i in range(N):
    for j in range(1,W+1):
        if j<w[i]:
            value[i][j] = value[i-1][j]
        else:
            value[i][j] = max(value[i-1][j],value[i-1][j-w[i]]+v[i])


print(value[N-1][W])

Measured memory_bytes: 27804
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int v[105];

int main(void) {
  int i,j;
  int n,m,x;
  cin>>n>>m>>x;
  rep(i,m){
    int a;
    cin>>a;
    v[a]++;
  }
  int ans1=0;
  for(i=x;i<=n;i++)if(v[i])ans1++;
  int ans2=0;
  for(i=x;i>=0;i--)if(v[i])ans2++;
  cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 256
n = gets.strip.to_i
s = readlines.map {|line| line.strip.split('').sort.join('') }

log = {}
result = 0
s.each do |s|
  log[s] = 0 if log[s].nil?
  log[s] += 1
  result+=log[s]-1 if log[s] > 1
end

p result


Measured memory_bytes: 37996
#include<bits/stdc++.h>
using namespace std;
char s[222222],ans[222222];
int n,dp[222222][2],path[222222][2],nw,c,x;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++)
	{
		dp[i][0]=dp[i][1]=-1e9;
	}
	if (s[0]=='?')
	{
		dp[0][0]=0;
		dp[0][1]=1;
	}
	else if (s[0]=='P') dp[0][0]=0;
	else dp[0][1]=1;
	for (int i=0;i<n-1;i++)
	{
		for (int j=0;j<2;j++)
		{
			for (int k=0;k<2;k++)
			{
				if ((s[i+1]=='D' && !k) || (s[i+1]=='P' && k)) continue;
				nw=dp[i][j];
				if (k) nw++;
				if (!j && k) nw++;
				if (dp[i+1][k]<nw)
				{
					dp[i+1][k]=nw;
					path[i+1][k]=j;
				}
			}
		}
	}
	if (dp[n-1][0]>dp[n-1][1]) 
	{
		c=0;
	}
	else c=1;
	x=n-1;
	while(x>=0)
	{
		if (c) ans[x]='D';
		else ans[x]='P';
		c=path[x][c];
		x--;
	}
	for (int i=0;i<n;i++) putchar(ans[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 7208
#include <iostream>
using namespace std;
int main(){
    int N, X;
    cin>>N>>X;
    int l[101];
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    int ans = 0;
    int x = 0, i;
    if(x <= X)ans++;
    for(i = 1; i <= N; i++){
        x += l[i-1];
        if(x<=X)
        ans++;
    }
    // if(i == N)ans++;
    cout<<ans<<endl;
}

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

int main () {
  string s;
  cin >> s;
  string ans = "Yes";
  if (s[0] == 'A' && s[1] == 'A' && s[2] == 'A') ans = "No";
  if (s[0] == 'B' && s[1] == 'B' && s[2] == 'B') ans = "No";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>
using namespace std;
#define rep(i,n) for (int i=0 ; i<(n);i++)
#define INF 1e9+7
int main(){
	int n,m;
	cin >> n;
	vector<int> a(n);
	rep(i, n)
		cin >> a[i];
	cin >> m;
	int left,right;
	rep(i, m) {
		int cnt=0;
		cin >> left >> right;
		left--;
		rep(j, n) {
			if (j == left)
				cnt += right;
			else cnt += a[j];
		}
		cout << cnt << endl;
	}

}

Measured memory_bytes: 256
n = int(input())
data = list(input().split() for _ in range(n))
c = 0

for k in range(n):
    data[k].append(str(k))


def exchange(a, i, j):
    tmp = a[i]
    a[i] = a[j]
    a[j] = tmp
    return a


def partition(a, p, r):
    x = int(a[r][1])
    i = p-1
    for j in range(p, r):
        if int(a[j][1]) <= x:
            i += 1
            a = exchange(a, i, j)
    exchange(a, i+1, r)
    return i+1


def quicksort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quicksort(a, p, q-1)
        quicksort(a, q+1, r)


quicksort(data, 0, n-1)

for l in range(n-1):
    if int(data[l][1]) == int(data[l+1][1]):
        if int(data[l][2]) > int(data[l+1][2]):
            print('Not stable')
            c = 1
            break

if c == 0:
    print('Stable')

for l in range(n):
    print(data[l][0], data[l][1])



Measured memory_bytes: 29168
W,H,N=list(map(int,input().split(" ")))
point=[]
square=[[1 for i in range(W)] for j in range(H)]
for i in range(N):
    x,y,a=list(map(int,input().split(" ")))
    if a==1:
        for i in range(H):
            for j in range(x):
                square[i][j]=0
    if a==2:
        for i in range(H):
            for j in range(W-1,x-1,-1):
                square[i][j]=0
    if a==3:
        for i in range(y):
            square[i]=[0 for j in range(W)]
    if a==4:
        for i in range(H-1,y-1,-1):
             square[i]=[0 for j in range(W)]

area=0
for i in range(H):
    for j in range(W):
        if square[i][j]==1:
            area+=1
print(area)



Measured memory_bytes: 3188
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
 
	
	ll N;
	cin >> N;
	double an=0,A;
	string B;
	
	
	for (ll i = 0; i < N; i++) {
		cin >> A>>B;
		if (B == "JPY") {
			an += A;
		}
		else {
			an += A * 380000;
		}
	}
	
	cout <<an<< endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    double a,b, c, d, e, f, x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        y=(a*f-c*d)/(a*e-d*b);
        x=(c-b*y)/a;
        printf("%.3f %.3f\n",x,y);
    }
}

Measured memory_bytes: 1080
n, x = map(int, input().split())
a = list(map(int, input().split()))
count_a = 0

for i in range(len(a)-1):
  if a[i]+a[i+1] > x:
    count_a += a[i]+a[i+1] - x
    if x - a[i] < 0:
      a[i+1] = 0
    else:
      a[i+1] -= a[i]+a[i+1] - x

print(count_a)

Measured memory_bytes: 14468
l,r=map(int,input().split())
m=ans=2019
if l//m<r//m:
  print(0)
else:
  a,b=l%m,r%m
  for i in range(a, b+1):
    for j in range(i+1,b+1):
      ans=min(ans,(i*j)%m)
  print(ans)


Measured memory_bytes: 9180
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, input_line):
    """Test Case
    >>> print_ans(3, "3 6 5")
    12
    >>> print_ans(4, "23 36 66 65")
    188
    >>> print_ans(20, "1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181")
    2012721721873704572
    """
    ar = np.array(input_line.split(), 'int64')
    X = np.bitwise_xor.reduce(ar)
    ar = np.hstack((ar, np.array([ 1 << i for i in range(60) if X&(1 << i)],'int64')))
    for k in range(60)[::-1]:
        b = 1 << k
        j = ar&b != 0
        i = np.where(j&(ar<2 * b))[0]
        if len(i):
            i = i[0]
            x = ar[i]
            ar[j] ^=x
            ar[i] = x
    r = np.bitwise_xor.reduce(ar)
    print(r+(r^X))

if __name__ == '__main__':
    N = int(input().rstrip())
    input_line = input().rstrip()
    print_ans(N, input_line)


Measured memory_bytes: 30864
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= MOD;
	}
	return ret;
}

#pragma endregion 



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

	int n;
	cin >> n;
	vi s(n);
	f_vI(s, n);
	sort(all(s));
	int ans = 0;
	f(i, 0, n) {
		ans += s[i];
	}
	if (ans % 10 == 0) {
		f(i, 0, n) {
			if (s[i] % 10 != 0) {
				ans -= s[i];
				cout << ans;
				return 0;
			}
		}
		cout << 0;
		return 0;
	}
	cout << ans;
	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 A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		while (true) {
			C = C - B;
			if (C <= 0) {
				System.out.println("Yes");
				break;
			}
			A = A - D;
			if (A <= 0) {
				System.out.println("No");
				break;
			}
		}
	}

}

Measured memory_bytes: 35720
MODULO = 10**9+7

def perm(n):
	p = 1
	for i in range(1,n+1):
		p = (p*i) % MODULO 
	return p

n, m = map(int, input().strip().split())
x = abs(n-m)
if (x > 1):
	print(0)
else:
	permn = perm(n)
	permm = perm(m)

	if x==0: 
		print((permn*permm*2)%MODULO)
	else: 
		print((permn*permm)%MODULO)


Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys
import bisect

"""
ABC113_C ID 学び：
 python の0埋め　s.rjust(digit,0) でいける
 sortを県ごとにしないといけない、とわかれば、input, sort , outputの３段かいに別れる
どんな配列を持てばいいかは事前に考える。
実際にそこまで立てて、inputをローカルでやると良い
"""

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m = map(int, input().split())
lis_p = [[] for _ in range(n)]  # 県pに属する市の誕生年が入る
city = [[0, 0] for _ in range(m)]  # p と　idx
idx_p = []  # 何番目にそのcity が県pに追加されたかを記憶
# input
for i in range(m):
    p, y = map(int, input().split())
    city[i][0] = p - 1
    city[i][1] = y
    lis_p[p - 1].append(y)
for pref in range(n):
    k = len(lis_p[pref])
    # print(lis_p[pref])
    idx = []
    if k > 0:
        lis_p[pref], idx = zip(*sorted(zip(lis_p[pref], range(k))))
    idx_p.append(list(idx))
# print(lis_p, idx_p)
for i in range(m):
    # string になおす必要がある rjust
    print(str(city[i][0] + 1).rjust(6, "0"), end="")
    print(str(1 + bisect.bisect_left(lis_p[city[i][0]], city[i][1])).rjust(6, "0"))


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll N;

void init()
{
	cin >> N;
}

void solve()
{
	reps(x, 1, 3501) {
		reps(y, 1, 3501) {
			ll a = N * x * y;
			ll b = 4 * x * y - N * x - N * y;
			if (b == 0) continue;
			if (a % b == 0 && a / b > 0) {
				cout << x << " " << y << " " << a / b << endl;
				return;
			}
		}
	}
}


Measured memory_bytes: 384
let () =
  Scanf.scanf "%d" @@ fun n ->
  let h x = x * (x + 1) / 2 in
  let rec g i a =
    if i > n then a
    else g (i + 1) (a + i * (h (n / i))) in  
  Printf.printf "%d" (g 1 0)

Measured memory_bytes: 3812
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	map<ll,ll> m ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		m[a] = i ;
	}
	ll ans = n-1 ;
	ll cnt = 1 ;
	for(int i=1;i<n;i++){
		if(m[i]<m[i+1]) cnt++ ;
		else{
			ans = min(ans,n-cnt) ;
			cnt = 1 ;
		}
	}
	ans = min(ans,n-cnt) ;
	cout << ans << endl ;
}



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

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

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

	int co=0;
	for(int i=0;i<n;++i){
		if(v[i]-c[i]>0){
			co += v[i]-c[i];
		}
	}
	cout << co << endl;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> count(256, 0);
    for (int i = 0; i < s.size(); ++i)
        ++count[s[i]];
    ll res = 1;
    for (int i = 0; i < count.size(); ++i) {
        res = (res * (count[i] + 1)) % mod;
    }
    res = (res + mod - 1) % mod;
    cout << res << endl;

}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 512
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<math.h>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	string str;
	int l,r,n,cnt=0,m;
	while(cin >> str){
		n=str.size()/2;
		r=str.size()-1;
		l=0;
		m=0;
		REP(i,n){
			if(str[l]!=str[r]){
				m=1;
				break;
			}
			l++;
			r--;
		}
		if(m!=1)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1184
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    if n%2==0:
        print(int(n*n/4))
    else:
        print((n//2)*(n//2+1))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        ABC142CStudent[] a = new ABC142CStudent[n];
        for(int i=0; i<n; i++) {
            ABC142CStudent s = new ABC142CStudent();
            s.id = i+1;
            s.xth = in.nextInt();
            a[i] = s;
        }
        Arrays.sort(a);
        for(int i=0; i<n; i++) {
            System.out.print(a[i].id);
            if(i==n-1) {
                System.out.println();
            }
            else {
                System.out.print(' ');
            }
        }
    }
}
class ABC142CStudent implements Comparable<ABC142CStudent> {
    int id;
    int xth;

    @Override
    public int compareTo(ABC142CStudent o) {
        return this.xth - o.xth;
    }
}


Measured memory_bytes: 67204
#include <bits/stdc++.h>
using namespace std;
#define MAX_V 100000
#define INF 1000000000000000
#define int long long
typedef pair<int, int> P; //firstは最短距離,secondは頂点の番号
struct edge
{
    long long to, cost;
};
struct graph
{
    int V;                  //頂点数
    vector<vector<edge>> G; //頂点sからの最短距離
    vector<long long> d;
    graph(int n)
    {
        init(n);
    }
    void init(int n)
    {
        V = n;
        G.resize(V);
        d.resize(V);
        for (int i = 0; i < V; i++)
        {
            d[i] = INF;
        }
    }
    void add_edge(int s, int t, long long cost)
    {
        edge e;
        e.to = t;      //行き先
        e.cost = cost; //cost
        G[s].push_back(e);
    }
    void dijkstra(int s)
    {
        for (int i = 0; i < V; i++)
        {
            d[i] = INF;
        }
        d[s] = 0;
        priority_queue<P, vector<P>, greater<P>> que;
        que.push(P(0, s));
        while (!que.empty())
        {
            P p = que.top();
            que.pop();
            long long v = p.second;
            if (d[v] < p.first)
                continue;
            for (auto e : G[v])
            {
                if (d[e.to] > d[v] + e.cost)
                {
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }
};
main()
{
    int n;
    cin >> n;
    graph G1(n);
    graph G2(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G1.add_edge(a, b, 1);
        G1.add_edge(b, a, 1);
        G2.add_edge(a, b, 1);
        G2.add_edge(b, a, 1);
    }
    G1.dijkstra(0);
    G2.dijkstra(n - 1);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (G1.d[i] <= G2.d[i])
        {
            cnt++;
        }
    }
    if (cnt == n - cnt)
        cout << "Snuke" << endl;
    else if (cnt > n - cnt)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
}


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

using namespace std;
typedef long long ll ;
const int N = 1e5 + 2 , OO = 0x3f3f3f3f ;
ll arr1[N]  , arr2[N] , arr3[N], mem[102][N];
int n , w ;
ll solve(int idx , int value){
    if(value <=0 )
        return 0;
    if(idx < 0)
        return OO;
    ll &ret = mem[idx][value];
    if(~ret)
        return ret;
    ret  = OO;
   ret = min(ret , min(solve(idx -1 , value) , solve(idx -1 , value - arr2[idx]) + arr1[idx]));
    return ret;
}
int main()
{
    cin >> n >> w ;
    for(int i = 0 ; i < n ; ++i) cin >> arr1[i] >> arr2[i];
    memset(mem , -1 , sizeof mem);
    for(int i = 100001 ; i>=0 ; --i){
        if(solve(n-1 , i) <= w){
            cout << i ;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 82176
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
int N;
  cin>>N;
  
  vector<int> A(N); 
  for(int i=0;i<N;i++){
  cin>> A[i];
  
    
  }
   vector<int> B(N);
 
for(int i=0;i<N;i++){
cin>> B[i];
  
  
}
  int count=0;
  for(int i=0;i<N;i++){
    if(A[i]-B[i]>0){
   count+=A[i]-B[i];
    }
  }
  
cout<<count<<endl;


}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var line = br.readLine().split(" ");
      final var h = Integer.parseInt(line[0]);
      final var w = Integer.parseInt(line[1]);
      final var k = Integer.parseInt(line[2]);

      final var lines = new char[h][w];
      for (int i = 0; i < h; i++) {
        final var l = br.readLine();
        for (int j = 0; j < w; j++) {
          lines[i][j] = l.charAt(j);
        }
      }

      int count = 0;
      for (int row = 0; row < Math.pow(2, h); row++) {
        for (int col = 0; col < Math.pow(2, w); col++) {
          if (countBlack(lines, row, col) == k) {
            count++;
          }
        }
      }

      System.out.println(count);
    }
  }

  private static int countBlack(char[][] lines, int rows, int cols) {
    final var rowsBool = new boolean[lines.length];
    for (int i = 0; i < rowsBool.length; i++) {
      rowsBool[i] = (rows & (1 << i)) == (1 << i);
    }

    final var colsBool = new boolean[lines[0].length];
    for (int i = 0; i < colsBool.length; i++) {
      colsBool[i] = (cols & (1 << i)) == (1 << i);
    }

    int count = 0;
    for (int i = 0; i < lines.length; i++) {
      for (int j = 0; j < lines[i].length; j++) {
        if (rowsBool[i] || colsBool[j]) continue;

        if (lines[i][j] == '#') {
          count++;
        }
      }
    }

    return count;
  }
}


Measured memory_bytes: 34108