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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

static const int MOD = 998244353;

vector<int> BitsetGcd(vector<int> s, vector<int> t) {
        int n = s.size(), m = t.size();
        if (n < m) return BitsetGcd(t, s);
        if (!m) return s;
        for (int i = 0; i < m; i ++) s[i] ^= t[i];
        int l = n;
        for (int i = 0; i < n; i ++) {
                if (s[i]) {
                        l = min(l, i);
                        break;
                }
        }
        vector<int> a(n - l);
        for (int i = 0; i < n - l; i ++) {
                a[i] = s[l + i];
        }
        return BitsetGcd(t, a);
}

//#define N 4040
//
//int Len(const bitset<N> &a) {
//        for (int res = N - 1; res >= 0; res --) {
//                if (a[res]) return res + 1;
//        }
//        return 0;
//}
//
//bitset<N> gcd(bitset<N> s, bitset<N> t) {
//        int n = Len(s), m = Len(t);
//        if (n < m) return gcd(t, s);
//        if (t.none()) return s;
//        int d = n - m;
//        bitset<N> u = t;
//        u <<= d;
//        s ^= u;
//        return gcd(t, s);
//}

long long ModPow(long long x, long long n, long long m) {
        long long res = 1;
        while (n > 0) {
                if (n & 1) res = res * x % m;
                x = x * x % m;
                n >>= 1;
        }
        return res;
}

int main() {
        int n;
        scanf("%d", &n);
        //bitset<N> x;
        //cin >> x;
        //bitset<N> g;
        //for (int i = 0; i < n; i ++) {
        //        bitset<N> s;
        //        cin >> s;
        //        g = gcd(g, s);
        //}
        //cerr << g << endl;
        string x;
        cin >> x;
        vector<int> g;
        for (int i = 0; i < n; i ++) {
                string s;
                cin >> s;
                int k = s.size();
                vector<int> b(k);
                for (int i = 0; i < k; i ++) b[i] = s[i] - '0';
                g = BitsetGcd(g, b);
        }
        for (int i = 0; i < g.size(); i ++) {
                cerr << g[i];
        }
        cerr << endl;
        n = x.size();
        vector<int> c(n), d(n);
        for (int i = 0; i < n; i ++) c[i] = x[i] - '0';
        int m = g.size();
        int ans = 0;
        for (int i = 0; i + m <= n; i ++) {
                if (c[i]) ans = (ans + ModPow(2, n - m - i, MOD)) % MOD;
                if (c[i] == d[i]) continue;
                for (int j = 0; j < m; j ++) d[i + j] ^= g[j];
        }
        printf("%d\n", (ans + (d > c ? 0 : 1)) % MOD);
        return 0;
}


Measured memory_bytes: 113024
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
int n,l,t;
pair<ll,int>a[100001];
ll endp[100001];
ll tm;
int ans[100001];
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> l >> t;
	for(int i=1; i<=n ;i++){
		cin >> a[i].first >> a[i].second;
		if(a[i].second==1){
			endp[i]=(a[i].first+t)%l;
			tm+=t;
		}
		else{
			endp[i]=((a[i].first-t)%l+l)%l;
			tm-=t;
		}
		tm=tm+a[i].first-endp[i];
		a[i].second=i;
	}
	tm=(tm%(1LL*n*l)+1LL*n*l)%(1LL*n*l);
	sort(a+1,a+n+1);
	sort(endp+1,endp+n+1);
	int fst=tm/l;
	for(int i=1; i<=n ;i++){
		ans[a[i].second]=endp[(fst+i-1)%n+1];
	}
	for(int i=1; i<=n ;i++) cout << ans[i] << '\n';
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1LL<<50)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
const int MAX_V=100;
//辺を表す構造体(行き先，容量，逆辺)
struct edge{int to,cap,rev;};
vector<edge> G[MAX_V];  //隣接リスト
bool used[MAX_V];       //dfsの探索済フラグ

//fromからtoに向かう容量capの辺をグラフに追加
void add_edge(int from,int to,int cap){
    G[from].pb((edge){to,cap,(int)G[to].size()});
    G[to].pb((edge){from,0,(int)G[from].size()-1});
}

//増加パスをDFSで探す
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    REP(i,G[v].size()){
        edge& e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからtの最大流
int max_flow(int s,int t){
    int flow=0;
        for(;;){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,INF);
        if(f==0)return flow;
        flow+=f;
    }
}

signed main(){
    int n;
    cin>>n;
    int sum=0;
    FOR(i,1,n+1){
        int t;
        cin>>t;
        if(t>=0){
            sum+=t;
            add_edge(0,i,t);
            add_edge(i,n+1,0);
        }else{
            add_edge(0,i,0);
            add_edge(i,n+1,-t);
        }
        for(int j=2;i*j<=n;j++){
            add_edge(i*j,i,INF);
        }
    }
    cout<<sum-max_flow(0,n+1)<<endl;
    return 0;
}

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

import math
import sys
#def input():
#  return sys.stdin.readline()[:-1]

N, K = map(int, input().split())

n = math.log(N, K)
if n == math.floor(n):
  print(math.ceil(n)+1)
else:
  print(math.ceil(n))

Measured memory_bytes: 38384
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

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

  std::vector<char> except_x;
  for (const char s_i : s) {
    if (s_i != 'x') except_x.push_back(s_i);
  }
  const i64 except_x_size = except_x.size();

  std::vector<i64> x;
  i64 combo = 0;
  for (const char s_i : s) {
    if (s_i == 'x') {
      ++combo;
    } else {
      x.push_back(combo);
      combo = 0;
    }
  }
  x.push_back(combo);
  const i64 x_size = x.size();
  for (i64 i = 0; i < except_x_size / 2; ++i) {
    if (except_x[i] != except_x[except_x_size - i - 1]) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }

  i64 answer = 0;
  for (i64 i = 0; i < x_size / 2; ++i) {
    answer += std::abs(x[i] - x[x_size - i - 1]);
  }
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a,b,c;

int main(){
	cin>>a>>b>>c;
	cout<<(a+b+c>=22?"bust":"win")<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	string S;
	cin >> S;
	int N = S.size();
	ll sum = 0;
	for (int bit = 0; bit < (1 << (N - 1)); bit++) {
		ll now = S[0] - '0';
		for (int i = 0; i + 1 < N; i++) {
			if (bit&(1 << i)) {
				sum += now;
				now = S[i + 1] - '0';
			}
			else {
				now *= 10;
				now += S[i + 1] - '0';
			}
		}
		sum += now;
	}
	cout << sum << endl;
}


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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var s = new int[9];
            for(var i = 0; i < n; i++){
                if(a[i] >= 1 && a[i] <= 399){
                    s[0] += 1;
                }else if(a[i] >= 400 && a[i] <= 799){
                    s[1] += 1;                    
                }else if(a[i] >= 800 && a[i] <= 1199){                    
                    s[2] += 1;
                }else if(a[i] >= 1200 && a[i] <= 1599){
                    s[3] += 1;                    
                }else if(a[i] >= 1600 && a[i] <= 1999){
                    s[4] += 1;                    
                }else if(a[i] >= 2000 && a[i] <= 2399){
                    s[5] += 1;                                        
                }else if(a[i] >= 2400 && a[i] <= 2799){
                    s[6] += 1;                                                            
                }else if(a[i] >= 2800 && a[i] <= 3199){
                    s[7] += 1;                                                            
                }else if(a[i] >= 3200){
                    s[8] += 1;                                                            
                }
            }

            var count = 0;
            for(var i = 0; i < 8; i++){
                if(s[i] > 0){
                    count += 1;
                }
            }

            var min = 0;
            if(count > 0){
                min = count;
            }else{
                min = 1;
            }

            var max = count + s[8];
            
            Console.WriteLine(string.Format("{0} {1}",min,max));
        }
    }
}



Measured memory_bytes: 13396
awk '{
    n = $1
    k = $2
    ans = 0
    for (i = 1; i <= n; ++i) {
        p = 1.0 / n
        x = i
        while (x < k) {
            p /= 2
            x *= 2
        }
        ans += p
    }
    printf "%.10f", ans
}'

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n) {
		int x;
		cin >> x;
		if ((i+1) % 2 == 1) {
			if (x % 2 == 1) ans++;
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int n,i;
    cin>>n;
    int arr[n+3];
    for(i=0; i<n; i++)
    {
        cin>>arr[i];

    }
    for(i=0; i<n; i++)
    {
        if(arr[i]%2==0 && arr[i]%3!=0 && arr[i]%5!=0)
        {
            cout<<"DENIED"<<endl;return 0;

        }
    }
    cout<<"APPROVED"<<endl;




    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long

using namespace std;
const int MAXN = (1 << 20);
const int64_t inf = (int64_t)1e17 + 42;

int n, c, h;

struct Convex{
   typedef pair<int,int> PII;
   #define INT int
   #define SZ(i) (int)i.size()
   vector<PII> lns;
   bool shit(int a,int b,int c){
      return (lns[c].second-lns[a].second)*(lns[a].first-lns[b].first)<(lns[b].second-lns[a].second)*(lns[a].first-lns[c].first);
   }
   void add_line(INT A,INT B){
      lns.push_back({A,B});
      while(SZ(lns)>=3&&shit(SZ(lns)-3,SZ(lns)-2,SZ(lns)-1)){
         lns[SZ(lns)-2]=lns[SZ(lns)-1];
         lns.pop_back();
      }
   }
   INT get(int whr,INT x){
      return lns[whr].first*x+lns[whr].second;
   }
   INT query(INT x){
      int l=0,r=SZ(lns)-1;
      while(r>l){
         int m=(l+r)>>1;
         if(get(m,x)>=get(m+1,x)){
            l=m+1;
         }else{
            r=m;
         }
      }
      return get(l,x);
   }
}s;

void solve()
{
   cin>>n>>c;
   cin>>h;
   s.add_line(-2*h, h*h);

   int y = 0;
   for (int i = 1; i < n; ++i)
   {
      cin>>h;
      int tt = s.query(h);
      y = h*h + c + s.query(h);
      s.add_line(-2*h, h*h + y);
   }
   cout<<y;
}

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

   solve();
   return 0;
}

Measured memory_bytes: 6256
n,m=gets.split.map &:to_i
v={1=>r=[1]}
h=Hash.new{|h,k|h[k]=[]}
m.times{a,b=gets.split.map &:to_i;h[a]<<b;h[b]<<a}
f=->x{1while h[x].any?{|e|!v[e]&&v[e]=r<<x=e}}
f[1]
r.reverse!
f[1]
p r.size
puts r

Measured memory_bytes: 23036
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double r = sc.nextDouble();
    String a = String.format("%.5f",r*r*Math.PI);
    String b = String.format("%.5f",2*r*Math.PI);
    System.out.print(a + " ");
    System.out.println(b);
  }
}

Measured memory_bytes: 28344
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<vector<int>> gridgraph1(int h, int w, vector<string> s) {
    vector<vector<int>> edge(h * w);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                continue;
            }
            if (i - 1 >= 0 && s[i - 1][j] == '.') {
                edge[i * w + j].push_back((i - 1) * w + j);
            }
            if (i + 1 < h && s[i + 1][j] == '.') {
                edge[i * w + j].push_back((i + 1) * w + j);
            }
            if (j + 1 < w && s[i][j + 1] == '.') {
                edge[i * w + j].push_back(i * w + j + 1);
            }
            if (j - 1 >= 0 && s[i][j - 1] == '.') {
                edge[i * w + j].push_back(i * w + j - 1);
            }
        }
    }
    return edge;
}
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    int black = 0;
    for (int i = 0; i < h; i++) {
        cin >> a[i];
        black += count(all(a[i]), '#');
    }
    auto edge = gridgraph1(h, w, a);
    vector<int> d(h * w, -1);
    queue<int> que;
    que.push(0);
    d[0] = 0;
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        for (auto next : edge[now]) {
            if (d[next] == -1) {
                d[next] = d[now] + 1;
                que.push(next);
            }
        }
    }
    if (d[h * w - 1] == -1) {
        cout << -1 << endl;
    } else {
        cout << h * w - black - d[h * w - 1] - 1 << endl;
    }
}


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

int main(){
	vector<int> v(100);
	int n,d,cnt=0;
	cin>>n;
	for(int i=0; i<n; i++){
		int check=1;
		cin>>d;
		for(int j=0; j<(signed)v.size(); j++){
			if(v[j]==d){
				check=0;break;
			}
		}
		if(check)cnt++,v.push_back(d);
	}
	cout<<cnt<<endl;
}


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

#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define all(c) (c).begin(), (c).end()
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 1e5 + 2, MOD = 1e9 + 7;
int n, d;

void solve(){
	int cnt = 0;
	while(n >= 1){
		n -= (d * 2);
		n--;
		cnt++;
	}
	cout << cnt << endl;
}

int main(){
	speed
	cin >> n >> d;
	solve();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,sum=0,a=0,cpy;
  scanf("%d",&n);
  cpy=n;
  while(n!=0){
    a=n%10;
    sum+=a;
    n/=10;
  }
  if(cpy%sum==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll p=0,m=0;
  if(a>=k){
    p=k;
  }else{
    p=a;
  }

  if(a+b<=k){
    m=k-a-b;
  }

  cout << p-m << endl;
}


Measured memory_bytes: 3640
n = int(input())
l = []
for i in range(n):
    a,b =input().split()
    b = int(b)
    l.append([a,b])
for y in ["S","H","C","D"]:
    for x in range(1, 14):
        if [y,x] not in l:
            print(y,x)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int n;
    cin >> n;
    int k;
    cin >> k;
    int sum = 0;

    REP(i,n) {
        int tmp;
        cin >> tmp;
        if(tmp >= k){
            sum++;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int N;
    char tgt;
    cin>>N;
    for(int i=0;i<N;i++){
        scanf("%c",&tgt);
        if(tgt=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline uint32_t read()
{
	uint32_t x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(uint32_t x) {
	int s = 0;
	char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int main()
{
	int h = read(), w = read();
	vector<int> rowMax(w, 0);
	vector<int> columnAccum(w, 0);
	int max = 0;
	for (size_t i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (size_t j = 0; j < w; j++)
		{
			if (getchar_unlocked() == 35) 
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				for (size_t k = j - currentChain; k < j; k++)
					rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		for (size_t j = w - currentChain; j < w; j++)
			rowMax[j] = Max(rowMax[j], currentChain);
		getchar_unlocked();
	}
	for (size_t i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 256
ary = [list(map(int,input().split())) for _ in range(3)]
for i in range(ary[0][0]+1):
    a = [ary[0][0]-i,ary[0][1]-i,ary[0][2]-i]
    a2 = ary[1][0] - a[0]
    a3 = ary[2][0] - a[0]
    b = [a2+a[0],a2+a[1],a2+a[2]]
    c = [a3+a[0],a3+a[1],a3+a[2]]
    if ary == [a,b,c]:print("Yes");exit()
else:print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	final int MAX_N = 2000000;
	final int K = 10000;
	
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n + 1];

		for (int j = 1; j <= n; j++)
			a[j] = scan.nextInt();
		countingSort(a, b, K);

		StringBuilder builder = new StringBuilder();
		for (int i = 1; i < n; i++)
			builder.append(b[i] + " ");
		System.out.println(builder.append(b[n]));
	}

	void countingSort(int[] a, int[] b, int k) {
		int[] c = new int[k + 1];
		for (int i = 1; i < a.length; i++)
			c[a[i]] += 1;
		
		for (int i = 1; i <= k; i++)
			c[i] += c[i - 1];
		
		for (int j = a.length - 1; j >= 1; j--) {
			b[c[a[j]]] = a[j];
			c[a[j]]--;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 578308
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Problem C: Dividing Students
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		StringBuilder sb = new StringBuilder();
		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);

			for (int i = 0; i < n; ++i) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				int pm = Integer.parseInt(st.nextToken());
				int pe = Integer.parseInt(st.nextToken());
				int pj = Integer.parseInt(st.nextToken());

				int sum = pm + pe + pj;
				char rank = 'C';
				if (pm == 100 || pe == 100 || pj == 100) {
					rank = 'A';
				} else if (sum >= 240 || sum - pj >= 180) {
					rank = 'A';
				} else if (sum >= 210) {
					rank = 'B';
				} else if (sum >= 150 && (pm >= 80 || pe >= 80)) {
					rank = 'B';
				}
				sb.append(rank).append('\n');
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 22200
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N, K;
    cin >> N >> K;
    vector<ll> x(N+1);
    vector<ll> x_dist(N);
    ll cost = 0;
    ll total_cost = INF;
    ll sunuke = 0;
    ll sunuke_pos;
    for(size_t i=0;i<N; i++)
    {
        ll pos;
        cin >> pos;
        if(sunuke == 0 && pos >= 0)
        {
            sunuke++;
            x[i] = 0;
            sunuke_pos = i;
        }
        x[i+sunuke] = pos;
    }
    ll count = 0;

    for(size_t i=0;i<=N-K; i++)
    {
        cost = min(abs(x[i]) + abs(x[i+K] - x[i]), abs(x[i+K]) + abs(x[i+K] - x[i]));
        total_cost = min(total_cost, cost);
        //cerr << i << ":" << cost << endl;
        /*
        x_dist[i-1] = x[i] - x[i-1];
        count++;
        if(count <= K)
        {
            cost += x_dist[i-1];
            if(count == K) total_cost = min(total_cost, cost);
        }else
        {
            cost = cost + x_dist[i-1] - x_dist[i-1-K];
            total_cost = min(total_cost, cost);
        }
        */
    }
    cout << total_cost << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 1792
S = input()
count =0
total =0
if S[0] == 'A':
  count +=1
bbb = S[2:-1]
if bbb.count('C') == 1:
  count +=1
for i in S:
  if i.isupper():
    total +=1
if total ==2:
  count +=1
if count == 3:
  print('AC')
else:
  print('WA')
  

Measured memory_bytes: 9016
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(ll i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main(){
  ll n,sum=0;
  cin>>n;
  ll a[100000];
  rep(i,n){
    cin>>a[i];
  }

  bool flag=false;
  ll mixi=inf,nega=0;
  rep(i,n){
    if(a[i]==0) flag=true;
    if(a[i]<0) nega++;

    if(mixi>abs(a[i])) mixi=abs(a[i]);
  }

  if(flag){
    rep(i,n) sum+=abs(a[i]);
    cout<<sum<<endl;
  }
  else if(nega%2){
    rep(i,n) sum+=abs(a[i]);
    cout<<sum-2*mixi<<endl;
  }
  else{
    rep(i,n) sum+=abs(a[i]);
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1024
N=int(input())
S=input()
from collections import defaultdict
dd = defaultdict(int)
ddd = defaultdict(int)
d=[]

for s in S:
  for xx in dd.keys():
    ddd[xx+s]=1
  for x in d:
    dd[x+s]=1
  if s in d: 
    pass
  else:
    d.append(s)
print(len(ddd))

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

using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    int x;
    for (int i = 0; i < N; ++i) cin >> x;

    int p = N - 1;
    int d = K - 1;
    cout << (p + d - 1) / d << endl;
}


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

int main() {
  
  // Variables
  int a;
  cin >> a;
  
  //Main loop
  cout << a + (a * a) + (a * a * a) << endl;
  
  return 0;
}

Measured memory_bytes: 3588
from collections import Counter
n,m = (int(i) for i in input().split())
a = [int(i)%m for i in input().split()]
for i in range(1,n): a[i] = (a[i]+a[i-1])%m
a = [0]+a
c,ans = Counter(a),0
for i in c.most_common():
	if i[1]==1: break
	ans += i[1]*(i[1]-1)//2
print(ans)

Measured memory_bytes: 15564
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int a,b; cin >> a >> b;
	int ans = 0;
	rep(i,2){
		if(a>b){
			ans+=a;
			a--;
		}else{
			ans+=b;
			b--;
		}
	}
	cout << ans << endl;
}




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

struct Card {
    char suit, value;
};

void bubbleSort(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N -1; j >= i + 1; j--) {
            if (A[j].value < A[j - 1].value) {
                //TODO確認
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selectionSort(struct Card A[], int N) {
    
    for (int i = 0; i < N; i++) {
        
        int min = i;
        for (int j = i; j < N; j++) {
            if (A[j].value < A[min].value) min = j;
        }
        Card t = A[i]; A[i] = A[min]; A[min] = t;
    }
}

void print(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main() {
    
    Card C1[100], C2[100];
    int N;
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }
    
    //配列コピー
    for (int i = 0; i < N; i++) C2[i] = C1[i];

    bubbleSort(C1, N);

    selectionSort(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include <stdio.h>
#include <string.h>
int main(void){
    int n,i,j,k;
    scanf("%d",&n);
    int num[n];
    int ans[n];
    for(i=0;i<n;i++){
        scanf("%d",&num[i]);
    }
    for(i=0;i<n;i++){
        ans[i]=0;
    }
    if(n%2==0){
        for(i=0,j=1;i<n/2;i++){
            ans[i]=num[n-j];
            j+=2;
        }
        j--;
        for(i=n/2;i<n;i++){
            ans[i]=num[n-j];
            j-=2;
        }
    }else{
        for(i=0,j=1;i<((n/2)+1);i++){
            ans[i]=num[n-j];
            j+=2;
            //printf("ans[%d]=%d\n",i,ans[i]);
        }
        for(k=0,j=1;k<n/2;k++,i++){
            ans[i]=num[j];
            j+=2;
            //printf("ans[%d]=%d\n",i,ans[i]);
        }
    }
    for(i=0;i<n;i++){
        printf("%d%c",ans[i],i==n-1?'\n':' ');
    }
    return 0;
}


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

int dp[3005][3005];
string s, t;

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> s >> t;
    for(int i = 1; i <= (int)s.size(); i++)
        for(int j = 1; j <= (int)t.size(); j++)
            if(s[i-1] == t[j-1])    dp[i][j] = dp[i-1][j-1]+1;
            else                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    string ans;
    int n = (int)s.size(), m = (int)t.size();
    while(n > 0 || m > 0){
        if(n == 0)  m--;
        else if(m == 0) n--;
        else{
            if(s[n-1] == t[m-1])    ans += s[n-1], n--, m--;
            else if(dp[n-1][m] > dp[n][m-1])    n--;
            else                                m--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}

Measured memory_bytes: 35456
using System;
using System.Collections.Generic;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputnum = Console.ReadLine().Split();

            var divisor = new List<int>();
            int answer = 0;

            for (int i = 1; i <= int.Parse(inputnum[2]); i++)
            {
                if (int.Parse(inputnum[2]) % i == 0)
                {
                    divisor.Add(i);
                }
            }

            for (int j = 0; j < divisor.Count; j++)
            {
                if (int.Parse(inputnum[0]) <= divisor[j] && divisor[j] <= int.Parse(inputnum[1]))
                {
                    answer += 1;
                }
            }

            Console.WriteLine(answer);

        }
    }
}



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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

//すべての組み合わせを列挙して一番多く使われるp, qが答え
int main() {

    ll N;
    cin >> N;
    map<vector<ll >, ll> mp;
    vector<pi > p;
    for(ll i = 0; i < N; i++){
        ll x, y; cin >> x >> y;
        p.push_back(make_pair(x, y));
    }

    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            if(i == j) continue;
            mp[vector<ll>{p[i].first - p[j].first, p[i].second - p[j].second}]++;
        }        
    }

    ll mx = 0;
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        mx = max(mx, iter->second);
    }    

    cout << N - mx << endl;

}

Measured memory_bytes: 512
from queue import Queue

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
dist = [[-1 for _ in range(W)] for __ in range(H)]
searched = [[False for _ in range(W)] for __ in range(H)]
bfq = Queue()

def search(x, y, d):
    if not (0 <= x < W and 0 <= y < H):
        return
    if searched[y][x]:
        return
    searched[y][x] = True
    if field[y][x] == '#':
        return
    dist[y][x] = d
    bfq.put([x, y, d])
    return

search(0, 0, 0)

while not (searched[H-1][W-1] or bfq.empty()):
    x, y, d = bfq.get()
    search(x-1, y, d+1)
    search(x+1, y, d+1)
    search(x, y-1, d+1)
    search(x, y+1, d+1)

walls = sum(list(map(lambda x: x.count('#'), field)))

print(W*H - walls - dist[H-1][W-1] - 1 if searched[H-1][W-1] else "-1")

Measured memory_bytes: 47336
use proconio::input;

fn main() {
  input! {
    n: usize,
    mut h: [i32; n],
  }

  let mut dp = vec![-1_i32; n + 1];
  dp[0] = 0;

  for i in 0..n {
    if dp[i] == -1 {
      dp[i+1] = -1;
    } else if (h[i] - 1) >= dp[i] {
      dp[i+1] = h[i] - 1;
    } else if h[i] >= dp[i] {
      dp[i+1] = h[i];
    } else {
      dp[i+1] = -1;
    }
  }

  println!("{}", if dp[n] >= 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 3684
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,i,j,k,a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&n);
	for (int i=min(a,b);i>=1;i--){
		if (a%i==0 && b%i==0) k++;
		if (k==n){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	int n;
	cin >> n;

	cout << (n-2) * 180  << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int a,b;
  cin >> a >> b;
  int ans=a+a-1;
  cout << max(max(ans,a+b),b+b-1) << endl;
return 0;}


Measured memory_bytes: 384
def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


H, W = map(int, input().split())
ls = [0]*10
cost = [[10**5]*10 for i in range(10)]
dist = [0]*10
for i in range(10):
  inf = [int(c) for c in input().split()]
  for j in range(10):
    cost[i][j] = inf[j]
dist = warshall_floyd(cost,10)
cnt = [0]*(12)
for i in range(H):
  inf = [int(c) for c in input().split()]
  for j in range(W):
    cnt[inf[j]] += 1
ans = 0
for i in range(10):
  ans += dist[i][1]*cnt[i]
print(ans)

Measured memory_bytes: 40556
#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() {
	string s;
	string ans = "Yes";

	cin >> s;

	ll n = s.size();

	ll head, tail;
	rep(i, (n - 1) / 2) {
		head = i;
		tail = (n - 1) / 2 - i - 1;
		if (s[head] != s[tail]) {
			ans = "No";
			break;
		}
	}

	rep2(i, (n + 3)/2 - 1, n) {
		head = i;
		tail = n - i - 1;
		if (s[head] != s[tail]) {
			ans = "No";
			break;
		}
	}

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

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

	solve_abc();

	return 0;
}

Measured memory_bytes: 256
use io::*;
use std::*;

fn solve(N: usize, A: Vec<usize>) {
    let mut counts = vec![0; N];
    A.iter().for_each(|number| counts[number - 1] += 1);
    counts.iter().for_each(|count| println!("{}", count));
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut N: usize;
    N = scanner.next();
    let mut A: Vec<usize> = vec![0usize; (N - 2 + 1) as usize];
    for i in 0..(N - 2 + 1) as usize {
        A[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(N, A)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 5612
# 入力を受け取る
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

# 動的計画法のテーブルを初期化
dp = [None] * (K + 1)

# テーブルの初期値を設定 石が０個時は必ず負ける
dp[0] = False

# 残り石が少ない方からdpテーブルを埋めてゆく
for n in range(1, K + 1):
    # nより小さいAのカードを抽出
    ta = [x for x in A if x <= n]
    
    # n以下のカードがないなら必ず負ける
    if len(ta) == 0:
        dp[n] = False
    else:
        res = True
        for a in ta:
            res = res and dp[n - a]
        dp[n] = not res

print("First" if dp[K] else "Second")


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

int main() {
    int X, Y;
    int A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<long long> p(A, 0);
    vector<long long> q(B, 0);
    vector<long long> r(C, 0);
    for (int i = 0; i < A; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < B; ++i) {
        cin >> q[i];
    }
    for (int i = 0; i < C; ++i) {
        cin >> r[i];
    }

    sort(p.begin(), p.end(), greater<long long>());
    sort(q.begin(), q.end(), greater<long long>());
    sort(r.begin(), r.end(), greater<long long>());

    vector<long long> redgreen(X + Y, 0ll);
    for (int i = 0; i < X; ++i) {
        redgreen[i] = p[i];
    }
    for (int i = 0; i < Y; ++i) {
        redgreen[X + i] = q[i];
    }
    for (int i = 0; i < r.size(); ++i) {
        redgreen.push_back(r[i]);
    }
    sort(redgreen.begin(), redgreen.end(), greater<long long>());
    long long sum = 0ll;
    for (int i = 0; i < X + Y; ++i) {
        sum += redgreen[i];
    }

    //vector<long long> red(X, 0ll);
    //vector<long long> green(Y, 0ll);
    //for (int i = 0; i < X; ++i) {
    //    red[i] = p[i];
    //}
    //for (int i = 0; i < Y; ++i) {
    //    green[i] = q[i];
    //}
    //sort(red.begin(), red.end());
    //sort(green.begin(), green.end());

    //int ired = 0;
    //int igreen = 0;
    //int itrans = 0;
    //while (true) {
    //    if (ired >= red.size() || igreen >= green.size() || itrans >= r.size()) {
    //        break;
    //    }
    //    bool encolor = false;
    //    if (red[ired] < green[igreen]) {
    //        if (red[ired] < r[itrans]) {
    //            red[ired] = r[itrans];
    //            ++ired;
    //            ++itrans;
    //            encolor = true;
    //        }
    //    }
    //    else {
    //        if (green[igreen] < r[itrans]) {
    //            green[igreen] = r[itrans];
    //            ++igreen;
    //            ++itrans;
    //            encolor = true;
    //        }
    //    }
    //    if (!encolor) {
    //        break;
    //    }
    //}

    //long long sum = accumulate(red.begin(), red.end(), 0ll);
    //sum += accumulate(green.begin(), green.end(), 0ll);
    cout << sum << endl;
    //cout << setprecision(15) << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, A;
    cin >> H >> A;
    cout << (H + (A - 1)) / A  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

bool is_ok(ll mid, ll key, vector<ll> &bsum){
	if (bsum[mid] <= key) return true;
	return false;
}

int nibutan(ll ok, ll ng, ll key, vector<ll> &bsum){
	if (ng - ok == 1) return ok;
	ll mid = (ok + ng)/2;
	if (is_ok(mid, key, bsum)) return nibutan(mid, ng, key, bsum);
	return nibutan(ok, mid, key, bsum);
}


int main(){
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	vector<ll> asum(n+1), bsum(m+1);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	for (int i = 1; i <= n; i++) asum[i] = asum[i-1] + a[i-1];
	for (int i = 1; i <= m; i++) bsum[i] = bsum[i-1] + b[i-1];

	int ans = 0;
	for (int i = 0; i <= n; i++){
		if (asum[i] > k) break;
		ll left_t = k - asum[i];
		int temp_ans;
		if (bsum[m] <= left_t){
			temp_ans = i + m;
			ans = max(ans, temp_ans);
			continue;
		}
		temp_ans = i + nibutan(0, m, left_t, bsum);
		ans = max(ans, temp_ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9544
N,M = (int(x) for x in input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split())) 
switchstate = [False for i in range(1, N+1)]
count = 0
for i in range(2 ** (N)):
    broke = False
    for j in range(N):
        if i >> j & 1:
            switchstate[j] = True
        else:
            switchstate[j] = False
    for j in range(M):
        temp = []
        for k in range(len(ks[j])-1):
            temp.append(switchstate[ks[j][k+1]-1])
        if temp.count(True) % 2 != p[j]:
            broke = True
            break
    if broke == False:
        count += 1
print(count)

Measured memory_bytes: 3064
def main():
    from sys import stdin
    input = stdin.readline

    n, m, r = map(int, input().split())
    l = list(map(int, input().split()))
    for i in range(r):
        l[i] -= 1
    d = [[10**8] * n for _ in range(n)]
    for _ in range(m):
        i, j, k = map(int, input().split())
        d[i-1][j-1] = k
        d[j-1][i-1] = k

    # Warshall-Floyd algorithm
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    # full search
    # 8! = 40320
    from itertools import permutations

    answer = 10**8
    for i in permutations(l):
        ans = 0
        for j in range(r-1):
            ans += d[i[j]][i[j+1]]
        if ans < answer:
            answer = ans

    print(answer)

main()


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

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

Measured memory_bytes: 256
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        a: [Usize1; n],
        mut b: [Usize1; n],
    }

    let mut c = vec![0; n];
    let mut d = vec![0; n];
    for i in 0..n {
        c[a[i]] += 1;
        d[b[i]] += 1;
    }

    if c[0] + d[0] > n {
        println!("No");
    } else {
        for i in 1..n {
            if c[i] + d[i] > n {
                println!("No");
                return
            }
            c[i] += c[i - 1];
            d[i] += d[i - 1];
        }

        let mut x = c[0] as isize;
        for i in 1..n {
            x = x.max(c[i] as isize - d[i - 1] as isize)
        }

        if x >= 0 {
            b.rotate_right(x as usize);
        } else {
            b.rotate_left(x.abs() as usize);
        }

        println!("Yes");
        println!("{}", b.iter().map(|v| (v + 1).to_string()).collect::<Vec<String>>().join(" "));
    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int n; cin >> n;
  string s = to_string(n);
  cout << (n%Sum(s)==0?"Yes":"No") << endl;
}


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

int main(){
  int N; 
  cin>>N;
  
  for(int i=1;i<=10;i++){
    if(i*1000-N<0){
      continue;
    }
    if(i*1000-N>=0){
      cout<<i*1000-N<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x; is >> x; a = ModInt<mod>(x); return (is);
    }
};

const int MAX_N = 2020;
const int MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];
    
    ModInt<MOD> dp[MAX_N][MAX_N];
    for (int i = 0; i < MAX_N; i++) dp[i][0] = dp[0][i] = 1;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j] - dp[i][j];
            if (s[i] == t[j]) dp[i+1][j+1] += dp[i][j];
        }
    }
    
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,N; cin>>H>>N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin>>A[i]; 
  int sum=0;
  for (int i=0; i<N; i++){
    sum += A[i];
  }
  if (sum < H){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
}

Measured memory_bytes: 640