akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from collections import deque

N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]

ans = N - K + 1

D = deque([x for x in P[:K]])
oc = 0
ordered_twice = False

for i in range(len(D) - 1):
    if D[i] <= D[i + 1]:
        oc += 1

Q = deque([])
Q_min = []
Q_max = []

for i in range(N):
    while len(Q) > 0 and P[Q[len(Q) - 1]] >= P[i]:
        Q.pop()
    Q.append(i)
    if Q[len(Q) - 1] >= K - 1:
        Q_min.append(P[Q[0]])
        if Q[0] == i + 1 - K:
            Q.popleft()

PP = [-x for x in P]
Q = deque([])

for i in range(N):
    while len(Q) > 0 and PP[Q[len(Q) - 1]] >= PP[i]:
        Q.pop()
    Q.append(i)
    if Q[len(Q) - 1] >= K - 1:
        Q_max.append(-PP[Q[0]])
        if Q[0] == i + 1 - K:
            Q.popleft()

for i in range(N - K + 1):
    if i > 0:
        D.popleft()
        D.append(P[i + K - 1])
        if P[i - 1] <= D[0]:
            oc -= 1
        if D[K - 2] <= D[K - 1]:
            oc += 1

        if (Q_min[i - 1] == P[i - 1] and Q_max[i] == D[-1]) or (oc == K - 1 and ordered_twice):
            ans -= 1

    if oc == K - 1:
        ordered_twice = True

print(ans)

Measured memory_bytes: 98180
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j;
    cin>>n;
    while(n>0)
    {
        ll x=n%10;
        if(x==7)
        {
            cout<<"Yes";
            return 0;
        }
        n=n/10;
    }
    cout<<"No";
    return 0;

}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define pb push_back 
#define ff first 
#define ss second
#define all(c) c.begin(), c.end()
#define sz(z) (int)z.size()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; i--)
//Debugging tools 
#define debug(v) cout<<#v<<endl;for(ll i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define debugn(v,n) cout<<#v<<endl;for(ll i=0; i<n; i++) cout<<v[i]<<" "; cout<<endl;
#define deb(sum) cout<<#sum<<" = "<<sum<<endl;
//Predefined values
#define INF (ll)1e18
#define endl "\n"
#define pi 3.142857142857143

const ll MOD = 1e9 + 7;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t=1;    
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        rep(i,0,n) cin>>a[i];
        vector<ll> pref(n);
        rep(i,0,n){
            if(i==0)
                pref[i] = a[i];
            else{
                pref[i] = pref[i-1] + a[i];
            }
        }
        ll ans = 0;
        rep(i,0,n-1){
            ans += ((a[i]%MOD)*((pref[n-1]-pref[i])%MOD))%MOD;
            ans %= MOD;
        }   
        cout<<ans%MOD<<endl;

    }
  return 0;
 }

















Measured memory_bytes: 6360
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX_N = 100000;

int N;
int memo[MAX_N + 3];

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		memo[a]++; memo[b + 1]--;
	}
	int res = 0;
	for(int i = 1; i <= N + 1; i++){
		memo[i] += memo[i - 1];
		if(memo[i] + 1 < i) continue;
		res = max(res, min(memo[i], i - 1));
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()

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

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

const ll INF=1e11;

//string dp[3010][3010];
//この方針だと　tle mle が発生したから
//dpの復元を試みる。
const ll maxv=100010;

ll dp[3010][3010]={0};

int main(){
  string s1,s2;
  cin >> s1 >> s2;
  rep(i,s1.size()){
    rep(j,s2.size()){
      if(s1[i]==s2[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        if(dp[i][j+1]<dp[i+1][j]){
          dp[i+1][j+1]=dp[i+1][j];
        }else{
          dp[i+1][j+1]=dp[i][j+1];
        }
      }
    }
  }
  //cout << dp[s1.size()][s2.size()] <<endl;
  string ans="";
  ll i=s1.size(),j=s2.size();
  while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j]){
      --i;
    }else if(dp[i][j]==dp[i][j-1]){
      --j;
    }else{
      ans=s1[i-1] + ans;
      --i;
      --j;
    }
  }
  cout << ans <<endl;
}


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

int main() {
  // ここにプログラムを追記
  int a, x;
  cin >> a;
  if(a == 0){
    x = 0;
  }
  if(a == 100 || a == 10 || a == 1){
    x = 1;
  }
  if(a == 110 || a == 101 || a == 11){
    x = 2;
  }
  if(a == 111){
    x = 3;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#define int long long
#define max(a,b)((a)>(b)?(a):(b))
const int N=2e5+3,D=1<<18;
struct segment_tree{
	int mx[1<<19];
	inline int Change(int k,int a){
		for(mx[k+=D]=a,k>>=1;k;k>>=1)mx[k]=max(mx[k<<1],mx[k<<1|1]);
	}
	inline int Max(int l,int r){
		int res=0;
		for(l+=D-1,r+=D+1;l^r^1;l>>=1,r>>=1){
		  if(~l&1)res=max(res,mx[l^1]);
		  if( r&1)res=max(res,mx[r^1]);
		}return res;
	}
}t;
int n,a[N],b[N],dp,ans;
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",a+i);
	for(int i=1;i<=n;i++)scanf("%lld",b+i);
	for(int i=1;i<=n;i++)t.Change(a[i],dp=t.Max(1,a[i])+b[i]),ans=max(ans,dp);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6912
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ld= long double;

ld get_dis(const pair<ld,ld>&l,const pair<ld, ld>&r) {
	return sqrt((l.first-r.first)*(l.first-r.first)+(l.second-r.second)*(l.second-r.second));

}

ld dfs(vector<vector<vector<ld>>>&memo,const vector<vector<pair<ld, ld>>>&lines, const int now, const int is_a, bitset<14>&bs) {
	if (memo[now][bs.to_ulong()][is_a] > -1) {
		return memo[now][bs.to_ulong()][is_a];
	}
	if (bs.count() == memo.size()) {
		memo[now][bs.to_ulong()][is_a]=0;
	}
	else {
		ld ans=1e9;
		for (int next = 0; next < lines.size(); ++next) {
			if(bs[next])continue;
			else {
				for (int next_is_a = 0; next_is_a < 2; ++next_is_a) {
					ld plus=get_dis(lines[now][is_a],lines[next][next_is_a]);
					bs[next]=true;
					plus+=dfs(memo,lines,next,!next_is_a,bs);
					bs[next]=false;
					ans=min(ans,plus);
				}
			}
		}

		memo[now][bs.to_ulong()][is_a]=ans;
	}

	return memo[now][bs.to_ulong()][is_a];
}

int main() {
	int case_id=0;
	while (true) {
		case_id++;
		int N;cin>>N;
		if(!N)break;
		vector<vector<pair<ld, ld>>>lines(N);
		for (int i = 0; i < N; ++i) {
			ld x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
			lines[i] = vector<pair<ld,ld>>{ make_pair(x1,y1),make_pair(x2,y2) };
		}
		bitset<14>used;
		vector<vector<vector<ld>>>memo(N,vector<vector<ld>>(1<<14,vector<ld>(2,-1e9)));

		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 2; ++j) {
				memo[i][0][j]=0;

			}
		}
		ld ans=1e9;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 2; ++j) {
				used[i]=true;
				ans=min(ans,dfs(memo,lines,i,j,used));
				used[i]=false;
			}
		}
		for (auto line : lines) {
			ans+=get_dis(line[0],line[1]);
		}
		cout<<setprecision(10)<<fixed;
		cout<<"Case "<<case_id<<": "<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 20084
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ull
#define fi first
#define se second
#define mod 1000000007
#define maxn 200005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;while(t--)
#define go_pt int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<ll,ll>pii;
typedef pair<ll,ll>piii;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    #endif

    fastio;
    string a;
    cin>>a;
    int n = a.size();
    ll k;
    cin>>k;
    string s;
    for(int i=0;i<10;i++)
        s.append(a);
    //cout<<s<<endl;
    vector<int>seq;
    int ind=0,cnt=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
            s[i]='#';
            cnt++;
        }
        ind++;
        if(ind==n){
            seq.pb(cnt);
            cnt=0;
            ind=0;
        }
    }
    ll ans=seq[0];
    if(k==1)cout<<seq[0]<<endl;
    else if(k==2)cout<<seq[0]+seq[1]<<endl;
    else
    {
        k--;
        if(seq[2]==seq[1])
            ans+=k*seq[1];
        else if(seq[2]==seq[0])
        {
            k+=1;
            ans=0;
            ans+=(k/2)*seq[1];
            ans+=(k/2)*seq[0];
            if(k%2==1)ans+=seq[0];
        }
        cout<<ans<<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 = sc.nextInt();
      long sum = 0;
      for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
          int ij = gcd(i, j);
          for(int k = 1; k <= n; k++) {
            sum += gcd(ij, k);
          }
        }
      }
      System.out.println(sum);
  }
  private static int gcd(int a, int b) {
    if(b == 0)  return a;
    return gcd(b, a % b);
  }
}


Measured memory_bytes: 35740
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

const int M_N=200000;

struct BIT{
    //1-indexed
    LL bit[M_N+1],n;

    LL sum(int i){
        LL s=0;
        while(i>0){
            s+=bit[i];
            i=i&(i-1);
        }
        return s;
    }

    void add(int i,LL x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }

};

BIT bit;
map<LL,LL> mp;

int main(){
    int N,t=0;
    LL K;
    cin >> N >> K;
    bit.n=N;
    vector<LL> A,T;
    for(int i=0;i<N;i++){
        LL a;
        cin >> a;
        A.emplace_back(a-K);
    }
    LL sum=0;
    for(int i=0;i<N;i++){
        sum+=A[i];
        T.emplace_back(sum);
    }
    A=T;
    sort(T.begin(),T.end());
    for(int i=0;i<N;i++){
        if(mp[T[i]]) continue;
        mp[T[i]]=i+1;
    }
    LL ans=0;
    for(int i=0;i<N;i++){
        bit.add(mp[A[i]],1);
        ans+=bit.sum(mp[A[i]]++)+(A[i]>=0?0:-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19440
/*

*/
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

#define INF 99999;
#define MOD 1000000007

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int n, m;
char com;
//vector< vector< pair<int, int> > > graph;
int Cost[25][25];
int s, g, V, P;

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

    cin >> n >> m;
    //graph.resize(n);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            Cost[i][j] = INF;
        }
    }
    int a, b, c, d;
    for(int i = 0; i < m; i++){
        cin >> a >>com>> b >>com>> c >>com>> d;
        Cost[a][b] = c;
        Cost[b][a] = d;
    }
    cin >> s >>com>> g >>com>> V >>com>> P;

    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                dbugf(k)dbugf(i)dbugf(j)dbug(Cost[i][j])dbugln
                Cost[i][j] = min(Cost[i][j], Cost[i][k] + Cost[k][j]);
                dbug(Cost[i][j])dbug(Cost[i][k])dbug(Cost[k][j])dbugln
            }
        }
        dbugln;
    }

    cout << V - Cost[s][g] - Cost[g][s] - P << "\n";

    return 0;
}


Measured memory_bytes: 3136
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int INF = 1001001001;

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << endl;
}


Measured memory_bytes: 256
/**
Code by Nitin1184
**/
# include <bits/stdc++.h>
# define ll long long
# define pi 3.14159265358979323846
# define M 1000000007
# define pb push_back
# define mp make_pair
# define ff first
# define ss second
 
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll a[n],s=0;
    unordered_map<ll,ll> m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
        m[a[i]]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        ll b,c;
        cin>>b>>c;
        s=s-b*m[b]+c*m[b];
        m[c]+=m[b];
        m[b]=0;
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 7844
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var N = input[0];
        var W = input[1];
        var dp = new long[N + 1, W + 1];
        var values = new long[N];
        var weight = new long[N];
        for (var i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            weight[i] = input[0];
            values[i] = input[1];
        }

        /*
         * 3 8
           3 30
           4 50
           5 60
         */

        /*
         *         for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

         */

        for (var i = 0; i < N; i++)
        {
            for (var j = 0; j <= W; j++)
            {
                dp[i + 1, j] = dp[i, j];

                if (j - weight[i] >= 0)
                {
                    dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j - weight[i]] + values[i]);
                }
            }
        }

        Console.WriteLine(dp[N, W]);

        /*
         * 3 8
           3 30
           4 50
           5 60
         */
    }
}

Measured memory_bytes: 89056
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int r;cin>>r;
	cout<<3*r*r<<endl;
}

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

int main()
{
    int cnt = 0 ;
    int n;
    long long d;
    cin >> n >> d;
    long long x,y;
    for(int i=0;i<n;i++){
        cin >> x >>y;
        if(x*x+y*y<=d*d)
            cnt++;

    }

        cout <<cnt <<endl;
    return 0;
}


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

int main(){
    vector<vector<char>> data(3, vector<char> (3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> data.at(i).at(j);
        }
    }

    string ans;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(i==j) ans += data.at(i).at(j);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s,n,w;
  cin>>s>>n>>w;
  cout<<"A"<<n[0]<<"C"<<'\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
    char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const ll p=1000000007;
const int N=100010;
int cmp(pii a,pii b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second>b.second;
}
int n,m,t,t2;
int a[N],b[N],d[N];
pii c[N];
ll e[N];
ll add(ll a,ll b)
{
    a+=b;
    return a>=p?a-p:a;
}
void add(int x,ll v)
{
    for(;x<=t2;x+=x&-x)
        e[x]=add(e[x],v);
}
ll sum(int x)
{
    ll s=0;
    for(;x;x-=x&-x)
        s=add(s,e[x]);
    return s;
}
int main()
{
    //freopen("1.txt","r",stdin);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)
        if(a[i]>b[1]&&a[i]<b[m])
        {
            int x=lower_bound(b+1,b+m+1,a[i])-b;	//lower_bound 是第一个大于等于 a[i]的数，upper_bound是大于 
            if(b[x]==a[i])
                continue;
            c[++t]=pii(a[i]-b[x-1],b[x]-a[i]);		//坐标系上的点 
            d[++t2]=b[x]-a[i];						//点的纵坐标 
        }
    sort(d+1,d+t2+1);
    t2=unique(d+1,d+t2+1)-d-1;	//unique的作用是“去掉”容器中相邻元素的重复元素（不一定要求数组有序），它会把重复的元素添加到容器末尾（所以数组大小并没有改变），而返回值是去重之后的尾地址 
    							//由于返回的是容器末尾，所以如果想得到去重后的size，需要减去初始地址
	for(int i=1;i<=t;i++)
        c[i].second=lower_bound(d+1,d+t2+1,c[i].second)-d;
    sort(c+1,c+t+1,cmp);
    t=unique(c+1,c+t+1)-c-1;
    ll ans=1;
    for(int i=1;i<=t;i++)
    {
        ll s=sum(c[i].second-1)+1;
        ans+=s;
        add(c[i].second,s);
    }
    ans%=p;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int i=0;i<n;i++){cin>>Array[i];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	string s;
	cin >> s;

	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N; 
  string S;
  cin>>N;
    cin>>S;
  bool te=false;
  string A=S.substr(0,N/2);
  string B=S.substr(N/2);
    if(A==B) te=true;
  if (te) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
                  

Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[]
for i in range(M):
  BC.append(list(map(int,input().split())))

A.sort()
BC=sorted(BC, key=lambda x: -x[1])

j=0
for i in range(N):
  if A[i]<BC[j][1]:
    A[i]=BC[j][1]
    BC[j][0]-=1
    if BC[j][0]==0:
      j+=1
      if j==M:
        break
  else:
    break
    
#print(A)
print(sum(A))

Measured memory_bytes: 36944
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,ll>;
const ll inf=1000000000007;


int main() {
  int x;
  cin >> x;
  if(x==1) cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}

Measured memory_bytes: 3628
import math
N = list(input())

def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

change_num = math.floor(len(N) / 2)
ans = 0
count = 1
for i in N[:change_num]:
    if N[-count] != i:
        ans += 1
    count += 1
    
print(ans)

Measured memory_bytes: 3060
/**
 *    author:  math2do
 *    created: 06.09.2020 12:23:23
**/

#include <bits/stdc++.h>

using namespace std;

const int mod = (int) (1e9 + 7);

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <vector <int> > can(n, vector <int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> can[i][j];
    } 
  }
  vector <int> dp(1 << n);
  dp[0] = 1;
  for (int mask = 0; mask < (1 << n) - 1; mask++) {
    int i = __builtin_popcount(mask);
    for (int j = 0; j < n; j++) {
      if (can[i][j] && !(mask & (1 << j))) {
        int m = mask ^ (1 << j);
        add(dp[m], dp[mask]);
      } 
    } 
  } 

  cout << dp[(1 << n) - 1] << endl;
  return 0;
}


Measured memory_bytes: 11368
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

#define all(o) o.begin(), o.end()

void radix_sort(vector<int> &v) {
	vector<int> t(v.size());
	array<int, 256> c, s;
	for (int i = 0; i < 32; i += 8) {
		fill(all(c), 0);
		for_each(all(v), [&](int j) {c[(j >> i) & 255]++;});
		s.front() = 0;
		partial_sum(all(c) - 1, s.begin() + 1);
		for_each(all(v), [&](int j) {t[s[(j >> i) & 255]++] = j;});
		swap(v, t);
	}
}

int main() {
	for (int N, M; N = in(), M = in();) {
		vector<int> t(N), u;
		for (int &p: t)
			p = in();
		t.push_back(0);
		for (auto i = t.begin(); i != t.end(); i++)
			for (auto j = i; j != t.end(); j++)
				if (*i + *j <= M)
					u.push_back(*i + *j);
		radix_sort(u);
		int r = 0;
		for (auto i = u.begin(), e = u.end() - 1; i <= e; i++) {
			for (; *i + *e >= M; e--)
				;
			r = max(r, *i + *e);
		}
		outl(r);
	}
}


Measured memory_bytes: 6116
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<math.h> 
#include<stdlib.h>
#include<map>
#include<set>
#include<time.h>
#include<bitset>
#include<list>
const double inf=1e20;
const int md=1e9+7;
const int MX=1e5+10;
using namespace std;
int a[MX],ans;
int main(){
	int N;scanf("%d",&N);
	for (int i=1;i<=N;i++)
	scanf("%d",&a[i]);
	for (int i=1;i<=N;i++)
	{
		if (i==a[i]) ans++,i++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    ll tmp = C - (A-B);
    print(max(tmp, 0ll));
    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++)
 
int main(){
    int n; cin >> n;
    vector<pair<int, int>> p(n);
    vector<int> t(n);
    rep(i, n){
        cin >> t[i] >> p[i].first >> p[i].second;
    }
    bool ok = true;
    int xi = 0, yi = 0, ti = 0;
    rep(i, n){
        int x = p[i].first, y = p[i].second;
        if (abs(x - xi) + abs(y - yi) > t[i] - ti) ok = false;
        else if ((t[i] - ti)%2 != (abs(x - xi) + abs(y - yi))%2) ok = false;
        xi = x; yi = y; ti = t[i];
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4116
#include<stdio.h>
int main(void)
{
	int a,b,x;
	char op;
	scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
		x=a+b;
	}
	else{
		x=a-b;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
    ll x;
    cin >> x;
    int ans = 0;
    ll cur = 100;
    while(true) {
        ans++;
        cur = cur + cur / 100;
        if(cur >= x) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, n)cin >> x[i] >> v[i];
    vector<ll> l(n), r(n), lm(n), rm(n);
    rep(i, n){
        if(i == 0){
            l[i] = v[i] - x[i];
            lm[i] = l[i];
            r[n-1-i] = v[n-1-i] - (c - x[n-1-i]);
            rm[n-1-i] = r[n-1-i];
        }else{
            l[i] = l[i-1] + v[i] - (x[i] - x[i-1]);
            lm[i] = max(lm[i-1], l[i]);
            r[n-1-i] = r[n-i] + v[n-1-i] - (x[n-i] - x[n-1-i]);
            rm[n-1-i] = max(rm[n-i], r[n-1-i]);
        }
    }

    ll ans = 0;
    rep(i, n){
        ans = max(ans, l[i]);
        if(i < n-1)ans = max(ans, l[i] + rm[i+1] - x[i]);
        ans = max(ans, r[i]);
        if(i > 0)ans = max(ans, r[i] + lm[i-1] - (c - x[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
	int p[100],n,num=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	for(int i=0;i<n-2;i++){
		if(p[i]<p[i+1] && p[i+1]<p[i+2] || p[i]>p[i+1] && p[i+1]>p[i+2]){	
			num++;
		}
	}
	printf("%d\n",num);	
	return 0;
}
	


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

#define N 100010
#define LLINF 2000000000000000000LL

int sum[N][3];
ll dp1[N][5],dp2[N][6];

int main(){
  int n,st[N];
  char s[N];

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

  for(int i=1;i<=n;i++){
    if(s[i-1]=='J') st[i]=1;
    if(s[i-1]=='O') st[i]=2;
    if(s[i-1]=='I') st[i]=3;

    sum[i][st[i]]++;
  }

  for(int i=1;i<=n;i++){
    for(int j=0;j<3;j++){
      sum[i+1][j] += sum[i][j];
    }
  }

  ll ans = 0;

  dp1[0][0] = 1;

  for(int i=1;i<=n;i++){
    dp1[i][st[i]] += dp1[i-1][st[i]-1];
    for(int j=0;j<=4;j++){
      dp1[i][j] += dp1[i-1][j];
    }
  }

  dp2[n+1][4] = 1;

  for(int i=n;i>=1;i--){
    dp2[i][st[i]] += dp2[i+1][st[i]+1];
    for(int j=0;j<=4;j++){
      dp2[i][j] += dp2[i+1][j];
    }
  }

  for(int i=0;i<=n;i++){
    for(int j=1;j<=4;j++){
      ans = max(ans,dp1[i][j-1] * dp2[i+1][j+1]);
    }
  }

  printf("%lld\n",ans + dp1[n][3]);

  return 0;
}

Measured memory_bytes: 13400
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct Node{
  int ID;
  int N;
  Node* p[2];
  Node(int ID) : ID(ID){}
  Node(int ID, int N) : ID(ID), N(N) {}
};
string s;
int L;
int S[10];
int R;
pair<Node*, int> parse(int k){
  if(s[k] == '('){
    Node* res = new Node(L++);
    pair<Node*, int> pr = parse(k + 1);
    res->p[0] = pr.first;
    pair<Node*, int> pr2 = parse(pr.second + 1);
    res->p[1] = pr2.first;
    return make_pair(res, pr2.second + 1);
  }else{
    assert(isdigit(s[k]));
    Node* node = new Node(-1, s[k] - '1');
    return make_pair(node, k + 1);
  }
}
int input(){
  int res = 0;
  REP(i, 4){
    int t; cin>>t;
    res += (t<<i);
  }
  return res;
}
int dfs(Node* p){
  if(p->ID == -1){
    return S[p->N];
  }else{
    int op = R >> (2 * p->ID) & 3;
    int l = dfs(p->p[0]);
    int r = dfs(p->p[1]);
    if(l == -1 || r == -1) return -1;
    if(op == 0){
      return l & r;
    }else if(op == 1){
      return l | r;
    }else if(op == 2){
      return l ^ r;
    }else if(op == 3){
      return -1;
    }
  }
}

int main(){
  while(getline(cin, s) && s != "END"){
    L = 0;
    Node* r = parse(0).first;
    int N; cin>>N;
    REP(i, N){
      S[i] = input();
    }
    int ans = 0;
    for(R = 0; R < 1 << (2 * L); R++){
      if(dfs(r) == 15) ans++;
    }
    cout << ans << endl;
    cin.ignore();
  }
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort((x).begin(), (x).end())
#define CMPSORT(x, cp) sort((x).begin(), (x).end(), cp)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

ll ft[MAXN];

void upd(ll x, ll val){
    for (; x<=MAXN; x+=x&(-x)) ft[x]+=val, ft[x]%MOD;
    return;
}

ll query(ll x){
    ll res=0;
    for (; x; x-=x&(-x)) res+=ft[x], res%=MOD;
    return res;
}

int main(){
    FAST
    ll n;
    cin >> n;
    ll prev=0;

    vector<ll> groups;
    FOR(i,1,n){
        ll x;
        cin >> x;
        if (x!=prev) groups.pb(x);
        prev=x;
    }
    
    n = groups.size();

    vector<ii> colour;
    ll c[MAXN];
    MEM(c,-1);
    FOR(i,0,n-1){
        ll x = groups[i];
        if (c[x]==-1){
            c[x]=i;
        } else {
            colour.eb(c[x]+1,i+1);
            c[x]=i;
        }
    }
    SORT(colour);

    ll ans=0;
    for (auto pr : colour){
        ll k = query(pr.f) + 1;
        ans+=k;
        ans%=MOD;
        upd(pr.s,k);
    }
    ans++;
    cout << ans%MOD;
}

Measured memory_bytes: 9328
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		long tmp = scanner.nextLong();
		for (int i = 0; i < n - 1; i++) {
			tmp = lcm(tmp, scanner.nextLong());
		}

		System.out.println(tmp);
	}

	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}

	private static long lcm(long m, long n) {
		return m / gcd(m, n) * n;
	}
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1005,INF=1000;

int main(){
    
    ll N;cin>>N;
    vector<ll> S(N);
    bool flag=true;
    ll sum=0,a=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
        sum+=S[i];
        a+=(i+1);
    }
    if(sum%a!=0) flag=false;
    ll play=sum/a;
    for(int i=0;i<N-1;i++){
        if((play-(S[i+1]-S[i]))%N!=0) flag=false;
        if((play-(S[i+1]-S[i]))/N<0||(play-(S[i+1]-S[i]))/N>play) flag=false;
    }
    if((play-(S[0]-S[N-1]))%N!=0) flag=false;
    if((play-(S[0]-S[N-1]))/N<0||(play-(S[0]-S[N-1]))/N>play) flag=false;
    
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int main(){
  int n,d;
  cin>>n>>d;
  if(n%(2*d+1)==0){
    cout<<n/(2*d+1)<<endl;
  }
  else{
    cout<<(n/(2*d+1))+1<<endl;
  }
}


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

using namespace std;

const int N = 1e7 + 1000;
long long int a[N], b[N] , c[N] , ansa , ans;
pair <long long int , long long int> p[N];
long long int aa , bb , cc;

int main () {
    long long int n;
    cin >> n;
    string a , b , c;
    cin >> a >> b >> c;
    for(long long int i = 0 ; i < n ; i++ ) {
        if(a[i] == b[i] && c[i] != b[i]) {
            cc++;
        }
        if(c[i] == b[i] && a[i] != b[i]) {
            cc++;
        }
        if(a[i] == c[i] && a[i] != b[i]) {
            cc++;
        }
        if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i]) {
            cc+=2;
        }
    }
    cout << cc;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    int n, b, f, r, v;
    int info[4][3][10]; //info[building][floor][room]=people
    
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                info[i][j][k]=0;
            }
            
        }
        
    }
    

    cin>>n;
    
    for (int i = 0; i < n; i++)
    {
        cin>>b>>f>>r>>v;
        info[b-1][f-1][r-1] += v;
    }


    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                cout<<' '<<info[i][j][k];
            }
            cout<<endl;
        }

    if (i<3)
    {
        cout<<"####################"<<endl;
    }
    
        
    }
    
    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
      Scanner in = new Scanner(System.in) ;
      String str = in.next() ;
      if(str.length()==6&&str.charAt(2)==str.charAt(3)&&str.charAt(4)==str.charAt(5))
        System.out.println("Yes");
      else
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,n,arr[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	cout<<arr[k];
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

char s[1111],ins[1111];

bool formula(int l,int r){
	if(s[l]=='T')return true;
	else if(s[l]=='F') return false;
	else if(s[l]=='-'){
		if(formula(l+1,r))return false;
		else return true;
	}
	string op="";
	int k,level=0;
	for(k=l+1;k<r-1;k++){
		if(s[k]=='(')level++;
		if(s[k]==')')level--;
		if(level==0){
			if(s[k]=='*')op="*";
			else if(s[k]=='+')op="+";
			else if(s[k]=='-'&&s[k+1]=='>')op="->";
		}
		if(op!="")break;
	}
	bool resa=formula(l+1,k),resb=formula(op=="->"?k+2:k+1,r-1);
	if(op=="*")return resa&resb;
	else if(op=="+")return resa|resb;
	else{
		if(resa==false)return true;
		else return resb;
	}
}

bool equation(int l,int r){
	int k=0;
	for(k=l;k<r;k++){
		if(s[k]=='=')break;
	}
	return formula(l,k)==formula(k+1,r);
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>ins;
		if(ins[0]=='#')break;
		vector<char> cnt;
		int n=strlen(ins);
		rep(i,n){
			if(ins[i]>='a'&&ins[i]<='k'){
				if(!exist(cnt,ins[i]))cnt.pb(ins[i]);
			}
		}
		bool ok=true;
		rep(i,1<<cnt.size()){
			map<char,bool> maps;
			memcpy(s,ins,sizeof(ins));
			rep(j,cnt.size()){
				if((i>>j)&1){
					maps[cnt[j]]=true;
				}else{
					maps[cnt[j]]=false;
				}
			}
			rep(j,n){
				if(exist(cnt,s[j])){
					if(maps[s[j]])s[j]='T';
					else s[j]='F';
				}
			}
			if(!equation(0,n)){
				ok=false;
				break;
			}
		}
		if(ok)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3288
n, a, b = map(int,input().split())
v = sorted(list(map(int,input().split())),reverse = True)
set_v = set()
cnt_v = []
for i in v:
    if i not in set_v:
        set_v.add(i)
        cnt_v.append(i)

from collections import Counter
from operator import itemgetter
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
c = Counter(v)
sum = 0
cnt = 0
num = 0
if c[v[0]] >= a:
    print(float(v[0]))
    for i in range(a,min(b,c[v[0]]) + 1):
        num += combinations_count(c[v[0]], i)
    print(num)
    exit()
for i in cnt_v:
    if c[i] < a:
        a -= c[i]
        b -= c[i]
        sum += c[i]*i
        cnt += c[i]
    else:
        sum += i*a
        cnt += a
        print(sum/cnt)
        print(combinations_count(c[i],a))
        break

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

using ll=long long;

struct edge{
  ll w,v,u;
};

bool edge_cmp(edge &v, edge &u){
  return v.w<u.w;
}

vector<int> al(200010);
ll n,d;

vector<edge> edges;

void rec(ll left, ll right){
  if(right-left<=1){
    return;
  }
  ll mid = (left+right)/2;

  ll leftmin = left;
  for(int i=left;i<mid;i++){
    ll t = al[i] - d*i;
    ll t2 = al[leftmin] - d*leftmin;
    if(t<t2){
      leftmin = i;
    }
  }

  ll rightmin = mid;
  for(int i=mid;i<right;i++){
    ll t = al[i] + d*i;
    ll t2 = al[rightmin] + d*rightmin;
    if(t<t2){
      rightmin = i;
    }
  }

  for(int i=left;i<mid;i++){
    edge e = {al[rightmin]+al[i]+(rightmin-i)*d, i, rightmin};
    edges.push_back(e);
  }
  for(int i=mid;i<right;i++){
    edge e = {al[leftmin]+al[i]+(i-leftmin)*d, leftmin, i};
    edges.push_back(e);
  }

  rec(left, mid);
  rec(mid, right);
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int find(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[find(x)];
    }
};

int main(){
  cin>>n>>d;
  for(int i=0;i<n;i++){
    cin>>al[i];
  }
  rec(0, n);

  UnionFind uf(n);
  sort(edges.begin(), edges.end(), edge_cmp);
  ll res = 0;
  for(auto e:edges){
    if(uf.same(e.v, e.u)){
      continue;
    }
    res += e.w;
    uf.unite(e.u,e.v);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 101472
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    cout<<(n-1)*(m-1)<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	char s[3];
	int c = 0;
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
		if (s[i] == 'o')
			c++;
	}
	cout << 700 + c * 100 << endl;
}

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

const int N = 2e5 + 5;
typedef long long ll;

int n, k, a[N], h[N];
vector<pair<ll, int> > v;
int ft[N] = {};

int get(int x) {
	int ret = 0;
	for (++x; x; x -= x & -x) ret += ft[x];
	return ret;
}

void put(int x, int v) {
	for (++x; x < N; x += x & -x) ft[x] += v;
}

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k;
	ll sum = 0;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i] - k;
		if (sum >= 0) ++ans;
		v.push_back({sum, i});
	}
	sort(v.begin(), v.end());
	h[v[0].second] = 0;
	for (int i = 1; i < n; ++i) {
		h[v[i].second] = i;
		if (v[i - 1].first == v[i].first)
			h[v[i].second] = h[v[i - 1].second];
	}
	for (int i = 0; i < n; ++i) {
		ans += get(h[i]);
		put(h[i], 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
// const ll MOD = 1e9+7;
const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N;

int Main() {
    cin >> N;
    const double PI = acos(-1);
    cout << fixed << setprecision(20) << N* PI* 2 << endl;
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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


vector<int> cnt(100*100*10+1,0);

int main(){
    int N;
    cin >> N;
    
    ll sum = 0;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        cnt[a]++;
        sum += a;
    }
    
    int Q;
    cin >> Q;
    int b,c;
    for(int i = 0; i<Q; i++){
        cin >> b >> c;
        sum = sum + cnt[b]*(c-b);
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3720
n,m=map(int,input().split())
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    l.append(b)
for i in range(n):
    k=0
    for j in range(2*m):
        if i+1==l[j]:
            k+=1
    print(k)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int x[55];
typedef long long ll;
ll n,a;
ll dp[55][55][2550];
int main()
{
    cin>>n>>a;
    for(int i=0;i<n;i++) cin>>x[i];
    dp[0][0][0]=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    for(int k=0;k<n*a;k++)
    {
        dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
        dp[i+1][j][k]+=dp[i][j][k];
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=dp[n][i][i*a];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 56448