akhauriyash/Code-Regression huggingface dataset:
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, i = 111; cin>>n;
	while (i < n) i+=111;
	cout<<i;
	return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
X = [0, A, B, C]
L = [int(input()) for _ in range(N)]
d = 4 ** N
magic = int(1e+9)
for i in range(d):
  F = [0 for _ in range(4)]
  cnt = [0 for _ in range(4)]
  tmp = i
  for j in range(N):
    F[i%4] += L[j]
    cnt[i%4] += 1
    i //= 4
  p = True
  for k in range(1, 4):
    if F[k] == 0:
      p = False
      break
  tmpp = 0
  if p:
    for k in range(1, 4):
      tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10
    if tmpp < magic:
      magic = tmpp
print(magic)

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rep2(i,j,k) for(int i=j;i>=k;i--)
#define mo 1000000007
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
int n;
int powe[200010];int inv[200010];
inline int poww(int n,int m){
	int temp=n;int tmp=m;int ret=1;
	while(tmp){
		if(tmp&1)ret=(1ll*ret*temp)%mo;
		temp=(1ll*temp*temp)%mo;
		tmp>>=1; 
	}
	return ret;
}
struct wzy{
	int nxt,vertice;
}edge[400010];
int head[200010];int len=0;
inline void add_edge(int x,int y){
	edge[++len].nxt=head[x];edge[len].vertice=y;head[x]=len;return;
}

int dp[200010];int siz[200010];int ans[200010];
inline void dfs(int u,int fa){
	dp[u]=1;siz[u]=1;
	for(int i=head[u];i;i=edge[i].nxt){
		int nop=edge[i].vertice;
		if(nop==fa)continue;
		dfs(nop,u);siz[u]+=siz[nop]; 
		dp[u]=(1ll*dp[u]*dp[nop])%mo;dp[u]=(1ll*dp[u]*inv[siz[nop]])%mo;
	}
	dp[u]=(1ll*dp[u]*powe[siz[u]-1])%mo;return;
}
inline void sol(int u,int fa){
	ans[u]=1;
	for(int i=head[u];i;i=edge[i].nxt){
		int nop=edge[i].vertice;
		if(nop!=fa){
			ans[u]=(1ll*ans[u]*dp[nop])%mo;ans[u]=(1ll*ans[u]*inv[siz[nop]])%mo;
		}else{
			int temp=(1ll*ans[fa]*inv[n-1])%mo;temp=(1ll*temp*powe[n-1-siz[u]])%mo;
			temp=(1ll*temp*powe[siz[u]])%mo;temp=(1ll*temp*poww(dp[u],mo-2))%mo;
			ans[u]=(1ll*ans[u]*temp)%mo;ans[u]=(1ll*ans[u]*inv[n-siz[u]])%mo;
		}
	}
	ans[u]=(1ll*ans[u]*powe[n-1])%mo;
	
	for(int i=head[u];i;i=edge[i].nxt){
		if(edge[i].vertice!=fa)sol(edge[i].vertice,u);
	}
	return;
}

int main(){
	read(n);
	powe[0]=powe[1]=1;inv[1]=1; 
	rep(i,2,n)powe[i]=(1ll*powe[i-1]*i)%mo;
	inv[n]=poww(powe[n],mo-2);
	rep2(i,n-1,2)inv[i]=(1ll*inv[i+1]*(i+1))%mo;
	
	rep(i,1,n-1){int a,b;read(a);read(b);add_edge(a,b);add_edge(b,a);}
	
	dfs(1,0);ans[1]=dp[1];
	for(int i=head[1];i;i=edge[i].nxt){
		int nop=edge[i].vertice;
		sol(nop,1);
	}
	rep(i,1,n)write(ans[i]);
	return 0;
}

Measured memory_bytes: 11512
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  
    
  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
       IOS
       int n;
       cin>>n;
       vector<int> v(n),right(n,0);
       int rmax,sum=0;
       for(int i= 0;i<n;i++)
        cin>>v[i];
      rmax = v[0];
       for(int i = 1;i<n;i++)
       {
         rmax =  max(rmax,v[i]);
         if(v[i]<rmax)
          sum+=abs(v[i] - rmax);
        //trace2(sum,rmax);
       }
       cout<<sum;
        return 0;
  }
       

Measured memory_bytes: 6320
#include <iostream>
#include<bits/stdc++.h>
#define ll long long 

#define pb push_back
#define pii pair<int,int>
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;


void solve(){
int n;
cin >> n;

ll arr[n];
long double sum=0;
int flag=0;
ll alt=1;
f(i,n){
		cin >> arr[i];
		if(arr[i]==0)
			flag=1;
		
}	
if(flag==1){
	cout<<0<<endl;
	return;
}


	for(int i=0;i<n;i++){
		
			sum = sum + log10(arr[i]);
			if(sum>18)
			{
				cout<<-1<<endl;
				return;
			}
			if(alt*arr[i]>1000000000000000000){
				cout<<-1<<endl;
				return;
			}
			alt=alt*arr[i];
		
	}
	cout<<alt<<endl;

}

int main() {
	
	/*int t;
	cin >> t;
	
	while(t--)*/
	    solve();
	    
	return 0;
}



Measured memory_bytes: 4604
N = int(input())
A = list(map(int, input().split()))

right = 0
sum_n = bit_n = 0
ans = 0

for left in range(N):
    while right < N and sum_n + A[right] == sum_n ^ A[right]:
        sum_n += A[right]
        bit_n ^= A[right]
        right += 1

    ans += right - left

    if right == left :
        right += 1
    else:
        sum_n -= A[left]
        bit_n ^= A[left]

print(ans)

Measured memory_bytes: 24424
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vvll vector<vector<ll>>
#define mll map<ll,ll>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<=n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   macke_pair 
#define MOD 1000000007
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
int md(int n){
	if(n>0)return n;
	else return -n;
}
void solve(){
	ll n;cin>>n;
	ll h;cin>>h;ll sum=0;
	fori(n-1){
		ll a;cin>>a;
		if(a>=h){
			h=a;continue;
		}
		sum+=h-a;
	}
	cout<<sum;
}

int main(){

 
    	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
		
	}
	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3632
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
cnt = 0
while li[2] != li[1]:
    li[0] += 1
    li[1] += 1
    cnt+=1
cnt += (li[1]-li[0])//2
if (li[1]-li[0])%2 != 0:
    cnt += 2
print(cnt)


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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else if (i == 1 && j == 1)
            {
                dp[i][j] = 1;
            }
            else if (v[i - 1][j - 1] == '.')
            {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                if (dp[i][j] >= mod)
                {
                    dp[i][j] -= mod;
                }
            }
            else
            {
                dp[i][j] = 0;
            }
        }
    }

    cout << dp[n][m] << '\n';
}


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    cout << max( min(b,d) - max(a,c), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main 
{

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		Dice dice = new Dice();
		
		for(int i=0;i<strs.length;i++)
		{
			dice.setNum(i,Integer.parseInt(strs[i]));
		}
		int question = Integer.parseInt(br.readLine());
		
		for(int i=0;i<question;i++)
		{
			String[] s = br.readLine().split(" ");
			dice.getTopFront(Integer.parseInt(s[0]),Integer.parseInt(s[1]));
		}
		// TODO 自動生成されたメソッド・スタブ

	}
}

class Dice
{
	int[] num;
	
	public Dice()
	{
		num = new int[6];
	}
	
	public void getTopFront(int top,int front)
	{
		int i=0;
		while(true)
		{
			rotateN();
			if(front == num[1])
			{
				break;
			}
			
			if(i%2==0)
			{
				rotateE();
			}else
			{
				rotateW();
			}

			if(front==num[1])
			{
				break;
			}
			i++;
		}
		
		while(true)
		{
			rotateW();
			if(top == num[0])
			{
				break;
			}
		}
		
		
		System.out.println(num[2]);
	}
	
	public void setNum(int index,int Num)
	{
		num[index] = Num;
	}
	
	public void rotateS()
	{
		int temp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = temp;
	}
	
	public void rotateN()
	{
		int temp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = temp;
	}
	
	public void rotateW()
	{
		int temp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = temp;
	}
	
	public void rotateE()
	{
		int temp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = temp;
	}
	
	public void rotation(String instruction)
	{
		for(int i=0;i<instruction.length();i++)
		{
			switch(instruction.charAt(i))
			{
			case 'S':
				rotateS();
				break;
			case 'N':
				rotateN();
				break;
			case 'W':
				rotateW();
				break;
			case 'E':
				rotateE();
				break;
				
				default :
					break;
			}
		}
	}
}

Measured memory_bytes: 16924
n,tmax = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if t[i+1] - t[i]< tmax:
        ans += t[i+1] - t[i]
    else:
        ans += tmax
ans += tmax
print(ans)

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<P> a(n),b(n);
    vector<int> p(n);
    for (int i = 0;i < n;++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i = 0;i < n;++i) {
        cin >> b[i].first;
        b[i].second = i;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for (int i = 0;i < n;++i) if (a[i].first > b[i].first) {
        cout << "No" << endl;
        return 0;
    }
    vector<bool> used(n,false);
    for (int i = 0;i < n;++i) p[a[i].second] = b[i].second;
    for (int i = 0;i < n;++i) if (!used[i]) {
        if (i) {
            cout << "Yes" << endl;
            return 0;
        }
        int j = 0;
        while (!used[j]) {
            used[j] = true;
            j = p[j];
        }
    }
    for (int i = 0;i < n-1;++i) if (a[i+1].first <= b[i].first) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,c=0;
  cin>>a;
  vector<int> b(a);
  fo(i,a)
    cin>>b[i];
  fo(i,a){
    if(i==a-1&&b[i]==i+1)
      c++;
    else if(b[i]==i+1){
      swap(b[i],b[i+1]);
      c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n)for(int i=0;i<n;i++)
#define REPR(i,n)for(int i=n;i>=0;i--)
#define FOR(i,m,n)for(int i=m;i<n;i++)
#define INF 999999999
#define llong long long

using namespace std;

int main(){
	string s;
	cin>>s;
	int max=0;
	int flag=0;
	for(int i=0;i<s.size();i++){
		for(int j=i;j<s.size();j++){
			flag=0;
			for(int k=i;k<=j;k++){
				if(s[k]!='A' && s[k]!='C' && s[k]!='G' && s[k]!='T'){
					flag=1;
				}
			}
				
			if(flag==0 && max<j-i+1){
				max=j-i+1;
				}
			}
		}
	cout<<max<<endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
string s;
int cnt[4];

void solve(){
    cin >> s;
    n=s.length();
    rep(i,n){
        if(s[i]=='N') cnt[0]+=1;
        if(s[i]=='S') cnt[1]+=1;
        if(s[i]=='W') cnt[2]+=1;
        if(s[i]=='E') cnt[3]+=1;
    }
    if(cnt[0]>0 && cnt[1]==0){
        cout << "No" << endl;
        return;
    }
    if(cnt[1]>0 && cnt[0]==0){
        cout << "No" << endl;
        return;

    }
    if(cnt[2]>0 && cnt[3]==0){
        cout << "No" << endl;
        return;
    }
    if(cnt[3]>0 && cnt[2]==0){
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

int main(){
  int n; cin >> n;
  
  bool ans = false;
  for(int i=0; i<=25; i++) {
    for(int j=0; j<15; j++) {
      if(4*i + 7*j == n) {
        ans = true;
        break;
      }
    }
    if(ans == true) break;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 256
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
    char a;

    cin >> a;

    if (a == 'A') {
        cout << 'T' << endl;
    }
    else if (a == 'C') {
        cout << 'G' << endl;

    }
    else if (a == 'G') {
        cout << 'C' << endl;

    }
    else {
        cout << 'A' << endl;


    }
    return 0;
}


Measured memory_bytes: 3560
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 100005;
const ll mm = 1e+18;
map<int,int>mp;
int f(int n){
    if(mp[n]) return mp[n];
    return mp[n]=((f(n/2)+f((n-1)/2)+f((n-2)/2)))%mod;
}
void solve()
{
    int n;
    cin>>n;
    mp[0]=1;
    mp[1]=2;
    cout<<f(n);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

typedef long long ll;
ll f[100005][15], mod = 1e9 + 7, pre, cnt;
string s;

ll get(ll x, ll y)
{
	ll now = x - y;
	while (now < 0) now += 13;
	return now;
}

int main()
{
	cin >> s;
	ll cur = 1;
	pre = s.length();
	f[s.length()][0] = 1;
	for (ll i = s.length() - 1; i >= 0; i--)
	{
		if (s[i] == '?')
		{
			for (ll j = 0; j <= 9; j++)
			{
				ll now = (j * cur) % 13;
				for (ll k = 0; k < 13; k++)
				{
					f[i][k] = (f[i][k] + f[pre][get(k, now)]) % mod;
				}
			}
			pre = i;
		}
		else cnt = (cnt + ((s[i] - '0') * cur) % 13) % 13;
		cur = (cur * 10) % 13;
	}
	cout << f[pre][get(5, cnt)] << endl;
	return 0;
}


Measured memory_bytes: 12160
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC123B
int main(void) {
  int n, k, i, cou=0, tmp, min=10, a[5];

  for(i=0; i<5; i++){
    scanf(" %d", &a[i]);
    if(min>a[i]%10&&a[i]%10!=0) min=a[i]%10;
    cou+=(a[i]-1)/10*10+10;
  }
  printf("%d", cou-10+min);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int low = INF, high = 0;
    vector<P> trade;
    rep(i, n) {
        if (a[i]<low) {
            low = a[i];
        } else if (a[i]>low) {
            high = a[i];
        }
        if (high>low) {
            trade.emplace_back(low, high);
            debug(i, low, high);
            low = a[i]; high = 0;
        }
    }
    ll cur = 1000;
    for(const auto& p: trade) {
        cur += (p.se-p.fi) * (cur/p.fi);
    }
    cout << cur << endl;
}

Measured memory_bytes: 3632
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
ans = 0
for i in range(N):
    if i == N - 1:
        if a[i] == x:
            ans += 1
    else:
        if a[i] <= x:
            x -= a[i]
            ans += 1
        else:
            break
print(ans)


Measured memory_bytes: 2940
n=int(input())
l=[]
for i in range(n):
    s = input()
    s = sorted(s)
    l.append(''.join(s))
l.sort()
sa = l[0]
cnt = 0
n = 1
for sb in l[1:]:
  if sb == sa:
    n += 1
  else:
    cnt += (n * (n-1) // 2)
    n = 1
    sa = sb
cnt += (n * (n-1) // 2)
print(cnt)


Measured memory_bytes: 11024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    ans = gcd(A, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
import java.util.HashMap;

class Main
{
    // driver function to test the above functions
    public static void main(String args[]) throws IOException
    {
        Reader.init(System.in);
        double a = Reader.nextInt();
        int b = Reader.nextInt();

        double base = b*10;
        int helper = b*10;
        double ans = 0;
        for (int i=0; i<10; i++){
            double test = Math.floor(base*0.08);
            if (test==a){
                System.out.println(helper);
                break;
            }
            base=base+1;
            helper=helper+1;
            if (i==9){
                System.out.println(-1);
                break;
            }
        }







    }

}

class Node{
    char val;
    Node nxt = null;
    Node prev=null;


}



class solu{

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static String line() throws IOException {
        return reader.readLine();
    }
}

Measured memory_bytes: 22740
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

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


int main() {
	string day[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
	string n;
	cin >> n;

	repz(i,7)if(n == day[i]) {
		cout << 7 - i << endl;
	}




	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace testes
{
    class Program
    {
        static int[] L;
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            L = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(L);
            Array.Reverse(L);

            int ans = 0;
            int count = 0;

            for (int i = 0; i < N - 2; i++)
            {
                for (int j = i + 1; j < N - 1; j++)
                {
                    int target = L[i] - L[j];
                    int[] tmp = new int[N - j];
                    Array.Copy(L, j, tmp, 0, N - j);
                    ans += nibunn(tmp,target);
                }
            }

            Console.WriteLine(ans);
            

        }

        static int nibunn(int[] array, int target)
        {
            int L = 0;
            int R = array.Length; 
            
            while(R - L > 1)
            {
                int mid = (R + L) / 2;
                if (array[mid] > target) L = mid;
                else R = mid;
            }
            return L;
        }

        static bool solve(int a, int b, int c)
        {
            return a < c + b;
        }


        static bool AAABBB(long target, long N, long K, long[] F, long[] A)
        {
            long count = 0, need;
            for (long i = 0; i < N; i++)
            {
                need = target / F[i];
                count += Math.Max(0, A[i] - need);
            }
            return count <= K;
        }
        public static long LIS(long[] c)
        {
            // 部分数列和
            long count = 1;
            long N = c.Length;
            long[] array = new long[N];
            array[0] = c[0];

            for (long i = 1; i < N; i++)
            {
                //for (long p = 0; p < N; p++) Console.Write($"{array[p]},");
                // Console.WriteLine("");
                if (array[count - 1] < c[i])
                {
                    array[count] = c[i];
                    count++;
                    continue;
                }
                for (long j = count - 2; j >= 0; j--)
                {
                    if (array[j] < c[i])
                    {
                        array[j + 1] = c[i];
                        break;
                    }
                }
                if (array[0] > c[i]) array[0] = c[i];
            }
            return count;
        }
        public static void Rotation(char[] array, long l, long r)
        {
        }
    }
}

/*
long a, b, c;
a = long.Parse(Console.ReadLine()); //標準入力
string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
b = long.Parse(str[0]);  //数値で受け取りたい場合は変換する
c = long.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
Member = ReadLine().Split(' ').Select(long.Parse).ToArray();

string[] str = Console.ReadLine().Split(' ');
long[] a = new long[N];
for(long i = 0; i < N; i++) a[i] = long.Parse(str[i]);
 */


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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x));
#define cou(x) cout << x << endl;
#define y() cout << "Yes" << endl;
#define n() cout << "No" << endl;
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	int N;

	cin >> N;

	vi vec(N);
	int p;
	rep(i, N) {
		cin >> p;
		vec[i] = p;
	}
	sort(vec);
	rep(i, N - 1) {
		if (vec[i] == vec[i + 1]) {
			cou("NO");
			exit(0);
		}
	}
	cou("YES");
}

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

int main()
{
  int n , k , q ;
  cin >> n >> k >> q ;
  vector<int> A(q) ;
  for(int i=0; i<q; i++)
    cin >> A.at(i) ;
  vector<int> player(n,k-q) ;
  
  for(int i=0; i<q; i++)
  {
    player.at(A.at(i)-1) += 1 ;
  }
  for(int i=0; i<n; i++)
    if(player.at(i) > 0)
      cout << "Yes" << endl ;
  else
    cout << "No" << endl ;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

//const ll mod = 998244353;
const ll mod = 1e9 + 7;
const ll MAX_SIZE = 2000005;
array<ll, MAX_SIZE> fac, inv, finv;
ll fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % mod;
    finv[0] = modpow(fac[MAX_SIZE - 1], mod - 2, mod);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % mod;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, mod - 2, mod);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % mod; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % mod * finv[a - b] % mod; }

ll f(ll r, ll c){
    return comb(r + c + 2, r + 1) - 1;
}
int main() {
    init();
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    fac_init();

    ll ans = (f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1) + 5 * mod) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 47104
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    S[K - 1] = S[K - 1] - 'A' + 'a';
    cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s, t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]) cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 3832
#include<map>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int T;
    cin >> T;
    map<string, int> mp;
    while (T--) {
        int t;
        cin >> t;
        if (t==0) {
            string s;int a;
            cin >> s >> a;
            mp[s] = a;
        } else if (t==1) {
            string s;
            cin >> s;
            if (mp.find(s)==mp.end()) cout << 0 << endl;
            else cout << mp[s] << endl;
        } else {
            string s;
            cin >> s;
            mp.erase(s);
        }
    }
    return 0;
}


Measured memory_bytes: 27728
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct query {
    int a, b, c, d;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
    vector<int> used(N, 0);
    vector<pair<int, int>> ans;
    if(N % 2 == 1) {
        rep(i, M) {
            ans.pb(mp(i, N - 1 - i));
        }
    }
    else {
        vector<int> A;
        rep(i, 1, N / 2) {
            if(i % 2 == 1) {
                A.pb(N - i);
            }
            else A.pb(i);
        }
        sort(all(A));
        reverse(all(A));
        rep(i, M) {
            ans.pb(mp(i, i + A[i]));
        }
    }
    
    rep(i, M) {
        cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4980
// Problem : B - Golden Coins
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int x;
    cin >> x;
    cout << x / 500 * 1000 + x % 500 / 5 * 5 << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		int N = Integer.parseInt(sc.next());

		List<Integer> A = new ArrayList<Integer>();

		for (int i=0; i<N; i++){
			A.add(Integer.parseInt(sc.next()));
		}

		int j = 0;
		int ans = 0;
		for (int i=0; i<N; i++){
			j = A.get(j)-1;
			ans += 1;
			if (j == 1){
				System.out.println(ans);
				return;
			}
		}
		System.out.println(-1);
		return;
	}
}

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

using namespace std;

int main(){
    string s;
    cin >> s;

    if(s[s.length() - 1] == 's'){
        s = s + "es";
    } else {
        s = s + "s";
    }

    cout << s << endl;


    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h> 
const int N = 305;
const int M = 305;
int main()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == 0)
		{
			break;
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m;j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int main()
{
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  vector<int> steps(N + 1, INF);
  steps.at(N) = 0;
  vector<bool> checked(N + 1, false);
  checked.at(N) = true;
  for (int i = N; i > 0; i--)
  {
    if (S[i] == '1')
    {
      continue;
    }
    for (int j = max(0, i - M); j <= i; j++)
    {
      if (checked.at(j))
      {
        break;
      }
      checked.at(j) = true;
      if (S[j] == '1')
      {
        continue;
      }
      steps.at(j) = steps.at(i) + 1;
    }
  }
  if (steps.at(0) >= INF)
  {
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 1; j <= M && i + j <= N; j++)
    {
      if (steps.at(i + j) == steps.at(i) - 1)
      {
        ans.push_back(j);
        i += j - 1;
        break;
      }
    }
  }
  for (int i = 0; i < (int)ans.size(); i++)
  {
    if (i)
      cout << ' ';
    cout << ans.at(i);
  }
  cout << endl;
}


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

using namespace std;
using ll = long long int;
using lc = complex<double>;

#include<atcoder/all>
using namespace atcoder;

template <typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    const T e;
    const F f;
    size_t sz;
    vector<T> tree;

    SegmentTree(size_t n, const F &f, const T &e = 0) : f(f), e(e) {
        sz = 1;
        while(sz < n) sz <<= 1;
        tree.assign(2*sz, e);
    }

    void set(typename vector<T>::iterator begin, typename vector<T>::iterator end) {
        copy(begin, end, tree.begin() + sz);
        for(size_t k=sz-1; k>0; k--)
            tree[k] = f(tree[2*k+0], tree[2*k+1]);
    }

    void update(size_t k, const T &x) {
        k += sz;
        tree[k] = x;
        while(k >>= 1)
            tree[k] = f(tree[2*k+0], tree[2*k+1]);
    }

    T query(size_t a, size_t b) const {
        b = min(b, sz);
        a = max((size_t)0, a);
        T l = e, r = e;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) l = f(l, tree[a++]);
            if(b & 1) r = f(tree[--b], r);
        }
        return f(l, r);
    }

    T operator[](const size_t k) const {
        return tree[sz + k];
    }
};

int main(void) {
    constexpr ll MOD = 1e9+7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    for(auto &e: a) cin >> e;
    vector<ll> b = a;
    sort(b.begin(), b.end());

    SegmentTree<ll> st(n, [&](ll a, ll b){return max(a, b);}, 0);

    for(auto &e: a) {
        ll ui = lower_bound(b.begin(), b.end(), e-k) - b.begin();
        ll vi = upper_bound(b.begin(), b.end(), e+k) - b.begin();
        ll wi = lower_bound(b.begin(), b.end(), e) - b.begin();
        ll t = st.query(ui, vi) + 1;
        st.update(wi, t);
    }
    cout << st.query(0, n) << endl;
}

Measured memory_bytes: 16172
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <cassert>
#include <deque>
using namespace std;
#define int64_t long long
constexpr int64_t MOD=1e9+7;
int main() {
    int n;
    scanf("%d",&n);
    map<int,int>m[2];
    for(int i=0;i<n;++i){
        int x;
        scanf("%d",&x);
        m[i%2][x]++;
    }
    vector<pair<int,int>>v[2];
    for(int i=0;i<2;++i){
        for(auto e:m[i]){
            v[i].push_back({e.second,e.first});
        }
        sort(v[i].begin(),v[i].end());
    }
    int ans=0;
    for(int i=0;i<2;++i){
        int k=v[i].back().first;
        int t=v[i].back().second;
        ans=max(ans,k);
        for(auto p:v[i^1]){
            if(t==p.second)continue;
            ans=max(ans,p.first+k);
        }
    }
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 6136
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int[,] a = new int[12,12];

        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int[] tempArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int n, m, x;
            n = tempArray[0];
            m  = tempArray[1];
            x = tempArray[2];
            int[] c = new int[n];

            for (int i = 0; i < n; i++)
            {
                tempArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
                c[i] = tempArray[0];
                for (int j = 0; j < m; j++)
                {
                    a[i, j] = tempArray[j+1];
                }
            }

            var inf = 1001001000;
            var ans = inf;
            for (int i = 0; i < 1 << n; i++)
            {
                int cost = 0;
                int[] d = new int[m];
                for (int j = 0; j < n; j++)
                {
                    if ((i>>j&1) == 1) 
                    {
                        cost += c[j];
                        for (int k = 0; k < m; k++)
                        {
                            d[k] += a[j, k];
                        }
                    }
                }

                var ok = true;
                for (int l = 0; l < m; l++)
                {
                    if (d[l]< x) 
                    {
                        ok = false;
                    }
                }
                if (ok) ans = Math.Min(ans, cost);
            }

            if (ans == inf) Console.WriteLine(-1);
            else Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;




int main() {
	
	int n, m;
	cin >> n >> m;
	VB b(112345, true);

	REP(i, m) {
		int a;
		cin >> a;
		b[a] = false;
	}

	VLL dp(112345, 0);
	dp[0] = 1;
	if (b[1])dp[1] = 1;

	FOR(i, 2, n+2) {
		if (!b[i])continue;
		dp[i] = dp[i - 1] + dp[i - 2];
		dp[i] %= mod;
	}


	cout << dp[n] << endl;

	


}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(void) {
  string s;
  cin>>s;
  int a = s[0] - '0';
  int b = s[1] - '0';
  int c = s[2] - '0';
  int d = s[3] - '0'; 
  if(a-b-c-d == 7) {printf("%d-%d-%d-%d=7", a,b,c,d); return 0;}
  if(a-b-c+d == 7) {printf("%d-%d-%d+%d=7", a,b,c,d); return 0;}
  if(a-b+c-d == 7) {printf("%d-%d+%d-%d=7", a,b,c,d); return 0;}
  if(a+b-c-d == 7) {printf("%d+%d-%d-%d=7", a,b,c,d); return 0;}
  if(a-b+c+d == 7) {printf("%d-%d+%d+%d=7", a,b,c,d); return 0;}
  if(a+b+c-d == 7) {printf("%d+%d+%d-%d=7", a,b,c,d); return 0;}
  if(a+b-c+d == 7) {printf("%d+%d-%d+%d=7", a,b,c,d); return 0;}
  if(a+b+c+d == 7) {printf("%d+%d+%d+%d=7", a,b,c,d); return 0;}
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long dp[100005][3],n;
int arr[100005][3];

long long max(long long a,long long b) {return (a>b?a:b);}

long long solve(int day,int prev)
{
  if(day>=n) return (long long) 0;
  if(dp[day][prev]!=-1) return dp[day][prev];
  if(prev==3) return max(solve(day+1,0)+arr[day][0],max(solve(day+1,1)+arr[day][1],solve(day+1,2)+arr[day][2]));
  else if(prev==0) return dp[day][prev]=max(solve(day+1,1)+arr[day][1],solve(day+1,2)+arr[day][2]);
  else if(prev==1) return dp[day][prev]=max(solve(day+1,0)+arr[day][0],solve(day+1,2)+arr[day][2]);
  else return dp[day][prev]=max(solve(day+1,0)+arr[day][0],solve(day+1,1)+arr[day][1]);
}

int main()
{
  long long ans;
  for(int i=0;i<100005;i++)
    for(int j=0;j<3;j++)
      dp[i][j]=-1;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    scanf("%d%d%d",&arr[i][0],&arr[i][1],&arr[i][2]);
  ans=solve((int)0,(int) 3);
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    char c;
    cin >> c;
    char ans;
    ans = c + 1;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n;
    cin >> n;
    int a[n];
    int idx=1;
    rep(i,n) {
        cin >> a[i];
    }
    int count=0;
    while(idx!=2){
        if(count>n) {
            cout<<"-1" << endl;
            return 0;
        }
        idx=a[idx-1];
        count++;
    }
    cout << count<<endl;
    return 0;
}

Measured memory_bytes: 640
import itertools

memo = {}

def dist(x, y):
    key = (x, y)
    if key in memo:
        return memo[key]
    
    v = sum(map(lambda x: (x[0] - x[1]) ** 2, zip(x, y)))
    memo[key] = v
    return v


N, M = map(int, raw_input().split())
color = []
for i in xrange(N):
    l, a, b = map(float, raw_input().split())
    color.append((l, a, b))

m = -1
for c in itertools.combinations(color, M):
    temp = 0
    for i in xrange(M - 1):
        for j in xrange(i + 1, M):
            temp += dist(c[i], c[j])
#            print dist(c[i], c[j]), c[i], c[j]
    m = max(m, temp)

print '{:.10f}'.format(m)

Measured memory_bytes: 4452