akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    s = f.read_str()
    w = f.read_int()
    return ''.join(s[::w])


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s;
  cin >> s;
  int n = s.length();
  int res[n];
  fill(res,res+n,-1);
  int cnt_1 = 0;
  for(int i=n-1;i>=0; i--){
    if(s[i]=='p'){
      res[i] = 1;
      cnt_1++;
    }else{
      if(cnt_1){
        res[i] = 0;
        cnt_1--;
      }
    }
  }
  int balance = 0;
  REP(i,n){
    switch(res[i]){
      case 0: balance++; break;
      case 1: balance--; break;
      default:
      if(balance){
        res[i] = 1;
        balance--;
      }else{
        res[i] = 0;
        balance++;
      }
    }
  }
  int ans = 0;
  REP(i,n){
    if(s[i]=='g'&&res[i]==1) ans++;
    if(s[i]=='p'&&res[i]==0) ans--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a= gi();
	    int b= gi();
	    int c= gi();

        if ((a==b+c)||(b==a+c)||(c==b+a)) {
	        System.out.print("Yes");
        } else {
        	System.out.print("No");
        }
	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35376
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int p[11],c[11];
int d,g;

int solve(int x);

int main(){


  cin>>d>>g;
  g /= 100;

  REP(i,11){
    p[i] = 0;
    c[i] = 0;
  }

  REP(i,d){
    int x,y;
    cin>>x>>y;
    p[i+1] = x;
    c[i+1] = y/100;
  }
  int ans = INF;
  REP(i,pow(2,d)){
    ans = min(ans,solve(i));
  }
  cout<<ans<<endl;

  return 0;
}


int solve(int x){
  int t = x;
  int maxx = 0;
  int sum = 0;
  int ans = 0;
  REP(i,d){
    if(t%2 == 0){
      maxx = i+1;
    }else{
      sum += p[i+1] * (i+1) + c[i+1];
      ans += p[i+1];
    }
    t /= 2;
  }

  if(sum>= g){
    return ans;
  }

  if((sum +maxx * (p[maxx] -1) >= g)){
    return ans + (g-sum +maxx-1)/maxx;
  }
  return INF;

}

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

using namespace std;
// using P = pair<long, long>;
using P = pair<double, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

vector<int> G[200005];

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

  int a;
  cin >> a;

  bool canDo = false;

  int kosu = a/100;
  int amari = a - (kosu*100);
  if (amari > kosu*5) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 4992
n = int(input())
t, a = map(int,input().split())
a *= 1000
t *= 1000
h = list(map(int,input().split()))

diff = 1e9
ans = 0
for i in range(n):
  h[i] = t - h[i] * 6
  if abs(a - h[i]) < diff:
    diff = abs(a - h[i])
    ans = i + 1
  
print(ans)


Measured memory_bytes: 3060
A, B = map(int, input().split())

total = 0

for i in range(A, B + 1):
    str_i = str(i)
    length = len(str_i)
    half = length // 2
    rev = str_i[::-1]
    if str_i[:half] == rev[:half]:
        total += 1

print(total)

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

#define ll long long

signed main() {
  int a,b,c;
  cin >> a >> b >> c;

  if(a == b && b == c)
  {cout << 1 << endl;}

  else if(a == b || b == c || a == c)
  {cout << 2 << endl;}

  else{cout << 3 << endl;}
}

Measured memory_bytes: 3580
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N = int(input())
A = lmi()


# dp = [[-INF]*3 for _ in range(N)]
def solve2():
    """

6
1 2 3 4 5 6
>> 12
6
2 1 3 4 5 6
>> 12
    :return:
    """
    assert N % 2 == 0
    even = [0]
    odd = [0]
    for v in range(N):
        if v % 2 == 0:
            even.append(even[-1] + A[v])
        else:
            odd.append(odd[-1] + A[v])

    # print(even)
    # print(odd)
    ans = 0
    for i in range(len(even)):
        ans = max(ans, even[i] + odd[-1] - odd[i])
    print(ans)


def solve():
    # dp[N][ignored]
    dp = [[-INF] * 3 for _ in range(N // 2 + 1)]
    dp[0][0] = 0
    dp[0][1] = 0
    dp[0][2] = 0

    for v in range(N):
        for ignore_count in range(3):
            if ignore_count == 0:
                flag = (v < N - 1 and v % 2 == 0)
                dp_slice = v // 2
            elif ignore_count == 1:
                flag = (v % 2 == 1)
                dp_slice = v // 2
            else:  # ignore_count == 2:
                flag = (v > 1 and v % 2 == 0)
                dp_slice = v // 2 - 1
            if flag:
                dp[dp_slice + 1][ignore_count] = max(dp[dp_slice][ignore_count] + A[v], dp[dp_slice + 1][ignore_count])
                if ignore_count != 2:
                    dp[dp_slice + 1][ignore_count + 1] = max(dp[dp_slice + 1][ignore_count],
                                                             dp[dp_slice + 1][ignore_count + 1])
                # if ignore_count==0:
                #     dp[dp_slice + 1][2] = max(dp[dp_slice + 1][ignore_count],
                #                                              dp[dp_slice + 1][2])

                # if ignore_count:
                #     dp[dp_slice + 1][ignore_count] = dp[dp_slice][ignore_count - 1]
    if N % 2 == 1:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))


if N % 2 == 1:
    solve()
else:
    solve()



Measured memory_bytes: 98772
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int X, K;
int r[100000];
int Q;
int t[100000], a[100000];
vector<P> query;	//(時刻, 内容(-1:ひっくり返す, a[i](>=0):求める))

signed main() {
	int i;
	
	cin >> X >> K;
	rep(i, K) cin >> r[i]; cin >> Q; rep(i, Q) cin >> t[i] >> a[i];
	rep(i, K) query.push_back(P(r[i], -1));
	rep(i, Q) query.push_back(P(t[i], a[i]));
	sort(query.begin(), query.end());
	
	int l = 0, r = X, b = 0, c = X;
	int dx = -1, prevT = 0;
	
	rep(i, query.size()) {
		int qt = query[i].first;
		int qa = query[i].second;
		
		//更新
		if (dx == -1) {
			int cnt1 = min(b, qt - prevT);
			int cnt2 = qt - prevT - cnt1;
			b -= cnt1;
			c -= cnt1 + cnt2; if (c < b) c = b;
			l = min(l + cnt2, r);
		}
		else {
			int cnt1 = min(X - c, qt - prevT);
			int cnt2 = qt - prevT - cnt1;
			c += cnt1;
			b += cnt1 + cnt2; if (b > c) b = c;
			r = max(r - cnt2, l);
		}
		prevT = qt;
		
		//cout << "debug[l, r, b, c, dx, prevT, qa] = [" << l << ", " << r << ", " << b << "," << c << ", " << dx << ", " << prevT << ", "<< qa << "]" << endl;
		//クエリ
		if (qa == -1) {
			dx *= -1;
		}
		else {
			if (qa <= l) cout << b << endl;
			else if (qa >= r) cout << c << endl;
			else cout << b + (qa - l) << endl;
		}
	}
	return 0;
}

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

int main(){
    ll n, a;
    map<ll,int> cnt1, cnt2;

    cin >> n;

    for(int i=1;i<=n;i++){
        cin >> a;
        cnt1[i+a]++;
        cnt2[i-a]++;
    }

    ll acm = 0, qtd;
    for(auto p:cnt1){
        qtd = cnt2[p.first];
        acm += qtd*(p.second);
    }  

    cout << acm << '\n';

    return 0;
}


Measured memory_bytes: 37896
n = list(map(int, list(input())))
k = int(input())
le = len(n)
dp = [[[0] * (le + 2) for _ in range(2)] for _ in range(le + 1)]
dp[0][0][0] = 1
for i in range(1, le + 1):
    for j in range(2):
        for s in range(le + 1):
            m = 10
            if j == 0:
                m = n[i - 1] + 1
            for t in range(m):
                x, y = 1, s
                if j == 0 and t == m - 1:
                    x = 0
                if not t == 0:
                    y += 1
                dp[i][x][y] += dp[i - 1][j][s]
ans = dp[le][0][k] + dp[le][1][k]
print(ans)

Measured memory_bytes: 3428
#include <stdio.h>

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D

int main(int argc, char **argv) {
    int n, minv, maxp, i, x;
    scanf("%d", &n);
    scanf("%d", &minv);
    maxp = -1000000000;
    for (i = 1; i < n; i++) {
        scanf("%d", &x);
        if (x - minv > maxp)
            maxp = x - minv;
        if (x < minv)
            minv = x;
    }
    printf("%d\n", maxp);
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string t,u;
    cin>>t>>u;
    
    if (t[0] == u[2] && t[1] == u[1] && t[2] == u[0])cout << "YES" << endl;
    else cout << "NO" << endl;
        
    return 0;
}



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


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	for(int i=0; i<k; i++) {
		if(b <= a) {
			b *= 2;
		}
		else{
			c *= 2;
		}
	}
	if(b > a && c > b) {
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define db(x) cerr<<#x<<" = "<<x<<'\n'
using namespace std;

const int MAX=1e5+5,MOD=1e9+7;

int n,mark[MAX],fact[MAX],inv[MAX];

int mul(int x,int k) {
	if(k==0)
		return 1;
	int tmp=mul(x,k/2);
	if(k%2==0)
		return tmp*tmp%MOD;
	return tmp*tmp%MOD*x%MOD;
}

int C(int n,int k) {
	if(n<k)
		return 0;
	return fact[n]*inv[k]%MOD*inv[n-k]%MOD;
}

int32_t main() {
	//freopen("input","r",stdin);
	cin>>n;
	fact[0]=inv[0]=1;
	for(int i=1;i<=n+1;i++) {
		fact[i]=fact[i-1]*i%MOD;
		inv[i]=mul(fact[i],MOD-2);
	}
	int x,l,r;
	for(int i=1;i<=n+1;i++) {
		cin>>x;
		if(mark[x]==0)
			mark[x]=i;
		else {
			l=mark[x];
			r=i;
		}
	}
	for(int i=1;i<=n+1;i++) {
		int rs=(C(n+1,i)-C(l-1+n+1-r,i-1)+MOD)%MOD;
		cout<<rs<<'\n';
	}
}


Measured memory_bytes: 5924
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define rep1(i, n) for (int i=1; i <= n; i ++)
#define _min(x, y) x = min(x, y)
#define _max(x, y) x = max(x, y)
using namespace std;


int main() {
  int n; cin >> n;
  int max_move = 0;
  int now_move = 0;
  int prev_h = -1;
  rep(i, n) {
    int h; cin >> h;
    if (h <= prev_h) {
      now_move += 1;
    } else {
      max_move = _max(max_move, now_move);
      now_move = 0;
    }
    prev_h = h;
  }
  max_move = _max(max_move, now_move);
  cout << max_move << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC099_B solver = new ABC099_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC099_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int snow = 0;
            for (int i = b - a; i > 0; i--) {
                snow += i;
            }

            out.print(snow - b);

        }

    }
}



Measured memory_bytes: 21204
n,x = map(int,input().split())

def layers(L):
  if L == 0:
    return 1
  else:
    return layers(L-1)*2+3
  
def patties(L,X):
  if L == 0:
    return 1
  elif X == 1:
    return 0
  elif X <= layers(L)//2:
    return patties(L-1,X-1)
  elif X == layers(L)//2+1:
    return layers(L-1)//2+2
  elif layers(L)//2+2 <= X <= layers(L)-1:
    return layers(L-1)//2+2+patties(L-1,X-layers(L)//2-1) 
  else:
    return layers(L)//2+1
    
print(patties(n,x))

Measured memory_bytes: 3064
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unistd.h>
# include <unordered_map>
# include <unordered_set>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e18 + 5, NMAX = 1e6 + 5, MOD = 1000000007, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;

signed main() {
    fast_work

    int n;
    cin >> n;

    vector<pii> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i].f >> v[i].s;

    for(int i = 2; i < n; ++i) {
        if(v[i - 2].f == v[i - 2].s && v[i - 1].f == v[i - 1].s && v[i].f == v[i].s) return cout << "Yes", 0;
    }

    cout << "No";
}


Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.Read()
	k := stdin.ReadInt()

	m := len(n)
	ans := 0
	for x := 0; x < m; x++ {
		l := 0
		for i := 0; i < x; i++ {
			if n[i] != '0' {
				l++
			}
		}

		d := int(n[x] - '0')
		if d > 0 {
			ans += C(m-x-1, k-l-1) * Pow(9, k-l-1) * (d - 1)
			ans += C(m-x-1, k-l) * Pow(9, k-l)
		}
	}

	l := 0
	for _, ch := range n {
		if ch != '0' {
			l++
		}
	}
	if l == k {
		ans++
	}

	stdout.Println(ans)
}

func C(n, k int) int {
	if n == k || k == 0 {
		return 1
	}
	if n <= 0 || k < 0 || n < k {
		return 0
	}
	return C(n-1, k-1) + C(n-1, k)
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N;
int main() {
  cin >> N;
  long long c = 0, s = 0;
  for (int i=0; i<N; i++) {
    int a; cin >> a;
    if (a == 0) {
      c += s/2;
      s = 0;
    }
    else {
      s += a;
    }
  }
  c += s/2;
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l; cin >> l;
    bool start = false;
    struct Elem{
        int first, second, third;
        Elem(int f, int s, int t): first(f), second(s), third(t) { }
    };
    vector<Elem> anss;
    int cnt = 1, cost = 1, num = 1;
    for(int i = 30; i >= 0; i--){
        if(start){
            num++;
            anss.emplace_back(cnt, cnt + 1, 0);
            anss.emplace_back(cnt, cnt + 1, cost);
            // anss.emplace_back(cnt, cnt + 1, 1 << cost++);
            cnt++;
            cost *= 2;
        }
        if(l >>i & 1){
            if(start){
                anss.emplace_back(1, cnt, cost);
                cost++;
                // anss.emplace_back(1, cnt, 1 << cost++);
            }
            start = true;
        }
    }
    cout << num << ' ' << anss.size() << '\n';
    for(size_t i = 0; i < anss.size(); i++){
        cout << anss[i].first << ' ' << anss[i].second << ' ' << anss[i].third << '\n';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define esraa ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);

using namespace std;
const int N = 1e6+10, INF=9e9;
vector <long long> adj[N];
bool visited[N];
int nodesNum,edges,arr[N],ans=0;

void dfs(int node)
{
    if(visited[node])
        return;
    visited[node]=true;
    for(int child: adj[node])
    {
        if(!visited[child])
            dfs(child);

        arr[node]=max(arr[node],arr[child]+1);
    }
}

int main()
{
    esraa;
    cin>>nodesNum>>edges;
    for(int i=1; i<=edges; i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    for(int i=1; i<=nodesNum; i++)
    {
        if(!visited[i])
            dfs(i);
    }
    for(int i=1; i<=nodesNum; i++)
        ans=max(ans,arr[i]);
    cout<<ans<<"\n";


	return 0;
}


Measured memory_bytes: 32128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int H, W; cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }

    vector<tuple<int, int, int, int>> ans;
    for (int i = 0; i < H; i++) {
        if (i&1) {
            for (int j = W-1; j > 0; j--) {
                if (a[i][j]&1) {
                    a[i][j]--; a[i][j-1]++;
                    ans.push_back(make_tuple(i+1, j+1, i+1, j));
                }
            }
            if (i != H-1) {
                if (a[i][0]&1) {
                    a[i][0]--; a[i+1][0]++;
                    ans.push_back(make_tuple(i+1, 1, i+2, 1));
                }
            }
        }
        else {
            for (int j = 0; j < W-1; j++) {
                if (a[i][j]&1) {
                    a[i][j]--; a[i][j+1]++;
                    ans.push_back(make_tuple(i+1, j+1, i+1, j+2));
                }
            }
            if (i != H-1) {
                if (a[i][W-1]&1) {
                    a[i][W-1]--; a[i+1][W-1]++;
                    ans.push_back(make_tuple(i+1, W, i+2, W));
                }
            }
        }
    }

    cout << ans.size() << '\n';
    for (auto t : ans) {
        cout << get<0>(t) << ' ';
        cout << get<1>(t) << ' ';
        cout << get<2>(t) << ' ';
        cout << get<3>(t) << '\n';
    }


}

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

    solve();

    return 0;
}

Measured memory_bytes: 6336
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n,k;
    ll ans = -(1LL<<60);
    cin >> n >> k;
    vector<ll> a(n),s1(n+1,0),s2(n+1,0);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        s1[i+1] = s1[i] + a[i];
        if(a[i] >= 0) s2[i+1] = s2[i] + a[i];
        else s2[i+1] = s2[i];
    }
    for(int i = 0;i + k <= n;i++){
        int left = i,right = i+k;
        ll tmp = (s2[left]-s2[0]) + max(0LL,s1[right]-s1[left]) + (s2[n] - s2[right]);
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n,m,q;
	cin>>n>>m>>q;
	int memo[505][505]={},l,r;
	int ans[505][505]={};
	for (int i = 0; i < m; ++i)
	{
		cin>>l>>r;
		++ans[l][r];
	}
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			ans[i+1][j]+=ans[i][j];
		}
	}
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			ans[i][j+1]+=ans[i][j];
		}
	}
	for (int i = 0; i < q; ++i)
	{
		cin>>l>>r;--l;
		cout<<ans[r][r]-ans[l][r]-ans[r][l]+ans[l][l]<<endl;
	}
	return 0;
}


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

using namespace std;

int main(){
    int a,b;
    int d,r;
    double f;
    
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    cout << d << " " << r << " " << fixed << setprecision(5) << f;
    
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int h, n; cin >> h >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    vector<vector<ll> > dp(n + 1, vector<ll>(h + 1, 1000000000));

    dp[0][0] = 0;
    REP(i, n) {
        REP(k, h + 1) {
            dp[i + 1][k] = min(dp[i + 1][k], dp[i][k]);
            dp[i + 1][min(k + a[i], h)] = min(dp[i + 1][min(k + a[i], h)], dp[i + 1][k] + b[i]);
        }
    }
    
    cout << dp[n][h] << endl;
}


Measured memory_bytes: 78592
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	double num =(a[0] + a[1])*1.0/2 ;
	for(int i = 2;i < n;i++){
		num+=a[i];
		num/=2;
	}
	cout << num <<endl;
	return 0;
}

Measured memory_bytes: 256
n,l = gets.chop.split.map(&:to_i)

low=l+1-1
high=l+n-1

sum=(low+high)*n/2

res=0

if (low<=0 && high>=0)
  res=sum
elsif(low>0 && high>=0)
  res=sum-low
elsif(low<=0 && high<0)
  res=sum-high
end

puts res


Measured memory_bytes: 1788
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
         
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        ArrayList<Integer> a = new ArrayList<>();
        
        for(int i=0;i<n;i++){
        	a.add(sc.nextInt());
        }
        
        Pair[] q = new Pair[m];
        
        for(int i=0;i<m;i++){
        	q[i] = new Pair(sc.nextInt(),sc.nextInt());
        }
        
        Arrays.sort(q);
        
        int ad = 0;
        int idx = m-1;
        while(ad<n && idx>=0){
        	for(int i=0;i<q[idx].a && ad<n;i++){
        		a.add(q[idx].b);
        		ad += 1;
        	}
        	idx -= 1;
        }
        
        Collections.sort(a);
        
        long ans = 0;
        int l = a.size();
        for(int i=0;i<n;i++){
        	ans += a.get(l-1-i);
        }
        
        System.out.println(ans);

    }
	
}

class Pair implements Comparable<Pair>{
	int a,b;
	
	public Pair(int a, int b){
		this.a = a;
		this.b = b;
	}
	
	@Override
	public boolean equals(Object o){
		if(o instanceof Pair){
			Pair p = (Pair) o;
			return a == p.a && b == p.b;
		}
		return super.equals(o);
	}
	
	@Override
	public int compareTo(Pair o){
		return Integer.compare(b, o.b);
	}
	
	@Override
	public int hashCode(){
		return (a<<16)+b;
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

constexpr int mod = 1e9+7;

struct edge {
  int f,t,w;
  edge(int f, int t, int w) : f(f), t(t), w(w) {}
  bool operator < (const edge &e) const {
    return w < e.w;
  }
};

vector<edge> eg, unused;
vector<pair<int,int>> g[1005];

long long dist[1005][1005];

int gr[1005], n;
int fn(int x) {
  return x==gr[x]?x:gr[x]=fn(gr[x]);
}
void un(int x, int y) {
  gr[fn(x)] = gr[fn(y)];
}

long long pw(long long a, int n) {
  if(!n) return 1;
  if(n&1) return a*pw(a,n-1)%mod;
  return pw(a*a%mod,n/2);
}

void dijk(int fr, int to) {
  for(int i=1;i<=n;i++) dist[0][i] = 4e18;
  dist[0][fr] = 0;
  priority_queue<pair<int,int>> pq;
  pq.emplace(0,fr);
  while(!pq.empty()) {
    int w,t;
    tie(w,t) = pq.top();
    pq.pop();
    w = -w;
    if(dist[0][t] < w) continue;
    if(t == to) break;
    for(auto e : g[t]) {
      int ww = max(w, e.second);
      if(ww >= dist[0][e.first]) continue;
      dist[0][e.first] = ww;
      pq.emplace(-ww,e.first);
    }
  }
  dist[fr][to] = dist[0][to];
}

int main() {
  int m;
  long long X, mst=0;
  scanf("%d%d%lld",&n,&m,&X);
  for(int i=1;i<=n;i++) gr[i] = i;
  for(int i=0;i<m;i++) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    eg.push_back(edge(a,b,c));
  }
  sort(eg.begin(),eg.end());
  for(auto e : eg) {
    int x = e.f, y = e.t;
    if(fn(x) == fn(y)) {
      dijk(x,y);
      unused.push_back(e);
    } else {
      un(x,y);
      mst += e.w;
      g[x].emplace_back(y,e.w);
      g[y].emplace_back(x,e.w);
    }
  }
  int hi=0, eq=0;
  for(auto e : unused) {
    long long tmp = mst - dist[e.f][e.t] + e.w;
    if(tmp == X) eq++;
    if(tmp > X) hi++;
  }
  int ans = 0;
  while(eq--) {
    ans = (ans + pw(2,hi+eq)) % mod;
  }
  ans = ans*2%mod;
  if(X == mst) ans = (ans + (pw(2,n-1) - 2LL)*pw(2,unused.size()))%mod;
  printf("%d\n",ans);
}


Measured memory_bytes: 6016
n, k = gets.split.map(&:to_i)
trees = n.times.map{ gets.to_i }.sort
min = trees[-1] - trees[0]
(n-k+1).times do |i|
  dif = trees[i+k-1] - trees[i]
  if dif < min
    min = dif
  end
end
puts min

Measured memory_bytes: 4528
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int X;
    cin >> X;
    int mod = X % 100;
    int div = X / 100;
    cout << (div * 5 < mod ? 0 : 1) << endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		System.out.println(n.length() < 4 ? "ABC" : "ABD");

	}

}


Measured memory_bytes: 21204
typedef long long ll;
/*
id: sadykhzadeh -> Azer_Sadykhzadeh
Programming Language: C++
*/
#define qq2(x,y) cout << (#x) << " = " << (x) << '\t' << (#y) << " = " << (y) << endl
#define qq(x) cout << (#x) << " = " << (x) << endl
#define elif else if
#define pb push_back
#define ins insert
#define pow2(x) ((x)*(x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define rus_lang setlocale(LC_ALL , "Russian")
#define F_READ ios_base::sync_with_stdio(false);cin.tie(0)
#define MOD 1000000007
#define COUT(x) return cout << x << endl, 0;
#define stop return 0
using namespace std;

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define endl "\n"

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

string s;

int main(){
    cin >> s; set <char> a;
    for(ll i = 0; i < s.length(); i++){
        a.ins(s[i]);
    }
    if(a.size() == 2) cout << "Yes"; else cout << "No"; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int ans[110000];
int treesize[110000];
int root[110000];

struct Unionfind {
  vector<int> par;

  Unionfind(int n) : par(n) {
    rep(i,n) par[i] = i;
  }

  int root(int x) {
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx==ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  Unionfind tree(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree.unite(a,b);
    ans[a]--; ans[b]--;
  }
  rep(i,n) root[i] = tree.root(i);
  rep(i,k) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    if(root[c]==root[d]) {
      ans[c]--; ans[d]--;
    }
  }
  rep(i,n) treesize[root[i]]++;
  rep(i,n) {
    int r = root[i];
    ans[i] += (treesize[r] - 1);
  }
  rep(i,n) {
    cout << ans[i];
    if(i!=n-1) cout << " ";
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int ans = (n - 1 + k - 2) / (k - 1);
        System.out.println(ans);
    }
}

Measured memory_bytes: 59684
#include<bits/stdc++.h>
using namespace std;
string s="abcdefghijklmnopqrstuvwxyz";
int main(){
	long long n;
	cin>>n;
	string ans;
	while(n){
		n--;
		ans+=s[n%26];
		n/=26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3620
#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>

using namespace std;

typedef long long ll;

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    int v = i;
    while (v) {
      v /= 10;
      cnt++;
    }
    if (cnt % 2) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

#define LINE_BUF_SIZE 1024

int main(){

    int i,j,k;
    int length,first;
    long int N,value;
    char line[LINE_BUF_SIZE];
    int count = 0;

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%ld",&value);
    length = strlen(line);
    
        if(strncmp(&line[0],"2",1)==0){
            first = 2;
        }

        if(strncmp(&line[0],"3",1)==0){
            first = 3;
        }

        if(strncmp(&line[0],"4",1)==0){
            first = 4;
        }

        if(strncmp(&line[0],"5",1)==0){
            first = 5;
        }

        if(strncmp(&line[0],"6",1)==0){
            first = 6;
        }

        if(strncmp(&line[0],"7",1)==0){
            first = 7;
        }

        if(strncmp(&line[0],"8",1)==0){
            first = 8;
        }

        if(strncmp(&line[0],"9",1)==0){
            first = 9;
            count  = 1;
            for(j=1;j<length-1;j++){
                if(strncmp(&line[j],"9",1)==0){
                    count += 1;
                }
            }
        }

        if(strncmp(&line[0],"9",1)!=0){
            for(j=1;j<length-1;j++){
                    if(strncmp(&line[j],"9",1)==0){
                        count += 1;
                    }
            }
        }

  //printf("%d,%d\n",length,count);

    if(value < 10){
       printf("%ld",value);
        return 0;
    }

    if(count == length-1){  /*全て9の場合*/
        printf("%d",9*(length-1));
        return 0;
    }

    else if(strncmp(&line[0],"1",1)==0){    /*先頭が1の場合*/
        if(count == length-2){
            printf("%d",9*(length-2)+1);
            return 0;
        }
        printf("%d",9*(length-2));
        return 0;
    }

    else if(strncmp(&line[0],"9",1)==0){   /*先頭が9の場合で、全てが9ではない場合*/
            printf("%d",9*(length-2)+8);
            //printf("koko\n");
            return 0;
    }

    else if(count == length-2){
            printf("%d",9*(length-2)+first);
            //printf("koko");
            return 0;
        }

    else{   /*それ以外*/
        printf("%d",9*(length-2)+first-1);
    }

/*
    if(strncmp(&line[0],"1",1)==0 && (count != length-2)){
        printf("%d\n",9*(length-2));
    }

    else if(strncmp(&line[0],"1",1)==0 && (count == length-2)){
        printf("%d\n",9*(length-2)+first);
    }
    
    else if(strncmp(&line[0],"1",1)!=0 && (count == length-2)){
        printf("%d\n",9*(length-2)+first-1);
    }
    
    else if(first != 9 && (count == length-2)){
        printf("%d\n",9*(length-2)+(first-1));
    }

    else if(first == 9 && (count == length-1)){
        printf("%d\n",9*(length-1));
    }

    else if(first == 9 && (count != length-1)){
        printf("%d\n",9*(length-2)+(first-1));
    }
*/
//    printf("%d\n",first);
//    printf("%s\n", line);
//    printf("%ld\n", N);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int bcnt = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (cnt < a + b) {
      if (s[i] == 'a') {
        cout << "Yes" << ln;
        cnt++;
      } else if (s[i] == 'b' && bcnt < b) {
        cout << "Yes" << ln;
        bcnt++;
        cnt++;
      } else {
        cout << "No" << ln;
      }
    } else {
      cout << "No" << ln;
    }
  }

  return 0;
}

Measured memory_bytes: 848
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(0);
    int a;
    string s;
    cin >> a >> s;
    cout << ((a<3200)?"red":s) << endl;
}


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

int N;

char alt(char c){
  if(c+N > 90) return c+N-26;
  else return c+N;
}

int main(){
  cin >>N;
  string S;
  cin >>S;
  
  for(int i=0;i<S.size();i++){
    cout << alt(S[i]);
  }
  cout << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A, B = map(int, input().split())
    if A + B == 15:
        print("+")
    elif A * B == 15:
        print("*")
    else:
        print("x")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9956
a,b,m = map(int,input().split())

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

xyc = [ list(map(int,input().split())) for _ in range(m) ]

ma = min(a)
mb = min(b)

cost = ma + mb

for i in range(m):
    x = xyc[i][0]
    y = xyc[i][1]
    c = xyc[i][2]
    cost = min( cost, a[x-1] + b[y-1] - c )

print(cost)

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

int main() {
int n;
string s;
cin >> n >> s;
int t = n/2;
if(n % 2 == 0 && s.substr(0,t) == s.substr(t,t)){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
  
}

Measured memory_bytes: 256
MAX_ITEM = 4
NUM = 7

ABCD = [int(i) for i in list(input())]


def main():
    for i in range(2 ** (MAX_ITEM - 1)):
        ans = ABCD[0]

        for j in range(MAX_ITEM - 2, -1, -1):
            if i >> j & 1:
                ans += ABCD[j + 1]

            else:
                ans -= ABCD[j + 1]

        if NUM == ans:
            print("".join(
                ["+" if k % 2 and i >> k // 2 & 1 else
                 "-" if k % 2 else
                 str(ABCD[k // 2]) for k in range(2 * MAX_ITEM - 1)])
                + "=" + str(NUM))

            break

    return


main()


Measured memory_bytes: 3064
def readinput():
    a,b,x=list(map(int,input().split()))
    return a,b,x

def main(a,b,x):
    ans = b//x - (a-1)//x
    return ans

if __name__=='__main__':
    a,b,x=readinput()
    ans=main(a,b,x)
    print(ans)


Measured memory_bytes: 9180
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int n, m; cin >> n >> m;
	map <int, int> dic;
	int ACcount = 0;
	int WAcount = 0;
	rep(i, m){
		int p; string s; cin >> p >> s;
		if(s == "AC"){
			if(dic[p] == -1) continue;
			ACcount++;
			if(0 < dic[p]) WAcount += dic[p];
			dic[p] = -1;
		} else{
			if(dic[p] != -1) dic[p]++;
		}
	}

	cout << ACcount << " " << WAcount << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	int isp[100000] = {};
	vector<int> v;
	Rep(i, 2, 100000) {
		if (!isp[i]) {
			v.push_back(i);
			for(int j=2*i;j<100000;j+=i){
				isp[j] = 1;
			}
		}
	}
	int p, q; cin >> p >> q;
	int d = gcd(q,p);
	q /= d;
	int out = 1; int now = 0;
	while (q > 1) {
		if (q%v[now] == 0) {
			out*=v[now];
			while (q%v[now] == 0)q /= v[now];
		}
		else if (v[now] > (int)sqrt(q + 0.5)) {
			out *= q; q = 1;
		}
		else now++;
	}
	if (out == 1)out = 2;
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 3644