akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string s;
  cin >> s;
  cout << (count(all(s), 'x')<=7 ? "YES" : "NO") << newl;
  return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

#define MAX_S 4000
#define MAX_T 4000


int solve(string s,string t){
    static int dp[4001][4001];
    rep(i,s.size()+1)rep(j,t.size()+1)dp[i][j] = 0;
    int maxi=0;
    
    for(int i=1;i<s.size()+1;i++){
        for(int j=1;j<t.size()+1;j++){
            if(s[i-1]==t[j-1])  dp[i][j] = dp[i-1][j-1]+1;
            else                dp[i][j] = 0;
            maxi = max(maxi,dp[i][j]);
        }
    }
    
    return maxi;
}

int main(){
    string a,b;
    while(cin>>a>>b){
        cout<<solve(a,b)<<endl;
    }
}

Measured memory_bytes: 65776
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int a[maxn],b[maxn];
ll s[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m,K;
  cin>>n>>m>>K;
  int ret = 0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    s[i] = a[i] + s[i-1];
    if(s[i]<=K)ret=i;
  }
  for(int i=1;i<=m;i++)cin>>b[i];
  ll sum = 0;
  int pos = n;
  for(int i=1;i<=m;i++){
    sum += b[i];
    if(sum>K)break;
    while(pos&&sum+s[pos]>K)pos--;
    ret = max(ret, i + pos);
  }
  cout<<ret<<endl;
  return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>>to(n);
  vector<bool>seen(n,false);
  vector<int>par(n);
  queue<int>que;
  que.push(0);
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  while(!que.empty()){
    int i = que.front();
    que.pop();
    rep(j,0,to[i].size()){
      if(seen[to[i][j]]) continue;
      else{
        seen[to[i][j]] = true;
        par[to[i][j]] = i;
        que.push(to[i][j]);
      }
    }
  }
  cout << "Yes" << endl;
  rep(i,1,n) cout << par[i]+1 << endl;
}

Measured memory_bytes: 10272
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main (){
    int x;
    cin >> x;
    double ans = 1;
    rep(i,2,x) {
        int tmp = x;
        int cnt = 0;
        while(tmp>=i) {
            tmp/=i;
            cnt++;
        }
        if (cnt>=2) {
            ans = max(ans, pow(i,cnt));
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
//using namespace std;

int main(){
    int a,b=0;
    char op;
    while(true)
    {
    std::cin >>a>> op>>b;
    if(op == '?')break;
    switch(op)
    {
        case '+':
            std::cout << a+b << std::endl;
            break;
            
        case '-' :
            std::cout << a-b << std::endl;
            break;
            
        case '*':
            std::cout << a*b << std::endl;
            break;
            
        case '/':
            std::cout << a/b << std::endl;
            break;
    }
    }
}



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

long l[87];

long calcL(int n){
	if(n == 0) return 2;
	else if(n == 1) return 1;
	else if(l[n] == 0){
		l[n] = calcL(n-1) + calcL(n-2);
	}
	return l[n];
}

int main(){
	int n;
	cin >> n;
	cout << calcL(n);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll n,cnt=0;
void dfs(ll x,ll a ,ll b ,ll c) {
	if (x > n)return;
	if (a && b && c)cnt++;
	dfs(10*x+3,1,b,c);
	dfs(10*x+5,a,1,c);
	dfs(10*x+7,a,b,1);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << cnt << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    string s;
    while(cin>>s){
        ll ans=0;
        int m=s.size();
        char n=s[m-1];
        if(n=='3'){
        	cout<<"bon"<<endl;
        }
        else if(n=='0' || n=='1' || n=='6' || n=='8'){
        	cout<<"pon"<<endl;
        }
        else{
        	cout<<"hon"<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 3628
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if(N==1){
        cout << "Hello World" << endl;
    }else{
        int A, B;
        cin >> A >> B;
        cout << A+B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (auto& v : A)cin >> v;
  sort(begin(A), end(A));
  for (int i = 0; i < M; ++i) {
    int a = A.back() >> 1; A.pop_back();
    A.insert(lower_bound(begin(A), end(A), a), a);
  }
  int64_t ans = accumulate(begin(A), end(A), 0ll);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
#include <bitset>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <random>
#include <cassert>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s;
	cin >> s;
	if (s.size() & 1) {
		cout << "No\n";
		return 0;
	}
	for (int i = 0; i < s.size(); i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i') {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	//system("pause");
	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();
        int K = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();
        sc.close();

        int sum = 0;

        for(int i = 0; i < N; i++){
            sum += 2*Math.min(x[i], K-x[i]);
        }
        System.out.println(sum);
   }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ms(x, t) memset(x, t, sizeof(x))
typedef long long int ll;
typedef unsigned long long int ull;
const int limit = 1e5 + 2;
const int inf = 1e7;
ll h[limit];
ll m[limit];
int abs(int i)
{
    if (i < 0)
    {
        return -i;
    }
    return i;
}
int dp(int i)
{
    if(i<1){
        return inf;
    }

    if (i == 1)
    {
        return 0;
    }
    if (m[i] != -1)
    {
        return m[i];
    }
    m[i] = min(dp(i - 1) + abs(h[i] - h[i-1]), dp(i - 2) + abs(h[i] - h[i-2]));
    return m[i];
}
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
    }
    ms(m, -1);

    cout<<dp(n)<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define pob pop_back
#define MP make_pair
#define MT make_tuple
#define rep(i,a,b) for(int i=a;i<b;i++)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define rept(it,v) for(auto it=v.begin();it!=v.end();it++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define endl "\n"
#define ct continue

ll abs(ll a)
{
	if(a<0)
		return -1*a;
	return a;
}

ll bin(ll a, ll b, ll mod)
{
	if(b==0)
	return 1;
	if(b&1)
		return (a*bin((a*a)%mod,b/2,mod))%mod;
	return (1*bin((a*a)%mod,b/2,mod))%mod;
}


void I_m_Beast()
{
	int n;
	cin>>n;
	ll A[n+1][3];
	rep(i,1,n+1)
	{
		cin>>A[i][0]>>A[i][1]>>A[i][2];
	}
	ll dp[n+1][3];
	rep(i,0,n+1)
		rep(j,0,3)
			dp[i][j]=0;
	rep(i,0,3)
		dp[1][i]=A[1][i];
	rep(i,2,n+1)
	{
		rep(j,0,3)
		{
			rep(k,0,3)
			if(k!=j)
			dp[i][j]=max(dp[i][j],dp[i-1][k]+A[i][j]);
		}
	}
	ll ans=0;
	rep(i,0,3)
		ans=max(ans,dp[n][i]);
	cout<<ans<<endl;
}

int main()
{
	fastio;
	int t=1;
//	cin>>t;
	while(t--)
	{
		I_m_Beast();
	}	
	return 0;	
}

Measured memory_bytes: 8344
using System;
using System.Collections.Generic;
class Program {

    static Graph G;
    static int H;
    static int W;
    static int N;

    public struct Graph {
        public HashSet<int>[] points;

        public Graph (int n) {
            points = new HashSet<int>[n];
            for (int i = 0; i < n; i++) {
                points[i] = new HashSet<int> ();
            }
        }

        public void AddLine (int a, int b) {
            points[a].Add (b);
            points[b].Add (a);
        }

        public void AddDirectionalLine (int a, int b) {
            points[a].Add (b);
        }
    }

    static void Main (string[] args) {
        string[] input = Console.ReadLine ().Split (' ');
        H = int.Parse (input[0]);
        W = int.Parse (input[1]);
        N = H * W;
        G = new Graph (N);
        bool[, ] board = new bool[H, W];

        for (int h = 0; h < H; h++) {
            char[] input2 = Console.ReadLine ().ToCharArray ();
            for (int w = 0; w < W; w++) {
                if (input2[w] == '.') {
                    board[h, w] = true;
                } else {
                    board[h, w] = false;
                }
            }
        }

        G = BoardToGraph (board, G);

        int max = 0;

        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                if (board[h, w]) {
                    int t = BFS (G, h * W + w);
                    if (t > max) {
                        max = t;
                    }
                }
            }
        }

        Console.WriteLine (max);

    }

    static int BFS (Graph graph, int startNode) {
        int[] dist = new int[N];
        Queue<int> que = new Queue<int> ();
        for (int i = 0; i < N; i++) {
            dist[i] = -1;
        }
        dist[startNode] = 0;
        que.Enqueue (startNode);

        while (que.Count > 0) {
            int nowPoint = que.Dequeue ();
            foreach (int nextPoint in graph.points[nowPoint]) {
                if (dist[nextPoint] != -1) continue;

                dist[nextPoint] = dist[nowPoint] + 1;
                que.Enqueue (nextPoint);
            }
        }

        int max = 0;

        for (int i = 0; i < N; i++) {
            if (dist[i] > max) {
                max = dist[i];
            }
        }
        return max;
    }

    static Graph BoardToGraph (bool[, ] board, Graph graph) {
        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W - 1; w++) {
                if (board[h, w] && board[h, w + 1]) {
                    graph.AddLine (h * W + w, h * W + w + 1);
                }
            }
        }
        for (int h = 0; h < H - 1; h++) {
            for (int w = 0; w < W; w++) {
                if (board[h, w] && board[h + 1, w]) {
                    graph.AddLine (h * W + w, h * W + w + W);
                }
            }
        }
        return graph;
    }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 2e5 + 7;
int n;
int a[N], ok[N];
LL k[N], b[N], s, cnt, r;
int main() {
#ifdef fwat
//	freopen("data.in", "r", stdin);
#endif
	n = gi();
//	s1[1]++, s1[6]--;
//	rep(i, 1, 5) s1[i] += s1[i - 1];
//	rep(i, 1, 5) s2[i] = s2[i - 1] + s1[i], printf("%lld\n", s2[i]);
	rep(i, 1, n) a[i] = gi(), s += a[i];
	a[0] = a[n];
	r = 1ll * n * (n + 1) / 2;
	if(s % r != 0) return puts("NO"), 0;
	cnt = s / r;
	rep(i, 1, n) {
		if(a[i] - a[i - 1] > cnt) return puts("NO"), 0;
		if(a[i] - a[i - 1] < cnt) {
			if((cnt - (a[i] - a[i - 1])) % n != 0) return puts("NO"), 0;
			LL num = (cnt - (a[i] - a[i - 1])) / n;
			k[1] += num;
			b[i] += (1 - i) * num;
			if(i ^ 1) {
				b[1] += (n - i + 1) * num;
				b[i] -= (n - i + 1) * num;
			}
		}
	}
	rep(i, 1, n) k[i] += k[i - 1], b[i] += b[i - 1];
	rep(i, 1, n) {
		LL s = k[i] * i + b[i];
		int x = i <= n ? i : i - n;
		if(s != a[i <= n ? i : i - n]) return puts("NO"), 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3712
/*
    ( ´-ω･)︻┻┳══━一一一一一一一				(× _ ×)
	
	Stay Low. Go Fast
	Kill First. Die Last
	One Shot. One Kill
	No Luck. Pure Skill 
*/

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

/*************************** MACROS **************************/
#define ld long double
#define ll long long  
#define ull unsigned long long
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x;i>=y;i--)
#define vll vector<ll>
#define pb push_back
#define S second
#define F first
#define B begin()
#define E end()
#define W(x) while(x--)
#define pll pair< ll,ll >
#define vpll vector< pll >
#define qll queue<ll>
#define dqll deque<ll>
#define qpll queue<pll>
#define dqpll deque<pll>
#define pqll priority_queue<ll>
#define pqpll priority_queue<pll>
#define Line cout<<"\n**************************\n\n";

/*************************** CONST ******************************/

const ll MOD = 1000000007;
const ll MOD1 = 998244353;
const ll MIN_LL = -1e18;
const ll MAX_LL = 1e18;
const int MAX_INT = 1e9;
const int MIN_INT = -1e9;
const ld pie = 3.1415926535;
 
/************************** POW UTIL *****************************/
 
ll fpow(ll n,ll p){;ll m=1;while(p){if(p%2)m*=n;p>>=1;n*=n;}return m;}
ll mfpow(ll n,ll p,ll M){ll m=1;n%=M;while(p){if(p%2)m=(m*n)%M;n=(n*n)%M;p>>=1;}return m%M;}
 
/************************* PRINT UTIL *****************************/

template<class T> inline ostream& operator<<(ostream& o,vector<T> v){for(auto i:v)o<<i<<" ";return o;};
template<class T> inline ostream& operator<<(ostream& o,set<T> s){for(auto i:s)o<<i<<" ";return o;}
template<class T> inline ostream& operator<<(ostream& o,multiset<T> s){for(auto i:s)cout<<i<<" ";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,pair<T1,T2> p){o<<p.F<<" "<<p.S<<"\n";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,map<T1,T2> m){for(auto p:m)o<<p.F<<" "<<p.S<<"\n";return o;}

/*************************** VARIABLES **************************/

const vll days={31,28,31,30,31,30,31,31,30,31,30,31};
 
bool br,br1,br2; 
char ch,ch1,ch2;
 

ll n,m,k,x,y,z,mini,maxi,l,r,sum,t,w;
pll p,p1,p2;

string s,s1,s2;

set<ll> st,st1,st2;
multiset<ll> mst; 

map<ll,ll> mp;

/**************************** FXNS ****************************/

ll a[(int)1e6+100];
ll b[(int)1e6+100];

void solve()
{

	cin>>n>>m>>k;

	loop(i,0,n)
	{
		cin>>a[i];
		if(i)a[i] += a[i-1];
	}

	maxi = upper_bound(a,a+n,k)-a;

	loop(i,0,m)
	{
		cin>>b[i];
		if(i)b[i] += b[i-1];

		if(b[i] <= k)
		{
			maxi = max(maxi,upper_bound(a,a+n,k-b[i])-a+i+1);
		}
	}

	cout<<maxi<<endl;

}
 
/*************************** MAIN ****************************/
 
int main(){
 
 
	// #ifndef ONLINE_JUDGE
	        // freopen("input.txt", "rt", stdin);
	        // freopen("output.txt", "wt", stdout);
	// #endif
 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);

	solve();
 
	return 0;
}


Measured memory_bytes: 6792
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>

using namespace std;

#define LL long long
#define Linf (1ll<<60)
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };
bool OOA(int h, int w, int x, int y) {
	return (x >= h || y >= w || x < 0 || y < 0);
}

typedef pair<LL, pair<LL, LL>> trio;

LL N,A,B,X[100001],ans=0ll;

int main() {
	cin >> N >> A >> B;
	for(int i=0; i<N; i++)cin >> X[i];

	for(int i=1; i<N; i++){
		int dist = X[i]-X[i-1];
		ans+=min(A*dist,B);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  string s,t;
  cin>>s>>t;
  int i,j,n=s.size();
  s=s+s;
   bool f;
  for(i=0;i<n;i++)
  {
    f=true;
    for(j=0;j<n;j++)
    {
      if(s[i+j]!=t[j]){f=false;break;}
    }
    if(f==true){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
  return 0;
  
}

Measured memory_bytes: 3608
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = sum(a)
for i in range(N-1):
    if a[i] + a[i+1] > x:
        a[i+1] = max(0,x - a[i])
    if a[i] + a[i+1] > x:
        a[i] = x
print(ans-sum(a))

Measured memory_bytes: 14052
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MOD 1000000007
#define MAX 101
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],f[MAX][MAX][MAX],ans;
int main()
{
	n=read();for(int i=1;i<n+n;++i)a[i]=read();
	sort(&a[1],&a[n+n]);
	f[n][1][0]=1;
	for(int i=n-1;i;--i)
	{
		int pl=(a[i]!=a[i+1]),pr=(a[n+n-i]!=a[n+n-i-1]);
		for(int l=0;l<=n+n-1;++l)
			for(int r=0;l+r<=n+n-1;++r)
				if(f[i+1][l][r])
				{
					for(int L=1;L<=l+pl;++L)add(f[i][l+pl-L+1][r+pr+(L>1)],f[i+1][l][r]);
					for(int R=1;R<=r+pr;++R)add(f[i][l+pl+1][r+pr-R],f[i+1][l][r]);
				}
	}
	for(int i=0;i<n+n;++i)
		for(int j=0;j<n+n;++j)
			add(ans,f[1][i][j]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int
main()
{
  int s;
  cin >> s;
  int n = 0;
  switch(s) {
    case 0:
      n = 0;
      break;
    case 1:
      n = 1;
      break;
    case 10:
      n = 1;
      break;
    case 11:
      n = 2;
      break;
    case 100:
      n = 1;
      break;
    case 101:
      n = 2;
      break;
    case 110:
      n = 2;
      break;
    case 111:
      n = 3;
      break;
    default:
      break;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
inp = []
ans = [(0, False) for _ in range(n)]

for _ in range(m):
    inp.append(input().split())

for i in inp:
    q, r = int(i[0]) - 1, i[1]
    count = ans[q][0]
    flag = ans[q][1]
    if r == 'WA' and not flag:
        ans[q] = (count+1, False)
    if r == 'AC':
        ans[q] = (count, True)
ac = list(filter(lambda x: x[1], ans))
print(len(ac), sum(map(lambda x: x[0], ac)))


Measured memory_bytes: 40248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String rank = "SHCD";
		String[] input_data = new String[2];
		int[][] output_data = new int[4][13];
		Scanner sc = new Scanner(System.in);
		String input1 = sc.nextLine();
		int n = Integer.parseInt(input1);
		String input2 = "";
		int rank_number = 0;
		int card_number = 0;
		boolean judge = true;
		String output_rank = "";

		if (n > 0 && n <= 52) {

			out: for (int i = 0; i < n; i++) {
				input2 = sc.nextLine();
				input_data = input2.split(" ");
				rank_number = rank.indexOf(input_data[0]);
				card_number = Integer.parseInt(input_data[1]);
				if ((rank_number == -1)
						|| (1 > card_number || card_number > 13)) {
					judge = false;
					break out;
				}

				if (output_data[rank_number][card_number - 1] != card_number) {
					output_data[rank_number][card_number - 1] = card_number;
				}

			}

			//System.out.println();

			if (judge == true) {
				for (int j = 0; j < output_data.length; j++) {
					output_rank = "" + rank.charAt(j);
					for (int k = 0; k < output_data[0].length; k++) {
						if (output_data[j][k] != (k + 1)) {
							System.out.println(output_rank + " " + (k + 1));
						}

					}

				}
			}

		}

	}
}



Measured memory_bytes: 26040
#include <stdio.h>

int n;
int a[100010];
int bs(int k){
	if(a[0]>k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<=k)l=m;
		else r=m;
	}
	return a[l]==k;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	int ans=0;
	while(q--){
		int t;
		scanf("%d",&t);
		ans+=bs(t);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2080
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

using namespace std;


int main()
{
    size_t k;
    cin >> k;
    if(k < 10){
        cout << k << '\n';
        return 0;
    }
    queue<int64_t> lln;
    for(int64_t i = 1; i < 10; ++i){
        lln.push(i);
    }
    while(k > 1){
        const auto lk = lln.front();
        //cout << lk << ',';
        lln.pop();
        if(lln.size() < k){
            const int lsd = lk % 10;
            const auto llshift = lk * 10;
            if(lsd > 0) lln.push(llshift + lsd - 1);
            lln.push(llshift + lsd);
            if(lsd < 9) lln.push(llshift + lsd + 1);
        }
        --k;
    }
    cout << lln.front() << '\n';
    return 0;
}


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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    int k; cin >> k;
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x : a) cin >> x;

    int max_dist = 0;
    for (int i = 0; i < n; i++) {
        int d1 = a[i];
        int d2 = a[(i+1)%n];
        int dd;
        if (d2 < d1) dd = (k - d1) + d2;
        else dd = d2 - d1;
        
        max_dist = max(max_dist, dd);
    }

    cout << k - max_dist << endl;


    return 0; 
}



Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N;
    vector<ll> hs;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(hs));

    auto ans = 0;
    auto start_it = begin(hs);
    auto last_it = unique(start_it, end(hs));
    while (distance(start_it, last_it) > 2) {
        // 0ではない中で最小の値
        auto m = *min_element(start_it, last_it,
            [](auto a, auto b) {
                a = (a > 0) ? a : numeric_limits<decltype(a)>::max();
                b = (b > 0) ? b : numeric_limits<decltype(a)>::max();
                return a < b;
            });

        ll cnt = 1 + count(start_it + 1, last_it - 1, 0);

        transform(begin(hs), last_it, begin(hs), [m](auto n) { return max(n - m, 0L); });
        last_it = unique(start_it, last_it);
        ans += cnt * m;
    }

    ans += *max_element(start_it, last_it);
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <stack>
#include <list>
#include <vector>

using namespace std;
int N, P;
int Num[201];
void refr(){
  int tmp[201];
  for(int i=0; i<2*N; ++i){
    tmp[i] = Num[i];
  }
  for(int i=0; i<N; ++i){
    Num[2*i] = tmp[i];
    Num[2*i+1] = tmp[N+i];
  }
}
void cut(int k){
  int tmp[201];
  for(int i=0; i<2*N; ++i){
    tmp[i] = Num[i];
  }
  for(int i=k; i<2*N; ++i){
    Num[i-k] = tmp[i];
  }
  for(int i=0; i<k; ++i){
    Num[i+(2*N-k)] = tmp[i];
  }
}
int main(){
  cin >> N >> P;
  for(int i=0; i<2*N; ++i){
    Num[i] = i+1;
  }
  for(int i=0; i<P; ++i){
    int a;
    cin >> a;
    if(a == 0) refr();
    else cut(a);
  }
  
  for(int i=0; i<2*N; ++i){
    cout << Num[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <queue>

using namespace std;
typedef long long int ll;

int main(){

    ll N;
    cin >> N;
    vector<ll > A(2 * N, 0);
    for(ll i = 0; i < 2 * N; i++){
        cin >> A[i];  
    }
    sort(A.rbegin(), A.rend());
    
    ll ans = 0;
    //大きいやつは大きいやつと組ませるとお得
    for(ll i = 1; i < 2 * N; i+=2){
        ans += A[i];  
    }

    cout << ans << endl;


} 

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

using namespace std;

int main(){
    
    int n;
    cin>>n;
    
    int A[n],B[n],C[n];
    
    for(int i=0;i<n;i++){
        
        cin>>A[i];
        cin>>B[i];
        cin>>C[i];
        
    }
    
    int dp[3][n];
    
    dp[0][0]= A[0];
    dp[1][0]= B[0];
    dp[2][0]= C[0];
    
    for(int i=1;i<n;i++){
        
        dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + A[i]; 
        dp[1][i] = max(dp[2][i-1],dp[0][i-1]) + B[i];
        dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + C[i];
        
    }
    
    int y = max(dp[0][n-1], dp[1][n-1]);
    y = max(y,dp[2][n-1]);
    
    cout<<y;
    
    
    
    return 0;
    
}

Measured memory_bytes: 2560
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<unordered_map>
#include<map>
#include<queue>
using namespace std;
const int N=3e5+10,M=1e7+10;

int a[N],n,m,k,len,dp[N],ans,tr[M];
int query(int x,int y,int l,int r,int rt){
	int mid=(l+r)/2;
	int maxn=0;
	if(x<=l&&r<=y)return tr[rt];
	if(x<=mid)maxn=max(maxn,query(x,y,l,mid,rt<<1));
	if(y>mid)maxn=max(maxn,query(x,y,mid+1,r,rt<<1|1));
	return maxn;
}
void pushup(int rt){
	tr[rt]=max(tr[rt<<1],tr[rt<<1|1]);
}
void change(int nt,int l,int r,int rt,int k){
	if(l==r){
		tr[rt]=max(tr[rt],k);
		return ;
	}
	int mid=(l+r)>>1;
	if(nt<=mid)change(nt,l,mid,rt<<1,k);
	else change(nt,mid+1,r,rt<<1|1,k);
	pushup(rt);
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		len=max(len,a[i]+k);
	}
	for(int i=1;i<=n;i++)
	a[i]++;
	for(int i=1;i<=n;i++){
		int l=max(a[i]-k,1),r=a[i]+k;
		dp[i]=query(l,r,1,len,1)+1;
		change(a[i],1,len,1,dp[i]);
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 10776
import copy

while 1:
    n = int(input())
    if n == 0:
        break

    datas = list(map(int, input().split()))
    prev = copy.deepcopy(datas)
    curr = [0] * n
    cnt = 0

    while 1:
        for i, p in enumerate(prev):
            curr[i] = prev.count(p)

        if prev == curr:
            break
        prev = copy.deepcopy(curr)
        cnt += 1

    print(cnt)
    print(' '.join(str(p) for p in prev))


Measured memory_bytes: 6332
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(anys{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	ll a, b, c;
	cin >> a >> b >> c;

	if(c-a-b>0 && 4*a*b < (c-a-b)*(c-a-b)){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return (x * 1ll * y) % MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld a,b;
        cin>>a>>b;
        b--;
        a--;
        if(b%a==0)
            cout<<b/a;
        else
            cout<<b/a+1<<endl;
    }
}



Measured memory_bytes: 256
fn a() {
    input!{
        d: u32,
        t: u32,
        s: u32,
    }

    if (t * s < d) {
        println!("No");
    }
    else {
        println!("Yes");
    }
}

use proconio::{input, marker::Chars};

fn main() {
    a();
}


Measured memory_bytes: 2148
a, b = list(map(int, input().split()))
if a == b:
    print("Draw")
else:
    if a != 1 and b != 1:
        if a > b:
            print("Alice")
        else:
            print("Bob")
    else:
        if a == 1:
            print("Alice")
        else:
            print("Bob")

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // ?¨±??????????????????????????£????????????
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// ?????????dot(a,b) = |a||b|cos??
D dot(P a, P b) {return (conj(a)*b).X; }

// ?????????cross(a,b) = |a||b|sin??
D cross(P a, P b) {  return (conj(a)*b).Y;}

// ??????????????????
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}
// 2??´????????????
P crosspointLL(P a1, P a2, P b1, P b2) {
  D d1 = cross(b2-b1, b1-a1);
  D d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  if (EQ(d2, 0)) throw "kouten ga nai";   // ???????????????
  return a1 + d1/d2 * (a2-a1);
}
// ???????§???¢?????????????????°
VP convexCut(const VP& ps, P a1, P a2) {
  int n = ps.size();
  VP ret;
  rep(i,n) {
    int ccwc = ccw(a1, a2, ps[i]);
    if (ccwc != -1) ret.push_back(ps[i]);
    int ccwn = ccw(a1, a2, ps[(i + 1) % n]);
    if (ccwc * ccwn == -1) ret.push_back(crosspointLL(a1, a2, ps[i], ps[(i + 1) % n]));
  }
  return ret;
}
D area(const VP& ps) {
  D a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}
int main(){
  int n;
  cin>>n;
  VP v;
  while(n--){
    double a,b;
    cin>>a>>b;
    v.push_back(P(a,b));
   }
   int q;
   cin>>q;
   while(q--){
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    VP p=convexCut(v,P(a,b),P(c,d));
    printf("%.10f\n",area(p));
   }
}

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

#define pb push_back
#define fst first
#define scd second
#define all(x) x.begin(), x.end()
#define N int(1e6+10)
#define mkp make_pair

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef list<int> li;
typedef list<ll> llong;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

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

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

ll inv_mod(ll a, ll b){
	ll x=0, y=1, r, q, ta=a;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=ta;
	return x%ta;
}

int main(){
	string s;
	cin>>s;
	for(int i=1; i<s.length(); i++){
		if(s[i]=='C' && s[i-1]=='A'){
			cout<<"Yes\n";
			return 0;
		}
	}

	cout<<"No\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int func(int a, int b) {
  string aa = to_string(a);
  string bb = to_string(b);
  return max(aa.size(), bb.size());
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    vector<set<int>> st(10);
    rep(i,n) {
        int d=s[i]-'0';
        st[d].insert(i);
    }
    int ans = 0;
    repe(i,9) {
        repe(j,9) {
            repe(k,9) {
                int pos = -1;
                if (st[i].upper_bound(pos) == st[i].end()) continue;
                pos = *st[i].upper_bound(pos);
                if (st[j].upper_bound(pos) == st[j].end()) continue;
                pos = *st[j].upper_bound(pos);
                if (st[k].upper_bound(pos) == st[k].end()) continue;
                pos = *st[k].upper_bound(pos);
                ans ++;
            }
        }
    }
    ct(ans);

}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int n,ans,ter=1;bool can=false;
std::vector<int> a;
int main(){
  cin >> n;
  a.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (size_t i = 0; i < n; i++) {
    if(a[i] == ter){
      ter++;
      can = true;
    }
    else ans++;
  }
  cout << (can?ans:-1) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Aug 29 21:10:14 JST 2020
 **/

const Int K = (Int)1e6 + 2;
signed main() {
    Int n;
    std::cin >> n;
    std::vector<bool> b(K);
    Int g = 0;
    REP(i, n) {
        Int x;
        std::cin >> x;
        b[x] = true;
        g = std::gcd(g, x);
    }
    if (g != 1) {
        std::cout << "not coprime\n";
        return 0;
    }
    REP(x, 2, K) {
        Int cnt = 0;
        for (Int y = x; y < K; y += x) {
            cnt += b[y];
        }
        if (cnt >= 2) {
            std::cout << "setwise coprime\n";
            return 0;
        }
    }
    std::cout << "pairwise coprime\n";
}


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

int main(){
    int n;
    while(cin >> n, n != 0){
        bool on_floor = true;
        int feet = 0, cnt = 0;
        for(int i=0;i<n;++i){
            string s;
            cin >> s;
            if(s == "lu"){
                feet |= 1;
                if(on_floor && feet == 3){
                    cnt++;
                    on_floor = false;
                }
            }else if(s == "ru"){
                feet |= 2;
                if(on_floor && feet == 3){
                    cnt++;
                    on_floor = false;
                }
            }else if(s == "ld"){
                feet &= ~1;
                if(!on_floor && feet == 0){
                    cnt++;
                    on_floor = true;
                }
            }else{
                feet &= ~2;
                if(!on_floor && feet == 0){
                    cnt++;
                    on_floor = true;
                }
            }
        }
        cout << cnt << endl;;
    }

    return 0;
}


Measured memory_bytes: 3136
import java.util.Scanner;

/**
 * Created by yufeng.fyf on 16/10/10.
 */
public class Main {
    private static String temple = "CODEFESTIVAL2016";
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        int n = 0;
        for(int i=0;i<16;i++){
            if(s.charAt(i)!=temple.charAt(i)){
                n++;
            }
        }
        System.out.println(n);
    }
}


Measured memory_bytes: 8916
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! eprint(
    ($($arg:tt)*) => {
        if cfg!(feature = "debug") {
            use std::io::Write;
            let r = write!(&mut ::std::io::stderr(), $($arg)*);
            r.expect("failed printing to stderr");
        }
    }
);

macro_rules! eprintln(
    ($($arg:tt)*) => {
        if cfg!(feature = "debug") {
            use std::io::Write;
            let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
            r.expect("failed printing to stderr");
        }
    }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        if cfg!(feature = "debug") {
            match $val {
                tmp => {
                    eprintln!(
                        "[{}:{}] {} = {:#?}",
                        file!(),
                        line!(),
                        stringify!($val),
                        &tmp
                    );
                    tmp
                }
            }
        } else {
            $val
        }
    };
}

fn main() {
    input! {
        n: u64,
    }

    solve(n);
}

fn solve(n: u64) {
    if n == 0 {
        return;
    }

    let maybe_k = ((-1.0 + ((1 + 8 * n) as f64).sqrt()) / 2.0).ceil() as u64;
    let maybe_ks = [maybe_k - 1, maybe_k, maybe_k + 1];
    let k = maybe_ks
        .iter()
        .filter(|&&k| {
            let n_geq = (k * (k + 1)) as f64 / 2.0;
            n_geq >= n as f64
        })
        .min()
        .unwrap();

    println!("{}", k);

    solve(n - k);
}


Measured memory_bytes: 4860
n = int(input())
sp = [input().split() for _ in range(n)]
d = {}
for idx,(s,p) in enumerate(sp):
  if s in d.keys():
    d[s].append([int(p),idx])
  else:
    d[s] = [[int(p),idx]]

for key in sorted(d.keys()):
  for v in sorted(d[key])[::-1]:
    print(v[1]+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int answer = d.at(N/2) - d.at(N/2-1);
  
  cout << answer << endl;
}

Measured memory_bytes: 640
R,G,B,N=map(int,input().split())
ANS=0

for r in range(3001):
    if r>N//R:
        break
    for g in range(3001):
        if g>N//G:
            break

        rest=N-(r*R+g*G)
        if rest>=0 and rest%B==0:
            ANS+=1

print(ANS)

Measured memory_bytes: 40812
#include <iostream>
using namespace std;
using ll = long long;

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

ll INF = 1e12;

int main() {
  ll L, R;
  cin >> L >> R;
  ll min = INF;
  for(ll i = L; i < L + 2019 && i <= R - 1; ++i) {
    for(ll j = i + 1; j < i + 1 + 2019 && j <= R; ++j) {
      chmin(min, (i * j) % 2019);
      if(min == 0) {
        break;
      }
    }
  }
  cout << min << endl;
  return 0;
}
/*
int main() {
  ll L, R;
  cin >> L >> R;
  if((R - L) / 2019 > 0) {
    cout << 0 << endl;
    return 0;
  }
  ll l = L % 2019;
  ll r = R % 2019;
  if(l > r) {
    cout << 0 << endl;
  } else {
    cout << l * (l + 1) << endl;
  }
  return 0;
}
*/

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    while(q--){
        int k; cin >> k;
        ll ans=0;
        ll d=0,m=0,dm=0;
        for(int i=0;i<n;i++){
            if(i>=k){
                if(s[i-k]=='D'){
                    d--;
                    dm-=m;
                }
                else if(s[i-k]=='M')m--;
            }
            if(s[i]=='D'){
                d++;
            }
            else if(s[i]=='M'){
                dm+=d;
                m++;
            }
            else if(s[i]=='C'){
                ans+=dm;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define tc int t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff(i,a,b) for(i=a;i<b;i++)
#define fb(i,b,a) for(i=b;i>a;i--)
#define ffi(i,a,b,c) for(i=a;i<b;i+=c)
#define fbi(i,b,a,c) for(i=b;i>a;i-=c)
#define clin(s) getline(cin,s)
#define MOD 1e9+7
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ub upper_bound
#define lb lower_bound
int main() {
	fio;
	int n,i,j;
	cin>>n;
	int arr[n], dp[n];
	ff(i,0,n){
		cin>>arr[i];
	}
	dp[0]=0;
	dp[1]=abs(arr[0]-arr[1]);
	//cout<<dp[0]<<" "<<dp[1]<<" ";
	ff(i,2,n){
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
		//cout<<dp[i]<<" ";
	}
	//cout<<"\n";
	cout<<dp[n-1]<<"\n";
	return 0;
}


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

int dp[200010];
int a[200010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	int ans=n-k+1;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	dp[1]=1;
	for(int i=2;i<=n;i++)
		if(a[i]>a[i-1])
			dp[i]=dp[i-1]+1;
		else
			dp[i]=1;
	for(int i=1;i<=n;i++)
		if(dp[i]>=k)
			ans--;
	for(int i=1;i<=n;i++)
		if(dp[i]>=k){
			ans++;
			break;
		}
	set<int> s;
	for(int i=2;i<=k;i++)
		s.insert(a[i]);
	for(int i=k+1;i<=n;i++){
		if(a[i-k]<*s.begin()&&*(--s.end())<a[i])
			if(dp[i]<k)
			ans--;
		s.erase(a[i-k+1]);
		s.insert(a[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 11136
import java.util.*;
public class Main{
	static int power(int a, int k){
		int pow = 1;
		while(k!=0){
			if(k%2==0){
				a = a*a;
				k /= 2;
			}
			else {
				pow *= a;
				k -= 1;
			}
		}
		return pow;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		System.out.println((100*n+1800*m)*power(2, m));
		System.out.println();
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    if(a + b >= c){
        print(b + c);
        return 0;
    } else{
        print(2 * b + a + 1);
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s, t; cin >> s >> t;
  reverse(all(s));
  for(int i=n; i>=0; i--) {
    string ss = s.substr(0, i);
    reverse(all(ss));
    if(ss == t.substr(0, i)) {
      cout << 2*n-i << endk;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3612