akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

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

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int H, W; cin >> H >> W;
	VI alp(26, 0), cnt(4, 0);
	REP(i, H) {
		string S; cin >> S;
		REP(j, W) alp[S[j] - 'a']++;
	}
	cnt[0] = (H / 2)*(W / 2);
	cnt[1] = (H % 2) && (W % 2);
	cnt[2] = (H*W - cnt[0]*4)/2;

	REP(i, 26) {
		int tmp = min(cnt[0], alp[i] / 4);
		alp[i] -= 4 * tmp;
		cnt[0] -= tmp;
	}
	REP(i, 26) {
		int tmp = min(cnt[2], alp[i] / 2);
		alp[i] -= 2 * tmp;
		cnt[2] -= tmp;
	}
	REP(i, 26) {
		int tmp = min(cnt[1], alp[i] / 1);
		alp[i] -= 1 * tmp;
		cnt[1] -= tmp;
	}
	Yn(cnt[0]==0 && cnt[1] == 0 && cnt[2] == 0);
	return 0;
}



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

int main() {
    ll n, m, x;
    cin >> n >> m >> x ;
    vector<vector<ll>> book(n);
    vector<ll>cost(n);
    rep(i, 0, n){
        cin >> cost[i];
        rep(j, 0, m){
            ll b;
            cin >>b;
            book.at(i).push_back(b);
        }
    }
    ll ans = 10000000;
    for(int bit=0; bit < (1 << n); bit++ ){
        ll tempans = 0;
        int count = 0;
        vector<ll> com(m, 0);
        rep(i, 0, n){
            if(bit & (1 << i)){
                rep(j, 0, m){
                    com[j] += book[i][j];
                }
                tempans += cost[i];
            }
        }
        rep(k, 0, m){
                if(com[k] >= x)count++; 
        }
        if(count == m) ans = min(ans, tempans);
    }
    if(ans == 10000000) cout << -1 << endl;
    else cout << ans << endl;
}



Measured memory_bytes: 3580
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    vector<priority_queue<int>> a;
    int n, q, query, t, x;
    
    cin >> n >> q;
    a.resize(n);
    // query processing
    for (int i=0; i<q; ++i){
        cin >> query;
        // insert
        if(query == 0){
            cin >> t >> x;
            a[t].push(x);
        }
        // getMax
        else if(query == 1){
            cin >> t;
            if(!a[t].empty()){
                cout << a[t].top() << endl;
            }
        }
        // deleteMax
        else if(query == 2){
            cin >> t;
            if(!a[t].empty()){
                a[t].pop();
            }
        }
    }
}



Measured memory_bytes: 4144
s=input()
ng=len(s)

now=0
chi=0
swit=0
kao=[]
if s[0]=='<':
    kao.append(0)

for i in range(ng):
    if s[i]=='>':
        swit=1
    else:
        if swit==1:
            kao.append(i)
        swit=0

if s[-1]=='>':
    kao.append(ng)


kaz=[-1]*(ng+1)
for k in kao:
    kaz[k]=0

for i in range(len(kao)):
    swit=0
    ima=kao[i]
    while swit==0:
        if ima+1<len(kaz):
            if s[ima]=='<':
                kaz[ima+1]=kaz[ima]+1
                ima+=1
            else:
                swit=1
        else:
            swit=1

for i in range(len(kao)):
    swit=0
    ima=kao[i]-1
    loop=0
    while swit==0:
        loop+=1
        if ima>=0:
            if s[ima]=='>':
                if kaz[ima]<kaz[ima+1]+1:
                    kaz[ima]=kaz[ima+1]+1
                ima-=1
            else:
                swit=1
        else:
            swit=1

print(sum(kaz))

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


int main() {
  ll n ,k , q;

  cin >> n >> k >> q;

  vector<int> a(q);
  rep(i ,q) cin >> a[i];

  ll base = k - q;
  vector<ll> v(n, base); 

  rep(i, q) --a[i];

  rep(i, q) v[a[i]]++;


  rep(i, n) {
    if(v[i] <= 0) {
      cout << "No" << endl;      
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}

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

int main() {
  int a, b, c, d, m, n;
  cin >> a >> b >> c >> d;
  m = a - c;
  n = b - d;
    cout << c + n << " " << d - m << " " << a + n << " " << b - m << endl;
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 100005;
int a[N];
ll dp[N][2], ac[N];

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, q; cin >> n >> q;
	dp[0][0] = dp[0][1] = 0;
	ac[0] = 0;
	REPU(i, 0, n) {
		cin >> a[i];
		dp[i + 1][0] = dp[i][0];
		dp[i + 1][1] = dp[i][1];
		dp[i + 1][i & 1] += a[i];
		ac[i + 1] = ac[i] + a[i];
	}

	while (q--) {
		int x; cin >> x;
		int idx = lower_bound(a, a + n, x) - a;
		int rem = n - idx;
		ll ans = 0;
		int lb = 0, rb = rem + 1;
		while (rb - lb > 1) {
			int m = (lb + rb) >> 1;
			// get m cards
			int v = a[idx + m - 1];
			int u = x - v + x;
			int j = lower_bound(a, a + n, u) - a;
			if (idx + m - j <= n - (idx + m)) lb = m;
			else rb = m;
		}
		ans = ac[n] - ac[idx + lb];
		//DEBUG(idx, lb);
		if (lb > 0) {
			int v = a[idx + lb - 1];
			int u = x - v + x;
			int j = lower_bound(a, a + n, u) - a;
			--j;
			int rev = n - (idx + lb);
			amin(j, idx + lb - 1 - rev);
			//DEBUG(j);
			if (j >= 0) {
				if ((n - j + 1) & 1) j--;
				if (j >= 0) {
					ans += dp[j + 1][j & 1];
				}
			}
		}
		else {
			int v = idx - (n - idx);
			if (v > 0) {
				ans += dp[v][(v - 1) & 1];
			}
		}

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

	return 0;
}


Measured memory_bytes: 4480
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=Integer.parseInt(in.next()),A[]=new int[n],cnt=0;
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());
		
		int m=Integer.parseInt(in.next());
		for(int i=0;i<m;i++) {
			int key=Integer.parseInt(in.next());
			if(Arrays.binarySearch(A, key)>=0)cnt++;
			else break;
		}
		
		if(cnt==m)System.out.println(1);
		else System.out.println(0);
	}
}



Measured memory_bytes: 96068
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

u = UnionFind(n)
for a, b in ab:
    a, b = a-1, b-1
    u.unite(a, b)
print(sum([1 for i in u.parents if i < 0]) - 1)

Measured memory_bytes: 29492
# -*- coding:utf-8 -*-

S = input()

R = S[::-1].translate({
    ord(u'b'): u'd',
    ord(u'd'): u'b',
    ord(u'p'): u'q',
    ord(u'q'): u'p',
})

if S == R:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3700
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int D[101000], n;
vector<int>E[101000];
void DFS(int a){
    int i;
    if(E[a].empty())return;
    for(i=0;i<E[a].size();i++){
        DFS(E[a][i]);
    }
    vector<int>TP;
    for(i=0;i<E[a].size();i++){
        TP.push_back(D[E[a][i]]);
    }
    sort(TP.begin(),TP.end());
    int Mx = 0, sz = TP.size();
    for(i=0;i<TP.size();i++){
        Mx = max(Mx,TP[i] + sz - i);
    }
    D[a] = Mx;
}
int main(){
    int i, a;
    scanf("%d",&n);
    for(i=2;i<=n;i++){
        scanf("%d",&a);
        E[a].push_back(i);
    }
    DFS(1);
    printf("%d\n",D[1]);
}

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

int main(){
        int ans = 0;
        std::string s;
        std::cin >> s;

        for(int i=0; i<s.size(); i++){
                int tmp = 0;
                for(int j=i; j<s.size(); j++){
                        if(s[j]!='A' and s[j]!='C' and s[j]!='G' and s[j]!='T'){
                                break;
                        }else{
                                tmp++;
                        }
                }
                ans = std::max(ans, tmp);
        }

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

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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

struct Edge {
    int u, v, w;
};

const int MAXN = 25;

int L, n, m, dp[MAXN];
vector<Edge> edge;
vector<ii> g[MAXN];

int DFS(int u) {
    if (dp[u] != -1) return dp[u];
    if (u == n) return 1;

    int &res = dp[u] = 0;
    fto(i, 0, sz(g[u])-1) {
        int v = g[u][i].first;
        res += DFS(v);
    }
    return dp[u];
}

void Check() {
    fto(u, 1, n) g[u].clear();
    for(Edge e: edge) {
        g[e.u].pb({e.v, e.w});
    }

    fto(u, 1, n) dp[u] = -1;
    if (DFS(1) != L) {
        printf("%d\n", L);
        return;
    }
}

void Solve() {
    n = 20;
    edge.clear();

    fto(i, 1, n-2) {
        edge.pb({i, i+1, 0});
        edge.pb({i, i+1, 1<<(i-1)});
    }

    int cur = 0;
    if (L >= (1<<(n-1))) {
        edge.pb({n-1, n, 0});
        edge.pb({n-1, n, 1<<(n-2)});
        cur += 1<<(n-1);
    }

    fdto(i, n-2, 0) {
        if ((L>>i)&1) {
            edge.pb({i+1, n, cur});
            cur += 1<<i;
        }
    }

    m = sz(edge);
    printf("%d %d\n", n, m);
    for(Edge e: edge) printf("%d %d %d\n", e.u, e.v, e.w);
}

int main () {
    scanf("%d", &L);
    Solve();



//    fto(i, 2, 1000000) {
//        Solve();
//        Check();
//    }

    return 0;
}


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

int n,cnt;
int a[N],h[N],b[N],t[N];

void add(int x) {
	for (;x<=2*n;x+=x&(-x)) t[x]++;
}
int query(int x) {
	int ret=0;
	for (;x;x-=x&(-x)) ret+=t[x];
	return ret;
}

bool check(int mid)
{
	ll sum=0;
	for (int i=1;i<=n;i++)
		if (a[i]>=mid) b[i]=1; else b[i]=-1;
	memset(t,0,sizeof(t));
	add(n);
	for (int i=1;i<=n;i++)
	{
		b[i]+=b[i-1];
		sum+=query(b[i]+n);
		add(b[i]+n);
	}
	return sum>=(1ll*(n+1)*n/2+1)/2;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),h[i]=a[i];
	sort(h+1,h+n+1);
	cnt=unique(h+1,h+n+1)-h-1;
	for (int i=1;i<=n;i++) a[i]=lower_bound(h+1,h+cnt+1,a[i])-h;
	
	int l=1,r=cnt,mid,ans;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (check(mid))
			ans=mid,l=mid+1;
			else r=mid-1;
	}
	printf("%d\n",h[ans]);
	return 0;
}

Measured memory_bytes: 2176
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 100005
# define eps 1e-6
# define MAXM 10000005
# define MOD 1000000007
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}

struct Edge{int p, next, w, v;}edge[MAXM];
int head[MAXN], dis[MAXN], vis[MAXN], pre[MAXN], pos[MAXN], cnt, s, t;

inline void init(){memset(head,0,sizeof(head)); cnt=2;}
inline void add_edge(int u, int v, int w, int val)
{
    edge[cnt].p=v; edge[cnt].w=w; edge[cnt].v=val; edge[cnt].next=head[u]; head[u]=cnt++;
	edge[cnt].p=u; edge[cnt].w=0; edge[cnt].v=-val; edge[cnt].next=head[v]; head[v]=cnt++;
}
bool spfa()
{
	int v, i;
	for (i=s; i<=t; ++i) dis[i]=INF, pre[i]=-1, vis[i]=0;
	dis[s]=0; vis[s]=1; pre[s]=s;
	queue<int>Q; Q.push(s);
	while (!Q.empty()) {
		v=Q.front(); Q.pop(); vis[v]=0;
		for (i=head[v]; i; i=edge[i].next)
			if (edge[i].w>0 && dis[v]+edge[i].v<dis[edge[i].p]) {
				dis[edge[i].p]=dis[v]+edge[i].v; pre[edge[i].p]=v; pos[edge[i].p]=i;
				if (vis[edge[i].p]==0) vis[edge[i].p]=1, Q.push(edge[i].p);
			}
	}
	return pre[t]!=-1&&dis[t]<INF;
}
int costflow()
{
	int cf=0, nf=0, min, i;
	while (spfa()) {
		min = INF;
		for (i=t; i!=s; i=pre[i]) min=MIN(min,edge[pos[i]].w);
		nf+=min; cf+=min*dis[t];
		for (i=t; i!=s; i=pre[i]) edge[pos[i]].w-=min, edge[pos[i]^1].w+=min;
	}
	return cf;
}
int main (void)
{
	int x, i, j, sum, n, m;
    scanf("%d%d",&n,&m);
    init(); sum=0;
    for (i=0; i<n; ++i) for (j=0; j<m; ++j) {
        scanf("%d",&x);
        if ((i==0&&j==0)||(i==n-1&&j==m-1)) sum+=x;
        add_edge(i*m+j,i*m+j+n*m,(i==0&&j==0)||(i==n-1&&j==m-1)?2:1,-x);
        if (i+1<n) add_edge(i*m+j+n*m,(i+1)*m+j,1,0);
        if (j+1<m) add_edge(i*m+j+n*m,i*m+j+1,1,0);
    }
    s=0; t=2*n*m-1;
    printf("%d\n",-costflow()-sum);
	return 0;
}



Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    vector<vector<int>> a(3, vector<int>(3));
    rep(i,3) {
        rep(j,3) {
            cin >> a[i][j];
        }
    }

    int n;
    cin >> n;
    rep(k,n) {
        int tmp;
        cin >> tmp;
        rep(i,3) {
            rep(j,3) {
                if (a[i][j] == tmp)
                    a[i][j] = 0;
            }
        }
    }

    string ans = "No";
    rep(i,3) {
        if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0)
            ans = "Yes";
    }
    rep(i,3) {
        if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0)
            ans = "Yes";
    }
    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
            ans = "Yes";
    if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0)
            ans = "Yes";

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


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;

int main(){
    scanf("%ld", &n);
    long dist = LINF;
    for(long i = 1; i * i <= n; i++){
        //printf("  %ld\n", i);
        if(n % i == 0){
            dist = std::min(dist, n / i + i - 2);
        }
    }
    printf("%ld\n", dist);
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  
  int ans = 0;
  for (int i = 0; i < S.size() / 2; i++) {
    if (S.at(i) != S.at(S.size() - i -1)) {
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 5010;


ll n, A, B, P[maxn], dp[maxn][maxn];

void MAIN() {

    cin >> n >> A >> B;
    fori (i, n) cin >> P[i + 1];
    memset(dp, 20, sizeof dp);
    dp[0][0] = 0;
    fori (i, n) {
        fori (j, i + 1) {
            if (P[i + 1] > P[j]) {
                smin(dp[i + 1][i + 1], dp[i][j]);
                smin(dp[i + 1][j], dp[i][j] + A);
            } else {
                smin(dp[i + 1][j], dp[i][j] + B);
            }
        }
    }
    ll ans = *min_element(dp[n], dp[n] + n + 1);
    cout << ans << '\n';

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
9 40 50
5 3 4 7 6 1 2 9 8
    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 196480
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(s,t);
  bool flg = false;
  REP(i,s.size()){
    if(s==t){
      flg = true;
      break;
    }
    s = s.back() + s.substr(0,s.size()-1);
  }
  Yes(flg);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

vector<string> StringSplit(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int ShiftCounter(int N, vector<string> vkey){
  vector<int> counter(2, 0);
  unsigned long num = 0;

  for(int i = 0; i < N; i++){
    counter[1] = 0;
    num = stol(vkey[i]);
    while(num % 2 == 0){
      num = num >> 1;
      if(i == 0){
        counter[0]++;
      }else{
        counter[1]++;
      }
    }
    if(i > 0 && (counter[0] > counter[1]) ){
      counter[0] = counter[1];
    }
  }
  return counter[0];
}

int main(void){
  int N;
  string ss;
  cin >> N;
  cin.ignore();
  getline(cin, ss);
  vector<string> vkey = StringSplit(ss,' ');
  cout << ShiftCounter(N, vkey);
  return 0;
}

Measured memory_bytes: 256
A=10**9+7

def g(n, m)
  f=->n{(1..n).inject{|r,n|r*n%A}}

  [2*a=f[n]*f[m],a][n-m]||0
end

N, M = gets.split.take(2).map(&:to_i)
p g(N, M)%A


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, t;
  cin >> n >> t;

  int dp[7000];
  memset(dp, 0, sizeof dp);
  vector<pair<int, int>> p(n);
  for (int i = 0; i < n; ++i)
    cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());

  for (int i = 0; i < n; ++i) {
    int a, b;
    a = p[i].first, b = p[i].second;
    for (int j = t-1; j >= 0; --j) {
      dp[j+a] = max(dp[j+a], dp[j] + b);
    }
  }

  int ans = 0;
  for (int i = 0; i < 7000; ++i)
    ans = max(ans, dp[i]);

  cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(n);
	makei(t);
	int cmin = 1001;
	rep(n) {
		makei(ci);
		makei(ti);
		if (ti <= t) {
			mini(cmin, ci);
		}
	}
	if (cmin == 1001)say("TLE");
	else say(cmin);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	for (int i = 1; i <= 3; ++i) {
		if ((a * b * i) & 1) {
			cout << "Yes\n";
			return 0;
		}
	}

	cout << "No\n";

	return 0;

}

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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int a[100];

void solve()
{
  int b;
  REP(i,64) if(a[i])
  {
    b = i;
    break;
  }
  if(a[b+1])
  {
    if(a[b+2]) printf("C\n");
    else if(a[b+8])
    {
      if(a[b+9]) printf("A\n");
      else printf("G\n");
    }
    else printf("E\n");
  }
  else if(a[b+16]) printf("B\n");
  else if(a[b+9]) printf("F\n");
  else printf("D\n");
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int i = 0; string s;
  fill_n(a,100,0);
  while(cin >> s)
  {
    REP(j,8) a[i*8+j] = (s[j]-'0');
    (++i) %= 8;
    if(i == 0) solve();
  }
  return 0;
}

Measured memory_bytes: 1180
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):

    BC = [[B[i], C[i]] for i in range(M)]
    BC = sorted(BC, key=lambda x:x[1], reverse=True)
    
    idx = 0
    A.sort()

    for i in range(N):
        if idx < M and BC[idx][0] > 0 and A[i] < BC[idx][1]:
            A[i] = BC[idx][1]
            BC[idx][0] -= 1
            if(BC[idx][0] == 0):
                idx += 1        


    print(sum(A))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27540
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

char a[200010];
int b[1<<26];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	scanf("%s",a+1);int n=strlen(a+1);
	int m=(1<<26);
	for (int i=1;i<m;i++) b[i]=n;b[0]=0;
	int t=0;
	for (int i=1;i<=n;i++)
	{
		t^=(1<<(a[i]-97));
		for (int j=0;j<26;j++) b[t]=min(b[t],b[t^(1<<j)]+1);
	}
	printf("%d\n",max(b[t],1));
	return 0;
}



Measured memory_bytes: 262656
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  for (ll i=0; i<S.size(); i++){
    char s = S[i];
    if((i+1)%2){
      // 奇数
      if(!( s == 'U' || s == 'R' || s == 'D')){
        cout << NO << endl;
        return;
      }
    }else{
      // 偶数
      if(!( s == 'U' || s == 'L' || s == 'D')){
        cout << NO << endl;
        return;
      }
    }
  }
  cout << YES << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        _: usize,
        s: Chars
    };
    let modp = 1_000_000_007_i64;
    let mut c = vec![1_i64; 26];
    for &s_i in s.iter() {
        let c_i = (s_i as u8 - 'a' as u8) as usize;
        c[c_i] += 1;
    }
    let mut ans = 1_i64;
    for &c_i in c.iter() {
        ans *= c_i;
        ans %= modp;
    }
    ans -= 1;
    println!("{}", ans);
}


Measured memory_bytes: 2564
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int V = in.nextInt();
		int E = in.nextInt();

		used = new boolean[V];
		lEdge = new List[V];
		for (int i=0;i<V;i++) {
			lEdge[i] = new ArrayList<Edge>();
		}
		
		for (int i=0;i<E;i++) {
			addEdge(in.nextInt(), in.nextInt(), in.nextInt());
		}
		
		int res = 0;
		while(true) {
			Arrays.fill(used, false);
			int ret = dfs(0, V-1, Integer.MAX_VALUE);
			if (ret==0) break;
			res += ret;
		}
		System.out.println(res);
	}
	static List<Edge>[] lEdge;
	static void addEdge(int fr, int to, int cap) {
		lEdge[fr].add(new Edge(to, cap, lEdge[to].size()));
		lEdge[to].add(new Edge(fr, 0, lEdge[fr].size()-1));
	}
	
	static class Edge {
		int to, cap, rev;
		public Edge(int to, int cap, int rev) {
			this.to= to;
			this.cap = cap;
			this.rev = rev;
		}
	}

	static boolean[] used;
	
	static int dfs (int fr, int to, int f) {
		if (fr==to) return f;
		used[fr] = true;
		
		for (int i=0;i<lEdge[fr].size();i++) {
			Edge e = lEdge[fr].get(i);
			if (!used[e.to] && e.cap>0) {
				int dist = dfs(e.to, to, Math.min(f, e.cap));
				if (dist>0) {
					e.cap -=dist;
					lEdge[e.to].get(e.rev).cap += dist;
					return dist;
				}
			}
		}
		return 0;
	}
	
}

Measured memory_bytes: 34540
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint comb(int a, int b) {
    
    mint ans(1);
    rep(i, b) {
        ans *= (a-i);
        ans /= (i+1);
    }
    return ans;
}


int main(){
    int x, y;
    cin >> x >> y;
    if ((x+y)%3 || 2*x<y || 2*y<x) {
        cout << "0" << endl;
        return 0;
    }
    int n = (x+y)/3;
    int dx = x-n;
    mint ans = comb(n, dx);
    
    
    
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * ???????????§??????????´? EightQueen.java
 *
 * Copyright(C) 2016 Nagasaki Team All Rights Reserved.
 */
/**
 * ??°?????????????????????(ITP1_9-B)
 *
 * @author Iwanaga
 * @version 1.00
 */
 
 
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class Main{
	/**
	 *??°?????????????????????
	 */
	public static void main(String[] args) throws IOException{//try????????\????????????
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int count = 1;
		while(!str.equals("0")){
			System.out.println("Case "+count+": "+str);//"Case1:??\?????°???"?????¢?????§??¨???
			count++;
			str = br.readLine();//?¬??????????????????????
		}
	}
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i=0,j,N,M,K,cnt,a,b;
  string ss;
  cin>>ss;
  N=ss.size();
  vector<ll> v(N,0);

  while(i<N){
    cnt=0;
    while(ss[i]=='R'){
      i++;
      cnt++;
    }
    v[i-1]=cnt;
    cnt=0;
    j=i;
    while(j<N&&ss[j]=='L'){
      j++;
      cnt++;
    }
    v[i]=cnt;
    a=(v[i]+v[i-1])/2;
    if((v[i]+v[i-1])%2){
      if((min(v[i],v[i-1]))%2==0){
        if(v[i-1]<v[i]){
          v[i-1]=a;
          v[i]=a+1;
        }else{
          v[i-1]=a+1;
          v[i]=a;
        }
      }else{
        if(v[i-1]<v[i]){
          v[i-1]=a+1;
          v[i]=a;
        }else{
          v[i-1]=a;
          v[i]=a+1;
        }
      }
    }else{
      v[i-1]=v[i]=a;
    }
    i=j;
  }
  rep(i,N){
    cout<<v[i]<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    int count=0;
    char array[SIZE];
    int i=0;
    char dump;


    //最初のノードの指す先
    node *first = NULL;

    scanf("%s",array);
    
    //スタックにノードを追加
    for(i=0;i<strlen(array);i++){
        if(first == NULL || first->elem == array[i]){
            push(&first, array[i]);
        }else{
            dump = pop(&first);
            count += 2;
        }
    }
    
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 4932
def main():
    import bisect
    n, k, q = map(int, input().split())
    indic = {}
    for _ in range(q):
        a = int(input())
        if a in indic:
            indic[a] += 1
        else:
            indic[a] = 1
    
    for i in range(n):
        if i+1 not in indic:
            tensuu = k - q
        else:
            tensuu = k - q + indic[i+1]
        if tensuu <= 0:
            print('No')
        else:
            print('Yes')
    


if __name__ == "__main__":
    main()


Measured memory_bytes: 83100
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
 
using namespace std;
 
int main(){

    ll a,b;
    cin >> a >> b;

    if(a*b <= 0){
        cout << "Zero";
        return 0;
    }
    if(a > 0 && b > 0)cout << "Positive";
    else if((b-a)%2)cout << "Positive";
    else cout << "Negative";
}

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

int main(){
  string s;
  cin >> s;
  if(s == "ABC"){
    cout << "ARC" << endl;
    
  }
  else cout << "ABC" << endl;
}


Measured memory_bytes: 3624
X,K,D = map(int,input().split())

# 絶対値を取れば正の座標だけ考えれば済む
X = abs(X)

# D>Xなら移動1回だけで原点飛び越える
if D > X:
  #偶数の場合はそのままで奇数の場合はD-X
  if K % 2 == 0:
    print(X)
  else:
    print(abs(D-X))
    
# K回移動してもまだ正のときは最後の座標
else:
  if X//D >= K:
    print(X - K*D)
# その後の移動の検討
  else:
    tmp = X - (X//D)*D
    if (K - X//D) % 2 == 0:
      print(tmp)
    else:
      print(min(abs(tmp-D),tmp+D))

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

using namespace std;
typedef long long ll;

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

    if(a==b && a!=c)
        cout << "Yes" << endl;
    else if (a == c && a != b)
        cout << "Yes" << endl;
    else if (b == c && a != c)
        cout << "Yes" << endl;

    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
int main(){
	fast;
	ll n;
	cin >> n;
	ll h[n];
	for(int i=0; i<n; i++){
		cin>>h[i];
	}
	ll dp[n] = {0};
	dp[1] = abs(h[1] - h[0]);
	for(int i=2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}	
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, l] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  const ajis = Array(n)
    .fill(0)
    .map((e, i) => {
      return l + i
    })

  let sum = 0

  if (ajis[0] > 0) {
    for (let i = 1; i < ajis.length; i++) {
      sum += ajis[i]
    }
    return sum
  } else if (ajis[ajis.length - 1] < 0) {
    for (let i = 0; i < ajis.length - 1; i++) {
      sum += ajis[i]
    }
    return sum
  } else {
    return ajis.reduce((p, c) => p + c)
  }
}

console.log(ans())


Measured memory_bytes: 9420
NK = input().split()
N = int(NK[0])
K = int(NK[1])

RSP = input().split()
R = int(RSP[0])
S = int(RSP[1])
P = int(RSP[2])
T = input()

hands = {'r':'p', 's':'r', 'p':'s', 'e':'e'}
points = {'r':R, 's': S, 'p': P}
hist = {}
point = 0
for i in range(len(T)):
  if (i-K >= 0) and (hist[i-K] == hands[T[i]]):
    hist[i] = hands['e']
  else:
    hist[i] = hands[T[i]]
    point += points[hist[i]]
print(point)

Measured memory_bytes: 15344
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i = 0;i<n-1;i++)
        cout<<a[i]<<' ';
    cout<<a[n-1];
    cout<<endl;
    for(int i=1;i<n;i++)
    {
        int v=a[i];
        int j=i-1;
        while(j>=0&&a[j]>v)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        for(int i=0;i<n-1;i++)
            cout<<a[i]<<' ';
        cout<<a[n-1];
        cout<<endl;
    }
    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> x(m);
    rep(i,m) cin>>x[i];

    if(n>=m){
        cout<<0<<endl;
        return 0;
    }

    sort(all(x));
    vector<ll> v;
    ll ans=0;
    rep(i,m-1){
        ans+=x[i+1]-x[i];
        v.push_back(x[i+1]-x[i]);
    }

    sort(all(v));
    reverse(all(v));
    rep(i,n-1){
        ans-=v[i];
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 5012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
 
int main() {
    char s[101], t[101];
    rep(i, 101) s[i] = t[i] = '\0';
    scanf("%s", s);
    scanf("%s", t);
    int p = 0;
    while (t[p] != '\0') {
        printf("%c", t[p++]);
    }
    p = 0;
    while (s[p] != '\0') {
        printf("%c", s[p++]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3616
toTuple :: String -> (Int, String, Int)
toTuple s = (read a, op, read b)
    where
        [a, op, b] = words s

solve :: (Int, String, Int) -> Int
solve (a, op, b)
    | op == "+" = a + b
    | op == "-" = a - b
    | op == "*" = a * b
    | op == "/" = a`div` b

main :: IO ()
main = interact (unlines . map (show . solve) . takeWhile (\(_, op, _) -> op /= "?") . map toTuple . lines)

Measured memory_bytes: 4052