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

long long MOD=1000000007;
long long expo(long long a,long long b){
	if(b==0)return 1;
	long long temp=expo(a,b/2);
	if(b%2==0)return (temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
long long inv(long long a){
	return expo(a,MOD-2)%MOD;
}

long long fac[100005];

long long choose(long long n,long long k){
	return (((fac[n]*inv(fac[k]))%MOD)*inv(fac[n-k]))%MOD;
}

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	long long arr[n];
	for(int i=0;i<n;i++)scanf("%lld",&arr[i]);
	sort(arr,arr+n);
	fac[0]=1;
	for(long long i=1;i<100005;i++){
		fac[i]=fac[i-1]*i;fac[i]%=MOD;
	}
	long long ans=0;
	for(int i=0;i<n;i++){
		if(i<=n-k){
			ans-=(arr[i]*choose(n-i-1,k-1))%MOD;
		}
		if(i>=k-1){
			ans+=(arr[i]*choose(i,k-1))%MOD;
		}
		ans%=MOD;
		ans+=MOD;
		ans%=MOD;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 1792
n = int(input())

d2 = n % 100
u2 = n // 100

if 1 <= d2 <= 12 and 1 <= u2 <= 12:
    print("AMBIGUOUS ")
elif 1 <= d2 <= 12:
    print("YYMM")
elif 1 <= u2 <= 12:
    print("MMYY")
else:
    print("NA")


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int dp[55][3030];

int main() {

  int const MOD = 100000;

  for(int N, M, S; cin >> N >> M >> S && (N|M|S);) {
    rep(i, 55) rep(j, 3030)
      dp[i][j] = 0;

    dp[0][0] = 1;

    REP(add, 1, M + 1) {
      for(int currIndex = N * N; currIndex >= 1; currIndex--) {
        for(int currSum = add; currSum <= S; currSum++) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }

    cout << dp[N*N][S] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3724
n = int(input())
k = int(input())
x = list(map(int,input().split()))
S = 0
for i in range(n):
    l_a = 2 * x[i]
    l_b = 2 * abs(k-x[i])
    if l_a >= l_b:
        S += l_b
    else:
        S += l_a
        
print(S)

Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
	int w[10], k[10], i, p = 0, q = 0;
	for (i = 0; i < 10; i++)
		cin >> w[i];
	for (i = 0; i < 10; i++)
		cin >> k[i];
	sort(w, w+10, greater<int>());
	sort(k, k+10, greater<int>());
	for (i = 0; i < 3; i++)
	{
		p += w[i];
		q += k[i];
	}
	cout << p << " " << q << endl;
}

Measured memory_bytes: 0
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
int cnt[13];
int ans;
void solve(int t, int bit) {
	if (t == 13) {
		int mi = 1 << 30;
		for (int i = 0; i < 24; i++) {
			if ((bit&(1 << i)) == 0) continue;
			for (int j = i + 1; j < 24; j++) {
				if ((bit&(1 << j)) == 0) continue;
				int d = abs(i - j);
				mi = min(mi, min(d, 24 - d));
			}
		}
		ans = max(ans, mi);
		return;
	}
	if (cnt[t] == 0) {
		solve(t + 1, bit);
		return;
	}
	if (cnt[t] == 1) {
		solve(t + 1, bit | (1 << t));
		if (t > 0) solve(t + 1, bit | (1 << (24 - t)));
		return;
	}
	solve(t + 1, bit | (1 << t) | (1 << (24 - t)));
}
int main() {
	int N;
	cin >> N;
	cnt[0]++;
	rep(i, N) {
		int D;
		cin >> D;
		cnt[D]++;
	}
	if (cnt[0] > 1 || cnt[12] > 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < 12; i++) {
		if (cnt[i] > 2) {
			cout << 0 << endl;
			return 0;
		}
	}
	solve(0, 0);
	cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
def resolve():
    INF = 10 ** 18
    N, M, L = map(int, input().split())
    G = [[INF] * N for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        G[a][b] = G[b][a] = c

    G = csr_matrix(G)
    dist = floyd_warshall(G, directed=False)

    G2 = np.full((N, N), np.inf)  # 値をINFにした配列
    np.fill_diagonal(G2, 0)  # G[i][i]は動いていない状態なのでコスト0
    G2[dist <= L] = 1

    dist2 = floyd_warshall(G2, directed=False)

    Q = int(input())
    for _ in range(Q):
        a, b = map(lambda x: int(x) - 1, input().split())
        if dist2[a][b] == np.inf:
            print(-1)
        else:
            print(int(dist2[a][b]) - 1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 46280
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll K,N,M;
ll ans;
 
 
int main(){
    cin >>K>> N>>M;
    if(M/K-(N-1)/K>=1){
        cout << "OK" << endl;
    }else{
        cout << "NG" <<endl;
    }
    
}

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

using namespace std;

int g1[81][81];
int g2[81][81];
bool dp[81][81][6480];


int main() {
	int H, W;
	cin>>H>>W;
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g1[i][j];
		}
	}
	
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g2[i][j];
		}
	}
	
	dp[0][0][abs(g1[0][0] - g2[0][0])] = true;

	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			for (int k = 0;k <= 6400;++k) {
				if (dp[i][j][k]) {
					dp[i][j+1][abs(k - abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i][j+1][abs(k + abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i+1][j][abs(k - abs(g1[i+1][j] - g2[i+1][j]))] = true;
					dp[i+1][j][abs(k + abs(g1[i+1][j] - g2[i+1][j]))] = true;
				}
			}
		}
	}
	
	for (int i = 0;i <= 6400;++i) {
		if (dp[H-1][W-1][i]) {
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 41728
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

typedef pair<int,int> pii;
int n,m;
int s,t;
pii ps[101];
// »ê¼êÌÀW©çêÔß¢RrjÖÌ£
int dists[101][101];
const int INF=1000000000;
pii cand[101];
bool used[101][101];
bool noSet[101][101];

const int dy[2][6]={{-1,-1,0,1,1,0},{-1,-1,0,1,1,0}};
const int dx[2][6]={{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}};

int updateMinDist(int sx,int sy,bool isSearch=true){
    memset(used,0,sizeof(used));
    queue<pii> q[2];
    int cur=0;
    int nxt=1;
    int cnt=0;
    pii sp=pii(sy,sx);
    used[sy][sx]=true;
    dists[sy][sx]=0;
    int res=1;
    q[cur].push(sp);
    while(q[cur].size()){
        while(q[cur].size()){
            pii p=q[cur].front();q[cur].pop();
            for(int i=0;i<6;i++){
                int ny=dy[p.first%2][i]+p.first;
                int nx=dx[p.first%2][i]+p.second;
                if(ny>=0&&nx>=0&&ny<n&&nx<m&&!used[ny][nx]){
                    used[ny][nx]=true;
                    q[nxt].push(pii(ny,nx));
                    if(isSearch)dists[ny][nx]=min(dists[ny][nx],cnt+1);
                    else if(dists[ny][nx]>cnt+1)res++;
                }
            }
        }
        cnt++;
        swap(cur,nxt);
    }
    return res;
}

int main(){
    while(cin>>m>>n&&(m|n)){
        memset(noSet,0,sizeof(noSet));
        cin>>s;
        for(int i=0;i<101;i++)for(int j=0;j<101;j++)dists[i][j]=INF;
        for(int i=0;i<s;i++){
            cin>>ps[i].second>>ps[i].first;
            ps[i].second--;
            ps[i].first--;
            noSet[ps[i].first][ps[i].second]=true;
        }
        for(int k=0;k<s;k++)updateMinDist(ps[k].second,ps[k].first);
        cin>>t;
        for(int i=0;i<t;i++){
            cin>>cand[i].second>>cand[i].first;
            cand[i].second--;
            cand[i].first--;
        }
        int res=0;
        for(int i=0;i<t;i++){
            int cnt=0;
            cnt=updateMinDist(cand[i].second,cand[i].first,false);
            res=max(res,cnt);
        }
        cout<<res<<endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

const int N_MAX = 1e5;
vi G[N_MAX];

bool seen[N_MAX];
void dfs(int v){
    seen[v]=true;
    for(auto u:G[v]){
        if (seen[u]) continue;
        dfs(u);
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin>>N>>M;
    rep(i,M){
        int a,b; cin>>a>>b; a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int ans=0;
    rep(v,N){
        if (!seen[v]){
            ans++;
            dfs(v);
        }
    }
    cout<<ans-1<<endl;
    return 0;
}


Measured memory_bytes: 9708
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c > a + b) {
		cout <<  a+b+b+1 << endl;
	}
	else {
		cout << c + b << endl;
	}
	return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int m = 1;
  int num = 1;
  while (num*2 < n) {
    num *= 2;
    m++;
  }
  vector<int> x(n);
  for (int i=0;i<n;i++) cin >> x[i];
  int l,q;
  cin >> l >> q;
  vector<vector<int>> to(m,vector<int>(n,0));
  for (int i=0;i<n;i++) {
    int tomax = x[i]+l;
    int ind = upper_bound(x.begin(),x.end(),tomax)-x.begin();
    to[0][i] = ind-1;
  }
  for (int i=1;i<m;i++) {
    for (int j=0;j<n;j++) {
      to[i][j] = to[i-1][to[i-1][j]];
    }
  }
  for (int i=0;i<q;i++) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    int high = n-1;
    int low = 1;
    if (a > b) swap(a,b);
    int las = high;
    while (low <= high) {
      int now = (low+high)/2;
      int na = a;
      int left = now;
      int times = 0;
      while (left > 0) {
        if (left%2 == 1) {
          na = to[times][na];
        }
        left /= 2;
        times++;
      }
      if (na >= b) {
        las = now;
        high = now-1;
      }
      else {
        low = now+1;
      }
    }
    cout << las << endl;
  }
}


Measured memory_bytes: 10572
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[]={100,101,102,103,104,105};
bool f[N];
int main() {
	int x;
	scanf("%d",&x);
	f[0]=true;
	for(int i=0;i<6;i++) {
		for(int j=a[i];j<=x;j++) {
			f[j]|=f[j-a[i]];
		}
	}
	printf("%d\n",f[x]);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
    ll n;
    cin >> n;
    ll sum = 0;
    for(int i=1;i<=n;i++) {
        if(i%3!=0 && i%5!=0) {
            sum+=i;
        }
    }
    cout << sum <<endl;
}

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

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

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

	int p, q;

	int count = 0;

	for (int i = 0; i < n; i++){
		cin >> p >> q;

		count += q - p + 1;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <cstring>

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

using namespace std;
typedef long long ll;

int main(){
    int N;
    cin>>N;
    int ans=0;
    
    ll H[N];
    for(int i=0;i!=N;++i){
        cin>>H[i];
    }
    
    int count=0;
    for(int i=1;i!=N;++i){
        if(H[i]>H[i-1]){
            count=0;
        }else{
            ++count;
            ans=max(ans,count);
        }
    }
        
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 4424
#include <stdio.h>

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

int main(void){
	int i = 5, s = 0, t;
	while (i--) scanf("%d", &t), s += max(t, 40);
	printf("%d\n", s / 5);
	return 0;
}

Measured memory_bytes: 600
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> M;
	vector<vector<int>>edge(N * 3);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L * 3].push_back(R * 3 + 1);
		edge[L * 3 + 1].push_back(R * 3 + 2);
		edge[L * 3 + 2].push_back(R * 3);
	}
	vector<int>depth(N * 3, MOD);
	cin >> L >> R;
	L--;
	R--;
	Calculate_Depth(edge, depth, L * 3);
	long long int ans = depth[R * 3];
	if (ans == MOD)ans = -1;
	else ans /= 3;
	cout << ans << endl;
}

Measured memory_bytes: 17792
s = str(input())
t = str(input())

mi = 100000
l_s = len(s)
l_t = len(t)

for i in range(l_s-l_t+1):
    sub = s[i:i+l_t]
    d = 0
    for j in range(l_t):
        if sub[j] is not t[j]:
            d += 1
    if d < mi:
        mi = d

print(mi)

Measured memory_bytes: 9144
#include<iostream>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
int he[N],ver[N*2],nex[N*2],tot;
void add(int,int);
int dp[N][2];
void dfs(int,int);
int main(){
    int n;scanf("%d",&n);
    int u,v;tot=1;
    for(int i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
    dfs(1,0);
    printf("%d\n",(dp[1][0]+dp[1][1])%mod);
}
void dfs(int u,int fa){
    dp[u][0]=dp[u][1]=1;
    for(int i=he[u];i;i=nex[i]){
        int v=ver[i];
        if(v==fa) continue;
        dfs(v,u);
        dp[u][0]=1LL*dp[u][0]*(dp[v][0]+dp[v][1])%mod;
        dp[u][1]=1LL*dp[u][1]*dp[v][0]%mod;
    }
}
void add(int u,int v){
    ver[tot]=v;nex[tot]=he[u];he[u]=tot++;
}


Measured memory_bytes: 8576
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
using namespace std;
const double PI = 3.1415926535897932;
int main() {
  int r = 0;
  cin >> r;
  double res = PI * 2 * r;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n;i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];
    int ans = b[0];
    b.push_back(100005);
    rep(i, n-1) ans += min(b[i],b[i+1]);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t cnt;
std::vector<int64_t> G;

void insertionSort(int64_t A[], int64_t n, int64_t g) {
	for (int64_t i = g; i < n; i++) {
		int64_t v = A[i];
		int64_t j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int64_t A[], int64_t n) {
	for (int64_t h = 1; ;) {
		if (h > n) break;
		G.push_back(h);
		h = 3 * h + 1;
	}

	for (int64_t i = G.size() - 1; i >= 0; i--) {
		insertionSort(A, n, G[i]);
	}
}

void solve()
{
	int64_t n;
	std::cin >> n;
	int64_t A[1000000];
	for (int64_t i = 0; i < n; i++) {
		std::cin >> A[i];
	}

	cnt = 0;
	
	shellSort(A, n);

	std::cout << G.size() << std::endl;

	for (int64_t i = G.size() - 1; i >= 0; i--) {
		std::cout << G[i];
		if (i > 0) {
			std::cout << " ";
		}
	}
	std::cout << std::endl;

	std::cout << cnt << std::endl;

	for (int64_t i = 0; i < n; i++) {
		std::cout << A[i] << std::endl;
	}

	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}



Measured memory_bytes: 10988
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		int num = sc.nextInt(); 
      	int stack_item = num/100;
      	int diff = num - stack_item * 100;
      	boolean pos = false;
      
      	if(diff <= stack_item*5) pos = true;
      	
      	if(pos) System.out.println("1");
      	else System.out.println("0");
        
	}
}


Measured memory_bytes: 35536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		int mod = (int) 1E9 + 7;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();

		// i文字目までを13で割った余りがｊであるものの個数を格納する
		long dp[][] = new long[s.length][13];

		// 初期値
		if ( s[0] == '?' ) {
			for ( int n = 0; n < 10; n++ ) {
				dp[0][n] = 1;
			}
		} else {
			dp[0][s[0] - '0'] = 1;
		}

		// 1文字づつ見る
		for ( int i = 1; i < s.length; i++ ) {
			// 前回の余りrごとに見る
			for ( int r = 0; r < 13; r++ ) {
				
				if ( s[i] == '?' ) {
					for ( int now = 0; now < 10; now++ ) {
						dp[i][(r * 10 + now) % 13] += dp[i - 1][r];
					}

				} else {
					int now = s[i] - '0';
					dp[i][(r * 10 + now) % 13] += dp[i - 1][r];
				}
			}
			// %mod
			for ( int t = 0; t < 13; t++ ) {
				dp[i][t] %= mod;
			}
		}
		System.out.println(dp[s.length - 1][5]);
		br.close();
	}
}

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

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

  int x, y, z;
  x = a + b;
  y = a - b;
  z = a * b;
  int max = x;
  if (max < y) max = y;
  if (max < z) max = z;

  cout << max << endl;
}

Measured memory_bytes: 256
while (num = gets.to_i) != 0
  alice = 0
  karen = 0

  num.times do
    a, b = gets.split.map(&:to_i)
    if a > b
      alice += (a + b)
    elsif a < b
      karen += (a + b)
    else
      alice += a
      karen += b
    end
  end

  puts "#{alice} #{karen}"
end

Measured memory_bytes: 8824
#include<stdio.h>
                int main(void){
                int a,b,c;
                  scanf("%d%d%d",&a,&b,&c);
                  if((a==b&&b!=c)||(b==c&&a!=b)||(c==a&&b!=c)){
                    printf("Yes");
                  }
                  else{
                    printf("No");
                  }
                    return 0;
                  }

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

int N;
int s, partner[100];
int edge[10000][2];

int main(void) {
	scanf("%d", &N);
	if (N % 2 == 0) {
		s = N + 1;
	}
	else {
		s = N;
	}

	for (int i = 0; i<N; i++) {
		partner[i] = s - i - 2;
	}
	/*partner以外全員と繋ぐ*/
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			if (partner[i] == j) {
				continue;
			}
			edge[ans][0] = i + 1;
			edge[ans][1] = j + 1;
			ans += 1;
		}
	}
	printf("%d\n", ans);
	for (int i = 0; i < ans; i++) {
		printf("%d %d\n", edge[i][0], edge[i][1]);
	}
	
}

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

public class Main {

    public static void main(String[] args) {
        int n;
        int[] arr_a;

        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.nextLine());
        arr_a = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int i = 0;
        for (int a : arr_a) {
            arr_a[i] = a - (i + 1);
            i++;
        }

        Arrays.sort(arr_a);
        long med;
        if (arr_a.length % 2 == 0) {
            int medIndex = arr_a.length / 2;
            med = (arr_a[medIndex - 1] + arr_a[medIndex]) / 2;
        } else {
            med = arr_a[arr_a.length / 2];
        }

        long sum = 0;
        for (int a : arr_a) {
            sum += Math.abs(a - med);
        }

        System.out.println(sum);
    }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int i = 0;
  int x = 1;
  
  while (i < N) {
    if (x*2 <= x+K) {
      x *= 2;
    }
    else {
      x += K;
    }
    i++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
int main(void){
    int n; cin>>n;
    vector <int> a(n);
    ll araisan = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        araisan+= a[i];
    }
    ll ans  = INF;
    ll snuke = 0;
    for(int i=0;i<n;i++){
        snuke+=a[i]; araisan -= a[i];
        if(i!= n-1&& ans != araisan)
        ans = min(ans,abs(araisan - snuke));
    }
    
    cout<<ans<<endl;
}


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

using namespace std;

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

signed main(void) {
    int i,j;
    int n,k;

    cin >> n >> k;
    vi a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    int ans = 0;
    rep(i,31){
        //cout << "! " << i << endl;
        //kのiビット目を0にする, iビット目以下はkを超えない範囲でできるだけ1を立てる
        int bit = 0;
        for(j = 30; j > i; j--)
            if(k & (1 << j))
                bit += 1 << j;

        for(j = i - 1; j >= 0; j--)
            if((bit + (1 << j)) <= k)
                bit += 1 << j;

        if(bit > k)continue;

        int tmp = 0;
        rep(j,n){
            if(bit == (bit | a[j])){
                tmp += b[j];
                //cout << j << endl;
            }
        }
//        cout << "? " << bit << " " << tmp << endl;
        ans = max(ans, tmp);
    }

    cout << ans << endl;

}


Measured memory_bytes: 1792
import heapq as hq
N,M = map(int,input().split())
A = None
if N > 1:
	A = list(map(int,input().split()))
else:
	A = [int(input())]
A = [a*-1 for a in A]
hq.heapify(A)
for i in range(M):
	a = hq.heappop(A) * -1
	hq.heappush(A, (a//2) * -1)
print(-sum(A))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int X;cin>>X;
    if(X>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

const int N = 3005, P = 1e9 + 7;
char s[N];
int n, m, d[N], f[N][N], num[N];

int main () {
	scanf("%d%d", &n, &m);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++i) d[i] = i, num[i] = num[i - 1] + (s[i] == '1');
	for (int i = 1, l, r; i <= m; ++i) {
		scanf("%d%d", &l, &r);
		if (r > d[l]) d[l] = r;
	}
	f[0][0] = 1;
	for (int i = 0, r = 0; i < n; ++i) {
		if (d[i + 1] > r) r = d[i + 1];
		for (int j = 0; j <= num[r]; ++j) {
			if (f[i][j] >= P) f[i][j] -= P;
			if (!f[i][j]) continue ;
			if (num[r] - j < r - i) f[i + 1][j] += f[i][j];
			if (num[r] - j > 0) f[i + 1][j + 1] += f[i][j];
		}
	}
	printf("%d\n", f[n][num[n]] % P);
	return 0;
}

Measured memory_bytes: 33920
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	as := getIntSlice(n)

	ans := 0
	sum, xor := 0, 0
	r := 0
	for l := 0; l < n; l++ {
		r = max(r, l)
		for r < n {
			if (sum + as[r]) != (xor ^ as[r]) {
				break
			}
			sum += as[r]
			xor ^= as[r]
			r++
		}
		ans += r - l

		sum -= as[l]
		xor ^= as[l]
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<typename T>
struct edge {
    int from, to;
    T cost;
};

template<typename T>
T prim(vector<vector<edge<T>>> &edges, int V) {
    using Pi = pair<T, int>;

    T res = 0;
    vector<bool> used(V, false);
    priority_queue<Pi, vector<Pi>, greater<>> priorityQueue;
    priorityQueue.emplace(0, 0);
    while (!priorityQueue.empty()) {
        Pi p = priorityQueue.top();
        priorityQueue.pop();
        if (used[p.second]) continue;
        used[p.second] = true;
        res += p.first;
        for (edge<T> &e : edges[p.second]) {
            if (!used[e.to]) priorityQueue.push({e.cost, e.to});
        }
    }
    return res;
}

struct town {
    int x, y, idx;
};

/**
 * D - Built?
 * https://atcoder.jp/contests/abc065/submissions/7857625
 * プリム法で解いた。
 */
void Main() {
    int N;
    cin >> N;
    vector<town> towns;
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        towns.push_back({x, y, (int) i});
    }
    vector<town> towns2 = towns;
    sort(towns.begin(), towns.end(), [](const town &a, const town &b) {
        return a.x < b.x;
    });
    sort(towns2.begin(), towns2.end(), [](const town &a, const town &b) {
        return a.y < b.y;
    });
    vector<vector<edge<ll>>> edges(N);
    rep2(i, 1, N) {
        town ox = towns[i - 1];
        town nx = towns[i];
        edges[ox.idx].push_back({ox.idx, nx.idx, (ll) abs(ox.x - nx.x)});
        edges[nx.idx].push_back({nx.idx, ox.idx, (ll) abs(ox.x - nx.x)});
        town oy = towns2[i - 1];
        town ny = towns2[i];
        edges[oy.idx].push_back({oy.idx, ny.idx, (ll) abs(ny.y - oy.y)});
        edges[ny.idx].push_back({ny.idx, oy.idx, (ll) abs(ny.y - oy.y)});
    }
    cout << prim(edges, N) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

ll w[100005];
ll v[100005];
ll dp[105][100005];

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

    ll K,N;
    cin >> N >> K;

    REP(i,N)cin >> w[i] >> v[i];

    REP(i,N){
        REP(j,K+1){
            if(j - w[i] < 0){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }

    cout << dp[N][K] << endl;

    return 0;
}    

Measured memory_bytes: 79360
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
signed main(){
  string a;
  cin>>a;
  if(a.size()==2)
    cout<<a<<endl;
  else
    cout<<a[2]<<a[1]<<a[0]<<endl;
}


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

int main(){
 int n,ans=0;
 cin>>n;
 vector<int> l(n*2);

 for(int i=0;i<2*n;i++){
     cin>>l.at(i);
 }

 sort(l.begin(),l.end());

 for(int i=0;i<2*n;i++){
     if(i%2==0){
        ans+=l.at(i);
     }
 }

 cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
using P = pair<ll , ll>;
//using map = map<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    rep(i, s.size()){
        if(s.at(i) != t.at(i)) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3916
#include <stdio.h>
 
int main(void)
{
    int A[99][99] = { 0 }, i, j, N, t;
    char s, F[5] = "SHCD";
 
    scanf("%d\n", &N);
 
    for (i = 0; i < N; A[s][t] = 1, i++)
        scanf("%c %d\n", &s, &t);
 
    for (i = 0; i < 4; i++)
        for (j = 1; j < 14; j++)
            if (!A[F[i]][j])
                printf("%c %d\n", F[i], j);
 
    return 0;
}

Measured memory_bytes: 648
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

double dp[3010][3010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    double p[3010];
    rep(i, N) cin >> p[i];
    dp[0][0] = 1.0;
    rep(i, N) {
        rep(j, N + 1) {
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
            if (j != 0)
                dp[i + 1][j] += dp[i][j - 1] * p[i];
        }
    }
    double ans = 0;
    REP(i, (N + 1) / 2, N) ans += dp[N][i];
    printf("%.12f", ans);

    return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int n, l, i;
    scanf("%d %d", &n, &l);
    int min = l;
    for(i = 1; i <= n; ++i){
        if(abs(min) > abs(l+i-1)){
            min = l+i-1;
            if(min == 0){break;}
        }
    }
    int ans = (l-1)*n + n*(n+1)/2 - min;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
N =int(input())

count = [0,0,0,0]

for i in range(N):
  S = input()
  if S == 'AC':
    count[0]+=1
  elif S == 'WA':
    count[1]+=1
  elif S == 'TLE':
    count[2]+=1
  elif S == 'RE':
    count[3]+=1

print('AC x '+str(count[0]))
print('WA x '+str(count[1]))
print('TLE x '+str(count[2]))
print('RE x '+str(count[3]))

Measured memory_bytes: 69932
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.length();
    string ans="Yes";
    rep(i,s.length()){
        if(s[i]!=s[s.length()-i-1]){
            ans="No";
        }
    }
    string s1=s.substr(0,(n-1)/2);
    string s2=s.substr((n+3)/2-1,n-1);
    rep(i,s1.length()){
        if(s1[i]!=s1[s1.length()-i-1]){
            ans="No";
        }
    }
    rep(i,s2.length()){
        if(s2[i]!=s2[s2.length()-i-1]){
            ans="No";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)


int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];
    ll a, b;
    vector<vector<ll>> v(N);
    REP(i, M){
        cin >> a >> b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    vector<bool> t(N, true);
    ll ans = 0;
    REP(i, N){
        if (!t[i]) continue;
        ll st = H[i];
        for(auto iter: v[i]) if (st <= H[iter]) t[i] = false;
    }
    REP(i, N) if(t[i]) ans++;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int ans = 0;
	for (int l = 0, r = 0; l < n;) {
		while (r + 1 < n and a[r] >= a[r + 1]) {
			++r;
		}
		ans = max(ans, r - l);
		l = ++r;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=1000000;
const ll inf=1e9;
const ll mod=1e9+7;

ll dp[10][10];

string S(int x)
{
    string s="";
    while(x)
    {
        s+=(x%10+'0');
        x/=10;
    }
    reverse(s.begin(), s.end());
    return s;
}
int main()
{
    FasterIO;
    ll n, rs=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        string s=S(i);
        dp[s[0]-'0'][s.back()-'0']++;
    }
    for(int i=1; i<=9; i++)
    {
        for(int j=1; j<=9; j++)
        {
            rs+=(dp[i][j]*dp[j][i]);
        }
    }
    cout<<rs<<endl;
    return 0;
}


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

int main() {
	string s,t;
	int cnt;
	cin>>s>>t;
	if(s[0]==t[0]){
		cnt+=1;
	}
	if(s[1]==t[1]){
		cnt+=1;
	}
	if(s[2]==t[2]){
		cnt+=1;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
s=input()
slash=[]
area=0

slash_2=[]
area_2=[]

for i in range(len(s)):
    if s[i]=="\\":
        slash.append(i)
    elif s[i]=="/":
        try: 
            j=slash.pop()
            area=area+i-j
            a=i-j
            while len(area_2) > 0 and slash_2[len(slash_2)-1] >j:
                a=a+area_2[len(slash_2)-1]
                area_2.pop()
                slash_2.pop() 
            slash_2.append(j)     
            area_2.append(a)
        except: pass


if area==0:
    print(0)
    print(0)
else:
    print(area)
    print(str(len(area_2))+" "+" ".join(map(str, area_2)))


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

int main() {
  int A, B, C, D;	cin >> A >> B >> C >> D;
  
  if((A+B) > (C+D))	cout << "Left" << endl;
  else if((A+B) < (C+D))	cout << "Right" << endl;
  else if((A+B) == (C+D))	cout << "Balanced" << endl;
}

Measured memory_bytes: 256
//define debug for debugging
//#define DEBUG
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define MAX 100000 + 100
#define max3(a,b,c) max(a,max(b,c))
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void swap(int *a,int *b){
	int temp = *a;
	*a = *b;
	*b = temp;
}


int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef DEBUG
    freopen("i.txt","r",stdin);
    freopen("o.txt","w",stdout);
#endif              
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22)
    	cout << "bust";
    else
    	cout << "win";
	return 0;
}


Measured memory_bytes: 256
n, t = map(int,input().split())
cc = []
tt = []
for i in range(n):
    a,b = map(int,input().split())
    cc.append(a)
    tt.append(b)

cnt = 0
d = []
for i in range(n):
    if tt[i] <= t:
        cnt += 1
        d.append(cc[i])

if cnt == 0:
    print('TLE')
else:
    print(min(d))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 1234567;
bool isp[MAXN];

int main() {
    LL A, B;
    scanf("%lld %lld", &A, &B);
    LL g = __gcd(A, B);
    vector<int> prime;
    int ans = 1;
    for (LL i = 2; i < MAXN; i++) {
        if (!isp[i]) {
           prime.push_back(i);
           for (LL j = i * i; j < MAXN; j += i) {
               isp[j] = 1;
           }
        }
    }
    for (int i = 0; i < (int)prime.size(); i++) {
        if ((g % prime[i]) == 0) {
           ans++;
           while ((g % prime[i]) == 0) {
                 g /= prime[i];
           }
        }
    }
    if (g != 1) ans++;
    printf("%d\n", ans);
    return 0;
}


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

typedef struct node{
  struct node *p,*r,*l;
  int key;
}Node;

Node *insert(Node *p,int key){
  Node *x,*y,*n;
  x=p;
  y=NULL;
  while(x!=NULL){
    y=x;
    if(x->key<=key)x=x->r;
    else x=x->l;
  }
  
  n=new Node;
  n->p=y;
  n->r=NULL;
  n->l=NULL;
  n->key=key;

  if (p==NULL)return n;
  if (y->key<=key) y->r=n;
  else y->l=n;
  return p;
}

void printA(Node *p){
  if (p==NULL) return;
  printA(p->l);
  cout << " " << p->key;
  printA(p->r);
}

void printB(Node *p){
  if (p==NULL) return;
  cout << " " << p->key;
  printB(p->l);
  printB(p->r);
}

void print(Node *p){
  printA(p);
  cout << endl;
  printB(p);
  cout << endl;
}

void find(Node *p,int key){
  Node *x=p;
  while(x!=NULL){
    if (x->key<key) x=x->r;
    else if (x->key>key) x=x->l;
    else {
      cout << "yes" << endl;
      return;
    }
  }
  cout << "no"<<endl;
}
Node *delnode(Node *p,int key){
  Node *x=p;
  Node *dn,*nn,*t,*root=p;
  while(x!=NULL){
    if (x->key<key) x=x->r;
    else if (x->key>key) x=x->l;
    else {
      break;
    }
  }
  if (x==NULL)return root;
  if (x->l==NULL||x->r==NULL)dn=x;
  else {
    if (x->r==NULL){
      t=x->p;
      while (t!=NULL&&t->r==NULL){
	dn=t;
	t=t->p;
      }
    }else{
      dn=x->r;
      while (dn->l!=NULL){
	dn=dn->l;
      }
    }
  }
  if (dn->l==NULL) nn=dn->r;
  else nn=dn->l;
  
  if (nn!=NULL)nn->p=dn->p;
  
  if (dn->p==NULL)root=nn;
  else if (dn->p->l==dn)dn->p->l=nn;
  else dn->p->r=nn;
  
  if (dn!=x)x->key=dn->key;
  delete dn;
  return root;
}

int main(){
  int n,k;
  Node *root=NULL;
  char cmd[16];

  cin >> n;
  for (int i=0;i<n;i++){
    cin >> cmd;
    if (cmd[0]=='i'){
      cin >> k;
      root=insert(root,k);
    }else if (cmd[0]=='p'){
      print(root);
    }else if (cmd[0]=='f'){
      cin >> k;
      find(root,k);
    }else if (cmd[0]=='d'){
      cin >> k;
      root=delnode(root,k);
    }
  }
  
  return 0;
}

Measured memory_bytes: 21820
/*
[abc121] C - Energy Drink Collector
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N, M;
pii AB[MAX_N];

ll solve() {
    sort(AB, AB + N);

    ll ans = 0;
    for (int i = 0, m = M; i < N && m > 0; i++) {
        int d = min(m, AB[i].second);
        m -= d;
        ans += 1LL * d * AB[i].first;
    }

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> AB[i].first >> AB[i].second;
    }

    cout << solve() << endl;

    return 0;
}


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

void solve(long long N, std::vector<std::vector<long long>> A)
{
    long long S = 0;
    long long maxa = 0;
    long long up = 0;

    for (int i = 0; i < N; i++)
    {
        up += A[0][i];
        maxa = up;
    }

    for (int i = 0; i < N - 1; i++)
    {
        S += A[0][i];
        long long down = 0;
        down += S; //こいつの位置がおかしかった。
        for (int j = i; j < N - 1; j++)
        {
            down += A[1][j];
        }
        maxa = max(maxa, down);
    }
    maxa += A[1][N - 1];
    cout << maxa << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<std::vector<long long>> A(2, std::vector<long long>(N));
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < N; j++)
        {
            scanf("%lld", &A[i][j]);
        }
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    stack<int> S1;
    stack< pair<int, int> > S2;
    char ch;
    int sum = 0;

    for (int i = 0; cin >> ch; i++) {
        if (ch == '\\') {
            S1.push(i);
        } else if (ch == '/' && S1.size() > 0) {
            int j = S1.top();
            S1.pop();

            sum += i - j;
            int a = i - j;

            while (S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second;
                S2.pop();
            }

            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while (S2.size() > 0) {
        ans.push_back(S2.top().second);
        S2.pop();
    }

    reverse(ans.begin(), ans.end());

    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = double.Parse(Console.ReadLine());

            for (var i = 1; i <= n; i++)
            {
                if (Math.Floor(i * 1.08) == n)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(":(");
        }
    }
}


Measured memory_bytes: 13140
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e18+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	//bitsetで行くか?
	int n,i,all=0;cin>>n;
	bitset<2005000> bi;bi[0]=true;
	for(i=0;i<n;i++){
		int a;cin>>a;all+=a;
		bi|=(bi<<a);
	}
	for(int i=(all+1)/2;i<=all;i++){
		if(bi[i]){cout<<i<<endl;RE;}
	}RE;
}

Measured memory_bytes: 1024