akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 3005
using namespace std;
int n,mod,c[maxn][maxn],g[maxn][maxn];
int Pow(int a,int b,const int mod = ::mod){
	int s=1;for(;b;b>>=1,a=1ll*a*a%mod) b&1&&(s=1ll*s*a%mod); return s;
}
int main()
{
	scanf("%d%d",&n,&mod);
	for(int i=0;i<=n;i++)
		for(int j=c[i][0]=g[i][0]=1;j<=i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod,g[i][j]=(g[i-1][j-1]+1ll*(j+1)*g[i-1][j])%mod;
	int ans=0;
	for(int i=0;i<=n;i++){
		int s=0,x=Pow(2,n-i);
		for(int j=0,pw=1;j<=i;j++,pw=1ll*pw*x%mod) s=(s+1ll*g[i][j]*pw)%mod;
		ans=(ans+1ll*(i&1?-1:1)*c[n][i]*s%mod*Pow(2,Pow(2,n-i,mod-1)))%mod;
	}
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 58868
# まだ解いてない配点を nokori として持つ
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
int a[3];
int ans;

void cnt(int num, int left){
    if(num == 2){
        if(left%a[2]==0)ans++;
        return;
    }
    for(int i = 0; a[num]*i <= left; i++)cnt(num+1, left-a[num]*i);
}
int main(){
    int n;
    ans = 0;
    cin >> a[0] >> a[1] >> a[2] >> n;
    cnt(0, n);
    cout << ans << endl;
    return 0;
}

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


int main(){
   int A,B;
   cin >> A >> B;
   cout << A * B << endl;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int N;
cin >> N;
vector<double> A(N);
REP(i, N) cin >> A.at(i);

double ans;
double bun = 0;
REP(i, N){
bun += 1 / A.at(i); 
}
ans = 1 / bun;
print(ans);
}

Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//#define max(a,b) max((ll)a,(ll)b)
//#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  if(m == 0) return n;
  if(n == 0) return m;
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};


/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////



//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(2);
  
  lin(N);

  vlin(a, N);

  sort(rall(a));

  ll res = 0;



  rep(i, N-1){
    ll j = i + 1;
    j /= 2;
    res += a[j];
    //cout << j << endl;
  }

  cout << res << endl;
}

Measured memory_bytes: 4844
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
 
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    readb(n, m);
    readarr(a, n);
    
    int cnt = 0, sum = 0;
    FOR (i, 1, n) sum += a[i];
    
    FOR (i, 1, n)
    {
        int x = sum/(4*m);
        if (sum % (4*m)) x++;
        if (a[i] >= x) cnt++;
    }
    
    if (cnt >= m) cout << "Yes";
    else cout << "No";
}









Measured memory_bytes: 256
N = int(input())
if N<105:
    print(0)
else:
    ans = 0
    for i in range(105, N+1):
        if i%2 == 0:
            continue
        else:
            cnt = 0
            for j in range(1,i+1):
                if i%j == 0:
                    cnt +=1
            if cnt == 8:
                ans += 1
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    string s; cin>>s;
    int ans=0;
    for(int i=0; i<4; i++){
        ans += (s[i] == '2');
    }

    cout << ans << endl;
}

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

void swap(int*,int*);
int main(){
  int a,b,c,tmp;
  cin >> a >> b >> c;
  if(c<a) swap(&a,&c);
  if(b<a) swap(&a,&b);
  if(c<b) swap(&b,&c);
  cout << a << " "<< b << " " << c << endl;
  return 0;
}
void swap(int* a, int* b){
  int tmp;
  tmp = *a;
  *a =*b;
  *b = tmp;
}



Measured memory_bytes: 3108
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, x, y);
  OUTL(x + y / 2);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    static Scanner scan=new Scanner(System.in);
    public static void main(String args[]){
        int n;
        double t,a;

        n=scan.nextInt();
        t=scan.nextDouble();
        a=scan.nextDouble();
        double h[]=new double[n];
        for(int i=0;i<n;i++){
            h[i]=scan.nextDouble();
        }
        double min=99999999.0;
        double x;
        int ans=0;
        for(int i=0;i<n;i++){
            x=t-h[i]*0.006;
            if(Math.abs(x-a)<min){
                min=Math.abs(x-a);
                ans=i+1;
            }
        }
        System.out.println(ans);

    }   
}

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

bool has3(int x){
    while(x){
        if(x%10==3)return true;
        x/=10;
    }return 0;
}void call(int n){
    for(int x=1;x<=n;x++){
        if(x%3==0||has3(x)){
            cout<<" "<<x;
        }
    }cout<<endl;
}int main(){
    int n;
    cin>>n;
    call(n);
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

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

    vector<char> S(N); REP(i, N) cin >> S[i];

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

    int cnt = 1;
    REP(i, N - 1) {
        if(S[i] != S[i + 1]) {
            cnt++;
        }

        if(i == N - 1) {
            if(S[i] != S[i + 1]) {
                cnt++;
            }
        }
    }

    if(cnt == 3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
}

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

int gcd(int a,int b){
    int q,r;
    do{
        r = a % b;
        q = (a-r) / b;
        a = b;
        b = r;
       // cout << q <<" " << r <<  "\n";
    } while(r>0);
    return a;
}

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

    if(a>b){
       d = gcd(a,b);
    } else{
        d = gcd(b,a);
    }
    cout << d << "\n";

}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, v, p;
ll m, a[100100];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> m >> v >> p;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  int l = p - 1, r = n;
  while (l + 1 < r) {
    int i = (l + r) / 2;
    ll h = (p - 1) * m + (n - i) * m;
    for (int j = p - 1; j < i; j++)
      h += a[i] + m - a[j];
    if (a[i] + m >= a[p - 1] && h >= v * m)
      l = i;
    else
      r = i;
  }
  cout << r << "\n";
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(){
  int N,T,C=0;
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    scanf("%d",&T);
    if(i!=T) C++;
  }
  if(C<=2) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
// use gp_hash_table<int,int,custom_hash> m;
// in place of map
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
// This custom_hash is for unordered_map 
// use map<int, int, custom_hash> mp;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	string s,t;
	cin>>s>>t;
	cout<<t<<s;	

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int c=1;
	int a[100000];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		c=a[c-1];
		if(c==2){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long x;
	cin >> x;
	if(x%100==0 || x%101==0 || x%102==0 || x%103==0 || x%104==0 || x%105==0){
		cout << "1" << endl;
		return 0;
	}
	int x1000=x%10000;
	int x1=x1000/100;
	for(int a=0;a<=x1;a++){
		for(int b=0;b<=x1;b++){
			for(int c=0;c<=x1;c++){
				for(int d=0;d<=x1;d++){
					for(int e=0;e<=x1;e++){
						for(int f=0;f<=x1;f++){
							if(a*100+b*101+c*102+d*103+e*104+f*105==x1000){
								cout << "1" << endl;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	cout << "0" << endl;		
	return 0;
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll a, b;
    cin>>a>>b;
    cout<<a*b;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

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

long int memo[90];

long int lucas(int k) {
  if (k==0) { return 2; }
  if (k==1) { return 1; }
  
  if (memo[k] == 0) {
    memo[k] = lucas(k-1) + lucas(k-2);
  }
  return memo[k];
}

int main() {
  for(int i=0; i<90; i++){
    memo[i] = 0;
  }
  
  int n;
  cin >> n;
  cout << lucas(n);
  return 0;
}


Measured memory_bytes: 256
x = int(input())
ans = 0
for i in range(x, 0, -1):
    if i == 1:
        ans = 1
        break
    tmp = i
    for j in range(31, 1 ,-1):
        i = tmp
        #print(i,j)
        flag = 0
        while(i > 1):
            i = i/j
            flag += 1
            if i == 1 and flag > 1:
                ans = tmp
                break
        if ans != 0:
            break
    if ans != 0:
        break
print(ans)

Measured memory_bytes: 3064
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
#S = input()
N, M, K = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
A = list(map(int, input().split()))
B = list(map(int, input().split()))

AcumA = [0] + list(accumulate(A))
AcumB = [0] + list(accumulate(B))

ia, ib = 0, M 
answer = 0

while ib >= 0 and ia <= N:
    if AcumA[ia] + AcumB[ib] <= K:
        answer = max(answer, ia + ib)
        ia += 1
    else:
        ib -= 1

print(answer)

Measured memory_bytes: 133664
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int,int> P;
const int maxn=1e5+10;
char s[maxn*2];
int main()
{
        int n,a,b,c,d;
        cin>>n;
        cin>>a>>b>>c>>d;
        scanf("%s",s+1);
        int len=strlen(s+1);
        int f=1;
        for(int i=min(a,b);i<=max(d,c);i++)
        {
            if(s[i]=='#'&&s[i+1]=='#')
                  f=0;
        }
        if(s[c]=='#'||s[d]=='#'||f==0)
            puts("No");
       else if((a<b&&c<d)||(b<a&&d<c))
         puts("Yes");
       else
       {      int flag=0;
             for(int i=max(a,b);i<=min(c,d);i++)
             {
                 if(s[i]==s[i-1]&&s[i]==s[i+1]&&s[i]=='.')
                    flag=1;
             }
             if(flag)
                puts("Yes");
             else
                puts("No");
       }



    return 0;
}



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

int main() {
    int N;
    cin >> N;
    int a[110];
    for(int i=0; i<N; ++i) cin >> a[i];
    int max=0, min=0;
    for(int i=1; i<N; ++i)
    {
        if(a[max]<a[i]) max=i;
        if(a[min]>a[i]) min=i;
    }
    cout << a[max] - a[min] << endl;
    return 0;
}


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

#define mod ((int)1e9+7)

int solve(int mat[][21], int n, int dp[][1<<21], int index, int mask){
	if(dp[index][mask]!=-1){
		return dp[index][mask];
	}
	if(index==0){
		for(int i = 0; i < n; i++){
			if(mat[0][i] && (mask&(1<<i))){
				return dp[0][mask] = 1;
			}
		}
	}
	int curr_ans = 0;
	for(int i = 0; i < n; i++){
		if(mat[index][i] && (mask&(1<<i))){
			curr_ans = ((curr_ans%mod)+(solve(mat, n, dp, index-1, mask^(1<<i)))%mod)%mod;
		}
	}
	return dp[index][mask] = curr_ans%mod;
}

void test(int mat[][21], int n){
	int dp[21][1<<21];
	memset(dp, -1, sizeof(dp));
	cout << solve(mat, n, dp, n-1, (1<<n)-1) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int mat[21][21];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> mat[i][j];
		}
	}
	test(mat, n);
	return 0;
}

Measured memory_bytes: 175624
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int zero = 0, one = 0;
    REP(i, s.size()){
        if(s[i] == '0') zero++;
        else one++;
    }
    int ans = min(zero, one) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n,a,b;
	sd(n);
	if(n==1) printf("Hello World\n");
	else{
		sd(a);sd(b);
		pd(a+b);
	}
	return 0;
}

Measured memory_bytes: 256
import sys

def main():
    num, younou = map(int, input().split())

    data = [list(map(int, input().split())) for i in range(younou)]
    data.sort(key=lambda x: x[1])

    ans = 0
    now_value = 1
    for ele in data:
        if ele[0] >= now_value:
            now_value = ele[1]
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65568
n, k = map(int, input().split())
a = list(map(int, input().split()))
#n, k = 200000, 100
#a = [i+2 for i in range(n-1)] + [2]
move = [a[i] - 1 for i in range(n)]
#print(move)
d = [-1 for _ in range(n)]
d[0] = 0
cur = 0
for _ in range(300000):
    to = move[cur]
    if d[to] == -1:
        d[to] = d[cur] + 1
    else:
        rou = d[cur] + 1 - d[to]
        rou_start = to
        break
    cur = to
#print(rou_start, rou)
#print(d)
if k < d[rou_start]:
    x = k
    rou_start = 0
else:
    x = (k - d[rou_start]) % rou
cur = rou_start
for _ in range(x):
    cur = move[cur]


print(cur + 1)

Measured memory_bytes: 32984
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(int i=m; i<n; i++)
#define MOD 998244353
#define ios ios::sync_with_stdio(0), cin.tie(0)
 
using namespace std;

int main()
{
    ios;
    
    int n, W;
    cin >> n >> W;
    int w[n];
    ll v[n];
    fop(i,0,n) cin >> w[i] >> v[i];
    
    ll dp[W+1] = {0};
    fop(i,0,n){
        if(i == 0){
            dp[w[i]] = v[i];
            continue;
        }
        for(int j=W; j>=0; j--){
            if(j-w[i] >= 0) dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
        }
        
        /*cout << i;
        fop(j,0,W+1) cout << " " << dp[j];
        cout << endl;*/
    }
    
    ll ans=0;
    fop(i,0,W+1) ans = max(ans, dp[i]);
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 4408
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

const ll maxn=1e5+10, mod=1e9+7, inf=1e18;

ll n,L,a[maxn];

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

	cin>>n>>L;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int j=1;j<n;j++)if(a[j]+a[j+1]>=L){
		cout<<"Possible\n";
		for(int i=1;i<j;i++) cout<<i<<endl;
		for(int i=n-1;i>=j;i--) cout<<i<<endl;
		return 0;
	}
	cout<<"Impossible\n";

	return 0;
}









Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
 long long int n,d,x,a,b;
 cin>>n>>d>>x;
   a=n;
   b=d-x+1;
 rep(i,x){
   if(n<=a&&a<=d){
   cout<<a<<endl;
   }
   a++;
 }
 rep(i,x){
   if(n<=b&&b<=d&&a<=b){
   cout<<b<<endl;
   }
   b++;
 } 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
using namespace std;

int main(){
    std::ostringstream oss ;
    int n, k ;
    cin >> n >> k;
    vector<int> c(10) ;
    vector<int> d(k) ;
    for (size_t i = 0; i < 10; i++)
    {
        c.at(i) = i ;
    }
    
    for (size_t i = 0; i < k; i++)
    {
        cin >> d.at(i) ;
    }
    for (size_t i = 0; i < k; i++)
    {
        c.erase(c.begin() + d.at(k-1-i)) ;
    }    
    int ans = n ;
    while (1)
    {
        int copy = ans ;
        bool bad = false ;
        while (copy != 0)
        {
            int j = copy % 10 ;
            bool good = false ;
            for (size_t i = 0; i < c.size(); i++)
            {
                if (j == c.at(i))
                {
                    good = true ;
                }
                
            }
            if (good == false)
            {
                bad = true ;
                break ;
            }
            copy /= 10 ;
            
        }
        if (bad == false)
        {
            break ;
        }else
        {
            ans ++ ;
        }
        
        
        
    }
    
    cout << ans << endl ;
}

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

int main(){
    long long n,w;
    cin>>n>>w;
    long long products[n][2];
    long long dp[n+1][w+1];
    for(long long i=0;i<n;i++){
        long long a,b;
        cin>>a>>b;
        products[i][1]=a;
        products[i][0]=b;
    }
    for(long long i=0;i<=n;i++){
        for(long long j=0;j<=w;j++){
            if(i==0 || j==0) dp[i][j]=0;
            else{
                if(products[i-1][1]<=j)
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-products[i-1][1]]+products[i-1][0]);
                else
                    dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 82444
N = int(input())
S = [input() for _ in range(N)]
T = input()

pre = 0
post = 0
for s in S:
	if s.replace('?','z') < T:
		pre += 1
	elif s.replace('?','a') > T:
		post += 1

print(*range(pre + 1, N - post + 2))

Measured memory_bytes: 4084
solver::Int->Int->Int->Int->Int
solver a b c d = minimum [x+y|x<-[a,b],y<-[c,d]]

main::IO()
main=do
  a'<-getLine
  b'<-getLine
  c'<-getLine
  d'<-getLine
  let a:b:c:d:[]=map read [a',b',c',d']::[Int]
  print (solver a b c d) 

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

using namespace std;

vector<int> a;

int main()
{
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p; a.push_back(p);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        x -= a[i];
        if (x >= 0) ans++;
        if (x < 0) break;
    }
    if (x > 0) ans--;
    cout << ans << endl;
}

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

typedef long long               ll;
typedef long double             ld;


#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLOCK			 cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define PII              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(int i=(int)a;i<(int)b;i++)
#define forn(i,a,b)      for(int i=(int)a;i>(int)b;i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2};
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};


ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}

ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}

void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}


int solve()
{
	int n;
	si(n);
	vi v(n);
	forr(i,0,n) si(v[i]);
	
	int mx=0;
	
	int now=0;
	
	
	forr(i,0,n-1)
	{
		if(v[i]>=v[i+1]) now++;
		else
		{
			mx=max(now,mx);
			now=0;
		}
	}
	
	mx=max(now,mx);
	
	pi(mx);
	

	return 0;   	    
}


int main()
{
    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
//	CLOCK;   
    return 0;
}



///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main() {
  ll n,k;
  cin>>n>>k;
  ll ans=(n/k)*(n/k-1)*(n/k-2)+(n/k)*(n/k-1)/2*2*3+(n/k);
  if (k%2==0) {
    ll m=k/2;
    ll l=n/k+((n%k)<m ? 0:1);
    ans+=l*(l-1)*(l-2)+l*(l-1)/2*2*3+l;
  }
  cout<<ans<<endl;     
  return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int H,W,T;
string s[10];

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i(0);i<N;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int ans(1e9);
  for(int i(K);i<=N;i++){
    ans = min(ans,h[i-1]-h[i-K]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
  int n;
  string s;
  int count=0;
  
  cin>>n>>s;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      count++;
    }
  }
  
  cout<<count;
  
  return 0;
}

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

namespace Q3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var n = 0;
            if (int.TryParse(input, out n) == false) {
                return;
            }

            var q = n * n * n;
            Console.WriteLine(q);
        }
    }
}

Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#include <iomanip>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing
using PII = pair<double, int>;
int main() {
	int xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;
	int n;
	cin >> n;
	vector <tuple<int, int, int>> A(n + 2);
	for (int i = 1; i <= n; i++) {
		int x, y, r;
		cin >> x >> y >> r;
		A[i] = make_tuple(x, y, r);
	}
	A[0] = make_tuple(xs, ys, 0);
	A[n + 1] = make_tuple(xt, yt, 0);
	auto calcDist = [&] (int i, int j) {
		ll x1, y1, r1;
		tie(x1, y1, r1) = A[i];
		ll x2, y2, r2;
		tie(x2, y2, r2) = A[j];
		return max(0.0, double(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) - (r1 + r2))); 
	};
	// dijkstra
	vector<double> dist(n + 2, INF);
	set <PII> st;
	st.insert({0, 0});
	dist[0] = 0;
	while(!st.empty()) {
		int x = st.begin()->ss;
		st.erase(st.begin());
		for (int i = 1; i <= n + 1; i++) {
			double distxi = calcDist(x, i);
			if (dist[x] + distxi < dist[i]) {
				st.erase({dist[i], i});
				dist[i] = dist[x] + distxi;
				st.insert({dist[i], i});
			}
		}
	}
	printf("%.10lf", dist[n + 1]);
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

int main()
{

	long x;
	long money = 100;
	int year = 0;
	
	cin >> x;
	while(money < x){
		money *= 1.01;
		year++;
	}
	
	cout << year << endl;
	return 0;

}

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

int main(){
  long long n;
  cin >> n;
  string s = "";
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  while(n!=0){
    long long mod = abs(n) % 2;
    s = to_string(mod) + s; 
    n = (n - mod) / -2;
  }
  cout << s << endl;
}



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

using namespace std;

#define MP make_pair
#define EACH(i, c) for(__typeof((c).begin()) i=(c).begin(); (i)!=(c).end(); i++)

typedef pair<int, int> PII;

const int SIZE = 100;

char line[SIZE], t[SIZE];
set<int> memo[SIZE][SIZE];
set<PII> used;
 
void eval(int const l, int const r) {
   
  set<int>& ret = memo[l][r];
  if(l == r) return;
   
  if(used.count(MP(l, r))) return;
  used.insert(MP(l, r));
   
  // check is digits [l, r)
  bool digits = true;
  for(int i=l; i<r; i++) { digits = digits && isdigit(line[i]); }
  strncpy(t, line+l, r-l); t[r-l] = 0;
  if(digits) { ret.insert(atoi(t)); return; }
   
  int par = 0; bool check = true;
  for(int i=l; i<r-1; i++) {
    if(line[i] == '(') { par ++; }
    if(line[i] == ')') { par --; }
    if(par == 0) { check = false; }
  }
   
  // "(expr)"
  if(check) {
    if(line[r-1] == ')') {
      eval(l+1, r-1); ret = memo[l+1][r-1]; return;
    }
  }
   
  par = 0;
  // parsing loop
  for(int i=l; i<r; i++) {
    if(line[i] == '(') { par ++; }
    if(line[i] == ')') { par --; }
    if(par != 0) continue;
     
    switch(line[i]) {
    case '+': case '-': case '*': case '/':
      eval(l, i); eval(i+1, r);
      EACH(ia, memo[l][i]) EACH(ib, memo[i+1][r]) {
        if(line[i] == '+') { ret.insert(*ia + *ib); }
        if(line[i] == '-') { ret.insert(*ia - *ib); }
        if(line[i] == '*') { ret.insert(*ia * *ib); }
        if(line[i] == '/' && *ib!=0) { ret.insert(*ia / *ib); }
      }
      break;
    }
  } // for parsing loop
}
 
int main() {
   
  while(1) {
    scanf("%s\n", line);
    for(int i=0; i<SIZE; i++)
      for(int j=0; j<SIZE; j++)
        memo[i][j].clear();
     
    used.clear();
     
    if(0==strcmp(line, "#")) break;
    eval(0, strlen(line));
    cout << memo[0][strlen(line)].size() << endl;
  }
   
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  bool easy = true;
  
  for (int i; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S.at(i) == 'L') easy = false;
    }
    if (i % 2 == 1) {
      if (S.at(i) == 'R') easy = false;
    }
  }
  
  if (easy) cout << "Yes" << endl;
  else      cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)
#define DMP(x) cerr << #x << ": " << x << "\n"

using namespace std;
typedef long long lint;
const int MOD = 1000000007;


int main() {

	cin.tie(0);
	
	int N;
	cin >> N;

	vector<int> A(N);
	FOR(i, 0, N) cin >> A[i];

	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()),A.end());

	if (A.size() % 2 == 0)cout << A.size() - 1;
	else cout << A.size();

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define inf (1LL<<57)
#define PII pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
const long long mod = 1e9 + 7;
typedef unsigned long long ull;
using namespace std;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;
/*============================================================================
rk
Deependra Chourasia
IIT(ISM) DHANBAD
16je001916

============================================================================
*/


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n);
    unordered_map<ll,ll> mp;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        v[i]/=2;
        mp[v[i]]++;
    }
    // ll odd=0,even=0;
    // for(auto it:mp)
    // {
    //     if( it.first%2 == 0)even++;
    //     else odd++;
    // }
    
    // if(odd && even)
    // {
    //     cout<<0<<endl;
    //     return 0;
    // }
    
    ll ans=1;
    for(auto it:mp)
    {
        ll x = it.first;
        ans = (ans*x)/__gcd(ans,x);
        if(ans>m)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    
    for(auto it:mp)
    {
        if ((ans / it.first) % 2 == 0) { cout << 0 << endl; return 0; }
    }
    // cout<<ans<<endl;
    
    ll tmp = m/ans;
    tmp = (tmp+1)/2;
    cout<<tmp<<endl;
    
    return 0;
}


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

using namespace std;

#define ll long long
#define mod 998244353

void solve(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i = 0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int sum = 0;
    for(int i = 0;i<k;i++){
        sum += arr[i];
    }
    cout<<sum;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t = 1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3592
n,m = map(int, input().split())

par = [i for i in range(n)]
rank = [0]*n

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if rank[x]<rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

def same(x,y):
    return find(x) == find(y)

a = []
b = []

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

ans = 0
for i in range(m):
    par = [k for k in range(n)]
    rank = [0]*n
    # i番目の2頂点以外を連結
    for j in range(m):
        if i != j:
            unite(a[j],b[j])
            
    
    # 全ての点が連結してるか確認
    if not same(a[i],b[i]):
        ans+=1
  

print(ans)





Measured memory_bytes: 40816
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long int
#define pb push_back
#define bpc __builtin_popcount
#define f first
#define s second

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

stack <char> st;

llong n, a[mxn], dp[1001][1001], p1, p2, cnt = 1;

string s;

int main(){
    cin >> s;
    for (int i = 0; i < s.size(); i ++){
        if(s[i] == 'S'){
            st.push('S');
        }else if(s[i] == 'T'){
            if(st.empty() || st.top() == 'T'){
                st.push('T');
            }else{
                st.pop();
            }
        }
    }cout << st.size();
    return 0;
}


Measured memory_bytes: 644
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

let a = Int(split[0])!
let b = Int(split[1])!
let c = Int(split[2])!
let k = Int(split[3])!

var ans = 0

if k > a {
ans = a

let s = a + b
let t = k - s

if t > 0 {
    ans -= t
}

} else {
  ans = k
}

print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;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--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_d() {
	ll k;
	ll ans = 0;

	cin >> k;

	queue<ll> q;

	rep(i, 9) {
		q.push(i + 1);
	}

	ll x;
	rep(i, k) {
		x = q.front();
		q.pop();

		if (x % 10 != 0) {
			q.push(10 * x + (x % 10) - 1);
		}

		q.push(10 * x + (x % 10));

		if (x % 10 != 9) {
			q.push(10 * x + (x % 10) + 1);
		}
	}

	ans = x;
	
	cout << ans << "\n";
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define max1 200001


int main(){	
	
	int n,k;
	cin>>n>>k;
	int vis[n+1]={0};
	for (int i = 0; i < k; ++i)
	{
		int d;
		cin>>d;
		for(int j=0;j<d;j++){
			int a;
			cin>>a;
			vis[a]+=1;
		}

	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=(vis[i]==0);
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,k;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k);
	if (k<=(n+1)/2) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1e9;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    rep(i, N) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int v;
            cin >> v;
            G[u - 1].push_back(v - 1);
        }
    }

    vector<int> d(N, INF);
    d[0] = 0;
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto to : G[v]) {
            if (d[to] != INF) continue;
            d[to] = d[v] + 1;
            que.push(to);
        }
    }

    rep(i, N) {
        cout << i + 1 << " " << (d[i] == INF ? -1 : d[i]) << endl;
    }
    return 0;
}


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

bool sort_by_second (pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    vector<pair<int, int>> t;
    int sum=0;
    rep(i, 5) {
        int a; cin >> a;
        int b = a % 10;
        if(b == 0) sum += a;
        else t.push_back(make_pair(a, b));
    }
    if(t.empty()) {
        cout << sum << endl;
        return 0;
    }
    sort(t.begin(), t.end(), sort_by_second);
    sum += t[0].first;
    for(int i=1; i<t.size(); i++) sum += t[i].first - t[i].second + 10;
    cout << sum << endl;
}
   

Measured memory_bytes: 256
N,M = map(int,input().split())
ac_cnt = [0] * (N + 1)
wa_cnt = [0] * (N + 1)

for i in range(M):
  p,S = input().split()
  p = int(p)
  
  if ac_cnt[p] == 0:
    if S == "WA":
      wa_cnt[p] += 1
    else:
      ac_cnt[p] += 1
    
wa_cnt = [wa for i, wa in enumerate(wa_cnt) if ac_cnt[i] == 1]
print(sum(ac_cnt),sum(wa_cnt))

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

int main(){
 int n,m,l;
 cin >> n >> m >> l;
 int A[n][m]={};
 int B[m][l]={};
 long long C[n][l]={};

 for(int i=0;i<n;++i){
  for(int k=0;k<m;++k){
   cin >> A[i][k];
  }
 }
 for(int k=0;k<m;++k){
  for(int j=0;j<l;++j){
   cin >> B[k][j];
  }
 }

 for(int i=0;i<n;++i){
  for(int j=0;j<l;++j){
   for(int k=0;k<m;++k){
    C[i][j]+=A[i][k]*B[k][j];
   }
   cout << C[i][j];
   if(j<(l-1)) cout << " ";
  }
  cout << endl;
 }
 return 0;
}

Measured memory_bytes: 3200