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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=2e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
	ll n,m,tar;
	cin >> n >> m >> tar; 
	vector<string> a(n);
	ll v[n][m];
	for(ll i=0;i<n;i++){
		cin >> a[i];
		for(ll j=0;j<m;j++){
			v[i][j]=(a[i][j]=='1');
		}
	}

	ll ans=INF,cur_ans,parts;
	for(ll k=0;k<(1ll<<(n-1));k++){
		cur_ans=parts=__builtin_popcountll(k);
		parts++;
		vl c(n),type(n);
		ll kind=0;
		for(ll j=0;j<n;j++){
			if(k & (1ll<<(n-j-1)))
				kind++;
			type[j]=kind;
		}
		vl cur(n,0),temp(n,0);
		bool flag=0;
		for(ll j=0;j<m;j++){
			fill(temp.begin(),temp.end(),0);
			// bool flag=false;
			for(ll i=0;i<n;i++){
				temp[type[i]]+=v[i][j];
			}
			bool flag=false;
			for(ll i=0;i<parts;i++){
				if(cur[i]+temp[i] > tar){
					flag=1;
					break;
				}
				else{
					cur[i]+=temp[i];
				}
			}

			if(flag){
					bool check=true;
					for(ll i=0;i<parts;i++)
						if(temp[i]>tar){
							check=false;
							break;
						}
					if(!check){
						cur_ans=INF;
						break;
					}
					cur_ans++;
					for(ll i=0;i<parts;i++){
						cur[i]=temp[i];
					}
			}
		}
		ans=min(ans,cur_ans);
	}
	cout << ans << "\n";

} 
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	}
return 0;
}


Measured memory_bytes: 384
package main

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

func reverseString(s string) string {
	t := make([]byte, len(s))
	for i, b := range []byte(s) {
		t[len(s)-1-i] = b
	}
	return string(t)
}

func main() {
	s := readString()
	t := readString()
	dp := make([][]int, len(s)+1)
	for i := 0; i <= len(s); i++ {
		dp[i] = make([]int, len(t)+1)
	}
	for i := 1; i <= len(s); i++ {
		for j := 1; j <= len(t); j++ {
			k := dp[i-1][j]
			if dp[i][j-1] > k {
				k = dp[i][j-1]
			}
			if s[i-1] == t[j-1] && dp[i-1][j-1]+1 > k {
				k = dp[i-1][j-1] + 1
			}
			dp[i][j] = k
		}
	}
	u := make([]byte, 0, 4096)
	i := len(s)
	j := len(t)
	for i > 0 && j > 0 {
		if dp[i-1][j] == dp[i][j] {
			i--
		} else if dp[i][j-1] == dp[i][j] {
			j--
		} else {
			u = append(u, s[i-1])
          	i--
          	j--
		}
	}
	fmt.Println(reverseString(string(u)))
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int k;cin>>k;
  int ans;
  if(k%2==0){
    ans=(k/2)*(k/2);
  }else{
    ans=(k/2)*(k/2+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n;
    cin >> n;
    vector<int> a(n - 1);
    REP(i, n - 1)
    cin >> a[i];

    vector<int> p(n);

    for (int i = 0; i < a.size(); i++)
    {
        p[a[i] - 1] = p[a[i] - 1] + 1;
    }

    for (int i = 0; i < p.size() - 1; i++)
    {
        cout << p.at(i) << endl;
    }
    cout << p.at(p.size() - 1) << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 4840
def solve(n, m, data)
  id_map = data.group_by(&:first)
             .map { |k, v| [k, v.map!(&:last).sort!] }
             .flat_map do |pref, years|
    years.map!.with_index {|y, i| ["#{pref}-#{y}", sprintf("%06d%06d", pref, i + 1)]}
  end.to_h

  data.map{|p, y| id_map["#{p}-#{y}"]}
end

def main
  stdin = STDIN.gets
  nm = stdin.split(/\s/)
  n = nm[0].to_i
  m = nm[1].to_i

  data = []
  (0...m).each do
    stdin = STDIN.gets
    p_y = stdin.split(/\s/).map!(&:to_i)
    data.push(p_y)
  end

  ret = solve(n, m, data)
  ret.each { |r| puts r }
end

main

Measured memory_bytes: 67324
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_long long.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Blong long = mp::cpp_long long;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    string N;
    cin>>N;
    if(N[0]==N[1]||N[1]==N[2]||N[2]==N[3]) cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;
}


Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct unionfind {
  vector<int> dat;

  unionfind(int n) : dat(n) {
    for (int i = 0; i < n; i++) {
      dat[i] = i;
    }
  }

  int find(int x) {
    if (dat[x] == x) return x;
    return dat[x] = find(dat[x]);
  }

  void unite(int x, int y) {
    dat[find(x)] = find(y);
  }
};

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  vector<pair<int, int>> AB;
  for (int i = 0; i < N; i++) {
    AB.emplace_back(A[i], i);
    AB.emplace_back(B[i], i + N);
  }
  sort(AB.begin(), AB.end());
  int a = 0;
  int b = 0;
  bool any = false;
  unionfind uf(N);
  int prev_a = 0;
  for (auto t : AB) {
    if (t.second < N) {
      a++;
      prev_a = t.second;
    } else {
      b++;
      uf.unite(prev_a, t.second - N);
    }
    if (a < b) {
      cout << "No" << endl;
      return 0;
    }
    if (a >= b + 2) {
      any = true;
    }
  }
  int cycles = 0;
  for (int i = 0; i < N; i++) {
    if (uf.find(i) == i) cycles++;
  }
  if (cycles == 1 && !any) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3952
S_ = input()
T = input()

for i in range(len(S_) - len(T), -1, -1):
    for j in range(len(T)):
        if S_[i + j] != '?' and S_[i + j] != T[j]:
            break
    else:
        print((S_[:i] + T + S_[i + len(T):]).replace('?', 'a'))
        break
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	int x[3];
	x[0] = a; x[1] = b; x[2] = c;

	sort(x, x + 3, greater<int>());

	cout << x[0] * 10 + x[1] + x[2] << endl;

	//int test = max({ a, b, c });
	//cout << test << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1000000007;
    private static final int MAX_N = 200005;
    private static final long[] MODULAR_INVERSE = new long[MAX_N];
    private static final long[] FACTORIAL = new long[MAX_N];

    private static long pow(long base, int exp) {
        long ret = 1;
        while (exp != 0) {
            if ((exp & 1) != 0) ret = (ret * base) % MOD;
            base = (base * base) % MOD;
            exp >>= 1;
        }
        return ret;
    }


    private static void pre(int N) {
        FACTORIAL[0] = 1;
        for (int i = 1; i < MAX_N; i++) FACTORIAL[i] = FACTORIAL[i - 1] * i % MOD;
        MODULAR_INVERSE[0] = 1;
        MODULAR_INVERSE[N] = pow(FACTORIAL[N], MOD - 2);
        for (int i = N - 1; i > 0; i--)
            MODULAR_INVERSE[i] = MODULAR_INVERSE[i + 1] * (i + 1) % MOD;
    }

    private static long binomial_coefficient(int n, int r) {
        if (n < 0 || r < 0) return 1;
        return FACTORIAL[n] * MODULAR_INVERSE[r] % MOD * MODULAR_INVERSE[n - r] % MOD;
    }

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            int A = sc.nextInt();
            int B = sc.nextInt();
            pre(H + W - 2);
            long ans = 0;
            for (int i = B + 1; i <= W; i++) {
                ans += binomial_coefficient(H - A + i - 2, i - 1) * binomial_coefficient(A + W - i - 1, A - 1) % MOD;
                ans %= MOD;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 25940
import sys
LI = lambda : [int(x) for x in sys.stdin.readline().split()]

N,M = LI()
island = [0 for _ in range(N)]
req = [[] for _ in range(N)]
for _ in range(M):
    a,b = LI()
    req[a-1].append(b-1)

p = 1
ans = 0
for i in range(N):
    if island[i] > p:
        ans += 1
        p = island[i]
    for b in req[i]:
        island[b] = p+1
print(ans)

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



int main(){
  int n,inp,str,str2,str3,d;
  int a[101] = {};
  int b[101] = {};
  int c[101] = {};
  
  inp = 0;
  cin >> n;

  for(int i=0;i<=101;i++){
    a[i]=0;
    b[i]=0;
    c[i]=0;
  }
  cin >> str;
  if(str != 0){
    for(int i=0;i<str;i++){
      cin >> inp;
      a[inp] = 1;
    }
  }
    
  cin >> str2;
  if(str2 != 0){
    for(int i=0;i<str2;i++){
      cin >> inp;
      b[inp] = 1;
    }
  }
  
  cin >> str3;
  
  if(str3 != 0){
    for(int i=0;i<str3;i++){
      cin >> inp;
      c[inp] =1;
    }
  }
  d  = 0;
  for(int i=0;i<101;i++){
    if(b[i] == 1 && c[i] == 1)d++;
    if(a[i] == 0 && b[i] == 0 &&  c[i] == 1)d++;
  }


  cout << d << endl ;


}
  



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

const int mod = 1e9 + 7;

map<ll, ll> prime_factorization(ll n){
	map<ll, ll> ans;
	ll a = 2;
	while(n >= a*a){
		if(n % a == 0){
			ans[a]++;
			n /= a;
		}else{
			a++;
		}
	}
	ans[n]++;
	
	return ans;
}

int main(){
	int n;
	cin >> n;
	map<int, int> m;
	rep2(i, 1, n+1){
		map<ll, ll> ne_mp = prime_factorization(i);
		for(auto p : ne_mp){
			if(p.first == 1) continue;
			m[p.first] += p.second;
		}
	}
	
	ll ans = 1;
	for(auto p : m){
		ans = (ans * (p.second+1)) % mod;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VVI e(n, VI(n, 0));
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[a][b] = 1;
    e[b][a] = 1;
  }
  VI ord(n);
  iota(all(ord), 0);
  int ans = 0;
  do {
    if(ord[0] != 0) continue;
    bool flag = true;
    rep(i, ord.size()-1) {
      if(e[ord[i]][ord[i+1]] == 0) {
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  }while (next_permutation(all(ord)));

  out(ans);
  return 0;
}


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

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

Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<map>
#define MAX 10000000
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
struct edge{
	int cost,to;
};
typedef pair<int,int> p;
typedef pair<int,p> P;
//`Pbg@»ÝÌ@v
int main(){
	int tic,n,m,s,a,b,g,d[11][101],f;
	//d ticket place
	while(cin>>tic>>n>>m>>s>>g,tic||n||m||s||g){
		s--;g--;
		//tic `Pbg
		//n Ì
		//m ´Ì
		//s¨g
		vector<edge> v[101];
		rep(i,m){
			cin>>a>>b>>f;
			a--;b--;
			edge c;
			c.cost=f;
			c.to=b;v[a].push_back(c);
			c.to=a;v[b].push_back(c);
		}
		rep(i,tic+1)
		rep(j,n){
			if(j==s)
			d[i][j]=0;
			else
			d[i][j]=MAX;
		}
		int nowticket,nowplace,nowsum;
		priority_queue<P,vector<P>,greater<P> > que;
		P now;
		que.push(P(tic,p(s,0)));
		while(!que.empty()){
			now=que.top();
			que.pop();
			nowticket=now.first;
			nowplace=now.second.first;
			nowsum=now.second.second;
			if(d[nowticket][nowplace]<nowsum)
				continue;
			rep(i,(int)v[nowplace].size()){
				edge e=v[nowplace][i];
				if(nowticket>0){
					if(d[nowticket-1][e.to]>e.cost/2+nowsum){
						d[nowticket-1][e.to]=e.cost/2+nowsum;
						que.push(P(nowticket-1,p(e.to,d[nowticket-1][e.to])));
					}
				}
				if(d[nowticket][e.to]>e.cost+nowsum){
						d[nowticket][e.to]=e.cost+nowsum;
						que.push(P(nowticket,p(e.to,d[nowticket][e.to])));
				}
			}
		}
		int mi=100000000;
		rep(i,tic+1)
		mi=min(mi,d[i][g]);
		cout<<mi<<endl;
	}
	return 0;
}

Measured memory_bytes: 932
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

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

const int N=1000005;
int a[N],b[3],c[3],d[3],p[3],q[3],n,x,y;
char s[N];

int main(){
	scanf("%s",s+1);
	for(int i=1;s[i];i++)
		if(s[i]!=s[i-1])a[++n]=s[i]-'A',b[a[n]]++;
	REP(i,3)p[i]=i;
	sort(p,p+3,[&](int x,int y){
		return b[x]<b[y];
	});
	if(!b[p[0]])return 0;
	REP(i,3)q[p[i]]=i;
	rep(i,1,n)a[i]=q[a[i]],c[a[i]]++;
	for(int l=1,r;l<=n;l++)
		if(a[l]){
			r=l;
			while(r<n&&a[r+1])r++;
			if(1<l&&r<n&&l==r&&a[l]==2)y++;
			else{
				if(l<r||l==r&&a[l]==1)x++;
				if(a[l]==2&&c[2]>c[1])a[l]=-1,c[2]--;
				if(a[r]==2&&c[2]>c[1])a[r]=-1,c[2]--;
			}
			l=r;
		}
	int t=max(0,y-x);
	for(int i=2;i<=n-1&&t;i++)
		if(!a[i-1]&&!a[i+1]&&a[i]==2)
			a[i]=a[i-1]=-1,c[0]--,c[2]--,t--;
	int nn=0;
	rep(i,1,n)
		if(a[i]>=0)a[++nn]=a[i];
	n=nn;
	assert(c[1]==c[2]);
	for(int l=1,r;l<=n;l++)
		if(a[l]){
			r=l;
			while(r<n&&a[r+1])r++;
			int t=min((l==1||r==n?(r-l+1)/2:(r-l)/2),c[1]-c[0]);
			for(int i=l;t;i+=2)
				a[i]=a[i+1]=-1,c[1]--,t--;
			l=r;
		}
	rep(i,1,n)
		if(a[i]!=-1)putchar('A'+p[a[i]]);
	puts("");
	return 0;
}

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


void solve(std::vector<long long> x){
    for (int i = 0; i < 5; i++)
    {
        if (x[i] == 0){
            cout << i+1 << endl;
        }
    }
    
}

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


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S, T;
	cin >> S >> T;

	cout << T << S << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		int tmp = 0;
		if (S[i] == 'A') {
			tmp++;
			i++;
			bool flag = 1;
			while (flag) {
				if (i >= S.size()-1)break;
				if (S[i] == 'A') {
					tmp++;
					i++;
				}
				else if (S[i] == 'B'&&S[i + 1] == 'C') {
					ans += tmp;
					i += 2;
				}
				else {
					flag = 0;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int A[100100];
    int B[100100];
    rep(i, n+1) cin >> A[i];
    rep(i, n) cin >> B[i];
    
    ll ans = 0;
    for(int i = n-1; i>=0; --i) {
        int al, ar, b;
        ar = A[i+1];
        al = A[i];
        b = B[i];

        if (b >= ar) {
            ans += ar;
            b -= ar;
            if (b >= al) {
                ans += al;
                A[i] = 0;
            } else {
                ans += b;
                A[i] -= b;
            }
        } else {
            ans += b;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
   ll n,k;
   cin>>n>>k;
   ll arr[n],i,j;
   for(i=0;i<n;i++)
   {
       cin>>arr[i];
   }

   ll d[n+1]={0};
   for(i=1;i<=n;i++)
   {
       d[i] = d[i-1]+arr[i-1];
   }
   ll ans=0;
   for(i=0;i<=n;i++)
   {
       if(d[i]<=k)
       {
           ans++;
       }
   }
   cout<<ans<<endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {


    int D, N;
    cin >> D >> N;

    if(D==0){
        if(N==100)cout << N+1 << endl;
        else cout << N << endl;
    }else if(D==1){
        if(N==100)cout << N*100+100 << endl;
        else cout << N*100 << endl;

    }else{
        if(N==100)cout << N*10000+10000 << endl;
        else cout << N*10000 << endl;
    }


    

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		String S = sc.next();
		int count=0;
		int ans =0;
	
		char [] a= S.toCharArray();
		 for(int i=0;i<a.length; i++) {

			 if(a[i]=='A' ||a[i]=='C' ||a[i]=='G'||a[i]=='T') {
				 count++;
			 }else {
				 if(ans<count) {
					 ans=count;
					 count=0;
					 
				 }
			 }
			
		 }
		 if(ans<count) {
			 ans=count;
		 }
		 System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#4問目
N = int(input())
A = list(map(int, input().split()))
result = sum(A)
dictionaly = {}
for i in A:
    dictionaly[i] = dictionaly.get(i, 0) + 1
RESULT = []
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    sub = C - B
    if B in dictionaly:
        result += (dictionaly[B] * sub)
        dictionaly[C] = dictionaly.get(C,0) + dictionaly[B]
        dictionaly[B] = 0
    RESULT.append(result)
for i in RESULT:
    print(i)

Measured memory_bytes: 94448
n = int(input())
h = list(map(int, input().split()))
ans_list = [0] * len(h)

for i in range(len(h)-2, -1, -1):
    if h[i] >= h[i+1]:
        ans_list[i] = ans_list[i+1] + 1

print(max(ans_list))


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,ans,tmp,hoge,fuga,piyo,sum;
ll A[200100],B[200100],C[200100],D[200100];
string st,str;
char ch;
long double dd;
int main(){
  cin>>a>>st;
  ans=a*int(st[0]-'0');
  d+=10*a*int(st[2]-'0');
  d+=a*int(st[3]-'0');
  d/=100;
  cout<<ans+d;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N;cin>>N;
  int T[110];

  int sum=0;
  for(int t=0;t<N;t++){
    cin>>T[t];
    sum+=T[t];
  }

  int M;cin>>M;
  queue<int>q;
  for(int t=0;t<M;t++){
    int p,x;cin>>p>>x;
    p--;
    int temp=sum;
    temp-=T[p];
    temp+=x;
    q.push(temp);
  }

  while(!q.empty()){
    cout<<q.front()<<endl;
    q.pop();
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
b = [int(i) for i in input().split()]
L = []

f = True

for _ in range(N):
  index = 0
  for i, bi in enumerate(b):
    if i+1 < bi:
      f = False
    if i+1 == bi:
      index = i
  L.append(index+1)
  del b[index]

if f:
  L.reverse()
  for l in L:
    print(l)
else:
  print(-1)

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

string s;
int now=0;

string solve();
string fplus();
string sub();
string rev();

int main(){
  int i;
  while(1){
    cin >> s;
    if(s==".")break;
    now=0;
    cout << solve() << endl;
  }
  return 0;
}

string solve(){
  string ans;
  while(now<s.size()){
    now++;
    if((s[now-1]>='A'&&s[now-1]<='Z')||s[now-1]=='?')ans+=s[now-1];
    else if(s[now-1]=='+')ans+=fplus();
    else if(s[now-1]=='-')ans+=sub();
    else if(s[now-1]=='[')ans+=rev();
  }
  for(int i=0;i<ans.size();i++)if(ans[i]=='?')ans[i]='A';
  return ans;
}
string fplus(){
  string ans;
  now++;
  if(s[now-1]=='+')ans=fplus();
  else if(s[now-1]=='-')ans=sub();
  else ans = s[now-1];

  if(ans=="Z")ans="A";
  else if(ans=="?")ans="?";
  else ans=ans[0]+1;
  return ans;
}
string sub(){
  string ans;
  now++;
  if(s[now-1]=='+')ans=fplus();
  else if(s[now-1]=='-')ans=sub();
  else ans = s[now-1];

  if(ans=="A")ans="Z";
  else if(ans=="?")ans="?";
  else ans=ans[0]-1;
  return ans;
}
string rev(){
  string ans;
  while(s[now]!=']'){
    now++;
    if((s[now-1]>='A'&&s[now-1]<='Z')||s[now-1]=='?')ans+=s[now-1];
    else if(s[now-1]=='+')ans+=fplus();
    else if(s[now-1]=='-')ans+=sub();
    else if(s[now-1]=='[')ans+=rev();
  }
  now++;
  reverse(ans.begin(),ans.end());
  return ans;
}



Measured memory_bytes: 3172
#include<stdio.h>
#include<stdbool.h>

int main(void){
    bool flag = false;
    int count = 0;
    int a[3][3];
    int x[3][3]={{0,0,0},{0,0,0},{0,0,0}};
    scanf("%d",&a[0][0]);
    scanf("%d",&a[0][1]);
    scanf("%d",&a[0][2]);
    scanf("%d",&a[1][0]);
    scanf("%d",&a[1][1]);
    scanf("%d",&a[1][2]);
    scanf("%d",&a[2][0]);
    scanf("%d",&a[2][1]);
    scanf("%d",&a[2][2]);
    int n;
    scanf("%d",&n);
    int b[n];
    for(int i=0;i<n;++i){
        scanf("%d",&b[i]);
    }
    for(int j=0;j<3;++j){
        for(int k=0;k<3;++k){
            for(int l=0;l<n;++l){
                if(a[j][k]==b[l]){
                    x[j][k]=1;
                }
            }
        }
    }
    for(int m=0;m<3;++m){
        count += x[0][m];
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    for(int n=0;n<3;++n){
        count += x[1][n];
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    for(int m1=0;m1<3;++m1){
        count += x[2][m1];
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    for(int n1=0;n1<3;++n1){
        count += x[n1][0];
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    for(int n2=0;n2<3;++n2){
        count += x[n2][1];
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    for(int n3=0;n3<3;++n3){
        count += x[n3][2];
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    for(int x1=0;x1<3;++x1){
        count += x[x1][x1];
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    int x3=0;
    for(int x2=2;x2>=0;x2--){
        count += x[x3][x2];
        x3++;
    }
    if(count==3){
        flag = true;
        count = 0;
    }else{
        count=0;
    }

    if(flag){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	static boolean[] visited;
	static int N;
	static int M;
	static boolean[][] graph;
	static boolean[][] test;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		M=sc.nextInt();
		visited=new boolean[N+1];
		graph=new boolean[N+1][N+1];	//隣接行列
		test=new boolean[N+1][N+1];
		int[][] path=new int[M][2];

		for(int i=0; i<=N; i++) {		//グラフの初期化
			for(int j=0; j<=N; j++) {
				graph[i][j]=false;
			}
		}

		for(int i=0; i<M; i++) {		//入力
			int from=sc.nextInt();
			int to=sc.nextInt();
			graph[from][to]=true;
			graph[to][from]=true;
			path[i][0]=from;
			path[i][1]=to;
		}

		boolean connected=true;		//連結であるという過程で解く
		int count=0;		//橋の数

		visited[0]=true;	//ぬさもとりあへず
		for(int h=0; h<M; h++) {
			for(int i=0; i<=N; i++) {
				for(int j=0; j<=N; j++) {
					test[i][j]=graph[i][j];		//データをコピー
				}
			}
			connected=true;
			test[path[h][0]][path[h][1]]=false;		//パスを引っこ抜く
			test[path[h][1]][path[h][0]]=false;

			for(int i=1; i<=N; i++) {		//訪問初期化
				visited[i]=false;
			}
			dfs(1);	//1から始める（実際問題どこでもいい）

			for(int i=1; i<=N; i++) {		//連結判定
				if(!visited[i]) {
					connected=false;
					break;
				}
			}
			//System.out.println(connected);	//for debug
			if(connected==false) {
				count++;
			}
		}
		System.out.println(count);

	}
	static void dfs(int x) {		//訪問していくDFS
		if(visited[x]) {
			return;		//すでに訪問している時はみない
		}
		visited[x]=true;		//まだ訪れてないなら　今訪れたのでtrueにする
		for(int i=1; i<=N; i++) {
			if(test[x][i]) {		//訪問できるところを訪問する
				dfs(i);
			}
		}
	}

}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,a;
	bool f=true;
	int k,sum=0;
	cin>>s>>k;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)!="1"){
			if(f){
				a=s.substr(i,1);
				f=false;
			}
		}else{
			if(f) sum++;
		}
	}
	if(sum>=k){
		cout<<1<<endl;
	}else{
		cout<<a<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 500

int N;
int C[MAX + 1];
ll S[MAX + 1];
int F[MAX + 1];

int main() {
  scanf("%d", &N);
  rep(i,N-1) cin >> C[i] >> S[i] >> F[i];

  rep(i,N-1) {
    ll tt = S[i] + C[i];
    for(int j = i+1; j < N-1; ++j) {
      ll c = tt - S[j];

      if (c < 0) {
        tt = S[j] + C[j];
        continue;
      }

      if (c % F[j] > 0) {
        ll next = F[j] - (c % F[j]);
        tt = tt + next + C[j];
      } else {
        tt = tt + C[j];
      }

    }

    cout << tt << endl;
  }

  cout << "0" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  int N, i = 0;
  cin >> N;
  vector<int> A(N);
  for(; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[N - 1] - A[0] << endl;
}

Measured memory_bytes: 256
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      lf                  long float
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main(){
   InTheNameOfGod

       ll test=1;
       //cin>>test;
       while(test--){
           ll n,i,j;
           string s;
           cin>>n;
           ll divs[n+5]={0};
           ll ans=0;
           for(i=1;i<=n;i++){
            for(j=i;j<=n;j+=i){
                divs[j]++;
            }
           }
           for(i=1;i<=n;i++)
            ans+=i*divs[i];
           cout<<ans<<endl;
        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 81776
//
// Created by 江口慎悟 on 2019-04-06.
//
#include <vector>
#include <iostream>
using namespace std;
void a(){

    vector<int> antena(5);
    for(int i = 0; i < 5; i++){
        cin >> antena[i];
    }
    int k; cin >> k;

    bool ok =(antena[4] - antena[0] <= k);

    if (ok)
        cout << "Yay!";
    else
        cout << ":(";

}

void b(){


    int time_sum = 0;
    int max_loss = 0;
    int loss_sum = 0;
    for(int i = 0; i < 5; i++){
        int time; cin >> time;
        time_sum += time;
        int loss = (10 - time%10)%10;
        max_loss = (max_loss > loss)? max_loss:loss;
        loss_sum += loss;
    }

    int ans = time_sum + loss_sum - max_loss;

    cout << ans;
}
int main(){

    b();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(Math.max(a + b, Math.max(a - b, a*b)));
	}

}


Measured memory_bytes: 23124
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    int N;
    cin>>N;
    int a[15];
    a[0]=1;
    for(int i=1;i<=6;++i) a[i]=pow(6,i);
    for(int i=7;i<=11;++i)a[i]=pow(9,i-6);

    int dp[15][100010];

    //dp 初期化
    for(int i=1;i<15;++i)     dp[i][0]=0;
    for(int j=0;j<100010;++j) dp[1][j]=j;

    for(int j=1;j<100010;++j){
        for(int i=2;i<15;++i){
            if(j>=a[i-1])dp[i][j]=min(dp[i][j-a[i-1]]+1,dp[i-1][j]);
            else         dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[12][N]<<endl;
    return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  std::map<ll, ll> mcnt;
  for (ll i = 0; i < N; i++) {
    if (va[i] <  400) {mcnt[0]++; continue; }
    if (va[i] <  800) {mcnt[1]++; continue; }
    if (va[i] < 1200) {mcnt[2]++; continue; }
    if (va[i] < 1600) {mcnt[3]++; continue; }
    if (va[i] < 2000) {mcnt[4]++; continue; }
    if (va[i] < 2400) {mcnt[5]++; continue; }
    if (va[i] < 2800) {mcnt[6]++; continue; }
    if (va[i] < 3200) {mcnt[7]++; continue; }
    mcnt[8]++;
  }

  ll ans = 0LL;
  for (ll c = 0; c < 8; c++) {
    if (mcnt[c] > 0) ans++;
  }

  ll ans_min = std::max(1LL, ans);
  ll ans_max = ans + mcnt[8];

  print(ans_min, ans_max);
  return 0;
}


Measured memory_bytes: 256
A,B,C = input().split()

A = int(A)
B = int(B)
C = int(C)

NpoisunCookie   = A + B 
beautifulCookie = B + C

if C <= A+B:
  print(beautifulCookie)
else:
  print(C-(C-(A+B)) + B + 1)



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

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,l;
  cin>>n>>l;
  vector<Int> d(n);
  for(Int i=0;i<n;i++) cin>>d[i];
  vector<Int> x(n,1);
  for(Int i=n-1;i>0;i--){
    if(x[i]<=d[i]-x[i]) x[i-1]=x[i];
    else x[i-1]=x[i]+d[i];
  }
  vector<Int> y(n+1,l);
  for(Int i=0;i<n;i++)
    y[i+1]=min(abs(y[i]-d[i]),y[i]);
  
  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int p;
    cin>>p;
    p--;
    //cout<<y[p]<<" "<<x[p]<<endl;
    cout<<(y[p]>=x[p]?"YES":"NO")<<endl;
  }
  return 0;
}


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

int main() {

	while (1) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		for (int i = 1; i <= a; i++) {
			if (i==1||i==a){
				for (int j = 1; j <= b; j++) {
					cout << "#";
				}
				cout << endl;
			}
			else {
				cout << "#";
				for (int j = 1; j <= b-2; j++) {
					cout << ".";
				}
				cout << "#" << endl;
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
  int n,b;
  cin >> n >> b;
  int res = 0;
  if(n <= 5) {
    res = 0;
  } else if(n <= 12){ 
    res = b/2;
  } else {
    res = b;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#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++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    rep(i, n-1){
        cin >> c[i] >> s[i] >> f[i];
    } 
    
    rep(i, n){
        int ans = 0;
        REP(j, i, n-1){
            if(ans < s[j]){
                ans = s[j];
            }
            else if(ans % f[j] == 0){
                ;
            }
            else{
                ans += f[j] - ans%f[j];
            }
            ans += c[j];
        }
        cout << ans << endl;
    }


    return 0;
}

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

using namespace std;

int main() {

	int N, M;
	cin>>N>>M;
	vector<int> A(N);
	int ans = 0;
	double total = 0;
	for (auto& x : A) {
		cin>>x;
		total += x;
	}

	total /= (4*M);
	for (auto& x : A) {
		if ((double)x >= total) {
			ans += 1;
		}

		if (ans >= M) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}

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


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int a, b;
    cin >> a >> b;
    string s, t;

    forn(i, b) s.push_back(a + '0');
    forn(i, a) t.push_back(b + '0');

    cout << (s <= t ? s : t) << endl;

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int>ans(n);
    int cnt=0;
    rep(i,n){
        if(s[i]=='R')cnt++;
        else{
            ans[i]+=cnt/2;
            ans[i-1]+=(cnt+1)/2;
            cnt=0;
        }
    }
    reverse(ans.begin(),ans.end());
    reverse(s.begin(),s.end());
    rep(i,n){
        if(s[i]=='L')cnt++;
        else{
            ans[i]+=cnt/2;
            ans[i-1]+=(cnt+1)/2;
            cnt=0;
        }
    }
    reverse(ans.begin(),ans.end());
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


ll ans(int x, int y, vector<string> &p, vector<vector<ll>> &memo){
  if(memo[x][y]!=-1) return memo[x][y];

  int r=p.size();
  int c=p[0].size();
  if(x==r-1 && y==c-1) return 1;

  ll rtn=0;
  if(x+1<r && p[x+1][y]=='.') rtn+=ans(x+1,y,p,memo);
  if(y+1<c && p[x][y+1]=='.') rtn+=ans(x,y+1,p,memo);
  if(rtn>=mod) rtn%=mod;
  memo[x][y]=rtn;
  return rtn;
}



int main() {
  int r,c;
  cin>>r>>c;

  vector<string> p(r);
  rep(i,r){
    cin>>p[i];
  }

  vector<vector<ll>> memo(r,vector<ll>(c,-1));

  cout << ans(0,0,p,memo) << endl;
}


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

using namespace std;

int fact(int n);

int nC2(int n)
{
    if(n<3) return 0;
    return (n*(n-1)) / 2;
}

// Returns factorial of n
int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    cout<<"fact of "<<n<<" is "<<res<<endl;
    return res;
}

int main()
{
    int n,m,ways=0;
    cin>>n>>m;
    if(n<3||m<3)
    {
        if(n<3)
        {
            if(n==2)
                ways+=1;
        }
        if(m<3)
        {
            if(m==2)
                ways+=1;
        }
    }

    cout<<ways+nC2(n)+nC2(m)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, Q;
    cin >> n >> m >> Q;
    vvi grid(n, vi(n));
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        grid[l][r]++;
    }
    vvi sm(n+1, vi(n+1));
    rep(i, n) rep(j, n) sm[i+1][j+1] = sm[i][j+1] + sm[i+1][j] - sm[i][j] + grid[i][j];

    while (Q--) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        int ans = sm[n][q+1] - sm[n][0] - sm[p][q+1] + sm[p][0];
        cout << ans << endl;
    }

}

Measured memory_bytes: 2944
m, d = gets.split.map(&:to_i)
cnt = 0
d10 = d/10
d1 = d - d10 * 10
for i in 1..d
  d10 = i/10
  d1 = i - d10 * 10
  for j in 1..m
    if d1 >= 2 && d10 >= 2 && d1*d10 == j
      cnt += 1
    end
  end
end
puts cnt

Measured memory_bytes: 1788
// atcoder/abc174/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, k;
  while (cin >> n >> k) {
    vec<lli> a(n);
    cin >> a;

    auto fn = [&] (lli x) {
      lli y = 0;
      each (i, a) {
        if (i % x) y += i / x;
        else y += max<lli>(0LL, (i / x) - 1);
      }
      return y <= k;
    };

    lli small = 0;
    lli large = 1LL << 60;
    while (small + 1 < large) {
      lli mid = (small + large) / 2;
      if (fn(mid)) large = mid;
      else small = mid;
    }
    cout << large << endl;
  }

  return 0;
}


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

int main()
{
ll n;
  cin>>n;
  
    ll a[n+1];
    ll b[n+1];
    ll c[n+1];
    
    ll dp1[n+1];
    ll dp2[n+1];
    ll dp3[n+1];
    
    
    ll i;
    i=1;
    while(i<=n)
    {
        cin>>a[i]>>b[i]>>c[i];
        i++;
    }
    dp1[1]=a[1];
    dp2[1]=b[1];
    dp3[1]=c[1];
    i=2;
    while(i<=n)
    {
        dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
        dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
        dp3[i]=c[i]+max(dp1[i-1],dp2[i-1]);
        
        
        i++;
    }
    
    
    
    cout<<max(dp1[n],max(dp2[n],dp3[n]));
    
    
  
 return 0; 
}




Measured memory_bytes: 4992
# 入力文字列
get_str = list(input())

# 操作回数
N = int(input())

# リバースフラグ
r_flag = 0

left_str = []
right_str = []
# 操作
for i in range(N):
    # 取得操作
    inp_cmd = list(input().split())
    # inp_cmd[0] = 1 ならリバースフラグ更新
    if(inp_cmd[0] == '1'):
        r_flag = (r_flag+1) % 2
    else:
        # inp_cmd[1]=1、かつリバースフラグなし
        # inp_cmd[1]=2、かつリバースフラグあり
        # 先頭に文字追加
        if((inp_cmd[1] == '1' and r_flag == 0) or (inp_cmd[1] == '2' and r_flag == 1)):
            left_str.append(inp_cmd[2])
        # 上記以外は後ろに追加
        else:
            right_str.append(inp_cmd[2])

# 左文字列リストを反転
left_str = left_str[::-1]

# 文字列結合
list_str = []
list_str = left_str + get_str + right_str

# リバースフラグあり
if(r_flag == 1):
    list_str = list_str[::-1]

out_str = ''.join(list_str)
print(out_str)

Measured memory_bytes: 9868