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

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

const long long INF = 1LL << 60;

int main ()
{
    int n,m;  cin >> n >>  m;
    int wa[105000];
    bool ac[105000];

    int wanum=0;
    int acnum=0;

    for(int i=0;i<n;i++){
        wa[i]=0;
        ac[i]=false;
    }

    while(m--){
        int p;
        string s;
        cin >> p >> s;
        if(ac[p])   continue;

        if(s=="AC") {
            acnum++;
            ac[p]=true;
            wanum+=wa[p];
        }

        else if (s=="WA"){
            wa[p]++;
        }
    }

    cout << acnum << " " << wanum << endl; 
    
}

     



Measured memory_bytes: 768
#include<iostream>
using namespace std;
typedef long long ll;
ll A[100005];
ll sum[100005];
bool vis[100005];

int main()
{
	long long N;
	cin >> N;
	ll X,M;
	cin >> X >> M;
	if(N == 1 || M == 1)
	{
		cout << X << endl;
		return 0;
	}
	A[1] = X;
	sum[1] = X;
	vis[A[1]] = true;
	ll ans = 0;
	for(int i = 2; i <= N; i++)
	{
		A[i] = A[i-1] * A[i-1] %M;
		sum[i] = A[i] + sum[i-1];
		if(i == N)
		{
			cout << sum[i] << endl;
			return 0;
		}
		if(A[i] == 0)
		{
			if(X>i)
			cout << sum[i] << endl;
			else cout << sum[X] << endl;
			return 0;
		}
		if(vis[A[i]] == true)
		{
			int j = 1; 
			for(;A[j] != A[i];j++);
			ans = ans + sum[i-1];
			long long n = N-i+1;
			ans = ans + n/(i-j) * (sum[i-1]-sum[j-1]);
			ans = ans + sum[j-1+(n%(i-j))] - sum[j-1];
			cout << ans << endl;
			return 0;
			
		}
		vis[A[i]] = true;
	}
}

Measured memory_bytes: 3928
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))

max_a = max(a)
c = {a_tmp: 0 for a_tmp in a}
for a_tmp in a:
    c[a_tmp] += 1

d = {a_tmp: 0 for a_tmp in a}
for a_tmp in a:
    if c[a_tmp] > 0:
        t = 2
        while a_tmp*t <= max_a:
            d[a_tmp*t] = 1
            t += 1
ans = 0
for a_tmp in a:
    if c[a_tmp] == 1 and d[a_tmp] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 104032
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-9;

// 内積 |a||b|cosθ
double dot(Point a, Point b){
	// return a.real() * b.real() + a.imag() * b.imag();
	return (conj(a) * b).real();
}
// 外積、符号付面積の２倍　|a||b|sinθ
double cross(Point a, Point b){
	// return a.real() * b.imag() - a.imag() * b.real();
	return (conj(a) * b).imag();
}
// 点の位置関係　2点a,bから見た点cの位置関係
int ccw(Point a, Point b, Point c){
    if(cross(b - a, c - a) > EPS) return 1;
    if(cross(b - a, c - a) < -EPS) return -1;
    if(dot(b - a, c - a) < -EPS) return 2;
    if(abs(b - a) + EPS < abs(c - a)) return -2;
    return 0;
}

int main(){
    double x, y;
    Point p1, p2;
    cin >> x >> y;
    p1 = {x, y};
    cin >> x >> y;
    p2 = {x, y};
    Line l = {p1, p2};
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> x >> y;
        Point p3 = {x, y};
        int res = ccw(p1, p2, p3);
        if(res == 1){
            cout << "COUNTER_CLOCKWISE" << endl;
        }else if(res == -1){
            cout << "CLOCKWISE" << endl;
        }else if(res == 2){
            cout << "ONLINE_BACK" << endl;
        }else if(res == -2){
            cout << "ONLINE_FRONT" << endl;
        }else{
            cout << "ON_SEGMENT" << endl;
        }
    }
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
const int N = 2e5;
int ans[N+100];
set<pii>st;
map<int,vector<pii> >m;
int main()
{
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		int s,t,x;
		scanf("%d%d%d",&s,&t,&x);
		if(s==t)continue;
		m[x].push_back(mp(s,t-1));
	}
	for(int i=1;i<=q;i++){
		int d;
		scanf("%d",&d);
		st.insert(mp(d,i));
	}
	for(auto i:m)
	{
		for(auto j:m[i.first])
		{
			int l = j.first-i.first,r = j.second-i.first;
			auto it = st.lower_bound(mp(l,-1));
			while(it!=st.end()&&it->first<=r)
			{
				ans[it->second] = i.first;
				pii tmp = *it;
				it++;
				st.erase(tmp);
			}
		}
	}
	for(auto it:st)
	{
		ans[it.second] = -1;
	}
	for(int i=1;i<=q;i++){
		printf("%d\n",ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 33280
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
int cnt[100100];

int solve(){
    cin >> n;
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        cnt[x]++;
    }

    int ans = cnt[0] + cnt[1];

    for(int i = 1; i < 100000; ++i){
        ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
    }

    return ans;
}

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

    cout << solve() << "\n";
    
    return 0;
}


Measured memory_bytes: 640
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m,q;
    static int s[1 << 20];
    fi>>n>>m>>q;
    for (int i = 1;i <= q;++i)
        fi>>s[i];
    vector < int > S;
    static int was[1 << 20];
    for (int i = 1;i <= m;++i)
        was[i] = -1;
    for (int i = q;i;--i)
        if (was[s[i]] == -1)
            S.push_back(s[i]),was[s[i]] = 1;
    static int cnt[1 << 20];
    for (int i = 1;i <= m;++i)
        if (was[i] == -1)
            S.push_back(i);
    static int where[1 << 20];
    for (int i = 0;i < m;++i)
        where[S[i]] = i + 1;
    cnt[0] = n;
    for (int i = q;i;--i)
    {
        const int index = where[s[i]] - 1;
        if (cnt[index])
            --cnt[index],++cnt[index + 1];
    }
    int Last = 0;
    for (int i = m - 1;i;--i)
        if (S[i] < S[i - 1])
            {Last = i;break;}
    int ok = 1;
    for (int i = 0;i < Last;++i)
        ok &= !cnt[i];
    fo << (ok ? "Yes" : "No") << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

//a = 1, K = 8 とすると、a mod K ≡ 1;
//a + b mod K ≡ 0 を実現しようとすると、 b mod K ≡ 7 が必要。
//以下ではこの性質を利用して、aを固定してからb,cの条件を絞り、十分性を確かめている。

//つまり、固定されたaをKで割ったあまりでb,cの候補は分類できる　→　剰余類問題といえる。
//しかも、余り同士の計算は合同式を使って、法が等しい時は　和差積　で閉じているので、a,b,cはKで割ったあまりとして定義していい。
//num[]は[1,N]のKで割ったあまりの一致する個数をカウントしておいて、indexとしてa,b,cを利用できるようにしておく。これによってO(N)でいける。


int main(){
    int N,K;cin >> N >> K;
    vector<LL> num(K,0);
    rep(i,N)num[(i+1)%K]++;   //num[x] は　Kで割ってx余る数が[1,N]にいくつあるか
    LL res = 0;
    rep(a,K){
        int b = (K-a) % K;  //a mod K と K-a mod K　の和は K mod K になり、その値は0のはず。
        int c = (K-a) % K;  //a+b,a+cの合同式が一致するので、a+b mod K ,a+c mod K が一致。なので、b,cともに K-a mod K となる。というか,ともに0になるのでこうならざるを得ない。
        if( (b+c) % K != 0)continue;    //aの固定により、b,cの必要条件 K-a mod K が確定したので、十分条件 b+c mod K の確認をしている。
        res += num[a] * num[b] * num[c];    //a,b,cはもともと同じ数字を取りうるので、個数をそのまんま掛け合わせればいい。
    }
    cout << res << endl;   
}

//aが動いていて、それに対して一組の(b,c)が候補としてあがり、確定するので、すべてのaに対して、b,cが決まる。
//よってa,b,cは対称性があるので、

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
tenboudai = [True for i in range(n)]

h_list = input().split()
h_list = [int(h) for h in h_list]

path_list = []
for i in range(m):
    a, b = map(int, input().split())
    path_list.append([a-1, b-1])

for path in path_list:
    if h_list[path[0]] < h_list[path[1]]:
        tenboudai[path[0]] = False
    elif h_list[path[1]] < h_list[path[0]]:
        tenboudai[path[1]] = False
    else:
        tenboudai[path[0]] = False
        tenboudai[path[1]] = False

print(tenboudai.count(True))


Measured memory_bytes: 28960
#include <cstdio>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cmath>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const double EPS = 1e-10;
const double PI = acos(-1);

// does a volume of x cm^3 spill?
bool check(int a, int b, int x, double alpha, bool trace = false) {
// double h = b * tan(PI/2 - alpha);
   double h = b / tan(alpha);
   double max_volume_no_spilling;
   if (h <= a + EPS) {
      max_volume_no_spilling = ((h * b) / 2) * a;
      if (trace)
         fprintf(stderr, "Case 1: max_volume_no_spilling: %.04f\n",
                 max_volume_no_spilling);
   }
   else {
      max_volume_no_spilling = a * a * b - ((a*tan(alpha) * a)/2) * a;
      if (trace)
         fprintf(stderr, "Case 2: max_volume_no_spilling: %.04f\n",
                 max_volume_no_spilling);
   }
   return max_volume_no_spilling < x - EPS;
}

double radian_to_degree(double rad) {
   return rad * 180 / PI;
}

double degree_to_radian(double deg) {
   return deg * PI / 180;
}

int main(int argc, char* argv[]) {
// check( 3, 1, 8, degree_to_radian(11.25), true );

   int a, b, x;
   scanf("%d %d %d", &a, &b, &x);

   double lo = 0.0, hi = PI / 2;
   FOR(t, 1, 80) {
      double mid = (lo + hi) / 2;
      bool will_spill = check(a, b, x, mid);
   // fprintf(stderr, "lo:%.05f  hi:%.05f  mid:%.05f  => %d\n",
   //         radian_to_degree(lo), radian_to_degree(hi),
   //         radian_to_degree(mid), will_spill);
      if (will_spill) {
         hi = mid;
      }
      else {
         lo = mid;
      }
   }

   double res = radian_to_degree((lo + hi) / 2);
   printf("%.10f\n", res);

   return 0;
}


Measured memory_bytes: 384
import math
def tax(p,x):
    return p*(100+x) // 100 


def main(x,y,s):
    maxV=0
    for i in range(1,s):
        for j in range(1,s):
            if tax(i,x)+tax(j,x)==s:
                maxV=max(maxV,tax(i,y)+tax(j,y))
            elif tax(i,x)+tax(j,x)> s:
                break
    return maxV

while True:
    x,y,s = map(int,input().split())
    if x==0:
        break
    print(main(x,y,s))



Measured memory_bytes: 5656
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, D, Q;
    cin >> N >> D;
    vll d(N);
    rep(i, N)cin >> d[i];
    vll A(N + 1), B(N + 1);
    A[0] = D;
    FOR(i, 1, N + 1) {
        A[i] = min(A[i - 1], abs(A[i - 1] - d[i - 1]));
    }
    B[N] = 1;
    for (int i = N - 1; i >= 0; --i) {
        if (2 * B[i + 1] <= d[i])B[i] = B[i + 1];
        else B[i] = B[i + 1] + d[i];
    }
    cin >> Q;
    while (Q--) {
        int q;
        cin >> q;
        cout << (A[q - 1] >= B[q] ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 14976
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int H, W;
int N;
vector<int> a;
int m[100][100];

void init()
{
}

void solve()
{
    int c = 0;
    int j = 0;
    int d;
    REP(i, H){
        if(i % 2 == 0) d = 1;
        else d = -1;
        REP(k, W){
RETRY:
            if(a[c] > 0){
                m[i][j] = c+1;
                a[c]--;
            }else{
                c++;
                if(c < N) goto RETRY;
            }
            if(k != W-1) j += d;
        }
    }
    
    REP(i, H){
        REP(j, W){
            cout << m[i][j];
            if(j != W-1) cout << " ";
            else cout << endl;
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> N;
    a.resize(N);
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

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

  int ss = s.size();
  int st = t.size();

  vector<vector<int>> dp(ss + 1, vector<int>(st + 1));
  for (int i = 0; i < ss; ++i) {
    for (int j = 0; j < st; ++j) {
      if (s[i] == t[j])
        dp[i + 1][j + 1] = dp[i][j] + 1;
      else
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
    }
  }

  string ans = "";
  int i = ss, j = st;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i][j - 1]) {
      --j;
    } else if (dp[i][j] == dp[i - 1][j]) {
      --i;
    } else {
      ans.push_back(s[i - 1]);
      --i;
      --j;
    }
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 35584
H,W = map(int,input().split())
s = [["#"]*(W+2)] + [["#"] + [c for c in input()] + ["#"] for _ in [0]*H] + [["#"]*(W+2)]
ans = sum([sum([int(c == ".") for c in row]) for row in s])
s[1][1] = 1
ij = [[1,1]]
d = [[0,1],[0,-1],[1,0],[-1,0]]
cnt = 0
while ij[cnt:]:
    i,j = ij[cnt]
    for di,dj in d:
        if s[i+di][j+dj] == ".":
            s[i+di][j+dj] = s[i][j] + 1
            ij.append([i+di,j+dj])
            if i+di == H and j+dj == W:
                break
    cnt += 1
if s[H][W] == ".":
    ans = -1
else:
    ans -= s[H][W]
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int n;
  string s;
  while(1){
    cin >> n;
    if(!n) break;
    cin >> s;
    int k=0;
    vector<int> p(n, 0);
    for(int i=0, j=0; i<s.size(); ++i){
      if(s[i] == 'M'){ ++p[j]; } 
      if(s[i] == 'S'){ k+=p[j]+1; p[j]=0; }
      if(s[i] == 'L'){ p[j]+=k+1; k=0; }
      ++j;
      if(j == p.size()) j=0;
    }
    sort(p.begin(), p.end());
    for(int i=0; i<p.size(); ++i) cout << p[i] << " ";
    cout << k << endl;
  }
  return 0;
}

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

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

int main(){
	int N;
	cin >> N;
	
	vector<bool> prime(55555+1,true);
	prime.at(0)=false;
	prime.at(1)=false;
	for(int i=2;i*i<=55555;i++){
		if(prime.at(i)==false)	continue;
		for(int j=2;i*j<=55555;j++){
			prime.at(i*j)=false;
		}
	}
	
	for(int i=1;i*5+2<=55555;i++){
		int xx=i*5+2;
		if(prime.at(xx)){
			if(N>=2){
				cout << xx << " ";
				N--;
			}
			else{
				cout << xx << endl;
				break;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

ifstream fin("../data.txt");

string s;
int n;
vector<char> ans;

int main() {

  getline(cin, s);
  n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') {
      if (!ans.empty()) ans.pop_back();
    } else {
      ans.push_back(s[i]);
    }
  }
  n = ans.size();
  for (int i = 0; i < n; i++) {
    cout << ans[i];
  }

  return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    val n = sc.nextInt()
    val tuples: List[(Double, Double)] = List.fill(n)((sc.nextInt(), sc.nextInt()))
    var sum: Double = 0
    for (i <- 0 until n) {
      for (j <- i + 1 until n) {
        sum += math.sqrt((tuples(i)._1 - tuples(j)._1) * (tuples(i)._1 - tuples(j)._1)
                      + (tuples(i)._2 - tuples(j)._2) * (tuples(i)._2 - tuples(j)._2))
      }
    }
    pw.println(sum * 2 / n)


    pw.flush()
  }
}

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

typedef long long ll;
const int MAX = 3001;

ll p;

void mult(int &a, int b) {
	ll mul = (a * 1ll) * (b * 1ll);
	if (mul >= p) mul %= p;
	a = (int)mul;
}

int fexp(int base, int exp) {
    int result = 1;
    while (exp > 0) {
        if (exp % 2 == 1) mult(result, base);
        exp >>= 1;
        mult(base, base);
    }
    return result;
}

int a[MAX], b[MAX], ncr[MAX][MAX];

void ncrtable() {
	for (int i = 0; i < MAX; i++) {
		ncr[i][0] = ncr[i][i] = 1;
		ncr[i][1] = i;
	}

	for (int n = 2; n < MAX; n++) {
		for (int r = 2; r < MAX; r++) {
			ncr[n][r] = ncr[n - 1][r] + ncr[n - 1][r - 1];
			if (ncr[n][r] >= p) ncr[n][r] -= p;
		}
	}
}

int main() {
    scanf("%lld", &p);
    for (int i = 0; i < p; i++) scanf("%d", &a[i]);

    vector<int> s;
    for (int i = 0; i < p; i++) {
    	if (a[i]) s.push_back(i);
    }

    ncrtable();

    if (a[0]) b[0] = 1;

    for (int r = 1; r < p; r++) {
    	for (int j : s) {
    		int x = ncr[p - 1][r];
    		mult(x, fexp(j, p - 1 - r));

    		if ((p - r) & 1) b[r] += (p - x);
    		else b[r] += x;

    		if (b[r] >= p) b[r] -= p;
    	}
    }

    for (int i = 0; i < p; i++) printf("%d ", b[i]);

	return 0;
}

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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;


const int maxn = 20;
int x, y, z;
int dp[2][1<<maxn] = {0};
int f = 0;
const int mod = 1e9+7;
inline void add(int &a, int b)
{
  a += b;
  if (a >= mod)
    a %= mod;
}
int n;
int mask;
bool work[1<<maxn] = {0};
int main()
{
  scanf("%d", &n);
  scanf("%d %d %d", &x, &y, &z);
  int bit = ((((1<<x)+1)<<y)+1)<<(z-1);
  mask = (1<<(x+y+z))-1;
  for (int i = 0; i <= mask; ++i)
    {
      work[i] = true;//找出尾数是几时，不成立的情况
      int tmp = i;
      while (tmp)
    {
      if ((tmp&bit)==bit)
        {
          work[i] = false;
          break;
        }
      tmp >>= 1;
    }
    }
  f = 0;
  dp[f][0] = 1;
  for (int i = 0; i < n; ++i)
    {
      f ^= 1;//压缩数组
      memset(dp[f], 0, (mask+1)*sizeof(int));
      for (int j = 0; j <= mask; ++j)
    if (work[j])
      for (int d = 1; d <= 10; ++d)
        {
          int nxt = ((j<<1)|1)<<(d-1);//这是表示我的末尾数字是多少的时候，加和之后的尾数情况
          nxt &= mask;//然后判断末尾的几个数字有没有包括x,y,z，因为前面的肯定是不会包括的，他都是按照不成立时才向前推进
          if (work[nxt])//此时成立说明在位数为当前的时候，尾数是多少是肯定不符合条件的，然后才能加上比他少一位时不成立的个数
        add(dp[f][nxt], dp[f^1][j]);
        }
    }
  int ans = 0;
  for (int i = 0; i <= mask; ++i)
    add(ans, dp[f][i]);
  ll tot = 1;
  for (int i = 0; i < n; ++i)
    tot = tot * 10 % mod;
  tot -= ans;
  tot %= mod;
  if (tot < 0)
    tot += mod;
  ans = tot;
  printf("%d\n", ans);
}


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

using namespace std;

int N,W;
int w[102];
int v[102];
long long dp[102][100002];

long long solve(int i , int weight)
{
    if(i==N)
        return 0;

    long long &res = dp[i][weight];
    if(~res)
        return res;
    res = solve(i+1 , weight);
    if(weight>=w[i])
        res = max(res , solve(i+1 , weight-w[i])+v[i]);

    return res;

}



int main()
{

    memset(dp , -1 , sizeof(dp));
    cin>>N>>W;
    for(int i=0; i<N; i++)
    {
        cin>>w[i]>>v[i];
    }

    cout<<solve(0 , W);

    return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a == b && b == c ? "Yes" : "No") << '\n';
	return 0;
}

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  int sum=0,count=1;
  for(int i=0;i<n;i++){
    cin >> l.at(i);
    sum += l.at(i);
    if(sum>x){
      break;
    }
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m, t, p;
    while (cin >> n >> m >> t >> p, n){
        vector<int> v(n, 1), u(m, 1);
        for (int i = 0; i < t; ++i) {
            int d, c;
            cin >> d >> c;
            if(d == 1){
                vector<int> vv(max((int)v.size()-c, c));
                for (int j = 0; j < vv.size(); ++j) {
                    if(j+c < v.size()) vv[j] = v[j+c];
                    if(c-1-j >= 0) vv[j] += v[c-1-j];
                }
                v.swap(vv);
            }else {
                vector<int> uu(max((int)u.size()-c, c));
                for (int j = 0; j < uu.size(); ++j) {
                    if(j+c < u.size()) uu[j] = u[j+c];
                    if(c-1-j >= 0) uu[j] += u[c-1-j];
                }
                u.swap(uu);
            }
        }
        for (int i = 0; i < p; ++i) {
            int x, y;
            cin >> x >> y;
            cout << u[y]*v[x] << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int i=a;i<b;i++)
#define repn(a,b,c) for(int i=a;i<=b;i++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k;
    int a,b;
    cin>>k>>a>>b;
    if(a%k==0 || b%k==0){
        cout<<"OK"<<endl;
    }
    else{
        if(a/k !=b/k){
            cout<<"OK"<<endl;
        }
        else{
            cout<<"NG"<<endl;
        }
    }
    


    return 0;
}



Measured memory_bytes: 3648
fun main(args: Array<String>) {
    abc143d()
}

fun abc143d() {
    val n = readLine()!!.toInt()
    val lines = readLine()!!.split(" ").map { it.toInt() }
        .sorted().toIntArray()

    var answer = 0
    for (ai in 0..lines.size - 2) {
        for (bi in ai + 1..lines.size - 1) {
            val right = lowerBound(lines, lines[ai] + lines[bi])
            val left = bi + 1
            answer += Math.max(0, right - left)
        }
    }

    println(answer)
}

// list must be sorted
// find element's index, greater than or equals key
private fun lowerBound(list: IntArray, key: Int): Int {
    var ng = -1
    var ok = list.size

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (list[mid] >= key) ok = mid else ng = mid
    }
    return ok
}


Measured memory_bytes: 37728
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    char[][] a = new char[N][N];
    for(int i = 0; i < N; i++){
      String T = sc.nextLine();
      for(int j = 0; j < N; j++){
        a[i][j] = T.charAt(j);
      }
    }
    
    char[][] b = new char[M][M];
    for(int i = 0; i < M; i++){
      String T = sc.nextLine();
      for(int j = 0; j < M; j++){
        b[i][j] = T.charAt(j);
      }
    }
    
    String ans = "No";
    g : for(int i = 0; i < N-M+1; i++){
      f : for(int j = 0; j < N-M+1; j++){
        for(int k = 0; k < M; k++){
          for(int l = 0; l < M; l++){
            if(b[k][l] != a[k+i][l+j]){
              continue f;
            }
          }
        }
        ans = "Yes";
        break g;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
#include<stdio.h>
long long int count;
long long int c[100005];
int p[100005];
int root(int n)
{
	if (p[n] == n)
		return n;
	else
		return p[n] = root(p[n]);
}void u(int a, int b)
{
	if (root(a) == root(b))
		return;
	else
	{
		count -= c[root(a)] * c[root(b)];
		c[root(b)] += c[root(a)];
		p[root(a)] = root(b);
		return;
	}
}
int main()
{
	long long int n;
	int m;
	scanf("%lld %d", &n, &m);
	int i;
	int a[100005], b[100005];
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	for (i = 0; i < n; i++)
	{
		c[i] = 1;
		p[i] = i;
	}
	long long int ans[100005];
	count = n * (n - 1) / 2;
	for (i = m - 1; i >= 0; i--)
	{
		ans[i] = count;
		u(a[i], b[i]);
	}
	for (i = 0; i < m; i++)
		printf("%lld\n", ans[i]);
	return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI h(n);
    REP(i, n) cin >> h[i];
    VI dp(n);
    dp[0] = 0;
    FOR(i, 1, n - 1) {
        int cost_min = INT_MAX;
        FOR(j, 1, min(k, i)) 
            cost_min = min(cost_min, dp[i - j] + abs(h[i] - h[i - j]));
        dp[i] = cost_min;
    }
    cout << dp[n - 1] << ln;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  bitset<1001> res(0);
  for (int i = 0; i < k; i++) {
    int d; cin >> d;
    for (int j = 0; j < d; j++) {
      int a; cin >> a; a--;
      res.set(a);
    }
  }
  cout << n - res.count() << '\n';
  return 0;
}

Measured memory_bytes: 3520
//In The Name Of GOD
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 2000000000;
const int maxn = 100000;
#define ll long long
#define pb push_back
#define mp make_pair
#define IO ios_base::sync_with_stdio(false);
int main(){
  IO;
  int n,m;
  cin>>n>>m;
  if(m==1||m==2*n-1){
    cout<<"No";
    return 0;
  }else{
    cout<<"Yes\n";
    for(int i=0;i<2*n-1;i++){
      cout<<(i+m-n+2*n-1)%(2*n-1)+1<<endl;
    }
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int a[n],b[n],c[n-1];
    rep(i,n){cin>>a[i];a[i]--;}
    rep(i,n){cin>>b[i];}
    rep(i,n-1){cin>>c[i];}
    int res=0;
    int prev;
    rep(i,n){
        res += b[a[i]];
        if(i!=0&&prev+1==a[i]){res += c[prev];}
        prev = a[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long m = 0, a = 0, r = 0, c = 0, h = 0;
	long long ans = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M') {
			m++;
		}
		if (s[0] == 'A') {
			a++;
		}
		if (s[0] == 'R') {
			r++;
		}
		if (s[0] == 'C') {
			c++;
		}
		if (s[0] == 'H') {
			h++;
		}
	}
	ans += m * a * r;
	ans += m * a * c;
	ans += m * a * h;
	ans += m * r * c;
	ans += m * r * h;
	ans += m * c * h;
	ans += a * r * c;
	ans += a * r * h;
	ans += a * c * h;
	ans += r * c * h;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int n;
double dp[301][301][301];

double ans(int i, int j, int k) {
    if (dp[i][j][k] >= 0)return dp[i][j][k];

    double ret = 0;
    if (i)ret += ans(i - 1, j, k) * i;
    if (j)ret += ans(i + 1, j - 1, k) * j;
    if (k)ret += ans(i, j + 1, k - 1) * k;
    ret += n;
    ret /= (i + j + k);
    return dp[i][j][k] = ret;
}

int main() {
    init();

    cin >> n;
    int a, num[3] = {};
    FOR(i, 0, n) {
        cin >> a;
        num[--a]++;
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;
    cout << ans(num[0], num[1], num[2]) << "\n";
}


Measured memory_bytes: 213376
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=1e5+5;

int n,s;
long long p[N],x[N],ans[N],tot,la;

int main(){
    scanf("%d%d",&n,&s);
    FOR(i,1,n)scanf("%lld%lld",&x[i],&p[i]);
    int l=1,r=n;
    while(l<=r){
        if(s<=x[l])while(l<=r)ans[++la]=r--;//倒过来的
        else if(x[r]<=s)while(l<=r)ans[++la]=l++;
        else {
            if(p[l]>=p[r]){
                p[l]+=p[r];
                ans[++la]=r--;
            }else {
                p[r]+=p[l];
                ans[++la]=l++;
            }
        }
    }
    assert(la==n);
    reverse(ans+1,ans+n+1);
    ans[0]=0,x[0]=s;
    //FOR(i,0,n)printf("%d%c",x[ans[i]]," \n"[i==n]);
    FOR(i,1,n)tot+=abs(x[ans[i-1]]-x[ans[i]]);
    printf("%lld\n",tot);
    return 0;
}


Measured memory_bytes: 2560
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int128 LL;
//typedef __int64 LL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<long double, long double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII > VP;
typedef vector<double> VD;
typedef vector<LL> VL;
typedef long double ld;

void solve(int ks) {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	int mx = MIN(a, b);
	int mn = MAX(0, a + b - n);
	printf("%d %d\n", mx, mn);
}

int main()
{
#ifdef LOCAL
	double start_time = clock();
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif

	if (0) {
		int T;
		scanf("%d", &T);
		for (int ks = 1; ks <= T; ks++) solve(ks);
	}
	else {
		solve(0);
	}

#ifdef LOCAL
	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
#endif

	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	int B[N+2];
	int A[N+2];
	ll ans = 0;
	for(int i = 1; i < N; i++){
		cin >> B[i];
	}
	A[1] = B[1];
	A[N] = B[N-1];
	for(int i = 1; i < N-1; i++){
		if(B[i] <= B[i+1]){
			A[i+1] = B[i];
		}
		if(B[i] > B[i+1]){
			A[i+1] = B[i+1];
		}
	}	
	for(int i = 1; i < N+1; i++){
		ans+=A[i];
	}

	cout << ans << endl;
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

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

int main()
{
    int N;
    int ai;
    cin >> N;
    int count_sum=0;
    int color_prev = -1;
    int count_prev = 0;
    for(int i =0;i<N;i++){
        cin >> ai;
        if(i==0){
            count_prev++;
            color_prev = ai;
            continue;
        }
        if(ai==color_prev) count_prev++;
        else{
            count_sum += count_prev/2;
            count_prev = 1;
        }
        color_prev = ai;
    }
    count_sum += count_prev/2;
    cout << count_sum << endl;
    return 0;
}

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

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

  double sum = 0; 
  double A;       
  int i = 0;   

  while (i < N) {
    cin >> A;
    sum += 1 / A;
    i++;
  }

  cout << 1 / sum << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    max_count = 0
    max_i = 1
    for i in range(2, N+1):
        count = 0
        j = i
        while j > 0 and j % 2 == 0:
            j = j // 2
            count += 1
        if count > max_count:
            max_count = count
            max_i = i
    return max_i

if __name__ == '__main__':
    print(main())

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

int main(){
	int n;
	while(cin>>n){
		double a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<n-max(ceil(a/c),ceil(b/d))<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,M; cin>>N>>M;
	ll tmp=1;
	while(tmp<=M){
		tmp*=10;
	}
	double num=tmp*N+M;
	if((ll)sqrt(num)*(ll)sqrt(num)==(ll)num) cout<<"Yes";
	else cout<<"No";	
}

Measured memory_bytes: 256
#include<stdio.h>
void swap(int *a,int *b);
int main(){
    int n,x,a[100],i,j,count=0;
    
    scanf("%d%d",&n,&x);
    
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0;i<n;++i){
        for(j=n-1;j>i;--j){
            if(a[j]<a[j-1]){
               swap(&a[j],&a[j-1]);
            }
        }
    }
    i=0;
    while(x>0&&n>i){
        x-=a[i];
        i++;
        count++;
    }
    if(x==0){
        printf("%d\n",count);
    }else{
        printf("%d\n",count-1);
    }
    return 0;
}
void swap(int *a,int *b){
    int temp;
    temp=*a;
    *a=*b;
    *b=temp;
}

Measured memory_bytes: 128
A , B = map(int,input().split())
def XOR_0_to_n(n):
    if n % 2 == 0:
        if (n // 2) % 2 == 0:
            return 0 ^ n
        else:
            return 1 ^ n
    else:
        if ((n-1) // 2) % 2 == 0:
            return 0 ^  n ^ (n-1)
        else:
            return 1 ^ n ^ (n -1)
print(XOR_0_to_n(A-1)^XOR_0_to_n(B))


Measured memory_bytes: 38376
// #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using V = vector<int>;
using VV = vector<V>;

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 A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a) {
    if (a == 2) return true;
    if (a <= 1 || a % 2 == 0) return false;

    for (int i = 3; i * i <= a; i += 2) {
        if (a % i == 0) return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> aaa;
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (aaa[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1;  //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok =
        (int)aaa
            .size();  // 「index =
                      // a.size()-1」が条件を満たさないこともあるので、初期値は
                      // a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

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

    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }

    vector<int> ans(n);
    rep(i, n) { ans[a[i]] = i + 1; }

    rep(i, n) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3988
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>

constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr int LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;


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

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





}

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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;
int main(){

ll N,K;

cin >> N >> K;

vector<Pair> A(N+1);

A[1].second = 1;

for(ll i = 1;i <= N;++i){
    cin >> A[i].first;
    A[i].second = 0;
}

ll index = A[1].first;
ll telcnt = 0;
ll ans;
  
while(A[index].second != 2 && K > telcnt){
    ans = index;
    ++A[index].second;
    index = A[index].first;
    ++telcnt;
}

if(K == telcnt) cout << ans << endl;
else{

ll count = 0;
K = K - telcnt;

for(ll i = 1;i <= N;++i) if(A[i].second == 2) ++count;
  
K = K%count;
telcnt = 0;
  
while(K > telcnt){
    ans = index;
    ++A[index].second;
    index = A[index].first;
    ++telcnt;
}

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

}


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

int N,imap[100010],MINE;
int dp[100010];
void Init(){
scanf("%d",&N);
  for(int i=0;i<N;i++){
scanf("%d",&imap[i]);
    dp[i] = 1<<29;
  }
  for(int i=N;i<N+10;i++)dp[i] = 1<<29;
  MINE = 1<<29;
}

int main(){
  Init();
  deque<int> que;
  que.push_front(0);
  dp[0] = 0;

  while(!que.empty()){
    int p = que.front();que.pop_front();
   
    if(p >= N-1){
      
printf("%d\n",dp[p]);
      break;
    }
    if(imap[p] != 0){
      int np = p + imap[p];
      if(dp[np] <= dp[p])continue;
      dp[np] = dp[p];
      que.push_front(np);//飛ばされてきた場合を優先する
      continue;
    }
    for(int i=1;i<=6;i++){
      int np = p+i;
      if(dp[np] <= dp[p]+1)continue;
      dp[np] = dp[p]+1;
      que.push_back(np);
    }
  }
  return 0;
}

Measured memory_bytes: 1992
#include <iostream>
#include <set>
#include <string>

using namespace std;

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

    set<int> st;
    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        st.insert(s[i]);
    }

    cout << (s.size() == st.size() ? "yes" : "no") << endl;
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-') f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=3e3+50, mod=1e9+7;
inline void add(int &x,int y) {x=(x+y>=mod) ? (x+y-mod) : (x+y);}
int n,m,f[N][N][2];

int main() {
	n=rd(), m=rd();
	for(int i=0;i<=n;i++) f[0][i][i==0]=1;
	for(int i=1;i<=m;i++) {
		for(int j=0;j<=n;++j) {
			if(j) add(f[i][j][j==1],f[i-1][j][0]), add(f[i][j][1],f[i-1][j][1]);
			if(j) add(f[i][j-1][j==1],f[i-1][j][0]), add(f[i][j-1][1],f[i-1][j][1]);
			if(n-j) add(f[i][j][0],f[i-1][j][0]), add(f[i][j][1],f[i-1][j][1]);
			if(n-j) add(f[i][j+1][0],f[i-1][j][0]), add(f[i][j+1][1],f[i-1][j][1]);
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++) add(ans,f[m][i][1]);
	cout<<ans<<'\n';
}

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

using namespace std;

using ll = long long;
using ld = long double;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll sum = accumulate(all(a), 0LL);

  vector<ll> x(n);

  ll s = 0;
  for (ll i = 1; i < n; i += 2) {
    s += a[i];
  }
  x[0] = sum - s * 2;

  for (ll i = 1; i < n; i++) {
    x[i] = a[i - 1] * 2 - x[i - 1];
  }

  rep(i, n) {
    cout << x[i] << " ";
  }
  cout << endl;

  return 0;
}


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

#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e5 + 10;

struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
 int mn = INF;
 int n;
 cin >> n;
 vector<int> v(n);
 for (int i = 0; i < n; i++) cin >> v[i];
 int ret = 0;
 for (int i = 0; i < n; i++){
  if (mn > v[i]){
    mn = v[i];
    ret++;
  }
 }
 cout << ret << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define N 102
#define MAX 100001
static const int INFTY = (1<<21);

main(){
  int n, i, j, u, k, v, c;
  int M[N][N], d[N], p[N], q[N];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
    d[i] = INFTY;
    q[i] = 0;
  }
  d[0] = 0;
  q[0] = 1;
  p[0] = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
u = 1;
  for(c = 0; c < n - 1; c++){
    k = MAX;
    for(i = 0; i < u; i++){
      for(j = 0; j < n; j++){
        if(q[j] == 0){
          if(M[p[i]][j] < MAX && d[j] >= M[p[i]][j] + d[p[i]]){
            d[j] = M[p[i]][j] + d[p[i]];
            if(d[j] <= k){
              k = d[j];
              v = j;
            }
          }
        }
      }
    }
    u++;
    q[v] = 1;
    p[i] = v;
  }
  for ( i = 0; i < n; i++){
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}

Measured memory_bytes: 640