akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

int main(){
   string s;
   cin >> s;
   for(int i=1;i<s.size();i++){
      if(s[i]==s[i-1]){
         cout << "Bad" << endl;
         return 0;
      }
   }
   cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        ll ans = 0;
        rep(i, 0, N) {
                ll l, r;
                cin >> l >> r;
                ans += r - l + 1;
        }
        cout << ans << endl;
}

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

int main(void){
    long long  x,n;
    std::cin >> x;
    n = x;

    for(int i = 1; i <= sqrt(x); i++){
        if(x%i == 0){
            long long c = ((x/i)-1) + (i-1);
            n = std::min(n,c);
        }
    }

    std::cout << n << std::endl;

    
    
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
cin>>head;
CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(x,y);
  if(x%y==0){COUT(-1);return 0;}
  else{
    for(ll i=0;i*x<LINF;i++){
      if((i*x)%y != 0){COUT(i*x);return 0;}
    }
  }


  return 0;
}


Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,k,i,j,nishin,x:Integer;
  s:string;
begin
  try
    { TODO -oUser -cConsole Main : わからん。 }
    Read(n);
    Readln(k);

    n:=n-1;
    while n<>0 do begin //バラバラにせず間に合う？
      nishin := n mod 2;
      n := n div 2;
      s := IntToStr(nishin) + s;
    end;

    x:=k;//普通は1
    k:=k-1;
    while s<>'' do begin
      if s[Length(s)]='1' then begin
        x:=x*k;
      end;
      k:=k*k;
      if (x<0)or (x>2147483646) then begin //いらない？
        x:=2147483647;
        break;
      end;
      Delete(s,length(s),1);
    end;

    Writeln(x);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1Uint << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1Uint << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1Uint << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define int ll
#define double ld
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    int i = 0, j = 0, k = 2*n;
    bool turn = true;
    while (k--)
    {
        turn = !turn;
        if (!turn) { cout << a[i]; i++; }
        else { cout << b[j]; j++; }
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  int sum=0;
  for(int i=0;i<x;i++){
    if(x%(i+1)==0 && i+1!=1 && i+1!=x) {
      x++;
      i=0;}
    else if(x%(i+1)!=0) {
      sum+=1;
      if(sum==x-2) {
        break;}}
    }
  cout << x << endl;
  }
    

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define PI acos(-1)

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  double ans;
  // 台形
  if (2 * x >= a * a * b) {
    ans = (PI / 2 - atan(a * a * a / (2 * (a * a * b - x)))) * 180 / PI;
  } else {
    ans = (PI / 2 - atan(2 * x / (a * b * b))) * 180 / PI;
  }

  printf("%.10f\n", ans);
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {

	var N, K int
	fmt.Scan(&N, &K)
	sweetsCount := make([]int, N, N)
	for i := 0; i < K; i++ {
		var sweetsNum int
		fmt.Scan(&sweetsNum)
		for j := 0; j < sweetsNum; j++ {
			var snuke int
			fmt.Scan(&snuke)
			sweetsCount[snuke-1]++
		}
	}

	ans := 0
	for _, v := range sweetsCount {
		if v == 0 {
			ans++
		}
	}

	fmt.Println(ans)
}


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

int Parent(int i){
  return i/2;
}

int Left(int i){
  return 2*i;
}

int Right(int i){
  return 2*i+1;
}

int check(int n,int i){
  if(n>=Right(i)) return 1;
  else if(n>=Left(i) && n<Right(i)) return 2;
  else if(n<Left(i)) return 3;
}

void Print(int *A, int n){
  int i;
  
  for(i=1;i<=n;i++){
    if(Parent(i)==0){
      if(check(n,i)==1) printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i],A[Left(i)],A[Right(i)]);
      else if(check(n,i)==2) printf("node %d: key = %d, left key = %d, \n",i,A[i],A[Left(i)]);
      else if(check(n,i)==3) printf("node %d: key = %d, \n",i,A[i]);
    }
    else{
      if(check(n,i)==1) printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[Parent(i)],A[Left(i)],A[Right(i)]);
      else if(check(n,i)==2) printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[Parent(i)],A[Left(i)]);
      else if(check(n,i)==3)printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[Parent(i)]);
    }
  }
}

main(){
  int n,i;
  int *A;

  scanf("%d",&n);

  A=(int *)malloc((n+1)*sizeof(int));

  for(i=1;i<=n;i++) scanf("%d",&A[i]);

  Print(A,n);

  return 0;
}

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

public class Hello
{
    public static void Main()
    {
        var p = GeneratePrime(50);
        var a = new int[15];
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 2; i <= n; i++) getA(a, p, i);
        var ans = getAns(a);
        Console.WriteLine(ans);
    }
    static int getAns(int[] a)
    {
        var k = new int[] { 2, 4, 14, 24, 74 };
        var d = new Dictionary<int, int>();
        foreach (var x in k) d[x] = 0;
        for (int i = 0; i < a.Length; i++)
            foreach (var x in k)
                if (a[i] >= x) d[x]++;
        var a1 = d[74];
        var a2 = d[24] * (d[2] - 1);
        var a3 = d[14] * (d[4] - 1);
        var a4 = d[4] * (d[4] - 1) / 2 * (d[2] - 2);
        return a1 + a2 + a3 + a4;
    }
    static void getA(int[] a, List<int> p, int t)
    {
        var tp = t;
        var pc = p.Count();
        for (int i = 0; i < pc; i++)
        {
            if (p[i] > t) break;
            while (true)
                if (tp % p[i] == 0) { tp /= p[i]; a[i]++; }
                else break;
        }
    }
    public static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Math.Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
}


Measured memory_bytes: 13280
import math


n = int(input())
o = n / 1.080

o_floor = math.floor(o)
o_ceil = math.ceil(o)

if math.floor(o_floor * 1.08) == n:
    print(o_floor)

elif math.floor(o_ceil * 1.08) == n:
    print(o_ceil)

else:
    print(':(')

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;
typedef long long int lli;
typedef long int li;
const int inf = numeric_limits<int>::max();



int main(){
    lli x;
    cin>>x;
    lli a = x/500;
    x = x%500;
    lli b = x/5;
    cout<<((1000*a)+5*b);

}



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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long int ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
ll A[200010];
ll sum[200010];
bool used[200010];
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
        sum[i+1] = sum[i] + A[i];
    }
    ll l=0,r=2;
    ll ans=inf;

    REP(l2,2,N-1){
        ll mn = min(sum[l], (sum[l2] - sum[l]));
        ll mx = max(sum[l], (sum[l2] - sum[l]));
        ll mn2 = min(sum[r]-sum[l2], (sum[N]-sum[r]));
        ll mx2 = max(sum[r]-sum[l2], (sum[N]-sum[r]));
        while(abs(sum[l]-(sum[l2]-sum[l])) > abs(sum[l+1]-(sum[l2]-sum[l+1]))) {
            l++;
            mn = min(sum[l], (sum[l2] - sum[l]));
            mx = max(sum[l], (sum[l2] - sum[l]));
        }
        while(abs(sum[r]-sum[l2]-(sum[N]-sum[r]))>abs(sum[r+1]-sum[l2]-(sum[N]-sum[r+1]))) {
            r++;
            mn2 = min(sum[r]-sum[l2], (sum[N]-sum[r]));
            mx2 = max(sum[r]-sum[l2], (sum[N]-sum[r]));
        }
        ans=min(ans,max(mx,mx2)-min(mn,mn2));
    }
    p(ans);

    return 0;
}

Measured memory_bytes: 3328
def solve(m,ab):
    ans = 0
    for n in ab:
        if m == 0:
            break
        c = min(m,n[1])
        m -= c
        ans += c * n[0]
    return ans


def main():
    N,M = map(int, input().split())
    ab = []
    for _ in range(N):
        a,b = map(int, input().split())
        ab.append((a,b))
    ab.sort(key=lambda x: x[0])
    print(solve(M,ab))

if __name__ == '__main__':
    main()

Measured memory_bytes: 18152
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k, l;
  
  ll N, A, B;
  cin >> N >> A >> B;
  string s;
  cin >> s;
  ll ca=0, cb=0;
  
  vector<ll> v;
  for(i=0; i<N; i++) {
    if(s[i]=='c') {
      v.push_back(0);
    }else if(s[i]=='a') {
      
      if(ca+cb<A+B) {
        v.push_back(1);
        ca++;
      }else {
        v.push_back(0);
      }
      
    }else if(s[i]=='b') {
      
      if(ca+cb<A+B && cb<B) {
        v.push_back(1);
        cb++;
      }else {
        v.push_back(0);
      }
      
    }
  }
  
  for(i=0; i<N; i++) {
    if(v[i]) pt("Yes");
    else pt("No");
  }
  
}




Measured memory_bytes: 1652
#include<iostream>
using namespace std;
static const long long prime = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7;
typedef long long ll;
ll pow(long long a, long long n, long long p) {
    if (n == 0)
        return 1;
    if (n % 2 == 1) {
        ll b = (a * pow(a, n - 1, p)) % p;
        return b;
    }
    else {
        long long t = pow(a, n / 2, p);
        return (t * t) % p;
    }
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll caseA = 1;
    ll X = 1, Y = 1;
    ll k = pow(2, prime, prime);
    for (ll i = 0; i < a; i++)
    {
        X *= (n - i);
        X %= prime;
        Y *= (1 + i);
        Y %= prime;
    }
    caseA = X * pow(Y, prime - 2, prime) % prime;

    ll caseB = 1;
    X = 1;
    Y = 1;
    for (ll i = 0; i < b; i++)
    {
        X *= (n - i);
        X %= prime;
        Y *= (1 + i);
        Y %= prime;

    }
    ll p = pow(2, n, prime);
    caseB = X * pow(Y, prime - 2, prime) % prime;
    ll ans = p - caseA - caseB - 1;

    ans = ans % prime;
    if (ans < 0)
    {
        ans += prime;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int a = 0, b = 0; string s; cin >> s;
	Rep(i, 4){
		if(s[i] == '+'){
			a++;
		}else{
			b++;
		}
	}
	cout << a - b << endl;
}

Measured memory_bytes: 256
from collections import deque
l = [i for i in range(1,10)]
deque = deque(l)
cnt = 9

def lunlun(i):
    s =str(i)
    s_last=int(s[-1])
    if s_last == 0:
        s1 = s + str(s_last)
        s2 = s + str(s_last + 1)
        return int(s1),int(s2)
    elif s_last == 9:
        s0 = s + str(s_last - 1)
        s1 = s + str(s_last)
        return int(s0),int(s1)
    else:
        s0 = s + str(s_last - 1)
        s1 = s + str(s_last)
        s2 = s + str(s_last + 1)
        return int(s0),int(s1),int(s2)

while cnt <= 10**5:
    num = deque.popleft()
    t = list(lunlun(num))
    cnt += len(t)
    l.extend(t)
    deque.extend(t)

k = int(input())
print(l[k-1])

Measured memory_bytes: 7916
#include <algorithm>
#include <iostream>
#include <cstdio>

char ch;
template <typename T>
void read(T& x)
{
    x = 0;
    ch = getchar();
    int minus = 0;
    for (; !isdigit(ch); minus |= (ch == '-'), ch = getchar());
    for (; isdigit(ch); x = x * 10 + (ch ^ 48), ch = getchar());
    if (minus)
        x = -x;
}

int n, m, ans, s;
int a[1000010], d[1000010];

int main()
{
    read(n), read(m);
    for (int i = 1; i <= m; ++i)
        read(a[i]);
    if (n >= m)
    {
        printf("0\n");
        return 0;
    }
    std::sort(a + 1, a + m + 1);
    for (int i = 1; i < m; ++i)
        d[i] = a[i + 1] - a[i], s += d[i];
    std::sort(d + 1, d + m);
    for (int i = m - 1, cnt = 1; i && cnt < n; --i, ++cnt)
        ans += d[i];
    printf("%d\n", s - ans);
    return 0;
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9+7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def dfs_1(s,p): #部分木のサイズを数えるdfs
    par[s] = p
    for v in edges[s]:
        if v == p:
            continue
        size[s] += dfs_1(v,s)
    return size[s]

def dfs_2(s,p): #1を根としたときに進む向きのdp計算用dfs
    dp1[s] = fact[size[s]-1]
    for v in edges[s]:
        if v == p:
            continue
        dp1[s] *= dfs_2(v,s)
        dp1[s] %= mod
        dp1[s] *= pow(fact[size[v]], mod-2, mod)
        dp1[s] %= mod
    return dp1[s]

def comb(n,r):
    return fact[n]*pow(fact[r],mod-2,mod)*pow(fact[n-r],mod-2,mod) % mod

def bfs(s): #dp1と逆向きに進むdp計算用bfs
    que = deque()
    que.append((s,-1))
    while que:
        v,p = que.popleft()
        if v == 0:
            dp2[v] = dp1[v]
        else:
            inv = (dp2[p]*pow((dp1[v]*comb(n-1,size[v]))%mod,mod-2,mod)) % mod
            dp2[v] = (dp1[v]*inv*comb(n-1,size[v]-1)) % mod
        for u in edges[v]:
            if u == p:
                continue
            que.append((u,v))
n = I()
fact = [1]*(n+1)
par = [None]*n
for i in range(1,n+1):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

edges = [[] for _ in range(n)]
size = [1]*n
dp1 = [0]*n #1を根としたときに進む向きのdp
for _ in range(n-1):
    a,b = LI()
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

dfs_1(0,-1)
dfs_2(0,-1)
dp2 = [0]*n
bfs(0)
for i in dp2:
    print(i)




Measured memory_bytes: 152796
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    string s;
    cin>>s;
    long long int n=s.size(),ans=0;
    vector<int> dp(n);
    map<int,int> h;
    map<int,int>::iterator it;
    dp[n-1]=int(s[n-1]-'0');
    long long int x=10;
    for(int i=n-2;i>=0;i--)
    {
        dp[i]=((x*(int(s[i]-'0')))+(dp[i+1]))%2019;
        x*=10;
        x%=2019;
    }
    for(int i=n-1;i>=0;i--)
        h[dp[i]]++;
    for(it=h.begin();it!=h.end();it++)
    {
        long long int k=it->second;
        if(it->first==0)
            ans+=k;
        if(k>1)
            ans+=((k*(k-1))/2);
    }
    //for(int i=n-2;i>=0;i--)
    //    cout<<dp[i]<<" ";
    //cout<<endl;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4360
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007

void solve()
{
    int n,w;cin>>n>>w;
    int wt[n],val[n];
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    int dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(wt[i-1]<=j)
                dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;

    while(t--)
    {
      solve();
    }
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int a=0;
    int b=s.length();
    for (int i = 0; i < b ;i++)
    {
        if (s[i]!=t[i])
        {
            a++;
        }
        
    }
    
    cout<<a<<endl;

    return 0;
}


Measured memory_bytes: 3916
# stack
exp = input().split()
s = []

for lt in exp:
    if lt.isdigit():
        s.append(int(lt))
    else:
        rhs = s.pop()
        lhs = s.pop()
        if lt == '+':
            s.append(lhs + rhs)
        if lt == '*':
            s.append(lhs * rhs)
        if lt == '-':
            s.append(lhs - rhs)
        
print(str(s[0]))

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("dichromatic.in","r",stdin)
#define OUT freopen("dichromatic.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define sq(x)  ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

#define maxn 200005

char s[maxn] , t[maxn] ;
int a[maxn] , b[maxn] ;

bool f(int n, int pos , int lim)
{
    int left = 1 , right = lim ;

    for(int i=n ; i>=1 ; i--)
    {
        if( b[i]== 1 ) left-- ;
        if( b[i]==-1 ) right++ ;

        left = max(left,1) ;
        right = min(right,lim) ;

        if(a[i]==1) right-- ;
        if(a[i]==-1) left++ ;

        if( right<left ) return 0 ;
    }
    if( left <= pos && pos <= right ) return true ;
    return false ;
}

int main()
{
    int h , w , n , sr , sc ;

    scanf("%d %d %d",&h,&w,&n) ;
    scanf("%d %d",&sr,&sc) ;
    scanf("%s %s",s,t) ;

    int res = 1 ;

    for(int i=1 ; i<=n ; i++)
    {
        if( s[i-1]=='L' ) a[i] = -1 ;
        else if( s[i-1]=='R' ) a[i] = 1 ;
        else a[i] = 0 ;

        if( t[i-1]=='L' ) b[i] = -1 ;
        else if( t[i-1]=='R' ) b[i] = 1 ;
        else b[i] = 0 ;
    }

    res &= f(n,sc,w) ;

    for(int i=1 ; i<=n ; i++)
    {
        if( s[i-1]=='U' ) a[i] = -1 ;
        else if( s[i-1]=='D' ) a[i] = 1 ;
        else a[i] = 0 ;

        if( t[i-1]=='U' ) b[i] = -1 ;
        else if( t[i-1]=='D' ) b[i] = 1 ;
        else b[i] = 0 ;
    }

    res &= f(n,sr,h) ;

    if(res) printf("YES\n") ;
    else printf("NO\n") ;

    return 0 ;
}


Measured memory_bytes: 2176
a,b,c=map(int,input().split())
import sys
if a%2+b%2+c%2>0:
    print(0)
    sys.exit()
e=0

while e<10000:
    a,b,c=b//2+c//2,a//2+c//2,a//2+b//2
    e+=1
    if a%2+b%2+c%2>0:
        break

if e==10000:
    print(-1)
else:
    print(e)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 1;
  for(int i = 0; i < n; i++){
    if(ans*2>ans+k){
      ans = ans+k;
    }else{
      ans = ans * 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N,X;
	cin>>N>>X;
	int m;
	int i;
	int aw=N;
	int minM=100000;
	for (i=0;i<N;i++){
		cin>>m;
		X-=m;
		if (minM>m){
			minM=m;
		}
	}
	aw+=X/minM;
	cout<<aw<<endl;

	return 0;
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T> inline bool chkmax(T &x, const T &y){ return y > x ? x = y, 1 : 0; }
template <typename T> inline bool chkmin(T &x, const T &y){ return y < x ? x = y, 1 : 0; }

#ifdef ONLINE_JUDGE
#define debug(...) ;
#else
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG
#endif

//---------------------------------------------------------head----------------------------------------------------

LL ans;
LL pw[19];
LL D;

void calc(LL l)
{
	static int dlt[10];
	LL res = 1ll;
	LL D = ::D;
	forn(i, 0, (l - 1) / 2)
	{
		dlt[i] = D / pw[i] % 10;
		D -= dlt[i] * (pw[l - 1 - i] - pw[i]) / 9ll;
	}
	if(D) return;

	forn(i, 0, (l - 1) / 2)
	{
		int lb = i ? 0 : 1, rb = 9;
		lb += dlt[i], rb += dlt[i];
		if(lb < 0) lb = 0;
		if(rb > 9) rb = 9;
		if(lb > rb) return;
		res *= 1ll * (rb - lb + 1);
	}
	ans += res;
	return;
}

int main()
{
	scf(D);
	if(D % 9){ puts("0"); return 0; }
	D /= 9;
	pw[0] = 1ll;
	forn(i, 1, 18) pw[i] = pw[i - 1] * 10ll;
	cerr<<pw[18]<<endl;
	forn(l, 1, 18) calc(l);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
template <typename T>
struct BinaryIndexedTree
{
  vector<T> data;

  BinaryIndexedTree(ll sz)
  {
    data.assign(++sz, 0);
  }

  T sum(ll k)
  {
    T ret = 0;
    for (++k; k > 0; k -= k & -k)
      ret += data[k];
    return (ret);
  }

  void add(ll k, T x)
  {
    for (++k; k < data.size(); k += k & -k)
      data[k] += x;
  }
};
int main()
{
string s ;
cin >> s ;
vector<ll> v(26);
rep(i,s.size()){
  v[s[i]-'a']++;
}
ll odd=0;ll m=-1;
rep(i,26)if(v[i]%2){odd++;m=i;}
if((s.size()%2&&odd!=1)||(s.size()%2==0&&odd!=0)){
cout << -1 << endl;
return 0;
}
rep(i,26)v[i]/=2;
vector<ll> k(s.size());
rep(i,s.size()){
  ll t=s[i]-'a';
  if(v[t]==0&&t!=m)k[i]=2;
  else if(v[t]==0&&t==m){k[i]=1;m=-1;}
  else {k[i]=0;v[t]--;}
}
ll cnt=0;
rep(i,s.size()){
  if(k[i]!=0)cnt++;
  else ans+=cnt;
}
cnt=0;
rep(i,s.size()){
  if(k[i]==2)cnt++;
  if(k[i]==1)ans+=cnt;
}
BinaryIndexedTree<ll> bit(s.size()/2 +1);
queue<ll> d[26];
cnt=0;
rep(i,s.size()){
  if(k[i]==0){d[s[i]-'a'].push(cnt);cnt++;}
}
cnt=0;
for (ll i = s.size()-1; i >= 0; i--)
{
  if(k[i]==2){
    bit.add(d[s[i]-'a'].front(), 1);
    ans += cnt + 1 - bit.sum(d[s[i]-'a'].front());
    d[s[i]-'a'].pop();
    cnt++;
  }
}
cout << ans << endl;
return 0;
}

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

using namespace std;

class Shop {
public:
	int value;
	int left;

	Shop(int value, int left) :value(value), left(left) {};
};

bool ope(Shop shop1, Shop shop2) {
	return shop1.value < shop2.value;
}

int main()
{
	/*
		ABC121C問題

	*/
	int n, need;
	cin >> n >> need;

	vector<Shop> shops;
	shops.reserve(n);

	int value, left;
	for (int i = 0; i < n; i++) {
		cin >> value >> left;
		shops.push_back(Shop(value, left));
	}

	sort(shops.begin(), shops.end(), ope);

	long long cost = 0;
	int visitNum = 0;
	while (true) {
		if (shops[visitNum].left >= need) {
			cout << cost + (long long)need * shops[visitNum].value;
			return 0;
		}
		else {
			cost += (long long)(shops[visitNum].left) * shops[visitNum].value;
			need -= shops[visitNum].left;
			visitNum++;
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; ++i)  cin >> s[i];
    int WhiteCnt = 0;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(s[i][j] == '.')  ++WhiteCnt;
        }
    }
    vector<vector<int>> dist(h, vector<int>(w, INF));
    dist[0][0] = 0;
    queue<P> que;
    que.emplace(0, 0);
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        for(int i = 0; i < 4; ++i){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w)  continue;
            if(s[nx][ny] == '#')    continue;
            if(chmin(dist[nx][ny], dist[x][y] + 1)){
                que.emplace(nx, ny);
            }
        }
    }
    int ans = WhiteCnt - dist[h - 1][w - 1] - 1;
    if(dist[h - 1][w - 1] == INF)   ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.math.*;
import java.io.*;
import java.util.*;
import java.lang.*;


public class Main {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		if(n<1200)	System.out.println("ABC");
		else System.out.println("ARC");

	}

}

Measured memory_bytes: 9684
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include <iomanip>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(int argc, const char *argv[]){
    int n, q;
    cin >> n >> q;
    vector<int> a(n), b(n);
    vector<int> o(n,-1);
    vector<ll> p(q), x(q);
    rep(i,n-1) cin >> a[i] >> b[i];
    rep(i,q) cin >> p[i] >> x[i];
    vector<ll> c(n,0),ans(n,0);
    
    
    rep(i,n-1)o[b[i]-1] = a[i]-1;
    rep(i,q) c[p[i]-1] += x[i];
    ans[0] = c[0];
    rep1(i,n) ans[i] = c[i]+ans[o[i]];
    rep(i,n-1) cosp(ans[i]);
    co(ans[n-1]);
    return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,ans=0,N;
    cin>>n;
    N=n;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0&&i<n/i-1){ans+=n/i-1;}
    }
    cout<<ans;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
lst = [0 for _ in range(n)]
dlst = []
for _ in range(k):
  d = int(input())
  dlst.append(list(map(int, input().split())))

dlst = sum(dlst, [])
dlst = set(dlst)
print(n - len(dlst))

Measured memory_bytes: 9188
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, T, A, MIN;
	map<int, int> mp;
	cin >> N >> T >> MIN;
	for (int i = 1; i < N; i++) {
		cin >> A;
		mp[A - MIN]++;
		MIN = min(MIN, A);
	}
	auto it = mp.end();
	it--;
	cout << it->second;
}

Measured memory_bytes: 4992
using static Modulo;
using static System.Math;
using System;

class Modulo
{
    public const int MOD = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b) => (int)(BigMul(a, b) % MOD);
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
            m_facs[i] = Mul(m_facs[i - 1], i);
    }
    public int Fac(int n) => m_facs[n];
    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        if (n < k) { Console.WriteLine(0); goto exit; }
        var md = new Modulo(n);
        var ans = (long)md.Pow(k, n);
        for (int i = 1; i <= n - 1; i++)
        {
            var w = (long)md.Ncr(k, i);
            w *= md.Pow(k - i, n);
            w %= MOD;
            if (i % 2 == 1) { ans -= w; if (ans < 0) ans += MOD; ans %= MOD; }
            else { ans += w; ans %= MOD; }
        }
        Console.WriteLine(ans);
        exit:;
    }
}


Measured memory_bytes: 18012
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
first = 0
second = 0
former_second = 0
count = 0
for i in range(0, N):
    first = min(A[i] - former_second, B[i])
    second = min(A[i + 1], B[i] - first)
    former_second = second
    count += first + second

print(count)



Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	ll pmax = 0;
	ll pmin = 9999999999;
	rep(i, 0, N) {
		ll a;
		cin >> a;
		pmax = max(pmax, a);
		pmin = min(pmin, a);
	}
	cout << pmax - pmin << endl;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> v(n, 1);
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'R') {
      v[i + 2] += v[i];
      v[i] = 0;
    }
  }
  for (int i = n - 1; i > 0; i--) {
    if (s[i] == 'L' && s[i - 1] == 'L') {
      v[i - 2] += v[i];
      v[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << v[i] << " \n"[i == n - 1];
  }

  return 0;
}


Measured memory_bytes: 1024
count = 0
ans = 0
s = input()
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        if i != len(s)-1:
            count += 1
        else:
            count += 1
            ans = max(ans,count)
    else:
        ans = max(ans,count)
        count = 0
print(ans)

Measured memory_bytes: 3064
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int x;
int ar[N];
int dp[N];

int main(){
    scanf("%d%d" , &n , &x);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
    }
    dp[1] = 0;
    for(int i = 2; i <= n+1; i++){
        dp[i] = dp[i - 1] + ar[i - 1];
    }
    int cnt = 0;
    for(int i = 1; i <= n+1; i++){
        //cout << dp[i] << " ";
        if(dp[i] <= x){
            cnt++;
        }
    }
    printf("%d\n" , cnt);
}


Measured memory_bytes: 256
import sys
n = int(input())
A = list(map(int,input().split()))
ans = 10**18
tmp = 1

if 0 in A:
    print(0)
else:
    for i in range(n):
        tmp *= A[i]
        if tmp > ans:
            print(-1)
            sys.exit()
    print(tmp)

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

int can_make(vector<int> v, int resolution) {
  int x = 0;
  sort(v.begin(), v.end(), greater<int>());
  for (int e : v) {
    if (x < resolution)
      x += e;
    else
      x -= e;
  }
  return x == resolution;
}

int main() {
  string s;
  int x, y;
  cin >> s >> x >> y;
  s += 'T';
  x -= s.find('T');
  s = s.substr(s.find('T') + 1);
  vector<int> vertical, horizontal;
  bool is_vertical = true;
  int count = 0;
  for (auto c : s) {
    if (c == 'T') {
      (is_vertical ? vertical : horizontal).push_back(count);
      is_vertical = not is_vertical;
      count = 0;
    } else {
      ++count;
    }
  }
  cout << (can_make(vertical, y) and can_make(horizontal, x) ? "Yes" : "No")
       << endl;

  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int d = 'A' - 'a';
	printf("%c%c%c\n", a[0] + d, b[0] + d, c[0] + d);
}


Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let B = read::<i32>();
    let mut counter = 0;

    for n in A..B+1 {
        let S = n.to_string();
        let S = S.chars().collect::<Vec<char>>();
        if S[0] == S[4] && S[1] == S[3] {
            counter += 1;
        }
    }
    println!("{}", counter);

}


Measured memory_bytes: 4352
h, k = [int(i) for i in input().split()]

if h == 1 or k == 1:
    print(1)
elif h%2 == 0:
    print(int(int(h//2)*k))
else:
    if k%2 == 0:
        print(int(h*int(k//2)))
    else:
        print(int(h*int(k//2)+int(h//2)+1))

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

using namespace std;

int main()
{
    long long x,y,count;
    cin>>x>>y;
    if((x*y)==0){
        if(y>=x){
            count=abs(abs(x)-abs(y));
            cout<<count<<endl;
        }
        else{
            count=abs(abs(x)-abs(y))+1;
            cout<<count<<endl;
        }
    }
    else if((x*y)<0){
        count=abs(abs(x)-abs(y))+1;
        cout<<count<<endl;
    }
    else{
        if(x>=0 && y>=0){
            if(y>=x){
                count=abs(y-x);
                cout<<count<<endl;
            }
            else{
                count=abs(abs(x)-abs(y))+2;
                cout<<count<<endl;
            }
        }
        else if(x<0 && y<0){
            if(x>y){
                count=abs(abs(x)-abs(y))+2;
                cout<<count<<endl;
            }
            else{
                count=abs(abs(x)-abs(y));
                cout<<count<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);rep(i,n){cin>>a[i];}
    ll cnt = 1;
    ll res = 0;
    rep(i,n){
        if(a[i]==cnt){
            cnt++;
        }else if(cnt==1){
            res += a[i] - 1;
            cnt++;
        }else{

            res += a[i]/cnt;
            if(a[i]%cnt==0){
                res--;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
ll mod = 1e9+7;

int main(){
	string t,b;
	cin>>t>>b;
	ll n1 = t.size(),n2 = b.size();
	vector<vector<ll > > dp(n1,vector<ll> (n2,0) );
	for(int i=0;i<n1;i++){
		if(t[i]==b[0])	dp[i][0] = 1;
	}
	if(n1 < n2){
		cout<<0<<endl;
		return 0;
	}
	for(int i=1;i<n2;i++){
		ll sum = 0;
		for(int j=0;j<i;j++) {
			sum+=dp[j][i-1];
			sum%=mod;
		}
		for(int j=i;j<n1;j++){
			if(t[j]==b[i]) {
				dp[j][i] = sum;
			}
			sum+=dp[j][i-1];
			sum%=mod;
		}
	}
	ll res = 0;
	/*for(int i=0;i<n2;i++){
		for(int j=0;j<n1;j++){
			cout<<dp[i][j]<<' ';
		}
		cout<<endl;
	}*/
	for(int i=0;i<n1;i++) {
		res += dp[i][n2-1];
		res %= mod;
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 10692
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

ans = 0
(A+1).times { |a|
    (B+1).times { |b|
        (C+1).times { |c|
            if a*500+b*100+c*50 == X then
                ans += 1
            end
        }
    }
}

puts ans

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;
 
int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
 
    //vector<pair<int, bool> > v(n);
    int i = 0;
    int j = 0;
    int ans = 0;
    while(j < n){
        while(j < n && s[j] == '1')
            ++ j;
        ans = max(ans, j - i);
        while(j < n && s[j] == '0')
            ++ j;
        -- k;
        if(k < 0){
            while(i < n && s[i] == '1')
                ++ i;
            while(i < n && s[i] == '0')
                ++ i;
        }
        ans = max(ans, j - i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 512