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

int64_t ans(int64_t H);

int main()
{
    int64_t H;
    cin >> H;
    cout << ans(H) << endl;
}

int64_t ans(int64_t H)
{
    if (H == 1)
    {
        return 1;
    }
    int64_t A = 1;
    A += 2 * ans(H / 2);
    return A;
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int d,n;
	cin>>d>>n;
	if(d==0){
		if(n!=100)
		cout<<n<<endl;
		else{
			cout<<101<<endl;
		}
	}
	else if(d==1){
		if(n!=100)
			cout<<100*n<<endl;
		else{
			cout<<101*100<<endl;
		}
	}
	else{
		if(n!=100)
			cout<<10000*n<<endl;
		else{
			cout<<101*10000<<endl;
		}
	}
}

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]

L, R = [], []
for i in range(N):
  L.append(gcd(L[i-1],A[i-1]) if i else 0)
  R.append(gcd(R[i-1],A[N-i]) if i else 0)
print(max([gcd(L[i],R[N-i-1]) for i in range(N)]))

Measured memory_bytes: 16148
#include<stdio.h>
int main()
{
    char s[10];
    int i,j,p;
    gets(s);
    p=strlen(s);
    for(i=0;i<p;i++)
    {
        if(i==3)
        {
            s[i]=s[i]+1;
        }
    }
    printf("%s\n",s);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int d[N];
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> d[i];
    sum+=d[i];
  }
  int answer=0;
  for(int i=0;i<N-1;i++){
    sum-=d[i];
    answer+=d[i]*sum;
  }
  cout << answer;
}
      

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

int main(){

	ios::sync_with_stdio(false);

	int a, b, ans;
	cin >> a >> b;
	
	if (a >12) ans =b;
	else if (a<=5) ans = 0;
	else ans = b/2;
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
vl divisor(ll n) {
	vl ret;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i != 1 && i * i != n) ret.push_back(n / i);
		}
	}
	ret.push_back(n);
	return ret;
}

int main() {
	cin >> N >> K;
	vl A(N);
	ll sum = 0;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	vl D = divisor(sum);
	sort(D.begin(), D.end());
	reverse(D.begin(), D.end());
	for (i = 0; i < D.size(); i++) {
		vl M;
		ll can = 1;
		for (j = 0; j < N; j++) {
			if (A[j] % D[i] != 0) {
				M.push_back(A[j] % D[i]);
			}
		}
		sort(M.begin(), M.end());
		ll L = M.size();
		if (L != 0) {
			vl P(L + 1), Q(L + 1);
			P[0] = 0; Q[0] = 0;
			for (j = 0; j < L; j++) {
				P[j + 1] = P[j] + M[j];
				Q[j + 1] = Q[j] + (D[i] - M[j]);
			}
			ll pre = INF;
			for (j = 0; j < L; j++) {
				if (P[j] == Q[L] - Q[j]) pre = min(pre, P[j]);
			}
			//debug(pre);
			if (pre > K) can = 0;
		}
		if (can) {
			cout << D[i];
			exit(0);
		}
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AB_Problem
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            Console.WriteLine("{0} {1} {2:f10}", (int)a / b, a % b, (double)a / b);
        }
    }
}


Measured memory_bytes: 9232
def main(input):
    Arr = []
    Arr = input.split()
    for i in range(5):
        Arr[i] = int(Arr[i])
    L = []
    L.append([0,0])
    L.append([Arr[0],Arr[1]])
    for i in range(0, 2, 1):
        for j in range(0,2,1):
            if((-1)**(i-1)*(L[i][j]-Arr[2+j]))<Arr[4]:
                print('No')
                return
    print("Yes")

main(input())

Measured memory_bytes: 7764
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXS 100000

int len;
char s[MAXS+5];

int main() {
	scanf("%s",s);
	len=strlen(s);
	if(s[0]==s[1]) {
		printf("1 2\n");
		return 0;
	}
	for(int i=2;i<len;i++) {
		if(s[i]==s[i-1]) {
			printf("%d %d\n",i,i+1);
			return 0;
		}
		if(s[i]==s[i-2]) {
			printf("%d %d\n",i-1,i+1);
			return 0;
		}
	}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  string s;
  cin >> s;
  int a = 0,b = 0,c = 0;
  rep(i,s.size()){
    if(s[i] == 'a')a++;
    else if(s[i] == 'b')b++;
    else c++;
  }
  if(max({a,b,c}) - min({a,b,c}) <= 1)puts("YES");
  else puts("NO");
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 200005;

int X[N];

int main() {
  int h,w,n;
  S2(h,w);
  S(n);
  rep(i,0,n) {
    int x,y;
    S2(x,y);
    if(!X[x] || y < X[x]) {
      X[x] = y;
    }
  }
  X[h + 1] = 1;
  if(h == 1) {
    P(1);
    return 0;
  }
  int mx = 0;
  rep(i,1,h+1) {
    if(X[i] != mx + 1) {
      mx++;
    }
    if(X[i + 1] && X[i + 1] <= mx) {
      P(i);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    ll H,A;
    cin >> H >> A;
    cout << (H + A - 1)/ A << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	a, b, c := strings.ToUpper(next()), strings.ToUpper(next()), strings.ToUpper(next())
	as, bs, cs := len(a), len(b), len(c)
	ai, bi, ci := 0, 0, 0
	cur := "A"
	for ;; {
		if cur == "A"{
			if ai == as{
				fmt.Fprint(out, cur)
				return
			}else{
				cur = string(a[ai])
				ai ++
			}
		}else if cur == "B"{
			if bi == bs{
				fmt.Fprint(out, cur)
				return
			}else{
				cur = string(b[bi])
				bi ++
			}
		}else if cur == "C"{
			if ci == cs{
				fmt.Fprint(out, cur)
				return
			}else{
				cur = string(c[ci])
				ci ++
			}
		}
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int64 {
	a, _ := strconv.Atoi(next())
	return int64(a)
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int64 {
	ret := make([]int64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}


Measured memory_bytes: 640
io = STDIN
$n=io.gets.to_i
a=io.gets.split.map(&:to_i)
def pp(a,max)
  ix=a.index(max)
  puts "#{ix.next} 1"
  (1..$n).each_cons(2){|i,j|puts "#{i} #{j}"}
end
def mm(a,min)
  ix=a.index(min)
  puts "#{ix.next} #{$n}"
  (1..$n).to_a.reverse.each_cons(2){|i,j|puts "#{i} #{j}"}
end
def max2all(a,max)
  ix=a.index(max)
  (1..$n).map{|i|puts "#{ix.next} #{i}"}
  a.map{|i|i+max}
end
def min2all(a,min)
  ix=a.index(min)
  (1..$n).map{|i|puts "#{ix.next} #{i}"}
  a.map{|i|i+min}
end
max,min=a.max,a.min
if min==max
  puts 0
elsif min>=0
  puts $n
  pp(a,max)
elsif max<=0
  puts $n
  mm(a,min)
elsif min.abs < max.abs
  puts 2*$n
  a=max2all(a,max)
  pp(a,a.max)
else
  puts 2*$n
  a=min2all(a,min)
  mm(a,a.min)
end


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

using namespace std;

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

  if ((s[0] == s[1] && s[1] == s[2]) ||
          (s[1] == s[2] && s[2] == s[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,d,ans = 0,i,j,a,b;cin >> m >> d;
  for(i=4;i<=m;i++){
    for(j=22;j<=d;j++){
      a = j/10;b = j%10;
      if(a < 2 || b < 2) continue;
      if(i==a*b) ans++;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  private final int MOD = (int) (1e9 + 7);

  private void solve(Scanner in, PrintWriter out) {
    int N = in.nextInt();
    int M = in.nextInt();
    char[] S = in.next().toCharArray();
    int[] right = new int[N];
    Arrays.fill(right, -1);
    for (int i = 0; i < M; i++) {
      int l = in.nextInt() - 1;
      int r = in.nextInt() - 1;
      if (right[l] < r) right[l] = r;
    }

    int max = 0;
    for (int i = 0; i < N; i++) {
      max = Math.max(max, i);
      max = Math.max(max, right[i]);
      right[i] = max;
    }

    int[] sum = new int[N];
    for (int i = 0; i < N; i++) sum[i] = S[i] - '0';
    for (int i = 0; i < N - 1; i++) sum[i + 1] += sum[i];

    long[][] dp = new long[N + 1][N + 1];
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
      for (int usedOne = 0; usedOne < N; usedOne++) {
        int r = right[i];
        int restOne = sum[r] - usedOne;
        if (restOne < 0) continue;

        if (restOne > 0)
          dp[i + 1][usedOne + 1] = (dp[i + 1][usedOne + 1] + dp[i][usedOne]) % MOD;

        if (r - i + 1 != restOne)
          dp[i + 1][usedOne] = (dp[i + 1][usedOne] + dp[i][usedOne]) % MOD;
      }
    }
    out.println(dp[N][sum[N - 1]]);
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(in, out);
    in.close();
    out.close();
  }
}


Measured memory_bytes: 105920
import sys
import heapq
input = sys.stdin.readline

N = int(input())

forward = []
backward = []

for _ in range(N):
    pos = 0
    Min = 0
    for c in input()[:-1]:
        if c == '(':
            pos += 1
        else:
            pos -= 1
            Min = min(Min, pos)
    if pos >= 0:
        heapq.heappush(forward, (-Min, pos))
    else:
        heapq.heappush(backward, (pos-Min, -pos))

ansflg = True
pos1 = 0
while forward:
    down, pos = heapq.heappop(forward)
    if pos1 >= down:
        pos1 += pos
    else:
        ansflg = False
        break

pos2 = 0
if ansflg:
    while backward:
        down, pos = heapq.heappop(backward)
        if pos2 >= down:
            pos2 += pos
        else:
            ansflg = False
            break

if pos1 != pos2:
    ansflg = False

if ansflg:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 170484
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, A, B := sc.nextInt(), sc.nextInt(), sc.nextInt()
	H := sc.nextIntSlice(N)
	sort.Reverse(sort.IntSlice(H))
	f := func(num int) bool {
		total := 0
		for i := 0; i < N; i++ {
			rest := max(H[i]-num*B, 0)
			if rest > 0 {
				total += ceil(rest, A-B)
			}
		}
		//fmt.Fprintln(wtr, num, total)
		return total <= num
	}
	l := 0
	r := int(1e+9)
	for abs(r-l) > 1 {
		mid := (r + l) / 2
		if f(mid) {
			r = mid
		} else {
			l = mid
		}
	}

	fmt.Fprintln(wtr, r)
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
const int N=2e5+5;
int n,k,i;
int a[N],p[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));
    cin>>n>>k;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    int j;
    for(j=1;j<=min(k,1000);j++){

    
    for(i=1;i<=n;i++){
        int l=max(1,i-a[i]);
        int r=min(n,i+a[i]);
        p[l]++;
        p[r+1]--;
    }
    for(i=2;i<=n;i++){
        p[i]+=p[i-1];
    }
    for(i=1;i<=n;i++){
        a[i]=p[i];
        p[i]=0;
    }
}
for(i=1;i<=n;i++){
    cout<<a[i]<<" ";
}
    return 0;

}

Measured memory_bytes: 5208
# if(true)

# include <iostream>

using Int = int;

int main()
{
    Int N; std::cin >> N;

    if      (N < 1200) std::cout << "ABC";
    else if (N < 2800) std::cout << "ARC";
    else               std::cout << "AGC";


    return 0;
}


# endif

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        
        Scanner input=new Scanner(System.in);
        
        int a=input.nextInt();
        int b=input.nextInt();
        
        
        int z=b-a;
        
        int sum=z*(z+1)/2;
        
        
//        int p=1;
//        for(int i=2;i<999;i++)
//        {
//            if(p+i)
//            
//            
//        
//        
//        }
            System.out.println(sum-b);
    }
    
}


Measured memory_bytes: 21972
#include<stdio.h>

int main(){

    int a, b;

    scanf("%d %d", &a, &b);

    if ( a < b ) {
        printf("a < b\n");
    } else if ( a > b ){
        printf("a > b\n");
    } else if ( a == b ){
        printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
ll gcd(ll a, ll b){
  return (b > 0) ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b){
  return a*b/gcd(a, b);
}
int main()
{
  ll A, B, C, D, ansA, ansP;
  cin >> A >> B >> C >> D;
  ansA = B-(B/C+B/D)+B/lcm(C, D);
  ansP = A-1-((A-1)/C+(A-1)/D)+(A-1)/lcm(C, D);
  cout << ansA-ansP << "\n";

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	if(abs(A-B)%2)//間のマスが偶数
	{
		puts("Borys");
	}
	else
	{
		puts("Alice");
	}
	return 0;
}

Measured memory_bytes: 128
/*
 * aoj/dpl_5_h/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, K;
void solve() {
  cin >> N >> K;
  if (N>K) {
    cout << 0 << endl;
    return;
  }

  cout << 1 << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}



Measured memory_bytes: 3104
#include <cstdio>
#include <cstring>
using namespace std;

int ans;
char buf[10000];

int main() {
  while (1) {
    if (scanf("%s", buf) != 1) break;

    int n = strlen(buf);
    int cur_num = 0;
    for (int i=0; i<n; i++) {
      char c = buf[i];
      if ('0' <= c && c <= '9') {
        cur_num = cur_num*10 + (c-'0');
      } else {
        ans += cur_num;
        cur_num = 0;
      }
    }

    ans += cur_num;
  }

  printf("%d\n", ans);
}

Measured memory_bytes: 2544
def main(argv)
  (a, b) = gets.chomp.split(' ')
  n = (a + b).to_i
  m = Math.sqrt(n).floor.to_i
  puts (((m ** 2) == n) ? 'Yes' : 'No')
end

if self.to_s === 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall

	ins(a);
	if(a == "AAA" or a == "BBB")out("No");
	else{
		out("Yes");
	}
	return 0 ;
}

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

using namespace std;

int main() {

    int n, num1, num2;
    string s;

    cin >> n;

    while(n--) {

        cin >> s;

        sort(&s[0], &s[0] + s.size());
        num1 = atoi(s.c_str());

        sort(&s[0], &s[0] + s.size(), greater<int>());
        num2 = atoi(s.c_str());

        cout << num2 - num1 << endl;

    }

}

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

int main() {
 string s,a,b,A,B;
  cin>>s;
  a=s.substr(0,(s.size()-1)/2);
  b=s.substr((s.size()+1)/2,(s.size()-1)/2);
  A=a;
  reverse(A.begin(),A.end());
 // cout<<A;
  
  B=b;
  reverse(B.begin(),B.end());
  if(a==b&&a==A&&b==B){
  cout<<"Yes";
  }
 else{
  cout<<"No";
 }
  

    
}


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

int main() {
	int power[10] = { 1,8,64,512,4096,32768,262144,2097152,16777216,134217728 };
	int a[8][8];
	int c[8][8];
	int b[8][2];
	int n;
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i][0] >> b[i][1];
	}
	for (int i = 0; i < 16777216; i++) {
		sum = 0;
		memset(a, 0, sizeof(a));
		for (int j = 0; j < 8; j++) {
			a[j][(i / power[j]) % 8] = 1;
			sum += (i / power[j]) % 8;
		}
		if (sum == 28) {
			for (int j = 0; j < 8; j++) {
				for (int k = 0; k < 8; k++) {
					if (a[j][k] == 1) {
						c[j][k] = 1;
					}
					else {
						c[j][k] = 0;
					}
				}
			}
			for (int j = 0; j < n; j++) {
				if (c[b[j][0]][b[j][1]] == 0) {
					goto Exit;
				}
			}
			for (int j = 0; j < 8; j++) {
				for (int k = 0; k < 8; k++) {
					if (c[j][k] == 1) {
						for (int l = 0; l < 8; l++) {
							if (c[j][l] == 1 && k!=l) {
								goto Exit;
							}
						}
						for (int l = 0; l < 8; l++) {
							if (c[l][k] == 1 && j!=l) {
								goto Exit;
							}
						}
						for (int l = -7; l < 8; l++) {
							if (j + l >= 0 && k - l >= 0 && j + l < 8 && k - l < 8) {
								if (c[j + l][k - l] == 1 && l != 0) {
									goto Exit;
								}
							}
						}
						for (int l = -7; l < 8; l++) {
							if (j + l >= 0 && k + l >= 0 && j + l < 8 && k + l < 8) {
								if (c[j + l][k + l] == 1 && l != 0) {
									goto Exit;
								}
							}
						}
					}
				}
			}
			goto Exit2;
		Exit:;
		}
	}
Exit2:;
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			if (c[i][j] == 1) {
				cout << 'Q';
			}
			else {
				cout << '.';
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
h = []

maxv = A[0] + B[0] + C[0]


def inv(v):
    return maxv - v


pushed = [[[] for _ in range(Y)] for _ in range(X)]
heappush(h, (0, 0, 0, 0))
for _ in range(K):
    invv, i, j, k = heappop(h)
    print(inv(invv))
    if i + 1 < X and k not in pushed[i + 1][j]:
        heappush(h, (inv(A[i + 1] + B[j] + C[k]), i + 1, j, k))
        pushed[i + 1][j].append(k)
    if j + 1 < Y and k not in pushed[i][j + 1]:
        heappush(h, (inv(A[i] + B[j + 1] + C[k]), i, j + 1, k))
        pushed[i][j + 1].append(k)
    if k + 1 < Z and k + 1 not in pushed[i][j]:
        heappush(h, (inv(A[i] + B[j] + C[k + 1]), i, j, k + 1))
        pushed[i][j].append(k + 1)


Measured memory_bytes: 88668
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		if(Math.abs(a-c)<=d || (Math.abs(a-b)<=d && Math.abs(b-c)<=d)){
		    System.out.println("Yes");
		}else{
		    System.out.println("No");
		}
	}
}


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

int main() {
  
  int N,T;
  cin >> N >> T;
  
  int a=1001, ans=1001;
  
  for (int i=0; i<N; i++) {
    int c,t;
    cin >> c >> t;
    if (t<=T) {
      a = min(a,c);
      if (a == c) ans = a;
    } else {
      continue;
    }
  }
  
  if (ans == 1001) cout << "TLE" << endl;
  else cout << ans << endl;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,t,n,b,c,d,a,l,r;
    cin>>n;
    vector<ll>v(n);
    for(i=0; i<n; i++)
        cin>>v[i];
    ll cnt=0;
    for(i=1; i<n; i++)
    {
        if(v[i-1]>v[i])
        {
            cnt+=abs(v[i]-v[i-1]);
            v[i]=v[i-1];
        }
    }
    cout<<cnt<<'\n';
}












Measured memory_bytes: 4764
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# inputb = input().split()
# inputbList = [int(x) for x in inputb]

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input().split()
#     inputNum = [int(x) for x in inputNum]
#     inputList.append(inputNum)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

numList = [-1, float(a)]

cnt = 1
flg = True
while cnt < 1000000 and flg == True:
    cnt += 1
    if numList[cnt-1] % 2 == 0:
        numList.append(float(numList[cnt -1] / 2))
    else:
        numList.append(float(3*numList[cnt-1] + 1))

    for i in range(1, cnt):
        if numList[i] == numList[cnt]:
            print(cnt)
            flg = False
            break


Measured memory_bytes: 3444
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
using namespace std;

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

	if (s[s.length() - 1] == 's') {
		cout << s << "es\n";
	}
	else {
		cout << s << "s\n";
	}
	
	return 0;
}

Measured memory_bytes: 3624
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for j in range(n):
  for i in range(j):
    if (k:=2*j-i)<n:
      if s[i]!=s[k]!=s[j]!=s[i]:
        ans-=1   
print(ans)

Measured memory_bytes: 9192
// Aizu Vol0 0056: Goldbach's Conjecture
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);

#define MAX  50000
#define SQRT 223     // sqrt(MAX)
#define HALF 25000

char table[MAX + 5];
int combi[MAX + MAX];

int main()
{
	int i, n;
	char buf[100];
	char *p, *p2, *pmax;
	int *q;
	
	pmax = table + MAX;
	for (p = table + 2, i = 2; i <= SQRT; p++, i++) {
		if (!*p) {
			for (p2 = p + i; p2 <= pmax; p2 += i) *p2 = 1;
		}
	}
	combi[4] = 1;
	for (p = table + 3, q = combi + 5; p < pmax; p+=2, q+=2) {
		if (!*p) *q = 1;
	}
	for (i = 3, p = table + 3; i < HALF; i+=2, p+=2) {
		if (!*p) {
			for (p2 = p, q = combi+i+i; p2 < pmax; p2+=2, q+=2) {
				if (!*p2) (*q)++;
			}
		}
	}
#if 0
	for (i = 2; i < 200; i++) printf("[%d]=%d\n", i, combi[i]);
#endif

	while (1) {
		gets(buf);
		n = atoi(buf);
		if (n == 0) break;
		printf("%d\n", combi[n]);
	}
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
ll sqr(ll a)
{
    return ((a % MOD) * (a % MOD)) % MOD;
}
ll msub(ll a, ll b)
{
    return ((a - b) % MOD + MOD) % MOD;
}
ll madd(ll a, ll b)
{
    return (a + b) % MOD;
}
ll mmul(ll a, ll b)
{
    return ((a % MOD) * (b % MOD)) % MOD;
}
int t;
int ok[N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n, m;
    cin >> n >> m;
    int h[n + 1];
    FOR(i, 1, n)
    {
        cin >> h[i];
        ok[i] = 1;
    }
    FOR(i, 1, m)
    {
        int x, y;
        cin >> x >> y;
        if(h[x] <= h[y]) ok[x] = 0;
        if(h[y] <= h[x]) ok[y] = 0;
    }
    int res = 0;
    FOR(i, 1, n)
    {
       // cout << ok[i] << " ";
        if(ok[i] == 1) res++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 4440
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine

x ? (a,b) = if x then a else b
main = do
 inputs <- readLnInt
 print $ solve inputs

solve inputs = count 1 inputs

count n (a:as) = (a==0)?(n,count (n+1) as)


Measured memory_bytes: 3652
n,m = map(int, input().split())
ks = []
for i in range(m):
    b = list(map(int, input().split()))
    ks.append(b)

p = list(map(int, input().split()))
ans = 0

for i in range(2**n):
    switch = [0]*n
    for j in range(n):
        if (i>>j)&1:
            switch[j] = 1
    flag = 0
    for j in range(m):
        count = 0

        for k in range(len(ks[j])-1):
            if switch[ks[j][k+1]-1]==1:
                count+=1
        
        if not count%2 ==p[j]:
            flag = 1
    
    if flag == 0:
        ans +=1

print(ans)

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int H;
	static int W;
	static int K;

	static boolean[][] c;

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		K = sc.nextInt();

		c  = new boolean[H][W];
		int blackNum = 0;

		for(int i = 0; i<H; i++) {
			String str = sc.next();
			for(int j = 0;j<W ; j++) {
				if(str.charAt(j)=='#') {
					blackNum++;

					c[i][j]=true;
				}
			}
		}

		ans =0;

		solve(new boolean[H+W], 0);


		System.out.println(ans);
	}



	static void solve(boolean[] lines, int idx) {
		if(idx == lines.length) {
			evaluate(lines);
			return;
		}else {
			lines[idx] = false;
			solve(lines, idx+1);
			lines[idx] = true;
			solve(lines, idx+1);
		}
		return;
	}

	static void evaluate(boolean[] lines) {
		boolean[][] tmp = new boolean[H][W];
		for(int i = 0;i<H ; i++) {
			for(int j = 0;j<W ; j++) {
				if(c[i][j]) {
					tmp[i][j]=true;
				}
			}
		}
		for(int i = 0;i<H ; i++) {
			if(lines[i]) {
				Arrays.fill(tmp[i], false);
			}
		}
		for(int i = H;i<W+H ; i++) {
			if(lines[i]) {
				for(int j = 0;j<H ; j++) {
					tmp[j][i-H] = false;
				}
			}
		}
		int tmpBlack = 0;
		for(int i = 0;i<H ; i++) {
			for(int j = 0;j<W ; j++) {
				if(tmp[i][j]) {
					tmpBlack++;
				}
			}
		}
		if(tmpBlack == K) {
			ans++;
		}
		return;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}
}


Measured memory_bytes: 38152
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#define ll long long
#define MOD 1000000007
using namespace std;

int main() {
    double n;
    cin>>n;
    for(int i=1;i<=50000;i++){
        if((int)(i*1.08)==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":(\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int a, b;
int i, j;
while(scanf("%d %d", &a, &b) != EOF) {
  if (a == 0 && b == 0) break;
  for (i = 0; i < a; i++){
    for (j = 0; j < b; j++){
      printf("#");
    }
    printf("\n");
  }
  printf("\n");
}

return 0;
}

Measured memory_bytes: 572
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
 
aa = [0]
bb = [0]
a.size.times{|i| aa << a[i] + aa.last }
b.size.times{|i| bb << b[i] + bb.last }
 
i = 0
j = b.size
mx = 0
while i < aa.size && j >= 0
  if aa[i] + bb[j] <= k
    mx = i+j if mx < i+j
 
    i += 1
  else
    j -= 1
  end
end
 
 
p mx

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

#define N 500000
#define INFINITY 1000000001
void merge(int [], int, int, int);
void mergeSort(int [], int, int);

int count=0;

int main(){
  int S[N];
  int n, i;

  scanf("%d", &n);
  if(n > N) exit(1);
  for(i=0; i<n; i++){
    scanf("%d", &S[i]);
    if(S[i] < 0 || S[i] > 1000000000) exit(1);
  }
  mergeSort(S, 0, n);
  for(i=0; i<n; i++){
    printf("%d",S[i]);
    if(i < n-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

void merge(int A[], int left, int mid, int right){
  int n1, n2, i, j, k;
  int *L, *R;
  
  n1 = mid - left;
  n2 = right - mid;
  L = malloc( (n1+1)*sizeof(int) );
  R = malloc( (n2+1)*sizeof(int) );
  for(i=0; i<=n1-1; i++) L[i] = A[left + i];
  for(j=0; j<=n2-1; j++) R[j] = A[mid + j];

  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i = 0;
  j = 0;
  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      count++;
    }
    else{
      A[k] = R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(int A[], int left, int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}



Measured memory_bytes: 5464
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

struct RSQ {
	int n;
	vector<int> t;
	RSQ(int s) : n(s + 1), t(n) {};
	int sum(int i) {
		int s = 0;
		for (;i > 0; i -= i & -i)
			s += t[i];
		return s;
	}
	int sum(int a, int b) {
		return sum(b) - sum(a - 1);
	}
	void add(int i, int v) {
		for (;i <= n; i += i & -i)
			t[i] += v;
	}
};

int main() {
	RSQ r(in());
	for (int q = in(); q; q--) {
		int o = in(), x = in(), y = in();
		if (o)
			outl(r.sum(x, y));
		else
			r.add(x, y);
	}
}


Measured memory_bytes: 2628
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mod 1000000007
using namespace std;
char block[1001][1001];
ll dp[1001][1001];
ll row,col; 
ll ans;

ll no_of_paths(ll r, ll c){
    dp[0][0]=1;
    for(int j=1;j<c;j++){
        if(block[0][j]=='#'){
            dp[0][j]=0;
        }
        else dp[0][j]=dp[0][j-1];
    }
    for(int i=1;i<r;i++){
        if(block[i][0]=='#'){
            dp[i][0]=0;
        }
        else dp[i][0]=dp[i-1][0];
    }
    
    for(int i=1;i<r;i++){
        for(int j=1;j<c;j++){
            dp[i][j]=(block[i][j]!='#') ?  (dp[i-1][j]+dp[i][j-1])%mod : 0;
        }
    }
    return dp[r-1][c-1];
}

int main(){
    cin>>row>>col;
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            dp[i][j]=-1;
        }
    }
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            cin>>block[i][j];
        }
    }
    
    cout<<no_of_paths(row,col);
}

Measured memory_bytes: 12436
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int to[MN<<2],nxt[MN<<2],h[MN],cnt;
inline void ins(int s,int t){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;
}
int n,m,pre[MN];
queue<int>q;
int main(){
	scanf("%d%d",&n,&m);
	for(reg int i=1,s,t;i<=m;i++)
		scanf("%d%d",&s,&t),ins(s,t);
	q.push(1);pre[1]=1;
	while(!q.empty()){
		reg int v=q.front();q.pop();
		for(reg int i=h[v];i;i=nxt[i])
			if(!pre[to[i]])pre[to[i]]=v,q.push(to[i]);
	}
	puts("Yes");
	for(reg int i=2;i<=n;i++)printf("%d\n",pre[i]);
	return 0;
}

Measured memory_bytes: 7696
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (0 <= s - i - j && s - i - j <= k) {
        cnt++;
      }
    }
  }

  D(cnt);
 
  return 0;
}



Measured memory_bytes: 256
days = N = int(input())

happiness =  []
for _ in range(N):
    h =  list(map(int , input().split(' ')))
    #print(h)
    happiness.append(h)
    #print(happiness)

# N=  3
# happiness = [[10, 40, 70], 
#             [20, 50, 80], 
#          [30, 60, 90]]

# N=  1
# happiness = [[100, 10, 1]]


#print('dd',happiness)
dp=[]
for _ in range(N):
    dp.append([0,0,0])

# dp = [ [0]*3]*N
#print(dp)

dp[0] = happiness[0]
for index in range(1,len(happiness)):
    #print(dp)
    for acivity in [0,1,2]:
        if acivity ==0:
            max_h =  max(dp[index-1][1],dp[index-1][2])
            dp[index][0] = happiness[index][0]+ max_h
            #print(f'acivity:{acivity},index:{index} , dp:{dp}')

        elif acivity ==1:

            max_h =  max(dp[index-1][2],dp[index-1][0])
            dp[index][1] = happiness[index][1]+ max_h
            #print(f'acivity:{acivity},index:{index} , dp:{dp}')
         
        elif acivity ==2:
            max_h =  max(dp[index-1][1],dp[index-1][0])
            dp[index][2] = happiness[index][2]+ max_h
            #print(f'acivity:{acivity},index:{index} , dp:{dp}')
print(max(dp[N-1]))



Measured memory_bytes: 47344
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    for (int i=0;i<5;i++)
    {
        int x;
        cin>>x;
        if (x==0)
        {
            cout<<i+1;
            return 0;
        }
    }


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 3544
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int k[n];
    rep(i,n){
        cin >> k[i];
        sum += k[i];
    }
    sort(k,k+n);
    int a = k[n-1];
    cout << sum - a/2<< endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T>
void warshall_floyd(vector< vector<T> >& d)
{
   int N = d.size();
   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
         }
      }
   }
}

signed main()
{
   int n; cin >> n;
   V<int> a(n), b(n);
   for (int i = 0; i < n; i++) cin >> a[i];
   for (int i = 0; i < n; i++) cin >> b[i];
   const int MAX_N = 50;

   V<int> ans;
   for (int k = MAX_N; k >= 0; k--) {

      V<V<int>> d(MAX_N+1, V<int>(MAX_N+1, INF));
      for (int v = 0; v <= MAX_N; v++) {
         d[v][v] = 0;
      }
      for (int i = 1; i <= k; i++) {
         for (int v = 0; v <= MAX_N; v++) {
            d[v][v % i] = 0;
         }
      }
      for (auto i : ans) {
         for (int v = 0; v <= MAX_N; v++) {
            d[v][v % i] = 0;
         }
      }
      warshall_floyd(d);
      bool flag = true;
      for (int i = 0; i < n; i++) {
         if (d[a[i]][b[i]] != 0) {
            flag = false;
            break;
         }
      }
      if (!flag) {
         if (k == MAX_N) {
            cout << -1 << endl;
            return 0;
         }
         ans.push_back(k+1);
      }

   }

   int sum = 0;
   for (auto i : ans) {
      sum += 1LL<<i;
   }
   cout << sum << endl;

   return 0;
}


Measured memory_bytes: 384
s=list(input())
part=list(input())

def check(s1,s2):
    for a,b in zip(s1,s2):
        if not (a==b or a=='?'):
            return False
    else:
        return True
find=[]
for i in range(len(s)-len(part)+1):
    if check(s[i:i+len(part)], part):
        find.append(i)
if len(find)!=0:
    s[find[-1]:find[-1]+len(part)]=part
    print(''.join([c if c!='?' else 'a'for c in s]))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064